Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2324be428
commit
f2f1b9889f
112 changed files with 3262 additions and 3375 deletions
|
|
@ -16,14 +16,14 @@ SWIG_AsArgcArgv(PyObject* input,
|
|||
list = PyList_Check(input);
|
||||
if (list || PyTuple_Check(input)) {
|
||||
*argc = list ? PyList_Size(input) : PyTuple_Size(input);
|
||||
argv = SWIG_new_array(*argc + 1, char*);
|
||||
argv = %new_array(*argc + 1, char*);
|
||||
*owner = 1;
|
||||
for (; i < *argc; ++i) {
|
||||
PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i);
|
||||
char *cptr = 0; size_t size = 0; int alloc = 0;
|
||||
if (SWIG_AsCharPtrAndSize(obj, &cptr, &size, &alloc) == SWIG_OK) {
|
||||
if (cptr && size) {
|
||||
argv[i] = (alloc == SWIG_NEWOBJ) ? cptr : SWIG_new_copy_array(cptr, size, char);
|
||||
argv[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, size, char);
|
||||
} else {
|
||||
argv[i] = 0;
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ SWIG_AsArgcArgv(PyObject* input,
|
|||
argv = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &owner);
|
||||
if (!argv) {
|
||||
$1 = 0; $2 = 0;
|
||||
SWIG_arg_fail(SWIG_TypeError, "int ARGC, char **ARGV", $argnum);
|
||||
%argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $argnum);
|
||||
} else {
|
||||
$1 = ($1_ltype) argc;
|
||||
$2 = ($2_ltype) argv;
|
||||
|
|
@ -69,9 +69,9 @@ SWIG_AsArgcArgv(PyObject* input,
|
|||
if (owner$argnum) {
|
||||
size_t i = argc$argnum;
|
||||
while (i) {
|
||||
SWIG_delete_array(argv$argnum[--i]);
|
||||
%delete_array(argv$argnum[--i]);
|
||||
}
|
||||
SWIG_delete_array(argv$argnum);
|
||||
%delete_array(argv$argnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@
|
|||
NOTE: remember that if the type contains commas, such as
|
||||
'std::pair<int,int>', you need to use the macro like:
|
||||
|
||||
%attribute_ref(A, SWIG_arg(std::pair<int,int>), pval);
|
||||
%attribute_ref(A, %arg(std::pair<int,int>), pval);
|
||||
|
||||
where SWIG_arg() 'normalize' the type to be understood as a single
|
||||
where %arg() 'normalize' the type to be understood as a single
|
||||
argument, otherwise the macro will get confused (see the 'cpp'
|
||||
documentation).
|
||||
|
||||
|
|
@ -115,10 +115,10 @@
|
|||
%ignore Class::get;
|
||||
#if #__VA_ARGS__ != ""
|
||||
%ignore Class::__VA_ARGS__;
|
||||
%_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
|
||||
%_attribute(%arg(Class), Wrap, %arg(type),
|
||||
attr, _t->get(), _t->__VA_ARGS__(_val))
|
||||
#else
|
||||
%_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
|
||||
%_attribute(%arg(Class), Wrap, %arg(type),
|
||||
attr, _t->get(),
|
||||
fprintf(stderr,"'attr' is a read-only attribute"))
|
||||
#endif
|
||||
|
|
@ -127,15 +127,15 @@
|
|||
%define %_attribute_ref_T(Class, Wrap, type, refname, attr)
|
||||
%ignore Class::refname();
|
||||
%ignore Class::refname() const;
|
||||
%_attribute(SWIG_arg(Class), Wrap, SWIG_arg(type),
|
||||
%_attribute(%arg(Class), Wrap, %arg(type),
|
||||
attr, _t->refname(), _t->refname() = _val)
|
||||
%enddef
|
||||
|
||||
%define %attribute_ref_T(Class, Wrap, type, refname, ...)
|
||||
#if #__VA_ARGS__ == ""
|
||||
%_attribute_ref_T(SWIG_arg(Class), Wrap, SWIG_arg(type), refname, refname)
|
||||
%_attribute_ref_T(%arg(Class), Wrap, %arg(type), refname, refname)
|
||||
#else
|
||||
%_attribute_ref_T(SWIG_arg(Class), Wrap, SWIG_arg(type), refname, __VA_ARGS__)
|
||||
%_attribute_ref_T(%arg(Class), Wrap, %arg(type), refname, __VA_ARGS__)
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
|
|
@ -144,9 +144,9 @@
|
|||
//
|
||||
|
||||
%define %attribute(Class, type, attr, get, ...)
|
||||
%attribute_T(SWIG_arg(Class), SWIG_Mangle(Class), SWIG_arg(type), attr, get, __VA_ARGS__)
|
||||
%attribute_T(%arg(Class), %mangle(Class), %arg(type), attr, get, __VA_ARGS__)
|
||||
%enddef
|
||||
|
||||
%define %attribute_ref(Class, type, refname, ...)
|
||||
%attribute_ref_T(SWIG_arg(Class), SWIG_Mangle(Class), SWIG_arg(type), refname, __VA_ARGS__)
|
||||
%attribute_ref_T(%arg(Class), %mangle(Class), %arg(type), refname, __VA_ARGS__)
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@
|
|||
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
|
||||
|
||||
/* declaring the typemaps */
|
||||
%typemap_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
|
||||
%typemap_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
|
||||
%typemap_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
|
||||
|
|
|
|||
|
|
@ -1,10 +1 @@
|
|||
%include <typemaps/cstring.swg>
|
||||
%include <pystrings.swg>
|
||||
|
||||
%typemap_cstrings(%cstring,
|
||||
char,
|
||||
SWIG_AsCharPtr,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtr,
|
||||
SWIG_FromCharPtrAndSize);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
%include <typemaps/cstring.swg>
|
||||
%include <pywstrings.swg>
|
||||
|
||||
%typemap_cstrings(%cwstring,
|
||||
wchar_t,
|
||||
SWIG_AsWCharPtr,
|
||||
SWIG_AsWCharPtrAndSize,
|
||||
SWIG_FromWCharPtr,
|
||||
SWIG_FromWCharPtrAndSize);
|
||||
%include <typemaps/cwstring.swg>
|
||||
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ SWIG_AsFilePtr(PyObject *obj) {
|
|||
}
|
||||
|
||||
/* defining the typemaps */
|
||||
%typemap_asval(SWIG_CCode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
|
||||
%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ typedef struct swig_const_info {
|
|||
* Append a value to the result obj
|
||||
* ----------------------------------------------------------------------------- */
|
||||
SWIGINTERN PyObject*
|
||||
SWIG_Python_AppendResult(PyObject* result, PyObject* obj) {
|
||||
SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
|
||||
if (!result) {
|
||||
result = obj;
|
||||
} else if (result == Py_None) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
%fragment(SWIG_From_frag(Type),"header")
|
||||
{
|
||||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From(Type)(SWIG_cplusplus(const Type&, Type) c)
|
||||
SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
|
||||
{
|
||||
return PyComplex_FromDoubles(Real(c), Imag(c));
|
||||
}
|
||||
|
|
@ -46,7 +46,6 @@ SWIG_AsVal(Type) (PyObject *o, Type* val)
|
|||
/* the float case */
|
||||
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
|
||||
%fragment(SWIG_AsVal_frag(Type),"header",
|
||||
fragment="SWIG_CheckDoubleInRange",
|
||||
fragment=SWIG_AsVal_frag(float)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal(Type)(PyObject *o, Type *val)
|
||||
|
|
@ -55,11 +54,11 @@ SWIG_AsVal(Type)(PyObject *o, Type *val)
|
|||
double re = PyComplex_RealAsDouble(o);
|
||||
double im = PyComplex_ImagAsDouble(o);
|
||||
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
|
||||
if (val) *val = Constructor(SWIG_numeric_cast(re, float),
|
||||
SWIG_numeric_cast(im, float));
|
||||
if (val) *val = Constructor(%numeric_cast(re, float),
|
||||
%numeric_cast(im, float));
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_TypeError;
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
} else {
|
||||
float re;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace swig
|
|||
char msg[1024];
|
||||
snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
|
||||
if (!PyErr_Occurred()) {
|
||||
SWIG_type_error(swig::type_name<T>());
|
||||
%type_error(swig::type_name<T>());
|
||||
}
|
||||
SWIG_Python_AddErrorMsg(msg);
|
||||
SWIG_Python_AddErrorMsg(e.what());
|
||||
|
|
@ -371,7 +371,7 @@ namespace swig
|
|||
%enddef
|
||||
|
||||
%define %swig_sequence_methods_common(Sequence...)
|
||||
%swig_container_methods(SWIG_arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
%fragment("PySequence_Base");
|
||||
|
||||
%extend {
|
||||
|
|
@ -402,7 +402,7 @@ namespace swig
|
|||
%enddef
|
||||
|
||||
%define %swig_sequence_methods(Sequence...)
|
||||
%swig_sequence_methods_common(SWIG_arg(Sequence))
|
||||
%swig_sequence_methods_common(%arg(Sequence))
|
||||
%extend {
|
||||
const value_type& __getitem__(difference_type i) const throw (std::out_of_range) {
|
||||
return *(swig::cgetpos(self, i));
|
||||
|
|
@ -419,7 +419,7 @@ namespace swig
|
|||
%enddef
|
||||
|
||||
%define %swig_sequence_methods_val(Sequence...)
|
||||
%swig_sequence_methods_common(SWIG_arg(Sequence))
|
||||
%swig_sequence_methods_common(%arg(Sequence))
|
||||
%extend {
|
||||
value_type __getitem__(difference_type i) throw (std::out_of_range) {
|
||||
return *(swig::cgetpos(self, i));
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
|
|||
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
|
||||
break;
|
||||
case SWIG_PY_BINARY:
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype), 0);
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
|
||||
break;
|
||||
default:
|
||||
obj = 0;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,3 @@
|
|||
%include <typemaps/primtypes.swg>
|
||||
|
||||
/* Macro for 'signed long' derived types */
|
||||
|
||||
%define %type_slong(Type, Frag, Min, Max)
|
||||
%derived_type_from(long, Type)
|
||||
%signed_derived_type_asval(long, Type, Frag, Min, Max)
|
||||
%enddef
|
||||
|
||||
/* Macro for 'unsigned long' derived types */
|
||||
|
||||
%define %type_ulong(Type, Frag, Max)
|
||||
%derived_type_from(unsigned long, Type)
|
||||
%unsigned_derived_type_asval(unsigned long, Type, Frag, Max)
|
||||
%enddef
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Primitive Types
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
@ -50,33 +34,11 @@ SWIG_AsVal_dec(bool)(PyObject *obj, bool *val)
|
|||
}
|
||||
}
|
||||
|
||||
/* signed/unsigned char */
|
||||
|
||||
%type_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
|
||||
%type_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
|
||||
|
||||
/* short/unsigned short */
|
||||
|
||||
%type_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
|
||||
%type_ulong(unsigned short, "<limits.h>", USHRT_MAX)
|
||||
|
||||
/* int/unsigned int */
|
||||
|
||||
%type_slong(int, "<limits.h>", INT_MIN, INT_MAX)
|
||||
%type_ulong(unsigned int, "<limits.h>", UINT_MAX)
|
||||
|
||||
/* signed/unsigned wchar_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
%type_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
|
||||
%type_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
|
||||
#endif
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header",
|
||||
fragment="<limits.h>") {
|
||||
SWIG_define(SWIG_From_dec(long), PyInt_FromLong)
|
||||
%define_as(SWIG_From_dec(long), PyInt_FromLong)
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
|
|
@ -107,7 +69,7 @@ SWIGINTERNINLINE PyObject*
|
|||
SWIG_From_dec(unsigned long)(unsigned long value)
|
||||
{
|
||||
return (value > LONG_MAX) ?
|
||||
PyLong_FromUnsignedLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
|
||||
PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +107,7 @@ SWIGINTERNINLINE PyObject*
|
|||
SWIG_From_dec(long long)(long long value)
|
||||
{
|
||||
return ((value < LONG_MIN) || (value > LONG_MAX)) ?
|
||||
PyLong_FromLongLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
|
||||
PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +140,7 @@ SWIGINTERNINLINE PyObject*
|
|||
SWIG_From_dec(unsigned long long)(unsigned long long value)
|
||||
{
|
||||
return (value > LONG_MAX) ?
|
||||
PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(SWIG_numeric_cast(value,long));
|
||||
PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,15 +167,10 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
|
|||
}
|
||||
}
|
||||
|
||||
/* float */
|
||||
|
||||
%derived_type_from(double, float)
|
||||
%signed_derived_type_asval(double, float, "<float.h>", -FLT_MAX, FLT_MAX)
|
||||
|
||||
/* double */
|
||||
|
||||
%fragment(SWIG_From_frag(double),"header") {
|
||||
SWIG_define(SWIG_From_dec(double), PyFloat_FromDouble)
|
||||
%define_as(SWIG_From_dec(double), PyFloat_FromDouble)
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(double),"header") {
|
||||
|
|
@ -239,70 +196,5 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val)
|
|||
}
|
||||
}
|
||||
|
||||
/* char */
|
||||
|
||||
%fragment(SWIG_From_frag(char),"header") {
|
||||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From_dec(char)(char c)
|
||||
{
|
||||
return PyString_FromStringAndSize(&c,1);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(char),"header",
|
||||
fragment="SWIG_AsCharArray",
|
||||
fragment=SWIG_AsVal_frag(signed char)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(char)(PyObject *obj, char *val)
|
||||
{
|
||||
if (SWIG_AsCharArray(obj, val, 1) == SWIG_OK) {
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
signed char v;
|
||||
int res = SWIG_AsVal(signed char)(obj, &v);
|
||||
if (res == SWIG_OK && val) *val = (char)(v);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* wchar_t */
|
||||
|
||||
|
||||
%fragment(SWIG_From_frag(wchar_t),"header") {
|
||||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From_dec(wchar_t)(wchar_t c)
|
||||
{
|
||||
return PyUnicode_FromWideChar(&c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(wchar_t),"header",
|
||||
fragment="SWIG_AsWCharArray",
|
||||
fragment=SWIG_AsVal_frag(long)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(wchar_t)(PyObject *obj, wchar_t *val)
|
||||
{
|
||||
if (SWIG_AsWCharArray(obj, val, 1) == SWIG_OK) {
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
long v;
|
||||
int res = SWIG_AsVal(long)(obj, &v);
|
||||
if (res == SWIG_OK) {
|
||||
if (WCHAR_MIN <= v && v <= WCHAR_MAX) {
|
||||
if (val) *val = (wchar_t)(v);
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Apply the primitive typemap for all the types with checkcode
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%apply_checkctypes(%typemap_primitive)
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@
|
|||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
|
||||
|
||||
/* for raw packed data */
|
||||
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
|
||||
#define SWIG_NewPackedObj(ptr, sz, type, flags) SWIG_Python_NewPackedObj(ptr, sz, type)
|
||||
#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
|
||||
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
|
||||
|
||||
/* for class or struct pointers */
|
||||
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
|
||||
|
||||
/* for C or C++ function pointers */
|
||||
#define SWIG_ConvertFunctionPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertPtr(obj, pptr, type, 0)
|
||||
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
|
||||
|
||||
/* for C++ member pointers, ie, member methods */
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
|
||||
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
|
||||
|
||||
|
||||
|
|
@ -504,7 +504,7 @@ SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)
|
|||
|
||||
/* Convert a packed value value */
|
||||
SWIGRUNTIME int
|
||||
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
|
||||
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
|
||||
swig_cast_info *tc;
|
||||
const char *c = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace swig {
|
|||
if ((res != 0) && p) {
|
||||
typedef typename noconst_traits<Type>::noconst_type noconst_type;
|
||||
*(const_cast<noconst_type*>(val)) = *p;
|
||||
if (res == SWIG_NEWOBJ) SWIG_delete(p);
|
||||
if (res == SWIG_NEWOBJ) %delete(p);
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
|
|
@ -114,7 +114,7 @@ namespace swig {
|
|||
Type v;
|
||||
if (!obj || (asval(obj, &v) != SWIG_OK)) {
|
||||
if (!PyErr_Occurred()) {
|
||||
SWIG_type_error(swig::type_name<Type>());
|
||||
%type_error(swig::type_name<Type>());
|
||||
}
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ namespace swig {
|
|||
if (res && v) {
|
||||
if (res == SWIG_NEWOBJ) {
|
||||
Type r(*v);
|
||||
SWIG_delete(v);
|
||||
%delete(v);
|
||||
return r;
|
||||
} else {
|
||||
return *v;
|
||||
|
|
@ -139,7 +139,7 @@ namespace swig {
|
|||
// Uninitialized return value, no Type() constructor required.
|
||||
static Type *v_def = (Type*) malloc(sizeof(Type));
|
||||
if (!PyErr_Occurred()) {
|
||||
SWIG_type_error(swig::type_name<Type>());
|
||||
%type_error(swig::type_name<Type>());
|
||||
}
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
memset(v_def,0,sizeof(Type));
|
||||
|
|
@ -157,7 +157,7 @@ namespace swig {
|
|||
return v;
|
||||
} else {
|
||||
if (!PyErr_Occurred()) {
|
||||
SWIG_type_error(swig::type_name<Type>());
|
||||
%type_error(swig::type_name<Type>());
|
||||
}
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
return 0;
|
||||
|
|
@ -252,8 +252,8 @@ namespace swig {
|
|||
%enddef
|
||||
|
||||
|
||||
#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_list(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
|
|||
if (*alloc == SWIG_NEWOBJ)
|
||||
#endif
|
||||
{
|
||||
*cptr = SWIG_new_copy_array(cstr, len + 1, char);
|
||||
*cptr = %new_copy_array(cstr, len + 1, char);
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
}
|
||||
else {
|
||||
|
|
@ -60,10 +60,10 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
|||
{
|
||||
if (carray) {
|
||||
if (size > INT_MAX) {
|
||||
return SWIG_NewPointerObj(SWIG_const_cast(carray,char *),
|
||||
return SWIG_NewPointerObj(%const_cast(carray,char *),
|
||||
SWIG_TypeQuery("char *"), 0);
|
||||
} else {
|
||||
return PyString_FromStringAndSize(carray, SWIG_numeric_cast(size,int));
|
||||
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
|
||||
}
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
|
|
@ -72,9 +72,4 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* The plain char * handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemap_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
%include <typemaps/swigtype.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* --- Consttab --- needed for callbacks, it should be removed later.
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
*/
|
||||
|
||||
#warning "Deprecated file: Don't use t_output_helper anymore,"
|
||||
#warning "use SWIG_Python_AppendResult or SWIG_append_result instead."
|
||||
#warning "use SWIG_Python_AppendOutput or %append_output instead."
|
||||
|
|
|
|||
|
|
@ -16,37 +16,30 @@
|
|||
* Basic definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define_swig_object(PyObject *)
|
||||
#define SWIG_Object PyObject *
|
||||
#define VOID_Object (Py_INCREF(Py_None) ? Py_None : 0)
|
||||
|
||||
#define SWIG_VoidObject() (Py_INCREF(Py_None) ? Py_None : 0)
|
||||
#define SWIG_SetResultObj(obj) $result = obj
|
||||
#define SWIG_AppendResultObj(obj) $result = SWIG_Python_AppendResult($result, obj)
|
||||
#define SWIG_SetConstantObj(name, obj) SWIG_block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
|
||||
#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
|
||||
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
|
||||
#define SWIG_AppendOutput(result,obj) SWIG_Python_AppendOutput(result, obj)
|
||||
#define SWIG_SetConstant(name, obj) %block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
|
||||
#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
|
||||
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/exception.swg>
|
||||
%include <pyswigtype.swg>
|
||||
%include <typemaps/void.swg>
|
||||
%include <typemaps/valtypes.swg>
|
||||
%include <typemaps/ptrtypes.swg>
|
||||
%include <typemaps/swigobject.swg>
|
||||
%include <typemaps/inoutlist.swg>
|
||||
%include <pyprimtypes.swg>
|
||||
%include <pystrings.swg>
|
||||
%include <typemaps/misctypes.swg>
|
||||
%include <typemaps/enumint.swg>
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* fix for callbacks */
|
||||
%include <pyswigtype.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Backward compatibility output helper
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%fragment("t_output_helper","header") %{
|
||||
#define t_output_helper SWIG_Python_AppendResult
|
||||
#define t_output_helper SWIG_Python_AppendOutput
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
|||
if (isunicode) {
|
||||
int len = PyUnicode_GetSize(obj);
|
||||
if (cptr) {
|
||||
*cptr = SWIG_new_array(len + 1, wchar_t);
|
||||
*cptr = %new_array(len + 1, wchar_t);
|
||||
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
|
||||
(*cptr)[len] = 0;
|
||||
}
|
||||
|
|
@ -45,10 +45,10 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
|
|||
{
|
||||
if (carray) {
|
||||
if (size > INT_MAX) {
|
||||
return SWIG_NewPointerObj(SWIG_const_cast(carray,wchar_t *),
|
||||
return SWIG_NewPointerObj(%const_cast(carray,wchar_t *),
|
||||
SWIG_TypeQuery("wchar_t *"), 0);
|
||||
} else {
|
||||
return PyUnicode_FromWideChar(carray, SWIG_numeric_cast(size,int));
|
||||
return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
|
||||
}
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
|
|
@ -57,10 +57,4 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* The plain wchar_t * handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemap_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val)
|
|||
if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
|
||||
if (buf) {
|
||||
if (val) *val = new std::string(buf, size - 1);
|
||||
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
|
||||
if (alloc == SWIG_NEWOBJ) %delete_array(buf);
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -47,7 +47,7 @@ SWIGINTERNINLINE PyObject*
|
|||
}
|
||||
|
||||
%include <std/std_basic_string.i>
|
||||
%typemap_asptrfromn(SWIG_CCode(STRING), std::basic_string<char>);
|
||||
%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ SWIGINTERN int
|
|||
if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
|
||||
if (buf) {
|
||||
if (val) *val = new std::wstring(buf, size - 1);
|
||||
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
|
||||
if (alloc == SWIG_NEWOBJ) %delete_array(buf);
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -94,6 +94,6 @@ SWIGINTERNINLINE PyObject*
|
|||
}
|
||||
}
|
||||
|
||||
%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::basic_string<wchar_t>);
|
||||
%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
%include <pycomplex.swg>
|
||||
|
||||
|
||||
|
||||
%{
|
||||
#include <complex>
|
||||
%}
|
||||
|
|
@ -17,6 +19,8 @@
|
|||
std::complex<float>, std::real, std::imag)
|
||||
|
||||
|
||||
%typemap_primitive(SWIG_CCode(CPLXDBL), std::complex<double>);
|
||||
%typemap_primitive(SWIG_CCode(CPLXFLT), std::complex<float>);
|
||||
%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
|
||||
%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@
|
|||
T *pfirst = 0;
|
||||
U *psecond = 0;
|
||||
if (val) {
|
||||
*val = SWIG_new(std::pair<T,U>);
|
||||
*val = %new_instance(std::pair<T,U>);
|
||||
pfirst = &((*val)->first);
|
||||
psecond = &((*val)->second);
|
||||
}
|
||||
if ((swig::asval(first,pfirst) == SWIG_OK) && (swig::asval(second,psecond) == SWIG_OK)) {
|
||||
return SWIG_NEWOBJ;
|
||||
} else {
|
||||
SWIG_delete(*val);
|
||||
%delete(*val);
|
||||
}
|
||||
} else {
|
||||
value_type *p;
|
||||
|
|
|
|||
|
|
@ -1,30 +1 @@
|
|||
//
|
||||
// std::string
|
||||
//
|
||||
|
||||
#ifndef SWIG_STD_BASIC_STRING
|
||||
#define SWIG_STD_STRING
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
class string;
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
%include <pystrings.swg>
|
||||
|
||||
%std_string_asptr(std::string, char, SWIG_AsCharPtrAndSize)
|
||||
%std_string_from(std::string, SWIG_FromCharPtrAndSize)
|
||||
%std_string_asval(std::string)
|
||||
|
||||
%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
|
||||
|
||||
#else
|
||||
|
||||
%include <std/std_string.i>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,31 +1,3 @@
|
|||
//
|
||||
// std::wstring
|
||||
//
|
||||
|
||||
#ifndef SWIG_STD_BASIC_STRING
|
||||
#define SWIG_STD_WSTRING
|
||||
|
||||
%{
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
class wstring;
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
%include <pywstrings.swg>
|
||||
%include <typemaps/std_wstring.swg>
|
||||
|
||||
%std_string_asptr(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize)
|
||||
%std_string_from(std::wstring, SWIG_FromWCharPtrAndSize)
|
||||
%std_string_asval(std::wstring)
|
||||
|
||||
%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::wstring);
|
||||
|
||||
#else
|
||||
|
||||
%include <std/std_wstring.i>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue