Changeset 48

Show
Ignore:
Timestamp:
10/24/04 02:19:33 (4 years ago)
Author:
aldacron
Message:

[DerelictAL]
* removed some OpenGL references from the README
[DerelictGL]
* ripped out everything related to GLee.
[DerelictPY]
* added missing macros to several existing modules
* added templated PyObject?_HEAD and PyObject?_VAR_HEAD to object.d and changed all PyObject? and PyVarObject? struct declarations to use them as mixins
* removed some things from object.d and put them in descrobject.d and methodobject.d to match the C headers
* added version(USING_UNICODE) to unicode-related code
* added several new modules

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/DerelictAL/README

    r46 r48  
    3131++++++++++++++++++++++++++   CODE  +++++++++++++++++++++++++++++++++++++++++++++ 
    3232 
    33 import derelict.openal.al;      // core GL 1.1 functions 
    34 import glee;                    // Core GL functions up to 1.5 plus extensions 
     33import derelict.openal.al; 
    3534 
    3635++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  • trunk/DerelictGL/README

    r46 r48  
    55without the need to link to an import library. This gives you control over how 
    66to handle the case where the OpenGL shared library is not available on the 
    7 user's machine. DerelictGL also exposes all available core OpenGL functions 
    8 and extensions up to version 1.5 through Joel Anderson's port of Ben Woodhouse's 
    9 GL Easy Extensions (GLee) library. 
     7user's machine. 
    108 
    119Please note that the Linux version is not yet implemented. Anyone who would like 
     
    2119instructions). 
    2220 
    23 If you link to derelictGL.lib or the glee.d object file (one of which you must 
    24 do to make use of extensions), then you need to also use the supplied go.bat 
    25 file to build glee.lib with DMC and link with it as well. If you do not need 
    26 OpenGL functionality beyond version 1.1 *and* have no need for extensions, then 
    27 simply compile and link gl.d as part of your project and ignore glee.d and 
    28 the lib files.  
    29  
    30 In your code, you need to import the derelict.opengl.gl module. To make use 
    31 of GLEE extensions, import glee; 
     21In your code, you need to import the derelict.opengl.gl module. 
    3222 
    3323++++++++++++++++++++++++++   CODE  +++++++++++++++++++++++++++++++++++++++++++++ 
    3424 
    3525import derelict.opengl.gl;      // core GL 1.1 functions 
    36 import glee;                    // Core GL functions up to 1.5 plus extensions 
    3726 
    3827++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
     
    4433can go on about your business. 
    4534 
    46 If you wish to use GLee, then you'll need to make a call to GLeeInit. The catch  
    47 is that you must first create and activate an OpenGL context (if you aren't sure 
    48 what I'm talking about, take a gander at the nehe.gamedev.net OpenGL tutorials). 
    49 OpenGL requires that a GL context be active before querying for extensions. This 
    50 is why DerelictGL_Load only loads the core 1.1 functions. Once your context is  
    51 activated, calling GLeeInit will load all available core OpenGL 1.5 functions as 
    52 well as all available extensions. 
    53  
    54 Additionally, the use of GLee requires that you link to the C library GLee.lib 
    55 found in <derelict_dir>\DerelictGL\glee_dist\cbuild. GLee is a static library, 
    56 and not a DLL. 
    57  
    58 If you prefer linking to DerelictGL without including GLee, you can either include 
    59 GL.d and GL.obj on your project's build path, or make the DerelictGL library with 
    60 the command 'make lib_noglee' (see BUILDING below). You will then have to setup 
    61 and load any extensions manually. 
    6235 
    6336++++++++++++++++++++++++++   CODE  +++++++++++++++++++++++++++++++++++++++++++++ 
     
    6942... 
    7043 
    71 // load extensions via GLee 
    72 GLeeInit(); 
    73  
    7444 
    7545++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    76  
    77 Once the extensions are loaded, you can query for the availability of those 
    78 you need via GLee's extension flags. These take the same form as the extension 
    79 names, except that the 'GL_' in the names is replaced with 'GLEE_'. So, for 
    80 example, GL_ARB_vertex_program becomes GLEE_ARB_vertex_program.  
    81  
    82 Platform-specific extensions, such as the 'WGL_' extensions, follow a different  
    83 naming convention in that 'GLEE_' is prefixed to the extension name such that  
    84 WGL_ARB_buffer_region becomes GLEE_WGL_ARB_buffer_region. 
    85  
    86 And finally, variables for querying the version of OpenGL available beyond 1.1 
    87 take the form of 'GLEE_VERSION_(major)_(minor)', such as 'GLEE_VERSION_1_2'. 
    88  
    89 The query variables will be set to 0 if the extension or version is unavailable. 
    90  
    91 ++++++++++++++++++++++++++   CODE  +++++++++++++++++++++++++++++++++++++++++++++ 
    92  
    93 // querying for specific GL versions 
    94 if(GLEE_VERSION_1_5) 
    95     // do GL 1.5 stuff 
    96 else if(GLEE_VERSION_1_4) 
    97     // do GL 1.4 stuff 
    98  
    99 // querying for specific extensions 
    100 if(GLEE_ARB_vertex_program) 
    101     ... 
    102  
    103 if(GLEE_EXT_abgr) 
    104     ... 
    105  
    106 if(GLEE_WGL_ARB_pbuffer) 
    107     ... 
    108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    109  
    110 If you need to get the actual version/extension strings (or any other gl strings, 
    111 such as the vendor string) you can use glGetString as normal. Note, however, that 
    112 GLee provides some convenience functions which can be used to get standard and 
    113 platform-specific extensions, as well as error, strings: 
    114  
    115 GLeeGetExtStrGL(); 
    116 GLeeGetExtStrWGL(); // windows 
    117 GLeeGetExtStrGLX(); // linux 
    118 GLeeGetErrorString() 
    11946 
    12047 
     
    127541) ensure that both dmd\bin and dm\bin are on your path 
    128552) from a command prompt, cd to <derelict_dir>\DerelictGL 
    129 3) type 'make' or 'make lib' to build derelictGL.lib with GLee 
    130    optionally type 'make noglee' to build derelictGL.lib without GLee     
     563) type 'make' or 'make lib' to build derelictGL.lib 
    131574) optionally type 'make clean' to delete all object files OR 
    13258   optionally type 'make cleanall' to delete all object and lib files 
    133 5) optionally run <derelict_dir>\DerelictGL\glee_dist\cbuild\go.bat to build the 
    134 C library GLee.lib - this only need be done once but is required to make use of GLee. 
    13559 
  • trunk/DerelictPY/Makefile

    r41 r48  
    1515    $(PY.SRC.DIR)\cellobject.d \ 
    1616    $(PY.SRC.DIR)\cobject.d \ 
     17    $(PY.SRC.DIR)\compile.d \ 
    1718    $(PY.SRC.DIR)\complexobject.d \ 
    1819    $(PY.SRC.DIR)\descrobject.d \ 
    1920    $(PY.SRC.DIR)\errcode.d \ 
    2021    $(PY.SRC.DIR)\floatobject.d \ 
     22    $(PY.SRC.DIR)\frameobject.d \ 
    2123    $(PY.SRC.DIR)\intobject.d \ 
    2224    $(PY.SRC.DIR)\longintrepr.d \ 
    2325    $(PY.SRC.DIR)\longobject.d \ 
    2426    $(PY.SRC.DIR)\methodobject.d \ 
     27    $(PY.SRC.DIR)\node.d \ 
    2528    $(PY.SRC.DIR)\object.d \ 
    2629    $(PY.SRC.DIR)\python.d \ 
     30    $(PY.SRC.DIR)\pythonrun.d \ 
     31    $(PY.SRC.DIR)\tupleobject.d \ 
    2732    $(PY.SRC.DIR)\unicodeobject.d 
    2833     
     
    3338    $(PY.OBJ.DIR)\bufferobject.obj \ 
    3439    $(PY.OBJ.DIR)\cobject.obj \ 
     40    $(PY.OBJ.DIR)\compile.obj \ 
    3541    $(PY.OBJ.DIR)\complexobject.obj \ 
    3642    $(PY.OBJ.DIR)\cellobject.obj \ 
     
    3844    $(PY.OBJ.DIR)\errcode.obj \ 
    3945    $(PY.OBJ.DIR)\floatobject.obj \ 
     46    $(PY.OBJ.DIR)\frameobject.obj \ 
    4047    $(PY.OBJ.DIR)\intobject.obj \ 
    4148    $(PY.OBJ.DIR)\longintrepr.obj \ 
    4249    $(PY.OBJ.DIR)\longobject.obj \ 
    4350    $(PY.OBJ.DIR)\methodobject.obj \ 
     51    $(PY.OBJ.DIR)\node.obj \ 
    4452    $(PY.OBJ.DIR)\object.obj \ 
    4553    $(PY.OBJ.DIR)\python.obj \ 
     54    $(PY.OBJ.DIR)\pythonrun.obj \ 
     55    $(PY.OBJ.DIR)\tupleobject.obj \ 
    4656    $(PY.OBJ.DIR)\unicodeobject.obj 
    4757     
  • trunk/DerelictPY/derelict/python/boolobject.d

    r37 r48  
    1515 
    1616//============================================================================== 
    17 // TYPES 
     17// MACROS 
     18//============================================================================== 
     19bit PyBool_Check(PyObject* obj) 
     20
     21    return (obj.ob_type is PyBool_Type); 
     22
     23 
     24//============================================================================== 
     25// FUNCTIONS 
    1826//============================================================================== 
    1927extern(C) 
    2028{ 
    2129typedef PyObject* function(int) pfPyBool_FromLong; 
    22 pfPyBool_FromLong           PyBoolFromLong; 
     30pfPyBool_FromLong           PyBool_FromLong; 
    2331} 
  • trunk/DerelictPY/derelict/python/bufferobject.d

    r37 r48  
    99 
    1010PyTypeObject* PyBuffer_Type; 
     11 
     12//============================================================================== 
     13// MACROS 
     14//============================================================================== 
     15bit PyBuffer_Check(PyObject *obj) 
     16{ 
     17    return (obj.ob_type is PyBuffer_Type); 
     18} 
    1119 
    1220//============================================================================== 
  • trunk/DerelictPY/derelict/python/cellobject.d

    r40 r48  
    88struct PyCellObject 
    99{ 
    10     int ob_refcnt; 
    11     PyTypeObject* ob_type; 
     10    mixin PyObject_HEAD; 
    1211    PyObject* ob_ref; 
    1312} 
    1413 
    1514PyTypeObject* PyCell_Type; 
     15 
     16//============================================================================== 
     17// MACROS 
     18//============================================================================== 
     19bit PyCell_Check(PyObject *obj) 
     20{ 
     21    return (obj.ob_type is PyCell_Type); 
     22} 
    1623 
    1724//============================================================================== 
  • trunk/DerelictPY/derelict/python/cobject.d

    r41 r48  
    77//============================================================================== 
    88PyTypeObject* PyCObject_Type; 
     9 
     10//============================================================================== 
     11// MACROS 
     12//============================================================================== 
     13bit PyCObject_Check(PyObject* obj) 
     14{ 
     15    return (obj.ob_type is PyCObject_Type); 
     16} 
    917 
    1018//============================================================================== 
  • trunk/DerelictPY/derelict/python/complexobject.d

    r41 r48  
    1414struct PyComplexObject  
    1515{ 
    16     int ob_refcnt; 
    17     PyTypeObject *ob_type; 
     16    mixin PyObject_HEAD; 
    1817    Py_complex cval; 
    1918} 
    2019 
    2120PyTypeObject* PyComplex_Type; 
     21 
     22//============================================================================== 
     23// MACROS 
     24//============================================================================== 
     25bit PyComplex_Check(PyObject *obj) 
     26{ 
     27    return PyObject_TypeCheck(obj, PyComplex_Type); 
     28} 
     29 
     30bit PyComplex_CheckExact(PyObject *obj) 
     31{ 
     32    return (obj.ob_type is PyComplex_Type); 
     33} 
    2234 
    2335//============================================================================== 
  • trunk/DerelictPY/derelict/python/descrobject.d

    r37 r48  
    22 
    33private import derelict.python.object; 
     4private import derelict.python.methodobject; 
    45 
    56//============================================================================== 
     
    910{ 
    1011 
     12typedef PyObject* function(PyObject*, void*) getter; 
     13typedef int function(PyObject*, PyObject*, void*) setter; 
    1114typedef PyObject* function(PyObject*, PyObject*, void*) wrapperfunc; 
    1215typedef PyObject* function(PyObject*, PyObject*, void*, PyObject*) wrapperfunc_kwds; 
     
    2932struct PyDescrObject 
    3033{ 
    31     int ob_refcnt; 
    32     PyTypeObject* ob_type; 
     34    mixin PyObject_HEAD; 
    3335    PyTypeObject* d_type; 
    3436    PyObject* d_name; 
     
    3739struct PyMethodDescrObject 
    3840{ 
    39     int ob_refcnt; 
    40     PyTypeObject* ob_type; 
     41    mixin PyObject_HEAD; 
    4142    PyTypeObject* d_type; 
    4243    PyObject* d_name; 
     
    4647struct PyMemberDescrObject 
    4748{ 
    48     int ob_refcnt; 
    49     PyTypeObject* ob_type; 
     49    mixin PyObject_HEAD; 
    5050    PyTypeObject* d_type; 
    5151    PyObject* d_name; 
     
    5555struct PyGetSetDescrObject 
    5656{ 
    57     int ob_refcnt; 
    58     PyTypeObject* ob_type; 
     57    mixin PyObject_HEAD; 
    5958    PyTypeObject* d_type; 
    6059    PyObject* d_name; 
     
    6463struct PyWrapperDescrObject 
    6564{ 
    66     int ob_refcnt; 
    67     PyTypeObject* ob_type; 
     65    mixin PyObject_HEAD; 
    6866    PyTypeObject* d_type; 
    6967    PyObject* d_name; 
  • trunk/DerelictPY/derelict/python/floatobject.d

    r37 r48  
    88struct PyFloatObject 
    99{ 
    10     int ob_refcnt; 
    11     PyTypeObject *ob_type; 
     10    mixin PyObject_HEAD; 
    1211    double ob_fval; 
    1312} 
    1413 
    1514PyTypeObject* PyFloat_Type; 
     15 
     16//============================================================================== 
     17// MACROS 
     18//============================================================================== 
     19bit PyFloat_Check(PyObject* obj) 
     20{ 
     21    return PyObject_TypeCheck(obj, PyFloat_Type); 
     22} 
     23 
     24bit PyFloat_CheckExact(PyObject* obj) 
     25{ 
     26    return (obj.ob_type is PyFloat_Type); 
     27} 
     28 
     29double PyFloat_AS_DOUBLE(PyObject* obj) 
     30{ 
     31    PyFloatObject* fobj = cast(PyFloatObject*)obj; 
     32    return fobj.ob_fval; 
     33} 
    1634 
    1735//============================================================================== 
  • trunk/DerelictPY/derelict/python/intobject.d

    r37 r48  
    99struct PyIntObject 
    1010{ 
    11     int ob_refcnt; 
    12     PyTypeObject *ob_type; 
     11    mixin PyObject_HEAD; 
    1312    int ob_ival; 
    1413} 
    1514 
    1615PyTypeObject* PyInt_Type; 
     16 
     17//============================================================================== 
     18// MACROS 
     19//============================================================================== 
     20bit PyInt_Check(PyObject* obj) 
     21{ 
     22    return PyObject_TypeCheck(obj, PyInt_Type); 
     23} 
     24 
     25bit PyInt_CheckExact(PyObject* obj) 
     26{ 
     27    return (obj.ob_type is PyInt_Type); 
     28} 
    1729 
    1830//============================================================================== 
     
    2436 
    2537typedef PyObject* function(char*, char**, int) pfPyInt_FromString; 
    26 typedef PyObject* function(Py_UNICODE*, char**, int) pfPyInt_FromUnicode; 
    2738typedef PyObject* function(int) pfPyInt_FromLong; 
    2839typedef int function(PyObject*) pfPyInt_AsLong; 
     
    3344typedef int function(char*, char**, int) pfPyOS_strtol; 
    3445pfPyInt_FromString              PyInt_FromString; 
    35 pfPyInt_FromUnicode             PyInt_FromUnicode; 
    3646pfPyInt_FromLong                PyInt_FromLong; 
    3747pfPyInt_AsLong                  PyInt_AsLong; 
     
    4252pfPyOS_strtol                   PyOS_strtol; 
    4353 
     54version(USING_UNICODE) 
     55{ 
     56typedef PyObject* function(Py_UNICODE*, char**, int) pfPyInt_FromUnicode; 
     57pfPyInt_FromUnicode             PyInt_FromUnicode; 
     58} 
     59 
    4460} // extern(C) 
    4561 
  • trunk/DerelictPY/derelict/python/longintrepr.d

    r35 r48  
    1717struct PyLongObject 
    1818{ 
    19     int ob_refcnt; 
    20     PyTypeObject *ob_type; 
     19    mixin PyObject_HEAD; 
    2120    digit[1] ob_digit; 
    2221} 
  • trunk/DerelictPY/derelict/python/longobject.d

    r39 r48  
    1313 
    1414PyTypeObject* PyLong_Type; 
     15 
     16//============================================================================== 
     17// MACROS 
     18//============================================================================== 
     19bit PyLong_Check(PyObject* obj) 
     20{ 
     21    return PyObject_TypeCheck(obj, PyLong_Type); 
     22} 
     23 
     24bit PyLong_CheckExact(PyObject* obj) 
     25{ 
     26    return (obj.ob_type is PyLong_Type); 
     27} 
    1528 
    1629//============================================================================== 
     
    3649typedef PY_ULONG_LONG function(PyObject*) pfPyLong_AsUnsignedLongLongMask; 
    3750typedef PyObject* function(char*, char**, int) pfPyLong_FromString; 
    38 typedef PyObject* function(Py_UNICODE*, int, int) pfPyLong_FromUnicode; 
    3951typedef int function(PyObject*) pf_PyLong_Sign; 
    4052typedef size_t function(PyObject*) pf_PyLong_NumBits; 
     
    5769pfPyLong_AsUnsignedLongLongMask         PyLong_AsUnsignedLongLongMask; 
    5870pfPyLong_FromString                     PyLong_FromString; 
    59 pfPyLong_FromUnicode                    PyLong_FromUnicode; 
    6071pf_PyLong_Sign                          _PyLong_Sign; 
    6172pf_PyLong_NumBits                       _PyLong_NumBits; 
     
    6374pf_PyLong_AsByteArray                   _PyLong_AsByteArray; 
    6475 
     76version(USING_UNICODE) 
     77{ 
     78typedef PyObject* function(Py_UNICODE*, int, int) pfPyLong_FromUnicode; 
     79pfPyLong_FromUnicode                    PyLong_FromUnicode; 
     80} 
     81 
    6582} // extern(C) 
  • trunk/DerelictPY/derelict/python/methodobject.d

    r39 r48  
    2020    PyMethodChain* links; 
    2121} 
     22struct PyMethodDef 
     23{ 
     24    char* ml_name; 
     25    PyCFunction ml_meth; 
     26    int ml_flags; 
     27    char* ml_doc; 
     28} 
    2229 
    2330struct PyCFunctionObject 
    2431{ 
    25     int ob_refcnt; 
    26     PyTypeObject* ob_type; 
     32    mixin PyObject_HEAD; 
    2733    PyMethodDef* m_ml; 
    28     PyObject* *m_self; 
    29     PyObject* *m_module; 
     34    PyObject* m_self; 
     35    PyObject* m_module; 
    3036} 
    3137 
    3238PyTypeObject* PyCFunction_Type; 
    3339 
     40extern(C) 
     41{ 
     42typedef PyObject* function(PyObject*, PyObject*) PyCFunction; 
     43typedef PyObject* function(PyObject*, PyObject*, PyObject*) PyCFunctionWithKeywords; 
     44typedef PyObject* function(PyObject*) PyNoArgsFunction; 
     45} 
    3446 
    3547//============================================================================== 
    36 // METHODS 
     48// MACROS 
     49//============================================================================== 
     50bit PyCFunction_Check(PyObject* obj) 
     51
     52    return (obj.ob_type is PyCFunction_Type); 
     53
     54 
     55PyCFunction PyCFunction_GET_FUNCTION(PyObject* obj) 
     56
     57    PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 
     58    return func.m_ml.ml_meth; 
     59
     60 
     61PyObject* PyCFunction_GET_SELF(PyObject *obj) 
     62
     63    PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 
     64    return func.m_self; 
     65
     66 
     67int PyCFunction_GET_FLAGS(PyObject* obj) 
     68
     69    PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 
     70    return func.m_ml.ml_flags; 
     71
     72 
     73PyObject* PyCFunction_New(PyMethodDef* ml, PyObject* self) 
     74
     75    return PyCFunction_NewEx(ml, self, null); 
     76
     77 
     78//============================================================================== 
     79// FUNCTIONS 
    3780//============================================================================== 
    3881extern(C) 
  • trunk/DerelictPY/derelict/python/object.d

    r40 r48  
    33private import std.c.stdio; 
    44 
     5// declare these templates here so that the imports can use them as mixins 
     6// without worrying about forward reference errors 
     7template PyObject_HEAD() 
     8{ 
     9    int ob_refcnt; 
     10    PyTypeObject* ob_type; 
     11} 
     12 
     13template PyObject_VAR_HEAD() 
     14{ 
     15    mixin PyObject_HEAD; 
     16    int ob_size; 
     17} 
     18 
     19private import derelict.python.descrobject; 
     20private import derelict.python.methodobject; 
     21 
    522//============================================================================== 
    623// TYPES 
    724//============================================================================== 
    825extern(C) 
    9 
    10      
    11 // these two moved here from descrobject 
    12 typedef PyObject* function(PyObject*, void*) getter; 
    13 typedef int function(PyObject*, PyObject*, void*) setter; 
    14  
    15 // these three moved from methodobject 
    16 typedef PyObject* function(PyObject*, PyObject*) PyCFunction; 
    17 typedef PyObject* function(PyObject*, PyObject*, PyObject*) PyCFunctionWithKeywords; 
    18 typedef PyObject* function(PyObject*) PyNoArgsFunction; 
    19  
     26{    
    2027typedef PyObject* function(PyObject*) unaryfunc; 
    2128typedef PyObject* function(PyObject*, PyObject*) binaryfunc; 
     
    5562 
    5663} // extern(C) 
    57      
     64 
     65 
    5866struct PyObject 
    5967{ 
    60     int ob_refcnt; 
    61     PyTypeObject* ob_type; 
     68    mixin PyObject_HEAD; 
    6269} 
    6370 
    6471struct PyVarObject 
    6572{ 
    66     int ob_refcnt; 
    67     PyTypeObject* ob_Type; 
    68     int ob_size; 
     73    mixin PyObject_HEAD; 
     74    mixin PyObject_VAR_HEAD; 
    6975} 
    7076 
     
    8692    char* doc; 
    8793    void* closure; 
    88 } 
    89  
    90 // moved here from methodobject - it makes more sense 
    91 struct PyMethodDef 
    92 { 
    93     char* ml_name; 
    94     PyCFunction ml_meth; 
    95     int ml_flags; 
    96     char* ml_doc; 
    9794} 
    9895 
     
    168165} 
    169166 
     167private import derelict.python.methodobject; 
     168 
    170169struct PyTypeObject 
    171170{ 
    172     int ob_refcnt; 
    173     PyTypeObject* ob_type; 
    174     int ob_size; 
     171    mixin PyObject_VAR_HEAD; 
    175172    char *tp_name; 
    176173    int tp_basicsize; 
     
    217214    PyObject* tp_subclasses; 
    218215    PyObject* tp_weaklist; 
    219     destructor tp_del;   
     216    destructor tp_del; 
     217 
     218    version(COUNT_ALLOCS) 
     219    { 
     220        int tp_allocs; 
     221        int tp_frees; 
     222        int tp_maxalloc; 
     223        PyTypeObject* tp_next; 
     224    }    
    220225} 
    221226 
     
    264269const int Py_GE         = 5; 
    265270 
    266  
    267271PyTypeObject* PyType_Type; 
    268272PyTypeObject* PyBaseObject_Type; 
     
    275279// MACROS 
    276280//============================================================================== 
    277 bit PyType_TypeCheck(PyObject *ob, PyTypeObject *tp) 
    278 
    279     return (ob.ob_type is tp || PyType_IsSubType(ob.ob_type, tp)); 
     281bit PyObject_TypeCheck(PyObject* obj, PyTypeObject* tp) 
     282
     283    return (obj.ob_type is tp || PyType_IsSubType(obj.ob_type, tp)); 
     284
     285 
     286bit PyType_Check(PyObject* obj) 
     287
     288    return PyObject_TypeCheck(obj, PyType_Type); 
     289}  
     290 
     291bit PyType_CheckExaxt(PyObject* obj) 
     292
     293    return (obj.ob_type is PyType_Type); 
    280294} 
    281295 
     
    311325pfPyObject_ClearWeakRefs        PyObject_ClearWeakRefs; 
    312326 
    313 // declarations of DLL function pointers resuing pointer types declared earlier 
     327// declarations of DLL function pointers reusing pointer types declared earlier 
    314328printfunc                       PyObject_Print; 
    315329reprfunc                        PyObject_Repr; 
    316330unaryfunc                       PyObject_Str; 
     331 
     332version(USING_UNICODE) 
     333{ 
    317334unaryfunc                       PyObject_Unicode; 
     335} 
     336 
    318337cmpfunc                         PyObject_Compare; 
    319338richcmpfunc                     PyObject_RichCompare; 
  • trunk/DerelictPY/derelict/python/python.d

    r41 r48  
    66import derelict.python.cellobject; 
    77import derelict.python.cobject; 
     8import derelict.python.compile; 
    89import derelict.python.complexobject; 
    910import derelict.python.descrobject; 
    1011import derelict.python.errcode; 
    1112import derelict.python.floatobject; 
     13import derelict.python.frameobject; 
    1214import derelict.python.intobject; 
    1315import derelict.python.longintrepr; 
    1416import derelict.python.longobject; 
    1517import derelict.python.methodobject; 
     18import derelict.python.node; 
    1619import derelict.python.object; 
     20import derelict.python.pythonrun; 
     21import derelict.python.tupleobject; 
    1722import derelict.python.unicodeobject; 
    1823 
     
    116121    PyObject_IsInstance = cast(pfPyObject_IsInstance)getProc("PyObject_IsInstance"); 
    117122    PyObject_IsSubclass = cast(pfPyObject_IsSubclass)getProc("PyObject_IsSubclass"); 
     123     
    118124    // boolobject.d 
    119125    Py_False = cast(PyObject*)getProc("_Py_ZeroStruct"); 
    120126    Py_True = cast(PyObject*)getProc("_Py_TrueStruct"); 
    121127    PyBool_Type = cast(PyTypeObject*)getProc("PyBool_Type"); 
    122     PyBoolFromLong = cast(pfPyBool_FromLong)getProc("PyBool_FromLong"); 
     128    PyBool_FromLong = cast(pfPyBool_FromLong)getProc("PyBool_FromLong"); 
     129     
    123130    // bufferobject.d 
    124131    PyBuffer_Type = cast(PyTypeObject*)getProc("PyBuffer_Type"); 
     
    128135    PyBuffer_FromReadWriteMemory = cast(pfPyBuffer_FromReadWriteMemory)getProc("PyBuffer_FromReadWriteMemory"); 
    129136    PyBuffer_New = cast(pfPyBuffer_New)getProc("PyBuffer_New"); 
     137     
    130138    // cellobject.d 
    131139    PyCell_Type = cast(PyTypeObject*)getProc("PyCell_Type"); 
     
    133141    PyCell_Get = cast(pfPyCell_Get)getProc("PyCell_Get"); 
    134142    PyCell_Set = cast(pfPyCell_Set)getProc("PyCell_Set"); 
     143     
    135144    // cobject.d 
    136145    PyCObject_Type = cast(PyTypeObject*)getProc("PyCObject_Type"); 
     
    140149    PyCObject_GetDesc = cast(pfPyCObject_GetDesc)getProc("PyCObject_GetDesc"); 
    141150    PyCObject_Import = cast(pfPyCObject_Import)getProc("PyCObject_Import"); 
     151     
     152    // compile.d 
     153    PyCode_Type = cast(PyTypeObject*)getProc("PyCode_Type"); 
     154    PyNode_Compile = cast(pfPyNode_Compile)getProc("PyNode_Compile"); 
     155    PyCode_New = cast(pfPyCode_New)getProc("PyCode_New"); 
     156    PyCode_Addr2Line = cast(pfPyCode_Addr2Line)getProc("PyCode_Addr2Line"); 
     157    PyNode_Future = cast(pfPyNode_Future)getProc("PyNode_Future"); 
     158    PyNode_CompileFlags = cast(pfPyNode_CompileFlags)getProc("PyNode_CompileFlags"); 
     159     
    142160    // complexobject.d 
    143161    PyComplex_Type = cast(PyTypeObject*)getProc("PyComplex_Type"); 
     
    153171    c_quot = cast(pfc_quot)getProc("_Py_c_quot"); 
    154172    c_pow = cast(pfc_pow)getProc("_Py_c_pow"); 
     173     
    155174    // descrobject.d 
    156175    PyWrapperDescr_Type = cast(PyTypeObject*)getProc("PyWrapperDescr_Type"); 
     
    163182    PyDictProxy_New = cast(pfPyDictProxy_New)getProc("PyDictProxy_New"); 
    164183    PyWrapper_New = cast(pfPyWrapper_New)getProc("PyWrapper_New"); 
     184     
    165185    // floatobject.d 
    166186    PyFloat_Type = cast(PyTypeObject*)getProc("PyFloat_Type"); 
     
    174194    _PyFloat_Unpack4 = cast(pf_PyFloat_Unpack4)getProc("_PyFloat_Unpack4"); 
    175195    _PyFloat_Unpack8 = cast(pf_PyFloat_Unpack8)getProc("_PyFloat_Unpack8"); 
     196     
     197    // frameobject.d 
     198    PyFrame_Type = cast(PyTypeObject*)getProc("PyFrame_Type"); 
     199    PyFrame_BlockSetup = cast(pfPyFrame_BlockSetup)getProc("PyFrame_BlockSetup"); 
     200    PyFrame_BlockPop = cast(pfPyFrame_BlockPop)getProc("PyFrame_BlockPop"); 
     201    PyFrame_ExtendStack = cast(pfPyFrame_ExtendStack)getProc("PyFrame_ExtendStack"); 
     202    PyFrame_LocalsToFast = cast(pfPyFrame_LocalsToFast)getProc("PyFrame_LocalsToFast"); 
     203    PyFrame_FastToLocals = cast(pfPyFrame_FastToLocals)getProc("PyFrame_FastToLocals"); 
     204     
    176205    // intobject.d 
    177206    PyInt_Type = cast(PyTypeObject*)getProc("PyInt_Type"); 
    178207    PyInt_FromString = cast(pfPyInt_FromString)getProc("PyInt_FromString"); 
    179     PyInt_FromUnicode = cast(pfPyInt_FromUnicode)getProc("PyInt_FromUnicode"); 
    180208    PyInt_FromLong = cast(pfPyInt_FromLong)getProc("PyInt_FromLong"); 
    181209    PyInt_AsLong = cast(pfPyInt_AsLong)getProc("PyInt_AsLong"); 
     
    185213    PyOS_strtoul = cast(pfPyOS_strtoul)getProc("PyOS_strtoul"); 
    186214    PyOS_strtol = cast(pfPyOS_strtol)getProc("PyOS_strtol"); 
     215     
     216    version(USING_UNICODE) 
     217    { 
     218    PyInt_FromUnicode = cast(pfPyInt_FromUnicode)getProc("PyInt_FromUnicode"); 
     219    } 
    187220    // longintrepr.d 
    188221    _PyLong_New = cast(pf_PyLong_New)getProc("_PyLong_New"); 
    189222    _PyLong_Copy = cast(pf_PyLong_Copy)getProc("_PyLong_Copy"); 
     223     
    190224    // longobject.d 
    191225    PyLong_Type = cast(PyTypeObject*)getProc("PyLong_Type"); 
     
    205239    PyLong_AsUnsignedLongLongMask = cast(pfPyLong_AsUnsignedLongLongMask)getProc("PyLong_AsUnsignedLongLongMask"); 
    206240    PyLong_FromString = cast(pfPyLong_FromString)getProc("PyLong_FromString"); 
    207     PyLong_FromUnicode = cast(pfPyLong_FromUnicode)getProc("PyLong_FromUnicode"); 
    208241    _PyLong_Sign = cast(pf_PyLong_Sign)getProc("_PyLong_Sign"); 
    209242    _PyLong_NumBits = cast(pf_PyLong_NumBits)getProc("_PyLong_NumBits"); 
    210243    _PyLong_FromByteArray = cast(pf_PyLong_FromByteArray)getProc("_PyLong_FromByteArray"); 
    211244    _PyLong_AsByteArray = cast(pf_PyLong_AsByteArray)getProc("_PyLong_AsByteArray"); 
     245     
     246    version(USING_UNICODE) 
     247    { 
     248    PyLong_FromUnicode = cast(pfPyLong_FromUnicode)getProc("PyLong_FromUnicode"); 
     249    } 
     250     
    212251    // methodobject.d 
    213252    PyCFunction_Type = cast(PyTypeObject*)getProc("PyCFunction_Type"); 
     
    219258    PyCFunction_NewEx = cast(pfPyCFunction_NewEx)getProc("PyCFunction_NewEx"); 
    220259    Py_FindMethodChain = cast(pfPy_FindMethodChain)getProc("Py_FindMethodChain"); 
     260     
     261    // node.d 
     262    PyNode_New = cast(pfPyNode_New)getProc("PyNode_New"); 
     263    PyNode_AddChild = cast(pfPyNode_AddChild)getProc("PyNode_AddChild"); 
     264    PyNode_Free = cast(pfPyNode_Free)getProc("PyNode_Free"); 
     265    PyNode_ListTree = cast(pfPyNode_ListTree)getProc("PyNode_ListTree"); 
     266     
    221267    // object.d 
    222268    PyType_Type = cast(PyTypeObject*)getProc("PyType_Type"); 
     
    239285    PyObject_Repr = cast(reprfunc)getProc("PyObject_Repr"); 
    240286    PyObject_Str = cast(unaryfunc)getProc("PyObject_Str"); 
    241     PyObject_Unicode = cast(unaryfunc)getProc("PyObject_Unicode"); 
    242287    PyObject_Compare = cast(cmpfunc)getProc("PyObject_Compare"); 
    243288    PyObject_RichCompare = cast(richcmpfunc)getProc("PyObject_RichCompare"); 
     
    269314    _PyObject_New = cast(pf_PyObject_New)getProc("_PyObject_New"); 
    270315    _PyObject_NewVar = cast(pf_PyObject_NewVar)getProc("_PyObject_NewVar"); 
     316     
     317    version(USING_UNICODE) 
     318    { 
     319    PyObject_Unicode = cast(unaryfunc)getProc("PyObject_Unicode"); 
     320    } 
     321     
     322    // tupleobject.d 
     323    PyTuple_New = cast(pfPyTuple_New)getProc("PyTuple_New"); 
     324    PyTuple_Size = cast(pfPyTuple_Size)getProc("PyTuple_Size"); 
     325    PyTuple_GetItem = cast(pfPyTuple_GetItem)getProc("PyTuple_GetItem"); 
     326    PyTuple_SetItem = cast(pfPyTuple_SetItem)getProc("PyTuple_SetItem"); 
     327    PyTuple_GetSlice = cast(pfPyTuple_GetSlice)getProc("PyTuple_GetSlice"); 
     328     
    271329    // unicode.d 
     330    version(USING_UNICODE) 
     331    { 
    272332    PyUnicode_Type = cast(PyTypeObject*)getProc("PyUnicode_Type"); 
    273333    PyUnicode_FromUnicode = cast(pfPyUnicode_FromUnicode)getProc("PyUnicodeUCS2_FromUnicode"); 
     
    343403    _PyUnicode_IsNumeric = cast(pf_PyUnicode_IsNumeric)getProc("_PyUnicodeUCS2_IsNumeric"); 
    344404    _PyUnicode_IsAlpha = cast(pf_PyUnicode_IsAlpha)getProc("_PyUnicodeUCS2_IsAlpha"); 
     405    } // version(USING_UNICODE) 
    345406} 
    346407 
  • trunk/DerelictPY/derelict/python/unicodeobject.d

    r39 r48  
    11module derelict.python.unicodeobject; 
    22 
     3version(USING_UNICODE) 
     4{ 
     5     
    36private import derelict.python.object; 
    47 
     
    1013struct PyUnicodeObject 
    1114{ 
    12     int ob_refcnt; 
    13     PyTypeObject *ob_type; 
     15    mixin PyObject_HEAD; 
    1416    int length; 
    1517    Py_UNICODE *str; 
     
    2325// MACROS 
    2426//============================================================================== 
    25 int pfPyUnicode_GET_SIZE(PyUnicodeObject* op) 
    26 
    27     return op.length; 
    28 
    29  
    30 int PyUnicode_GET_DATA_SIZE(PyUnicodeObject* op) 
    31 
    32     return op.length * Py_UNICODE.sizeof; 
    33 
    34  
    35 Py_UNICODE* PyUnicode_AS_UNICODE(PyUnicodeObject* op) 
    36 
    37     return op.str; 
    38 
    39  
    40 char* PyUnicode_AS_DATA(PyUnicodeObject* op) 
    41 
    42     return cast(char*)(op.str); 
     27bit PyUnicode_Check(PyObject* obj) 
     28
     29    return PyObject_TypeCheck(opj, PyUnicode_Type); 
     30
     31 
     32bit PyUnicode_CheckExact(PyObject* obj) 
     33
     34    return (obj.ob_type is PyUnicode_Type); 
     35
     36 
     37int PyUnicode_GET_SIZE(PyObject* obj) 
     38
     39    PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 
     40    return uobj.length; 
     41
     42 
     43int PyUnicode_GET_DATA_SIZE(PyObject* obj) 
     44
     45    PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 
     46    return uobj.length * Py_UNICODE.sizeof; 
     47
     48 
     49Py_UNICODE* PyUnicode_AS_UNICODE(PyObject* obj) 
     50
     51    PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 
     52    return uobj.str; 
     53
     54 
     55char* PyUnicode_AS_DATA(PyObject* obj) 
     56
     57    PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 
     58    return cast(char*)(uobj.str); 
    4359} 
    4460 
     
    208224 
    209225} // extern(C) 
     226 
     227} // version(USING_UNICODE)