Merged with recent changes from trunk.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11187 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2009-04-11 16:46:47 +00:00
commit 8c74fa0f46
703 changed files with 21126 additions and 9266 deletions

View file

@ -1,5 +1,11 @@
%include <shared_ptr.i>
// Set SHARED_PTR_DISOWN to $disown if required, for example
// #define SHARED_PTR_DISOWN $disown
#if !defined(SHARED_PTR_DISOWN)
#define SHARED_PTR_DISOWN 0
#endif
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
%naturalvar TYPE;
@ -51,10 +57,10 @@
}
// plain pointer
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
@ -139,10 +145,10 @@
}
// plain pointer by reference
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}

View file

@ -107,7 +107,7 @@ namespace Swig {
/* memory handler */
struct GCItem
{
virtual ~GCItem() = 0;
virtual ~GCItem() {}
virtual int get_own() const
{
@ -115,10 +115,6 @@ namespace Swig {
}
};
GCItem::~GCItem()
{
}
struct GCItem_var
{
GCItem_var(GCItem *item = 0) : _item(item)
@ -212,10 +208,7 @@ namespace Swig {
swig_msg += msg;
}
if (!PyErr_Occurred()) {
swig_msg.insert(0, ": ");
PyErr_SetString(error, getMessage());
} else {
SWIG_Python_AddErrorMsg(getMessage());
}
SWIG_PYTHON_THREAD_END_BLOCK;
}

View file

@ -20,11 +20,13 @@ SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
if (val) *val = (FILE *)vptr;
return SWIG_OK;
}
}
%#if PY_VERSION_HEX < 0x03000000
if (PyFile_Check(obj)) {
if (val) *val = PyFile_AsFile(obj);
return SWIG_OK;
}
%#endif
return SWIG_TypeError;
}
}

10
Lib/python/pyabc.i Normal file
View file

@ -0,0 +1,10 @@
%define %pythonabc(Type, Abc)
%feature("python:abc", #Abc) Type;
%enddef
%pythoncode {import collections};
%pythonabc(std::vector, collections.MutableSequence);
%pythonabc(std::list, collections.MutableSequence);
%pythonabc(std::map, collections.MutableMapping);
%pythonabc(std::multimap, collections.MutableMapping);
%pythonabc(std::set, collections.MutableSet);
%pythonabc(std::multiset, collections.MutableSet);

View file

@ -27,6 +27,20 @@ typedef struct swig_const_info {
swig_type_info **ptype;
} swig_const_info;
/* -----------------------------------------------------------------------------
* Wrapper of PyInstanceMethod_New() used in Python 3
* It is exported to the generated module, used for -fastproxy
* ----------------------------------------------------------------------------- */
SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func)
{
#if PY_VERSION_HEX >= 0x03000000
return PyInstanceMethod_New(func);
#else
return NULL;
#endif
}
#ifdef __cplusplus
#if 0
{ /* cc-mode */

107
Lib/python/pybuffer.i Normal file
View file

@ -0,0 +1,107 @@
/* Implementing buffer protocol typemaps */
/* %pybuffer_mutable_binary(TYPEMAP, SIZE)
*
* Macro for functions accept mutable buffer pointer with a size.
* This can be used for both input and output. For example:
*
* %pybuffer_mutable_binary(char *buff, int size);
* void foo(char *buff, int size) {
* for(int i=0; i<size; ++i)
* buff[i]++;
* }
*/
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE)
(int res, Py_ssize_t size = 0, void *buf = 0) {
res = PyObject_AsWriteBuffer($input, &buf, &size);
if (res<0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size/sizeof($*1_type));
}
%enddef
/* %pybuffer_mutable_string(TYPEMAP, SIZE)
*
* Macro for functions accept mutable zero terminated string pointer.
* This can be used for both input and output. For example:
*
* %pybuffer_mutable_string(char *str);
* void foo(char *str) {
* while(*str) {
* *str = toupper(*str);
* str++;
* }
*/
%define %pybuffer_mutable_string(TYPEMAP)
%typemap(in) (TYPEMAP)
(int res, Py_ssize_t size = 0, void *buf = 0) {
res = PyObject_AsWriteBuffer($input, &buf, &size);
if (res<0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
}
%enddef
/* pybuffer_binary(TYPEMAP, SIZE)
*
* Macro for functions accept read only buffer pointer with a size.
* This must be used for input. For example:
*
* %pybuffer_binary(char *buff, int size);
* int foo(char *buff, int size) {
* int count = 0;
* for(int i=0; i<size; ++i)
* if (0==buff[i]) count++;
* return count;
* }
*/
%define %pybuffer_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE)
(int res, Py_ssize_t size = 0, const void *buf = 0) {
res = PyObject_AsReadBuffer($input, &buf, &size);
if (res<0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size / sizeof($*1_type));
}
%enddef
/* %pybuffer_string(TYPEMAP, SIZE)
*
* Macro for functions accept read only zero terminated string pointer.
* This can be used for input. For example:
*
* %pybuffer_string(char *str);
* int foo(char *str) {
* int count = 0;
* while(*str) {
* if (isalnum(*str))
* count++;
* str++;
* }
*/
%define %pybuffer_string(TYPEMAP)
%typemap(in) (TYPEMAP)
(int res, Py_ssize_t size = 0, const void *buf = 0) {
res = PyObject_AsReadBuffer($input, &buf, &size);
if (res<0) {
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
$1 = ($1_ltype) buf;
}
%enddef

View file

@ -1,55 +1,55 @@
#ifdef __cplusplus
/*
PyObject_ptr is used as a replacement of PyObject *, where
SwigPtr_PyObject is used as a replacement of PyObject *, where
the INCREF/DECREF are applied as needed.
You can use PyObject_ptr in a container, such as
You can use SwigPtr_PyObject in a container, such as
std::vector<PyObject_ptr>;
std::vector<SwigPtr_PyObject>;
or as a member variable:
struct A {
PyObject_ptr obj;
SwigPtr_PyObject obj;
A(PyObject *o) : _obj(o) {
}
};
or as a input/output value
PyObject_ptr func(PyObject_ptr obj) {
PyObject_ptr out = PyString_FromFormat("hello %s", PyObject_AsString(obj));
SwigPtr_PyObject func(SwigPtr_PyObject obj) {
SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj));
Py_DECREF(out);
return out;
}
just remember to pair the object creation with the proper DECREF,
the same as with plain PyObject *ptr, since PyObject_ptr always add
the same as with plain PyObject *ptr, since SwigPtr_PyObject always add
one reference at construction.
PyObject_ptr is 'visible' at the wrapped side, so you can do:
SwigPtr_PyObject is 'visible' at the wrapped side, so you can do:
%template(pyvector) std::vector<swig::PyObject_ptr>;
%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
and all the proper typemaps will be used.
*/
namespace swig {
%ignore PyObject_ptr;
struct PyObject_ptr {};
%apply PyObject * {PyObject_ptr};
%apply PyObject * const& {PyObject_ptr const&};
%ignore SwigPtr_PyObject;
struct SwigPtr_PyObject {};
%apply PyObject * {SwigPtr_PyObject};
%apply PyObject * const& {SwigPtr_PyObject const&};
/* For output */
%typemap(out,noblock=1) PyObject_ptr {
%typemap(out,noblock=1) SwigPtr_PyObject {
$result = (PyObject *)$1;
Py_INCREF($result);
}
%typemap(out,noblock=1) PyObject_ptr const & {
%typemap(out,noblock=1) SwigPtr_PyObject const & {
$result = (PyObject *)*$1;
Py_INCREF($result);
}
@ -58,28 +58,28 @@ namespace swig {
%{
namespace swig {
class PyObject_ptr {
class SwigPtr_PyObject {
protected:
PyObject *_obj;
public:
PyObject_ptr() :_obj(0)
SwigPtr_PyObject() :_obj(0)
{
}
PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj)
SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
{
Py_XINCREF(_obj);
}
PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
{
if (initial_ref) {
Py_XINCREF(_obj);
}
}
PyObject_ptr & operator=(const PyObject_ptr& item)
SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
{
Py_XINCREF(item._obj);
Py_XDECREF(_obj);
@ -87,7 +87,7 @@ namespace swig {
return *this;
}
~PyObject_ptr()
~SwigPtr_PyObject()
{
Py_XDECREF(_obj);
}
@ -106,33 +106,33 @@ namespace swig {
%}
/*
PyObject_var is used to manage 'in the scope' PyObject * variables,
SwigVar_PyObject is used to manage 'in the scope' PyObject * variables,
as in
int func () {
PyObject_var obj = PyString_FromString("hello");
SwigVar_PyObject obj = PyString_FromString("hello");
}
ie, 'obj' is created and destructed in the same scope from
a python object that carries at least one reference value.
PyObject_var just take care of applying the proper Py_DECREF.
SwigVar_PyObject just take care of applying the proper Py_DECREF.
Hence, this class is purely internal and not visible at the wrapped side.
*/
namespace swig {
%ignore PyObject_var;
struct PyObject_var {};
%apply PyObject * {PyObject_var};
%apply PyObject * const& {PyObject_var const&};
%ignore SwigVar_PyObject;
struct SwigVar_PyObject {};
%apply PyObject * {SwigVar_PyObject};
%apply PyObject * const& {SwigVar_PyObject const&};
}
%{
namespace swig {
struct PyObject_var : PyObject_ptr {
PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { }
struct SwigVar_PyObject : SwigPtr_PyObject {
SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
PyObject_var & operator = (PyObject* obj)
SwigVar_PyObject & operator = (PyObject* obj)
{
Py_XDECREF(_obj);
_obj = obj;

View file

@ -36,15 +36,15 @@
%include <std_except.i>
%fragment(SWIG_Traits_frag(swig::PyObject_ptr),"header",fragment="StdTraits") {
%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") {
namespace swig {
template <> struct traits<PyObject_ptr > {
template <> struct traits<SwigPtr_PyObject > {
typedef value_category category;
static const char* type_name() { return "PyObject_ptr"; }
static const char* type_name() { return "SwigPtr_PyObject"; }
};
template <> struct traits_from<PyObject_ptr> {
typedef PyObject_ptr value_type;
template <> struct traits_from<SwigPtr_PyObject> {
typedef SwigPtr_PyObject value_type;
static PyObject *from(const value_type& val) {
PyObject *obj = static_cast<PyObject *>(val);
Py_XINCREF(obj);
@ -53,14 +53,14 @@ namespace swig {
};
template <>
struct traits_check<PyObject_ptr, value_category> {
static bool check(PyObject_ptr) {
struct traits_check<SwigPtr_PyObject, value_category> {
static bool check(SwigPtr_PyObject) {
return true;
}
};
template <> struct traits_asval<PyObject_ptr > {
typedef PyObject_ptr value_type;
template <> struct traits_asval<SwigPtr_PyObject > {
typedef SwigPtr_PyObject value_type;
static int asval(PyObject *obj, value_type *val) {
if (val) *val = obj;
return SWIG_OK;
@ -69,15 +69,15 @@ namespace swig {
}
}
%fragment(SWIG_Traits_frag(swig::PyObject_var),"header",fragment="StdTraits") {
%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") {
namespace swig {
template <> struct traits<PyObject_var > {
template <> struct traits<SwigVar_PyObject > {
typedef value_category category;
static const char* type_name() { return "PyObject_var"; }
static const char* type_name() { return "SwigVar_PyObject"; }
};
template <> struct traits_from<PyObject_var> {
typedef PyObject_var value_type;
template <> struct traits_from<SwigVar_PyObject> {
typedef SwigVar_PyObject value_type;
static PyObject *from(const value_type& val) {
PyObject *obj = static_cast<PyObject *>(val);
Py_XINCREF(obj);
@ -86,14 +86,14 @@ namespace swig {
};
template <>
struct traits_check<PyObject_var, value_category> {
static bool check(PyObject_var) {
struct traits_check<SwigVar_PyObject, value_category> {
static bool check(SwigVar_PyObject) {
return true;
}
};
template <> struct traits_asval<PyObject_var > {
typedef PyObject_var value_type;
template <> struct traits_asval<SwigVar_PyObject > {
typedef SwigVar_PyObject value_type;
static int asval(PyObject *obj, value_type *val) {
if (val) *val = obj;
return SWIG_OK;
@ -102,7 +102,7 @@ namespace swig {
}
}
%fragment("PySequence_Base","header")
%fragment("SwigPySequence_Base","header")
{
%#include <functional>
@ -115,27 +115,38 @@ namespace std {
{
bool res;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
res = PyObject_Compare(v, w) < 0;
res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false;
/* This may fall into a case of inconsistent
eg. ObjA > ObjX > ObjB
but ObjA < ObjB
*/
if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) )
{
/* Objects can't be compared, this mostly occured in Python 3.0 */
/* Compare their ptr directly for a workaround */
res = (v < w);
PyErr_Clear();
}
SWIG_PYTHON_THREAD_END_BLOCK;
return res;
}
};
template <>
struct less <swig::PyObject_ptr>: public binary_function<swig::PyObject_ptr, swig::PyObject_ptr, bool>
struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
{
bool
operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const
operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
{
return std::less<PyObject *>()(v, w);
}
};
template <>
struct less <swig::PyObject_var>: public binary_function<swig::PyObject_var, swig::PyObject_var, bool>
struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
{
bool
operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const
operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
{
return std::less<PyObject *>()(v, w);
}
@ -277,24 +288,24 @@ namespace swig {
}
}
%fragment("PySequence_Cont","header",
%fragment("SwigPySequence_Cont","header",
fragment="StdTraits",
fragment="PySequence_Base",
fragment="PySwigIterator_T")
fragment="SwigPySequence_Base",
fragment="SwigPyIterator_T")
{
namespace swig
{
template <class T>
struct PySequence_Ref
struct SwigPySequence_Ref
{
PySequence_Ref(PyObject* seq, int index)
SwigPySequence_Ref(PyObject* seq, int index)
: _seq(seq), _index(index)
{
}
operator T () const
{
swig::PyObject_var item = PySequence_GetItem(_seq, _index);
swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
@ -309,7 +320,7 @@ namespace swig
}
}
PySequence_Ref& operator=(const T& v)
SwigPySequence_Ref& operator=(const T& v)
{
PySequence_SetItem(_seq, _index, swig::from<T>(v));
return *this;
@ -321,18 +332,18 @@ namespace swig
};
template <class T>
struct PySequence_ArrowProxy
struct SwigPySequence_ArrowProxy
{
PySequence_ArrowProxy(const T& x): m_value(x) {}
SwigPySequence_ArrowProxy(const T& x): m_value(x) {}
const T* operator->() const { return &m_value; }
operator const T*() const { return &m_value; }
T m_value;
};
template <class T, class Reference >
struct PySequence_InputIterator
struct SwigPySequence_InputIterator
{
typedef PySequence_InputIterator<T, Reference > self;
typedef SwigPySequence_InputIterator<T, Reference > self;
typedef std::random_access_iterator_tag iterator_category;
typedef Reference reference;
@ -340,11 +351,11 @@ namespace swig
typedef T* pointer;
typedef int difference_type;
PySequence_InputIterator()
SwigPySequence_InputIterator()
{
}
PySequence_InputIterator(PyObject* seq, int index)
SwigPySequence_InputIterator(PyObject* seq, int index)
: _seq(seq), _index(index)
{
}
@ -354,9 +365,9 @@ namespace swig
return reference(_seq, _index);
}
PySequence_ArrowProxy<T>
SwigPySequence_ArrowProxy<T>
operator->() const {
return PySequence_ArrowProxy<T>(operator*());
return SwigPySequence_ArrowProxy<T>(operator*());
}
bool operator==(const self& ri) const
@ -425,19 +436,19 @@ namespace swig
};
template <class T>
struct PySequence_Cont
struct SwigPySequence_Cont
{
typedef PySequence_Ref<T> reference;
typedef const PySequence_Ref<T> const_reference;
typedef SwigPySequence_Ref<T> reference;
typedef const SwigPySequence_Ref<T> const_reference;
typedef T value_type;
typedef T* pointer;
typedef int difference_type;
typedef int size_type;
typedef const pointer const_pointer;
typedef PySequence_InputIterator<T, reference> iterator;
typedef PySequence_InputIterator<T, const_reference> const_iterator;
typedef SwigPySequence_InputIterator<T, reference> iterator;
typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
PySequence_Cont(PyObject* seq) : _seq(0)
SwigPySequence_Cont(PyObject* seq) : _seq(0)
{
if (!PySequence_Check(seq)) {
throw std::invalid_argument("a sequence is expected");
@ -446,7 +457,7 @@ namespace swig
Py_INCREF(_seq);
}
~PySequence_Cont()
~SwigPySequence_Cont()
{
Py_XDECREF(_seq);
}
@ -495,7 +506,7 @@ namespace swig
{
int s = size();
for (int i = 0; i < s; ++i) {
swig::PyObject_var item = PySequence_GetItem(_seq, i);
swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
if (!swig::check<value_type>(item)) {
if (set_err) {
char msg[1024];
@ -522,40 +533,40 @@ namespace swig
class const_iterator;
class const_reverse_iterator;
%typemap(out,noblock=1,fragment="PySequence_Cont")
%typemap(out,noblock=1,fragment="SwigPySequence_Cont")
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
%typemap(out,noblock=1,fragment="PySequence_Cont")
%typemap(out,noblock=1,fragment="SwigPySequence_Cont")
std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
}
%fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="PySequence_Cont") {}
%fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {}
%typemap(out,noblock=1,fragment="PyPairBoolOutputIterator")
%typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator")
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second));
}
%typemap(in,noblock=1,fragment="PySequence_Cont")
iterator(swig::PySwigIterator *iter = 0, int res),
reverse_iterator(swig::PySwigIterator *iter = 0, int res),
const_iterator(swig::PySwigIterator *iter = 0, int res),
const_reverse_iterator(swig::PySwigIterator *iter = 0, int res) {
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
%typemap(in,noblock=1,fragment="SwigPySequence_Cont")
iterator(swig::SwigPyIterator *iter = 0, int res),
reverse_iterator(swig::SwigPyIterator *iter = 0, int res),
const_iterator(swig::SwigPyIterator *iter = 0, int res),
const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) {
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
if (!SWIG_IsOK(res) || !iter) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
} else {
swig::PySwigIterator_T<$type > *iter_t = dynamic_cast<swig::PySwigIterator_T<$type > *>(iter);
swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter);
if (iter_t) {
$1 = iter_t->get_current();
} else {
@ -564,18 +575,18 @@ namespace swig
}
}
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="PySequence_Cont")
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont")
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
swig::PySwigIterator *iter = 0;
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<$type > *>(iter) != 0));
swig::SwigPyIterator *iter = 0;
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter) != 0));
}
%fragment("PySequence_Cont");
%fragment("SwigPySequence_Cont");
%newobject iterator(PyObject **PYTHON_SELF);
%extend {
swig::PySwigIterator* iterator(PyObject **PYTHON_SELF) {
swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
@ -597,6 +608,11 @@ namespace swig
return !(self->empty());
}
/* Alias for Python 3 compatibility */
bool __bool__() const {
return !(self->empty());
}
size_type __len__() const {
return self->size();
}
@ -607,7 +623,7 @@ namespace swig
%swig_sequence_iterator(%arg(Sequence))
%swig_container_methods(%arg(Sequence))
%fragment("PySequence_Base");
%fragment("SwigPySequence_Base");
%extend {
value_type pop() throw (std::out_of_range) {
@ -618,6 +634,14 @@ namespace swig
return x;
}
/* typemap for slice object support */
%typemap(in) PySliceObject* {
$1 = (PySliceObject *) $input;
}
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* {
$1 = PySlice_Check($input);
}
Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
return swig::getslice(self, i, j);
}
@ -634,6 +658,43 @@ namespace swig
void __delitem__(difference_type i) throw (std::out_of_range) {
self->erase(swig::getpos(self,i));
}
/* Overloaded methods for Python 3 compatibility
* (Also useful in Python 2.x)
*/
Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
Py_ssize_t i, j, step;
if( !PySlice_Check(slice) ) {
SWIG_Error(SWIG_TypeError, "Slice object expected.");
return NULL;
}
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
return swig::getslice(self, i, j);
}
void __setitem__(PySliceObject *slice, const Sequence& v)
throw (std::out_of_range, std::invalid_argument) {
Py_ssize_t i, j, step;
if( !PySlice_Check(slice) ) {
SWIG_Error(SWIG_TypeError, "Slice object expected.");
return;
}
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
swig::setslice(self, i, j, v);
}
void __delitem__(PySliceObject *slice)
throw (std::out_of_range) {
Py_ssize_t i, j, step;
if( !PySlice_Check(slice) ) {
SWIG_Error(SWIG_TypeError, "Slice object expected.");
return;
}
PySlice_GetIndices(slice, self->size(), &i, &j, &step);
swig::delslice(self, i,j);
}
}
%enddef
@ -679,16 +740,16 @@ namespace swig
%fragment("StdSequenceTraits","header",
fragment="StdTraits",
fragment="PySequence_Cont")
fragment="SwigPySequence_Cont")
{
namespace swig {
template <class PySeq, class Seq>
template <class SwigPySeq, class Seq>
inline void
assign(const PySeq& pyseq, Seq* seq) {
// seq->assign(pyseq.begin(), pyseq.end()); // not used as not always implemented
typedef typename PySeq::value_type value_type;
typename PySeq::const_iterator it = pyseq.begin();
for (;it != pyseq.end(); ++it) {
assign(const SwigPySeq& swigpyseq, Seq* seq) {
// seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
typedef typename SwigPySeq::value_type value_type;
typename SwigPySeq::const_iterator it = swigpyseq.begin();
for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
@ -708,14 +769,14 @@ namespace swig {
}
} else if (PySequence_Check(obj)) {
try {
PySequence_Cont<value_type> pyseq(obj);
SwigPySequence_Cont<value_type> swigpyseq(obj);
if (seq) {
sequence *pseq = new sequence();
assign(pyseq, pseq);
assign(swigpyseq, pseq);
*seq = pseq;
return SWIG_NEWOBJ;
} else {
return pyseq.check() ? SWIG_OK : SWIG_ERROR;
return swigpyseq.check() ? SWIG_OK : SWIG_ERROR;
}
} catch (std::exception& e) {
if (seq) {

View file

@ -55,15 +55,16 @@ SWIG_Python_AddErrorMsg(const char* mesg)
if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
if (value) {
char *tmp;
PyObject *old_str = PyObject_Str(value);
PyErr_Clear();
Py_XINCREF(type);
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
Py_DECREF(value);
} else {
PyErr_SetString(PyExc_RuntimeError, mesg);
}
}

View file

@ -1,3 +1,64 @@
/* Compatibility marcos for Python 3 */
#if PY_VERSION_HEX >= 0x03000000
#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
#define PyInt_Check(x) PyLong_Check(x)
#define PyInt_AsLong(x) PyLong_AsLong(x)
#define PyInt_FromLong(x) PyLong_FromLong(x)
#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
#endif
#ifndef Py_TYPE
# define Py_TYPE(op) ((op)->ob_type)
#endif
/* SWIG APIs for compatibility of both Python 2 & 3 */
#if PY_VERSION_HEX >= 0x03000000
# define SWIG_Python_str_FromFormat PyUnicode_FromFormat
#else
# define SWIG_Python_str_FromFormat PyString_FromFormat
#endif
/* Warning: This function will allocate a new string in Python 3,
* so please call SWIG_Python_str_DelForPy3(x) to free the space.
*/
SWIGINTERN char*
SWIG_Python_str_AsChar(PyObject *str)
{
#if PY_VERSION_HEX >= 0x03000000
char *cstr;
char *newstr;
int len;
str = PyUnicode_AsUTF8String(str);
PyBytes_AsStringAndSize(str, &cstr, &len);
newstr = (char *) malloc(len+1);
memcpy(newstr, cstr, len+1);
Py_XDECREF(str);
return newstr;
#else
return PyString_AsString(str);
#endif
}
#if PY_VERSION_HEX >= 0x03000000
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#else
# define SWIG_Python_str_DelForPy3(x)
#endif
SWIGINTERN PyObject*
SWIG_Python_str_FromChar(const char *c)
{
#if PY_VERSION_HEX >= 0x03000000
return PyUnicode_FromString(c);
#else
return PyString_FromString(c);
#endif
}
/* Add PyOS_snprintf for old Pythons */
#if PY_VERSION_HEX < 0x02020000
@ -44,6 +105,7 @@ PyString_FromFormat(const char *fmt, ...) {
# define PyObject_GenericGetAttr 0
# endif
#endif
/* Py_NotImplemented is defined in 2.1 and up. */
#if PY_VERSION_HEX < 0x02010000
# ifndef Py_NotImplemented
@ -51,7 +113,6 @@ PyString_FromFormat(const char *fmt, ...) {
# endif
#endif
/* A crude PyString_AsStringAndSize implementation for old Pythons */
#if PY_VERSION_HEX < 0x02010000
# ifndef PyString_AsStringAndSize
@ -66,7 +127,6 @@ PyString_FromFormat(const char *fmt, ...) {
# endif
#endif
/* PyBool_FromLong for old Pythons */
#if PY_VERSION_HEX < 0x02030000
static

View file

@ -33,26 +33,58 @@ typedef struct swig_varlinkobject {
SWIGINTERN PyObject *
swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
#if PY_VERSION_HEX >= 0x03000000
return PyUnicode_InternFromString("<Swig global variables>");
#else
return PyString_FromString("<Swig global variables>");
#endif
}
SWIGINTERN PyObject *
swig_varlink_str(swig_varlinkobject *v) {
#if PY_VERSION_HEX >= 0x03000000
PyObject *str = PyUnicode_InternFromString("(");
PyObject *tail;
PyObject *joined;
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
tail = PyUnicode_FromString(var->name);
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
if (var->next) {
tail = PyUnicode_InternFromString(", ");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
}
}
tail = PyUnicode_InternFromString(")");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
#else
PyObject *str = PyString_FromString("(");
swig_globalvar *var;
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
PyString_ConcatAndDel(&str,PyString_FromString(var->name));
if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
}
PyString_ConcatAndDel(&str,PyString_FromString(")"));
#endif
return str;
}
SWIGINTERN int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
char *tmp;
PyObject *str = swig_varlink_str(v);
fprintf(fp,"Swig global variables ");
fprintf(fp,"%s\n", PyString_AsString(str));
fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(str);
return 0;
}
@ -110,8 +142,13 @@ swig_varlink_type(void) {
if (!type_init) {
const PyTypeObject tmp
= {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* Number of items in variable part (ob_size) */
#endif
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
0, /* Itemsize (tp_itemsize) */
@ -147,7 +184,10 @@ swig_varlink_type(void) {
#endif
};
varlink_type = tmp;
/* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */
#if PY_VERSION_HEX < 0x03000000
varlink_type.ob_type = &PyType_Type;
#endif
type_init = 1;
}
return &varlink_type;
@ -272,13 +312,37 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT void SWIG_init(void) {
PyObject *m, *d;
SWIGEXPORT
#if PY_VERSION_HEX >= 0x03000000
PyObject*
#else
void
#endif
SWIG_init(void) {
PyObject *m, *d;
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef SWIG_module = {
PyModuleDef_HEAD_INIT,
(char *) SWIG_name,
NULL,
-1,
SwigMethods,
NULL,
NULL,
NULL,
NULL
};
#endif
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&SWIG_module);
#else
m = Py_InitModule((char *) SWIG_name, SwigMethods);
#endif
d = PyModule_GetDict(m);
SWIG_InitializeModule(0);

View file

@ -6,56 +6,56 @@
*
* Implement a python 'output' iterator for Python 2.2 or higher.
*
* Users can derive form the PySwigIterator to implement their
* Users can derive form the SwigPyIterator to implement their
* own iterators. As an example (real one since we use it for STL/STD
* containers), the template PySwigIterator_T does the
* containers), the template SwigPyIterator_T does the
* implementation for genereic C++ iterators.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%fragment("PySwigIterator","header") {
%fragment("SwigPyIterator","header") {
namespace swig {
struct stop_iteration {
};
struct PySwigIterator {
struct SwigPyIterator {
private:
PyObject_ptr _seq;
SwigPtr_PyObject _seq;
protected:
PySwigIterator(PyObject *seq) : _seq(seq)
SwigPyIterator(PyObject *seq) : _seq(seq)
{
}
public:
virtual ~PySwigIterator() {}
virtual ~SwigPyIterator() {}
// Access iterator method, required by Python
virtual PyObject *value() const = 0;
// Forward iterator method, required by Python
virtual PySwigIterator *incr(size_t n = 1) = 0;
virtual SwigPyIterator *incr(size_t n = 1) = 0;
// Backward iterator method, very common in C++, but not required in Python
virtual PySwigIterator *decr(size_t /*n*/ = 1)
virtual SwigPyIterator *decr(size_t /*n*/ = 1)
{
throw stop_iteration();
}
// Random access iterator methods, but not required in Python
virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const
virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const
{
throw std::invalid_argument("operation not supported");
}
virtual bool equal (const PySwigIterator &/*x*/) const
virtual bool equal (const SwigPyIterator &/*x*/) const
{
throw std::invalid_argument("operation not supported");
}
// C++ common/needed methods
virtual PySwigIterator *copy() const = 0;
virtual SwigPyIterator *copy() const = 0;
PyObject *next()
{
@ -66,6 +66,12 @@ namespace swig {
return obj;
}
/* Make an alias for Python 3.x */
PyObject *__next__()
{
return next();
}
PyObject *previous()
{
SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
@ -75,42 +81,42 @@ namespace swig {
return obj;
}
PySwigIterator *advance(ptrdiff_t n)
SwigPyIterator *advance(ptrdiff_t n)
{
return (n > 0) ? incr(n) : decr(-n);
}
bool operator == (const PySwigIterator& x) const
bool operator == (const SwigPyIterator& x) const
{
return equal(x);
}
bool operator != (const PySwigIterator& x) const
bool operator != (const SwigPyIterator& x) const
{
return ! operator==(x);
}
PySwigIterator& operator += (ptrdiff_t n)
SwigPyIterator& operator += (ptrdiff_t n)
{
return *advance(n);
}
PySwigIterator& operator -= (ptrdiff_t n)
SwigPyIterator& operator -= (ptrdiff_t n)
{
return *advance(-n);
}
PySwigIterator* operator + (ptrdiff_t n) const
SwigPyIterator* operator + (ptrdiff_t n) const
{
return copy()->advance(n);
}
PySwigIterator* operator - (ptrdiff_t n) const
SwigPyIterator* operator - (ptrdiff_t n) const
{
return copy()->advance(-n);
}
ptrdiff_t operator - (const PySwigIterator& x) const
ptrdiff_t operator - (const SwigPyIterator& x) const
{
return x.distance(*this);
}
@ -119,7 +125,7 @@ namespace swig {
static int init = 0;
static swig_type_info* desc = 0;
if (!init) {
desc = SWIG_TypeQuery("swig::PySwigIterator *");
desc = SWIG_TypeQuery("swig::SwigPyIterator *");
init = 1;
}
return desc;
@ -128,18 +134,18 @@ namespace swig {
}
}
%fragment("PySwigIterator_T","header",fragment="PySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
namespace swig {
template<typename OutIterator>
class PySwigIterator_T : public PySwigIterator
class SwigPyIterator_T : public SwigPyIterator
{
public:
typedef OutIterator out_iterator;
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
typedef PySwigIterator_T<out_iterator> self_type;
typedef SwigPyIterator_T<out_iterator> self_type;
PySwigIterator_T(out_iterator curr, PyObject *seq)
: PySwigIterator(seq), current(curr)
SwigPyIterator_T(out_iterator curr, PyObject *seq)
: SwigPyIterator(seq), current(curr)
{
}
@ -149,7 +155,7 @@ namespace swig {
}
bool equal (const PySwigIterator &iter) const
bool equal (const SwigPyIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
@ -159,7 +165,7 @@ namespace swig {
}
}
ptrdiff_t distance(const PySwigIterator &iter) const
ptrdiff_t distance(const SwigPyIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
@ -187,17 +193,17 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class PySwigIteratorOpen_T : public PySwigIterator_T<OutIterator>
class SwigPyIteratorOpen_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef PySwigIterator_T<out_iterator> base;
typedef PySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
PySwigIteratorOpen_T(out_iterator curr, PyObject *seq)
: PySwigIterator_T<OutIterator>(curr, seq)
SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
: SwigPyIterator_T<OutIterator>(curr, seq)
{
}
@ -205,12 +211,12 @@ namespace swig {
return from(static_cast<const value_type&>(*(base::current)));
}
PySwigIterator *copy() const
SwigPyIterator *copy() const
{
return new self_type(*this);
}
PySwigIterator *incr(size_t n = 1)
SwigPyIterator *incr(size_t n = 1)
{
while (n--) {
++base::current;
@ -218,7 +224,7 @@ namespace swig {
return this;
}
PySwigIterator *decr(size_t n = 1)
SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
--base::current;
@ -230,17 +236,17 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class PySwigIteratorClosed_T : public PySwigIterator_T<OutIterator>
class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef PySwigIterator_T<out_iterator> base;
typedef PySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
: PySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
: SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
{
}
@ -252,12 +258,12 @@ namespace swig {
}
}
PySwigIterator *copy() const
SwigPyIterator *copy() const
{
return new self_type(*this);
}
PySwigIterator *incr(size_t n = 1)
SwigPyIterator *incr(size_t n = 1)
{
while (n--) {
if (base::current == end) {
@ -269,7 +275,7 @@ namespace swig {
return this;
}
PySwigIterator *decr(size_t n = 1)
SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
if (base::current == begin) {
@ -287,23 +293,23 @@ namespace swig {
};
template<typename OutIter>
inline PySwigIterator*
inline SwigPyIterator*
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
{
return new PySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
}
template<typename OutIter>
inline PySwigIterator*
inline SwigPyIterator*
make_output_iterator(const OutIter& current, PyObject *seq = 0)
{
return new PySwigIteratorOpen_T<OutIter>(current, seq);
return new SwigPyIteratorOpen_T<OutIter>(current, seq);
}
}
}
%fragment("PySwigIterator");
%fragment("SwigPyIterator");
namespace swig
{
/*
@ -321,65 +327,67 @@ namespace swig
/*
Mark methods that return new objects
*/
%newobject PySwigIterator::copy;
%newobject PySwigIterator::operator + (ptrdiff_t n) const;
%newobject PySwigIterator::operator - (ptrdiff_t n) const;
%newobject SwigPyIterator::copy;
%newobject SwigPyIterator::operator + (ptrdiff_t n) const;
%newobject SwigPyIterator::operator - (ptrdiff_t n) const;
%nodirector PySwigIterator;
%extend PySwigIterator {
%nodirector SwigPyIterator;
%extend SwigPyIterator {
%pythoncode {def __iter__(self): return self}
}
%catches(swig::stop_iteration) PySwigIterator::value() const;
%catches(swig::stop_iteration) PySwigIterator::incr(size_t n = 1);
%catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1);
%catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const;
%catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const;
%catches(swig::stop_iteration) PySwigIterator::next();
%catches(swig::stop_iteration) PySwigIterator::previous();
%catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n);
%catches(swig::stop_iteration) PySwigIterator::operator += (ptrdiff_t n);
%catches(swig::stop_iteration) PySwigIterator::operator -= (ptrdiff_t n);
%catches(swig::stop_iteration) PySwigIterator::operator + (ptrdiff_t n) const;
%catches(swig::stop_iteration) PySwigIterator::operator - (ptrdiff_t n) const;
%catches(swig::stop_iteration) SwigPyIterator::value() const;
%catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1);
%catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1);
%catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const;
%catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const;
%catches(swig::stop_iteration) SwigPyIterator::__next__();
%catches(swig::stop_iteration) SwigPyIterator::next();
%catches(swig::stop_iteration) SwigPyIterator::previous();
%catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n);
%catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n);
%catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n);
%catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const;
%catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const;
struct PySwigIterator
struct SwigPyIterator
{
protected:
PySwigIterator(PyObject *seq);
SwigPyIterator(PyObject *seq);
public:
virtual ~PySwigIterator();
virtual ~SwigPyIterator();
// Access iterator method, required by Python
virtual PyObject *value() const = 0;
// Forward iterator method, required by Python
virtual PySwigIterator *incr(size_t n = 1) = 0;
virtual SwigPyIterator *incr(size_t n = 1) = 0;
// Backward iterator method, very common in C++, but not required in Python
virtual PySwigIterator *decr(size_t n = 1);
virtual SwigPyIterator *decr(size_t n = 1);
// Random access iterator methods, but not required in Python
virtual ptrdiff_t distance(const PySwigIterator &x) const;
virtual ptrdiff_t distance(const SwigPyIterator &x) const;
virtual bool equal (const PySwigIterator &x) const;
virtual bool equal (const SwigPyIterator &x) const;
// C++ common/needed methods
virtual PySwigIterator *copy() const = 0;
virtual SwigPyIterator *copy() const = 0;
PyObject *next();
PyObject *__next__();
PyObject *previous();
PySwigIterator *advance(ptrdiff_t n);
SwigPyIterator *advance(ptrdiff_t n);
bool operator == (const PySwigIterator& x) const;
bool operator != (const PySwigIterator& x) const;
PySwigIterator& operator += (ptrdiff_t n);
PySwigIterator& operator -= (ptrdiff_t n);
PySwigIterator* operator + (ptrdiff_t n) const;
PySwigIterator* operator - (ptrdiff_t n) const;
ptrdiff_t operator - (const PySwigIterator& x) const;
bool operator == (const SwigPyIterator& x) const;
bool operator != (const SwigPyIterator& x) const;
SwigPyIterator& operator += (ptrdiff_t n);
SwigPyIterator& operator -= (ptrdiff_t n);
SwigPyIterator* operator + (ptrdiff_t n) const;
SwigPyIterator* operator - (ptrdiff_t n) const;
ptrdiff_t operator - (const SwigPyIterator& x) const;
};
}

View file

@ -0,0 +1,88 @@
/*
* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
* since they are inappropriate and discouraged in Python documentation
* (from http://www.python.org/doc/2.5.2/api/includes.html):
*
* "All user visible names defined by Python.h (except those defined by the included
* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with
* "_Py" are for internal use by the Python implementation and should not be used
* by extension writers. Structure member names do not have a reserved prefix.
*
* Important: user code should never define names that begin with "Py" or "_Py".
* This confuses the reader, and jeopardizes the portability of the user code to
* future Python versions, which may define additional names beginning with one
* of these prefixes."
*
* This file defined macros to provide backward compatibility for these deprecated
* symbols. In the case you have these symbols in your interface file, you can simply
* include this file at begining of it.
*
* However, this file may be removed in future release of SWIG, so using this file to
* keep these inappropriate names in your SWIG interface file is also not recommanded.
* Instead, we provide a simple tool for converting your interface files to
* the new naming convention. You can download the tool here:
* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
*/
%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {}
%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {}
%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {}
%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {}
%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
%inline %{
#define PyMapIterator_T SwigPyMapIterator_T
#define PyMapKeyIterator_T SwigPyMapKeyIterator_T
#define PyMapValueIterator_T SwigPyMapValueITerator_T
#define PyObject_ptr SwigPtr_PyObject
#define PyObject_var SwigVar_PyObject
#define PyOper SwigPyOper
#define PySeq SwigPySeq
#define PySequence_ArrowProxy SwigPySequence_ArrowProxy
#define PySequence_Cont SwigPySequence_Cont
#define PySequence_InputIterator SwigPySequence_InputIterator
#define PySequence_Ref SwigPySequence_Ref
#define PySwigClientData SwigPyClientData
#define PySwigClientData_Del SwigPyClientData_Del
#define PySwigClientData_New SwigPyClientData_New
#define PySwigIterator SwigPyIterator
#define PySwigIteratorClosed_T SwigPyIteratorClosed_T
#define PySwigIteratorOpen_T SwigPyIteratorOpen_T
#define PySwigIterator_T SwigPyIterator_T
#define PySwigObject SwigPyObject
#define PySwigObject_Check SwigPyObject_Check
#define PySwigObject_GetDesc SwigPyObject_GetDesc
#define PySwigObject_New SwigPyObject_New
#define PySwigObject_acquire SwigPyObject_acquire
#define PySwigObject_append SwigPyObject_append
#define PySwigObject_as_number SwigPyObject_as_number
#define PySwigObject_compare SwigPyObject_compare
#define PySwigObject_dealloc SwigPyObject_dealloc
#define PySwigObject_disown SwigPyObject_disown
#define PySwigObject_format SwigPyObject_format
#define PySwigObject_getattr SwigPyObject_getattr
#define PySwigObject_hex SwigPyObject_hex
#define PySwigObject_long SwigPyObject_long
#define PySwigObject_next SwigPyObject_next
#define PySwigObject_oct SwigPyObject_oct
#define PySwigObject_own SwigPyObject_own
#define PySwigObject_print SwigPyObject_print
#define PySwigObject_repr SwigPyObject_repr
#define PySwigObject_richcompare SwigPyObject_richcompare
#define PySwigObject_str SwigPyObject_str
#define PySwigObject_type SwigPyObject_type
#define PySwigPacked SwigPyPacked
#define PySwigPacked_Check SwigPyPacked_Check
#define PySwigPacked_New SwigPyPacked_New
#define PySwigPacked_UnpackData SwigPyPacked_UnpackData
#define PySwigPacked_compare SwigPyPacked_compare
#define PySwigPacked_dealloc SwigPyPacked_dealloc
#define PySwigPacked_print SwigPyPacked_print
#define PySwigPacked_repr SwigPyPacked_repr
#define PySwigPacked_str SwigPyPacked_str
#define PySwigPacked_type SwigPyPacked_type
#define pyseq swigpyseq
#define pyswigobject_type swigpyobject_type
#define pyswigpacked_type swigpypacked_type
%}

View file

@ -33,6 +33,12 @@
/* Special cases */
%rename(__invert__) *::operator~;
%rename(__call__) *::operator();
%feature("shadow") *::operator bool %{
def __nonzero__(self):
return $action(self)
__bool__ = __nonzero__
%};
%rename(__nonzero__) *::operator bool;
/* Ignored operators */
@ -84,7 +90,7 @@
*/
#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper
#define %pyinplaceoper(SwigPyOper, Oper) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper
%pyinplaceoper(__iadd__ , *::operator +=);
%pyinplaceoper(__isub__ , *::operator -=);

View file

@ -42,7 +42,7 @@
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
@ -238,7 +238,7 @@ SWIG_Py_Void(void)
return none;
}
/* PySwigClientData */
/* SwigPyClientData */
typedef struct {
PyObject *klass;
@ -247,30 +247,30 @@ typedef struct {
PyObject *destroy;
int delargs;
int implicitconv;
} PySwigClientData;
} SwigPyClientData;
SWIGRUNTIMEINLINE int
SWIG_Python_CheckImplicit(swig_type_info *ty)
{
PySwigClientData *data = (PySwigClientData *)ty->clientdata;
SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
return data ? data->implicitconv : 0;
}
SWIGRUNTIMEINLINE PyObject *
SWIG_Python_ExceptionType(swig_type_info *desc) {
PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
PyObject *klass = data ? data->klass : 0;
return (klass ? klass : PyExc_RuntimeError);
}
SWIGRUNTIME PySwigClientData *
PySwigClientData_New(PyObject* obj)
SWIGRUNTIME SwigPyClientData *
SwigPyClientData_New(PyObject* obj)
{
if (!obj) {
return 0;
} else {
PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
/* the klass element */
data->klass = obj;
Py_INCREF(data->klass);
@ -318,14 +318,14 @@ PySwigClientData_New(PyObject* obj)
}
SWIGRUNTIME void
PySwigClientData_Del(PySwigClientData* data)
SwigPyClientData_Del(SwigPyClientData* data)
{
Py_XDECREF(data->newraw);
Py_XDECREF(data->newargs);
Py_XDECREF(data->destroy);
}
/* =============== PySwigObject =====================*/
/* =============== SwigPyObject =====================*/
typedef struct {
PyObject_HEAD
@ -333,24 +333,28 @@ typedef struct {
swig_type_info *ty;
int own;
PyObject *next;
} PySwigObject;
} SwigPyObject;
SWIGRUNTIME PyObject *
PySwigObject_long(PySwigObject *v)
SwigPyObject_long(SwigPyObject *v)
{
return PyLong_FromVoidPtr(v->ptr);
}
SWIGRUNTIME PyObject *
PySwigObject_format(const char* fmt, PySwigObject *v)
SwigPyObject_format(const char* fmt, SwigPyObject *v)
{
PyObject *res = NULL;
PyObject *args = PyTuple_New(1);
if (args) {
if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
PyObject *ofmt = PyString_FromString(fmt);
if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
if (ofmt) {
#if PY_VERSION_HEX >= 0x03000000
res = PyUnicode_Format(ofmt,args);
#else
res = PyString_Format(ofmt,args);
#endif
Py_DECREF(ofmt);
}
Py_DECREF(args);
@ -360,49 +364,59 @@ PySwigObject_format(const char* fmt, PySwigObject *v)
}
SWIGRUNTIME PyObject *
PySwigObject_oct(PySwigObject *v)
SwigPyObject_oct(SwigPyObject *v)
{
return PySwigObject_format("%o",v);
return SwigPyObject_format("%o",v);
}
SWIGRUNTIME PyObject *
PySwigObject_hex(PySwigObject *v)
SwigPyObject_hex(SwigPyObject *v)
{
return PySwigObject_format("%x",v);
return SwigPyObject_format("%x",v);
}
SWIGRUNTIME PyObject *
#ifdef METH_NOARGS
PySwigObject_repr(PySwigObject *v)
SwigPyObject_repr(SwigPyObject *v)
#else
PySwigObject_repr(PySwigObject *v, PyObject *args)
SwigPyObject_repr(SwigPyObject *v, PyObject *args)
#endif
{
const char *name = SWIG_TypePrettyName(v->ty);
PyObject *hex = PySwigObject_hex(v);
PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
PyObject *hex = SwigPyObject_hex(v);
PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, hex);
Py_DECREF(hex);
if (v->next) {
#ifdef METH_NOARGS
PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
#else
PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
#endif
#if PY_VERSION_HEX >= 0x03000000
PyObject *joined = PyUnicode_Concat(repr, nrep);
Py_DecRef(repr);
Py_DecRef(nrep);
repr = joined;
#else
PyString_ConcatAndDel(&repr,nrep);
#endif
}
return repr;
}
SWIGRUNTIME int
PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
char *str;
#ifdef METH_NOARGS
PyObject *repr = PySwigObject_repr(v);
PyObject *repr = SwigPyObject_repr(v);
#else
PyObject *repr = PySwigObject_repr(v, NULL);
PyObject *repr = SwigPyObject_repr(v, NULL);
#endif
if (repr) {
fputs(PyString_AsString(repr), fp);
str = SWIG_Python_str_AsChar(repr);
fputs(str, fp);
SWIG_Python_str_DelForPy3(str);
Py_DECREF(repr);
return 0;
} else {
@ -411,53 +425,71 @@ PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
}
SWIGRUNTIME PyObject *
PySwigObject_str(PySwigObject *v)
SwigPyObject_str(SwigPyObject *v)
{
char result[SWIG_BUFFER_SIZE];
return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
PyString_FromString(result) : 0;
SWIG_Python_str_FromChar(result) : 0;
}
SWIGRUNTIME int
PySwigObject_compare(PySwigObject *v, PySwigObject *w)
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
{
void *i = v->ptr;
void *j = w->ptr;
return (i < j) ? -1 : ((i > j) ? 1 : 0);
}
/* Added for Python 3.x, whould it also useful for Python 2.x? */
SWIGRUNTIME PyObject*
SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
{
PyObject* res;
if( op != Py_EQ && op != Py_NE ) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) )
res = Py_True;
else
res = Py_False;
Py_INCREF(res);
return res;
}
SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
SWIGRUNTIME PyTypeObject*
PySwigObject_type(void) {
SwigPyObject_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
return type;
}
SWIGRUNTIMEINLINE int
PySwigObject_Check(PyObject *op) {
return ((op)->ob_type == PySwigObject_type())
|| (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
SwigPyObject_Check(PyObject *op) {
return (Py_TYPE(op) == SwigPyObject_type())
|| (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
}
SWIGRUNTIME PyObject *
PySwigObject_New(void *ptr, swig_type_info *ty, int own);
SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
SWIGRUNTIME void
PySwigObject_dealloc(PyObject *v)
SwigPyObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
SwigPyObject *sobj = (SwigPyObject *) v;
PyObject *next = sobj->next;
if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
if (destroy) {
/* destroy is always a VARARGS method */
PyObject *res;
if (data->delargs) {
/* we need to create a temporal object to carry the destroy operation */
PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
res = SWIG_Python_CallFunctor(destroy, tmp);
Py_DECREF(tmp);
} else {
@ -479,15 +511,15 @@ PySwigObject_dealloc(PyObject *v)
}
SWIGRUNTIME PyObject*
PySwigObject_append(PyObject* v, PyObject* next)
SwigPyObject_append(PyObject* v, PyObject* next)
{
PySwigObject *sobj = (PySwigObject *) v;
SwigPyObject *sobj = (SwigPyObject *) v;
#ifndef METH_O
PyObject *tmp = 0;
if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
next = tmp;
#endif
if (!PySwigObject_Check(next)) {
if (!SwigPyObject_Check(next)) {
return NULL;
}
sobj->next = next;
@ -497,12 +529,12 @@ PySwigObject_append(PyObject* v, PyObject* next)
SWIGRUNTIME PyObject*
#ifdef METH_NOARGS
PySwigObject_next(PyObject* v)
SwigPyObject_next(PyObject* v)
#else
PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
PySwigObject *sobj = (PySwigObject *) v;
SwigPyObject *sobj = (SwigPyObject *) v;
if (sobj->next) {
Py_INCREF(sobj->next);
return sobj->next;
@ -513,30 +545,30 @@ PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
SWIGINTERN PyObject*
#ifdef METH_NOARGS
PySwigObject_disown(PyObject *v)
SwigPyObject_disown(PyObject *v)
#else
PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
PySwigObject *sobj = (PySwigObject *)v;
SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = 0;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
#ifdef METH_NOARGS
PySwigObject_acquire(PyObject *v)
SwigPyObject_acquire(PyObject *v)
#else
PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
PySwigObject *sobj = (PySwigObject *)v;
SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = SWIG_POINTER_OWN;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
PySwigObject_own(PyObject *v, PyObject *args)
SwigPyObject_own(PyObject *v, PyObject *args)
{
PyObject *val = 0;
#if (PY_VERSION_HEX < 0x02020000)
@ -549,20 +581,20 @@ PySwigObject_own(PyObject *v, PyObject *args)
}
else
{
PySwigObject *sobj = (PySwigObject *)v;
SwigPyObject *sobj = (SwigPyObject *)v;
PyObject *obj = PyBool_FromLong(sobj->own);
if (val) {
#ifdef METH_NOARGS
if (PyObject_IsTrue(val)) {
PySwigObject_acquire(v);
SwigPyObject_acquire(v);
} else {
PySwigObject_disown(v);
SwigPyObject_disown(v);
}
#else
if (PyObject_IsTrue(val)) {
PySwigObject_acquire(v,args);
SwigPyObject_acquire(v,args);
} else {
PySwigObject_disown(v,args);
SwigPyObject_disown(v,args);
}
#endif
}
@ -573,30 +605,30 @@ PySwigObject_own(PyObject *v, PyObject *args)
#ifdef METH_O
static PyMethodDef
swigobject_methods[] = {
{(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
{(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
{(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
{(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
{(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
{(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
{(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
{(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
{(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
{(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
{(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
{(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
{0, 0, 0, 0}
};
#else
static PyMethodDef
swigobject_methods[] = {
{(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
{(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
{(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
{(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
{(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
{(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
{(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
{(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
{(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
{(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
{(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
{(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
{0, 0, 0, 0}
};
#endif
#if PY_VERSION_HEX < 0x02020000
SWIGINTERN PyObject *
PySwigObject_getattr(PySwigObject *sobj,char *name)
SwigPyObject_getattr(SwigPyObject *sobj,char *name)
{
return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
}
@ -606,11 +638,14 @@ SWIGRUNTIME PyTypeObject*
_PySwigObject_type(void) {
static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
static PyNumberMethods PySwigObject_as_number = {
static PyNumberMethods SwigPyObject_as_number = {
(binaryfunc)0, /*nb_add*/
(binaryfunc)0, /*nb_subtract*/
(binaryfunc)0, /*nb_multiply*/
/* nb_divide removed in Python 3 */
#if PY_VERSION_HEX < 0x03000000
(binaryfunc)0, /*nb_divide*/
#endif
(binaryfunc)0, /*nb_remainder*/
(binaryfunc)0, /*nb_divmod*/
(ternaryfunc)0,/*nb_power*/
@ -624,13 +659,23 @@ _PySwigObject_type(void) {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
(coercion)0, /*nb_coerce*/
(unaryfunc)PySwigObject_long, /*nb_int*/
(unaryfunc)PySwigObject_long, /*nb_long*/
#if PY_VERSION_HEX < 0x03000000
0, /*nb_coerce*/
#endif
(unaryfunc)SwigPyObject_long, /*nb_int*/
#if PY_VERSION_HEX < 0x03000000
(unaryfunc)SwigPyObject_long, /*nb_long*/
#else
0, /*nb_reserved*/
#endif
(unaryfunc)0, /*nb_float*/
(unaryfunc)PySwigObject_oct, /*nb_oct*/
(unaryfunc)PySwigObject_hex, /*nb_hex*/
#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
#if PY_VERSION_HEX < 0x03000000
(unaryfunc)SwigPyObject_oct, /*nb_oct*/
(unaryfunc)SwigPyObject_hex, /*nb_hex*/
#endif
#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
@ -639,32 +684,41 @@ _PySwigObject_type(void) {
#endif
};
static PyTypeObject pyswigobject_type;
static PyTypeObject swigpyobject_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp
= {
/* PyOjbect header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
(char *)"PySwigObject", /* tp_name */
sizeof(PySwigObject), /* tp_basicsize */
#endif
(char *)"SwigPyObject", /* tp_name */
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)PySwigObject_dealloc, /* tp_dealloc */
(printfunc)PySwigObject_print, /* tp_print */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
(printfunc)SwigPyObject_print, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)PySwigObject_getattr, /* tp_getattr */
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
(getattrfunc)0, /* tp_getattr */
#endif
(setattrfunc)0, /* tp_setattr */
(cmpfunc)PySwigObject_compare, /* tp_compare */
(reprfunc)PySwigObject_repr, /* tp_repr */
&PySwigObject_as_number, /* tp_as_number */
#if PY_VERSION_HEX >= 0x03000000
0, /* tp_reserved in 3.0.1 */
#else
(cmpfunc)SwigPyObject_compare, /* tp_compare */
#endif
(reprfunc)SwigPyObject_repr, /* tp_repr */
&SwigPyObject_as_number, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)PySwigObject_str, /* tp_str */
(reprfunc)SwigPyObject_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -672,7 +726,7 @@ _PySwigObject_type(void) {
swigobject_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
(richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
@ -689,11 +743,11 @@ _PySwigObject_type(void) {
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_subclasses */
0, /* tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
@ -703,17 +757,20 @@ _PySwigObject_type(void) {
0,0,0,0 /* tp_alloc -> tp_next */
#endif
};
pyswigobject_type = tmp;
pyswigobject_type.ob_type = &PyType_Type;
swigpyobject_type = tmp;
/* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */
#if PY_VERSION_HEX < 0x03000000
swigpyobject_type.ob_type = &PyType_Type;
#endif
type_init = 1;
}
return &pyswigobject_type;
return &swigpyobject_type;
}
SWIGRUNTIME PyObject *
PySwigObject_New(void *ptr, swig_type_info *ty, int own)
SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
{
PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
if (sobj) {
sobj->ptr = ptr;
sobj->ty = ty;
@ -732,10 +789,10 @@ typedef struct {
void *pack;
swig_type_info *ty;
size_t size;
} PySwigPacked;
} SwigPyPacked;
SWIGRUNTIME int
PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
char result[SWIG_BUFFER_SIZE];
fputs("<Swig Packed ", fp);
@ -749,29 +806,29 @@ PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
}
SWIGRUNTIME PyObject *
PySwigPacked_repr(PySwigPacked *v)
SwigPyPacked_repr(SwigPyPacked *v)
{
char result[SWIG_BUFFER_SIZE];
if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
} else {
return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
}
}
SWIGRUNTIME PyObject *
PySwigPacked_str(PySwigPacked *v)
SwigPyPacked_str(SwigPyPacked *v)
{
char result[SWIG_BUFFER_SIZE];
if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
return PyString_FromFormat("%s%s", result, v->ty->name);
return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
} else {
return PyString_FromString(v->ty->name);
return SWIG_Python_str_FromChar(v->ty->name);
}
}
SWIGRUNTIME int
PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
{
size_t i = v->size;
size_t j = w->size;
@ -782,22 +839,22 @@ PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
SWIGRUNTIME PyTypeObject*
PySwigPacked_type(void) {
SwigPyPacked_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
return type;
}
SWIGRUNTIMEINLINE int
PySwigPacked_Check(PyObject *op) {
SwigPyPacked_Check(PyObject *op) {
return ((op)->ob_type == _PySwigPacked_type())
|| (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
|| (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
}
SWIGRUNTIME void
PySwigPacked_dealloc(PyObject *v)
SwigPyPacked_dealloc(PyObject *v)
{
if (PySwigPacked_Check(v)) {
PySwigPacked *sobj = (PySwigPacked *) v;
if (SwigPyPacked_Check(v)) {
SwigPyPacked *sobj = (SwigPyPacked *) v;
free(sobj->pack);
}
PyObject_DEL(v);
@ -806,28 +863,37 @@ PySwigPacked_dealloc(PyObject *v)
SWIGRUNTIME PyTypeObject*
_PySwigPacked_type(void) {
static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
static PyTypeObject pyswigpacked_type;
static PyTypeObject swigpypacked_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp
= {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX>=0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
(char *)"PySwigPacked", /* tp_name */
sizeof(PySwigPacked), /* tp_basicsize */
0, /* ob_size */
#endif
(char *)"SwigPyPacked", /* tp_name */
sizeof(SwigPyPacked), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)PySwigPacked_dealloc, /* tp_dealloc */
(printfunc)PySwigPacked_print, /* tp_print */
(destructor)SwigPyPacked_dealloc, /* tp_dealloc */
(printfunc)SwigPyPacked_print, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)PySwigPacked_compare, /* tp_compare */
(reprfunc)PySwigPacked_repr, /* tp_repr */
0, /* tp_as_number */
#if PY_VERSION_HEX>=0x03000000
0, /* tp_reserved in 3.0.1 */
#else
(cmpfunc)SwigPyPacked_compare, /* tp_compare */
#endif
(reprfunc)SwigPyPacked_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)PySwigPacked_str, /* tp_str */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)SwigPyPacked_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -866,17 +932,20 @@ _PySwigPacked_type(void) {
0,0,0,0 /* tp_alloc -> tp_next */
#endif
};
pyswigpacked_type = tmp;
pyswigpacked_type.ob_type = &PyType_Type;
swigpypacked_type = tmp;
/* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */
#if PY_VERSION_HEX < 0x03000000
swigpypacked_type.ob_type = &PyType_Type;
#endif
type_init = 1;
}
return &pyswigpacked_type;
return &swigpypacked_type;
}
SWIGRUNTIME PyObject *
PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
{
PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
if (sobj) {
void *pack = malloc(size);
if (pack) {
@ -893,10 +962,10 @@ PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
}
SWIGRUNTIME swig_type_info *
PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
{
if (PySwigPacked_Check(obj)) {
PySwigPacked *sobj = (PySwigPacked *)obj;
if (SwigPyPacked_Check(obj)) {
SwigPyPacked *sobj = (SwigPyPacked *)obj;
if (sobj->size != size) return 0;
memcpy(ptr, sobj->pack, size);
return sobj->ty;
@ -912,7 +981,7 @@ PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
SWIGRUNTIMEINLINE PyObject *
_SWIG_This(void)
{
return PyString_FromString("this");
return SWIG_Python_str_FromChar("this");
}
SWIGRUNTIME PyObject *
@ -924,11 +993,16 @@ SWIG_This(void)
/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
SWIGRUNTIME PySwigObject *
/* TODO: I don't know how to implement the fast getset in Python 3 right now */
#if PY_VERSION_HEX>=0x03000000
#define SWIG_PYTHON_SLOW_GETSET_THIS
#endif
SWIGRUNTIME SwigPyObject *
SWIG_Python_GetSwigThis(PyObject *pyobj)
{
if (PySwigObject_Check(pyobj)) {
return (PySwigObject *) pyobj;
if (SwigPyObject_Check(pyobj)) {
return (SwigPyObject *) pyobj;
} else {
PyObject *obj = 0;
#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
@ -964,12 +1038,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
return 0;
}
#endif
if (obj && !PySwigObject_Check(obj)) {
if (obj && !SwigPyObject_Check(obj)) {
/* a PyObject is called 'this', try to get the 'real this'
PySwigObject from it */
SwigPyObject from it */
return SWIG_Python_GetSwigThis(obj);
}
return (PySwigObject *)obj;
return (SwigPyObject *)obj;
}
}
@ -978,7 +1052,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
sobj->own = own;
@ -997,7 +1071,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (ptr) *ptr = 0;
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
if (own)
*own = 0;
while (sobj) {
@ -1011,7 +1085,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
} else {
swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
if (!tc) {
sobj = (PySwigObject *)sobj->next;
sobj = (SwigPyObject *)sobj->next;
} else {
if (ptr) {
int newmemory = 0;
@ -1040,7 +1114,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
} else {
int res = SWIG_ERROR;
if (flags & SWIG_POINTER_IMPLICIT_CONV) {
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
if (data && !data->implicitconv) {
PyObject *klass = data->klass;
if (klass) {
@ -1053,7 +1127,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
impconv = 0;
}
if (impconv) {
PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
if (iobj) {
void *vptr;
res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
@ -1115,7 +1189,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
if (!to) return SWIG_ERROR;
if (ty) {
if (to != ty) {
@ -1137,7 +1211,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
*/
SWIGRUNTIME PyObject*
SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
{
#if (PY_VERSION_HEX >= 0x02020000)
PyObject *inst = 0;
@ -1161,10 +1235,16 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
#endif
}
} else {
#if PY_VERSION_HEX >= 0x03000000
inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
PyObject_SetAttr(inst, SWIG_This(), swig_this);
Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
#else
PyObject *dict = PyDict_New();
PyDict_SetItem(dict, SWIG_This(), swig_this);
inst = PyInstance_NewRaw(data->newargs, dict);
Py_DECREF(dict);
#endif
}
return inst;
#else
@ -1227,9 +1307,9 @@ SWIG_Python_InitShadowInstance(PyObject *args) {
if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
return NULL;
} else {
PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
if (sthis) {
PySwigObject_append((PyObject*) sthis, obj[1]);
SwigPyObject_append((PyObject*) sthis, obj[1]);
} else {
SWIG_Python_SetSwigThis(obj[0], obj[1]);
}
@ -1245,8 +1325,8 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
return SWIG_Py_Void();
} else {
int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
PyObject *robj = PySwigObject_New(ptr, type, own);
PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
PyObject *robj = SwigPyObject_New(ptr, type, own);
SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
if (inst) {
@ -1262,7 +1342,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
SWIGRUNTIMEINLINE PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
}
/* -----------------------------------------------------------------------------*
@ -1333,8 +1413,8 @@ SWIG_Python_DestroyModule(void *vptr)
for (i =0; i < swig_module->size; ++i) {
swig_type_info *ty = types[i];
if (ty->owndata) {
PySwigClientData *data = (PySwigClientData *) ty->clientdata;
if (data) PySwigClientData_Del(data);
SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
if (data) SwigPyClientData_Del(data);
}
}
Py_DECREF(SWIG_This());
@ -1344,8 +1424,13 @@ SWIGRUNTIME void
SWIG_Python_SetModule(swig_module_info *swig_module) {
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
#if PY_VERSION_HEX >= 0x03000000
/* Add a dummy module object into sys.modules */
PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
#else
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
swig_empty_runtime_method_table);
#endif
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
if (pointer && module) {
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
@ -1365,7 +1450,7 @@ SWIGRUNTIME swig_type_info *
SWIG_Python_TypeQuery(const char *type)
{
PyObject *cache = SWIG_Python_TypeCache();
PyObject *key = PyString_FromString(type);
PyObject *key = SWIG_Python_str_FromChar(type);
PyObject *obj = PyDict_GetItem(cache, key);
swig_type_info *descriptor;
if (obj) {
@ -1392,21 +1477,23 @@ SWIG_Python_TypeQuery(const char *type)
SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
char *tmp;
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
} else {
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
}
SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
}
return 1;
@ -1429,9 +1516,9 @@ SWIG_Python_ArgFail(int argnum)
}
SWIGRUNTIMEINLINE const char *
PySwigObject_GetDesc(PyObject *self)
SwigPyObject_GetDesc(PyObject *self)
{
PySwigObject *v = (PySwigObject *)self;
SwigPyObject *v = (SwigPyObject *)self;
swig_type_info *ty = v ? v->ty : 0;
return ty ? ty->str : (char*)"";
}
@ -1441,10 +1528,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
#if defined(SWIG_COBJECT_TYPES)
if (obj && PySwigObject_Check(obj)) {
const char *otype = (const char *) PySwigObject_GetDesc(obj);
if (obj && SwigPyObject_Check(obj)) {
const char *otype = (const char *) SwigPyObject_GetDesc(obj);
if (otype) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
type, otype);
return;
}
@ -1454,10 +1541,11 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? PyString_AsString(str) : 0;
const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
SWIG_Python_str_DelForPy3(cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
@ -1479,10 +1567,12 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
#if SWIG_POINTER_EXCEPTION
if (flags) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
#endif
}
return result;
}

View file

@ -46,7 +46,7 @@ namespace swig {
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0;
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}

View file

@ -5,10 +5,28 @@
SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
{
if (PyString_Check(obj)) {
%#if PY_VERSION_HEX>=0x03000000
if (PyUnicode_Check(obj))
%#else
if (PyString_Check(obj))
%#endif
{
char *cstr; Py_ssize_t len;
%#if PY_VERSION_HEX>=0x03000000
if (!alloc && cptr) {
/* We can't allow converting without allocation, since the internal
representation of string in Python 3 is UCS-2/UCS-4 but we require
a UTF-8 representation.
TODO(bhy) More detailed explanation */
return SWIG_RuntimeError;
}
obj = PyUnicode_AsUTF8String(obj);
PyBytes_AsStringAndSize(obj, &cstr, &len);
if(alloc) *alloc = SWIG_NEWOBJ;
%#else
PyString_AsStringAndSize(obj, &cstr, &len);
if (cptr) {
%#endif
if (cptr) {
if (alloc) {
/*
In python the user should not be able to modify the inner
@ -33,10 +51,16 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
*alloc = SWIG_OLDOBJ;
}
} else {
*cptr = PyString_AsString(obj);
%#if PY_VERSION_HEX>=0x03000000
assert(0); /* Should never reach here in Python 3 */
%#endif
*cptr = SWIG_Python_str_AsChar(obj);
}
}
if (psize) *psize = len + 1;
%#if PY_VERSION_HEX>=0x03000000
Py_XDECREF(obj);
%#endif
return SWIG_OK;
} else {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
@ -64,7 +88,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
return pchar_descriptor ?
SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
%#if PY_VERSION_HEX >= 0x03000000
return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
%#else
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
%#endif
}
} else {
return SWIG_Py_Void();

View file

@ -88,7 +88,7 @@
if ($result) {
PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL);
if (robj && !PyErr_Occurred()) {
PySwigObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
(PyObject *) SWIG_Python_GetSwigThis(robj));
Py_DECREF(robj);
}

View file

@ -8,14 +8,16 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
{
PyObject *tmp = 0;
int isunicode = PyUnicode_Check(obj);
%#if PY_VERSION_HEX < 0x03000000
if (!isunicode && PyString_Check(obj)) {
if (cptr) {
obj = tmp = PyUnicode_FromObject(obj);
}
isunicode = 1;
}
%#endif
if (isunicode) {
int len = PyUnicode_GetSize(obj);
Py_ssize_t len = PyUnicode_GetSize(obj);
if (cptr) {
*cptr = %new_array(len + 1, wchar_t);
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);

View file

@ -17,7 +17,7 @@ namespace swig {
%extend std::carray {
%fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
fragment="PySwigIterator_T",
fragment="SwigPyIterator_T",
fragment=SWIG_Traits_frag(_Type),
fragment="StdCarrayTraits") {
namespace swig {
@ -36,7 +36,7 @@ namespace swig {
%typemap(out,noblock=1) iterator, const_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
inline size_t __len__() const { return self->size(); }
@ -46,7 +46,7 @@ namespace swig {
inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) {
swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
}

View file

@ -5,12 +5,12 @@
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class PySeq, class K, class T >
template <class SwigPySeq, class K, class T >
inline void
assign(const PySeq& pyseq, std::map<K,T > *map) {
assign(const SwigPySeq& swigpyseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
typename PySeq::const_iterator it = pyseq.begin();
for (;it != pyseq.end(); ++it) {
typename SwigPySeq::const_iterator it = swigpyseq.begin();
for (;it != swigpyseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
@ -21,7 +21,11 @@
static int asptr(PyObject *obj, map_type **val) {
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL);
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
%#if PY_VERSION_HEX >= 0x03000000
/* In Python 3.x the ".items()" method return a dict_items object */
items = PySequence_Fast(items, ".items() havn't returned a sequence!");
%#endif
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
@ -54,8 +58,8 @@
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
swig::PyObject_var key = swig::from(i->first);
swig::PyObject_var val = swig::from(i->second);
swig::SwigVar_PyObject key = swig::from(i->first);
swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
@ -86,10 +90,10 @@
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
struct PyMapIterator_T : PySwigIteratorClosed_T<OutIterator, ValueType, FromOper>
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
{
PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: PySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
@ -97,37 +101,37 @@
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
struct PyMapKeyIterator_T : PyMapIterator_T<OutIterator, FromOper>
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline PySwigIterator*
inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new PyMapKeyIterator_T<OutIter>(current, begin, end, seq);
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
struct PyMapValueIterator_T : PyMapIterator_T<OutIterator, FromOper>
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline PySwigIterator*
inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new PyMapValueIterator_T<OutIter>(current, begin, end, seq);
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
}
}
}
@ -218,12 +222,12 @@
}
%newobject key_iterator(PyObject **PYTHON_SELF);
swig::PySwigIterator* key_iterator(PyObject **PYTHON_SELF) {
swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
%newobject value_iterator(PyObject **PYTHON_SELF);
swig::PySwigIterator* value_iterator(PyObject **PYTHON_SELF) {
swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}

View file

@ -6,12 +6,12 @@
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class PySeq, class K, class T >
template <class SwigPySeq, class K, class T >
inline void
assign(const PySeq& pyseq, std::multimap<K,T > *multimap) {
assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) {
typedef typename std::multimap<K,T>::value_type value_type;
typename PySeq::const_iterator it = pyseq.begin();
for (;it != pyseq.end(); ++it) {
typename SwigPySeq::const_iterator it = swigpyseq.begin();
for (;it != swigpyseq.end(); ++it) {
multimap->insert(value_type(it->first, it->second));
}
}
@ -22,7 +22,7 @@
static int asptr(PyObject *obj, std::multimap<K,T> **val) {
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL);
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
@ -55,8 +55,8 @@
}
PyObject *obj = PyDict_New();
for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) {
swig::PyObject_var key = swig::from(i->first);
swig::PyObject_var val = swig::from(i->second);
swig::SwigVar_PyObject key = swig::from(i->first);
swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;

View file

@ -7,13 +7,13 @@
%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
template <class PySeq, class T>
template <class SwigPySeq, class T>
inline void
assign(const PySeq& pyseq, std::multiset<T>* seq) {
// seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented
typedef typename PySeq::value_type value_type;
typename PySeq::const_iterator it = pyseq.begin();
for (;it != pyseq.end(); ++it) {
assign(const SwigPySeq& swigpyseq, std::multiset<T>* seq) {
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
typedef typename SwigPySeq::value_type value_type;
typename SwigPySeq::const_iterator it = swigpyseq.begin();
for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}

View file

@ -42,8 +42,8 @@
}
} else if (PySequence_Check(obj)) {
if (PySequence_Size(obj) == 2) {
swig::PyObject_var first = PySequence_GetItem(obj,0);
swig::PyObject_var second = PySequence_GetItem(obj,1);
swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
res = get_pair(first, second, val);
}
} else {
@ -92,8 +92,8 @@
}
} else if (PySequence_Check(obj)) {
if (PySequence_Size(obj) == 2) {
swig::PyObject_var first = PySequence_GetItem(obj,0);
swig::PyObject_var second = PySequence_GetItem(obj,1);
swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
res = get_pair(first, second, val);
}
} else {

View file

@ -5,13 +5,13 @@
%fragment("StdSetTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
template <class PySeq, class T>
template <class SwigPySeq, class T>
inline void
assign(const PySeq& pyseq, std::set<T>* seq) {
// seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented
typedef typename PySeq::value_type value_type;
typename PySeq::const_iterator it = pyseq.begin();
for (;it != pyseq.end(); ++it) {
assign(const SwigPySeq& swigpyseq, std::set<T>* seq) {
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
typedef typename SwigPySeq::value_type value_type;
typename SwigPySeq::const_iterator it = swigpyseq.begin();
for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}