F:/KPlato/koffice/libs/kross/python/cxx/IndirectPythonInterface.cxx

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

Généré le Wed Nov 22 23:41:12 2006 pour KPlato par  doxygen 1.5.1-p1