lib

IndirectPythonInterface.cpp
1//
2// IndirectPythonInterface.cpp
3//
4#undef _XOPEN_SOURCE
5#include "IndirectPythonInterface.h"
6
7namespace Py
8{
9bool _Buffer_Check( PyObject *op ) { return (op)->ob_type == _Buffer_Type(); }
10bool _CFunction_Check( PyObject *op ) { return (op)->ob_type == _CFunction_Type(); }
11bool _Class_Check( PyObject *op ) { return (op)->ob_type == _Class_Type(); }
12bool _CObject_Check( PyObject *op ) { return (op)->ob_type == _CObject_Type(); }
13bool _Complex_Check( PyObject *op ) { return (op)->ob_type == _Complex_Type(); }
14bool _Dict_Check( PyObject *op ) { return (op)->ob_type == _Dict_Type(); }
15bool _File_Check( PyObject *op ) { return (op)->ob_type == _File_Type(); }
16bool _Float_Check( PyObject *op ) { return (op)->ob_type == _Float_Type(); }
17bool _Function_Check( PyObject *op ) { return (op)->ob_type == _Function_Type(); }
18bool _Instance_Check( PyObject *op ) { return (op)->ob_type == _Instance_Type(); }
19bool _Int_Check( PyObject *op ) { return (op)->ob_type == _Int_Type(); }
20bool _List_Check( PyObject *o ) { return o->ob_type == _List_Type(); }
21bool _Long_Check( PyObject *op ) { return (op)->ob_type == _Long_Type(); }
22bool _Method_Check( PyObject *op ) { return (op)->ob_type == _Method_Type(); }
23bool _Module_Check( PyObject *op ) { return (op)->ob_type == _Module_Type(); }
24bool _Range_Check( PyObject *op ) { return (op)->ob_type == _Range_Type(); }
25bool _Slice_Check( PyObject *op ) { return (op)->ob_type == _Slice_Type(); }
26bool _String_Check( PyObject *o ) { return o->ob_type == _String_Type(); }
27bool _TraceBack_Check( PyObject *v ) { return (v)->ob_type == _TraceBack_Type(); }
28bool _Tuple_Check( PyObject *op ) { return (op)->ob_type == _Tuple_Type(); }
29bool _Type_Check( PyObject *op ) { return (op)->ob_type == _Type_Type(); }
30
31#if PY_MAJOR_VERSION >= 2
32bool _Unicode_Check( PyObject *op ) { return (op)->ob_type == _Unicode_Type(); }
33#endif
34
35
36
37#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
38
39#if defined(MS_WINDOWS)
40#include <windows.h>
41
42
43static HMODULE python_dll;
44
45static PyObject *ptr__Exc_ArithmeticError = NULL;
46static PyObject *ptr__Exc_AssertionError = NULL;
47static PyObject *ptr__Exc_AttributeError = NULL;
48static PyObject *ptr__Exc_EnvironmentError = NULL;
49static PyObject *ptr__Exc_EOFError = NULL;
50static PyObject *ptr__Exc_Exception = NULL;
51static PyObject *ptr__Exc_FloatingPointError = NULL;
52static PyObject *ptr__Exc_ImportError = NULL;
53static PyObject *ptr__Exc_IndexError = NULL;
54static PyObject *ptr__Exc_IOError = NULL;
55static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
56static PyObject *ptr__Exc_KeyError = NULL;
57static PyObject *ptr__Exc_LookupError = NULL;
58static PyObject *ptr__Exc_MemoryError = NULL;
59static PyObject *ptr__Exc_MemoryErrorInst = NULL;
60static PyObject *ptr__Exc_NameError = NULL;
61static PyObject *ptr__Exc_NotImplementedError = NULL;
62static PyObject *ptr__Exc_OSError = NULL;
63static PyObject *ptr__Exc_OverflowError = NULL;
64static PyObject *ptr__Exc_RuntimeError = NULL;
65static PyObject *ptr__Exc_StandardError = NULL;
66static PyObject *ptr__Exc_SyntaxError = NULL;
67static PyObject *ptr__Exc_SystemError = NULL;
68static PyObject *ptr__Exc_SystemExit = NULL;
69static PyObject *ptr__Exc_TypeError = NULL;
70static PyObject *ptr__Exc_ValueError = NULL;
71static PyObject *ptr__Exc_ZeroDivisionError = NULL;
72
73#ifdef MS_WINDOWS
74static PyObject *ptr__Exc_WindowsError = NULL;
75#endif
76
77#if PY_MAJOR_VERSION >= 2
78static PyObject *ptr__Exc_IndentationError = NULL;
79static PyObject *ptr__Exc_TabError = NULL;
80static PyObject *ptr__Exc_UnboundLocalError = NULL;
81static PyObject *ptr__Exc_UnicodeError = NULL;
82#endif
83
84static PyObject *ptr__PyNone = NULL;
85
86static PyTypeObject *ptr__Buffer_Type = NULL;
87static PyTypeObject *ptr__CFunction_Type = NULL;
88static PyTypeObject *ptr__Class_Type = NULL;
89static PyTypeObject *ptr__CObject_Type = NULL;
90static PyTypeObject *ptr__Complex_Type = NULL;
91static PyTypeObject *ptr__Dict_Type = NULL;
92static PyTypeObject *ptr__File_Type = NULL;
93static PyTypeObject *ptr__Float_Type = NULL;
94static PyTypeObject *ptr__Function_Type = NULL;
95static PyTypeObject *ptr__Instance_Type = NULL;
96static PyTypeObject *ptr__Int_Type = NULL;
97static PyTypeObject *ptr__List_Type = NULL;
98static PyTypeObject *ptr__Long_Type = NULL;
99static PyTypeObject *ptr__Method_Type = NULL;
100static PyTypeObject *ptr__Module_Type = NULL;
101static PyTypeObject *ptr__Range_Type = NULL;
102static PyTypeObject *ptr__Slice_Type = NULL;
103static PyTypeObject *ptr__String_Type = NULL;
104static PyTypeObject *ptr__TraceBack_Type = NULL;
105static PyTypeObject *ptr__Tuple_Type = NULL;
106static PyTypeObject *ptr__Type_Type = NULL;
107
108#if PY_MAJOR_VERSION >= 2
109static PyTypeObject *ptr__Unicode_Type = NULL;
110#endif
111
112static int *ptr_Py_DebugFlag = NULL;
113static int *ptr_Py_InteractiveFlag = NULL;
114static int *ptr_Py_OptimizeFlag = NULL;
115static int *ptr_Py_NoSiteFlag = NULL;
116static int *ptr_Py_TabcheckFlag = NULL;
117static int *ptr_Py_VerboseFlag = NULL;
118
119#if PY_MAJOR_VERSION >= 2
120static int *ptr_Py_UnicodeFlag = NULL;
121#endif
122
123static char **ptr__Py_PackageContext = NULL;
124
125#ifdef Py_REF_DEBUG
126int *ptr_Py_RefTotal;
127#endif
128
129
130//--------------------------------------------------------------------------------
131class GetAddressException
132 {
133public:
134 GetAddressException( const char *_name )
135 : name( _name )
136 {}
137 virtual ~GetAddressException() {}
138 const char *name;
139 };
140
141
142//--------------------------------------------------------------------------------
143static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
144 {
145 FARPROC addr = GetProcAddress( python_dll, name );
146 if( addr == NULL )
147 throw GetAddressException( name );
148
149 return *(PyObject **)addr;
150 }
151
152static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
153 {
154 FARPROC addr = GetProcAddress( python_dll, name );
155 if( addr == NULL )
156 throw GetAddressException( name );
157
158 return (PyObject *)addr;
159 }
160
161static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
162 {
163 FARPROC addr = GetProcAddress( python_dll, name );
164 if( addr == NULL )
165 throw GetAddressException( name );
166
167 return *(PyTypeObject **)addr;
168 }
169
170static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
171 {
172 FARPROC addr = GetProcAddress( python_dll, name );
173 if( addr == NULL )
174 throw GetAddressException( name );
175
176 return (PyTypeObject *)addr;
177 }
178
179static int *GetInt_as_IntPointer( const char *name )
180 {
181 FARPROC addr = GetProcAddress( python_dll, name );
182 if( addr == NULL )
183 throw GetAddressException( name );
184
185 return (int *)addr;
186 }
187
188static char **GetCharPointer_as_CharPointerPointer( const char *name )
189 {
190 FARPROC addr = GetProcAddress( python_dll, name );
191 if( addr == NULL )
192 throw GetAddressException( name );
193
194 return (char **)addr;
195 }
196
197
198#ifdef _DEBUG
199static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
200#else
201static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
202#endif
203
204//--------------------------------------------------------------------------------
205bool InitialisePythonIndirectInterface()
206 {
207 char python_dll_name[sizeof(python_dll_name_format)];
208
209 sprintf( python_dll_name, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
210
211 python_dll = LoadLibrary( python_dll_name );
212 if( python_dll == NULL )
213 return false;
214
215 try
216 {
217#ifdef Py_REF_DEBUG
218 ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
219#endif
220 ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
221 ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
222 ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
223 ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
224 ptr_Py_TabcheckFlag = GetInt_as_IntPointer( "Py_TabcheckFlag" );
225 ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
226#if PY_MAJOR_VERSION >= 2
227 ptr_Py_UnicodeFlag = GetInt_as_IntPointer( "Py_UnicodeFlag" );
228#endif
229 ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
230
231 ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
232 ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
233 ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
234 ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
235 ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
236 ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
237 ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
238 ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
239 ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
240 ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
241 ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
242 ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
243 ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
244 ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
245 ptr__Exc_MemoryErrorInst = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryErrorInst" );
246 ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
247 ptr__Exc_NotImplementedError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
248 ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
249 ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
250 ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
251 ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
252 ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
253 ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
254 ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
255 ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
256 ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
257#ifdef MS_WINDOWS
258 ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
259#endif
260 ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
261
262#if PY_MAJOR_VERSION >= 2
263 ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
264 ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
265 ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
266 ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
267#endif
268 ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
269
270 ptr__Buffer_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBuffer_Type" );
271 ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
272 ptr__Class_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyClass_Type" );
273 ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
274 ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
275 ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
276 ptr__File_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFile_Type" );
277 ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
278 ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
279 ptr__Instance_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInstance_Type" );
280 ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
281 ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
282 ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
283 ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
284 ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
285 ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
286 ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
287 ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
288 ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
289 ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
290 ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
291
292#if PY_MAJOR_VERSION >= 2
293 ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
294#endif
295 }
296 catch( GetAddressException &e )
297 {
298 OutputDebugString( python_dll_name );
299 OutputDebugString( " does not contain symbol ");
300 OutputDebugString( e.name );
301 OutputDebugString( "\n" );
302
303 return false;
304 }
305
306 return true;
307 }
308
309//
310// Wrap variables as function calls
311//
312PyObject * _Exc_ArithmeticError() { return ptr__Exc_ArithmeticError; }
313PyObject * _Exc_AssertionError() { return ptr__Exc_AssertionError; }
314PyObject * _Exc_AttributeError() { return ptr__Exc_AttributeError; }
315PyObject * _Exc_EnvironmentError() { return ptr__Exc_EnvironmentError; }
316PyObject * _Exc_EOFError() { return ptr__Exc_EOFError; }
317PyObject * _Exc_Exception() { return ptr__Exc_Exception; }
318PyObject * _Exc_FloatingPointError() { return ptr__Exc_FloatingPointError; }
319PyObject * _Exc_ImportError() { return ptr__Exc_ImportError; }
320PyObject * _Exc_IndexError() { return ptr__Exc_IndexError; }
321PyObject * _Exc_IOError() { return ptr__Exc_IOError; }
322PyObject * _Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
323PyObject * _Exc_KeyError() { return ptr__Exc_KeyError; }
324PyObject * _Exc_LookupError() { return ptr__Exc_LookupError; }
325PyObject * _Exc_MemoryError() { return ptr__Exc_MemoryError; }
326PyObject * _Exc_MemoryErrorInst() { return ptr__Exc_MemoryErrorInst; }
327PyObject * _Exc_NameError() { return ptr__Exc_NameError; }
328PyObject * _Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
329PyObject * _Exc_OSError() { return ptr__Exc_OSError; }
330PyObject * _Exc_OverflowError() { return ptr__Exc_OverflowError; }
331PyObject * _Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
332PyObject * _Exc_StandardError() { return ptr__Exc_StandardError; }
333PyObject * _Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
334PyObject * _Exc_SystemError() { return ptr__Exc_SystemError; }
335PyObject * _Exc_SystemExit() { return ptr__Exc_SystemExit; }
336PyObject * _Exc_TypeError() { return ptr__Exc_TypeError; }
337PyObject * _Exc_ValueError() { return ptr__Exc_ValueError; }
338#ifdef MS_WINDOWS
339PyObject * _Exc_WindowsError() { return ptr__Exc_WindowsError; }
340#endif
341PyObject * _Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
342
343#if PY_MAJOR_VERSION >= 2
344PyObject * _Exc_IndentationError() { return ptr__Exc_IndentationError; }
345PyObject * _Exc_TabError() { return ptr__Exc_TabError; }
346PyObject * _Exc_UnboundLocalError() { return ptr__Exc_UnboundLocalError; }
347PyObject * _Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
348#endif
349
350//
351// wrap items in Object.h
352//
353PyObject * _None() { return ptr__PyNone; }
354
355
356PyTypeObject * _Buffer_Type() { return ptr__Buffer_Type; }
357PyTypeObject * _CFunction_Type() { return ptr__CFunction_Type; }
358PyTypeObject * _Class_Type() { return ptr__Class_Type; }
359PyTypeObject * _CObject_Type() { return ptr__CObject_Type; }
360PyTypeObject * _Complex_Type() { return ptr__Complex_Type; }
361PyTypeObject * _Dict_Type() { return ptr__Dict_Type; }
362PyTypeObject * _File_Type() { return ptr__File_Type; }
363PyTypeObject * _Float_Type() { return ptr__Float_Type; }
364PyTypeObject * _Function_Type() { return ptr__Function_Type; }
365PyTypeObject * _Instance_Type() { return ptr__Instance_Type; }
366PyTypeObject * _Int_Type() { return ptr__Int_Type; }
367PyTypeObject * _List_Type() { return ptr__List_Type; }
368PyTypeObject * _Long_Type() { return ptr__Long_Type; }
369PyTypeObject * _Method_Type() { return ptr__Method_Type; }
370PyTypeObject * _Module_Type() { return ptr__Module_Type; }
371PyTypeObject * _Range_Type() { return ptr__Range_Type; }
372PyTypeObject * _Slice_Type() { return ptr__Slice_Type; }
373PyTypeObject * _String_Type() { return ptr__String_Type; }
374PyTypeObject * _TraceBack_Type() { return ptr__TraceBack_Type; }
375PyTypeObject * _Tuple_Type() { return ptr__Tuple_Type; }
376PyTypeObject * _Type_Type() { return ptr__Type_Type; }
377
378#if PY_MAJOR_VERSION >= 2
379PyTypeObject * _Unicode_Type() { return ptr__Unicode_Type; }
380#endif
381
382char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
383
384
385//
386// wrap the Python Flag variables
387//
388int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
389int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
390int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
391int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
392int &_Py_TabcheckFlag() { return *ptr_Py_TabcheckFlag; }
393int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
394#if PY_MAJOR_VERSION >= 2
395int &_Py_UnicodeFlag() { return *ptr_Py_UnicodeFlag; }
396#endif
397
398void _XINCREF( PyObject *op )
399 {
400 // This function must match the contents of Py_XINCREF(op)
401 if( op == NULL )
402 return;
403
404#ifdef Py_REF_DEBUG
405 (*ptr_Py_RefTotal)++;
406#endif
407 (op)->ob_refcnt++;
408
409 }
410
411void _XDECREF( PyObject *op )
412 {
413 // This function must match the contents of Py_XDECREF(op);
414 if( op == NULL )
415 return;
416
417#ifdef Py_REF_DEBUG
418 (*ptr_Py_RefTotal)--;
419#endif
420
421 if (--(op)->ob_refcnt == 0)
422 _Py_Dealloc((PyObject *)(op));
423 }
424
425
426#else
427#error "Can only delay load under Win32"
428#endif
429
430#else
431
432//
433// Duplicated these declarations from rangeobject.h which is missing the
434// extern "C". This has been reported as a bug upto and include 2.1
435//
436extern "C" DL_IMPORT(PyTypeObject) PyRange_Type;
437extern "C" DL_IMPORT(PyObject *) PyRange_New(long, long, long, int);
438
439
440//================================================================================
441//
442// Map onto Macros
443//
444//================================================================================
445
446//
447// Wrap variables as function calls
448//
449
450PyObject * _Exc_ArithmeticError() { return ::PyExc_ArithmeticError; }
451PyObject * _Exc_AssertionError() { return ::PyExc_AssertionError; }
452PyObject * _Exc_AttributeError() { return ::PyExc_AttributeError; }
453PyObject * _Exc_EnvironmentError() { return ::PyExc_EnvironmentError; }
454PyObject * _Exc_EOFError() { return ::PyExc_EOFError; }
455PyObject * _Exc_Exception() { return ::PyExc_Exception; }
456PyObject * _Exc_FloatingPointError() { return ::PyExc_FloatingPointError; }
457PyObject * _Exc_ImportError() { return ::PyExc_ImportError; }
458PyObject * _Exc_IndexError() { return ::PyExc_IndexError; }
459PyObject * _Exc_IOError() { return ::PyExc_IOError; }
460PyObject * _Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
461PyObject * _Exc_KeyError() { return ::PyExc_KeyError; }
462PyObject * _Exc_LookupError() { return ::PyExc_LookupError; }
463PyObject * _Exc_MemoryError() { return ::PyExc_MemoryError; }
464PyObject * _Exc_MemoryErrorInst() { return ::PyExc_MemoryErrorInst; }
465PyObject * _Exc_NameError() { return ::PyExc_NameError; }
466PyObject * _Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
467PyObject * _Exc_OSError() { return ::PyExc_OSError; }
468PyObject * _Exc_OverflowError() { return ::PyExc_OverflowError; }
469PyObject * _Exc_RuntimeError() { return ::PyExc_RuntimeError; }
470PyObject * _Exc_StandardError() { return ::PyExc_StandardError; }
471PyObject * _Exc_SyntaxError() { return ::PyExc_SyntaxError; }
472PyObject * _Exc_SystemError() { return ::PyExc_SystemError; }
473PyObject * _Exc_SystemExit() { return ::PyExc_SystemExit; }
474PyObject * _Exc_TypeError() { return ::PyExc_TypeError; }
475PyObject * _Exc_ValueError() { return ::PyExc_ValueError; }
476PyObject * _Exc_ZeroDivisionError() { return ::PyExc_ZeroDivisionError; }
477
478#ifdef MS_WINDOWS
479PyObject * _Exc_WindowsError() { return ::PyExc_WindowsError; }
480#endif
481
482
483#if PY_MAJOR_VERSION >= 2
484PyObject * _Exc_IndentationError() { return ::PyExc_IndentationError; }
485PyObject * _Exc_TabError() { return ::PyExc_TabError; }
486PyObject * _Exc_UnboundLocalError() { return ::PyExc_UnboundLocalError; }
487PyObject * _Exc_UnicodeError() { return ::PyExc_UnicodeError; }
488#endif
489
490
491//
492// wrap items in Object.h
493//
494PyObject * _None() { return &::_Py_NoneStruct; }
495
496PyTypeObject * _Buffer_Type() { return &PyBuffer_Type; }
497PyTypeObject * _CFunction_Type() { return &PyCFunction_Type; }
498PyTypeObject * _Class_Type() { return &PyClass_Type; }
499PyTypeObject * _CObject_Type() { return &PyCObject_Type; }
500PyTypeObject * _Complex_Type() { return &PyComplex_Type; }
501PyTypeObject * _Dict_Type() { return &PyDict_Type; }
502PyTypeObject * _File_Type() { return &PyFile_Type; }
503PyTypeObject * _Float_Type() { return &PyFloat_Type; }
504PyTypeObject * _Function_Type() { return &PyFunction_Type; }
505PyTypeObject * _Instance_Type() { return &PyInstance_Type; }
506PyTypeObject * _Int_Type() { return &PyInt_Type; }
507PyTypeObject * _List_Type() { return &PyList_Type; }
508PyTypeObject * _Long_Type() { return &PyLong_Type; }
509PyTypeObject * _Method_Type() { return &PyMethod_Type; }
510PyTypeObject * _Module_Type() { return &PyModule_Type; }
511PyTypeObject * _Range_Type() { return &PyRange_Type; }
512PyTypeObject * _Slice_Type() { return &PySlice_Type; }
513PyTypeObject * _String_Type() { return &PyString_Type; }
514PyTypeObject * _TraceBack_Type() { return &PyTraceBack_Type; }
515PyTypeObject * _Tuple_Type() { return &PyTuple_Type; }
516PyTypeObject * _Type_Type() { return &PyType_Type; }
517
518#if PY_MAJOR_VERSION >= 2
519PyTypeObject * _Unicode_Type() { return &PyUnicode_Type; }
520#endif
521
522//
523// wrap flags
524//
525int &_Py_DebugFlag() { return Py_DebugFlag; }
526int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
527int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
528int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
529int &_Py_TabcheckFlag() { return Py_TabcheckFlag; }
530int &_Py_VerboseFlag() { return Py_VerboseFlag; }
531#if PY_MAJOR_VERSION >= 2
532int &_Py_UnicodeFlag() { return Py_UnicodeFlag; }
533#endif
534char *__Py_PackageContext() { return _Py_PackageContext; }
535
536//
537// Needed to keep the abstactions for delayload interface
538//
539void _XINCREF( PyObject *op )
540 {
541 Py_XINCREF(op);
542 }
543
544void _XDECREF( PyObject *op )
545 {
546 Py_XDECREF(op);
547 }
548
549#endif
550}
const char * name(StdAction id)