Commit d350f27d authored by Pino Toscano's avatar Pino Toscano

python: bump PyCXX to 7.1.0

Bump the embedded copy of PyCXX to 7.1.0, using only the Python2 sources
with a layout that matches the upstream sources (and thus it is easier
to build the sources with no changes).

Adapt krosspython to the new PyCXX:
- adjust the paths to sources, and to includes to the new layout of the
  files
- build the new cxx_exceptions.cxx
- build with -DPYCXX_PYTHON_2TO3 to use all the compatibility functions
  not available in Python 3
- build the C sources as C99, as they use C99 features
- explicitly use PyCxx_ssize_t as type for a couple of methods, instead
  of 'int' used by old versions
- unambiguate one Py::MethodDefExt constructor call
parent d837a8c0
project(KROSSPYTHON)
include_directories(${PYTHON2_INCLUDE_DIRS})
include_directories(${PYTHON2_INCLUDE_DIRS} cxx)
kde_enable_exceptions()
add_definitions(-DPYCXX_PYTHON_2TO3)
########### next target ###############
set(libkrosspythoncxx_SRCS
cxx/cxxsupport.cxx
cxx/cxx_extensions.cxx
cxx/cxxextensions.c
cxx/IndirectPythonInterface.cxx
cxx/Src/cxxsupport.cxx
cxx/Src/cxx_extensions.cxx
cxx/Src/cxxextensions.c
cxx/Src/IndirectPythonInterface.cxx
cxx/Src/cxx_exceptions.cxx
)
########### next target ###############
......@@ -25,6 +28,8 @@ set(krosspython_PART_SRCS ${libkrosspythoncxx_SRCS}
)
add_library(krosspython MODULE ${krosspython_PART_SRCS})
# the C sources use C99 features
set_property(TARGET krosspython PROPERTY C_STANDARD 11)
# -ldl seems to be needed (on Linux at least).
# see http://lists.kde.org/?l=koffice-devel&m=116333261328694&w=2
......
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if defined( PYCXX_6_2_COMPATIBILITY )
typedef int PyCxx_ssize_t;
#else
typedef Py_ssize_t PyCxx_ssize_t;
#endif
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/Config.hxx"
#else
#include "CXX/Python3/Config.hxx"
#endif
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/CxxDebug.hxx"
#else
#include "CXX/Python3/CxxDebug.hxx"
#endif
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/Exception.hxx"
#else
#include "CXX/Python3/Exception.hxx"
#endif
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/Extensions.hxx"
#else
#include "CXX/Python3/Extensions.hxx"
#endif
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/IndirectPythonInterface.hxx"
#else
#include "CXX/Python3/IndirectPythonInterface.hxx"
#endif
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "CXX/Python2/Objects.hxx"
#else
#include "CXX/Python3/Objects.hxx"
#endif
//
// CxxDebug.hxx
//
// Copyright (c) 2008 Barry A. Scott
//
#ifndef __CXX_Debug_hxx
#define __CXX_Debug_hxx
//
// Functions useful when debugging PyCXX
//
#ifdef PYCXX_DEBUG
extern void bpt();
extern void printRefCount( PyObject *obj );
#endif
#endif
......@@ -38,10 +38,11 @@
#ifndef __CXX_Exception_h
#define __CXX_Exception_h
#include "WrapPython.h"
#include "Version.hxx"
#include "Config.hxx"
#include "IndirectPythonInterface.hxx"
#include "CXX/WrapPython.h"
#include "CXX/Version.hxx"
#include "CXX/Python2/Config.hxx"
#include "CXX/Python2/CxxDebug.hxx"
#include "CXX/Python2/IndirectPythonInterface.hxx"
#include <string>
#include <iostream>
......@@ -53,196 +54,116 @@ namespace Py
class Object;
class Exception
class BaseException
{
public:
Exception( ExtensionExceptionType &exception, const std::string& reason );
Exception( ExtensionExceptionType &exception, Object &reason );
BaseException( ExtensionExceptionType &exception, const std::string &reason );
BaseException( ExtensionExceptionType &exception, Object &reason );
BaseException( PyObject *exception, Object &reason );
BaseException( PyObject *exception, const std::string &reason );
explicit BaseException();
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();
}
void clear(); // clear the error
// is the exception this specific exception 'exc'
bool matches( ExtensionExceptionType &exc );
};
// Abstract
class StandardError: public Exception
#if defined( PYCXX_6_2_COMPATIBILITY )
class Exception : public BaseException
{
protected:
explicit StandardError()
public:
Exception( ExtensionExceptionType &exception, const std::string &reason )
: BaseException( exception, reason )
{}
};
class LookupError: public StandardError
{
protected:
explicit LookupError()
Exception( ExtensionExceptionType &exception, Object &reason )
: BaseException( exception, reason )
{}
};
class ArithmeticError: public StandardError
{
protected:
explicit ArithmeticError()
Exception( PyObject *exception, Object &reason )
: BaseException ( exception, reason )
{}
};
class EnvironmentError: public StandardError
{
protected:
explicit EnvironmentError()
Exception( PyObject *exception, const std::string &reason )
: BaseException( exception, reason )
{}
explicit Exception()
: BaseException()
{}
};
// 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());
}
};
#endif
// for user defined exceptions to be made know to pycxx
typedef void (*throw_exception_func_t)( void );
void addPythonException( ExtensionExceptionType &py_exc_type, throw_exception_func_t throw_func );
#define PYCXX_STANDARD_EXCEPTION( eclass, bclass ) \
class eclass : public bclass \
{ \
public: \
eclass() {} \
eclass( const char *reason ) { PyErr_SetString( _Exc_##eclass(), reason ); } \
eclass( const std::string &reason ) { PyErr_SetString( _Exc_##eclass(), reason.c_str() ); } \
~eclass() {} \
\
static void throwFunc() { throw eclass(); } \
static PyObject *exceptionType() { return _Exc_##eclass(); } \
}; \
#include <CXX/Python2/cxx_standard_exceptions.hxx>
#undef PYCXX_STANDARD_EXCEPTION
#define PYCXX_USER_EXCEPTION_STR_ARG( uclass ) \
class uclass : public Py::BaseException \
{ \
public: \
uclass( const std::string &reason ) \
: Py::BaseException( m_error, reason ) \
{ } \
~uclass() {} \
static void init( Py::ExtensionModuleBase &module ) \
{ \
m_error.init( module, #uclass ); \
Py::addPythonException( m_error, throwFunc ); \
Py::Dict d( module.moduleDictionary() ); \
d[#uclass] = m_error; \
} \
private: \
uclass() : Py::BaseException() {} \
static void throwFunc() \
{ \
throw uclass(); \
} \
static Py::ExtensionExceptionType m_error; \
}; \
Py::ExtensionExceptionType uclass::m_error;
#define PYCXX_USER_EXCEPTION_NO_ARG( uclass ) \
class uclass : public Py::BaseException \
{ \
public: \
uclass() \
: Py::BaseException() \
{ } \
~uclass() {} \
static void init( Py::ExtensionModuleBase &module ) \
{ \
m_error.init( module, #uclass ); \
Py::addPythonException( m_error, throwFunc ); \
Py::Dict d( module.moduleDictionary() ); \
d[#uclass] = m_error; \
} \
private: \
static void throwFunc() \
{ \
throw uclass(); \
} \
static Py::ExtensionExceptionType m_error; \
}; \
Py::ExtensionExceptionType uclass::m_error;
}// Py
......
//-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#ifndef __CXX_ExtensionModule__h
#define __CXX_ExtensionModule__h
namespace Py
{
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_noargs( void *method_def ) = 0;
virtual Object invoke_method_keyword( void *method_def, const Tuple &_args, const Dict &_keywords ) = 0;
virtual Object invoke_method_varargs( void *method_def, const Tuple &_args ) = 0;
const std::string &name() const;
const std::string &fullName() const;
// what is returned from PyInit_<module> function
Object moduleObject( void ) const;
protected:
// Initialize the module
void initialize( const char *module_doc );
const std::string m_module_name;
const std::string m_full_module_name;
MethodTable m_method_table;
PyObject *m_module;
private:
//
// prevent the compiler generating these unwanted functions
//
ExtensionModuleBase( const ExtensionModuleBase & ); //unimplemented
void operator=( const ExtensionModuleBase & ); //unimplemented
};
// Note: Python calls noargs as varargs buts args==NULL
extern "C" PyObject *method_noargs_call_handler( PyObject *_self_and_name_tuple, PyObject * );
extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args );
extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords );
extern "C" void do_not_dealloc( void * );