|
From: <jd...@us...> - 2010-01-16 22:08:01
|
Revision: 8084
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8084&view=rev
Author: jdh2358
Date: 2010-01-16 22:07:53 +0000 (Sat, 16 Jan 2010)
Log Message:
-----------
upgraded CXX to 6.1.1
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/CXX/Config.hxx
trunk/matplotlib/CXX/Exception.hxx
trunk/matplotlib/CXX/Extensions.hxx
trunk/matplotlib/CXX/IndirectPythonInterface.cxx
trunk/matplotlib/CXX/IndirectPythonInterface.hxx
trunk/matplotlib/CXX/Objects.hxx
trunk/matplotlib/CXX/Version.hxx
trunk/matplotlib/CXX/WrapPython.h
trunk/matplotlib/CXX/cxx_extensions.cxx
trunk/matplotlib/CXX/cxxextensions.c
trunk/matplotlib/CXX/cxxsupport.cxx
Added Paths:
-----------
trunk/matplotlib/CXX/IndirectPythonInterface.cxx~
trunk/matplotlib/CXX/Python2/
trunk/matplotlib/CXX/Python2/Config.hxx
trunk/matplotlib/CXX/Python2/CxxDebug.hxx
trunk/matplotlib/CXX/Python2/Exception.hxx
trunk/matplotlib/CXX/Python2/ExtensionModule.hxx
trunk/matplotlib/CXX/Python2/ExtensionOldType.hxx
trunk/matplotlib/CXX/Python2/ExtensionType.hxx
trunk/matplotlib/CXX/Python2/ExtensionTypeBase.hxx
trunk/matplotlib/CXX/Python2/Extensions.hxx
trunk/matplotlib/CXX/Python2/IndirectPythonInterface.cxx
trunk/matplotlib/CXX/Python2/IndirectPythonInterface.hxx
trunk/matplotlib/CXX/Python2/Objects.hxx
trunk/matplotlib/CXX/Python2/PythonType.hxx
trunk/matplotlib/CXX/Python2/cxx_extensions.cxx
trunk/matplotlib/CXX/Python2/cxxextensions.c
trunk/matplotlib/CXX/Python2/cxxsupport.cxx
trunk/matplotlib/CXX/Python3/
trunk/matplotlib/CXX/Python3/Config.hxx
trunk/matplotlib/CXX/Python3/CxxDebug.hxx
trunk/matplotlib/CXX/Python3/Exception.hxx
trunk/matplotlib/CXX/Python3/ExtensionModule.hxx
trunk/matplotlib/CXX/Python3/ExtensionOldType.hxx
trunk/matplotlib/CXX/Python3/ExtensionType.hxx
trunk/matplotlib/CXX/Python3/ExtensionTypeBase.hxx
trunk/matplotlib/CXX/Python3/Extensions.hxx
trunk/matplotlib/CXX/Python3/IndirectPythonInterface.cxx
trunk/matplotlib/CXX/Python3/IndirectPythonInterface.hxx
trunk/matplotlib/CXX/Python3/Objects.hxx
trunk/matplotlib/CXX/Python3/PythonType.hxx
trunk/matplotlib/CXX/Python3/cxx_extensions.cxx
trunk/matplotlib/CXX/Python3/cxxextensions.c
trunk/matplotlib/CXX/Python3/cxxsupport.cxx
trunk/matplotlib/CXX/cxxextensions.c~
trunk/matplotlib/CXX/cxxsupport.cxx~
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-01-16 19:20:03 UTC (rev 8083)
+++ trunk/matplotlib/CHANGELOG 2010-01-16 22:07:53 UTC (rev 8084)
@@ -1,3 +1,6 @@
+
+2010-01-16 Upgraded CXX to 6.1.1 - JDH
+
2009-01-16 Don't create minor ticks on top of existing major
ticks. Patch by Neil Crighton. -ADS
@@ -17,6 +20,7 @@
2009-01-11 Add add_click and pop_click methods in
BlockingContourLabeler. -JJL
+
2010-01-03 Added rcParams['axes.color_cycle'] - EF
2010-01-03 Added Pierre's qt4 formlayout editor and toolbar button - JDH
Modified: trunk/matplotlib/CXX/Config.hxx
===================================================================
--- trunk/matplotlib/CXX/Config.hxx 2010-01-16 19:20:03 UTC (rev 8083)
+++ trunk/matplotlib/CXX/Config.hxx 2010-01-16 22:07:53 UTC (rev 8084)
@@ -34,101 +34,10 @@
// DAMAGE.
//
//-----------------------------------------------------------------------------
+#include "CXX/WrapPython.h"
-#ifndef __PyCXX_config_hh__
-#define __PyCXX_config_hh__
-
-//
-// Microsoft VC++ 6.0 has no traits
-//
-#if defined( _MSC_VER )
-
-# define STANDARD_LIBRARY_HAS_ITERATOR_TRAITS 1
-
-#elif defined( __GNUC__ )
-# if __GNUC__ >= 3
-# define STANDARD_LIBRARY_HAS_ITERATOR_TRAITS 1
-# else
-# define STANDARD_LIBRARY_HAS_ITERATOR_TRAITS 0
-#endif
-
-//
-// Assume all other compilers do
-//
+#if PY_MAJOR_VERSION == 2
+#include "CXX/Python2/Config.hxx"
#else
-
-// Macros to deal with deficiencies in compilers
-# define STANDARD_LIBRARY_HAS_ITERATOR_TRAITS 1
+#include "CXX/Python3/Config.hxx"
#endif
-
-#if STANDARD_LIBRARY_HAS_ITERATOR_TRAITS
-# define random_access_iterator_parent(itemtype) std::iterator<std::random_access_iterator_tag,itemtype,int>
-#else
-# define random_access_iterator_parent(itemtype) std::random_access_iterator<itemtype, int>
-#endif
-
-//
-// Which C++ standard is in use?
-//
-#if defined( _MSC_VER )
-# if _MSC_VER <= 1200
-// MSVC++ 6.0
-# define PYCXX_ISO_CPP_LIB 0
-# define STR_STREAM <strstream>
-# define TEMPLATE_TYPENAME class
-# else
-# define PYCXX_ISO_CPP_LIB 1
-# define STR_STREAM <sstream>
-# define TEMPLATE_TYPENAME typename
-# endif
-#elif defined( __GNUC__ )
-# if __GNUC__ >= 3
-# define PYCXX_ISO_CPP_LIB 1
-# define STR_STREAM <sstream>
-# define TEMPLATE_TYPENAME typename
-# else
-# define PYCXX_ISO_CPP_LIB 0
-# define STR_STREAM <strstream>
-# define TEMPLATE_TYPENAME class
-# endif
-#endif
-
-#if PYCXX_ISO_CPP_LIB
-# define STR_STREAM <sstream>
-# define OSTRSTREAM ostringstream
-# define EXPLICIT_TYPENAME typename
-# define EXPLICIT_CLASS class
-# define TEMPLATE_TYPENAME typename
-#else
-# define STR_STREAM <strstream>
-# define OSTRSTREAM ostrstream
-# define EXPLICIT_TYPENAME
-# define EXPLICIT_CLASS
-# define TEMPLATE_TYPENAME class
-#endif
-
-// before 2.5 Py_ssize_t was missing
-#ifndef PY_MAJOR_VERSION
-#error not defined PY_MAJOR_VERSION
-#endif
-#if PY_MAJOR_VERSION < 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5)
-typedef int Py_ssize_t;
-#endif
-
-// hash_map container usage selection
-// 1) if PYCXX_USING_STD_MAP is defined PyCXX will be using std::map<> container
-// implementation only.
-// 2) if compilers are used other than MS Visual Studio (7.1+) or GCC 3.x
-// STANDARD_LIBRARY_HAS_HASH_MAP must be defined before compilation to
-// make PyCXX using hash_map container.
-#if !defined( PYCXX_USING_STD_MAP )
- #if defined( _MSC_VER ) || defined( __INTEL_COMPILER ) || defined ( __ICC ) || (defined( __GNUC__ ) && ( __GNUC__ > 3 ))
- # define PYCXX_USING_HASH_MAP
- #else
- # if defined( STANDARD_LIBRARY_HAS_HASH_MAP ) && !defined( PYCXX_USING_HASH_MAP )
- # define PYCXX_USING_HASH_MAP
- # endif
- #endif
-#endif
-
-#endif // __PyCXX_config_hh__
Modified: trunk/matplotlib/CXX/Exception.hxx
===================================================================
--- trunk/matplotlib/CXX/Exception.hxx 2010-01-16 19:20:03 UTC (rev 8083)
+++ trunk/matplotlib/CXX/Exception.hxx 2010-01-16 22:07:53 UTC (rev 8084)
@@ -34,216 +34,10 @@
// DAMAGE.
//
//-----------------------------------------------------------------------------
-
-#ifndef __CXX_Exception_h
-#define __CXX_Exception_h
-
#include "CXX/WrapPython.h"
-#include "CXX/Version.hxx"
-#include "CXX/Config.hxx"
-#include "CXX/IndirectPythonInterface.hxx"
-#include <string>
-#include <iostream>
-
-// This mimics the Python structure, in order to minimize confusion
-namespace Py
-{
- class ExtensionExceptionType;
-
- class Object;
-
- class Exception
- {
- public:
- Exception( ExtensionExceptionType &exception, const std::string& reason );
- Exception( ExtensionExceptionType &exception, Object &reason );
-
- explicit Exception ()
- {}
-
- Exception (const std::string& reason)
- {
- PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str());
- }
-
- Exception (PyObject* exception, const std::string& reason)
- {
- PyErr_SetString (exception, reason.c_str());
- }
-
- Exception (PyObject* exception, Object &reason);
-
- void clear() // clear the error
- // technically but not philosophically const
- {
- PyErr_Clear();
- }
- };
-
-
- // Abstract
- class StandardError: public Exception
- {
- protected:
- explicit StandardError()
- {}
- };
-
- class LookupError: public StandardError
- {
- protected:
- explicit LookupError()
- {}
- };
-
- class ArithmeticError: public StandardError
- {
- protected:
- explicit ArithmeticError()
- {}
- };
-
- class EnvironmentError: public StandardError
- {
- protected:
- explicit EnvironmentError()
- {}
- };
-
- // Concrete
-
- class TypeError: public StandardError
- {
- public:
- TypeError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_TypeError(),reason.c_str());
- }
- };
-
- class IndexError: public LookupError
- {
- public:
- IndexError (const std::string& reason)
- : LookupError()
- {
- PyErr_SetString (Py::_Exc_IndexError(), reason.c_str());
- }
- };
-
- class AttributeError: public StandardError
- {
- public:
- AttributeError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_AttributeError(), reason.c_str());
- }
- };
-
- class NameError: public StandardError
- {
- public:
- NameError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_NameError(), reason.c_str());
- }
- };
-
- class RuntimeError: public StandardError
- {
- public:
- RuntimeError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str());
- }
- };
-
- class SystemError: public StandardError
- {
- public:
- SystemError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_SystemError(),reason.c_str());
- }
- };
-
- class KeyError: public LookupError
- {
- public:
- KeyError (const std::string& reason)
- : LookupError()
- {
- PyErr_SetString (Py::_Exc_KeyError(),reason.c_str());
- }
- };
-
-
- class ValueError: public StandardError
- {
- public:
- ValueError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_ValueError(), reason.c_str());
- }
- };
-
- class OverflowError: public ArithmeticError
- {
- public:
- OverflowError (const std::string& reason)
- : ArithmeticError()
- {
- PyErr_SetString (Py::_Exc_OverflowError(), reason.c_str());
- }
- };
-
- class ZeroDivisionError: public ArithmeticError
- {
- public:
- ZeroDivisionError (const std::string& reason)
- : ArithmeticError()
- {
- PyErr_SetString (Py::_Exc_ZeroDivisionError(), reason.c_str());
- }
- };
-
- class FloatingPointError: public ArithmeticError
- {
- public:
- FloatingPointError (const std::string& reason)
- : ArithmeticError()
- {
- PyErr_SetString (Py::_Exc_FloatingPointError(), reason.c_str());
- }
- };
-
- class MemoryError: public StandardError
- {
- public:
- MemoryError (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_MemoryError(), reason.c_str());
- }
- };
-
- class SystemExit: public StandardError
- {
- public:
- SystemExit (const std::string& reason)
- : StandardError()
- {
- PyErr_SetString (Py::_Exc_SystemExit(),reason.c_str());
- }
- };
-
-}// Py
-
+#if PY_MAJOR_VERSION == 2
+#include "CXX/Python2/Exception.hxx"
+#else
+#include "CXX/Python3/Exception.hxx"
#endif
Modified: trunk/matplotlib/CXX/Extensions.hxx
===================================================================
--- trunk/matplotlib/CXX/Extensions.hxx 2010-01-16 19:20:03 UTC (rev 8083)
+++ trunk/matplotlib/CXX/Extensions.hxx 2010-01-16 22:07:53 UTC (rev 8084)
@@ -34,895 +34,10 @@
// DAMAGE.
//
//-----------------------------------------------------------------------------
-
-#ifndef __CXX_Extensions__h
-#define __CXX_Extensions__h
-
-
-#ifdef _MSC_VER
-// disable warning C4786: symbol greater than 255 character,
-// okay to ignore
-#pragma warning(disable: 4786)
-#endif
-
#include "CXX/WrapPython.h"
-#include "CXX/Version.hxx"
-#include "CXX/Config.hxx"
-#include "CXX/Objects.hxx"
-extern "C"
-{
- extern PyObject py_object_initializer;
-}
-
-#include <vector>
-
-// std::map / hash_map selection and declarations ----------------------------
-#if !defined( PYCXX_USING_HASH_MAP )
-
-#include <map>
-
+#if PY_MAJOR_VERSION == 2
+#include "CXX/Python2/Extensions.hxx"
#else
-
-#if defined( __GNUC__) && !defined( _STLPORT_VERSION )
- #include <ext/hash_map>
-#else
- #include <hash_map>
+#include "CXX/Python3/Extensions.hxx"
#endif
-#if defined( _STLPORT_VERSION )
- #define __PYCXX_HASHMAP_NAMESPACE std
- using namespace std;
-#elif defined ( _MSC_VER ) && !defined( __INTEL_COMPILER ) && !defined( __ICC ) && !defined( __ICL ) && !defined( __ECC )
- #define __PYCXX_HASHMAP_NAMESPACE stdext
- using namespace stdext;
-#elif defined( __INTEL_COMPILER ) || defined( __ICC ) || defined( __ICL ) || defined( __ECC )
- #define __PYCXX_HASHMAP_NAMESPACE stdext
- using namespace stdext;
-#elif defined( __GNUC__ )
- #define __PYCXX_HASHMAP_NAMESPACE __gnu_cxx
- using namespace __gnu_cxx;
-#else
- #define __PYCXX_HASHMAP_NAMESPACE std
- using namespace std;
-#endif
-
-class __pycxx_str_hash_func
-{
-public:
- enum
- {
- // parameters for hash table
- bucket_size = 4, // 0 < bucket_size
- min_buckets = 8 // min_buckets = 2 ^^ N, 0 < N
- };
-
- // http://www.azillionmonkeys.com/qed/hash.html
- size_t operator()( const std::string &str ) const
- {
- const unsigned char * data = reinterpret_cast<const unsigned char *>( str.c_str() );
- int len = (int)str.length();
- unsigned int hash = len;
- unsigned int tmp;
- int rem;
-
- if (len <= 0 || data == NULL)
- return 0;
-
- rem = len & 3;
- len >>= 2;
-
- /* Main loop */
- for (;len > 0; len--)
- {
- hash += (data[1] << 8) | data[0];
- tmp = (((data[3] << 8) | data[2]) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2*sizeof (unsigned short);
- hash += hash >> 11;
- }
-
- /* Handle end cases */
- switch (rem)
- {
- case 3: hash += (data[1] << 8) | data[0];
- hash ^= hash << 16;
- hash ^= data[sizeof (unsigned short)] << 18;
- hash += hash >> 11;
- break;
- case 2: hash += (data[1] << 8) | data[0];
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
- case 1: hash += *data;
- hash ^= hash << 10;
- hash += hash >> 1;
- }
-
- /* Force "avalanching" of final 127 bits */
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 4;
- hash += hash >> 17;
- hash ^= hash << 25;
- hash += hash >> 6;
-
- return hash;
- }
-
- bool operator()(const std::string &str_1, const std::string &str_2) const
- {
- // test if str_1 ordered before str_2
- return str_1 < str_2;
- }
-};
-#endif // PYCXX_USING_HASH_MAP
-// ----------------------------------------------------------------------
-
-namespace Py
-{
- class ExtensionModuleBase;
-
- // Make an Exception Type for use in raising custom exceptions
- class ExtensionExceptionType : public Object
- {
- public:
- ExtensionExceptionType();
- virtual ~ExtensionExceptionType();
-
- // call init to create the type
- void init( ExtensionModuleBase &module, const std::string& name, ExtensionExceptionType &parent );
- void init( ExtensionModuleBase &module, const std::string& name );
- };
-
-
- class MethodTable
- {
- public:
- MethodTable();
- virtual ~MethodTable();
-
- void add(const char* method_name, PyCFunction f, const char* doc="", int flag=1);
- PyMethodDef* table();
-
- protected:
- std::vector<PyMethodDef> t; // accumulator of PyMethodDef's
- PyMethodDef *mt; // Actual method table produced when full
-
- static PyMethodDef method (const char* method_name, PyCFunction f, int flags = 1, const char* doc="");
-
- private:
- //
- // prevent the compiler generating these unwanted functions
- //
- MethodTable(const MethodTable& m); //unimplemented
- void operator=(const MethodTable& m); //unimplemented
-
- }; // end class MethodTable
-
- extern "C"
- {
- typedef PyObject *(*method_varargs_call_handler_t)( PyObject *_self, PyObject *_args );
- typedef PyObject *(*method_keyword_call_handler_t)( PyObject *_self, PyObject *_args, PyObject *_dict );
- }
-
- template<class T>
- class MethodDefExt : public PyMethodDef
- {
- public:
- typedef Object (T::*method_varargs_function_t)( const Tuple &args );
- typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws );
-
- MethodDefExt
- (
- const char *_name,
- method_varargs_function_t _function,
- method_varargs_call_handler_t _handler,
- const char *_doc
- )
- {
- ext_meth_def.ml_name = const_cast<char *>(_name);
- ext_meth_def.ml_meth = _handler;
- ext_meth_def.ml_flags = METH_VARARGS;
- ext_meth_def.ml_doc = const_cast<char *>(_doc);
-
- ext_varargs_function = _function;
- ext_keyword_function = NULL;
- }
-
- MethodDefExt
- (
- const char *_name,
- method_keyword_function_t _function,
- method_keyword_call_handler_t _handler,
- const char *_doc
- )
- {
- ext_meth_def.ml_name = const_cast<char *>(_name);
- ext_meth_def.ml_meth = method_varargs_call_handler_t( _handler );
- ext_meth_def.ml_flags = METH_VARARGS|METH_KEYWORDS;
- ext_meth_def.ml_doc = const_cast<char *>(_doc);
-
- ext_varargs_function = NULL;
- ext_keyword_function = _function;
- }
-
- ~MethodDefExt()
- {}
-
- PyMethodDef ext_meth_def;
- method_varargs_function_t ext_varargs_function;
- method_keyword_function_t ext_keyword_function;
- };
-
- class ExtensionModuleBase
- {
- public:
- ExtensionModuleBase( const char *name );
- virtual ~ExtensionModuleBase();
-
- Module module(void) const; // only valid after initialize() has been called
- Dict moduleDictionary(void) const; // only valid after initialize() has been called
-
- virtual Object invoke_method_keyword( const std::string &_name, const Tuple &_args, const Dict &_keywords ) = 0;
- virtual Object invoke_method_varargs( const std::string &_name, const Tuple &_args ) = 0;
-
- const std::string &name() const;
- const std::string &fullName() const;
-
- protected:
- // Initialize the module
- void initialize( const char *module_doc );
-
- const std::string module_name;
- const std::string full_module_name;
- MethodTable method_table;
-
- private:
-
- //
- // prevent the compiler generating these unwanted functions
- //
- ExtensionModuleBase( const ExtensionModuleBase & ); //unimplemented
- void operator=( const ExtensionModuleBase & ); //unimplemented
-
- };
-
- extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords );
- extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args );
- extern "C" void do_not_dealloc( void * );
-
-
- template<TEMPLATE_TYPENAME T>
- class ExtensionModule : public ExtensionModuleBase
- {
- public:
- ExtensionModule( const char *name )
- : ExtensionModuleBase( name )
- {}
- virtual ~ExtensionModule()
- {}
-
- protected:
- typedef Object (T::*method_varargs_function_t)( const Tuple &args );
- typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws );
-
-#if defined( PYCXX_USING_HASH_MAP )
- typedef __PYCXX_HASHMAP_NAMESPACE::hash_map<std::string, MethodDefExt<T> *, __pycxx_str_hash_func> method_map_t;
-#else
- typedef std::map<std::string,MethodDefExt<T> *> method_map_t;
-#endif
-
- static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" )
- {
- method_map_t &mm = methods();
-
- MethodDefExt<T> *method_definition = new MethodDefExt<T>
- (
- name,
- function,
- method_varargs_call_handler,
- doc
- );
-
- mm[std::string( name )] = method_definition;
- }
-
- static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" )
- {
- method_map_t &mm = methods();
-
- MethodDefExt<T> *method_definition = new MethodDefExt<T>
- (
- name,
- function,
- method_keyword_call_handler,
- doc
- );
-
- mm[std::string( name )] = method_definition;
- }
-
- void initialize( const char *module_doc="" )
- {
- ExtensionModuleBase::initialize( module_doc );
- Dict dict( moduleDictionary() );
-
- //
- // put each of the methods into the modules dictionary
- // so that we get called back at the function in T.
- //
- method_map_t &mm = methods();
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
-
- for( i=mm.begin(); i != mm.end(); ++i )
- {
- MethodDefExt<T> *method_definition = (*i).second;
-
- static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
-
- Tuple args( 2 );
- args[0] = Object( self );
- args[1] = String( (*i).first );
-
- PyObject *func = PyCFunction_New
- (
- &method_definition->ext_meth_def,
- new_reference_to( args )
- );
-
- dict[ (*i).first ] = Object( func );
- }
- }
-
- protected: // Tom Malcolmson reports that derived classes need access to these
-
- static method_map_t &methods(void)
- {
- static method_map_t *map_of_methods = NULL;
- if( map_of_methods == NULL )
- map_of_methods = new method_map_t;
-
- return *map_of_methods;
- }
-
-
- // this invoke function must be called from within a try catch block
- virtual Object invoke_method_keyword( const std::string &name, const Tuple &args, const Dict &keywords )
- {
- method_map_t &mm = methods();
- MethodDefExt<T> *meth_def = mm[ name ];
- if( meth_def == NULL )
- {
- std::string error_msg( "CXX - cannot invoke keyword method named " );
- error_msg += name;
- throw RuntimeError( error_msg );
- }
-
- // cast up to the derived class
- T *self = static_cast<T *>(this);
-
- return (self->*meth_def->ext_keyword_function)( args, keywords );
- }
-
- // this invoke function must be called from within a try catch block
- virtual Object invoke_method_varargs( const std::string &name, const Tuple &args )
- {
- method_map_t &mm = methods();
- MethodDefExt<T> *meth_def = mm[ name ];
- if( meth_def == NULL )
- {
- std::string error_msg( "CXX - cannot invoke varargs method named " );
- error_msg += name;
- throw RuntimeError( error_msg );
- }
-
- // cast up to the derived class
- T *self = static_cast<T *>(this);
-
- return (self->*meth_def->ext_varargs_function)( args );
- }
-
- private:
- //
- // prevent the compiler generating these unwanted functions
- //
- ExtensionModule( const ExtensionModule<T> & ); //unimplemented
- void operator=( const ExtensionModule<T> & ); //unimplemented
- };
-
-
- class PythonType
- {
- public:
- // if you define one sequence method you must define
- // all of them except the assigns
-
- PythonType (size_t base_size, int itemsize, const char *default_name );
- virtual ~PythonType ();
-
- const char *getName () const;
- const char *getDoc () const;
-
- PyTypeObject* type_object () const;
- PythonType & name (const char* nam);
- PythonType & doc (const char* d);
- PythonType & dealloc(void (*f)(PyObject*));
-
- PythonType & supportPrint(void);
- PythonType & supportGetattr(void);
- PythonType & supportSetattr(void);
- PythonType & supportGetattro(void);
- PythonType & supportSetattro(void);
- PythonType & supportCompare(void);
-#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 1)
- PythonType & supportRichCompare(void);
-#endif
- PythonType & supportRepr(void);
- PythonType & supportStr(void);
- PythonType & supportHash(void);
- PythonType & supportCall(void);
- PythonType & supportIter(void);
-
- PythonType & supportSequenceType(void);
- PythonType & supportMappingType(void);
- PythonType & supportNumberType(void);
- PythonType & supportBufferType(void);
-
- protected:
- PyTypeObject *table;
- PySequenceMethods *sequence_table;
- PyMappingMethods *mapping_table;
- PyNumberMethods *number_table;
- PyBufferProcs *buffer_table;
-
- void init_sequence();
- void init_mapping();
- void init_number();
- void init_buffer();
-
- private:
- //
- // prevent the compiler generating these unwanted functions
- //
- PythonType (const PythonType& tb); // unimplemented
- void operator=(const PythonType& t); // unimplemented
-
- }; // end of PythonType
-
-
-
- // Class PythonExtension is what you inherit from to create
- // a new Python extension type. You give your class itself
- // as the template paramter.
-
- // There are two ways that extension objects can get destroyed.
- // 1. Their reference count goes to zero
- // 2. Someone does an explicit delete on a pointer.
- // In (1) the problem is to get the destructor called
- // We register a special deallocator in the Python type object
- // (see behaviors()) to do this.
- // In (2) there is no problem, the dtor gets called.
-
- // PythonExtension does not use the usual Python heap allocator,
- // instead using new/delete. We do the setting of the type object
- // and reference count, usually done by PyObject_New, in the
- // base class ctor.
-
- // This special deallocator does a delete on the pointer.
-
-
- class PythonExtensionBase : public PyObject
- {
- public:
- PythonExtensionBase();
- virtual ~PythonExtensionBase();
-
- public:
- virtual int print( FILE *, int );
- virtual Object getattr( const char * ) = 0;
- virtual int setattr( const char *, const Object & );
- virtual Object getattro( const Object & );
- virtual int setattro( const Object &, const Object & );
- virtual int compare( const Object & );
- virtual Object rich_compare( const Object &, int op );
- virtual Object repr();
- virtual Object str();
- virtual long hash();
- virtual Object call( const Object &, const Object & );
- virtual Object iter();
- virtual PyObject* iternext();
-
- // Sequence methods
- virtual int sequence_length();
- virtual Object sequence_concat( const Object & );
- virtual Object sequence_repeat( Py_ssize_t );
- virtual Object sequence_item( Py_ssize_t );
- virtual Object sequence_slice( Py_ssize_t, Py_ssize_t );
- virtual int sequence_ass_item( Py_ssize_t, const Object & );
- virtual int sequence_ass_slice( Py_ssize_t, Py_ssize_t, const Object & );
-
- // Mapping
- virtual int mapping_length();
- virtual Object mapping_subscript( const Object & );
- virtual int mapping_ass_subscript( const Object &, const Object & );
-
- // Number
- virtual int number_nonzero();
- virtual Object number_negative();
- virtual Object number_positive();
- virtual Object number_absolute();
- virtual Object number_invert();
- virtual Object number_int();
- virtual Object number_float();
- virtual Object number_long();
- virtual Object number_oct();
- virtual Object number_hex();
- virtual Object number_add( const Object & );
- virtual Object number_subtract( const Object & );
- virtual Object number_multiply( const Object & );
- virtual Object number_divide( const Object & );
- virtual Object number_remainder( const Object & );
- virtual Object number_divmod( const Object & );
- virtual Object number_lshift( const Object & );
- virtual Object number_rshift( const Object & );
- virtual Object number_and( const Object & );
- virtual Object number_xor( const Object & );
- virtual Object number_or( const Object & );
- virtual Object number_power( const Object &, const Object & );
-
- // Buffer
- virtual Py_ssize_t buffer_getreadbuffer( Py_ssize_t, void** );
- virtual Py_ssize_t buffer_getwritebuffer( Py_ssize_t, void** );
- virtual Py_ssize_t buffer_getsegcount( Py_ssize_t* );
-
- private:
- void missing_method( void );
- static PyObject *method_call_handler( PyObject *self, PyObject *args );
- };
-
- template<TEMPLATE_TYPENAME T>
- class PythonExtension: public PythonExtensionBase
- {
- public:
- static PyTypeObject* type_object()
- {
- return behaviors().type_object();
- }
-
- static int check( PyObject *p )
- {
- // is p like me?
- return p->ob_type == type_object();
- }
-
- static int check( const Object& ob )
- {
- return check( ob.ptr());
- }
-
-
- //
- // every object needs getattr implemented
- // to support methods
- //
- virtual Object getattr( const char *name )
- {
- return getattr_methods( name );
- }
-
- protected:
- explicit PythonExtension()
- : PythonExtensionBase()
- {
- #ifdef PyObject_INIT
- (void)PyObject_INIT( this, type_object() );
- #else
- ob_refcnt = 1;
- ob_type = type_object();
- #endif
-
- // every object must support getattr
- behaviors().supportGetattr();
- }
-
- virtual ~PythonExtension()
- {}
-
- static PythonType &behaviors()
- {
- static PythonType* p;
- if( p == NULL )
- {
-#if defined( _CPPRTTI ) || defined(__GNUG__)
- const char *default_name = (typeid ( T )).name();
-#else
- const char *default_name = "unknown";
-#endif
- p = new PythonType( sizeof( T ), 0, default_name );
- p->dealloc( extension_object_deallocator );
- }
-
- return *p;
- }
-
-
- typedef Object (T::*method_varargs_function_t)( const Tuple &args );
- typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws );
-
-#if defined( PYCXX_USING_HASH_MAP )
- typedef __PYCXX_HASHMAP_NAMESPACE::hash_map<std::string, MethodDefExt<T> *, __pycxx_str_hash_func> method_map_t;
-#else
- typedef std::map<std::string,MethodDefExt<T> *> method_map_t;
-#endif
-
- // support the default attributes, __name__, __doc__ and methods
- virtual Object getattr_default( const char *_name )
- {
- std::string name( _name );
-
- if( name == "__name__" && type_object()->tp_name != NULL )
- {
- return Py::String( type_object()->tp_name );
- }
- if( name == "__doc__" && type_object()->tp_doc != NULL )
- {
- return Py::String( type_object()->tp_doc );
- }
-
-// trying to fake out being a class for help()
-// else if( name == "__bases__" )
-// {
-// return Py::Tuple(0);
-// }
-// else if( name == "__module__" )
-// {
-// return Py::Nothing();
-// }
-// else if( name == "__dict__" )
-// {
-// return Py::Dict();
-// }
-
- return getattr_methods( _name );
- }
-
- // turn a name into function object
- virtual Object getattr_methods( const char *_name )
- {
- std::string name( _name );
-
- method_map_t &mm = methods();
-
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
-
- if( name == "__methods__" )
- {
- List methods;
-
- for( i = mm.begin(); i != mm.end(); ++i )
- methods.append( String( (*i).first ) );
-
- return methods;
- }
-
- // see if name exists and get entry with method
- i = mm.find( name );
- if( i == mm.end() )
- throw AttributeError( name );
-
- Tuple self( 2 );
-
- self[0] = Object( this );
- self[1] = String( name );
-
- MethodDefExt<T> *method_definition = i->second;
-
- PyObject *func = PyCFunction_New( &method_definition->ext_meth_def, self.ptr() );
-
- return Object(func, true);
- }
-
- static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" )
- {
- method_map_t &mm = methods();
-
- // check that all methods added are unique
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
- i = mm.find( name );
- if( i != mm.end() )
- throw AttributeError( name );
-
- MethodDefExt<T> *method_definition = new MethodDefExt<T>
- (
- name,
- function,
- method_varargs_call_handler,
- doc
- );
-
- mm[std::string( name )] = method_definition;
- }
-
- static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" )
- {
- method_map_t &mm = methods();
-
- // check that all methods added are unique
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
- i = mm.find( name );
- if( i != mm.end() )
- throw AttributeError( name );
-
- MethodDefExt<T> *method_definition = new MethodDefExt<T>
- (
- name,
- function,
- method_keyword_call_handler,
- doc
- );
-
- mm[std::string( name )] = method_definition;
- }
-
- private:
- static method_map_t &methods(void)
- {
- static method_map_t *map_of_methods = NULL;
- if( map_of_methods == NULL )
- map_of_methods = new method_map_t;
-
- return *map_of_methods;
- }
-
- static PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords )
- {
- try
- {
- Tuple self_and_name_tuple( _self_and_name_tuple );
-
- PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
- T *self = static_cast<T *>( self_in_cobject );
-
- String name( self_and_name_tuple[1] );
-
- method_map_t &mm = methods();
-
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
- i = mm.find( name );
- if( i == mm.end() )
- return 0;
-
- MethodDefExt<T> *meth_def = i->second;
-
- Tuple args( _args );
-
- // _keywords may be NULL so be careful about the way the dict is created
- Dict keywords;
- if( _keywords != NULL )
- keywords = Dict( _keywords );
-
- Object result( (self->*meth_def->ext_keyword_function)( args, keywords ) );
-
- return new_reference_to( result.ptr() );
- }
- catch( Exception & )
- {
- return 0;
- }
- }
-
- static PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args )
- {
- try
- {
- Tuple self_and_name_tuple( _self_and_name_tuple );
-
- PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
- T *self = static_cast<T *>( self_in_cobject );
-
- String name( self_and_name_tuple[1] );
-
- method_map_t &mm = methods();
-
- EXPLICIT_TYPENAME method_map_t::const_iterator i;
- i = mm.find( name );
- if( i == mm.end() )
- return 0;
-
- MethodDefExt<T> *meth_def = i->second;
-
- Tuple args( _args );
-
- Object result;
-
- // TMM: 7Jun'01 - Adding try & catch in case of STL debug-mode exceptions.
- #ifdef _STLP_DEBUG
- try
- {
- result = (self->*meth_def->ext_varargs_function)( args );
- }
- catch (std::__stl_debug_exception)
- {
- // throw cxx::RuntimeError( sErrMsg );
- throw cxx::RuntimeError( "Error message not set yet." );
- }
- #else
- result = (self->*meth_def->ext_varargs_function)( args );
- #endif // _STLP_DEBUG
-
- return new_reference_to( result.ptr() );
- }
- catch( Exception & )
- {
- return 0;
- }
- }
-
- static void extension_object_deallocator ( PyObject* t )
- {
- delete (T *)( t );
- }
-
- //
- // prevent the compiler generating these unwanted functions
- //
- explicit PythonExtension( const PythonExtension<T>& other );
- void operator=( const PythonExtension<T>& rhs );
- };
-
- //
- // ExtensionObject<T> is an Object that will accept only T's.
- //
- template<TEMPLATE_TYPENAME T>
- class ExtensionObject: public Object
- {
- public:
-
- explicit ExtensionObject ( PyObject *pyob )
- : Object( pyob )
- {
- validate();
- }
-
- ExtensionObject( const ExtensionObject<T>& other )
- : Object( *other )
- {
- validate();
- }
-
- ExtensionObject( const Object& other )
- : Object( *other )
- {
- validate();
- }
-
- ExtensionObject& operator= ( const Object& rhs )
- {
- return (*this = *rhs );
- }
-
- ExtensionObject& operator= ( PyObject* rhsp )
- {
- if( ptr() == rhsp )
- return *this;
- set( rhsp );
- return *this;
- }
-
- virtual bool accepts ( PyObject *pyob ) const
- {
- return ( pyob && T::check( pyob ));
- }
-
- //
- // Obtain a pointer to the PythonExtension object
- //
- T *extensionObject(void)
- {
- return static_cast<T *>( ptr() );
- }
- };
-
-} // Namespace Py
-// End of CXX_Extensions.h
-#endif
Modified: trunk/matplotlib/CXX/IndirectPythonInterface.cxx
===================================================================
--- trunk/matplotlib/CXX/IndirectPythonInterface.cxx 2010-01-16 19:20:03 UTC (rev 8083)
+++ trunk/matplotlib/CXX/IndirectPythonInterface.cxx 2010-01-16 22:07:53 UTC (rev 8084)
@@ -34,564 +34,10 @@
// DAMAGE.
//
//-----------------------------------------------------------------------------
+#include "CXX/WrapPython.h"
-#include "CXX/IndirectPythonInterface.hxx"
-
-namespace Py
-{
-bool _Buffer_Check( PyObject *op ) { return (op)->ob_type == _Buffer_Type(); }
-bool _CFunction_Check( PyObject *op ) { return (op)->ob_type == _CFunction_Type(); }
-bool _Class_Check( PyObject *op ) { return (op)->ob_type == _Class_Type(); }
-bool _CObject_Check( PyObject *op ) { return (op)->ob_type == _CObject_Type(); }
-bool _Complex_Check( PyObject *op ) { return (op)->ob_type == _Complex_Type(); }
-bool _Dict_Check( PyObject *op ) { return (op)->ob_type == _Dict_Type(); }
-bool _File_Check( PyObject *op ) { return (op)->ob_type == _File_Type(); }
-bool _Float_Check( PyObject *op ) { return (op)->ob_type == _Float_Type(); }
-bool _Function_Check( PyObject *op ) { return (op)->ob_type == _Function_Type(); }
-bool _Instance_Check( PyObject *op ) { return (op)->ob_type == _Instance_Type(); }
-bool _Boolean_Check( PyObject *op ) { return (op)->ob_type == _Bool_Type(); }
-bool _Int_Check( PyObject *op ) { return (op)->ob_type == _Int_Type(); }
-bool _List_Check( PyObject *o ) { return o->ob_type == _List_Type(); }
-bool _Long_Check( PyObject *op ) { return (op)->ob_type == _Long_Type(); }
-bool _Method_Check( PyObject *op ) { return (op)->ob_type == _Method_Type(); }
-bool _Module_Check( PyObject *op ) { return (op)->ob_type == _Module_Type(); }
-bool _Range_Check( PyObject *op ) { return (op)->ob_type == _Range_Type(); }
-bool _Slice_Check( PyObject *op ) { return (op)->ob_type == _Slice_Type(); }
-bool _String_Check( PyObject *o ) { return o->ob_type == _String_Type(); }
-bool _TraceBack_Check( PyObject *v ) { return (v)->ob_type == _TraceBack_Type(); }
-bool _Tuple_Check( PyObject *op ) { return (op)->ob_type == _Tuple_Type(); }
-bool _Type_Check( PyObject *op ) { return (op)->ob_type == _Type_Type(); }
-
-#if PY_MAJOR_VERSION >= 2
-bool _Unicode_Check( PyObject *op ) { return (op)->ob_type == _Unicode_Type(); }
-#endif
-
-
-
-#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
-
-#if defined(MS_WINDOWS)
-#include <windows.h>
-
-
-static HMODULE python_dll;
-
-static PyObject *ptr__Exc_ArithmeticError = NULL;
-static PyObject *ptr__Exc_AssertionError = NULL;
-static PyObject *ptr__Exc_AttributeError = NULL;
-static PyObject *ptr__Exc_EnvironmentError = NULL;
-static PyObject *ptr__Exc_EOFError = NULL;
-static PyObject *ptr__Exc_Exception = NULL;
-static PyObject *ptr__Exc_FloatingPointError = NULL;
-static PyObject *ptr__Exc_ImportError = NULL;
-static PyObject *ptr__Exc_IndexError = NULL;
-static PyObject *ptr__Exc_IOError = NULL;
-static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
-static PyObject *ptr__Exc_KeyError = NULL;
-static PyObject *ptr__Exc_LookupError = NULL;
-static PyObject *ptr__Exc_MemoryError = NULL;
-static PyObject *ptr__Exc_MemoryErrorInst = NULL;
-static PyObject *ptr__Exc_NameError = NULL;
-static PyObject *ptr__Exc_NotImplementedError = NULL;
-static PyObject *ptr__Exc_OSError = NULL;
-static PyObject *ptr__Exc_OverflowError = NULL;
-static PyObject *ptr__Exc_RuntimeError = NULL;
-static PyObject *ptr__Exc_StandardError = NULL;
-static PyObject *ptr__Exc_SyntaxError = NULL;
-static PyObject *ptr__Exc_SystemError = NULL;
-static PyObject *ptr__Exc_SystemExit = NULL;
-static PyObject *ptr__Exc_TypeError = NULL;
-static PyObject *ptr__Exc_ValueError = NULL;
-static PyObject *ptr__Exc_ZeroDivisionError = NULL;
-
-#ifdef MS_WINDOWS
-static PyObject *ptr__Exc_WindowsError = NULL;
-#endif
-
-#if PY_MAJOR_VERSION >= 2
-static PyObject *ptr__Exc_IndentationError = NULL;
-static PyObject *ptr__Exc_TabError = NULL;
-static PyObject *ptr__Exc_UnboundLocalError = NULL;
-static PyObject *ptr__Exc_UnicodeError = NULL;
-#endif
-
-static PyObject *ptr__PyNone = NULL;
-
-static PyObject *ptr__PyFalse = NULL;
-static PyObject *ptr__PyTrue = NULL;
-
-static PyTypeObject *ptr__Buffer_Type = NULL;
-static PyTypeObject *ptr__CFunction_Type = NULL;
-static PyTypeObject *ptr__Class_Type = NULL;
-static PyTypeObject *ptr__CObject_Type = NULL;
-static PyTypeObject *ptr__Complex_Type = NULL;
-static PyTypeObject *ptr__Dict_Type = NULL;
-static PyTypeObject *ptr__File_Type = NULL;
-static PyTypeObject *ptr__Float_Type = NULL;
-static PyTypeObject *ptr__Function_Type = NULL;
-static PyTypeObject *ptr__Instance_Type = NULL;
-static PyTypeObject *ptr__Int_Type = NULL;
-static PyTypeObject *ptr__List_Type = NULL;
-static PyTypeObject *ptr__Long_Type = NULL;
-static PyTypeObject *ptr__Method_Type = NULL;
-static PyTypeObject *ptr__Module_Type = NULL;
-static PyTypeObject *ptr__Range_Type = NULL;
-static PyTypeObject *ptr__Slice_Type = NULL;
-static PyTypeObject *ptr__String_Type = NULL;
-static PyTypeObject *ptr__TraceBack_Type = NULL;
-static PyTypeObject *ptr__Tuple_Type = NULL;
-static PyTypeObject *ptr__Type_Type = NULL;
-
-#if PY_MAJOR_VERSION >= 2
-static PyTypeObject *ptr__Unicode_Type = NULL;
-#endif
-
-static int *ptr_Py_DebugFlag = NULL;
-static int *ptr_Py_InteractiveFlag = NULL;
-static int *ptr_Py_OptimizeFlag = NULL;
-static int *ptr_Py_NoSiteFlag = NULL;
-static int *ptr_Py_TabcheckFlag = NULL;
-static int *ptr_Py_VerboseFlag = NULL;
-
-#if PY_MAJOR_VERSION >= 2
-static int *ptr_Py_UnicodeFlag = NULL;
-#endif
-
-static char **ptr__Py_PackageContext = NULL;
-
-#ifdef Py_REF_DEBUG
-int *ptr_Py_RefTotal;
-#endif
-
-
-//--------------------------------------------------------------------------------
-class GetAddressException
-{
-public:
- GetAddressException( const char *_name )
- : name( _name )
- {}
- virtual ~GetAddressException() {}
- const char *name;
-};
-
-
-//--------------------------------------------------------------------------------
-static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyObject **)addr;
-}
-
-static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyObject *)addr;
-}
-
-static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyTypeObject **)addr;
-}
-
-static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyTypeObject *)addr;
-}
-
-static int *GetInt_as_IntPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (int *)addr;
-}
-
-static char **GetCharPointer_as_CharPointerPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (char **)addr;
-}
-
-
-#ifdef _DEBUG
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
+#if PY_MAJOR_VERSION == 2
+#include "Python2/IndirectPythonInterface.cxx"
#else
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
+#include "Python3/IndirectPythonInterface.cxx"
#endif
-
-//--------------------------------------------------------------------------------
-bool InitialisePythonIndirectInterface()
-{
- char python_dll_name[sizeof(python_dll_name_format)];
-
- sprintf( python_dll_name, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
-
- python_dll = LoadLibrary( python_dll_name );
- if( python_dll == NULL )
- return false;
-
- try
-{
-#ifdef Py_REF_DEBUG
- ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
-#endif
- ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
- ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
- ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
- ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
- ptr_Py_TabcheckFlag = GetInt_as_IntPointer( "Py_TabcheckFlag" );
- ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
-#if PY_MAJOR_VERSION >= 2
- ptr_Py_UnicodeFlag = GetInt_as_IntPointer( "Py_UnicodeFlag" );
-#endif
- ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
-
- ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
- ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
- ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
- ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
- ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
- ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
- ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
- ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
- ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
- ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
- ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
- ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
- ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
- ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
- ptr__Exc_MemoryErrorInst = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryErrorInst" );
- ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
- ptr__Exc_NotImplementedError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
- ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
- ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
- ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
- ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
- ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
- ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
- ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
- ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
- ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
-#ifdef MS_WINDOWS
- ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
-#endif
- ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
-
-#if PY_MAJOR_VERSION >= 2
- ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
- ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
- ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
- ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
-#endif
- ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
-
- ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
- ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
-
- ptr__Buffer_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBuffer_Type" );
- ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
- ptr__Class_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyClass_Type" );
- ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
- ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
- ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
- ptr__File_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFile_Type" );
- ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
- ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
- ptr__Instance_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInstance_Type" );
- ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
- ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
- ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
- ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
- ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
- ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
- ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
- ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
- ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
- ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
- ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
-
-#if PY_MAJOR_VERSION >= 2
- ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
-#endif
-}
- catch( GetAddressException &e )
- {
- OutputDebugString( python_dll_name );
- OutputDebugString( " does not contain symbol ");
- OutputDebugString( e.name );
- OutputDebugString( "\n" );
-
- return false;
- }
-
- return true;
-}
-
-//
-// Wrap variables as function calls
-//
-PyObject * _Exc_ArithmeticError(){ return ptr__Exc_ArithmeticError; }
-PyObject * _Exc_AssertionError(){ return ptr__Exc_AssertionError; }
-PyObject * _Exc_AttributeError(){ return ptr__Exc_AttributeError; }
-PyObject * _Exc_EnvironmentError(){ return ptr__Exc_EnvironmentError; }
-PyObject * _Exc_EOFError() { return ptr__Exc_EOFError; }
-PyObject * _Exc_Exception() { return ptr__Exc_Exception; }
-PyObject * _Exc_FloatingPointError(){ return ptr__Exc_FloatingPointError; }
-PyObject * _Exc_ImportError() { return ptr__Exc_ImportError; }
-PyObject * _Exc_IndexError() { return ptr__Exc_IndexError; }
-PyObject * _Exc_IOError() { return ptr__Exc_IOError; }
-PyObject * _Exc_KeyboardInterrupt(){ return ptr__Exc_KeyboardInterrupt; }
-PyObject * _Exc_KeyError() { return ptr__Exc_KeyError; }
-PyObject * _Exc_LookupError() { return ptr__Exc_LookupError; }
-PyObject * _Exc_MemoryError() { return ptr__Exc_MemoryError; }
-PyObject * _Exc_MemoryErrorInst(){ return ptr__Exc_MemoryErrorInst; }
-PyObject * _Exc_NameError() { return ptr__Exc_NameError; }
-PyObject * _Exc_NotImplementedError(){ return ptr__Exc_NotImplementedError; }
-PyObject * _Exc_OSError() { return ptr__Exc_OSError; }
-PyObject * _Exc_OverflowError() { return ptr__Exc_OverflowError; }
-PyObject * _Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
-PyObject * _Exc_StandardError() { return ptr__Exc_StandardError; }
-PyObject * _Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
-PyObject * _Exc_SystemError() { return ptr__Exc_SystemError; }
-PyObject * _Exc_SystemExit() { return ptr__Exc_SystemExit; }
-PyObject * _Exc_TypeError() { return ptr__Exc_TypeError; }
-PyObject * _Exc_ValueError() { return ptr__Exc_ValueError; }
-#ifdef MS_WINDOWS
-PyObject * _Exc_WindowsError() { return ptr__Exc_WindowsError; }
-#endif
-PyObject * _Exc_ZeroDivisionError(){ return ptr__Exc_ZeroDivisionError; }
-
-#if PY_MAJOR_VERSION >= 2
-PyObject * _Exc_IndentationError(){ return ptr__Exc_IndentationError; }
-PyObject * _Exc_TabError() { return ptr__Exc_TabError; }
-PyObject * _Exc_UnboundLocalError(){ return ptr__Exc_UnboundLocalError; }
-PyObject * _Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
-#endif
-
-//
-// wrap items in Object.h
-//
-PyObject * _None() { return ptr__PyNone; }
-
-PyObject * _False() { return ptr__PyFalse; }
-PyObject * _True() { return ptr__PyTrue; }
-
-PyTypeObject * _Buffer_Type() { return ptr__Buffer_Type; }
-PyTypeObject * _CFunction_Type(){ return ptr__CFunction_Type; }
-PyTypeObject * _Class_Type() { return ptr__Class_Type; }
-PyTypeObject * _CObject_Type() { return ptr__CObject_Type; }
-PyTypeObject * _Complex_Type() { return ptr__Complex_Type; }
-PyTypeObject * _Dict_Type() { return ptr__Dict_Type; }
-PyTypeObject * _File_Type() { return ptr__File_Type; }
-PyTypeObject * _Float_Type() { return ptr__Float_Type; }
-PyTypeObject * _Function_Type() { return ptr__Function_Type; }
-PyTypeObject * _Instance_Type() { return ptr__Instance_Type; }
-PyTypeObject * _Bool_Type() { return ptr__Bool_Type; }
-PyTypeObject * _Int_Type() { return ptr__Int_Type; }
-PyTypeObject * _List_Type() { return ptr__List_Type; }
-PyTypeObject * _Long_Type() { return ptr__Long_Type; }
-PyTypeObject * _Method_Type() { return ptr__Method_Type; }
-PyTypeObject * _Module_Type() { return ptr__Module_Type; }
-PyTypeObject * _Range_Type() { return ptr__Range_Type; }
-PyTypeObject * _Slice_Type() { return ptr__Slice_Type; }
-PyTypeObject * _String_Type() { return ptr__String_Type; }
-PyTypeObject * _TraceBack_Type(){ return ptr__TraceBack_Type; }
-PyTypeObject * _Tuple_Type() { return ptr__Tuple_Type; }
-PyTypeObject * _Type_Type() { return ptr__Type_Type; }
-
-#if PY_MAJOR_VERSION >= 2
-PyTypeObject * _Unicode_Type() { return ptr__Unicode_Type; }
-#endif
-
-char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
-
-
-//
-// wrap the Python Flag variables
-//
-int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
-int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
-int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
-int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
-int &_Py_TabcheckFlag() { return *ptr_Py_TabcheckFlag; }
-int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
-#if PY_MAJOR_VERSION >= 2
-int &_Py_UnicodeFlag() { return *ptr_Py_UnicodeFlag; }
-#endif
-
-void _XINCREF( PyObject *op )
-{
- // This function must match the contents of Py_XINCREF(op)
- if( op == NULL )
- return;
-
-#ifdef Py_REF_DEBUG
- (*ptr_Py_RefTotal)++;
-#endif
- (op)->ob_refcnt++;
-
-}
-
-void _XDECREF( PyObject *op )
-{
- // This function must match the contents of Py_XDECREF(op);
- if( op == NULL )
- return;
-
-#ifdef P...
[truncated message content] |