merge revisions 11243-11872 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12162 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
ab1cd03979
387 changed files with 12383 additions and 4412 deletions
|
|
@ -6,18 +6,23 @@
|
|||
#define SHARED_PTR_DISOWN 0
|
||||
#endif
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE
|
||||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Feature to adapt the code generated in the swigregister functions for smart pointers
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ namespace Swig {
|
|||
try {
|
||||
throw;
|
||||
} catch (DirectorException& e) {
|
||||
std::cerr << "Swig Director exception caught:" << std::endl
|
||||
std::cerr << "SWIG Director exception caught:" << std::endl
|
||||
<< e.getMessage() << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
||||
|
|
@ -273,12 +273,12 @@ namespace Swig {
|
|||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
||||
public:
|
||||
DirectorTypeMismatchException(PyObject *error, const char* msg="")
|
||||
: Swig::DirectorException(error, "Swig director type mismatch", msg)
|
||||
: Swig::DirectorException(error, "SWIG director type mismatch", msg)
|
||||
{
|
||||
}
|
||||
|
||||
DirectorTypeMismatchException(const char* msg="")
|
||||
: Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg)
|
||||
: Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ namespace Swig {
|
|||
class DirectorMethodException : public Swig::DirectorException {
|
||||
public:
|
||||
DirectorMethodException(const char* msg = "")
|
||||
: DirectorException(PyExc_RuntimeError, "Swig director method error.", msg)
|
||||
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ namespace Swig {
|
|||
{
|
||||
public:
|
||||
DirectorPureVirtualException(const char* msg = "")
|
||||
: DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg)
|
||||
: DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,15 +279,15 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
|||
}
|
||||
}
|
||||
if (ci) {
|
||||
size_t shift = (ci->ptype) - types;
|
||||
swig_type_info *ty = types_initial[shift];
|
||||
size_t ldoc = (c - methods[i].ml_doc);
|
||||
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
|
||||
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
||||
if (ndoc) {
|
||||
char *buff = ndoc;
|
||||
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
|
||||
if (ptr) {
|
||||
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
|
||||
if (ptr) {
|
||||
size_t shift = (ci->ptype) - types;
|
||||
swig_type_info *ty = types_initial[shift];
|
||||
size_t ldoc = (c - methods[i].ml_doc);
|
||||
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
|
||||
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
||||
if (ndoc) {
|
||||
char *buff = ndoc;
|
||||
strncpy(buff, methods[i].ml_doc, ldoc);
|
||||
buff += ldoc;
|
||||
strncpy(buff, "swig_ptr: ", 10);
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
|||
int newmemory = 0;
|
||||
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
|
||||
if (newmemory == SWIG_CAST_NEW_MEMORY) {
|
||||
assert(own);
|
||||
assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
|
||||
if (own)
|
||||
*own = *own | SWIG_CAST_NEW_MEMORY;
|
||||
}
|
||||
|
|
@ -1160,10 +1160,10 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
|
|||
/* here we get the method pointer for callbacks */
|
||||
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
|
||||
const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
|
||||
if (desc) {
|
||||
if (desc)
|
||||
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
|
||||
if (!desc) return SWIG_ERROR;
|
||||
}
|
||||
if (!desc)
|
||||
return SWIG_ERROR;
|
||||
if (ty) {
|
||||
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
|
||||
if (tc) {
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@
|
|||
typedef std::map<K,T> map_type;
|
||||
static int asptr(PyObject *obj, map_type **val) {
|
||||
int res = SWIG_ERROR;
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
if (PyDict_Check(obj)) {
|
||||
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!");
|
||||
/* In Python 3.x the ".items()" method returns a dict_items object */
|
||||
items = PySequence_Fast(items, ".items() didn't return a sequence!");
|
||||
%#endif
|
||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
|
|
@ -32,6 +33,7 @@
|
|||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
|
@ -47,10 +49,10 @@
|
|||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
size_type size = map.size();
|
||||
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
|
|
@ -62,6 +64,7 @@
|
|||
swig::SwigVar_PyObject val = swig::from(i->second);
|
||||
PyDict_SetItem(obj, key, val);
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
@ -165,8 +168,8 @@
|
|||
PyObject* keys() {
|
||||
Map::size_type size = self->size();
|
||||
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
|
|
@ -177,14 +180,15 @@
|
|||
for (int j = 0; j < pysize; ++i, ++j) {
|
||||
PyList_SET_ITEM(keyList, j, swig::from(i->first));
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return keyList;
|
||||
}
|
||||
|
||||
PyObject* values() {
|
||||
Map::size_type size = self->size();
|
||||
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
|
|
@ -195,14 +199,15 @@
|
|||
for (int j = 0; j < pysize; ++i, ++j) {
|
||||
PyList_SET_ITEM(valList, j, swig::from(i->second));
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return valList;
|
||||
}
|
||||
|
||||
PyObject* items() {
|
||||
Map::size_type size = self->size();
|
||||
int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1;
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
|
|
@ -213,6 +218,7 @@
|
|||
for (int j = 0; j < pysize; ++i, ++j) {
|
||||
PyList_SET_ITEM(itemList, j, swig::from(*i));
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return itemList;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue