Changeset 54

Show
Ignore:
Timestamp:
12/12/06 17:10:59 (2 years ago)
Author:
KirkMcDonald
Message:

DMD 0.177 update

Files:

Legend:

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

    r53 r54  
    6262extern(C) 
    6363export void initrawexample() { 
    64     PyObject* m = Py_InitModule("rawexample", rawexample_methods); 
     64    PyObject* m = Py_InitModule("rawexample", rawexample_methods.ptr); 
    6565 
    6666    Base_type.ob_type = PyType_Type_p; 
  • trunk/infrastructure/pyd/class_wrap.d

    r52 r54  
    262262        // It's possible that appending the empty item invalidated the 
    263263        // pointer in the type struct, so we renew it here. 
    264         wrapped_class_type!(T).tp_methods = list
     264        wrapped_class_type!(T).tp_methods = list.ptr
    265265    } 
    266266 
     
    291291        pragma(msg, "class.prop: " ~ name); 
    292292        static PyGetSetDef empty = { null, null, null, null, null }; 
    293         wrapped_prop_list!(T)[length-1].name = name ~ \0
     293        wrapped_prop_list!(T)[length-1].name = (name ~ \0).ptr
    294294        wrapped_prop_list!(T)[length-1].get = 
    295295            &wrapped_get!(T, fn).func; 
     
    304304        // pointer in the type struct, so we renew it here. 
    305305        wrapped_class_type!(T).tp_getset = 
    306             wrapped_prop_list!(T)
     306            wrapped_prop_list!(T).ptr
    307307    } 
    308308 
     
    379379    type.ob_type      = PyType_Type_p(); 
    380380    type.tp_basicsize = (wrapped_class_object!(T)).sizeof; 
    381     type.tp_doc       = name ~ " objects" ~ \0
     381    type.tp_doc       = (name ~ " objects" ~ \0).ptr
    382382    type.tp_flags     = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; 
    383383    //type.tp_repr      = &wrapped_repr!(T).repr; 
    384     type.tp_methods   = wrapped_method_list!(T)
    385     type.tp_name      = module_name ~ "." ~ name ~ \0
     384    type.tp_methods   = wrapped_method_list!(T).ptr
     385    type.tp_name      = (module_name ~ "." ~ name ~ \0).ptr
    386386 
    387387    // Numerical operator overloads 
     
    431431    } 
    432432    Py_INCREF(cast(PyObject*)&type); 
    433     PyModule_AddObject(Pyd_Module_p(modulename), name, cast(PyObject*)&type); 
     433    PyModule_AddObject(Pyd_Module_p(modulename), name.ptr, cast(PyObject*)&type); 
    434434    is_wrapped!(T) = true; 
    435435    wrapped_classes[typeid(T)] = true; 
     
    471471        return obj; 
    472472    } else { 
    473         PyErr_SetString(PyExc_RuntimeError, "Type " ~ typeid(T).toString() ~ " is not wrapped by Pyd."); 
     473        PyErr_SetString(PyExc_RuntimeError, ("Type " ~ typeid(T).toString() ~ " is not wrapped by Pyd.").ptr); 
    474474        return null; 
    475475    } 
  • trunk/infrastructure/pyd/def.d

    r52 r54  
    8787    PyMethodDef[]* list = &module_methods[modulename]; 
    8888 
    89     (*list)[length-1].ml_name = name ~ \0
     89    (*list)[length-1].ml_name = (name ~ \0).ptr
    9090    (*list)[length-1].ml_meth = &function_wrap!(fn, MIN_ARGS, fn_t).func; 
    9191    (*list)[length-1].ml_flags = METH_VARARGS; 
     
    9999PyObject* module_init(char[] name) { 
    100100    //_loadPythonSupport(); 
    101     pyd_modules[""] = Py_InitModule(name ~ \0, module_methods[""].ptr); 
     101    pyd_modules[""] = Py_InitModule((name ~ \0).ptr, module_methods[""].ptr); 
    102102    return pyd_modules[""]; 
    103103} 
     
    107107 */ 
    108108PyObject* add_module(char[] name) { 
    109     pyd_modules[name] = Py_InitModule(name ~ \0, module_methods[name].ptr); 
     109    pyd_modules[name] = Py_InitModule((name ~ \0).ptr, module_methods[name].ptr); 
    110110    return pyd_modules[name]; 
    111111} 
  • trunk/infrastructure/pyd/exception.d

    r46 r54  
    7777    // Python exception. 
    7878    catch (Exception e) { 
    79         PyErr_SetString(PyExc_RuntimeError, "D Exception: " ~ e.classinfo.name ~ ": " ~ e.msg ~ \0); 
     79        PyErr_SetString(PyExc_RuntimeError, ("D Exception: " ~ e.classinfo.name ~ ": " ~ e.msg ~ \0).ptr); 
    8080        return error_code!(T)(); 
    8181    } 
    8282    // Some other D object was thrown. Deal with it. 
    8383    catch (Object o) { 
    84         PyErr_SetString(PyExc_RuntimeError, "thrown D Object: " ~ o.classinfo.name ~ ": " ~ o.toString() ~ \0); 
     84        PyErr_SetString(PyExc_RuntimeError, ("thrown D Object: " ~ o.classinfo.name ~ ": " ~ o.toString() ~ \0).ptr); 
    8585        return error_code!(T)(); 
    8686    } 
  • trunk/infrastructure/pyd/func_wrap.d

    r52 r54  
    8585    str ~= " (" ~ toString(gotArgs) ~ " given)"; 
    8686 
    87     PyErr_SetString(PyExc_TypeError, str ~ \0); 
     87    PyErr_SetString(PyExc_TypeError, (str ~ \0).ptr); 
    8888} 
    8989 
  • trunk/infrastructure/pyd/make_object.d

    r52 r54  
    165165        return t; 
    166166    } 
    167     PyErr_SetString(PyExc_RuntimeError, "D conversion function _py failed with type " ~ typeid(T).toString()); 
     167    PyErr_SetString(PyExc_RuntimeError, ("D conversion function _py failed with type " ~ typeid(T).toString()).ptr); 
    168168    return null; 
    169169} 
  • trunk/infrastructure/pyd/pydobject.d

    r49 r54  
    9191    /// Same as _hasattr(this, attr_name) in Python. 
    9292    bool hasattr(char[] attr_name) { 
    93         return PyObject_HasAttrString(m_ptr, attr_name ~ \0) == 1; 
     93        return PyObject_HasAttrString(m_ptr, (attr_name ~ \0).ptr) == 1; 
    9494    } 
    9595 
     
    101101    /// Same as _getattr(this, attr_name) in Python. 
    102102    PydObject getattr(char[] attr_name) { 
    103         return new PydObject(PyObject_GetAttrString(m_ptr, attr_name ~ \0)); 
     103        return new PydObject(PyObject_GetAttrString(m_ptr, (attr_name ~ \0).ptr)); 
    104104    } 
    105105 
     
    113113     */ 
    114114    void setattr(char[] attr_name, PydObject v) { 
    115         if (PyObject_SetAttrString(m_ptr, attr_name ~ \0, v.m_ptr) == -1) 
     115        if (PyObject_SetAttrString(m_ptr, (attr_name ~ \0).ptr, v.m_ptr) == -1) 
    116116            handle_exception(); 
    117117    } 
     
    129129     */ 
    130130    void delattr(char[] attr_name) { 
    131         if (PyObject_DelAttrString(m_ptr, attr_name ~ \0) == -1) 
     131        if (PyObject_DelAttrString(m_ptr, (attr_name ~ \0).ptr) == -1) 
    132132            handle_exception(); 
    133133    } 
     
    227227    PydObject method(char[] name, PydObject args=null) { 
    228228        // Get the method PydObject 
    229         PyObject* m = PyObject_GetAttrString(m_ptr, name ~ \0); 
     229        PyObject* m = PyObject_GetAttrString(m_ptr, (name ~ \0).ptr); 
    230230        PyObject* self_tuple, args_tuple, result; 
    231231        // If this method doesn't exist (or other error), throw exception 
     
    254254    PydObject method(char[] name, PydObject args, PydObject kw) { 
    255255        // Get the method PydObject 
    256         PyObject* m = PyObject_GetAttrString(m_ptr, name ~ \0); 
     256        PyObject* m = PyObject_GetAttrString(m_ptr, (name ~ \0).ptr); 
    257257        PyObject* self_tuple, args_tuple, result; 
    258258        // If this method doesn't exist (or other error), throw exception. 
     
    328328     */ 
    329329    PydObject opIndex(char[] key) { 
    330         return new PydObject(PyMapping_GetItemString(m_ptr, key ~ \0)); 
     330        return new PydObject(PyMapping_GetItemString(m_ptr, (key ~ \0).ptr)); 
    331331    } 
    332332    /// Equivalent to o[_i] in Python; usually only makes sense for sequences. 
     
    345345     */ 
    346346    void opIndexAssign(PydObject value, char[] key) { 
    347         if (PyMapping_SetItemString(m_ptr, key ~ \0, value.m_ptr) == -1) 
     347        if (PyMapping_SetItemString(m_ptr, (key ~ \0).ptr, value.m_ptr) == -1) 
    348348            handle_exception(); 
    349349    } 
     
    367367     */ 
    368368    void delItem(char[] key) { 
    369         if (PyMapping_DelItemString(m_ptr, key ~ \0) == -1) 
     369        if (PyMapping_DelItemString(m_ptr, (key ~ \0).ptr) == -1) 
    370370            handle_exception(); 
    371371    } 
     
    739739    /// Same as opIn_r 
    740740    bool hasKey(char[] key) { 
    741         int result = PyMapping_HasKeyString(m_ptr, key ~ \0); 
     741        int result = PyMapping_HasKeyString(m_ptr, (key ~ \0).ptr); 
    742742        if (result == -1) handle_exception(); 
    743743        return result == 1; 
  • trunk/infrastructure/pyd/struct_wrap.d

    r52 r54  
    7171        static PyGetSetDef empty = {null, null, null, null, null}; 
    7272        alias wrapped_prop_list!(T*) list; 
    73         list[length-1].name = name ~ \0
     73        list[length-1].name = (name ~ \0).ptr
    7474        list[length-1].get = &wrapped_member!(T*, M, offset).get; 
    7575        list[length-1].set = &wrapped_member!(T*, M, offset).set; 
  • trunk/infrastructure/python/2.4/python.d

    r45 r54  
    11921192    // Will the D layout for a 1-PyObject* array be the same as the C layout? 
    11931193    // I think the D array will be larger. 
    1194     PyObject *ob_item[1]; 
     1194    PyObject *_ob_item[1]; 
     1195    PyObject** ob_item() { 
     1196      return _ob_item.ptr; 
     1197    } 
    11951198  } 
    11961199 
     
    31483151  // Will the D layout for a 1-obj array be the same as the C layout?  I 
    31493152  // think the D array will be larger. 
    3150   PyObject *ob_item[1]; 
     3153  PyObject *_ob_item[1]; 
     3154  PyObject** ob_item() { 
     3155    return _ob_item.ptr; 
     3156  } 
    31513157} 
    31523158 
     
    33013307PyObject *eval(char[] code) { 
    33023308    PyObject *pyGlobals = PyEval_GetGlobals(); /* borrowed ref */ 
    3303     PyObject *res = PyRun_String(code ~ \0, Py_eval_input, 
     3309    PyObject *res = PyRun_String((code ~ \0).ptr, Py_eval_input, 
    33043310        pyGlobals, pyGlobals 
    33053311    ); /* New ref, or NULL on error. */ 
     
    33193325    if (Ptr is null) { 
    33203326        PyObject* sys_modules = PyImport_GetModuleDict(); 
    3321         Ptr = PyDict_GetItemString(sys_modules, name ~ \0); 
     3327        Ptr = PyDict_GetItemString(sys_modules, (name ~ \0).ptr); 
    33223328    } 
    33233329    assert (Ptr !is null, "python.d couldn't load " ~ name ~ " attribute!"); 
     
    33313337typeof(Ptr) lazy_load(alias from, alias Ptr, char[] name) () { 
    33323338    if (Ptr is null) { 
    3333         Ptr = cast(typeof(Ptr)) PyObject_GetAttrString(from(), name ~ \0); 
     3339        Ptr = cast(typeof(Ptr)) PyObject_GetAttrString(from(), (name ~ \0).ptr); 
    33343340    } 
    33353341    assert (Ptr !is null, "python.d couldn't load " ~ name ~ " attribute!"); 
  • trunk/infrastructure/python/2.5/python.d

    r45 r54  
    12371237    // Will the D layout for a 1-PyObject* array be the same as the C layout? 
    12381238    // I think the D array will be larger. 
    1239     PyObject *ob_item[1]; 
     1239    PyObject *_ob_item[1]; 
     1240    PyObject** ob_item() { 
     1241      return _ob_item.ptr; 
     1242    } 
    12401243  } 
    12411244 
     
    34433446  // Will the D layout for a 1-obj array be the same as the C layout?  I 
    34443447  // think the D array will be larger. 
    3445   PyObject *ob_item[1]; 
     3448  PyObject *_ob_item[1]; 
     3449  PyObject** ob_item() { 
     3450    return _ob_item.ptr; 
     3451  } 
    34463452} 
    34473453 
     
    35963602PyObject *eval(char[] code) { 
    35973603    PyObject *pyGlobals = PyEval_GetGlobals(); /* borrowed ref */ 
    3598     PyObject *res = PyRun_String(code ~ \0, Py_eval_input, 
     3604    PyObject *res = PyRun_String((code ~ \0).ptr, Py_eval_input, 
    35993605        pyGlobals, pyGlobals 
    36003606    ); /* New ref, or NULL on error. */ 
     
    36143620    if (Ptr is null) { 
    36153621        PyObject* sys_modules = PyImport_GetModuleDict(); 
    3616         Ptr = PyDict_GetItemString(sys_modules, name ~ \0); 
     3622        Ptr = PyDict_GetItemString(sys_modules, (name ~ \0).ptr); 
    36173623    } 
    36183624    assert (Ptr !is null, "python.d couldn't load " ~ name ~ " attribute!"); 
     
    36263632typeof(Ptr) lazy_load(alias from, alias Ptr, char[] name) () { 
    36273633    if (Ptr is null) { 
    3628         Ptr = cast(typeof(Ptr)) PyObject_GetAttrString(from(), name ~ \0); 
     3634        Ptr = cast(typeof(Ptr)) PyObject_GetAttrString(from(), (name ~ \0).ptr); 
    36293635    } 
    36303636    assert (Ptr !is null, "python.d couldn't load " ~ name ~ " attribute!");