lib
IndirectPythonInterface.cxx00001
00002
00003
00004 #undef _XOPEN_SOURCE
00005 #include "IndirectPythonInterface.hxx"
00006
00007 namespace Py
00008 {
00009 bool _Buffer_Check( PyObject *op ) { return (op)->ob_type == _Buffer_Type(); }
00010 bool _CFunction_Check( PyObject *op ) { return (op)->ob_type == _CFunction_Type(); }
00011 bool _Class_Check( PyObject *op ) { return (op)->ob_type == _Class_Type(); }
00012 bool _CObject_Check( PyObject *op ) { return (op)->ob_type == _CObject_Type(); }
00013 bool _Complex_Check( PyObject *op ) { return (op)->ob_type == _Complex_Type(); }
00014 bool _Dict_Check( PyObject *op ) { return (op)->ob_type == _Dict_Type(); }
00015 bool _File_Check( PyObject *op ) { return (op)->ob_type == _File_Type(); }
00016 bool _Float_Check( PyObject *op ) { return (op)->ob_type == _Float_Type(); }
00017 bool _Function_Check( PyObject *op ) { return (op)->ob_type == _Function_Type(); }
00018 bool _Instance_Check( PyObject *op ) { return (op)->ob_type == _Instance_Type(); }
00019 bool _Int_Check( PyObject *op ) { return (op)->ob_type == _Int_Type(); }
00020 bool _List_Check( PyObject *o ) { return o->ob_type == _List_Type(); }
00021 bool _Long_Check( PyObject *op ) { return (op)->ob_type == _Long_Type(); }
00022 bool _Method_Check( PyObject *op ) { return (op)->ob_type == _Method_Type(); }
00023 bool _Module_Check( PyObject *op ) { return (op)->ob_type == _Module_Type(); }
00024 bool _Range_Check( PyObject *op ) { return (op)->ob_type == _Range_Type(); }
00025 bool _Slice_Check( PyObject *op ) { return (op)->ob_type == _Slice_Type(); }
00026 bool _String_Check( PyObject *o ) { return o->ob_type == _String_Type(); }
00027 bool _TraceBack_Check( PyObject *v ) { return (v)->ob_type == _TraceBack_Type(); }
00028 bool _Tuple_Check( PyObject *op ) { return (op)->ob_type == _Tuple_Type(); }
00029 bool _Type_Check( PyObject *op ) { return (op)->ob_type == _Type_Type(); }
00030
00031 #if PY_MAJOR_VERSION >= 2
00032 bool _Unicode_Check( PyObject *op ) { return (op)->ob_type == _Unicode_Type(); }
00033 #endif
00034
00035
00036
00037 #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
00038
00039 #if defined(MS_WINDOWS)
00040 #include <windows.h>
00041
00042
00043 static HMODULE python_dll;
00044
00045 static PyObject *ptr__Exc_ArithmeticError = NULL;
00046 static PyObject *ptr__Exc_AssertionError = NULL;
00047 static PyObject *ptr__Exc_AttributeError = NULL;
00048 static PyObject *ptr__Exc_EnvironmentError = NULL;
00049 static PyObject *ptr__Exc_EOFError = NULL;
00050 static PyObject *ptr__Exc_Exception = NULL;
00051 static PyObject *ptr__Exc_FloatingPointError = NULL;
00052 static PyObject *ptr__Exc_ImportError = NULL;
00053 static PyObject *ptr__Exc_IndexError = NULL;
00054 static PyObject *ptr__Exc_IOError = NULL;
00055 static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
00056 static PyObject *ptr__Exc_KeyError = NULL;
00057 static PyObject *ptr__Exc_LookupError = NULL;
00058 static PyObject *ptr__Exc_MemoryError = NULL;
00059 static PyObject *ptr__Exc_MemoryErrorInst = NULL;
00060 static PyObject *ptr__Exc_NameError = NULL;
00061 static PyObject *ptr__Exc_NotImplementedError = NULL;
00062 static PyObject *ptr__Exc_OSError = NULL;
00063 static PyObject *ptr__Exc_OverflowError = NULL;
00064 static PyObject *ptr__Exc_RuntimeError = NULL;
00065 static PyObject *ptr__Exc_StandardError = NULL;
00066 static PyObject *ptr__Exc_SyntaxError = NULL;
00067 static PyObject *ptr__Exc_SystemError = NULL;
00068 static PyObject *ptr__Exc_SystemExit = NULL;
00069 static PyObject *ptr__Exc_TypeError = NULL;
00070 static PyObject *ptr__Exc_ValueError = NULL;
00071 static PyObject *ptr__Exc_ZeroDivisionError = NULL;
00072
00073 #ifdef MS_WINDOWS
00074 static PyObject *ptr__Exc_WindowsError = NULL;
00075 #endif
00076
00077 #if PY_MAJOR_VERSION >= 2
00078 static PyObject *ptr__Exc_IndentationError = NULL;
00079 static PyObject *ptr__Exc_TabError = NULL;
00080 static PyObject *ptr__Exc_UnboundLocalError = NULL;
00081 static PyObject *ptr__Exc_UnicodeError = NULL;
00082 #endif
00083
00084 static PyObject *ptr__PyNone = NULL;
00085
00086 static PyTypeObject *ptr__Buffer_Type = NULL;
00087 static PyTypeObject *ptr__CFunction_Type = NULL;
00088 static PyTypeObject *ptr__Class_Type = NULL;
00089 static PyTypeObject *ptr__CObject_Type = NULL;
00090 static PyTypeObject *ptr__Complex_Type = NULL;
00091 static PyTypeObject *ptr__Dict_Type = NULL;
00092 static PyTypeObject *ptr__File_Type = NULL;
00093 static PyTypeObject *ptr__Float_Type = NULL;
00094 static PyTypeObject *ptr__Function_Type = NULL;
00095 static PyTypeObject *ptr__Instance_Type = NULL;
00096 static PyTypeObject *ptr__Int_Type = NULL;
00097 static PyTypeObject *ptr__List_Type = NULL;
00098 static PyTypeObject *ptr__Long_Type = NULL;
00099 static PyTypeObject *ptr__Method_Type = NULL;
00100 static PyTypeObject *ptr__Module_Type = NULL;
00101 static PyTypeObject *ptr__Range_Type = NULL;
00102 static PyTypeObject *ptr__Slice_Type = NULL;
00103 static PyTypeObject *ptr__String_Type = NULL;
00104 static PyTypeObject *ptr__TraceBack_Type = NULL;
00105 static PyTypeObject *ptr__Tuple_Type = NULL;
00106 static PyTypeObject *ptr__Type_Type = NULL;
00107
00108 #if PY_MAJOR_VERSION >= 2
00109 static PyTypeObject *ptr__Unicode_Type = NULL;
00110 #endif
00111
00112 static int *ptr_Py_DebugFlag = NULL;
00113 static int *ptr_Py_InteractiveFlag = NULL;
00114 static int *ptr_Py_OptimizeFlag = NULL;
00115 static int *ptr_Py_NoSiteFlag = NULL;
00116 static int *ptr_Py_TabcheckFlag = NULL;
00117 static int *ptr_Py_VerboseFlag = NULL;
00118
00119 #if PY_MAJOR_VERSION >= 2
00120 static int *ptr_Py_UnicodeFlag = NULL;
00121 #endif
00122
00123 static char **ptr__Py_PackageContext = NULL;
00124
00125 #ifdef Py_REF_DEBUG
00126 int *ptr_Py_RefTotal;
00127 #endif
00128
00129
00130
00131 class GetAddressException
00132 {
00133 public:
00134 GetAddressException( const char *_name )
00135 : name( _name )
00136 {}
00137 virtual ~GetAddressException() {}
00138 const char *name;
00139 };
00140
00141
00142
00143 static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
00144 {
00145 FARPROC addr = GetProcAddress( python_dll, name );
00146 if( addr == NULL )
00147 throw GetAddressException( name );
00148
00149 return *(PyObject **)addr;
00150 }
00151
00152 static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
00153 {
00154 FARPROC addr = GetProcAddress( python_dll, name );
00155 if( addr == NULL )
00156 throw GetAddressException( name );
00157
00158 return (PyObject *)addr;
00159 }
00160
00161 static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
00162 {
00163 FARPROC addr = GetProcAddress( python_dll, name );
00164 if( addr == NULL )
00165 throw GetAddressException( name );
00166
00167 return *(PyTypeObject **)addr;
00168 }
00169
00170 static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
00171 {
00172 FARPROC addr = GetProcAddress( python_dll, name );
00173 if( addr == NULL )
00174 throw GetAddressException( name );
00175
00176 return (PyTypeObject *)addr;
00177 }
00178
00179 static int *GetInt_as_IntPointer( const char *name )
00180 {
00181 FARPROC addr = GetProcAddress( python_dll, name );
00182 if( addr == NULL )
00183 throw GetAddressException( name );
00184
00185 return (int *)addr;
00186 }
00187
00188 static char **GetCharPointer_as_CharPointerPointer( const char *name )
00189 {
00190 FARPROC addr = GetProcAddress( python_dll, name );
00191 if( addr == NULL )
00192 throw GetAddressException( name );
00193
00194 return (char **)addr;
00195 }
00196
00197
00198 #ifdef _DEBUG
00199 static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
00200 #else
00201 static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
00202 #endif
00203
00204
00205 bool InitialisePythonIndirectInterface()
00206 {
00207 char python_dll_name[sizeof(python_dll_name_format)];
00208
00209 sprintf( python_dll_name, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
00210
00211 python_dll = LoadLibrary( python_dll_name );
00212 if( python_dll == NULL )
00213 return false;
00214
00215 try
00216 {
00217 #ifdef Py_REF_DEBUG
00218 ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
00219 #endif
00220 ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
00221 ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
00222 ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
00223 ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
00224 ptr_Py_TabcheckFlag = GetInt_as_IntPointer( "Py_TabcheckFlag" );
00225 ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
00226 #if PY_MAJOR_VERSION >= 2
00227 ptr_Py_UnicodeFlag = GetInt_as_IntPointer( "Py_UnicodeFlag" );
00228 #endif
00229 ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
00230
00231 ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
00232 ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
00233 ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
00234 ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
00235 ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
00236 ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
00237 ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
00238 ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
00239 ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
00240 ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
00241 ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
00242 ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
00243 ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
00244 ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
00245 ptr__Exc_MemoryErrorInst = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryErrorInst" );
00246 ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
00247 ptr__Exc_NotImplementedError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
00248 ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
00249 ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
00250 ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
00251 ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
00252 ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
00253 ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
00254 ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
00255 ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
00256 ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
00257 #ifdef MS_WINDOWS
00258 ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
00259 #endif
00260 ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
00261
00262 #if PY_MAJOR_VERSION >= 2
00263 ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
00264 ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
00265 ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
00266 ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
00267 #endif
00268 ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
00269
00270 ptr__Buffer_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBuffer_Type" );
00271 ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
00272 ptr__Class_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyClass_Type" );
00273 ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
00274 ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
00275 ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
00276 ptr__File_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFile_Type" );
00277 ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
00278 ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
00279 ptr__Instance_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInstance_Type" );
00280 ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
00281 ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
00282 ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
00283 ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
00284 ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
00285 ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
00286 ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
00287 ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
00288 ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
00289 ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
00290 ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
00291
00292 #if PY_MAJOR_VERSION >= 2
00293 ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
00294 #endif
00295 }
00296 catch( GetAddressException &e )
00297 {
00298 OutputDebugString( python_dll_name );
00299 OutputDebugString( " does not contain symbol ");
00300 OutputDebugString( e.name );
00301 OutputDebugString( "\n" );
00302
00303 return false;
00304 }
00305
00306 return true;
00307 }
00308
00309
00310
00311
00312 PyObject * _Exc_ArithmeticError() { return ptr__Exc_ArithmeticError; }
00313 PyObject * _Exc_AssertionError() { return ptr__Exc_AssertionError; }
00314 PyObject * _Exc_AttributeError() { return ptr__Exc_AttributeError; }
00315 PyObject * _Exc_EnvironmentError() { return ptr__Exc_EnvironmentError; }
00316 PyObject * _Exc_EOFError() { return ptr__Exc_EOFError; }
00317 PyObject * _Exc_Exception() { return ptr__Exc_Exception; }
00318 PyObject * _Exc_FloatingPointError() { return ptr__Exc_FloatingPointError; }
00319 PyObject * _Exc_ImportError() { return ptr__Exc_ImportError; }
00320 PyObject * _Exc_IndexError() { return ptr__Exc_IndexError; }
00321 PyObject * _Exc_IOError() { return ptr__Exc_IOError; }
00322 PyObject * _Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
00323 PyObject * _Exc_KeyError() { return ptr__Exc_KeyError; }
00324 PyObject * _Exc_LookupError() { return ptr__Exc_LookupError; }
00325 PyObject * _Exc_MemoryError() { return ptr__Exc_MemoryError; }
00326 PyObject * _Exc_MemoryErrorInst() { return ptr__Exc_MemoryErrorInst; }
00327 PyObject * _Exc_NameError() { return ptr__Exc_NameError; }
00328 PyObject * _Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
00329 PyObject * _Exc_OSError() { return ptr__Exc_OSError; }
00330 PyObject * _Exc_OverflowError() { return ptr__Exc_OverflowError; }
00331 PyObject * _Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
00332 PyObject * _Exc_StandardError() { return ptr__Exc_StandardError; }
00333 PyObject * _Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
00334 PyObject * _Exc_SystemError() { return ptr__Exc_SystemError; }
00335 PyObject * _Exc_SystemExit() { return ptr__Exc_SystemExit; }
00336 PyObject * _Exc_TypeError() { return ptr__Exc_TypeError; }
00337 PyObject * _Exc_ValueError() { return ptr__Exc_ValueError; }
00338 #ifdef MS_WINDOWS
00339 PyObject * _Exc_WindowsError() { return ptr__Exc_WindowsError; }
00340 #endif
00341 PyObject * _Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
00342
00343 #if PY_MAJOR_VERSION >= 2
00344 PyObject * _Exc_IndentationError() { return ptr__Exc_IndentationError; }
00345 PyObject * _Exc_TabError() { return ptr__Exc_TabError; }
00346 PyObject * _Exc_UnboundLocalError() { return ptr__Exc_UnboundLocalError; }
00347 PyObject * _Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
00348 #endif
00349
00350
00351
00352
00353 PyObject * _None() { return ptr__PyNone; }
00354
00355
00356 PyTypeObject * _Buffer_Type() { return ptr__Buffer_Type; }
00357 PyTypeObject * _CFunction_Type() { return ptr__CFunction_Type; }
00358 PyTypeObject * _Class_Type() { return ptr__Class_Type; }
00359 PyTypeObject * _CObject_Type() { return ptr__CObject_Type; }
00360 PyTypeObject * _Complex_Type() { return ptr__Complex_Type; }
00361 PyTypeObject * _Dict_Type() { return ptr__Dict_Type; }
00362 PyTypeObject * _File_Type() { return ptr__File_Type; }
00363 PyTypeObject * _Float_Type() { return ptr__Float_Type; }
00364 PyTypeObject * _Function_Type() { return ptr__Function_Type; }
00365 PyTypeObject * _Instance_Type() { return ptr__Instance_Type; }
00366 PyTypeObject * _Int_Type() { return ptr__Int_Type; }
00367 PyTypeObject * _List_Type() { return ptr__List_Type; }
00368 PyTypeObject * _Long_Type() { return ptr__Long_Type; }
00369 PyTypeObject * _Method_Type() { return ptr__Method_Type; }
00370 PyTypeObject * _Module_Type() { return ptr__Module_Type; }
00371 PyTypeObject * _Range_Type() { return ptr__Range_Type; }
00372 PyTypeObject * _Slice_Type() { return ptr__Slice_Type; }
00373 PyTypeObject * _String_Type() { return ptr__String_Type; }
00374 PyTypeObject * _TraceBack_Type() { return ptr__TraceBack_Type; }
00375 PyTypeObject * _Tuple_Type() { return ptr__Tuple_Type; }
00376 PyTypeObject * _Type_Type() { return ptr__Type_Type; }
00377
00378 #if PY_MAJOR_VERSION >= 2
00379 PyTypeObject * _Unicode_Type() { return ptr__Unicode_Type; }
00380 #endif
00381
00382 char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
00383
00384
00385
00386
00387
00388 int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
00389 int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
00390 int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
00391 int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
00392 int &_Py_TabcheckFlag() { return *ptr_Py_TabcheckFlag; }
00393 int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
00394 #if PY_MAJOR_VERSION >= 2
00395 int &_Py_UnicodeFlag() { return *ptr_Py_UnicodeFlag; }
00396 #endif
00397
00398 void _XINCREF( PyObject *op )
00399 {
00400
00401 if( op == NULL )
00402 return;
00403
00404 #ifdef Py_REF_DEBUG
00405 (*ptr_Py_RefTotal)++;
00406 #endif
00407 (op)->ob_refcnt++;
00408
00409 }
00410
00411 void _XDECREF( PyObject *op )
00412 {
00413
00414 if( op == NULL )
00415 return;
00416
00417 #ifdef Py_REF_DEBUG
00418 (*ptr_Py_RefTotal)--;
00419 #endif
00420
00421 if (--(op)->ob_refcnt == 0)
00422 _Py_Dealloc((PyObject *)(op));
00423 }
00424
00425
00426 #else
00427 #error "Can only delay load under Win32"
00428 #endif
00429
00430 #else
00431
00432
00433
00434
00435
00436 extern "C" DL_IMPORT(PyTypeObject) PyRange_Type;
00437 extern "C" DL_IMPORT(PyObject *) PyRange_New(long, long, long, int);
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 PyObject * _Exc_ArithmeticError() { return ::PyExc_ArithmeticError; }
00451 PyObject * _Exc_AssertionError() { return ::PyExc_AssertionError; }
00452 PyObject * _Exc_AttributeError() { return ::PyExc_AttributeError; }
00453 PyObject * _Exc_EnvironmentError() { return ::PyExc_EnvironmentError; }
00454 PyObject * _Exc_EOFError() { return ::PyExc_EOFError; }
00455 PyObject * _Exc_Exception() { return ::PyExc_Exception; }
00456 PyObject * _Exc_FloatingPointError() { return ::PyExc_FloatingPointError; }
00457 PyObject * _Exc_ImportError() { return ::PyExc_ImportError; }
00458 PyObject * _Exc_IndexError() { return ::PyExc_IndexError; }
00459 PyObject * _Exc_IOError() { return ::PyExc_IOError; }
00460 PyObject * _Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
00461 PyObject * _Exc_KeyError() { return ::PyExc_KeyError; }
00462 PyObject * _Exc_LookupError() { return ::PyExc_LookupError; }
00463 PyObject * _Exc_MemoryError() { return ::PyExc_MemoryError; }
00464 PyObject * _Exc_MemoryErrorInst() { return ::PyExc_MemoryErrorInst; }
00465 PyObject * _Exc_NameError() { return ::PyExc_NameError; }
00466 PyObject * _Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
00467 PyObject * _Exc_OSError() { return ::PyExc_OSError; }
00468 PyObject * _Exc_OverflowError() { return ::PyExc_OverflowError; }
00469 PyObject * _Exc_RuntimeError() { return ::PyExc_RuntimeError; }
00470 PyObject * _Exc_StandardError() { return ::PyExc_StandardError; }
00471 PyObject * _Exc_SyntaxError() { return ::PyExc_SyntaxError; }
00472 PyObject * _Exc_SystemError() { return ::PyExc_SystemError; }
00473 PyObject * _Exc_SystemExit() { return ::PyExc_SystemExit; }
00474 PyObject * _Exc_TypeError() { return ::PyExc_TypeError; }
00475 PyObject * _Exc_ValueError() { return ::PyExc_ValueError; }
00476 PyObject * _Exc_ZeroDivisionError() { return ::PyExc_ZeroDivisionError; }
00477
00478 #ifdef MS_WINDOWS
00479 PyObject * _Exc_WindowsError() { return ::PyExc_WindowsError; }
00480 #endif
00481
00482
00483 #if PY_MAJOR_VERSION >= 2
00484 PyObject * _Exc_IndentationError() { return ::PyExc_IndentationError; }
00485 PyObject * _Exc_TabError() { return ::PyExc_TabError; }
00486 PyObject * _Exc_UnboundLocalError() { return ::PyExc_UnboundLocalError; }
00487 PyObject * _Exc_UnicodeError() { return ::PyExc_UnicodeError; }
00488 #endif
00489
00490
00491
00492
00493
00494 PyObject * _None() { return &::_Py_NoneStruct; }
00495
00496 PyTypeObject * _Buffer_Type() { return &PyBuffer_Type; }
00497 PyTypeObject * _CFunction_Type() { return &PyCFunction_Type; }
00498 PyTypeObject * _Class_Type() { return &PyClass_Type; }
00499 PyTypeObject * _CObject_Type() { return &PyCObject_Type; }
00500 PyTypeObject * _Complex_Type() { return &PyComplex_Type; }
00501 PyTypeObject * _Dict_Type() { return &PyDict_Type; }
00502 PyTypeObject * _File_Type() { return &PyFile_Type; }
00503 PyTypeObject * _Float_Type() { return &PyFloat_Type; }
00504 PyTypeObject * _Function_Type() { return &PyFunction_Type; }
00505 PyTypeObject * _Instance_Type() { return &PyInstance_Type; }
00506 PyTypeObject * _Int_Type() { return &PyInt_Type; }
00507 PyTypeObject * _List_Type() { return &PyList_Type; }
00508 PyTypeObject * _Long_Type() { return &PyLong_Type; }
00509 PyTypeObject * _Method_Type() { return &PyMethod_Type; }
00510 PyTypeObject * _Module_Type() { return &PyModule_Type; }
00511 PyTypeObject * _Range_Type() { return &PyRange_Type; }
00512 PyTypeObject * _Slice_Type() { return &PySlice_Type; }
00513 PyTypeObject * _String_Type() { return &PyString_Type; }
00514 PyTypeObject * _TraceBack_Type() { return &PyTraceBack_Type; }
00515 PyTypeObject * _Tuple_Type() { return &PyTuple_Type; }
00516 PyTypeObject * _Type_Type() { return &PyType_Type; }
00517
00518 #if PY_MAJOR_VERSION >= 2
00519 PyTypeObject * _Unicode_Type() { return &PyUnicode_Type; }
00520 #endif
00521
00522
00523
00524
00525 int &_Py_DebugFlag() { return Py_DebugFlag; }
00526 int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
00527 int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
00528 int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
00529 int &_Py_TabcheckFlag() { return Py_TabcheckFlag; }
00530 int &_Py_VerboseFlag() { return Py_VerboseFlag; }
00531 #if PY_MAJOR_VERSION >= 2
00532 int &_Py_UnicodeFlag() { return Py_UnicodeFlag; }
00533 #endif
00534 char *__Py_PackageContext() { return _Py_PackageContext; }
00535
00536
00537
00538
00539 void _XINCREF( PyObject *op )
00540 {
00541 Py_XINCREF(op);
00542 }
00543
00544 void _XDECREF( PyObject *op )
00545 {
00546 Py_XDECREF(op);
00547 }
00548
00549 #endif
00550 }
|