| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef __CXX_Extensions__h |
| | #define __CXX_Extensions__h |
| |
|
| |
|
| | #ifdef _MSC_VER |
| | |
| | |
| | #pragma warning( disable: 4786 ) |
| | #endif |
| |
|
| | #include "CXX/WrapPython.h" |
| | #include "CXX/Version.hxx" |
| | #include "CXX/Python3/Config.hxx" |
| | #include "CXX/Python3/CxxDebug.hxx" |
| | #include "CXX/Python3/Objects.hxx" |
| |
|
| | extern "C" { extern PyObject py_object_initializer; } |
| |
|
| | #include <vector> |
| | #include <map> |
| |
|
| | |
| |
|
| | namespace Py |
| | { |
| | class ExtensionModuleBase; |
| |
|
| | |
| | class PYCXX_EXPORT ExtensionExceptionType : public Object |
| | { |
| | public: |
| | ExtensionExceptionType(); |
| | virtual ~ExtensionExceptionType(); |
| |
|
| | |
| | void init( ExtensionModuleBase &module, const std::string &name, ExtensionExceptionType &parent ); |
| | void init( ExtensionModuleBase &module, const std::string &name ); |
| | }; |
| |
|
| | class PYCXX_EXPORT 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; |
| | PyMethodDef *mt; |
| |
|
| | static PyMethodDef method( const char* method_name, PyCFunction f, int flags=1, const char* doc="" ); |
| |
|
| | private: |
| | |
| | |
| | |
| | MethodTable( const MethodTable &m ); |
| | void operator=( const MethodTable &m ); |
| |
|
| | }; |
| |
|
| | |
| | extern "C" typedef PyObject *(*method_noargs_call_handler_t)( PyObject *_self, PyObject * ); |
| | extern "C" typedef PyObject *(*method_varargs_call_handler_t)( PyObject *_self, PyObject *_args ); |
| | extern "C" typedef PyObject *(*method_keyword_call_handler_t)( PyObject *_self, PyObject *_args, PyObject *_dict ); |
| |
|
| | template<class T> |
| | class MethodDefExt |
| | { |
| | public: |
| | typedef Object (T::*method_noargs_function_t)(); |
| | 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_noargs_function_t _function, |
| | method_noargs_call_handler_t _handler, |
| | const char *_doc |
| | ) |
| | { |
| | ext_meth_def.ml_name = const_cast<char *>( _name ); |
| | ext_meth_def.ml_meth = reinterpret_cast<method_varargs_call_handler_t>( _handler ); |
| | ext_meth_def.ml_flags = METH_NOARGS; |
| | ext_meth_def.ml_doc = const_cast<char *>( _doc ); |
| |
|
| | ext_noargs_function = _function; |
| | ext_varargs_function = NULL; |
| | ext_keyword_function = NULL; |
| | } |
| |
|
| | |
| | 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 = reinterpret_cast<method_varargs_call_handler_t>( _handler ); |
| | ext_meth_def.ml_flags = METH_VARARGS; |
| | ext_meth_def.ml_doc = const_cast<char *>( _doc ); |
| |
|
| | ext_noargs_function = NULL; |
| | 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 = reinterpret_cast<method_varargs_call_handler_t>(reinterpret_cast<void (*) (void)>(_handler)); |
| | ext_meth_def.ml_flags = METH_VARARGS|METH_KEYWORDS; |
| | ext_meth_def.ml_doc = const_cast<char *>( _doc ); |
| |
|
| | ext_noargs_function = NULL; |
| | ext_varargs_function = NULL; |
| | ext_keyword_function = _function; |
| | } |
| |
|
| | ~MethodDefExt() |
| | {} |
| |
|
| | PyMethodDef ext_meth_def; |
| | method_noargs_function_t ext_noargs_function; |
| | method_varargs_function_t ext_varargs_function; |
| | method_keyword_function_t ext_keyword_function; |
| | Object py_method; |
| | }; |
| | } |
| |
|
| | #include "CXX/Python3/ExtensionModule.hxx" |
| | #include "CXX/Python3/PythonType.hxx" |
| | #include "CXX/Python3/ExtensionTypeBase.hxx" |
| | #include "CXX/Python3/ExtensionOldType.hxx" |
| | #include "CXX/Python3/ExtensionType.hxx" |
| |
|
| | |
| | #endif |
| |
|