Changeset 120

Show
Ignore:
Timestamp:
07/26/07 20:06:38 (1 year ago)
Author:
KirkMcDonald
Message:

* Pyd now requires D 2.003 or later.
* Pyd now compiles with D 2.003.
* Resolved long-standing string-copying annoyance (thanks to const).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/testdll/testdll.d

    r118 r120  
    1313} 
    1414 
    15 char[] bar(int i) { 
     15string bar(int i) { 
    1616    if (i > 10) { 
    1717        return "It's greater than 10!"; 
     
    2121} 
    2222 
    23 void baz(int i=10, char[] s="moo") { 
     23void baz(int i=10, string s="moo") { 
    2424    writefln("i = %s\ns = %s", i, s); 
    2525} 
  • trunk/infrastructure/meta/Demangle.d

    r40 r120  
    2929 * Pretty-prints a mangled type string. 
    3030 */ 
    31 template demangleType(char[] str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 
     31template demangleType(string str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 
    3232{ 
    3333    static if (wantQualifiedNames != MangledNameType.PrettyName) { 
     
    7070// split these off because they're numerous and simple 
    7171// Note: For portability, could replace "v" with void.mangleof, etc. 
    72 template demangleBasicType(char [] str) 
     72template demangleBasicType(string str) 
    7373{ 
    7474         static if (str == "v") const char [] demangleBasicType = "void"; 
     
    106106} 
    107107 
    108 template demangleTypeConsumed(char [] str) 
     108template demangleTypeConsumed(string str) 
    109109{ 
    110110    static if (str[0]=='A') 
     
    132132 
    133133// For static arrays, count number of digits used (eg, return 3 for "674") 
    134 template countLeadingDigits(char [] str) 
     134template countLeadingDigits(string str) 
    135135{ 
    136136    static if (str.length>0 && beginsWithDigit!( str)) 
     
    147147// (this happens with templates, when the name being 'lengthed' is itself an Lname). 
    148148// We guard against this by ensuring that the L is less than the length of the string. 
    149 template getLname(char [] str) 
     149template getLname(string str) 
    150150{ 
    151151    static if (str.length <= 9+1 || !beginsWithDigit!(str[1..$]) ) 
     
    163163// Deal with the case where an Lname contains an embedded "__D". 
    164164// This can happen when classes, typedefs, etc are declared inside a function. 
    165 template pretty_Dname(char [] str, int dotnameconsumed, MangledNameType wantQualifiedNames) 
     165template pretty_Dname(string str, int dotnameconsumed, MangledNameType wantQualifiedNames) 
    166166{ 
    167167    static if ( isMangledFunction!( (str[2+dotnameconsumed]))) { 
     
    181181// Deal with the case where an Lname contains an embedded ("__D") function. 
    182182// Split into a seperate function because it's so complicated. 
    183 template pretty_Dfunction(char [] str, int dotnameconsumed, int paramlistconsumed, 
     183template pretty_Dfunction(string str, int dotnameconsumed, int paramlistconsumed, 
    184184    MangledNameType wantQualifiedNames) 
    185185{ 
     
    203203 
    204204// for an Lname that begins with "_D" 
    205 template get_DnameConsumed(char [] str) 
     205template get_DnameConsumed(string str) 
    206206{ 
    207207    const int get_DnameConsumed = 2 + getQualifiedNameConsumed!(str[2..$]) 
     
    210210 
    211211// If Lname is a template, shows it as a template 
    212 template prettyLname(char [] str, MangledNameType wantQualifiedNames) 
     212template prettyLname(string str, MangledNameType wantQualifiedNames) 
    213213{ 
    214214    static if (str.length>3 && str[0..3] == "__T") // Template instance name 
     
    231231// str must start with an lname: first chars give the length 
    232232// how many chars are taken up with length digits + the name itself 
    233 template getLnameConsumed(char [] str) 
     233template getLnameConsumed(string str) 
    234234{ 
    235235    static if (str.length==0) 
     
    245245} 
    246246 
    247 template getQualifiedName(char [] str, MangledNameType wantQualifiedNames, char [] dotstr = "") 
     247template getQualifiedName(string str, MangledNameType wantQualifiedNames, string dotstr = "") 
    248248{ 
    249249    static if (str.length==0) const char [] getQualifiedName=""; 
     
    269269} 
    270270 
    271 template getQualifiedNameConsumed (char [] str) 
     271template getQualifiedNameConsumed (string str) 
    272272{ 
    273273    static if ( str.length>1 &&  beginsWithDigit!(str) ) { 
     
    290290* or "function " or "delegate " 
    291291*/ 
    292 template demangleFunctionOrDelegate(char [] str, char [] funcOrDelegStr, MangledNameType wantQualifiedNames) 
     292template demangleFunctionOrDelegate(string str, string funcOrDelegStr, MangledNameType wantQualifiedNames) 
    293293{ 
    294294    const char [] demangleFunctionOrDelegate = demangleExtern!(( str[0] )) 
     
    301301// Special case: types that are in function parameters 
    302302// For function parameters, the type can also contain 'lazy', 'out' or 'inout'. 
    303 template demangleFunctionParamType(char[] str, MangledNameType wantQualifiedNames) 
     303template demangleFunctionParamType(string str, MangledNameType wantQualifiedNames) 
    304304{ 
    305305    static if (str[0]=='L') 
     
    313313 
    314314// Deal with 'out' and 'inout' parameters 
    315 template demangleFunctionParamTypeConsumed(char[] str) 
     315template demangleFunctionParamTypeConsumed(string str) 
    316316{ 
    317317    static if (str[0]=='K' || str[0]=='J' || str[0]=='L') 
     
    338338// Skip through the string until we find the return value. It can either be Z for normal 
    339339// functions, or Y for vararg functions. 
    340 template demangleReturnValue(char [] str, MangledNameType wantQualifiedNames) 
     340template demangleReturnValue(string str, MangledNameType wantQualifiedNames) 
    341341{ 
    342342    static assert(str.length>=1, "Demangle error(Function): No return value found"); 
     
    347347 
    348348// Stop when we get to the return value 
    349 template demangleParamList(char [] str, MangledNameType wantQualifiedNames, char[] commastr = "") 
     349template demangleParamList(string str, MangledNameType wantQualifiedNames, string commastr = "") 
    350350{ 
    351351    static if (str[0] == 'Z') 
     
    362362 
    363363// How many characters are used in the parameter list and return value 
    364 template demangleParamListAndRetValConsumed(char [] str) 
     364template demangleParamListAndRetValConsumed(string str) 
    365365{ 
    366366    static assert (str.length>0, "Demangle error(ParamList): No return value found"); 
     
    376376//              TEMPLATES 
    377377 
    378 template templateValueArgConsumed(char [] str) 
     378template templateValueArgConsumed(string str) 
    379379{ 
    380380    static if (str[0]=='n') const int templateValueArgConsumed = 1; 
     
    387387 
    388388// pretty-print a template value argument. 
    389 template prettyValueArg(char [] str) 
     389template prettyValueArg(string str) 
    390390{ 
    391391    static if (str[0]=='n') const char [] prettyValueArg = "null"; 
     
    398398 
    399399// Pretty-print a template argument 
    400 template prettyTemplateArg(char [] str, MangledNameType wantQualifiedNames) 
     400template prettyTemplateArg(string str, MangledNameType wantQualifiedNames) 
    401401{ 
    402402    static if (str[0]=='S') // symbol name 
     
    411411} 
    412412 
    413 template templateArgConsumed(char [] str) 
     413template templateArgConsumed(string str) 
    414414{ 
    415415    static if (str[0]=='S') // symbol name 
     
    425425// Like function parameter lists, template parameter lists also end in a Z, 
    426426// but they don't have a return value at the end. 
    427 template prettyTemplateArgList(char [] str, MangledNameType wantQualifiedNames, char [] commastr="") 
     427template prettyTemplateArgList(string str, MangledNameType wantQualifiedNames, string commastr="") 
    428428{ 
    429429    static if (str[0]=='Z') 
     
    435435} 
    436436 
    437 template templateArgListConsumed(char [] str) 
     437template templateArgListConsumed(string str) 
    438438{ 
    439439    static assert(str.length>0, "No Z found at end of template argument list"); 
     
    452452   * it allows us to avoid the ugly double parentheses. 
    453453   */ 
    454 template beginsWithDigit(char [] s) 
     454template beginsWithDigit(string s) 
    455455{ 
    456456  static if (s[0]>='0' && s[0]<='9') 
  • trunk/infrastructure/pyd/class_wrap.d

    r118 r120  
    276276    mixin _Def!(fn, symbolnameof!(fn), typeof(&fn), ""); 
    277277} 
    278 struct Def(alias fn, char[] docstring) { 
     278struct Def(alias fn, string docstring) { 
    279279    mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), typeof(&fn)/+, minArgs!(fn)+/, docstring); 
    280280} 
    281 struct Def(alias fn, char[] name, char[] docstring) { 
     281struct Def(alias fn, string name, string docstring) { 
    282282    mixin _Def!(fn, /*symbolnameof!(fn),*/ name, typeof(&fn)/+, minArgs!(fn)+/, docstring); 
    283283} 
    284 struct Def(alias fn, char[] name, fn_t) { 
     284struct Def(alias fn, string name, fn_t) { 
    285285    mixin _Def!(fn, /*symbolnameof!(fn),*/ name, fn_t/+, minArgs!(fn)+/, ""); 
    286286} 
     
    288288    mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), fn_t/+, minArgs!(fn)+/, ""); 
    289289} 
    290 struct Def(alias fn, fn_t, char[] docstring) { 
     290struct Def(alias fn, fn_t, string docstring) { 
    291291    mixin _Def!(fn, /*symbolnameof!(fn),*/ symbolnameof!(fn), fn_t/+, minArgs!(fn)+/, docstring); 
    292292} 
    293 struct Def(alias fn, char[] name, fn_t, char[] docstring) { 
     293struct Def(alias fn, string name, fn_t, string docstring) { 
    294294    mixin _Def!(fn, /*symbolnameof!(fn),*/ name, fn_t/+, minArgs!(fn)+/, docstring); 
    295295} 
    296296/+ 
    297 template Def(alias fn, char[] name, fn_t, uint MIN_ARGS=minArgs!(fn)/+, char[] docstring=""+/) { 
     297template Def(alias fn, string name, fn_t, uint MIN_ARGS=minArgs!(fn)/+, string docstring=""+/) { 
    298298    alias Def!(fn, /*symbolnameof!(fn),*/ name, fn_t, MIN_ARGS/+, docstring+/) Def; 
    299299} 
    300300+/ 
    301 template _Def(alias fn, /*char[] _realname,*/ char[] name, fn_t/+, uint MIN_ARGS=minArgs!(fn)+/, char[] docstring) { 
     301template _Def(alias fn, /*string _realname,*/ string name, fn_t/+, uint MIN_ARGS=minArgs!(fn)+/, string docstring) { 
    302302    //static const type = ParamType.Def; 
    303303    alias fn func; 
     
    336336    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), typeof(&fn), minArgs!(fn), ""); 
    337337} 
    338 struct StaticDef(alias fn, char[] docstring) { 
     338struct StaticDef(alias fn, string docstring) { 
    339339    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), typeof(&fn), minArgs!(fn), docstring); 
    340340} 
    341 struct StaticDef(alias _fn, char[] name, char[] docstring) { 
     341struct StaticDef(alias _fn, string name, string docstring) { 
    342342    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, typeof(&fn), minArgs!(fn), docstring); 
    343343} 
    344 struct StaticDef(alias _fn, char[] name, fn_t, char[] docstring) { 
     344struct StaticDef(alias _fn, string name, fn_t, string docstring) { 
    345345    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, minArgs!(fn), docstring); 
    346346} 
     
    348348    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), fn_t, minArgs!(fn), ""); 
    349349} 
    350 struct StaticDef(alias _fn, fn_t, char[] docstring) { 
     350struct StaticDef(alias _fn, fn_t, string docstring) { 
    351351    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ symbolnameof!(fn), fn_t, minArgs!(fn), docstring); 
    352352} 
    353 struct StaticDef(alias _fn, char[] name, fn_t) { 
     353struct StaticDef(alias _fn, string name, fn_t) { 
    354354    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, minArgs!(fn), ""); 
    355355} 
    356 struct StaticDef(alias _fn, char[] name, fn_t, uint MIN_ARGS) { 
     356struct StaticDef(alias _fn, string name, fn_t, uint MIN_ARGS) { 
    357357    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, MIN_ARGS, ""); 
    358358} 
    359 struct StaticDef(alias _fn, char[] name, fn_t, uint MIN_ARGS, char[] docstring) { 
     359struct StaticDef(alias _fn, string name, fn_t, uint MIN_ARGS, string docstring) { 
    360360    mixin _StaticDef!(fn,/+ symbolnameof!(fn),+/ name, fn_t, MIN_ARGS, docstring); 
    361361} 
    362 template _StaticDef(alias fn,/+ char[] _realname,+/ char[] name, fn_t, uint MIN_ARGS, char[] docstring) { 
     362template _StaticDef(alias fn,/+ string _realname,+/ string name, fn_t, uint MIN_ARGS, string docstring) { 
    363363    //static const type = ParamType.StaticDef; 
    364364    alias fn func; 
     
    397397    mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), false, ""); 
    398398} 
    399 struct Property(alias fn, char[] docstring) { 
     399struct Property(alias fn, string docstring) { 
    400400    mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), false, docstring); 
    401401} 
    402 struct Property(alias fn, char[] name, char[] docstring) { 
     402struct Property(alias fn, string name, string docstring) { 
    403403    mixin _Property!(fn, symbolnameof!(fn), name, false, docstring); 
    404404} 
    405 struct Property(alias fn, char[] name, bool RO) { 
     405struct Property(alias fn, string name, bool RO) { 
    406406    mixin _Property!(fn, symbolnameof!(fn), name, RO, ""); 
    407407} 
    408 struct Property(alias fn, char[] name, bool RO, char[] docstring) { 
     408struct Property(alias fn, string name, bool RO, string docstring) { 
    409409    mixin _Property!(fn, symbolnameof!(fn), name, RO, docstring); 
    410410} 
     
    412412    mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), RO, ""); 
    413413} 
    414 struct Property(alias fn, bool RO, char[] docstring) { 
     414struct Property(alias fn, bool RO, string docstring) { 
    415415    mixin _Property!(fn, symbolnameof!(fn), symbolnameof!(fn), RO, docstring); 
    416416} 
    417 template _Property(alias fn, char[] _realname, char[] name, bool RO, char[] docstring) { 
     417template _Property(alias fn, string _realname, string name, bool RO, string docstring) { 
    418418    alias property_parts!(fn).getter_type get_t; 
    419419    alias property_parts!(fn).setter_type set_t; 
     
    545545iterator. 
    546546*/ 
    547 struct AltIter(alias fn, char[] name = symbolnameof!(fn), iter_t = ParameterTypeTuple!(fn)[0]) { 
     547struct AltIter(alias fn, string name = symbolnameof!(fn), iter_t = ParameterTypeTuple!(fn)[0]) { 
    548548    static const bool needs_shim = false; 
    549549    static void call(T) () { 
     
    564564} /*Pyd_with_StackThreads*/ 
    565565 
    566 void wrap_class(T, Params...) (char[] docstring="", char[] modulename="") { 
     566void wrap_class(T, Params...) (string docstring="", string modulename="") { 
    567567    _wrap_class!(T, symbolnameof!(T), Params).wrap_class(docstring, modulename); 
    568568} 
     
    572572} 
    573573+/ 
    574 template _wrap_class(_T, char[] name, Params...) { 
     574template _wrap_class(_T, string name, Params...) { 
    575575    static if (is(_T == class)) { 
    576576        pragma(msg, "wrap_class: " ~ name); 
     
    587587        alias _T* T; 
    588588    } 
    589 void wrap_class(char[] docstring="", char[] modulename="") { 
     589void wrap_class(string docstring="", string modulename="") { 
    590590    pragma(msg, "shim.mangleof: " ~ shim_class.mangleof); 
    591591    alias wrapped_class_type!(T) type; 
     
    603603 
    604604    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))); 
    606606 
    607607    ////////////////// 
  • trunk/infrastructure/pyd/def.d

    r100 r120  
    3636]; 
    3737 
    38 private PyMethodDef[][char[]] module_methods; 
    39 private PyObject*[char[]] pyd_modules; 
     38private PyMethodDef[][string] module_methods; 
     39private PyObject*[string] pyd_modules; 
    4040 
    41 private void ready_module_methods(char[] modulename) { 
     41private void ready_module_methods(string modulename) { 
    4242    PyMethodDef empty; 
    4343    if (!(modulename in module_methods)) { 
     
    4747} 
    4848 
    49 PyObject* Pyd_Module_p(char[] modulename="") { 
     49PyObject* Pyd_Module_p(string modulename="") { 
    5050    PyObject** m = modulename in pyd_modules; 
    5151    if (m is null) return null; 
     
    8585 *It's greater than 10!) 
    8686 */ 
    87 void def(alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (char[] docstring="") { 
     87void def(alias fn, string name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (string docstring="") { 
    8888    def!("", fn, name, fn_t, MIN_ARGS)(docstring); 
    8989} 
    9090 
    91 void def(char[] modulename, alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (char[] docstring) { 
     91void def(string modulename, alias fn, string name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS = minArgs!(fn, fn_t)) (string docstring) { 
    9292    pragma(msg, "def: " ~ name); 
    9393    PyMethodDef empty; 
     
    102102} 
    103103 
    104 char[] pyd_module_name; 
     104string pyd_module_name; 
    105105 
    106106/** 
    107107 * Module initialization function. Should be called after the last call to def. 
    108108 */ 
    109 PyObject* module_init(char[] docstring="") { 
     109PyObject* module_init(string docstring="") { 
    110110    //_loadPythonSupport(); 
    111     char[] name = pyd_module_name; 
     111    string name = pyd_module_name; 
    112112    ready_module_methods(""); 
    113113    pyd_modules[""] = Py_InitModule3((name ~ \0).ptr, module_methods[""].ptr, (docstring ~ \0).ptr); 
     
    118118 * Module initialization function. Should be called after the last call to def. 
    119119 */ 
    120 PyObject* add_module(char[] name, char[] docstring="") { 
     120PyObject* add_module(string name, string docstring="") { 
    121121    ready_module_methods(name); 
    122122    pyd_modules[name] = Py_InitModule3((name ~ \0).ptr, module_methods[name].ptr, (docstring ~ \0).ptr); 
  • trunk/infrastructure/pyd/func_wrap.d

    r113 r120  
    5959} 
    6060 
    61 void setWrongArgsError(int gotArgs, uint minArgs, uint maxArgs, char[] funcName="") { 
     61void setWrongArgsError(int gotArgs, uint minArgs, uint maxArgs, string funcName="") { 
    6262    char[] str; 
    6363    if (funcName == "") { 
     
    238238                return null; 
    239239            } 
    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); 
    241241            return pyApplyToDelegate(dg, args); 
    242242        }); 
  • trunk/infrastructure/pyd/lib_abstract.d

    r110 r120  
    4242    } 
    4343} else { 
    44     char[] objToStr(Object o) { 
     44    string objToStr(Object o) { 
    4545        return o.toString(); 
    4646    } 
    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; 
    4855 
    4956    public import std.string : toString; 
  • trunk/infrastructure/pyd/make_object.d

    r114 r120  
    152152    } else static if (is(T : cdouble)) { 
    153153        return PyComplex_FromDoubles(t.re, t.im); 
    154     } else static if (is(T : char[])) { 
     154    } else static if (is(T : string)) { 
    155155        return PyString_FromString((t ~ \0).ptr); 
    156156    } else static if (is(T : wchar[])) { 
     
    279279 */ 
    280280class PydConversionException : Exception { 
    281     this(char[] msg) { super(msg); } 
     281    this(string msg) { super(msg); } 
    282282} 
    283283 
     
    353353        return temp; 
    354354    +/ 
     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); 
    355370    } else static if (is(char[] : T)) { 
    356         char* result; 
     371        const(char)* result; 
    357372        PyObject* repr; 
    358373        // If it's a string, convert it 
     
    440455    // Pull out the name of the type of this Python object, and the 
    441456    // name of the D type. 
    442     char[] py_typename, d_typename; 
     457    string py_typename, d_typename; 
    443458    PyObject* py_type, py_type_str; 
    444459    py_type = PyObject_Type(o); 
  • trunk/infrastructure/pyd/make_wrapper.d

    r118 r120  
    114114        } 
    115115    } 
    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) { 
    118118            PyObject* _pyobj = this.__pyd_get_pyobj(); 
    119119            if (_pyobj !is null) { 
  • trunk/infrastructure/pyd/struct_wrap.d

    r118 r120  
    3737// as a template parameter, rather than the struct type itself. 
    3838 
    39 template wrapped_member(T, char[] name, _M=void) { 
     39template wrapped_member(T, string name, _M=void) { 
    4040    alias wrapped_class_type!(T) type; 
    4141    alias wrapped_class_object!(T) obj; 
     
    6363} 
    6464 
    65 struct Member(char[] realname) { 
     65struct Member(string realname) { 
    6666    mixin _Member!(realname, realname, ""); 
    6767} 
    68 struct Member(char[] realname, char[] docstring) { 
     68struct Member(string realname, string docstring) { 
    6969    mixin _Member!(realname, realname, docstring); 
    7070} 
    71 struct Member(char[] realname, char[] name, char[] docstring) { 
     71struct Member(string realname, string name, string docstring) { 
    7272    mixin _Member!(realname, name, docstring); 
    7373} 
    74 template _Member(char[] realname, char[] name, char[] docstring) { 
     74template _Member(string realname, string name, string docstring) { 
    7575    static const bool needs_shim = false; 
    7676    static void call(T) () { 
  • trunk/infrastructure/python/python.d

    r119 r120  
    6161} 
    6262 
     63version (D_Version2) { 
     64    alias const(char)* c_str; 
     65} else { 
     66    alias char* c_str; 
     67} 
     68 
    6369/* 
    6470 * Py_ssize_t is defined as a signed type which is 8 bytes on X86_64 and 4 
     
    137143  alias int (*getwritebufferproc)(PyObject *, int, void **); 
    138144  alias int (*getsegcountproc)(PyObject *, int *); 
    139   alias int (*getcharbufferproc)(PyObject *, int, char **); 
     145  alias int (*getcharbufferproc)(PyObject *, int, c_str*); 
    140146  // ssize_t-based buffer interface 
    141147  alias Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); 
    142148  alias Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); 
    143149  alias Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); 
    144   alias Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); 
     150  alias Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, c_str*); 
    145151 
    146152  alias int (*objobjproc)(PyObject *, PyObject *); 
     
    226232  alias void (*destructor)(PyObject *); 
    227233  alias int (*printfunc)(PyObject *, FILE *, int); 
    228   alias PyObject *(*getattrfunc)(PyObject *, char *); 
     234  alias PyObject *(*getattrfunc)(PyObject *, c_str); 
    229235  alias PyObject *(*getattrofunc)(PyObject *, PyObject *); 
    230   alias int (*setattrfunc)(PyObject *, char *, PyObject *); 
     236  alias int (*setattrfunc)(PyObject *, c_str, PyObject *); 
    231237  alias int (*setattrofunc)(PyObject *, PyObject *, PyObject *); 
    232238  alias int (*cmpfunc)(PyObject *, PyObject *); 
     
    245251    mixin PyObject_VAR_HEAD; 
    246252 
    247     char *tp_name; 
     253    c_str tp_name; 
    248254    Py_ssize_t tp_basicsize, tp_itemsize; 
    249255 
     
    269275    C_long tp_flags; 
    270276 
    271     char *tp_doc; 
     277    c_str tp_doc; 
    272278 
    273279    traverseproc tp_traverse; 
     
    362368  PyObject * PyObject_RichCompare(PyObject *, PyObject *, int); 
    363369  int PyObject_RichCompareBool(PyObject *, PyObject *, int); 
    364   PyObject * PyObject_GetAttrString(PyObject *, char *); 
    365   int PyObject_SetAttrString(PyObject *, char *, PyObject *); 
    366   int PyObject_HasAttrString(PyObject *, char *); 
     370  PyObject * PyObject_GetAttrString(PyObject *, c_str); 
     371  int PyObject_SetAttrString(PyObject *, c_str, PyObject *); 
     372  int PyObject_HasAttrString(PyObject *, c_str); 
    367373  PyObject * PyObject_GetAttr(PyObject *, PyObject *); 
    368374  int PyObject_SetAttr(PyObject *, PyObject *, PyObject *); 
     
    542548 
    543549    int PyUnicodeUCS2_Resize(PyObject **unicode, Py_ssize_t length); 
    544     PyObject *PyUnicodeUCS2_FromEncodedObject(PyObject *obj, char *encoding, char *errors); 
     550    PyObject *PyUnicodeUCS2_FromEncodedObject(PyObject *obj, c_str encoding, c_str errors); 
    545551    PyObject *PyUnicodeUCS2_FromObject(PyObject *obj); 
    546552 
     
    550556    PyObject *PyUnicodeUCS2_FromOrdinal(int ordinal); 
    551557 
    552     PyObject *_PyUnicodeUCS2_AsDefaultEncodedString(PyObject *, char *); 
    553  
    554     char *PyUnicodeUCS2_GetDefaultEncoding(); 
    555     int PyUnicodeUCS2_SetDefaultEncoding(char *encoding); 
    556  
    557     PyObject *PyUnicodeUCS2_Decode(char *s, Py_ssize_t size, char *encoding, char *errors); 
    558     PyObject *PyUnicodeUCS2_Encode(Py_UNICODE *s, Py_ssize_t size, char *encoding, char *errors); 
    559     PyObject *PyUnicodeUCS2_AsEncodedObject(PyObject *unicode, char *encoding, char *errors); 
    560     PyObject *PyUnicodeUCS2_AsEncodedString(PyObject *unicode, char *encoding, char *errors); 
    561  
    562     PyObject *PyUnicodeUCS2_DecodeUTF7(char *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); 
    563569    PyObject *PyUnicodeUCS2_EncodeUTF7(Py_UNICODE *data, Py_ssize_t length, 
    564         int encodeSetO, int encodeWhiteSpace, char *errors 
     570        int encodeSetO, int encodeWhiteSpace, c_str errors 
    565571      ); 
    566572 
    567     PyObject *PyUnicodeUCS2_DecodeUTF8(char *string, Py_ssize_t length, char *errors); 
    568     PyObject *PyUnicodeUCS2_DecodeUTF8Stateful(char *string, Py_ssize_t length, 
    569         char *errors, Py_ssize_t *consumed 
     573    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 
    570576      ); 
    571577    PyObject *PyUnicodeUCS2_AsUTF8String(PyObject *unicode); 
    572     PyObject *PyUnicodeUCS2_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    573  
    574     PyObject *PyUnicodeUCS2_DecodeUTF16(char *string, Py_ssize_t length, char *errors, int *byteorder); 
    575     PyObject *PyUnicodeUCS2_DecodeUTF16Stateful(char *string, Py_ssize_t length, 
    576         char *errors, int *byteorder, Py_ssize_t *consumed 
     578    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 
    577583      ); 
    578584    PyObject *PyUnicodeUCS2_AsUTF16String(PyObject *unicode); 
    579585    PyObject *PyUnicodeUCS2_EncodeUTF16(Py_UNICODE *data, Py_ssize_t length, 
    580         char *errors, int byteorder 
     586        c_str errors, int byteorder 
    581587      ); 
    582588 
    583     PyObject *PyUnicodeUCS2_DecodeUnicodeEscape(char *string, Py_ssize_t length, char *errors); 
     589    PyObject *PyUnicodeUCS2_DecodeUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 
    584590    PyObject *PyUnicodeUCS2_AsUnicodeEscapeString(PyObject *unicode); 
    585591    PyObject *PyUnicodeUCS2_EncodeUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 
    586     PyObject *PyUnicodeUCS2_DecodeRawUnicodeEscape(char *string, Py_ssize_t length, char *errors); 
     592    PyObject *PyUnicodeUCS2_DecodeRawUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 
    587593    PyObject *PyUnicodeUCS2_AsRawUnicodeEscapeString(PyObject *unicode); 
    588594    PyObject *PyUnicodeUCS2_EncodeRawUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 
    589595 
    590     PyObject *_PyUnicodeUCS2_DecodeUnicodeInternal(char *string, Py_ssize_t length, char *errors); 
    591  
    592     PyObject *PyUnicodeUCS2_DecodeLatin1(char *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); 
    593599    PyObject *PyUnicodeUCS2_AsLatin1String(PyObject *unicode); 
    594     PyObject *PyUnicodeUCS2_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    595  
    596     PyObject *PyUnicodeUCS2_DecodeASCII(char *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); 
    597603    PyObject *PyUnicodeUCS2_AsASCIIString(PyObject *unicode); 
    598     PyObject *PyUnicodeUCS2_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    599  
    600     PyObject *PyUnicodeUCS2_DecodeCharmap(char *string, Py_ssize_t length, 
    601         PyObject *mapping, char *errors 
     604    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 
    602608      ); 
    603609    PyObject *PyUnicodeUCS2_AsCharmapString(PyObject *unicode, PyObject *mapping); 
    604610    PyObject *PyUnicodeUCS2_EncodeCharmap(Py_UNICODE *data, Py_ssize_t length, 
    605         PyObject *mapping, char *errors 
     611        PyObject *mapping, c_str errors 
    606612      ); 
    607613    PyObject *PyUnicodeUCS2_TranslateCharmap(Py_UNICODE *data, Py_ssize_t length, 
    608         PyObject *table, char *errors 
     614        PyObject *table, c_str errors 
    609615      ); 
    610616 
    611617    version (Windows) { 
    612       PyObject *PyUnicodeUCS2_DecodeMBCS(char *string, Py_ssize_t length, char *errors); 
     618      PyObject *PyUnicodeUCS2_DecodeMBCS(c_str s, Py_ssize_t length, c_str errors); 
    613619      PyObject *PyUnicodeUCS2_AsMBCSString(PyObject *unicode); 
    614       PyObject *PyUnicodeUCS2_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, char *errors); 
     620      PyObject *PyUnicodeUCS2_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c_str errors); 
    615621    } 
    616622 
    617     int PyUnicodeUCS2_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, char *output, char *errors); 
     623    int PyUnicodeUCS2_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c_str output, c_str errors); 
    618624 
    619625    PyObject *PyUnicodeUCS2_Concat(PyObject *left, PyObject *right); 
     
    625631    } 
    626632    PyObject *PyUnicodeUCS2_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 
    627     PyObject *PyUnicodeUCS2_Translate(PyObject *str, PyObject *table, char *errors); 
     633    PyObject *PyUnicodeUCS2_Translate(PyObject *str, PyObject *table, c_str errors); 
    628634    PyObject *PyUnicodeUCS2_Join(PyObject *separator, PyObject *seq); 
    629635    Py_ssize_t PyUnicodeUCS2_Tailmatch(PyObject *str, PyObject *substr, 
     
    668674 
    669675    int PyUnicodeUCS4_Resize(PyObject **unicode, Py_ssize_t length); 
    670     PyObject *PyUnicodeUCS4_FromEncodedObject(PyObject *obj, char *encoding, char *errors); 
     676    PyObject *PyUnicodeUCS4_FromEncodedObject(PyObject *obj, c_str encoding, c_str errors); 
    671677    PyObject *PyUnicodeUCS4_FromObject(PyObject *obj); 
    672678 
     
    676682    PyObject *PyUnicodeUCS4_FromOrdinal(int ordinal); 
    677683 
    678     PyObject *_PyUnicodeUCS4_AsDefaultEncodedString(PyObject *, char *); 
    679  
    680     char *PyUnicodeUCS4_GetDefaultEncoding(); 
    681     int PyUnicodeUCS4_SetDefaultEncoding(char *encoding); 
    682  
    683     PyObject *PyUnicodeUCS4_Decode(char *s, Py_ssize_t size, char *encoding, char *errors); 
    684     PyObject *PyUnicodeUCS4_Encode(Py_UNICODE *s, Py_ssize_t size, char *encoding, char *errors); 
    685     PyObject *PyUnicodeUCS4_AsEncodedObject(PyObject *unicode, char *encoding, char *errors); 
    686     PyObject *PyUnicodeUCS4_AsEncodedString(PyObject *unicode, char *encoding, char *errors); 
    687  
    688     PyObject *PyUnicodeUCS4_DecodeUTF7(char *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); 
    689695    PyObject *PyUnicodeUCS4_EncodeUTF7(Py_UNICODE *data, Py_ssize_t length, 
    690         int encodeSetO, int encodeWhiteSpace, char *errors 
     696        int encodeSetO, int encodeWhiteSpace, c_str errors 
    691697      ); 
    692698 
    693     PyObject *PyUnicodeUCS4_DecodeUTF8(char *string, Py_ssize_t length, char *errors); 
    694     PyObject *PyUnicodeUCS4_DecodeUTF8Stateful(char *string, Py_ssize_t length, 
    695         char *errors, Py_ssize_t *consumed 
     699    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 
    696702      ); 
    697703    PyObject *PyUnicodeUCS4_AsUTF8String(PyObject *unicode); 
    698     PyObject *PyUnicodeUCS4_EncodeUTF8(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    699  
    700     PyObject *PyUnicodeUCS4_DecodeUTF16(char *string, Py_ssize_t length, char *errors, int *byteorder); 
    701     PyObject *PyUnicodeUCS4_DecodeUTF16Stateful(char *string, Py_ssize_t length, 
    702         char *errors, int *byteorder, Py_ssize_t *consumed 
     704    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 
    703709      ); 
    704710    PyObject *PyUnicodeUCS4_AsUTF16String(PyObject *unicode); 
    705711    PyObject *PyUnicodeUCS4_EncodeUTF16(Py_UNICODE *data, Py_ssize_t length, 
    706         char *errors, int byteorder 
     712        c_str errors, int byteorder 
    707713      ); 
    708714 
    709     PyObject *PyUnicodeUCS4_DecodeUnicodeEscape(char *string, Py_ssize_t length, char *errors); 
     715    PyObject *PyUnicodeUCS4_DecodeUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 
    710716    PyObject *PyUnicodeUCS4_AsUnicodeEscapeString(PyObject *unicode); 
    711717    PyObject *PyUnicodeUCS4_EncodeUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 
    712     PyObject *PyUnicodeUCS4_DecodeRawUnicodeEscape(char *string, Py_ssize_t length, char *errors); 
     718    PyObject *PyUnicodeUCS4_DecodeRawUnicodeEscape(c_str s, Py_ssize_t length, c_str errors); 
    713719    PyObject *PyUnicodeUCS4_AsRawUnicodeEscapeString(PyObject *unicode); 
    714720    PyObject *PyUnicodeUCS4_EncodeRawUnicodeEscape(Py_UNICODE *data, Py_ssize_t length); 
    715721 
    716     PyObject *_PyUnicodeUCS4_DecodeUnicodeInternal(char *string, Py_ssize_t length, char *errors); 
    717  
    718     PyObject *PyUnicodeUCS4_DecodeLatin1(char *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); 
    719725    PyObject *PyUnicodeUCS4_AsLatin1String(PyObject *unicode); 
    720     PyObject *PyUnicodeUCS4_EncodeLatin1(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    721  
    722     PyObject *PyUnicodeUCS4_DecodeASCII(char *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); 
    723729    PyObject *PyUnicodeUCS4_AsASCIIString(PyObject *unicode); 
    724     PyObject *PyUnicodeUCS4_EncodeASCII(Py_UNICODE *data, Py_ssize_t length, char *errors); 
    725  
    726     PyObject *PyUnicodeUCS4_DecodeCharmap(char *string, Py_ssize_t length, 
    727         PyObject *mapping, char *errors 
     730    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 
    728734      ); 
    729735    PyObject *PyUnicodeUCS4_AsCharmapString(PyObject *unicode, PyObject *mapping); 
    730736    PyObject *PyUnicodeUCS4_EncodeCharmap(Py_UNICODE *data, Py_ssize_t length, 
    731         PyObject *mapping, char *errors 
     737        PyObject *mapping, c_str errors 
    732738      ); 
    733739    PyObject *PyUnicodeUCS4_TranslateCharmap(Py_UNICODE *data, Py_ssize_t length, 
    734         PyObject *table, char *errors 
     740        PyObject *table, c_str errors 
    735741      ); 
    736742 
    737743    version (Windows) { 
    738       PyObject *PyUnicodeUCS4_DecodeMBCS(char *string, Py_ssize_t length, char *errors); 
     744      PyObject *PyUnicodeUCS4_DecodeMBCS(c_str s, Py_ssize_t length, c_str errors); 
    739745      PyObject *PyUnicodeUCS4_AsMBCSString(PyObject *unicode); 
    740       PyObject *PyUnicodeUCS4_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, char *errors); 
     746      PyObject *PyUnicodeUCS4_EncodeMBCS(Py_UNICODE *data, Py_ssize_t length, c_str errors); 
    741747    } 
    742748 
    743     int PyUnicodeUCS4_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, char *output, char *errors); 
     749    int PyUnicodeUCS4_EncodeDecimal(Py_UNICODE *s, Py_ssize_t length, c_str output, c_str errors); 
    744750 
    745751    PyObject *PyUnicodeUCS4_Concat(PyObject *left, PyObject *right); 
     
    751757    } 
    752758    PyObject *PyUnicodeUCS4_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 
    753     PyObject *PyUnicodeUCS4_Translate(PyObject *str, PyObject *table, char *errors); 
     759    PyObject *PyUnicodeUCS4_Translate(PyObject *str, PyObject *table, c_str errors); 
    754760    PyObject *PyUnicodeUCS4_Join(PyObject *separator, PyObject *seq); 
    755761    Py_ssize_t PyUnicodeUCS4_Tailmatch(PyObject *str, PyObject *substr, 
     
    12161222  } 
    12171223 
    1218   PyObject * PyString_FromStringAndSize(char *, Py_ssize_t); 
    1219   PyObject * PyString_FromString(char *); 
     1224  PyObject * PyString_FromStringAndSize(c_str, Py_ssize_t); 
     1225  PyObject * PyString_FromString(c_str); 
    12201226  // PyString_FromFormatV omitted 
    1221   PyObject * PyString_FromFormat(char*, ...); 
     1227  PyObject * PyString_FromFormat(c_str, ...); 
    12221228  Py_ssize_t PyString_Size(PyObject *); 
    1223   char * PyString_AsString(PyObject *); 
     1229  c_str PyString_AsString(PyObject *); 
    12241230  /* Use only if you know it's a string */ 
    12251231  int PyString_CHECK_INTERNED(PyObject* op) { 
     
    12271233  } 
    12281234  /* Macro, trading safety for speed */ 
    1229   char* PyString_AS_STRING(PyObject* op) { 
     1235  c_str PyString_AS_STRING(PyObject* op) { 
    12301236    return (cast(PyStringObject*)op).ob_sval; 
    12311237  } 
     
    12461252 
    12471253 
    1248   PyObject* PyString_Decode(char *s, Py_ssize_t size, char *encoding, char *errors); 
    1249   PyObject* PyString_Encode(char *s, Py_ssize_t size, char *encoding, char *errors); 
    1250  
    1251   PyObject* PyString_AsEncodedObject(PyObject *str, char *encoding, char *errors); 
    1252   PyObject* PyString_AsDecodedObject(PyObject *str, char *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); 
    12531259 
    12541260  // Since no one has legacy Python extensions written in D, the deprecated 
     
    14341440  int PyDict_MergeFromSeq2(PyObject *d, PyObject *seq2, int override_); 
    14351441 
    1436   PyObject * PyDict_GetItemString(PyObject *dp, char *key); 
    1437   int PyDict_SetItemString(PyObject *dp, char *key, PyObject *item); 
    1438   int PyDict_DelItemString(PyObject *dp, char *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); 
    14391445 
    14401446 
     
    14621468 
    14631469  struct PyMethodDef { 
    1464     char   *ml_name; 
     1470    c_str   ml_name; 
    14651471    PyCFunction  ml_meth; 
    14661472    int      ml_flags; 
    1467     char   *ml_doc; 
    1468   } 
    1469  
    1470   PyObject * Py_FindMethod(PyMethodDef[], PyObject *, char *); 
     1473    c_str   ml_doc; 
     1474  } 
     1475 
     1476  PyObject * Py_FindMethod(PyMethodDef[], PyObject *, c_str); 
    14711477