Changeset 120
- Timestamp:
- 07/26/07 20:06:38 (1 year ago)
- Files:
-
- trunk/examples/testdll/testdll.d (modified) (2 diffs)
- trunk/infrastructure/meta/Demangle.d (modified) (25 diffs)
- trunk/infrastructure/pyd/class_wrap.d (modified) (11 diffs)
- trunk/infrastructure/pyd/def.d (modified) (5 diffs)
- trunk/infrastructure/pyd/func_wrap.d (modified) (2 diffs)
- trunk/infrastructure/pyd/lib_abstract.d (modified) (1 diff)
- trunk/infrastructure/pyd/make_object.d (modified) (4 diffs)
- trunk/infrastructure/pyd/make_wrapper.d (modified) (1 diff)
- trunk/infrastructure/pyd/struct_wrap.d (modified) (2 diffs)
- trunk/infrastructure/python/python.d (modified) (54 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/testdll/testdll.d
r118 r120 13 13 } 14 14 15 char[]bar(int i) {15 string bar(int i) { 16 16 if (i > 10) { 17 17 return "It's greater than 10!"; … … 21 21 } 22 22 23 void baz(int i=10, char[]s="moo") {23 void baz(int i=10, string s="moo") { 24 24 writefln("i = %s\ns = %s", i, s); 25 25 } trunk/infrastructure/meta/Demangle.d
r40 r120 29 29 * Pretty-prints a mangled type string. 30 30 */ 31 template demangleType( char[]str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName)31 template demangleType(string str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 32 32 { 33 33 static if (wantQualifiedNames != MangledNameType.PrettyName) { … … 70 70 // split these off because they're numerous and simple 71 71 // Note: For portability, could replace "v" with void.mangleof, etc. 72 template demangleBasicType( char []str)72 template demangleBasicType(string str) 73 73 { 74 74 static if (str == "v") const char [] demangleBasicType = "void"; … … 106 106 } 107 107 108 template demangleTypeConsumed( char []str)108 template demangleTypeConsumed(string str) 109 109 { 110 110 static if (str[0]=='A') … … 132 132 133 133 // For static arrays, count number of digits used (eg, return 3 for "674") 134 template countLeadingDigits( char []str)134 template countLeadingDigits(string str) 135 135 { 136 136 static if (str.length>0 && beginsWithDigit!( str)) … … 147 147 // (this happens with templates, when the name being 'lengthed' is itself an Lname). 148 148 // We guard against this by ensuring that the L is less than the length of the string. 149 template getLname( char []str)149 template getLname(string str) 150 150 { 151 151 static if (str.length <= 9+1 || !beginsWithDigit!(str[1..$]) ) … … 163 163 // Deal with the case where an Lname contains an embedded "__D". 164 164 // This can happen when classes, typedefs, etc are declared inside a function. 165 template pretty_Dname( char []str, int dotnameconsumed, MangledNameType wantQualifiedNames)165 template pretty_Dname(string str, int dotnameconsumed, MangledNameType wantQualifiedNames) 166 166 { 167 167 static if ( isMangledFunction!( (str[2+dotnameconsumed]))) { … … 181 181 // Deal with the case where an Lname contains an embedded ("__D") function. 182 182 // Split into a seperate function because it's so complicated. 183 template pretty_Dfunction( char []str, int dotnameconsumed, int paramlistconsumed,183 template pretty_Dfunction(string str, int dotnameconsumed, int paramlistconsumed, 184 184 MangledNameType wantQualifiedNames) 185 185 { … … 203 203 204 204 // for an Lname that begins with "_D" 205 template get_DnameConsumed( char []str)205 template get_DnameConsumed(string str) 206 206 { 207 207 const int get_DnameConsumed = 2 + getQualifiedNameConsumed!(str[2..$]) … … 210 210 211 211 // If Lname is a template, shows it as a template 212 template prettyLname( char []str, MangledNameType wantQualifiedNames)212 template prettyLname(string str, MangledNameType wantQualifiedNames) 213 213 { 214 214 static if (str.length>3 && str[0..3] == "__T") // Template instance name … … 231 231 // str must start with an lname: first chars give the length 232 232 // how many chars are taken up with length digits + the name itself 233 template getLnameConsumed( char []str)233 template getLnameConsumed(string str) 234 234 { 235 235 static if (str.length==0) … … 245 245 } 246 246 247 template getQualifiedName( char [] str, MangledNameType wantQualifiedNames, char []dotstr = "")247 template getQualifiedName(string str, MangledNameType wantQualifiedNames, string dotstr = "") 248 248 { 249 249 static if (str.length==0) const char [] getQualifiedName=""; … … 269 269 } 270 270 271 template getQualifiedNameConsumed ( char []str)271 template getQualifiedNameConsumed (string str) 272 272 { 273 273 static if ( str.length>1 && beginsWithDigit!(str) ) { … … 290 290 * or "function " or "delegate " 291 291 */ 292 template demangleFunctionOrDelegate( char [] str, char []funcOrDelegStr, MangledNameType wantQualifiedNames)292 template demangleFunctionOrDelegate(string str, string funcOrDelegStr, MangledNameType wantQualifiedNames) 293 293 { 294 294 const char [] demangleFunctionOrDelegate = demangleExtern!(( str[0] )) … … 301 301 // Special case: types that are in function parameters 302 302 // For function parameters, the type can also contain 'lazy', 'out' or 'inout'. 303 template demangleFunctionParamType( char[]str, MangledNameType wantQualifiedNames)303 template demangleFunctionParamType(string str, MangledNameType wantQualifiedNames) 304 304 { 305 305 static if (str[0]=='L') … … 313 313 314 314 // Deal with 'out' and 'inout' parameters 315 template demangleFunctionParamTypeConsumed( char[]str)315 template demangleFunctionParamTypeConsumed(string str) 316 316 { 317 317 static if (str[0]=='K' || str[0]=='J' || str[0]=='L') … … 338 338 // Skip through the string until we find the return value. It can either be Z for normal 339 339 // functions, or Y for vararg functions. 340 template demangleReturnValue( char []str, MangledNameType wantQualifiedNames)340 template demangleReturnValue(string str, MangledNameType wantQualifiedNames) 341 341 { 342 342 static assert(str.length>=1, "Demangle error(Function): No return value found"); … … 347 347 348 348 // Stop when we get to the return value 349 template demangleParamList( char [] str, MangledNameType wantQualifiedNames, char[]commastr = "")349 template demangleParamList(string str, MangledNameType wantQualifiedNames, string commastr = "") 350 350 { 351 351 static if (str[0] == 'Z') … … 362 362 363 363 // How many characters are used in the parameter list and return value 364 template demangleParamListAndRetValConsumed( char []str)364 template demangleParamListAndRetValConsumed(string str) 365 365 { 366 366 static assert (str.length>0, "Demangle error(ParamList): No return value found"); … … 376 376 // TEMPLATES 377 377 378 template templateValueArgConsumed( char []str)378 template templateValueArgConsumed(string str) 379 379 { 380 380 static if (str[0]=='n') const int templateValueArgConsumed = 1; … … 387 387 388 388 // pretty-print a template value argument. 389 template prettyValueArg( char []str)389 template prettyValueArg(string str) 390 390 { 391 391 static if (str[0]=='n') const char [] prettyValueArg = "null"; … … 398 398 399 399 // Pretty-print a template argument 400 template prettyTemplateArg( char []str, MangledNameType wantQualifiedNames)400 template prettyTemplateArg(string str, MangledNameType wantQualifiedNames) 401 401 { 402 402 static if (str[0]=='S') // symbol name … … 411 411 } 412 412 413 template templateArgConsumed( char []str)413 template templateArgConsumed(string str) 414 414 { 415 415 static if (str[0]=='S') // symbol name … … 425 425 // Like function parameter lists, template parameter lists also end in a Z, 426 426 // but they don't have a return value at the end. 427 template prettyTemplateArgList( char [] str, MangledNameType wantQualifiedNames, char []commastr="")427 template prettyTemplateArgList(string str, MangledNameType wantQualifiedNames, string commastr="") 428 428 { 429 429 static if (str[0]=='Z') … … 435 435 } 436 436 437 template templateArgListConsumed( char []str)437 template templateArgListConsumed(string str) 438 438 { 439 439 static assert(str.length>0, "No Z found at end of template argument list"); … … 452 452 * it allows us to avoid the ugly double parentheses. 453 453 */ 454 template beginsWithDigit( char []s)454 template beginsWithDigit(string s) 455 455 { 456 456 static if (s[0]>='0' && s[0]<='9') trunk/infrastructure/pyd/class_wrap.d
r118 r120 276 276 mixin _Def!(fn, symbolnameof!(fn), typeof(&fn), ""); 277 277 } 278 struct Def(alias fn, char[]docstring) {278 struct Def(alias fn, string docstring) { 279 279 mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), typeof(&fn)/+, minArgs!(fn)+/, docstring); 280 280 } 281 struct Def(alias fn, char[] name, char[]docstring) {281 struct Def(alias fn, string name, string docstring) { 282 282 mixin _Def!(fn, /*symbolnameof!(fn),*/ name, typeof(&fn)/+, minArgs!(fn)+/, docstring); 283 283 } 284 struct Def(alias fn, char[]name, fn_t) {284 struct Def(alias fn, string name, fn_t) { 285 285 mixin _Def!(fn, /*symbolnameof!(fn),*/ name, fn_t/+, minArgs!(fn)+/, ""); 286 286 } … … 288 288 mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), fn_t/+, minArgs!(fn)+/, ""); 289 289 } 290 struct Def(alias fn, fn_t, char[]docstring) {290 struct Def(alias fn, fn_t, string docstring) { 291 291 mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), fn_t/+, minArgs!(fn)+/, docstring); 292 292 } 293 struct Def(alias fn, char[] name, fn_t, char[]docstring) {293 struct Def(alias fn, string name, fn_t, string docstring) { 294 294 mixin _Def!(fn, /*symbolnameof!(fn),*/ name, fn_t/+, minArgs!(fn)+/, docstring); 295 295 } 296 296 /+ 297 template Def(alias fn, char[] name, fn_t, uint MIN_ARGS=minArgs!(fn)/+, char[]docstring=""+/) {297 template Def(alias fn, string name, fn_t, uint MIN_ARGS=minArgs!(fn)/+, string docstring=""+/) { 298 298 alias Def!(fn, /*symbolnameof!(fn),*/ name, fn_t, MIN_ARGS/+, docstring+/) Def; 299 299 } 300 300 +/ 301 template _Def(alias fn, /* char[] _realname,*/ char[] name, fn_t/+, uint MIN_ARGS=minArgs!(fn)+/, char[]docstring) {301 template _Def(alias fn, /*string _realname,*/ string name, fn_t/+, uint MIN_ARGS=minArgs!(fn)+/, string docstring) { 302 302 //static const type = ParamType.Def; 303 303 alias fn func; … … 336 336 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), typeof(&fn), minArgs!(fn), ""); 337 337 } 338 struct StaticDef(alias fn, char[]docstring) {338 struct StaticDef(alias fn, string docstring) { 339 339 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), typeof(&fn), minArgs!(fn), docstring); 340 340 } 341 struct StaticDef(alias _fn, char[] name, char[]docstring) {341 struct StaticDef(alias _fn, string name, string docstring) { 342 342 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, typeof(&fn), minArgs!(fn), docstring); 343 343 } 344 struct StaticDef(alias _fn, char[] name, fn_t, char[]docstring) {344 struct StaticDef(alias _fn, string name, fn_t, string docstring) { 345 345 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, minArgs!(fn), docstring); 346 346 } … … 348 348 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), fn_t, minArgs!(fn), ""); 349 349 } 350 struct StaticDef(alias _fn, fn_t, char[]docstring) {350 struct StaticDef(alias _fn, fn_t, string docstring) { 351 351 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), fn_t, minArgs!(fn), docstring); 352 352 } 353 struct StaticDef(alias _fn, char[]name, fn_t) {353 struct StaticDef(alias _fn, string name, fn_t) { 354 354 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, minArgs!(fn), ""); 355 355 } 356 struct StaticDef(alias _fn, char[]name, fn_t, uint MIN_ARGS) {356 struct StaticDef(alias _fn, string name, fn_t, uint MIN_ARGS) { 357 357 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, MIN_ARGS, ""); 358 358 } 359 struct StaticDef(alias _fn, char[] name, fn_t, uint MIN_ARGS, char[]docstring) {359 struct StaticDef(alias _fn, string name, fn_t, uint MIN_ARGS, string docstring) { 360 360 mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, MIN_ARGS, docstring); 361 361 } 362 template _StaticDef(alias fn,/+ char[] _realname,+/ char[] name, fn_t, uint MIN_ARGS, char[]docstring) {362 template _StaticDef(alias fn,/+ string _realname,+/ string name, fn_t, uint MIN_ARGS, string docstring) { 363 363 //static const type = ParamType.StaticDef; 364 364 alias fn func; … … 397 397 mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), false, ""); 398 398 } 399 struct Property(alias fn, char[]docstring) {399 struct Property(alias fn, string docstring) { 400 400 mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), false, docstring); 401 401 } 402 struct Property(alias fn, char[] name, char[]docstring) {402 struct Property(alias fn, string name, string docstring) { 403 403 mixin _Property!(fn, symbolnameof!(fn), name, false, docstring); 404 404 } 405 struct Property(alias fn, char[]name, bool RO) {405 struct Property(alias fn, string name, bool RO) { 406 406 mixin _Property!(fn, symbolnameof!(fn), name, RO, ""); 407 407 } 408 struct Property(alias fn, char[] name, bool RO, char[]docstring) {408 struct Property(alias fn, string name, bool RO, string docstring) { 409 409 mixin _Property!(fn, symbolnameof!(fn), name, RO, docstring); 410 410 } … … 412 412 mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), RO, ""); 413 413 } 414 struct Property(alias fn, bool RO, char[]docstring) {414 struct Property(alias fn, bool RO, string docstring) { 415 415 mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), RO, docstring); 416 416 } 417 template _Property(alias fn, char[] _realname, char[] name, bool RO, char[]docstring) {417 template _Property(alias fn, string _realname, string name, bool RO, string docstring) { 418 418 alias property_parts!(fn).getter_type get_t; 419 419 alias property_parts!(fn).setter_type set_t; … … 545 545 iterator. 546 546 */ 547 struct AltIter(alias fn, char[]name = symbolnameof!(fn), iter_t = ParameterTypeTuple!(fn)[0]) {547 struct AltIter(alias fn, string name = symbolnameof!(fn), iter_t = ParameterTypeTuple!(fn)[0]) { 548 548 static const bool needs_shim = false; 549 549 static void call(T) () { … … 564 564 } /*Pyd_with_StackThreads*/ 565 565 566 void wrap_class(T, Params...) ( char[] docstring="", char[]modulename="") {566 void wrap_class(T, Params...) (string docstring="", string modulename="") { 567 567 _wrap_class!(T, symbolnameof!(T), Params).wrap_class(docstring, modulename); 568 568 } … … 572 572 } 573 573 +/ 574 template _wrap_class(_T, char[]name, Params...) {574 template _wrap_class(_T, string name, Params...) { 575 575 static if (is(_T == class)) { 576 576 pragma(msg, "wrap_class: " ~ name); … … 587 587 alias _T* T; 588 588 } 589 void wrap_class( char[] docstring="", char[]modulename="") {589 void wrap_class(string docstring="", string modulename="") { 590 590 pragma(msg, "shim.mangleof: " ~ shim_class.mangleof); 591 591 alias wrapped_class_type!(T) type; … … 603 603 604 604 assert(Pyd_Module_p(modulename) !is null, "Must initialize module before wrapping classes."); 605 char[]module_name = toString(python.PyModule_GetName(Pyd_Module_p(modulename)));605 string module_name = toString(python.PyModule_GetName(Pyd_Module_p(modulename))); 606 606 607 607 ////////////////// trunk/infrastructure/pyd/def.d
r100 r120 36 36 ]; 37 37 38 private PyMethodDef[][ char[]] module_methods;39 private PyObject*[ char[]] pyd_modules;38 private PyMethodDef[][string] module_methods; 39 private PyObject*[string] pyd_modules; 40 40 41 private void ready_module_methods( char[]modulename) {41 private void ready_module_methods(string modulename) { 42 42 PyMethodDef empty; 43 43 if (!(modulename in module_methods)) { … … 47 47 } 48 48 49 PyObject* Pyd_Module_p( char[]modulename="") {49 PyObject* Pyd_Module_p(string modulename="") { 50 50 PyObject** m = modulename in pyd_modules; 51 51 if (m is null) return null; … … 85 85 *It's greater than 10!) 86 86 */ 87 void def(alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (char[]docstring="") {87 void def(alias fn, string name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (string docstring="") { 88 88 def!("", fn, name, fn_t, MIN_ARGS)(docstring); 89 89 } 90 90 91 void def( char[] modulename, alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (char[]docstring) {91 void def(string modulename, alias fn, string name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (string docstring) { 92 92 pragma(msg, "def: " ~ name); 93 93 PyMethodDef empty; … … 102 102 } 103 103 104 char[]pyd_module_name;104 string pyd_module_name; 105 105 106 106 /** 107 107 * Module initialization function. Should be called after the last call to def. 108 108 */ 109 PyObject* module_init( char[]docstring="") {109 PyObject* module_init(string docstring="") { 110 110 //_loadPythonSupport(); 111 char[]name = pyd_module_name;111 string name = pyd_module_name; 112 112 ready_module_methods(""); 113 113 pyd_modules[""] = Py_InitModule3((name ~ \0).ptr, module_methods[""].ptr, (docstring ~ \0).ptr); … … 118 118 * Module initialization function. Should be called after the last call to def. 119 119 */ 120 PyObject* add_module( char[] name, char[]docstring="") {120 PyObject* add_module(string name, string docstring="") { 121 121 ready_module_methods(name); 122 122 pyd_modules[name] = Py_InitModule3((name ~ \0).ptr, module_methods[name].ptr, (docstring ~ \0).ptr); trunk/infrastructure/pyd/func_wrap.d
r113 r120 59 59 } 60 60 61 void setWrongArgsError(int gotArgs, uint minArgs, uint maxArgs, char[]funcName="") {61 void setWrongArgsError(int gotArgs, uint minArgs, uint maxArgs, string funcName="") { 62 62 char[] str; 63 63 if (funcName == "") { … … 238 238 return null; 239 239 } 240 fn_to_dg!(fn_t) dg = dg_wrapper!(C, fn_t)(instance, &real_fn);240 fn_to_dg!(fn_t) dg = dg_wrapper!(C, fn_t)(instance, cast(fn_t)&real_fn); 241 241 return pyApplyToDelegate(dg, args); 242 242 }); trunk/infrastructure/pyd/lib_abstract.d
r110 r120 42 42 } 43 43 } else { 44 char[]objToStr(Object o) {44 string objToStr(Object o) { 45 45 return o.toString(); 46 46 } 47 public import meta.Nameof : symbolnameof, prettytypeof, prettynameof; 47 template symbolnameof(alias symbol) { 48 static if (is(typeof(symbol) == function)) { 49 const char[] symbolnameof = (&symbol).stringof[2 .. $]; 50 } else { 51 const char[] symbolnameof = symbol.stringof; 52 } 53 } 54 public import meta.Nameof : /*symbolnameof,*/ prettytypeof, prettynameof; 48 55 49 56 public import std.string : toString; trunk/infrastructure/pyd/make_object.d
r114 r120 152 152 } else static if (is(T : cdouble)) { 153 153 return PyComplex_FromDoubles(t.re, t.im); 154 } else static if (is(T : char[])) {154 } else static if (is(T : string)) { 155 155 return PyString_FromString((t ~ \0).ptr); 156 156 } else static if (is(T : wchar[])) { … … 279 279 */ 280 280 class PydConversionException : Exception { 281 this( char[]msg) { super(msg); }281 this(string msg) { super(msg); } 282 282 } 283 283 … … 353 353 return temp; 354 354 +/ 355 } else static if (is(string : T)) { 356 const(char)* result; 357 PyObject* repr; 358 // If it's a string, convert it 359 if (PyString_Check(o) || PyUnicode_Check(o)) { 360 result = PyString_AsString(o); 361 // If it's something else, convert its repr 362 } else { 363 repr = PyObject_Repr(o); 364 if (repr is null) handle_exception(); 365 result = PyString_AsString(repr); 366 Py_DECREF(repr); 367 } 368 if (result is null) handle_exception(); 369 return .toString(result); 355 370 } else static if (is(char[] : T)) { 356 c har* result;371 const(char)* result; 357 372 PyObject* repr; 358 373 // If it's a string, convert it … … 440 455 // Pull out the name of the type of this Python object, and the 441 456 // name of the D type. 442 char[]py_typename, d_typename;457 string py_typename, d_typename; 443 458 PyObject* py_type, py_type_str; 444 459 py_type = PyObject_Type(o); trunk/infrastructure/pyd/make_wrapper.d
r118 r120 114 114 } 115 115 } 116 template __pyd_get_overload( char[]realname, fn_t) {117 ReturnType!(fn_t) func(T ...) ( char[]name, T t) {116 template __pyd_get_overload(string realname, fn_t) { 117 ReturnType!(fn_t) func(T ...) (string name, T t) { 118 118 PyObject* _pyobj = this.__pyd_get_pyobj(); 119 119 if (_pyobj !is null) { trunk/infrastructure/pyd/struct_wrap.d
r118 r120 37 37 // as a template parameter, rather than the struct type itself. 38 38 39 template wrapped_member(T, char[]name, _M=void) {39 template wrapped_member(T, string name, _M=void) { 40 40 alias wrapped_class_type!(T) type; 41 41 alias wrapped_class_object!(T) obj; … … 63 63 } 64 64 65 struct Member( char[]realname) {65 struct Member(string realname) { 66 66 mixin _Member!(realname, realname, ""); 67 67 } 68 struct Member( char[] realname, char[]docstring) {68 struct Member(string realname, string docstring) { 69 69 mixin _Member!(realname, realname, docstring); 70 70 } 71 struct Member( char[] realname, char[] name, char[]docstring) {71 struct Member(string realname, string name, string docstring) { 72 72 mixin _Member!(realname, name, docstring); 73 73 } 74 template _Member( char[] realname, char[] name, char[]docstring) {74 template _Member(string realname, string name, string docstring) { 75 75 static const bool needs_shim = false; 76 76 static void call(T) () { trunk/infrastructure/python/python.d
r119 r120 61 61 } 62 62 63 version (D_Version2) { 64 alias const(char)* c_str; 65 } else { 66 alias char* c_str; 67 } 68 63 69 /* 64 70 * Py_ssize_t is defined as a signed type which is 8 bytes on X86_64 and 4 … … 137 143 alias int (*getwritebufferproc)(PyObject *, int, void **); 138 144 alias int (*getsegcountproc)(PyObject *, int *); 139 alias int (*getcharbufferproc)(PyObject *, int, c har **);145 alias int (*getcharbufferproc)(PyObject *, int, c_str*); 140 146 // ssize_t-based buffer interface 141 147 alias Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); 142 148 alias Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); 143 149 alias Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); 144 alias Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, c har **);150 alias Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, c_str*); 145 151 146 152 alias int (*objobjproc)(PyObject *, PyObject *); … … 226 232 alias void (*destructor)(PyObject *); 227 233 alias int (*printfunc)(PyObject *, FILE *, int); 228 alias PyObject *(*getattrfunc)(PyObject *, c har *);234 alias PyObject *(*getattrfunc)(PyObject *, c_str); 229 235 alias PyObject *(*getattrofunc)(PyObject *, PyObject *); 230 alias int (*setattrfunc)(PyObject *, c har *, PyObject *);236 alias int (*setattrfunc)(PyObject *, c_str, PyObject *); 231 237 alias int (*setattrofunc)(PyObject *, PyObject *, PyObject *); 232 238 alias int (*cmpfunc)(PyObject *, PyObject *); … … 245 251 mixin PyObject_VAR_HEAD; 246 252 247 c har *tp_name;253 c_str tp_name; 248 254 Py_ssize_t tp_basicsize, tp_itemsize; 249 255 … … 269 275 C_long tp_flags; 270 276 271 c har *tp_doc;277 c_str tp_doc; 272 278 273 279 traverseproc tp_traverse; … … 362 368 PyObject * PyObject_RichCompare(PyObject *, PyObject *, int); 363 369 int PyObject_RichCompareBool(PyObject *, PyObject *, int); 364 PyObject * PyObject_GetAttrString(PyObject *, c har *);365 int PyObject_SetAttrString(PyObject *, c har *, PyObject *);366 int PyObject_HasAttrString(PyObject *, c har *);370 PyObject * PyObject_GetAttrString(PyObject *, c_str); 371 int PyObject_SetAttrString(PyObject *, c_str, PyObject *); 372 int PyObject_HasAttrString(PyObject *, c_str); 367 373 PyObject * PyObject_GetAttr(PyObject *, PyObject *); 368 374 int PyObject_SetAttr(PyObject *, PyObject *, PyObject *); … … 542 548 543 549 int PyUnicodeUCS2_Resize(PyObject **unicode, Py_ssize_t length); 544 PyObject *PyUnicodeUCS2_FromEncodedObject(PyObject *obj, c har *encoding, char *errors);550 PyObject *PyUnicodeUCS2_FromEncodedObject(PyObject *obj, c_str encoding, c_str errors); 545 551 PyObject *PyUnicodeUCS2_FromObject(PyObject *obj); 546 552 … … 550 556 PyObject *PyUnicodeUCS2_FromOrdinal(int ordinal); 551 557 552 PyObject *_PyUnicodeUCS2_AsDefaultEncodedString(PyObject *, c har *);553 554 c har *PyUnicodeUCS2_GetDefaultEncoding();555 int PyUnicodeUCS2_SetDefaultEncoding(c har *encoding);556 557 PyObject *PyUnicodeUCS2_Decode(c har *s, Py_ssize_t size, char *encoding, char *errors);558 PyObject *PyUnicodeUCS2_Encode(Py_UNICODE *s, Py_ssize_t size, c har *encoding, char *errors);559 PyObject *PyUnicodeUCS2_AsEncodedObject(PyObject *unicode, c har *encoding, char *errors);560 PyObject *PyUnicodeUCS2_AsEncodedString(PyObject *unicode, c har *encoding, char *errors);561 562 PyObject *PyUnicodeUCS2_DecodeUTF7(c har *string, Py_ssize_t length, char *errors);558 PyObject *_PyUnicodeUCS2_AsDefaultEncodedString(PyObject *, c_str); 559 560 c_str PyUnicodeUCS2_GetDefaultEncoding(); 561 int PyUnicodeUCS2_SetDefaultEncoding(c_str encoding); 562 563 PyObject *PyUnicodeUCS2_Decode(c_str s, Py_ssize_t size, c_str encoding, c_str errors); 564 PyObject *PyUnicodeUCS2_Encode(Py_UNICODE *s, Py_ssize_t size, c_str encoding, c_str errors); 565 PyObject *PyUnicodeUCS2_AsEncodedObject(PyObject *unicode, c_str encoding, c_str errors); 566 PyObject *PyUnicodeUCS2_AsEncodedString(PyObject *unicode, c_str encoding, c_str errors); 567 568 PyObject *PyUnicodeUCS2_DecodeUTF7(c_str s, Py_ssize_t length, c_str errors); 563 569 PyObject *PyUnicodeUCS2_EncodeUTF7(Py_UNICODE *data, Py_ssize_t length, 564 int encodeSetO, int encodeWhiteSpace, c har *errors570 int encodeSetO, int encodeWhiteSpace, c_str errors 565 571 ); 566 572 567 PyObject *PyUnicodeUCS2_DecodeUTF8(c har *string, Py_ssize_t length, char *errors);568 PyObject *PyUnicodeUCS2_DecodeUTF8Stateful(c har *string, Py_ssize_t length,569 c har *errors, Py_ssize_t *consumed573 PyObject *PyUnicodeUCS2_DecodeUTF8(c_str s, Py_ssize_t length, c_str errors); 574 PyObject *PyUnicodeUCS2_DecodeUTF8Stateful(c_str s, Py_ssize_t length, 575 c_str errors, Py_ssize_t *consumed 570 576 ); 571 577 PyObject *PyUnicodeUCS2_AsUTF8String(PyObject *unicode); 572 PyObject *PyUnicodeUCS2_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, c har *errors);573 574 PyObject *PyUnicodeUCS2_DecodeUTF16(c har *string, Py_ssize_t length, char *errors, int *byteorder);575 PyObject *PyUnicodeUCS2_DecodeUTF16Stateful(c har *string, Py_ssize_t length,576 c har *errors, int *byteorder, Py_ssize_t *consumed578 PyObject *PyUnicodeUCS2_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, c_str errors); 579 580 PyObject *PyUnicodeUCS2_DecodeUTF16(c_str s, Py_ssize_t length, c_str errors, int *byteorder); 581 PyObject *PyUnicodeUCS2_DecodeUTF16Stateful(c_str s, Py_ssize_t length, 582 c_str errors, int *byteorder, Py_ssize_t *consumed 577 583 ); 578 584 PyObject *PyUnicodeUCS2_AsUTF16String(PyObject *unicode); 579 585 PyObject *PyUnicodeUCS2_EncodeUTF16(Py_UNICODE *data, Py_ssize_t length, 580 c har *errors, int byteorder586 c_str errors, int byteorder 581 587 ); 582 588 583 PyObject *PyUnicodeUCS2_DecodeUnicodeEscape(c har *string, Py_ssize_t length, char *errors);589 PyObject *PyUnicodeUCS2_DecodeUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 584 590 PyObject *PyUnicodeUCS2_AsUnicodeEscapeString(PyObject *unicode); 585 591 PyObject *PyUnicodeUCS2_EncodeUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 586 PyObject *PyUnicodeUCS2_DecodeRawUnicodeEscape(c har *string, Py_ssize_t length, char *errors);592 PyObject *PyUnicodeUCS2_DecodeRawUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 587 593 PyObject *PyUnicodeUCS2_AsRawUnicodeEscapeString(PyObject *unicode); 588 594 PyObject *PyUnicodeUCS2_EncodeRawUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 589 595 590 PyObject *_PyUnicodeUCS2_DecodeUnicodeInternal(c har *string, Py_ssize_t length, char *errors);591 592 PyObject *PyUnicodeUCS2_DecodeLatin1(c har *string, Py_ssize_t length, char *errors);596 PyObject *_PyUnicodeUCS2_DecodeUnicodeInternal(c_str s, Py_ssize_t length, c_str errors); 597 598 PyObject *PyUnicodeUCS2_DecodeLatin1(c_str s, Py_ssize_t length, c_str errors); 593 599 PyObject *PyUnicodeUCS2_AsLatin1String(PyObject *unicode); 594 PyObject *PyUnicodeUCS2_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, c har *errors);595 596 PyObject *PyUnicodeUCS2_DecodeASCII(c har *string, Py_ssize_t length, char *errors);600 PyObject *PyUnicodeUCS2_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, c_str errors); 601 602 PyObject *PyUnicodeUCS2_DecodeASCII(c_str s, Py_ssize_t length, c_str errors); 597 603 PyObject *PyUnicodeUCS2_AsASCIIString(PyObject *unicode); 598 PyObject *PyUnicodeUCS2_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, c har *errors);599 600 PyObject *PyUnicodeUCS2_DecodeCharmap(c har *string, Py_ssize_t length,601 PyObject *mapping, c har *errors604 PyObject *PyUnicodeUCS2_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, c_str errors); 605 606 PyObject *PyUnicodeUCS2_DecodeCharmap(c_str s, Py_ssize_t length, 607 PyObject *mapping, c_str errors 602 608 ); 603 609 PyObject *PyUnicodeUCS2_AsCharmapString(PyObject *unicode, PyObject *mapping); 604 610 PyObject *PyUnicodeUCS2_EncodeCharmap(Py_UNICODE *data, Py_ssize_t length, 605 PyObject *mapping, c har *errors611 PyObject *mapping, c_str errors 606 612 ); 607 613 PyObject *PyUnicodeUCS2_TranslateCharmap(Py_UNICODE *data, Py_ssize_t length, 608 PyObject *table, c har *errors614 PyObject *table, c_str errors 609 615 ); 610 616 611 617 version (Windows) { 612 PyObject *PyUnicodeUCS2_DecodeMBCS(c har *string, Py_ssize_t length, char *errors);618 PyObject *PyUnicodeUCS2_DecodeMBCS(c_str s, Py_ssize_t length, c_str errors); 613 619 PyObject *PyUnicodeUCS2_AsMBCSString(PyObject *unicode); 614 PyObject *PyUnicodeUCS2_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c har *errors);620 PyObject *PyUnicodeUCS2_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c_str errors); 615 621 } 616 622 617 int PyUnicodeUCS2_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c har *output, char *errors);623 int PyUnicodeUCS2_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c_str output, c_str errors); 618 624 619 625 PyObject *PyUnicodeUCS2_Concat(PyObject *left, PyObject *right); … … 625 631 } 626 632 PyObject *PyUnicodeUCS2_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 627 PyObject *PyUnicodeUCS2_Translate(PyObject *str, PyObject *table, c har *errors);633 PyObject *PyUnicodeUCS2_Translate(PyObject *str, PyObject *table, c_str errors); 628 634 PyObject *PyUnicodeUCS2_Join(PyObject *separator, PyObject *seq); 629 635 Py_ssize_t PyUnicodeUCS2_Tailmatch(PyObject *str, PyObject *substr, … … 668 674 669 675 int PyUnicodeUCS4_Resize(PyObject **unicode, Py_ssize_t length); 670 PyObject *PyUnicodeUCS4_FromEncodedObject(PyObject *obj, c har *encoding, char *errors);676 PyObject *PyUnicodeUCS4_FromEncodedObject(PyObject *obj, c_str encoding, c_str errors); 671 677 PyObject *PyUnicodeUCS4_FromObject(PyObject *obj); 672 678 … … 676 682 PyObject *PyUnicodeUCS4_FromOrdinal(int ordinal); 677 683 678 PyObject *_PyUnicodeUCS4_AsDefaultEncodedString(PyObject *, c har *);679 680 c har *PyUnicodeUCS4_GetDefaultEncoding();681 int PyUnicodeUCS4_SetDefaultEncoding(c har *encoding);682 683 PyObject *PyUnicodeUCS4_Decode(c har *s, Py_ssize_t size, char *encoding, char *errors);684 PyObject *PyUnicodeUCS4_Encode(Py_UNICODE *s, Py_ssize_t size, c har *encoding, char *errors);685 PyObject *PyUnicodeUCS4_AsEncodedObject(PyObject *unicode, c har *encoding, char *errors);686 PyObject *PyUnicodeUCS4_AsEncodedString(PyObject *unicode, c har *encoding, char *errors);687 688 PyObject *PyUnicodeUCS4_DecodeUTF7(c har *string, Py_ssize_t length, char *errors);684 PyObject *_PyUnicodeUCS4_AsDefaultEncodedString(PyObject *, c_str); 685 686 c_str PyUnicodeUCS4_GetDefaultEncoding(); 687 int PyUnicodeUCS4_SetDefaultEncoding(c_str encoding); 688 689 PyObject *PyUnicodeUCS4_Decode(c_str s, Py_ssize_t size, c_str encoding, c_str errors); 690 PyObject *PyUnicodeUCS4_Encode(Py_UNICODE *s, Py_ssize_t size, c_str encoding, c_str errors); 691 PyObject *PyUnicodeUCS4_AsEncodedObject(PyObject *unicode, c_str encoding, c_str errors); 692 PyObject *PyUnicodeUCS4_AsEncodedString(PyObject *unicode, c_str encoding, c_str errors); 693 694 PyObject *PyUnicodeUCS4_DecodeUTF7(c_str s, Py_ssize_t length, c_str errors); 689 695 PyObject *PyUnicodeUCS4_EncodeUTF7(Py_UNICODE *data, Py_ssize_t length, 690 int encodeSetO, int encodeWhiteSpace, c har *errors696 int encodeSetO, int encodeWhiteSpace, c_str errors 691 697 ); 692 698 693 PyObject *PyUnicodeUCS4_DecodeUTF8(c har *string, Py_ssize_t length, char *errors);694 PyObject *PyUnicodeUCS4_DecodeUTF8Stateful(c har *string, Py_ssize_t length,695 c har *errors, Py_ssize_t *consumed699 PyObject *PyUnicodeUCS4_DecodeUTF8(c_str s, Py_ssize_t length, c_str errors); 700 PyObject *PyUnicodeUCS4_DecodeUTF8Stateful(c_str string, Py_ssize_t length, 701 c_str errors, Py_ssize_t *consumed 696 702 ); 697 703 PyObject *PyUnicodeUCS4_AsUTF8String(PyObject *unicode); 698 PyObject *PyUnicodeUCS4_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, c har *errors);699 700 PyObject *PyUnicodeUCS4_DecodeUTF16(c har *string, Py_ssize_t length, char *errors, int *byteorder);701 PyObject *PyUnicodeUCS4_DecodeUTF16Stateful(c har *string, Py_ssize_t length,702 c har *errors, int *byteorder, Py_ssize_t *consumed704 PyObject *PyUnicodeUCS4_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, c_str errors); 705 706 PyObject *PyUnicodeUCS4_DecodeUTF16(c_str s, Py_ssize_t length, c_str errors, int *byteorder); 707 PyObject *PyUnicodeUCS4_DecodeUTF16Stateful(c_str s, Py_ssize_t length, 708 c_str errors, int *byteorder, Py_ssize_t *consumed 703 709 ); 704 710 PyObject *PyUnicodeUCS4_AsUTF16String(PyObject *unicode); 705 711 PyObject *PyUnicodeUCS4_EncodeUTF16(Py_UNICODE *data, Py_ssize_t length, 706 c har *errors, int byteorder712 c_str errors, int byteorder 707 713 ); 708 714 709 PyObject *PyUnicodeUCS4_DecodeUnicodeEscape(c har *string, Py_ssize_t length, char *errors);715 PyObject *PyUnicodeUCS4_DecodeUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 710 716 PyObject *PyUnicodeUCS4_AsUnicodeEscapeString(PyObject *unicode); 711 717 PyObject *PyUnicodeUCS4_EncodeUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 712 PyObject *PyUnicodeUCS4_DecodeRawUnicodeEscape(c har *string, Py_ssize_t length, char *errors);718 PyObject *PyUnicodeUCS4_DecodeRawUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 713 719 PyObject *PyUnicodeUCS4_AsRawUnicodeEscapeString(PyObject *unicode); 714 720 PyObject *PyUnicodeUCS4_EncodeRawUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 715 721 716 PyObject *_PyUnicodeUCS4_DecodeUnicodeInternal(c har *string, Py_ssize_t length, char *errors);717 718 PyObject *PyUnicodeUCS4_DecodeLatin1(c har *string, Py_ssize_t length, char *errors);722 PyObject *_PyUnicodeUCS4_DecodeUnicodeInternal(c_str s, Py_ssize_t length, c_str errors); 723 724 PyObject *PyUnicodeUCS4_DecodeLatin1(c_str s, Py_ssize_t length, c_str errors); 719 725 PyObject *PyUnicodeUCS4_AsLatin1String(PyObject *unicode); 720 PyObject *PyUnicodeUCS4_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, c har *errors);721 722 PyObject *PyUnicodeUCS4_DecodeASCII(c har *string, Py_ssize_t length, char *errors);726 PyObject *PyUnicodeUCS4_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, c_str errors); 727 728 PyObject *PyUnicodeUCS4_DecodeASCII(c_str s, Py_ssize_t length, c_str errors); 723 729 PyObject *PyUnicodeUCS4_AsASCIIString(PyObject *unicode); 724 PyObject *PyUnicodeUCS4_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, c har *errors);725 726 PyObject *PyUnicodeUCS4_DecodeCharmap(c har *string, Py_ssize_t length,727 PyObject *mapping, c har *errors730 PyObject *PyUnicodeUCS4_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, c_str errors); 731 732 PyObject *PyUnicodeUCS4_DecodeCharmap(c_str s, Py_ssize_t length, 733 PyObject *mapping, c_str errors 728 734 ); 729 735 PyObject *PyUnicodeUCS4_AsCharmapString(PyObject *unicode, PyObject *mapping); 730 736 PyObject *PyUnicodeUCS4_EncodeCharmap(Py_UNICODE *data, Py_ssize_t length, 731 PyObject *mapping, c har *errors737 PyObject *mapping, c_str errors 732 738 ); 733 739 PyObject *PyUnicodeUCS4_TranslateCharmap(Py_UNICODE *data, Py_ssize_t length, 734 PyObject *table, c har *errors740 PyObject *table, c_str errors 735 741 ); 736 742 737 743 version (Windows) { 738 PyObject *PyUnicodeUCS4_DecodeMBCS(c har *string, Py_ssize_t length, char *errors);744 PyObject *PyUnicodeUCS4_DecodeMBCS(c_str s, Py_ssize_t length, c_str errors); 739 745 PyObject *PyUnicodeUCS4_AsMBCSString(PyObject *unicode); 740 PyObject *PyUnicodeUCS4_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c har *errors);746 PyObject *PyUnicodeUCS4_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c_str errors); 741 747 } 742 748 743 int PyUnicodeUCS4_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c har *output, char *errors);749 int PyUnicodeUCS4_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c_str output, c_str errors); 744 750 745 751 PyObject *PyUnicodeUCS4_Concat(PyObject *left, PyObject *right); … … 751 757 } 752 758 PyObject *PyUnicodeUCS4_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 753 PyObject *PyUnicodeUCS4_Translate(PyObject *str, PyObject *table, c har *errors);759 PyObject *PyUnicodeUCS4_Translate(PyObject *str, PyObject *table, c_str errors); 754 760 PyObject *PyUnicodeUCS4_Join(PyObject *separator, PyObject *seq); 755 761 Py_ssize_t PyUnicodeUCS4_Tailmatch(PyObject *str, PyObject *substr, … … 1216 1222 } 1217 1223 1218 PyObject * PyString_FromStringAndSize(c har *, Py_ssize_t);1219 PyObject * PyString_FromString(c har *);1224 PyObject * PyString_FromStringAndSize(c_str, Py_ssize_t); 1225 PyObject * PyString_FromString(c_str); 1220 1226 // PyString_FromFormatV omitted 1221 PyObject * PyString_FromFormat(c har*, ...);1227 PyObject * PyString_FromFormat(c_str, ...); 1222 1228 Py_ssize_t PyString_Size(PyObject *); 1223 c har *PyString_AsString(PyObject *);1229 c_str PyString_AsString(PyObject *); 1224 1230 /* Use only if you know it's a string */ 1225 1231 int PyString_CHECK_INTERNED(PyObject* op) { … … 1227 1233 } 1228 1234 /* Macro, trading safety for speed */ 1229 c har*PyString_AS_STRING(PyObject* op) {1235 c_str PyString_AS_STRING(PyObject* op) { 1230 1236 return (cast(PyStringObject*)op).ob_sval; 1231 1237 } … … 1246 1252 1247 1253 1248 PyObject* PyString_Decode(c har *s, Py_ssize_t size, char *encoding, char *errors);1249 PyObject* PyString_Encode(c har *s, Py_ssize_t size, char *encoding, char *errors);1250 1251 PyObject* PyString_AsEncodedObject(PyObject *str, c har *encoding, char *errors);1252 PyObject* PyString_AsDecodedObject(PyObject *str, c har *encoding, char *errors);1254 PyObject* PyString_Decode(c_str s, Py_ssize_t size, c_str encoding, c_str errors); 1255 PyObject* PyString_Encode(c_str s, Py_ssize_t size, c_str encoding, c_str errors); 1256 1257 PyObject* PyString_AsEncodedObject(PyObject *str, c_str encoding, c_str errors); 1258 PyObject* PyString_AsDecodedObject(PyObject *str, c_str encoding, c_str errors); 1253 1259 1254 1260 // Since no one has legacy Python extensions written in D, the deprecated … … 1434 1440 int PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override_); 1435 1441 1436 PyObject * PyDict_GetItemString(PyObject *dp, c har *key);1437 int PyDict_SetItemString(PyObject *dp, c har *key, PyObject *item);1438 int PyDict_DelItemString(PyObject *dp, c har *key);1442 PyObject * PyDict_GetItemString(PyObject *dp, c_str key); 1443 int PyDict_SetItemString(PyObject *dp, c_str key, PyObject *item); 1444 int PyDict_DelItemString(PyObject *dp, c_str key); 1439 1445 1440 1446 … … 1462 1468 1463 1469 struct PyMethodDef { 1464 c har *ml_name;1470 c_str ml_name; 1465 1471 PyCFunction ml_meth; 1466 1472 int ml_flags; 1467 c har *ml_doc;1468 } 1469 1470 PyObject * Py_FindMethod(PyMethodDef[], PyObject *, c har *);1473 c_str ml_doc; 1474 } 1475 1476 PyObject * Py_FindMethod(PyMethodDef[], PyObject *, c_str); 1471 1477
