Changeset 48
- Timestamp:
- 10/24/04 02:19:33 (4 years ago)
- Files:
-
- trunk/DerelictAL/README (modified) (1 diff)
- trunk/DerelictGL/README (modified) (5 diffs)
- trunk/DerelictGL/README.GLEE (deleted)
- trunk/DerelictGL/glConstants.d (deleted)
- trunk/DerelictGL/glee.d (deleted)
- trunk/DerelictGL/gleeFuncDef.d (deleted)
- trunk/DerelictGL/gleeTypes.d (deleted)
- trunk/DerelictGL/glee_dist (deleted)
- trunk/DerelictPY/Makefile (modified) (3 diffs)
- trunk/DerelictPY/derelict/python/boolobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/bufferobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/cellobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/cobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/compile.d (added)
- trunk/DerelictPY/derelict/python/complexobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/descrobject.d (modified) (7 diffs)
- trunk/DerelictPY/derelict/python/floatobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/frameobject.d (added)
- trunk/DerelictPY/derelict/python/intobject.d (modified) (4 diffs)
- trunk/DerelictPY/derelict/python/longintrepr.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/longobject.d (modified) (4 diffs)
- trunk/DerelictPY/derelict/python/methodobject.d (modified) (1 diff)
- trunk/DerelictPY/derelict/python/node.d (added)
- trunk/DerelictPY/derelict/python/object.d (modified) (8 diffs)
- trunk/DerelictPY/derelict/python/python.d (modified) (14 diffs)
- trunk/DerelictPY/derelict/python/pythonrun.d (added)
- trunk/DerelictPY/derelict/python/tupleobject.d (added)
- trunk/DerelictPY/derelict/python/unicodeobject.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/DerelictAL/README
r46 r48 31 31 ++++++++++++++++++++++++++ CODE +++++++++++++++++++++++++++++++++++++++++++++ 32 32 33 import derelict.openal.al; // core GL 1.1 functions 34 import glee; // Core GL functions up to 1.5 plus extensions 33 import derelict.openal.al; 35 34 36 35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ trunk/DerelictGL/README
r46 r48 5 5 without the need to link to an import library. This gives you control over how 6 6 to 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. 7 user's machine. 10 8 11 9 Please note that the Linux version is not yet implemented. Anyone who would like … … 21 19 instructions). 22 20 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; 21 In your code, you need to import the derelict.opengl.gl module. 32 22 33 23 ++++++++++++++++++++++++++ CODE +++++++++++++++++++++++++++++++++++++++++++++ 34 24 35 25 import derelict.opengl.gl; // core GL 1.1 functions 36 import glee; // Core GL functions up to 1.5 plus extensions37 26 38 27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ … … 44 33 can go on about your business. 45 34 46 If you wish to use GLee, then you'll need to make a call to GLeeInit. The catch47 is that you must first create and activate an OpenGL context (if you aren't sure48 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. This50 is why DerelictGL_Load only loads the core 1.1 functions. Once your context is51 activated, calling GLeeInit will load all available core OpenGL 1.5 functions as52 well as all available extensions.53 54 Additionally, the use of GLee requires that you link to the C library GLee.lib55 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 include59 GL.d and GL.obj on your project's build path, or make the DerelictGL library with60 the command 'make lib_noglee' (see BUILDING below). You will then have to setup61 and load any extensions manually.62 35 63 36 ++++++++++++++++++++++++++ CODE +++++++++++++++++++++++++++++++++++++++++++++ … … 69 42 ... 70 43 71 // load extensions via GLee72 GLeeInit();73 74 44 75 45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 76 77 Once the extensions are loaded, you can query for the availability of those78 you need via GLee's extension flags. These take the same form as the extension79 names, except that the 'GL_' in the names is replaced with 'GLEE_'. So, for80 example, GL_ARB_vertex_program becomes GLEE_ARB_vertex_program.81 82 Platform-specific extensions, such as the 'WGL_' extensions, follow a different83 naming convention in that 'GLEE_' is prefixed to the extension name such that84 WGL_ARB_buffer_region becomes GLEE_WGL_ARB_buffer_region.85 86 And finally, variables for querying the version of OpenGL available beyond 1.187 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 versions94 if(GLEE_VERSION_1_5)95 // do GL 1.5 stuff96 else if(GLEE_VERSION_1_4)97 // do GL 1.4 stuff98 99 // querying for specific extensions100 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, that112 GLee provides some convenience functions which can be used to get standard and113 platform-specific extensions, as well as error, strings:114 115 GLeeGetExtStrGL();116 GLeeGetExtStrWGL(); // windows117 GLeeGetExtStrGLX(); // linux118 GLeeGetErrorString()119 46 120 47 … … 127 54 1) ensure that both dmd\bin and dm\bin are on your path 128 55 2) 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 56 3) type 'make' or 'make lib' to build derelictGL.lib 131 57 4) optionally type 'make clean' to delete all object files OR 132 58 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 the134 C library GLee.lib - this only need be done once but is required to make use of GLee.135 59 trunk/DerelictPY/Makefile
r41 r48 15 15 $(PY.SRC.DIR)\cellobject.d \ 16 16 $(PY.SRC.DIR)\cobject.d \ 17 $(PY.SRC.DIR)\compile.d \ 17 18 $(PY.SRC.DIR)\complexobject.d \ 18 19 $(PY.SRC.DIR)\descrobject.d \ 19 20 $(PY.SRC.DIR)\errcode.d \ 20 21 $(PY.SRC.DIR)\floatobject.d \ 22 $(PY.SRC.DIR)\frameobject.d \ 21 23 $(PY.SRC.DIR)\intobject.d \ 22 24 $(PY.SRC.DIR)\longintrepr.d \ 23 25 $(PY.SRC.DIR)\longobject.d \ 24 26 $(PY.SRC.DIR)\methodobject.d \ 27 $(PY.SRC.DIR)\node.d \ 25 28 $(PY.SRC.DIR)\object.d \ 26 29 $(PY.SRC.DIR)\python.d \ 30 $(PY.SRC.DIR)\pythonrun.d \ 31 $(PY.SRC.DIR)\tupleobject.d \ 27 32 $(PY.SRC.DIR)\unicodeobject.d 28 33 … … 33 38 $(PY.OBJ.DIR)\bufferobject.obj \ 34 39 $(PY.OBJ.DIR)\cobject.obj \ 40 $(PY.OBJ.DIR)\compile.obj \ 35 41 $(PY.OBJ.DIR)\complexobject.obj \ 36 42 $(PY.OBJ.DIR)\cellobject.obj \ … … 38 44 $(PY.OBJ.DIR)\errcode.obj \ 39 45 $(PY.OBJ.DIR)\floatobject.obj \ 46 $(PY.OBJ.DIR)\frameobject.obj \ 40 47 $(PY.OBJ.DIR)\intobject.obj \ 41 48 $(PY.OBJ.DIR)\longintrepr.obj \ 42 49 $(PY.OBJ.DIR)\longobject.obj \ 43 50 $(PY.OBJ.DIR)\methodobject.obj \ 51 $(PY.OBJ.DIR)\node.obj \ 44 52 $(PY.OBJ.DIR)\object.obj \ 45 53 $(PY.OBJ.DIR)\python.obj \ 54 $(PY.OBJ.DIR)\pythonrun.obj \ 55 $(PY.OBJ.DIR)\tupleobject.obj \ 46 56 $(PY.OBJ.DIR)\unicodeobject.obj 47 57 trunk/DerelictPY/derelict/python/boolobject.d
r37 r48 15 15 16 16 //============================================================================== 17 // TYPES 17 // MACROS 18 //============================================================================== 19 bit PyBool_Check(PyObject* obj) 20 { 21 return (obj.ob_type is PyBool_Type); 22 } 23 24 //============================================================================== 25 // FUNCTIONS 18 26 //============================================================================== 19 27 extern(C) 20 28 { 21 29 typedef PyObject* function(int) pfPyBool_FromLong; 22 pfPyBool_FromLong PyBool FromLong;30 pfPyBool_FromLong PyBool_FromLong; 23 31 } trunk/DerelictPY/derelict/python/bufferobject.d
r37 r48 9 9 10 10 PyTypeObject* PyBuffer_Type; 11 12 //============================================================================== 13 // MACROS 14 //============================================================================== 15 bit PyBuffer_Check(PyObject *obj) 16 { 17 return (obj.ob_type is PyBuffer_Type); 18 } 11 19 12 20 //============================================================================== trunk/DerelictPY/derelict/python/cellobject.d
r40 r48 8 8 struct PyCellObject 9 9 { 10 int ob_refcnt; 11 PyTypeObject* ob_type; 10 mixin PyObject_HEAD; 12 11 PyObject* ob_ref; 13 12 } 14 13 15 14 PyTypeObject* PyCell_Type; 15 16 //============================================================================== 17 // MACROS 18 //============================================================================== 19 bit PyCell_Check(PyObject *obj) 20 { 21 return (obj.ob_type is PyCell_Type); 22 } 16 23 17 24 //============================================================================== trunk/DerelictPY/derelict/python/cobject.d
r41 r48 7 7 //============================================================================== 8 8 PyTypeObject* PyCObject_Type; 9 10 //============================================================================== 11 // MACROS 12 //============================================================================== 13 bit PyCObject_Check(PyObject* obj) 14 { 15 return (obj.ob_type is PyCObject_Type); 16 } 9 17 10 18 //============================================================================== trunk/DerelictPY/derelict/python/complexobject.d
r41 r48 14 14 struct PyComplexObject 15 15 { 16 int ob_refcnt; 17 PyTypeObject *ob_type; 16 mixin PyObject_HEAD; 18 17 Py_complex cval; 19 18 } 20 19 21 20 PyTypeObject* PyComplex_Type; 21 22 //============================================================================== 23 // MACROS 24 //============================================================================== 25 bit PyComplex_Check(PyObject *obj) 26 { 27 return PyObject_TypeCheck(obj, PyComplex_Type); 28 } 29 30 bit PyComplex_CheckExact(PyObject *obj) 31 { 32 return (obj.ob_type is PyComplex_Type); 33 } 22 34 23 35 //============================================================================== trunk/DerelictPY/derelict/python/descrobject.d
r37 r48 2 2 3 3 private import derelict.python.object; 4 private import derelict.python.methodobject; 4 5 5 6 //============================================================================== … … 9 10 { 10 11 12 typedef PyObject* function(PyObject*, void*) getter; 13 typedef int function(PyObject*, PyObject*, void*) setter; 11 14 typedef PyObject* function(PyObject*, PyObject*, void*) wrapperfunc; 12 15 typedef PyObject* function(PyObject*, PyObject*, void*, PyObject*) wrapperfunc_kwds; … … 29 32 struct PyDescrObject 30 33 { 31 int ob_refcnt; 32 PyTypeObject* ob_type; 34 mixin PyObject_HEAD; 33 35 PyTypeObject* d_type; 34 36 PyObject* d_name; … … 37 39 struct PyMethodDescrObject 38 40 { 39 int ob_refcnt; 40 PyTypeObject* ob_type; 41 mixin PyObject_HEAD; 41 42 PyTypeObject* d_type; 42 43 PyObject* d_name; … … 46 47 struct PyMemberDescrObject 47 48 { 48 int ob_refcnt; 49 PyTypeObject* ob_type; 49 mixin PyObject_HEAD; 50 50 PyTypeObject* d_type; 51 51 PyObject* d_name; … … 55 55 struct PyGetSetDescrObject 56 56 { 57 int ob_refcnt; 58 PyTypeObject* ob_type; 57 mixin PyObject_HEAD; 59 58 PyTypeObject* d_type; 60 59 PyObject* d_name; … … 64 63 struct PyWrapperDescrObject 65 64 { 66 int ob_refcnt; 67 PyTypeObject* ob_type; 65 mixin PyObject_HEAD; 68 66 PyTypeObject* d_type; 69 67 PyObject* d_name; trunk/DerelictPY/derelict/python/floatobject.d
r37 r48 8 8 struct PyFloatObject 9 9 { 10 int ob_refcnt; 11 PyTypeObject *ob_type; 10 mixin PyObject_HEAD; 12 11 double ob_fval; 13 12 } 14 13 15 14 PyTypeObject* PyFloat_Type; 15 16 //============================================================================== 17 // MACROS 18 //============================================================================== 19 bit PyFloat_Check(PyObject* obj) 20 { 21 return PyObject_TypeCheck(obj, PyFloat_Type); 22 } 23 24 bit PyFloat_CheckExact(PyObject* obj) 25 { 26 return (obj.ob_type is PyFloat_Type); 27 } 28 29 double PyFloat_AS_DOUBLE(PyObject* obj) 30 { 31 PyFloatObject* fobj = cast(PyFloatObject*)obj; 32 return fobj.ob_fval; 33 } 16 34 17 35 //============================================================================== trunk/DerelictPY/derelict/python/intobject.d
r37 r48 9 9 struct PyIntObject 10 10 { 11 int ob_refcnt; 12 PyTypeObject *ob_type; 11 mixin PyObject_HEAD; 13 12 int ob_ival; 14 13 } 15 14 16 15 PyTypeObject* PyInt_Type; 16 17 //============================================================================== 18 // MACROS 19 //============================================================================== 20 bit PyInt_Check(PyObject* obj) 21 { 22 return PyObject_TypeCheck(obj, PyInt_Type); 23 } 24 25 bit PyInt_CheckExact(PyObject* obj) 26 { 27 return (obj.ob_type is PyInt_Type); 28 } 17 29 18 30 //============================================================================== … … 24 36 25 37 typedef PyObject* function(char*, char**, int) pfPyInt_FromString; 26 typedef PyObject* function(Py_UNICODE*, char**, int) pfPyInt_FromUnicode;27 38 typedef PyObject* function(int) pfPyInt_FromLong; 28 39 typedef int function(PyObject*) pfPyInt_AsLong; … … 33 44 typedef int function(char*, char**, int) pfPyOS_strtol; 34 45 pfPyInt_FromString PyInt_FromString; 35 pfPyInt_FromUnicode PyInt_FromUnicode;36 46 pfPyInt_FromLong PyInt_FromLong; 37 47 pfPyInt_AsLong PyInt_AsLong; … … 42 52 pfPyOS_strtol PyOS_strtol; 43 53 54 version(USING_UNICODE) 55 { 56 typedef PyObject* function(Py_UNICODE*, char**, int) pfPyInt_FromUnicode; 57 pfPyInt_FromUnicode PyInt_FromUnicode; 58 } 59 44 60 } // extern(C) 45 61 trunk/DerelictPY/derelict/python/longintrepr.d
r35 r48 17 17 struct PyLongObject 18 18 { 19 int ob_refcnt; 20 PyTypeObject *ob_type; 19 mixin PyObject_HEAD; 21 20 digit[1] ob_digit; 22 21 } trunk/DerelictPY/derelict/python/longobject.d
r39 r48 13 13 14 14 PyTypeObject* PyLong_Type; 15 16 //============================================================================== 17 // MACROS 18 //============================================================================== 19 bit PyLong_Check(PyObject* obj) 20 { 21 return PyObject_TypeCheck(obj, PyLong_Type); 22 } 23 24 bit PyLong_CheckExact(PyObject* obj) 25 { 26 return (obj.ob_type is PyLong_Type); 27 } 15 28 16 29 //============================================================================== … … 36 49 typedef PY_ULONG_LONG function(PyObject*) pfPyLong_AsUnsignedLongLongMask; 37 50 typedef PyObject* function(char*, char**, int) pfPyLong_FromString; 38 typedef PyObject* function(Py_UNICODE*, int, int) pfPyLong_FromUnicode;39 51 typedef int function(PyObject*) pf_PyLong_Sign; 40 52 typedef size_t function(PyObject*) pf_PyLong_NumBits; … … 57 69 pfPyLong_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask; 58 70 pfPyLong_FromString PyLong_FromString; 59 pfPyLong_FromUnicode PyLong_FromUnicode;60 71 pf_PyLong_Sign _PyLong_Sign; 61 72 pf_PyLong_NumBits _PyLong_NumBits; … … 63 74 pf_PyLong_AsByteArray _PyLong_AsByteArray; 64 75 76 version(USING_UNICODE) 77 { 78 typedef PyObject* function(Py_UNICODE*, int, int) pfPyLong_FromUnicode; 79 pfPyLong_FromUnicode PyLong_FromUnicode; 80 } 81 65 82 } // extern(C) trunk/DerelictPY/derelict/python/methodobject.d
r39 r48 20 20 PyMethodChain* links; 21 21 } 22 struct PyMethodDef 23 { 24 char* ml_name; 25 PyCFunction ml_meth; 26 int ml_flags; 27 char* ml_doc; 28 } 22 29 23 30 struct PyCFunctionObject 24 31 { 25 int ob_refcnt; 26 PyTypeObject* ob_type; 32 mixin PyObject_HEAD; 27 33 PyMethodDef* m_ml; 28 PyObject* *m_self;29 PyObject* *m_module;34 PyObject* m_self; 35 PyObject* m_module; 30 36 } 31 37 32 38 PyTypeObject* PyCFunction_Type; 33 39 40 extern(C) 41 { 42 typedef PyObject* function(PyObject*, PyObject*) PyCFunction; 43 typedef PyObject* function(PyObject*, PyObject*, PyObject*) PyCFunctionWithKeywords; 44 typedef PyObject* function(PyObject*) PyNoArgsFunction; 45 } 34 46 35 47 //============================================================================== 36 // METHODS 48 // MACROS 49 //============================================================================== 50 bit PyCFunction_Check(PyObject* obj) 51 { 52 return (obj.ob_type is PyCFunction_Type); 53 } 54 55 PyCFunction PyCFunction_GET_FUNCTION(PyObject* obj) 56 { 57 PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 58 return func.m_ml.ml_meth; 59 } 60 61 PyObject* PyCFunction_GET_SELF(PyObject *obj) 62 { 63 PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 64 return func.m_self; 65 } 66 67 int PyCFunction_GET_FLAGS(PyObject* obj) 68 { 69 PyCFunctionObject* func = cast(PyCFunctionObject*)obj; 70 return func.m_ml.ml_flags; 71 } 72 73 PyObject* PyCFunction_New(PyMethodDef* ml, PyObject* self) 74 { 75 return PyCFunction_NewEx(ml, self, null); 76 } 77 78 //============================================================================== 79 // FUNCTIONS 37 80 //============================================================================== 38 81 extern(C) trunk/DerelictPY/derelict/python/object.d
r40 r48 3 3 private import std.c.stdio; 4 4 5 // declare these templates here so that the imports can use them as mixins 6 // without worrying about forward reference errors 7 template PyObject_HEAD() 8 { 9 int ob_refcnt; 10 PyTypeObject* ob_type; 11 } 12 13 template PyObject_VAR_HEAD() 14 { 15 mixin PyObject_HEAD; 16 int ob_size; 17 } 18 19 private import derelict.python.descrobject; 20 private import derelict.python.methodobject; 21 5 22 //============================================================================== 6 23 // TYPES 7 24 //============================================================================== 8 25 extern(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 { 20 27 typedef PyObject* function(PyObject*) unaryfunc; 21 28 typedef PyObject* function(PyObject*, PyObject*) binaryfunc; … … 55 62 56 63 } // extern(C) 57 64 65 58 66 struct PyObject 59 67 { 60 int ob_refcnt; 61 PyTypeObject* ob_type; 68 mixin PyObject_HEAD; 62 69 } 63 70 64 71 struct PyVarObject 65 72 { 66 int ob_refcnt; 67 PyTypeObject* ob_Type; 68 int ob_size; 73 mixin PyObject_HEAD; 74 mixin PyObject_VAR_HEAD; 69 75 } 70 76 … … 86 92 char* doc; 87 93 void* closure; 88 }89 90 // moved here from methodobject - it makes more sense91 struct PyMethodDef92 {93 char* ml_name;94 PyCFunction ml_meth;95 int ml_flags;96 char* ml_doc;97 94 } 98 95 … … 168 165 } 169 166 167 private import derelict.python.methodobject; 168 170 169 struct PyTypeObject 171 170 { 172 int ob_refcnt; 173 PyTypeObject* ob_type; 174 int ob_size; 171 mixin PyObject_VAR_HEAD; 175 172 char *tp_name; 176 173 int tp_basicsize; … … 217 214 PyObject* tp_subclasses; 218 215 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 } 220 225 } 221 226 … … 264 269 const int Py_GE = 5; 265 270 266 267 271 PyTypeObject* PyType_Type; 268 272 PyTypeObject* PyBaseObject_Type; … … 275 279 // MACROS 276 280 //============================================================================== 277 bit PyType_TypeCheck(PyObject *ob, PyTypeObject *tp) 278 { 279 return (ob.ob_type is tp || PyType_IsSubType(ob.ob_type, tp)); 281 bit PyObject_TypeCheck(PyObject* obj, PyTypeObject* tp) 282 { 283 return (obj.ob_type is tp || PyType_IsSubType(obj.ob_type, tp)); 284 } 285 286 bit PyType_Check(PyObject* obj) 287 { 288 return PyObject_TypeCheck(obj, PyType_Type); 289 } 290 291 bit PyType_CheckExaxt(PyObject* obj) 292 { 293 return (obj.ob_type is PyType_Type); 280 294 } 281 295 … … 311 325 pfPyObject_ClearWeakRefs PyObject_ClearWeakRefs; 312 326 313 // declarations of DLL function pointers re suing pointer types declared earlier327 // declarations of DLL function pointers reusing pointer types declared earlier 314 328 printfunc PyObject_Print; 315 329 reprfunc PyObject_Repr; 316 330 unaryfunc PyObject_Str; 331 332 version(USING_UNICODE) 333 { 317 334 unaryfunc PyObject_Unicode; 335 } 336 318 337 cmpfunc PyObject_Compare; 319 338 richcmpfunc PyObject_RichCompare; trunk/DerelictPY/derelict/python/python.d
r41 r48 6 6 import derelict.python.cellobject; 7 7 import derelict.python.cobject; 8 import derelict.python.compile; 8 9 import derelict.python.complexobject; 9 10 import derelict.python.descrobject; 10 11 import derelict.python.errcode; 11 12 import derelict.python.floatobject; 13 import derelict.python.frameobject; 12 14 import derelict.python.intobject; 13 15 import derelict.python.longintrepr; 14 16 import derelict.python.longobject; 15 17 import derelict.python.methodobject; 18 import derelict.python.node; 16 19 import derelict.python.object; 20 import derelict.python.pythonrun; 21 import derelict.python.tupleobject; 17 22 import derelict.python.unicodeobject; 18 23 … … 116 121 PyObject_IsInstance = cast(pfPyObject_IsInstance)getProc("PyObject_IsInstance"); 117 122 PyObject_IsSubclass = cast(pfPyObject_IsSubclass)getProc("PyObject_IsSubclass"); 123 118 124 // boolobject.d 119 125 Py_False = cast(PyObject*)getProc("_Py_ZeroStruct"); 120 126 Py_True = cast(PyObject*)getProc("_Py_TrueStruct"); 121 127 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 123 130 // bufferobject.d 124 131 PyBuffer_Type = cast(PyTypeObject*)getProc("PyBuffer_Type"); … … 128 135 PyBuffer_FromReadWriteMemory = cast(pfPyBuffer_FromReadWriteMemory)getProc("PyBuffer_FromReadWriteMemory"); 129 136 PyBuffer_New = cast(pfPyBuffer_New)getProc("PyBuffer_New"); 137 130 138 // cellobject.d 131 139 PyCell_Type = cast(PyTypeObject*)getProc("PyCell_Type"); … … 133 141 PyCell_Get = cast(pfPyCell_Get)getProc("PyCell_Get"); 134 142 PyCell_Set = cast(pfPyCell_Set)getProc("PyCell_Set"); 143 135 144 // cobject.d 136 145 PyCObject_Type = cast(PyTypeObject*)getProc("PyCObject_Type"); … … 140 149 PyCObject_GetDesc = cast(pfPyCObject_GetDesc)getProc("PyCObject_GetDesc"); 141 150 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 142 160 // complexobject.d 143 161 PyComplex_Type = cast(PyTypeObject*)getProc("PyComplex_Type"); … … 153 171 c_quot = cast(pfc_quot)getProc("_Py_c_quot"); 154 172 c_pow = cast(pfc_pow)getProc("_Py_c_pow"); 173 155 174 // descrobject.d 156 175 PyWrapperDescr_Type = cast(PyTypeObject*)getProc("PyWrapperDescr_Type"); … … 163 182 PyDictProxy_New = cast(pfPyDictProxy_New)getProc("PyDictProxy_New"); 164 183 PyWrapper_New = cast(pfPyWrapper_New)getProc("PyWrapper_New"); 184 165 185 // floatobject.d 166 186 PyFloat_Type = cast(PyTypeObject*)getProc("PyFloat_Type"); … … 174 194 _PyFloat_Unpack4 = cast(pf_PyFloat_Unpack4)getProc("_PyFloat_Unpack4"); 175 195 _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 176 205 // intobject.d 177 206 PyInt_Type = cast(PyTypeObject*)getProc("PyInt_Type"); 178 207 PyInt_FromString = cast(pfPyInt_FromString)getProc("PyInt_FromString"); 179 PyInt_FromUnicode = cast(pfPyInt_FromUnicode)getProc("PyInt_FromUnicode");180 208 PyInt_FromLong = cast(pfPyInt_FromLong)getProc("PyInt_FromLong"); 181 209 PyInt_AsLong = cast(pfPyInt_AsLong)getProc("PyInt_AsLong"); … … 185 213 PyOS_strtoul = cast(pfPyOS_strtoul)getProc("PyOS_strtoul"); 186 214 PyOS_strtol = cast(pfPyOS_strtol)getProc("PyOS_strtol"); 215 216 version(USING_UNICODE) 217 { 218 PyInt_FromUnicode = cast(pfPyInt_FromUnicode)getProc("PyInt_FromUnicode"); 219 } 187 220 // longintrepr.d 188 221 _PyLong_New = cast(pf_PyLong_New)getProc("_PyLong_New"); 189 222 _PyLong_Copy = cast(pf_PyLong_Copy)getProc("_PyLong_Copy"); 223 190 224 // longobject.d 191 225 PyLong_Type = cast(PyTypeObject*)getProc("PyLong_Type"); … … 205 239 PyLong_AsUnsignedLongLongMask = cast(pfPyLong_AsUnsignedLongLongMask)getProc("PyLong_AsUnsignedLongLongMask"); 206 240 PyLong_FromString = cast(pfPyLong_FromString)getProc("PyLong_FromString"); 207 PyLong_FromUnicode = cast(pfPyLong_FromUnicode)getProc("PyLong_FromUnicode");208 241 _PyLong_Sign = cast(pf_PyLong_Sign)getProc("_PyLong_Sign"); 209 242 _PyLong_NumBits = cast(pf_PyLong_NumBits)getProc("_PyLong_NumBits"); 210 243 _PyLong_FromByteArray = cast(pf_PyLong_FromByteArray)getProc("_PyLong_FromByteArray"); 211 244 _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 212 251 // methodobject.d 213 252 PyCFunction_Type = cast(PyTypeObject*)getProc("PyCFunction_Type"); … … 219 258 PyCFunction_NewEx = cast(pfPyCFunction_NewEx)getProc("PyCFunction_NewEx"); 220 259 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 221 267 // object.d 222 268 PyType_Type = cast(PyTypeObject*)getProc("PyType_Type"); … … 239 285 PyObject_Repr = cast(reprfunc)getProc("PyObject_Repr"); 240 286 PyObject_Str = cast(unaryfunc)getProc("PyObject_Str"); 241 PyObject_Unicode = cast(unaryfunc)getProc("PyObject_Unicode");242 287 PyObject_Compare = cast(cmpfunc)getProc("PyObject_Compare"); 243 288 PyObject_RichCompare = cast(richcmpfunc)getProc("PyObject_RichCompare"); … … 269 314 _PyObject_New = cast(pf_PyObject_New)getProc("_PyObject_New"); 270 315 _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 271 329 // unicode.d 330 version(USING_UNICODE) 331 { 272 332 PyUnicode_Type = cast(PyTypeObject*)getProc("PyUnicode_Type"); 273 333 PyUnicode_FromUnicode = cast(pfPyUnicode_FromUnicode)getProc("PyUnicodeUCS2_FromUnicode"); … … 343 403 _PyUnicode_IsNumeric = cast(pf_PyUnicode_IsNumeric)getProc("_PyUnicodeUCS2_IsNumeric"); 344 404 _PyUnicode_IsAlpha = cast(pf_PyUnicode_IsAlpha)getProc("_PyUnicodeUCS2_IsAlpha"); 405 } // version(USING_UNICODE) 345 406 } 346 407 trunk/DerelictPY/derelict/python/unicodeobject.d
r39 r48 1 1 module derelict.python.unicodeobject; 2 2 3 version(USING_UNICODE) 4 { 5 3 6 private import derelict.python.object; 4 7 … … 10 13 struct PyUnicodeObject 11 14 { 12 int ob_refcnt; 13 PyTypeObject *ob_type; 15 mixin PyObject_HEAD; 14 16 int length; 15 17 Py_UNICODE *str; … … 23 25 // MACROS 24 26 //============================================================================== 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); 27 bit PyUnicode_Check(PyObject* obj) 28 { 29 return PyObject_TypeCheck(opj, PyUnicode_Type); 30 } 31 32 bit PyUnicode_CheckExact(PyObject* obj) 33 { 34 return (obj.ob_type is PyUnicode_Type); 35 } 36 37 int PyUnicode_GET_SIZE(PyObject* obj) 38 { 39 PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 40 return uobj.length; 41 } 42 43 int PyUnicode_GET_DATA_SIZE(PyObject* obj) 44 { 45 PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 46 return uobj.length * Py_UNICODE.sizeof; 47 } 48 49 Py_UNICODE* PyUnicode_AS_UNICODE(PyObject* obj) 50 { 51 PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 52 return uobj.str; 53 } 54 55 char* PyUnicode_AS_DATA(PyObject* obj) 56 { 57 PyUnicodeObject* uobj = cast(PyUnicodeObject*)obj; 58 return cast(char*)(uobj.str); 43 59 } 44 60 … … 208 224 209 225 } // extern(C) 226 227 } // version(USING_UNICODE)
