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