Skip to content

Commit

Permalink
Upgraded PyCXX to version 6.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Sep 24, 2014
1 parent 16e8b0e commit ad3908c
Show file tree
Hide file tree
Showing 31 changed files with 8,477 additions and 912 deletions.
520 changes: 517 additions & 3 deletions src/CXX/IndirectPythonInterface.cxx

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions src/CXX/Python2/Config.hxx
Expand Up @@ -114,19 +114,5 @@
#if PY_MAJOR_VERSION < 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5)
typedef int Py_ssize_t;
#endif

// export macro
#if defined( _MSC_VER )
# pragma warning( disable : 4251 )
#endif
#if defined( _MSC_VER ) || defined( __MINGW32__ )
# ifdef PYCXX_DLL
# define PYCXX_EXPORT __declspec(dllexport)
# else
# define PYCXX_EXPORT __declspec(dllimport)
# endif
#else
# define PYCXX_EXPORT
#endif

#endif // __PyCXX_config_hh__
46 changes: 28 additions & 18 deletions src/CXX/Python2/Exception.hxx
Expand Up @@ -53,7 +53,7 @@ namespace Py

class Object;

class PYCXX_EXPORT Exception
class Exception
{
public:
Exception( ExtensionExceptionType &exception, const std::string& reason );
Expand Down Expand Up @@ -83,28 +83,28 @@ namespace Py


// Abstract
class PYCXX_EXPORT StandardError: public Exception
class StandardError: public Exception
{
protected:
explicit StandardError()
{}
};

class PYCXX_EXPORT LookupError: public StandardError
class LookupError: public StandardError
{
protected:
explicit LookupError()
{}
};

class PYCXX_EXPORT ArithmeticError: public StandardError
class ArithmeticError: public StandardError
{
protected:
explicit ArithmeticError()
{}
};

class PYCXX_EXPORT EnvironmentError: public StandardError
class EnvironmentError: public StandardError
{
protected:
explicit EnvironmentError()
Expand All @@ -113,7 +113,7 @@ namespace Py

// Concrete

class PYCXX_EXPORT TypeError: public StandardError
class TypeError: public StandardError
{
public:
TypeError (const std::string& reason)
Expand All @@ -123,7 +123,7 @@ namespace Py
}
};

class PYCXX_EXPORT IndexError: public LookupError
class IndexError: public LookupError
{
public:
IndexError (const std::string& reason)
Expand All @@ -133,7 +133,7 @@ namespace Py
}
};

class PYCXX_EXPORT AttributeError: public StandardError
class AttributeError: public StandardError
{
public:
AttributeError (const std::string& reason)
Expand All @@ -143,7 +143,7 @@ namespace Py
}
};

class PYCXX_EXPORT NameError: public StandardError
class NameError: public StandardError
{
public:
NameError (const std::string& reason)
Expand All @@ -153,7 +153,7 @@ namespace Py
}
};

class PYCXX_EXPORT RuntimeError: public StandardError
class RuntimeError: public StandardError
{
public:
RuntimeError (const std::string& reason)
Expand All @@ -163,7 +163,17 @@ namespace Py
}
};

class PYCXX_EXPORT SystemError: public StandardError
class NotImplementedError: public StandardError
{
public:
NotImplementedError (const std::string& reason)
: StandardError()
{
PyErr_SetString (Py::_Exc_NotImplementedError(), reason.c_str());
}
};

class SystemError: public StandardError
{
public:
SystemError (const std::string& reason)
Expand All @@ -173,7 +183,7 @@ namespace Py
}
};

class PYCXX_EXPORT KeyError: public LookupError
class KeyError: public LookupError
{
public:
KeyError (const std::string& reason)
Expand All @@ -184,7 +194,7 @@ namespace Py
};


class PYCXX_EXPORT ValueError: public StandardError
class ValueError: public StandardError
{
public:
ValueError (const std::string& reason)
Expand All @@ -194,7 +204,7 @@ namespace Py
}
};

class PYCXX_EXPORT OverflowError: public ArithmeticError
class OverflowError: public ArithmeticError
{
public:
OverflowError (const std::string& reason)
Expand All @@ -204,7 +214,7 @@ namespace Py
}
};

class PYCXX_EXPORT ZeroDivisionError: public ArithmeticError
class ZeroDivisionError: public ArithmeticError
{
public:
ZeroDivisionError (const std::string& reason)
Expand All @@ -214,7 +224,7 @@ namespace Py
}
};

class PYCXX_EXPORT FloatingPointError: public ArithmeticError
class FloatingPointError: public ArithmeticError
{
public:
FloatingPointError (const std::string& reason)
Expand All @@ -224,7 +234,7 @@ namespace Py
}
};

class PYCXX_EXPORT MemoryError: public StandardError
class MemoryError: public StandardError
{
public:
MemoryError (const std::string& reason)
Expand All @@ -234,7 +244,7 @@ namespace Py
}
};

class PYCXX_EXPORT SystemExit: public StandardError
class SystemExit: public StandardError
{
public:
SystemExit (const std::string& reason)
Expand Down
17 changes: 7 additions & 10 deletions src/CXX/Python2/ExtensionModule.hxx
Expand Up @@ -40,7 +40,7 @@

namespace Py
{
class PYCXX_EXPORT ExtensionModuleBase
class ExtensionModuleBase
{
public:
ExtensionModuleBase( const char *name );
Expand All @@ -66,9 +66,6 @@ namespace Py
const std::string m_module_name;
const std::string m_full_module_name;
MethodTable m_method_table;
#if PY3
PyModuleDef m_module_def;
#endif
PyObject *m_module;

private:
Expand All @@ -80,11 +77,11 @@ namespace Py
};

// Note: Python calls noargs as varargs buts args==NULL
extern "C" PYCXX_EXPORT PyObject *method_noargs_call_handler( PyObject *_self_and_name_tuple, PyObject * );
extern "C" PYCXX_EXPORT PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args );
extern "C" PYCXX_EXPORT PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords );
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" PYCXX_EXPORT void do_not_dealloc( void * );
extern "C" void do_not_dealloc( void * );

template<TEMPLATE_TYPENAME T>
class ExtensionModule : public ExtensionModuleBase
Expand Down Expand Up @@ -139,8 +136,8 @@ namespace Py
static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );

Tuple args( 2 );
args[0] = Object( self );
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
args[0] = Object( self, true );
args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );

PyObject *func = PyCFunction_New
(
Expand Down
2 changes: 1 addition & 1 deletion src/CXX/Python2/ExtensionOldType.hxx
Expand Up @@ -178,7 +178,7 @@ namespace Py
Tuple self( 2 );

self[0] = Object( this );
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );

PyObject *func = PyCFunction_New( &method_def->ext_meth_def, self.ptr() );

Expand Down
2 changes: 1 addition & 1 deletion src/CXX/Python2/ExtensionType.hxx
Expand Up @@ -113,7 +113,7 @@ namespace Py
};


class PYCXX_EXPORT ExtensionClassMethodsTable
class ExtensionClassMethodsTable
{
public:
ExtensionClassMethodsTable()
Expand Down
4 changes: 1 addition & 3 deletions src/CXX/Python2/ExtensionTypeBase.hxx
Expand Up @@ -59,7 +59,7 @@ namespace Py

// This special deallocator does a delete on the pointer.

class PYCXX_EXPORT PythonExtensionBase : public PyObject
class PythonExtensionBase : public PyObject
{
public:
PythonExtensionBase();
Expand All @@ -70,9 +70,7 @@ namespace Py
virtual void reinit( Tuple &args, Dict &kwds );

// object basics
#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
virtual int print( FILE *, int );
#endif
virtual Object getattr( const char * );
virtual int setattr( const char *, const Object & );
virtual Object getattro( const String & );
Expand Down
4 changes: 2 additions & 2 deletions src/CXX/Python2/Extensions.hxx
Expand Up @@ -63,7 +63,7 @@ namespace Py
class ExtensionModuleBase;

// Make an Exception Type for use in raising custom exceptions
class PYCXX_EXPORT ExtensionExceptionType : public Object
class ExtensionExceptionType : public Object
{
public:
ExtensionExceptionType();
Expand All @@ -74,7 +74,7 @@ namespace Py
void init( ExtensionModuleBase &module, const std::string &name );
};

class PYCXX_EXPORT MethodTable
class MethodTable
{
public:
MethodTable();
Expand Down

0 comments on commit ad3908c

Please sign in to comment.