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:
Marcelo Matus 2005-10-24 14:59:05 +00:00
commit f2f1b9889f
112 changed files with 3262 additions and 3375 deletions

View file

@ -1,16 +1,54 @@
Still in developing, but if you are interested into looking around,
start with
swigtypemaps.swg
which is the head file. Also read the docs for %fragments in
fragments.swg
and follow the definitions in one of the supported languages:
python, perl, ruby, tcl
/* -----------------------------------------------------------------------------
* Internal typemap specializations
* ----------------------------------------------------------------------------- */
enumint.swg enum especializations as int types
inoutlist.swg return the OUTPUT types in a list
misctypes.swg Miscellaneos types (size_t, ptrdiff_t, etc)
primtypes.swg Macros to manage primitive types (shot,int,double,etc)
ptrtypes.swg Typemaps for types with a 'ptr' behavior
strings.swg String base typemaps
cstring.swg Various forms of C character string handling
swigobject.swg Language object, such as PyObject, Tcl_Obj, etc
swigtype.swg SWIGTYPE
valtypes.swg Typemaps for types with a 'by value' behavior
void.swg void * typemaps
carrays.swg Implement the carrays.i library
cdata.swg Implement the cdata.i library
cmalloc.swg Implement the cmalloc.i library
cpointer.swg Implement the cpointer.i library
cstring.swg Implement the cstring.i library typemaps for char *
cwstring.swg Implement the cstring.i library typemaps for wchar_t *
exception.swg Implement the exception.i library
implicit.swg Allow the use of implicit C++ constructors
string.swg Typemaps for char * string
wstring.swg Typemaps for wchar_t * string
std_string.swg Typemaps for std::string
std_wstring.swg Typemaps for std::wstring
swigtype.swg Typemaps for the SWIGTYPE type
void.swg Typemaps for the 'void' type
enumint.swg Typemaps for enums treated as 'int'
swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc.
misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc)
ptrtypes.swg Typemaps for types with a 'ptr' behavior
valtypes.swg Typemaps for 'by value' types
inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list
primtypes.swg Common macros to manage primitive types (short,int,double,etc)
cstrings.swg Common macros to implemented the cstring/cwstring libraries
std_strings.swg Common macros to implemented the std::string/std::wstring typemaps
strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *)
swigmacros.swg Basic macros
fragments.swg Macros for fragment manipulations
typemaps.swg The old typemaps.i library, not needed anymore

View file

@ -25,11 +25,11 @@
%define %array_functions(TYPE,NAME)
%{
static TYPE *new_##NAME(size_t nelements) {
return SWIG_new_array(nelements, TYPE);
return %new_array(nelements, TYPE);
}
static void delete_##NAME(TYPE *ary) {
SWIG_delete_array(ary);
%delete_array(ary);
}
static TYPE NAME##_getitem(TYPE *ary, size_t index) {
@ -82,11 +82,11 @@ typedef struct NAME {
%extend NAME {
NAME(size_t nelements) {
return SWIG_new_array(nelements, TYPE);
return %new_array(nelements, TYPE);
}
~NAME() {
SWIG_delete_array(self);
%delete_array(self);
}
TYPE getitem(size_t index) {
@ -102,7 +102,7 @@ typedef struct NAME {
}
static NAME *frompointer(TYPE *t) {
return SWIG_static_cast(t, NAME *);
return %static_cast(t, NAME *);
}
};

View file

@ -20,7 +20,7 @@ typedef struct SWIGCDATA {
* ----------------------------------------------------------------------------- */
%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA {
$result = SWIG_FromCharPtrAndSize($1.data,$1.len);
%set_output(SWIG_FromCharPtrAndSize($1.data,$1.len));
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE);

View file

@ -55,10 +55,10 @@ typedef struct {
%extend NAME {
NAME() {
return SWIG_new(TYPE);
return %new_instance(TYPE);
}
~NAME() {
if (self) SWIG_delete(self);
if (self) %delete(self);
}
}
@ -109,15 +109,15 @@ typedef struct {
%define %pointer_functions(TYPE,NAME)
%{
static TYPE *new_##NAME() {
return SWIG_new(TYPE);
return %new_instance(TYPE);
}
static TYPE *copy_##NAME(TYPE value) {
return SWIG_new_copy(value, TYPE);
return %new_copy(value, TYPE);
}
static void delete_##NAME(TYPE *self) {
if (self) SWIG_delete(self);
if (self) %delete(self);
}
static void NAME ##_assign(TYPE *self, TYPE value) {
@ -146,7 +146,7 @@ TYPE NAME##_value(TYPE *self);
%define %pointer_cast(TYPE1,TYPE2,NAME)
%inline %{
TYPE2 NAME(TYPE1 x) {
return SWIG_static_cast(x, TYPE2);
return %static_cast(x, TYPE2);
}
%}
%enddef

View file

@ -1,275 +1,9 @@
/*
* cstring.i
* $Header$
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This file provides typemaps and macros for dealing with various forms
* of C character string handling. The primary use of this module
* is in returning character data that has been allocated or changed in
* some way.
*/
%include <typemaps/cstrings.swg>
%define %typemap_cstrings(Name, Char,
SWIG_AsCharPtr,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtr,
SWIG_FromCharPtrAndSize)
/* %cstring_input_binary(TYPEMAP, SIZE)
*
* Macro makes a function accept binary string data along with
* a size. For example:
*
* %cstring_input_binary(Char *buff, int size);
* void foo(Char *buff, int size) {
* }
*
*/
%define Name ## _input_binary(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
(Char *buf = 0, size_t size = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
}
%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
%enddef
/*
* %cstring_bounded_output(TYPEMAP, MAX)
*
* This macro is used to return a NULL-terminated output string of
* some maximum length. For example:
*
* %cstring_bounded_output(Char *outx, 512);
* void foo(Char *outx) {
* sprintf(outx,"blah blah\n");
* }
*
*/
%define Name ## _bounded_output(TYPEMAP,MAX)
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
$1[MAX] = 0;
SWIG_append_result(SWIG_FromCharPtr($1));
}
%enddef
/*
* %cstring_chunk_output(TYPEMAP, SIZE)
*
* This macro is used to return a chunk of binary string data.
* Embedded NULLs are okay. For example:
*
* %cstring_chunk_output(Char *outx, 512);
* void foo(Char *outx) {
* memmove(outx, somedata, 512);
* }
*
*/
%define Name ## _chunk_output(TYPEMAP,SIZE)
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
SWIG_append_result(SWIG_FromCharPtrAndSize($1,SIZE));
}
%enddef
/*
* %cstring_bounded_mutable(TYPEMAP, SIZE)
*
* This macro is used to wrap a string that's going to mutate.
*
* %cstring_bounded_mutable(Char *in, 512);
* void foo(in *x) {
* while (*x) {
* *x = toupper(*x);
* x++;
* }
* }
*
*/
%define Name ## _bounded_mutable(TYPEMAP,MAX)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "TYPEMAP", $argnum);
}
if ( n > (size_t) MAX ) n = (size_t) MAX;
memcpy(temp, t, sizeof(Char)*n);
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(t);
temp[n - 1] = 0;
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
$1[MAX] = 0;
SWIG_append_result(SWIG_FromCharPtr($1));
}
%enddef
/*
* %cstring_mutable(TYPEMAP [, expansion])
*
* This macro is used to wrap a string that will mutate in place.
* It may change size up to a user-defined expansion.
*
* %cstring_mutable(Char *in);
* void foo(in *x) {
* while (*x) {
* *x = toupper(*x);
* x++;
* }
* }
*
*/
%define Name ## _mutable(TYPEMAP,EXP...)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
#if #EXP != ""
expansion += EXP;
#endif
if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "TYPEMAP", $argnum);
}
$1 = SWIG_new_array(n+expansion, $*1_ltype);
memcpy($1,t,sizeof(Char)*n);
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(t);
$1[n-1] = 0;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
SWIG_append_result(SWIG_FromCharPtr($1));
SWIG_delete_array($1);
}
%enddef
/*
* %cstring_output_maxsize(TYPEMAP, SIZE)
*
* This macro returns data in a string of some user-defined size.
*
* %cstring_output_maxsize(Char *outx, int max) {
* void foo(Char *outx, int max) {
* sprintf(outx,"blah blah\n");
* }
*/
%define Name ## _output_maxsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long size) {
if (SWIG_AsVal(unsigned long)($input, &size) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$2 = SWIG_numeric_cast(size, $2_ltype);
$1 = SWIG_new_array(size+1, $*1_ltype);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
SWIG_append_result(SWIG_FromCharPtr($1));
SWIG_delete_array($1);
}
%enddef
/*
* %cstring_output_withsize(TYPEMAP, SIZE)
*
* This macro is used to return Character data along with a size
* parameter.
*
* %cstring_output_maxsize(Char *outx, int *max) {
* void foo(Char *outx, int *max) {
* sprintf(outx,"blah blah\n");
* *max = strlen(outx);
* }
*/
%define Name ## _output_withsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_As_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long n) {
if (SWIG_AsVal(unsigned long)($input, &n) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$1 = SWIG_new_array(n+1, $*1_ltype);
$2 = SWIG_new($*2_ltype);
*$2 = SWIG_numeric_cast(n, $*2_ltype);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
SWIG_append_result(SWIG_FromCharPtrAndSize($1,*$2));
SWIG_delete_array($1);
SWIG_delete($2);
}
%enddef
/*
* %cstring_output_allocate(TYPEMAP, RELEASE)
*
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, free($1));
* void foo(Char **outx) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");
* }
*/
%define Name ## _output_allocate(TYPEMAP, RELEASE)
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
$1 = &temp;
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
if (*$1) {
SWIG_append_result(SWIG_FromCharPtr(*$1));
RELEASE;
}
}
%enddef
/*
* %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
*
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, int *sz, free($1));
* void foo(Char **outx, int *sz) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");
* *sz = strlen(outx);
* }
*/
%define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE)
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
$1 = &temp; $2 = &tempn;
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
if (*$1) {
SWIG_append_result(SWIG_FromCharPtrAndSize(*$1,*$2));
RELEASE;
}
}
%enddef
%enddef
%typemaps_cstring(%cstring,
char,
SWIG_AsCharPtr,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtr,
SWIG_FromCharPtrAndSize);

View file

@ -0,0 +1,280 @@
/*
* cstring.i
* $Header$
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This file provides typemaps and macros for dealing with various forms
* of C character string handling. The primary use of this module
* is in returning character data that has been allocated or changed in
* some way.
*/
%define %typemaps_cstring(Name, Char,
SWIG_AsCharPtr,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtr,
SWIG_FromCharPtrAndSize)
/* %cstring_input_binary(TYPEMAP, SIZE)
*
* Macro makes a function accept binary string data along with
* a size. For example:
*
* %cstring_input_binary(Char *buff, int size);
* void foo(Char *buff, int size) {
* }
*
*/
%define Name ## _input_binary(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE)
(Char *buf = 0, size_t size = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$1 = ($1_ltype) buf;
$2 = ($2_ltype) size - 1;
}
%typemap(freearg,noblock=1) (TYPEMAP, SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
%enddef
/*
* %cstring_bounded_output(TYPEMAP, MAX)
*
* This macro is used to return a NULL-terminated output string of
* some maximum length. For example:
*
* %cstring_bounded_output(Char *outx, 512);
* void foo(Char *outx) {
* sprintf(outx,"blah blah\n");
* }
*
*/
%define Name ## _bounded_output(TYPEMAP,MAX)
%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP {
$1[MAX] = 0;
%append_output(SWIG_FromCharPtr($1));
}
%enddef
/*
* %cstring_chunk_output(TYPEMAP, SIZE)
*
* This macro is used to return a chunk of binary string data.
* Embedded NULLs are okay. For example:
*
* %cstring_chunk_output(Char *outx, 512);
* void foo(Char *outx) {
* memmove(outx, somedata, 512);
* }
*
*/
%define Name ## _chunk_output(TYPEMAP,SIZE)
%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) {
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP {
%append_output(SWIG_FromCharPtrAndSize($1,SIZE));
}
%enddef
/*
* %cstring_bounded_mutable(TYPEMAP, SIZE)
*
* This macro is used to wrap a string that's going to mutate.
*
* %cstring_bounded_mutable(Char *in, 512);
* void foo(in *x) {
* while (*x) {
* *x = toupper(*x);
* x++;
* }
* }
*
*/
%define Name ## _bounded_mutable(TYPEMAP,MAX)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) {
if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
}
if ( n > (size_t) MAX ) n = (size_t) MAX;
memcpy(temp, t, sizeof(Char)*n);
if (alloc == SWIG_NEWOBJ) %delete_array(t);
temp[n - 1] = 0;
$1 = ($1_ltype) temp;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
$1[MAX] = 0;
%append_output(SWIG_FromCharPtr($1));
}
%enddef
/*
* %cstring_mutable(TYPEMAP [, expansion])
*
* This macro is used to wrap a string that will mutate in place.
* It may change size up to a user-defined expansion.
*
* %cstring_mutable(Char *in);
* void foo(in *x) {
* while (*x) {
* *x = toupper(*x);
* x++;
* }
* }
*
*/
%define Name ## _mutable(TYPEMAP,EXP...)
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP
(Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) {
#if #EXP != ""
expansion += EXP;
#endif
if (SWIG_AsCharPtrAndSize($input, &t, &n, &alloc) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "TYPEMAP", $argnum);
}
$1 = %new_array(n+expansion, $*1_ltype);
memcpy($1,t,sizeof(Char)*n);
if (alloc == SWIG_NEWOBJ) %delete_array(t);
$1[n-1] = 0;
}
%typemap(freearg,noblock=1) TYPEMAP "";
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
%append_output(SWIG_FromCharPtr($1));
%delete_array($1);
}
%enddef
/*
* %cstring_output_maxsize(TYPEMAP, SIZE)
*
* This macro returns data in a string of some user-defined size.
*
* %cstring_output_maxsize(Char *outx, int max) {
* void foo(Char *outx, int max) {
* sprintf(outx,"blah blah\n");
* }
*/
%define Name ## _output_maxsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long size) {
if (SWIG_AsVal(unsigned long)($input, &size) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$2 = %numeric_cast(size, $2_ltype);
$1 = %new_array(size+1, $*1_ltype);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) {
%append_output(SWIG_FromCharPtr($1));
%delete_array($1);
}
%enddef
/*
* %cstring_output_withsize(TYPEMAP, SIZE)
*
* This macro is used to return Character data along with a size
* parameter.
*
* %cstring_output_maxsize(Char *outx, int *max) {
* void foo(Char *outx, int *max) {
* sprintf(outx,"blah blah\n");
* *max = strlen(outx);
* }
*/
%define Name ## _output_withsize(TYPEMAP, SIZE)
%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(unsigned long)) (TYPEMAP, SIZE) (unsigned long n) {
if (SWIG_AsVal(unsigned long)($input, &n) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "(TYPEMAP, SIZE)", $argnum);
}
$1 = %new_array(n+1, $*1_ltype);
$2 = %new_instance($*2_ltype);
*$2 = %numeric_cast(n, $*2_ltype);
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) {
%append_output(SWIG_FromCharPtrAndSize($1,*$2));
%delete_array($1);
%delete($2);
}
%enddef
/*
* %cstring_output_allocate(TYPEMAP, RELEASE)
*
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, free($1));
* void foo(Char **outx) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");
* }
*/
%define Name ## _output_allocate(TYPEMAP, RELEASE)
%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) {
$1 = &temp;
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP {
if (*$1) {
%append_output(SWIG_FromCharPtr(*$1));
RELEASE;
}
}
%enddef
/*
* %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
*
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, int *sz, free($1));
* void foo(Char **outx, int *sz) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");
* *sz = strlen(outx);
* }
*/
%define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE)
%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
$1 = &temp; $2 = &tempn;
}
%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) {
if (*$1) {
%append_output(SWIG_FromCharPtrAndSize(*$1,*$2));
RELEASE;
}
}
%enddef
%enddef

View file

@ -0,0 +1,10 @@
%include <typemaps/cstrings.swg>
%include <typemaps/wstring.swg>
%typemaps_cstring(%cwstring,
wchar_t,
SWIG_AsWCharPtr,
SWIG_AsWCharPtrAndSize,
SWIG_FromWCharPtr,
SWIG_FromWCharPtrAndSize);

View file

@ -8,20 +8,20 @@
%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
ecode = SWIG_AsVal(int)($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$basetype", $argnum);
%argument_fail(ecode, "$type", $argnum);
} else {
temp = SWIG_static_cast(val,$basetype);
temp = %static_cast(val,$basetype);
$1 = &temp;
}
}
%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
if (sizeof(int) != sizeof($1)) {
SWIG_var_fail(SWIG_AttributeError,"$type", "$name");
%variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name");
} else {
int ecode = SWIG_AsVal(int)($input, SWIG_reinterpret_cast(&$1,int*));
int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*));
if (ecode != SWIG_OK) {
SWIG_var_fail(ecode, "$type", "$name");
%variable_fail(ecode, "$type", "$name");
}
}
}
@ -29,18 +29,18 @@
/*
typemaps needed due to unnamed enums
*/
%define SWIG_ENUM_OUT_TYPEMAPS(from_meth,frag)
%define %enum_out_typemaps(from_meth,frag)
%typemap(out,noblock=1,fragment=frag) enum SWIGTYPE {
$result = from_meth(($1));
%set_output(from_meth(($1)));
}
%typemap(out,noblock=1,fragment=frag) const enum SWIGTYPE& {
$result = from_meth((*$1));
%set_output(from_meth((*$1)));
}
%typemap(varout,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
$result = from_meth($1);
%set_varoutput(from_meth($1));
}
%typemap(constcode,noblock=1,fragment=frag) enum SWIGTYPE {
SWIG_set_constant("$symname", from_meth($value));
%set_constant("$symname", from_meth($value));
}
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE *DIRECTORIN {
$input = from_meth(*$1_name);
@ -49,11 +49,11 @@
$input = from_meth($1_name);
}
%typemap(throws,noblock=1,fragment=frag) enum SWIGTYPE {
SWIG_raise(from_meth($1),"$type",0);
%raise(from_meth($1),"$type",0);
}
%enddef
SWIG_ENUM_OUT_TYPEMAPS(SWIG_From(int),SWIG_From_frag(int));
%enum_out_typemaps(SWIG_From(int),SWIG_From_frag(int));

View file

@ -1,13 +1,29 @@
// This SWIG library file provides language independent exception handling
%include <typemaps/swigmacros.swg>
/* macros for error manipulation */
#define %nullref_fmt() "invalid null reference "
#define %varfail_fmt(_type,_name) "in variable '"_name"' of type '"_type"'"
#define %argfail_fmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
#define %outfail_fmt(_type) "in output value of type '"_type"'"
#define %argnullref_fmt(_type, _argn) %nullref_fmt() %argfail_fmt(_type, _argn)
#define %varnullref_fmt(_type, _name) %nullref_fmt() %varfail_fmt(_type, _name)
#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type)
/* setting an error */
#define %error(code,msg...) SWIG_Error(code, msg)
#define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
%insert("runtime") {
SWIG_define(SWIG_exception(code, msg),
SWIG_block(SWIG_error(code, msg); SWIG_fail))
%define_as(SWIG_exception(code, msg),
%block(%error(code, msg); SWIG_fail))
SWIG_define(SWIG_contract_assert(expr, msg),
if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else)
%define_as(SWIG_contract_assert(expr, msg),
if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else)
}

View file

@ -0,0 +1,143 @@
/*
Special macros to define and use fragment names and declarations.
These macros generate the names used in fragments, for example, a
typical use will be:
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNINLINE PyObject*
SWIG_From_dec(bool)(bool value)
{
PyObject *obj = value ? Py_True : Py_False;
Py_INCREF(obj);
return obj;
}
}
and then you can call the method using
%typemap(out,fragment=SWIG_From_frag(bool)) bool {
%set_output(SWIG_From(bool)($1));
}
when the typemap get generated, the proper fragment for the
SWIG_From(bool) method will be included.
*/
#define SWIG_Traits_frag(Type...) %string_type(Traits, Type)
#define SWIG_AsPtr_frag(Type...) %string_type(AsPtr, Type)
#define SWIG_AsVal_frag(Type...) %string_type(AsVal, Type)
#define SWIG_From_frag(Type...) %string_type(From, Type)
#ifndef SWIG_ASVAL_DECL_ARGS
#define SWIG_ASVAL_DECL_ARGS
#endif
#ifndef SWIG_ASPTR_DECL_ARGS
#define SWIG_ASPTR_DECL_ARGS
#endif
#ifndef SWIG_FROM_DECL_ARGS
#define SWIG_FROM_DECL_ARGS
#endif
#ifndef SWIG_ASVAL_CALL_ARGS
#define SWIG_ASVAL_CALL_ARGS
#endif
#ifndef SWIG_ASPTR_CALL_ARGS
#define SWIG_ASPTR_CALL_ARGS
#endif
#ifndef SWIG_FROM_CALL_ARGS
#define SWIG_FROM_CALL_ARGS
#endif
#define SWIG_AsVal_dec(Type...) %name_type(AsVal, Type) SWIG_ASVAL_DECL_ARGS
#define SWIG_AsPtr_dec(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_DECL_ARGS
#define SWIG_From_dec(Type...) %name_type(From, Type) SWIG_FROM_DECL_ARGS
#define SWIG_AsVal(Type...) %name_type(AsVal, Type) SWIG_ASVAL_CALL_ARGS
#define SWIG_AsPtr(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_CALL_ARGS
#define SWIG_From(Type...) %name_type(From, Type) SWIG_FROM_CALL_ARGS
/* ------------------------------------------------------------
* common macro helpers
* ------------------------------------------------------------ */
/* Macros for numeric types */
%define %numeric_type_from(Type, Base)
%fragment(SWIG_From_frag(Type),"header",
fragment=SWIG_From_frag(Base)) {
SWIGINTERNINLINE SWIG_Object
SWIG_From_dec(Type)(Type value)
{
return SWIG_From(Base)(value);
}
}
%enddef
%define %numeric_type_asval(Type, Base, Frag, OverflowCond)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=Frag,
fragment=SWIG_AsVal_frag(Base)) {
SWIGINTERN int
SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
{
Base v;
int res = SWIG_AsVal(Base)(obj, &v);
if (res == SWIG_OK) {
if (OverflowCond) {
return SWIG_OverflowError;
} else {
if (val) *val = %numeric_cast(v, Type);
return SWIG_OK;
}
}
return res;
}
}
%enddef
%define %numeric_signed_type_asval(Type, Base, Frag, Min, Max)
%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max))
%enddef
%define %numeric_unsigned_type_asval(Type, Base, Frag, Max)
%numeric_type_asval(Type, Base, Frag, (v > Max))
%enddef
/* Macro for 'signed long' derived types */
%define %numeric_slong(Type, Frag, Min, Max)
%numeric_type_from(Type, long)
%numeric_signed_type_asval(Type, long, Frag , Min, Max)
%enddef
/* Macro for 'unsigned long' derived types */
%define %numeric_ulong(Type, Frag, Max)
%numeric_type_from(Type, unsigned long)
%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max)
%enddef
/* Macro for 'double' derived types */
%define %numeric_double(Type, Frag, Min, Max)
%numeric_type_from(Type, double)
%numeric_signed_type_asval(Type, double, Frag , Min, Max)
%enddef

View file

@ -0,0 +1,289 @@
/*
Fragments:
==========
Second to typemaps, fragments is one the most powerfull and
dangerous swig feature. So, if you are starting to read about them,
make sure you read all the document.
Basics:
=======
Fragments provide a way to include or generate code into "on-demand"
as the typemaps could require.
For example, if you have a very long typemap
%typemap(in) MyClass * {
MyClass *value = 0;
<very long typemap>
....
value = somewhere_converted_from_input_object_here($input);
...
<very long typemap>
$result = value;
}
very soon you will discoverd yourself copying the same long
conversion code in several typemaps, such as varin, directorout,
etc. Also, you wil discover that swig copy verbatim the same very
long conversion code for every argument that requires it, making the
code very large too.
To eliminate this automatic or manual code copying, we define a
fragment that includes the common conversion code:
%fragment("AsMyClass","header") {
MyClass *AsMyClass(PyObject *obj) {
MyClass *value = 0;
<very long conversion>
....
value = somewhere_converted_from_input_object_here(obj);
...
<very long conversion>
return value;
}
}
%typemap(in,fragment="AsMyClass") MyClass * {
$result = AsMyClass($input);
}
%typemap(varin,fragment="AsMyClass") MyClass * {
$result = AsMyClass($input);
}
When the 'in' or 'varin' typemaps for MyClass are invoked, the
fragment "AsMyClass" is added to the "header" section, and then the
typemap code is emitted. Hence, the method AsMyClass will be
included in the wrapping code and it will be available at the time
the typemap is applied.
To define a fragment then you need a name, a section where it goes,
and the code. Usually the section refers to the "header" part, and
both string and braces forms are accepted, ie:
%fragment("my_name","header") { ... }
%fragment("my_name","header") "...";
To ensure all the fragment/typemap engine works as expected, there
are some rules that fragments follow:
1.- A fragment is added to the wrapping code only once, ie, for the
method:
int foo(MyClass *a, MyClass *b);
the wrapped code will look as much as:
MyClass *AsMyClass(PyObject *obj) {
.....
}
int _wrap_foo(...) {
....
arg1 = AsMyClass(obj1);
arg2 = AsMyClass(obj2);
...
result = foo(arg1, arg2);
}
even when there will be duplicated typemap to process 'a' and
'b', the 'AsMyClass' method will be defined only once.
2.- A fragment can only defined once, and the first definition
is the only one taking in account. All other definitions of the
same fragments are silently ignored. For example, you can have
%fragment("AsMyClass","header") { <definition 1> }
....
%fragment("AsMyClass","header") { <definition 2> }
and then only the first definition is considered. In this way
you can change the 'system' fragments by including yours first.
Note that this behavior is opposite to the typemaps, where the
last typemap applied or defined prevails. Fragment follows the
first-in-first-out convention since they are intended to be
"global", while typemaps intend to be "locally" specialyzed.
3.- Fragments names can not contain commas.
A fragment can include one or more additional fragments, for example:
%fragment("<limits.h>", "header") {
#include <limits.h>
}
%fragment("AsMyClass", "header", fragment="<limits.h>") {
MyClass *AsMyClass(PyObject *obj) {
MyClass *value = 0;
int ival = somewhere_converted_from_input_object_here(obj)
...
if (ival < CHAR_MIN) {
value = something_from_ival(ival);
} else {
...
}
...
return value;
}
}
in this case, when the "AsMyClass" fragment is emitted, it also
trigger the inclusion of the "<limits.h>" fragment.
You can add as many fragments as you want, for example
%fragment("bigfragment","header", fragment="frag1", fragment="frag2", fragment="frag3") "";
here, when the "bigfragment" is included, the three fragments "frag1",
"frag2" and "frag3" are included. Note that as "bigframent" is defined
empty, "", it does not add any code by itself, buy only trigger the
inclusion of the other fragments.
In a typemap you can also include more than one fragment, but since the
syntax is different, you need to specify them in a 'comma separated'
list, for example, considering the previous example:
%typemap(in,fragment="frag1,frag2,frag3") {...}
is equivalent to
%typemap(in,fragment="bigfragment") {...}
Fragment type specialization
============================
Fragments can be "type specialized". The syntax is as follows
%fragment("name","header") { a type independent fragment }
%fragment("name" {Type}, "header") {typethe dependent fragment }
and they can also, as typemaps, be used inside templates, for exampe:
template <class T>
struct A {
%fragment("incode"{A<T>},"header") {
'incode' specialized fragment
}
%typemap(in,fragment="incode"{A<T>}) {
here we use the 'type specialized'
fragment "incode"{A<T>}
}
};
which could seems a not much interesting feature, but is
fundamental for automatic typemap and template specialization.
Fragments and automatic typemap specialozation:
===============================================
Since fragments can be type specialized, they can be elegantly used
to specialized typemaps .
For example, if you have something like:
%fragment("incode"{float}, "header") {
float in_mehtod_float(PyObject *obj) {
...
}
}
%fragment("incode"{long}, "header") {
float in_mehtod_long(PyObject *obj) {
...
}
}
%define %my_typemaps(Type)
%typemaps(in,fragment="incode"{Type}) {
value = in_method_##Type(obj);
}
%enddef
%my_typemaps(float);
%my_typemaps(long);
then the proper "incode"{float,double} fragment will be included,
and the proper in_method_{float,double} will be called.
Since this is a recurrent fragmen use, we provide a couple of
macros that make the automatic generation of typemaps easier:
Consider for example the following code:
%fragment(SWIG_From_frag(bool),"header") {
static PyObject*
SWIG_From_dec(bool)(bool value)
{
PyObject *obj = value ? Py_True : Py_False;
Py_INCREF(obj);
return obj;
}
}
%typemap(out,fragment=SWIG_From_frag(bool)) bool {
$result = SWIG_From(bool)($1));
}
Here the macros
SWIG_From_frag => fragment
SWIG_From_dec => declaration
SWIG_From => call
allow you to define/include a fragment, and declare and call the
'from-bool' method as needed. In the simpler case, these macros
just return something like
SWIG_From_frag(bool) => "SWIG_From_bool"
SWIG_From_dec(bool) => SWIG_From_bool
SWIG_From(bool) => SWIG_From_bool
But they are specialized for the different languages requirements,
such as perl or tcl that requires passing the interpreter pointer,
and also they can manage C++ ugly types, for example:
SWIG_From_frag(std::complex<double>) => "SWIG_From_std_complex_Sl_double_Sg_"
SWIG_From_dec(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
SWIG_From(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_
Hence, to declare methods to use with typemaps, always use the
SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr*
set of macros are provided.
*/
/* ------------------------------------------------------------
* common fragments
* ------------------------------------------------------------ */
%fragment("<limits.h>","header") %{
#include <limits.h>
%}
%fragment("<wchar.h>","header") %{
#include <wchar.h>
%}
%fragment("<float.h>","header") %{
#include <float.h>
%}

View file

@ -33,12 +33,10 @@
The plain implicit macro takes care of simple type list. If it doesn't
work because you are passing template types with commas, then use
the %implicit_{1,2,3} versions and/or the SWIG_arg macro.
the %implicit_{1,2,3} versions and/or the %arg macro.
*/
%check_swig_object()
%define %implicit_type(Type...)
%traits_swigtype(Type);
%enddef
@ -49,7 +47,7 @@
if (swig::asval<Type >(obj, 0) == SWIG_OK) {
Type _v;
swig::asval<Type >(obj, &_v);
if (val) *val = new value_type(_v);
if (val) *val = %new_copy(_v, value_type);
return SWIG_NEWOBJ;
}
%enddef
@ -86,7 +84,7 @@ namespace swig {
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
/* implicit_1 */
@ -121,7 +119,7 @@ namespace swig {
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
@ -159,7 +157,7 @@ namespace swig {
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef
@ -200,5 +198,5 @@ namespace swig {
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%typemap_traits_ptr(%checkcode(POINTER),Type);
%enddef

View file

@ -3,34 +3,29 @@
* Define the IN/OUTPUT typemaps assuming the output parameters are
* returned in a list, i.e., they are not directly modified.
*
* The user should provide the SWIG_append_result(result, obj) method,
* The user should provide the %append_output(result, obj) method,
* via a macro, which append a particular object to the result.
*
*
* In Tcl, for example, the file is used as:
*
* #define SWIG_append_result(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj);
* #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj);
* %include <typemaps/inoutlist.swg>
*
* while in Python it is used as:
*
* #define SWIG_append_result(obj) $result = SWIG_Python_AppendResult($result, obj)
* #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj)
* %include <typemaps/inoutlist.swg>
*
* where the method SWIG_Python_AppendResult is defined inside the
* SWIG_append_result fragment.
* %append_output fragment.
*
* If you forget to define SWIG_append_result, this file will generate
* If you forget to define %append_output, this file will generate
* an error.
*
* ------------------------------------------------------------ */
#ifndef SWIG_append_result
#error Undefined Method SWIG_append_result: used in the OUTPUT typemaps
#endif
//
// Uncomment the following definition if you don't want the in/out
// typemaps by default, ie, you prefer to use typemaps.i.
@ -76,60 +71,60 @@ or you can use the %apply directive :
*/
#ifdef SWIG_INPUT_ACCEPT_PTRS
#define SWIG_CheckInputPtr(input,arg,desc,disown) (SWIG_ConvertPtr(input,SWIG_as_voidptrptr(arg),desc,disown) == SWIG_OK)
#define %check_input_ptr(input,arg,desc,disown) (SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown) == SWIG_OK)
#else
#define SWIG_CheckInputPtr(input,arg,desc,disown) (0)
#define %check_input_ptr(input,arg,desc,disown) (0)
#endif
%define _SWIG_VALUE_INPUT_TYPEMAP(code, asval_meth, asval_frag, Type)
%define %_value_input_typemap(code, asval_meth, asval_frag, Type)
%typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) {
if (!SWIG_CheckInputPtr($input,&$1,$descriptor,$disown)) {
if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$*ltype",$argnum);
%argument_fail(ecode, "$*ltype",$argnum);
}
temp = SWIG_static_cast(val, $*ltype);
temp = %static_cast(val, $*ltype);
$1 = &temp;
res = SWIG_NEWOBJ;
}
}
%typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) {
if (!SWIG_CheckInputPtr($input,&$1,$descriptor,$disown)) {
if (!%check_input_ptr($input,&$1,$descriptor,$disown)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$*ltype",$argnum);
%argument_fail(ecode, "$*ltype",$argnum);
}
temp = SWIG_static_cast(val, $*ltype);
temp = %static_cast(val, $*ltype);
$1 = &temp;
res = SWIG_NEWOBJ;
}
}
%typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT {
void *ptr;
$1 = ((asval_meth($input, 0) == SWIG_OK) || (SWIG_CheckInputPtr($input,&ptr,$1_descriptor,0)));
$1 = ((asval_meth($input, 0) == SWIG_OK) || (%check_input_ptr($input,&ptr,$1_descriptor,0)));
}
%enddef
%define _SWIG_PTR_INPUT_TYPEMAP(code,asptr_meth,asptr_frag,Type)
%define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type)
%typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) {
res = asptr_meth($input, &$1);
if (!res) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
}
%typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) {
res = asptr_meth($input, &$1);
if (!res) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
if (!$1) {
SWIG_arg_nullref("$type",$argnum);
%argument_nullref("$type",$argnum);
}
}
%typemap(freearg,noblock=1) Type *INPUT, Type &INPUT {
if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
if (res$argnum == SWIG_NEWOBJ) %delete($1);
}
%typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT {
$1 = asptr_meth($input, (Type**)0) != 0;
@ -167,15 +162,18 @@ values.
*/
%define _SWIG_VALUE_OUTPUT_TYPEMAP(from_meth, from_frag, Type)
%define %_value_output_typemap(from_meth, from_frag, Type)
%typemap(in,numinputs=0,noblock=1)
Type *OUTPUT ($*1_ltype temp, int res = SWIG_NEWOBJ),
Type &OUTPUT ($*1_ltype temp, int res = SWIG_NEWOBJ) {
$1 = &temp;
}
%typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT {
SWIG_append_result(((res$argnum == SWIG_NEWOBJ) ?
from_meth((*$1)) : SWIG_NewPointerObj((void*)($1), $1_descriptor, 0)));
if (res$argnum == SWIG_NEWOBJ) {
%append_output(from_meth((*$1)));
} else {
%append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, 0));
}
}
%enddef
@ -218,7 +216,7 @@ phased out in future releases.
*/
%define _SWIG_VALUE_INOUT_TYPEMAP(Type)
%define %_value_inout_typemap(Type)
%typemap(in) Type *INOUT = Type *INPUT;
%typemap(in) Type &INOUT = Type &INPUT;
%typemap(typecheck) Type *INOUT = Type *INPUT;
@ -228,51 +226,51 @@ phased out in future releases.
%enddef
%define _SWIG_PTR_INOUT_TYPEMAP(Type)
_SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(Type))
%define %_ptr_inout_typemap(Type)
%_value_inout_typemap(%arg(Type))
%typemap(freearg) Type *INOUT = Type *INPUT;
%typemap(freearg) Type &INOUT = Type &INPUT;
%enddef
#ifndef SWIG_INOUT_NODEF
#define SWIG_VALUE_INPUT_TYPEMAP(code,_a,_af,...) \
_SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(code),SWIG_arg(_a), \
SWIG_arg(_af),SWIG_arg(__VA_ARGS__))
#define %value_input_typemap(code,_a,_af,...) \
%_value_input_typemap(%arg(code),%arg(_a), \
%arg(_af),%arg(__VA_ARGS__))
#define SWIG_PTR_INPUT_TYPEMAP(code,_a,_af,...) \
_SWIG_PTR_INPUT_TYPEMAP(SWIG_arg(code),SWIG_arg(_a),SWIG_arg(_af), \
SWIG_arg(__VA_ARGS__))
#define %ptr_input_typemap(code,_a,_af,...) \
%_ptr_input_typemap(%arg(code),%arg(_a),%arg(_af), \
%arg(__VA_ARGS__))
#define SWIG_VALUE_OUTPUT_TYPEMAP(_f,_ff,...) \
_SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(_f),SWIG_arg(_ff),SWIG_arg(__VA_ARGS__))
#define %value_output_typemap(_f,_ff,...) \
%_value_output_typemap(%arg(_f),%arg(_ff),%arg(__VA_ARGS__))
#define SWIG_VALUE_INOUT_TYPEMAP(...) _SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(__VA_ARGS__))
#define SWIG_PTR_INOUT_TYPEMAP(...) _SWIG_PTR_INOUT_TYPEMAP(SWIG_arg(__VA_ARGS__))
#define %value_inout_typemap(...) %_value_inout_typemap(%arg(__VA_ARGS__))
#define %ptr_inout_typemap(...) %_ptr_inout_typemap(%arg(__VA_ARGS__))
#else /* You need to include typemaps.i */
#define SWIG_VALUE_OUTPUT_TYPEMAP(...)
#define SWIG_VALUE_INPUT_TYPEMAP(...)
#define SWIG_VALUE_INOUT_TYPEMAP(...)
#define SWIG_PTR_INPUT_TYPEMAP(...)
#define SWIG_PTR_INOUT_TYPEMAP(...)
#define %value_output_typemap(...)
#define %value_input_typemap(...)
#define %value_inout_typemap(...)
#define %ptr_input_typemap(...)
#define %ptr_inout_typemap(...)
#endif /* SWIG_INOUT_DEFAULT */
%define %typemap_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...)
_SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(Code), SWIG_arg(AsValMeth),
SWIG_arg(AsValFrag), SWIG_arg(Type));
_SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), SWIG_arg(Type));
_SWIG_VALUE_INOUT_TYPEMAP(SWIG_arg(Type));
%define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...)
%_value_input_typemap(%arg(Code), %arg(AsValMeth),
%arg(AsValFrag), %arg(Type));
%_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type));
%_value_inout_typemap(%arg(Type));
%enddef
%define %typemap_inoutn(Code,Type...)
%typemap_inout(SWIG_arg(Code),
SWIG_arg(SWIG_AsVal(Type)),
SWIG_arg(SWIG_From(Type)),
SWIG_arg(SWIG_AsVal_frag(Type)),
SWIG_arg(SWIG_From_frag(Type)),
SWIG_arg(Type));
%define %typemaps_inoutn(Code,Type...)
%typemaps_inout(%arg(Code),
%arg(SWIG_AsVal(Type)),
%arg(SWIG_From(Type)),
%arg(SWIG_AsVal_frag(Type)),
%arg(SWIG_From_frag(Type)),
%arg(Type));
%enddef

View file

@ -1,9 +1,40 @@
/* ------------------------------------------------------------
* typemap for primitive type with no pointer representation
* Basic fragments derived from long and double types
* ------------------------------------------------------------ */
%define %typemap_primitive(Code, Type...)
%typemap_asvalfromn(SWIG_arg(Code), Type);
/* signed/unsigned char */
%numeric_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
%numeric_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
/* short/unsigned short */
%numeric_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
%numeric_ulong(unsigned short, "<limits.h>", USHRT_MAX)
/* int/unsigned int */
%numeric_slong(int, "<limits.h>", INT_MIN, INT_MAX)
%numeric_ulong(unsigned int, "<limits.h>", UINT_MAX)
/* signed/unsigned wchar_t */
#ifdef __cplusplus
%numeric_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
%numeric_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
#endif
/* float */
%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX)
/* ------------------------------------------------------------
* typemap macro for primitive types with asval/from methods
* ------------------------------------------------------------ */
%define %typemaps_primitive(Code, Type)
%typemaps_asvalfromn(%arg(Code), Type);
%enddef
/* ------------------------------------------------------------
@ -14,7 +45,7 @@
%define _apply_macro(macro, arg2, arg1...)
#if #arg1 != ""
macro(SWIG_arg(arg1),arg2);
macro(%arg(arg1),arg2);
#else
macro(arg2);
#endif
@ -53,80 +84,27 @@ _apply_macro(Macro, std::complex<double>, __VA_ARGS__);
%enddef
%define %apply_checkctypes(Macro)
Macro(SWIG_CCode(BOOL), bool);
Macro(SWIG_CCode(INT8), signed char);
Macro(SWIG_CCode(UINT8), unsigned char);
Macro(SWIG_CCode(INT16), short);
Macro(SWIG_CCode(UINT16), unsigned short);
Macro(SWIG_CCode(INT32), int);
Macro(SWIG_CCode(UINT32), unsigned int);
Macro(SWIG_CCode(INT64), long);
Macro(SWIG_CCode(UINT64), unsigned long);
Macro(SWIG_CCode(INT128), long long);
Macro(SWIG_CCode(UINT128), unsigned long long);
Macro(SWIG_CCode(FLOAT), float);
Macro(SWIG_CCode(DOUBLE), double);
Macro(SWIG_CCode(CHAR), char);
Macro(SWIG_CCode(UNICHAR), wchar_t);
Macro(%checkcode(BOOL), bool);
Macro(%checkcode(INT8), signed char);
Macro(%checkcode(UINT8), unsigned char);
Macro(%checkcode(INT16), short);
Macro(%checkcode(UINT16), unsigned short);
Macro(%checkcode(INT32), int);
Macro(%checkcode(UINT32), unsigned int);
Macro(%checkcode(INT64), long);
Macro(%checkcode(UINT64), unsigned long);
Macro(%checkcode(INT128), long long);
Macro(%checkcode(UINT128), unsigned long long);
Macro(%checkcode(FLOAT), float);
Macro(%checkcode(DOUBLE), double);
Macro(%checkcode(CHAR), char);
Macro(%checkcode(UNICHAR), wchar_t);
%enddef
/* ------------------------------------------------------------
* common fragments and macro helpers
* Apply the primitive typemap for all the types with checkcode
* ------------------------------------------------------------ */
%fragment("<limits.h>","header") %{
#include <limits.h>
%}
%fragment("<wchar.h>","header") %{
#include <wchar.h>
%}
%fragment("<float.h>","header") %{
#include <float.h>
%}
/* Macros for derived types */
%define %derived_type_from(Base, Type)
%fragment(SWIG_From_frag(Type),"header",
fragment=SWIG_From_frag(Base)) {
SWIG_define(SWIG_From_dec(Type), SWIG_From_dec(Base))
}
%enddef
%define %derived_type_asval(Base, Type, Frag, OverflowCond)
%check_swig_object()
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=Frag,
fragment=SWIG_AsVal_frag(Base)) {
SWIGINTERN int
SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
{
Base v;
int res = SWIG_AsVal(Base)(obj, &v);
if (res == SWIG_OK) {
if (OverflowCond) {
return SWIG_OverflowError;
} else {
if (val) *val = SWIG_numeric_cast(v, Type);
return SWIG_OK;
}
}
return res;
}
}
%enddef
%define %signed_derived_type_asval(Base, Type, Frag, Min, Max)
%derived_type_asval(Base, Type, Frag, (v < Min || v > Max))
%enddef
%define %unsigned_derived_type_asval(Base, Type, Frag, Max)
%derived_type_asval(Base, Type, Frag, (v > Max))
%enddef
%apply_checkctypes(%typemaps_primitive);

View file

@ -1,82 +1,101 @@
/*
Value typemaps (Type, const Type&) for "Ptr" types, such as swig
wrapped classes, that define the AsPtr/From methods
*/
/*---------------------------------------------------------------------
* Value typemaps (Type, const Type&) for "Ptr" types, such as swig
* wrapped classes, that define the AsPtr/From methods
*
* To apply them, just use one of the following macros:
*
* %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type)
* %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type)
*
* or the simpler and normalize form:
*
* %typemaps_asptrfromn(CheckCode, Type)
*
* Also, you can use the individual typemap definitions:
*
* %ptr_in_typemap(asptr_meth,frag,Type)
* %ptr_varin_typemap(asptr_meth,frag,Type)
* %ptr_typecheck_typemap(check,asptr_meth,frag,Type)
* %ptr_directorout_typemap(asptr_meth,frag,Type)
*
*---------------------------------------------------------------------*/
%include <typemaps/valtypes.swg>
/* in */
%define SWIG_PTR_IN_TYPEMAP(asptr_meth,frag,Type...)
%define %ptr_in_typemap(asptr_meth,frag,Type...)
%typemap(in,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
if (!res || !ptr) { SWIG_arg_fail(SWIG_TypeError, "$type", $argnum); }
if (!res || !ptr) { %argument_fail(SWIG_TypeError, "$type", $argnum); }
$1 = *ptr;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
if (res == SWIG_NEWOBJ) %delete(ptr);
}
%typemap(in,fragment=frag) const Type & (int res = 0) {
Type *ptr = (Type *)0;
res = asptr_meth($input, &ptr);
if (!res) { SWIG_arg_fail(SWIG_TypeError,"$type",$argnum); }
if (!ptr) { SWIG_arg_nullref("$type",$argnum); }
if (!res) { %argument_fail(SWIG_TypeError,"$type",$argnum); }
if (!ptr) { %argument_nullref("$type",$argnum); }
$1 = ptr;
}
%typemap(freearg,noblock=1) const Type & {
if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
if (res$argnum == SWIG_NEWOBJ) %delete($1);
}
%enddef
/* varin */
%define SWIG_PTR_VARIN_TYPEMAP(asptr_meth,frag,Type...)
%define %ptr_varin_typemap(asptr_meth,frag,Type...)
%typemap(varin,fragment=frag) Type {
Type *ptr = (Type *)0;
int res = asptr_meth($input, &ptr);
if (!res || !ptr) { SWIG_var_fail(SWIG_TypeError, "$type", "$name"); }
if (!res || !ptr) { %variable_fail(SWIG_TypeError, "$type", "$name"); }
$1 = *ptr;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
if (res == SWIG_NEWOBJ) %delete(ptr);
}
%enddef
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorout */
%define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
%define %ptr_directorout_typemap(asptr_meth,frag,Type...)
%typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp) {
Type *optr = 0;
int ores = $input ? asptr_meth($input, &optr) : 0;
if (!ores || !optr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
%dirout_fail(SWIG_TypeError,"$type");
}
temp = *optr;
$result = &temp;
if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
if (ores == SWIG_NEWOBJ) %delete(optr);
}
%typemap(directorout,noblock=1,fragment=frag) Type {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores || !optr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
%dirout_fail(SWIG_TypeError,"$type");
}
$result = *optr;
if (ores == SWIG_NEWOBJ) SWIG_delete(optr);
if (ores == SWIG_NEWOBJ) %delete(optr);
}
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *optr = 0;
int ores = asptr_meth($input, &optr);
if (!ores) {
SWIG_dout_fail(SWIG_TypeError,"$type");
%dirout_fail(SWIG_TypeError,"$type");
} else {
if (!optr) {
SWIG_dout_nullref("$type");
%dirout_nullref("$type");
}
}
if (ores == SWIG_NEWOBJ) {
/* Possible thread/reentrant problem here! */
static $*ltype temp = *optr;
$result = &temp;
SWIG_delete(optr);
%delete(optr);
} else {
$result = optr;
}
@ -88,26 +107,26 @@
#else
#define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
#define %ptr_directorout_typemap(asptr_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* typecheck */
%define SWIG_PTR_TYPECHECK_TYPEMAP(check,asptr_meth,frag,Type...)
%define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...)
%typemap(typecheck,precedence=check,fragment=frag)
Type, const Type&
"$1 = asptr_meth($input, (Type**)(0));";
%enddef
/*
typemap definition for types with AsPtr/From methods
*/
%define %typemap_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsPtr_frag(Type)) %{
SWIGINTERNINLINE int
/*---------------------------------------------------------------------
* typemap definition for types with asptr method
*---------------------------------------------------------------------*/
%define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...)
%fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) {
SWIGINTERNINLINE int
SWIG_AsVal(Type)(SWIG_Object obj, Type *val)
{
Type *v = (Type *)0;
@ -115,43 +134,38 @@
if (!res || !v) return SWIG_ERROR;
if (val) {
*val = *v;
if (res == SWIG_NEWOBJ) SWIG_delete(v);
if (res == SWIG_NEWOBJ) %delete(v);
}
return SWIG_OK;
}
%}
%fragment(SWIG_As_frag(Type),"header",
fragment=SWIG_AsVal_frag(Type)) %{
SWIGINTERNINLINE Type
SWIG_As(Type)(SWIG_Object obj)
{
Type v;
SWIG_AsVal(Type)(obj, &v);
return v;
}
%}
SWIG_PTR_IN_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
SWIG_PTR_VARIN_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
SWIG_PTR_DIRECTOROUT_TYPEMAP(SWIG_arg(AsPtrMeth), SWIG_arg(AsPtrFrag), Type);
SWIG_PTR_TYPECHECK_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsPtrMeth),
SWIG_arg(AsPtrFrag), Type);
%typemap_from(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_PTR_INPUT_TYPEMAP(SWIG_arg(CheckCode),SWIG_arg(AsPtrMeth),
SWIG_arg(AsPtrFrag),Type);
SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_PTR_INOUT_TYPEMAP(Type);
}
%ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
%ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
%ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type);
%ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type);
%ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type);
%enddef
/*
typemap for simple swig types with only AsPtr/From methods
*/
/*---------------------------------------------------------------------
* typemap definition for types with asptr/from methods
*---------------------------------------------------------------------*/
%define %typemap_asptrfromn(CheckCode, Type...)
%typemap_asptrfrom(SWIG_arg(CheckCode),
SWIG_arg(SWIG_AsPtr(Type)),
SWIG_arg(SWIG_From(Type)),
SWIG_arg(SWIG_AsPtr_frag(Type)),
SWIG_arg(SWIG_From_frag(Type)),
%define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...)
%typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type)
%typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
%value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%ptr_inout_typemap(Type);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with for 'normalized' asptr/from methods
*---------------------------------------------------------------------*/
%define %typemaps_asptrfromn(CheckCode, Type...)
%typemaps_asptrfrom(%arg(CheckCode),
%arg(SWIG_AsPtr(Type)),
%arg(SWIG_From(Type)),
%arg(SWIG_AsPtr_frag(Type)),
%arg(SWIG_From_frag(Type)),
Type);
%enddef

View file

@ -1,69 +1,24 @@
//
// String
//
#ifndef SWIG_STD_BASIC_STRING
#define SWIG_STD_STRING
%include <typemaps/std_strings.swg>
/* defining the String asptr/from methods */
%define %std_string_asptr_frag(String, Char, SWIG_AsCharPtrAndSize, Frag)
%check_swig_object()
%fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) {
SWIGINTERN int
SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val)
%{
#include <string>
%}
namespace std
{
static swig_type_info* string_info = SWIG_TypeQuery(#String " *");
String *vptr;
if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
if (buf) {
if (val) *val = new String(buf, size - 1);
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(buf);
return SWIG_NEWOBJ;
}
}
return 0;
}
class string;
}
}
%enddef
%define %std_string_from_frag(String, SWIG_FromCharPtrAndSize, Frag)
%check_swig_object()
%fragment(SWIG_From_frag(String),"header",fragment=Frag) {
SWIGINTERNINLINE SWIG_Object
SWIG_From_dec(String)(const String& s)
{
return SWIG_FromCharPtrAndSize(s.data(), s.size());
}
}
%enddef
%typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STRING));
%define %std_string_asval_frag(String, Frag)
%check_swig_object()
%fragment(SWIG_AsVal_frag(String),"header", fragment=Frag) {
SWIGINTERN int
SWIG_AsVal_dec(String)(SWIG_Object obj, String *val)
{
String* s;
int res = SWIG_AsPtr(String)(obj, &s);
if ((res != 0) && s) {
if (val) *val = *s;
if (res == SWIG_NEWOBJ) delete s;
return SWIG_OK;
}
return SWIG_TypeError;
}
}
%enddef
#else
%include <std/std_string.i>
#define %std_string_asptr(String, Char, Method) %std_string_asptr_frag(String, Char, Method, #Method)
#define %std_string_asval(String) %std_string_asval_frag(String, SWIG_AsPtr_frag(String))
#define %std_string_from(String, Method) %std_string_from_frag(String, Method, #Method)
#endif

View file

@ -0,0 +1,65 @@
/* defining the String asptr/from methods */
%define %std_string_asptr(String, Char, SWIG_AsCharPtrAndSize, Frag)
%fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) {
SWIGINTERN int
SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val)
{
static swig_type_info* string_info = SWIG_TypeQuery(#String " *");
String *vptr;
if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
if (buf) {
if (val) *val = new String(buf, size - 1);
if (alloc == SWIG_NEWOBJ) %delete_array(buf);
return SWIG_NEWOBJ;
}
}
return 0;
}
}
}
%enddef
%define %std_string_from(String, SWIG_FromCharPtrAndSize, Frag)
%fragment(SWIG_From_frag(String),"header",fragment=Frag) {
SWIGINTERNINLINE SWIG_Object
SWIG_From_dec(String)(const String& s)
{
return SWIG_FromCharPtrAndSize(s.data(), s.size());
}
}
%enddef
%define %std_string_asval(String)
%fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String)) {
SWIGINTERN int
SWIG_AsVal_dec(String)(SWIG_Object obj, String *val)
{
String* s;
int res = SWIG_AsPtr(String)(obj, &s);
if ((res != 0) && s) {
if (val) *val = *s;
if (res == SWIG_NEWOBJ) delete s;
return SWIG_OK;
}
return SWIG_TypeError;
}
}
%enddef
%define %typemaps_std_string(String, Char, AsPtrMethod, FromMethod, CheckCode)
%std_string_asptr(String, Char, AsPtrMethod, #AsPtrMethod)
%std_string_asval(String)
%std_string_from(String, FromMethod, #FromMethod)
%typemaps_asptrfromn(%arg(CheckCode), String);
%enddef

View file

@ -0,0 +1,25 @@
%include <typemaps/wstring.swg>
#ifndef SWIG_STD_BASIC_STRING
#define SWIG_STD_WSTRING
%include <typemaps/std_strings.swg>
%{
#include <cwchar>
#include <string>
%}
namespace std
{
class wstring;
}
%typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(UNISTRING));
#else
%include <std/std_wstring.i>
#endif

View file

@ -0,0 +1,3 @@
%include <typemaps/strings.swg>
%typemaps_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen,
"<limits.h>", CHAR_MIN, CHAR_MAX)

View file

@ -31,33 +31,33 @@
Char * (Char *buf = 0, int alloc = 0),
const Char * (Char *buf = 0, int alloc = SWIG_OLDOBJ) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = buf;
}
%typemap(freearg,noblock=1) Char *, const Char * {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = &temp;
}
%typemap(freearg, noblock=1) Char const*& {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* out */
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* {
SWIG_set_result(SWIG_FromCharPtr($1));
%set_output(SWIG_FromCharPtr($1));
}
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& {
SWIG_set_result(SWIG_FromCharPtr(*$1));
%set_output(SWIG_FromCharPtr(*$1));
}
@ -66,41 +66,41 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize) Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError,"$type","$name");
%variable_fail(SWIG_TypeError,"$type","$name");
}
if ($1) SWIG_delete_array($1);
if ($1) %delete_array($1);
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? SWIG_new_copy_array(cptr, csize, Char) : 0;
$1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
}
}
%typemap(varin,noblock=1,fragment=#SWIG_AsCharPtrAndSize,warning="451:Setting const Char * variable may leak memory") const Char * {
Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
if (SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(SWIG_TypeError, "$type", "$name");
}
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? SWIG_new_copy_array(cptr, csize, Char) : 0;
$1 = csize ? %new_copy_array(cptr, csize, Char) : 0;
}
}
/* varout */
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* {
$result = SWIG_FromCharPtr($1);
%set_varoutput(SWIG_FromCharPtr($1));
}
/* meberin */
%typemap(memberin,noblock=1) Char * {
if ($1) SWIG_delete_array($1);
if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
$1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -109,7 +109,7 @@
%typemap(memberin,noblock=1,warning="451:Setting const char * member may leak memory.") const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
$1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -118,10 +118,10 @@
/* globalin */
%typemap(globalin,noblock=1) Char * {
if ($1) SWIG_delete_array($1);
if ($1) %delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
$1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -130,7 +130,7 @@
%typemap(globalin,noblock=1,warning="451:Setting const char * variable may leak memory.") const Char * {
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
$1 = %new_copy_array($input, size, Char);
} else {
$1 = 0;
}
@ -140,7 +140,7 @@
%typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr)
Char *, Char const*, Char * const, Char const* const {
SWIG_set_constant("$symname", SWIG_FromCharPtr($value));
%set_constant("$symname", SWIG_FromCharPtr($value));
}
@ -159,14 +159,14 @@
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
%dirout_fail(SWIG_TypeError, "$type");
}
$result = buf;
}
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf = 0, int alloc = 0) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
%dirout_fail(SWIG_TypeError, "$type");
}
$result = ($1_ltype) &buf;
}
@ -184,7 +184,7 @@
/* throws */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * {
SWIG_raise(SWIG_FromCharPtr($1), "$type", 0);
%raise(SWIG_FromCharPtr($1), "$type", 0);
}
@ -197,7 +197,7 @@
%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char []
{
SWIG_var_fail(SWIG_AttributeError, "$type", "read-only $name");
%variable_fail(SWIG_AttributeError, "$type", "read-only $name");
}
@ -226,7 +226,7 @@
const Char [ANY](Char temp[$1_dim0])
{
if (SWIG_AsCharArray($input, temp, $1_dim0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = temp;
}
@ -234,7 +234,7 @@
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0])
{
if (SWIG_AsCharArray($input, temp, $1_dim0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = &temp;
}
@ -246,7 +246,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
SWIG_set_result(SWIG_FromCharPtrAndSize($1, size));
%set_output(SWIG_FromCharPtrAndSize($1, size));
}
/* varin */
@ -254,7 +254,7 @@
%typemap(varin,noblock=1,fragment=#SWIG_AsCharArray) Char [ANY]
{
if (SWIG_AsCharArray($input, $1, $1_dim0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(SWIG_TypeError, "$type", "$name");
}
}
@ -266,7 +266,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
$result = SWIG_FromCharPtrAndSize($1, size);
%set_varoutput(SWIG_FromCharPtrAndSize($1, size));
}
/* constant */
@ -278,7 +278,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($value[size - 1] == '\0')) --size;
%#endif
SWIG_set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
%set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
}
@ -302,7 +302,7 @@
const Char [ANY] (Char temp[$result_dim0])
{
if (SWIG_AsCharArray($input, temp, $result_dim0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
%dirout_fail(SWIG_TypeError, "$type");
}
$result = temp;
}
@ -327,7 +327,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
SWIG_raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
%raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
}
/* -------------------------------------------------------------------
@ -337,13 +337,13 @@
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
$result = SWIG_FromCharPtrAndSize($1, $1_dim0);
%set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0));
}
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
SWIG_set_result(SWIG_FromCharPtrAndSize($1, $1_dim0));
%set_output(SWIG_FromCharPtrAndSize($1, $1_dim0));
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
@ -358,7 +358,7 @@
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY] {
SWIG_raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
%raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
}
/* ------------------------------------------------------------
@ -371,13 +371,13 @@
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = SWIG_static_cast(buf, $1_ltype);
$2 = SWIG_numeric_cast(size - 1, $2_ltype);
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size - 1, $2_ltype);
}
%typemap(freearg,noblock=1) (Char *STRING, size_t LENGTH) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
@ -390,13 +390,13 @@
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = SWIG_static_cast(buf, $1_ltype);
$2 = SWIG_numeric_cast(size, $2_ltype);
$1 = %static_cast(buf, $1_ltype);
$2 = %numeric_cast(size, $2_ltype);
}
%typemap(freearg, noblock=1) (Char *STRING, size_t SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
@ -411,13 +411,13 @@
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
$2 = SWIG_static_cast(buf, $2_ltype) ;
$1 = SWIG_numeric_cast(size - 1, $1_ltype) ;
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size - 1, $1_ltype) ;
}
%typemap(freearg, noblock=1) (size_t LENGTH, Char *STRING) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
@ -429,13 +429,13 @@
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
{
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type",$argnum);
%argument_fail(SWIG_TypeError, "$type",$argnum);
}
$2 = SWIG_static_cast(buf, $2_ltype) ;
$1 = SWIG_numeric_cast(size, $1_ltype) ;
$2 = %static_cast(buf, $2_ltype) ;
$1 = %numeric_cast(size, $1_ltype) ;
}
%typemap(freearg, noblock=1) (size_t SIZE, Char *STRING) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
@ -444,11 +444,17 @@
%enddef
%define %typemap_string(Char, CharName,
/* ------------------------------------------------------------
* --- String fragment methods ---
* ------------------------------------------------------------ */
%define %typemaps_string(Char, CharName,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen)
/* String fragment methods */
SWIG_CharPtrLen,
FragLimits, CHAR_MIN, CHAR_MAX)
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
@ -467,11 +473,9 @@ SWIG_From##CharName##Array(const Char *cptr, size_t size)
}
%fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) {
SWIG_define(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc))
%define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc))
}
%check_swig_object()
%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) {
SWIGINTERN int
SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
@ -484,15 +488,49 @@ SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
if (csize) memcpy(val, cptr, csize*sizeof(Char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
}
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
if (alloc == SWIG_NEWOBJ) %delete_array(cptr);
return SWIG_OK;
}
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
if (alloc == SWIG_NEWOBJ) %delete_array(cptr);
}
return SWIG_TypeError;
}
}
/* Char */
%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_From_dec(Char)(Char c)
{
return SWIG_FromCharPtrAndSize(&c,1);
}
}
%fragment(SWIG_AsVal_frag(Char),"header",
fragment="SWIG_As"#CharName"Array",
fragment=FragLimits,
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN int
SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
{
int res = SWIG_As##CharName##Array(obj, val, 1);
if (res != SWIG_OK) {
long v;
res = SWIG_AsVal(long)(obj, (val ? &v : 0));
if (res == SWIG_OK) {
if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) {
if (val) *val = %numeric_cast(v, Char);
} else {
res = SWIG_OverflowError;
}
}
}
return res;
}
}
%_typemap_string(Char,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,

View file

@ -2,13 +2,31 @@
* SWIG API. Portion only visible from SWIG
* ----------------------------------------------------------------------------- */
/* basic preprocessor macros */
/* -----------------------------------------------------------------------------
* Basic preprocessor macros
* ----------------------------------------------------------------------------- */
#define SWIG_arg(Arg...) Arg
#define SWIG_str(Type...) #Type
#define SWIG_block(Block...) do { Block; } while(0)
#define %arg(Arg...) Arg
#define %str(Type...) #Type
#define %block(Block...) do { Block; } while(0)
/* casting operators */
/* define a new macro */
%define %define_as(Def, Val...)
%#define Def Val
%enddef
/* include C++ or else value */
%define %ifcplusplus(cppval, nocppval)
#ifdef __cplusplus
cppval
#else
nocppval
#endif
%enddef
/* -----------------------------------------------------------------------------
* Casting operators
* ----------------------------------------------------------------------------- */
#ifdef SWIG_NO_CPLUSPLUS_CAST
/* Disable 'modern' cplusplus casting operators */
@ -18,156 +36,74 @@
#endif
#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST)
# define SWIG_const_cast(a,Type...) const_cast<Type >(a)
# define SWIG_static_cast(a,Type...) static_cast<Type >(a)
# define SWIG_reinterpret_cast(a,Type...) reinterpret_cast<Type >(a)
# define SWIG_numeric_cast(a,Type...) static_cast<Type >(a)
# define SWIG_as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
# define SWIG_as_voidptrptr(a) reinterpret_cast<void **>(a)
# define %const_cast(a,Type...) const_cast<Type >(a)
# define %static_cast(a,Type...) static_cast<Type >(a)
# define %reinterpret_cast(a,Type...) reinterpret_cast<Type >(a)
# define %numeric_cast(a,Type...) static_cast<Type >(a)
# define %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
# define %as_voidptrptr(a) reinterpret_cast<void **>(a)
#else /* C case */
# define SWIG_const_cast(a,Type...) (Type)(a)
# define SWIG_static_cast(a,Type...) (Type)(a)
# define SWIG_reinterpret_cast(a,Type...) (Type)(a)
# define SWIG_numeric_cast(a,Type...) (Type)(a)
# define SWIG_as_voidptr(a) (void *)(a)
# define SWIG_as_voidptrptr(a) (void **)(a)
# define %const_cast(a,Type...) (Type)(a)
# define %static_cast(a,Type...) (Type)(a)
# define %reinterpret_cast(a,Type...) (Type)(a)
# define %numeric_cast(a,Type...) (Type)(a)
# define %as_voidptr(a) (void *)(a)
# define %as_voidptrptr(a) (void **)(a)
#endif /* __cplusplus */
/* macros for allocating/freeing elements */
/* -----------------------------------------------------------------------------
* Allocating/freeing elements
* ----------------------------------------------------------------------------- */
#if defined(__cplusplus)
# define SWIG_new(Type...) (new Type)
# define SWIG_new_copy(val,Type...) (new Type(SWIG_static_cast(val, const Type&)))
# define SWIG_new_array(size,Type...) (new Type[size])
# define SWIG_new_copy_array(ptr,size,Type...) SWIG_reinterpret_cast(memcpy(SWIG_new_array(size,Type), ptr, sizeof(Type)*(size)), Type*)
# define SWIG_delete(cptr) delete cptr
# define SWIG_delete_array(cptr) delete[] cptr
# define %new_instance(Type...) (new Type)
# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
# define %new_array(size,Type...) (new Type[size])
# define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)), Type*)
# define %delete(cptr) delete cptr
# define %delete_array(cptr) delete[] cptr
#else /* C case */
# define SWIG_new(Type...) (Type *)malloc(sizeof(Type))
# define SWIG_new_copy(val,Type...) (Type *)memcpy(SWIG_new(Type),&val,sizeof(Type))
# define SWIG_new_array(size,Type...) (Type *)malloc((size)*sizeof(Type))
# define SWIG_new_copy_array(ptr,size,Type...) (Type *)memcpy(SWIG_new_array(size,Type), ptr, sizeof(Type)*(size))
# define SWIG_delete(cptr) free((char*)cptr)
# define SWIG_delete_array(cptr) free((char*)cptr)
# define %new_instance(Type...) (Type *)malloc(sizeof(Type))
# define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type))
# define %new_array(size,Type...) (Type *)malloc((size)*sizeof(Type))
# define %new_copy_array(ptr,size,Type...) (Type *)memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size))
# define %delete(cptr) free((char*)cptr)
# define %delete_array(cptr) free((char*)cptr)
#endif /* __cplusplus */
/* macros for fragments/typemaps */
/* -----------------------------------------------------------------------------
* Swig names and mangling
* ----------------------------------------------------------------------------- */
#define SWIG_Mangle(Type...) #@Type
#define SWIG_Descriptor(Type...) SWIGTYPE_ ## #@Type
#define SWIG_NameType(Name, Type...) SWIG_ ## Name ## _ ## #@Type
#define SWIG_StringType(Name, Type...) "SWIG_" #Name "_" {Type}
#define %mangle(Type...) #@Type
#define %name_type(Name, Type...) SWIG_ ## Name ## _ ## #@Type
#define %string_type(Name, Type...) "SWIG_" #Name "_" {Type}
#define %checkcode(Code) %name_type(TYPECHECK, Code)
#define SWIG_AsVal(Type...) SWIG_NameType(AsVal, Type)
#define SWIG_AsPtr(Type...) SWIG_NameType(AsPtr, Type)
#define SWIG_As(Type...) SWIG_NameType(As, Type)
#define SWIG_From(Type...) SWIG_NameType(From, Type)
#define SWIG_Check(Type...) SWIG_NameType(Check, Type)
#define SWIG_OrderType(Type...) SWIG_NameType(OrderType, Type)
#define SWIG_EqualType(Type...) SWIG_NameType(EqualType, Type)
#define SWIG_AsVal_dec(Type...) SWIG_NameType(AsVal, Type)
#define SWIG_AsPtr_dec(Type...) SWIG_NameType(AsPtr, Type)
#define SWIG_As_dec(Type...) SWIG_NameType(As, Type)
#define SWIG_From_dec(Type...) SWIG_NameType(From, Type)
#define SWIG_Check_dec(Type...) SWIG_NameType(Check, Type)
#define SWIG_Traits_frag(Type...) SWIG_StringType(Traits, Type)
#define SWIG_AsPtr_frag(Type...) SWIG_StringType(AsPtr, Type)
#define SWIG_AsVal_frag(Type...) SWIG_StringType(AsVal, Type)
#define SWIG_As_frag(Type...) SWIG_StringType(As, Type)
#define SWIG_From_frag(Type...) SWIG_StringType(From, Type)
#define SWIG_Check_frag(Type...) SWIG_StringType(Check, Type)
#define SWIG_CCode(Type...) SWIG_NameType(TYPECHECK, Type)
#define SWIG_CCode_frag(Type...) SWIG_StringType(TYPECHECK, Type)
/* macros for result manipulation */
#define SWIG_set_result(obj) SWIG_SetResultObj(obj)
#define SWIG_append_result(obj) SWIG_AppendResultObj(obj)
#define SWIG_set_constant(name,value) SWIG_SetConstantObj(name,value)
/* macros for error manipulation */
#define SWIG_NullRefFmt() "invalid null reference "
#define SWIG_VarFailFmt(_type,_name) "in variable '"_name"' of type '"_type"'"
#define SWIG_ArgFailFmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
#define SWIG_OutFailFmt(_type) "in output value of type '"_type"'"
#define SWIG_ArgNullRefFmt(_type, _argn) SWIG_NullRefFmt() SWIG_ArgFailFmt(_type, _argn)
#define SWIG_VarNullRefFmt(_type, _name) SWIG_NullRefFmt() SWIG_VarFailFmt(_type, _name)
#define SWIG_OutNullRefFmt(_type) SWIG_NullRefFmt() SWIG_OutFailFmt(_type)
#define SWIG_ArgFail(code,type,argn) SWIG_Error(code, SWIG_ArgFailFmt(type, argn))
#define SWIG_VarFail(code,type,name) SWIG_Error(code, SWIG_VarFailFmt(type, name))
#define SWIG_ArgNullRef(type,argn) SWIG_Error(SWIG_ValueError, SWIG_ArgNullRefFmt(type, argn))
#define SWIG_VarNullRef(type,name) SWIG_Error(SWIG_ValueError, SWIG_VarNullRefFmt(type, name))
#define SWIG_OutNullRef(type) SWIG_Error(SWIG_ValueError, SWIG_OutNullRefFmt(type))
/* setting an error */
#define SWIG_error(code,msg...) SWIG_Error(code, msg)
#define SWIG_type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
/* setting an error and exit */
#define SWIG_error_block(Block...) SWIG_block(Block)
#define SWIG_arg_fail(code, type, arg) SWIG_error_block(SWIG_ArgFail(code, type, arg); SWIG_fail)
#define SWIG_arg_nullref(type, arg) SWIG_error_block(SWIG_ArgNullRef(type, arg); SWIG_fail)
#define SWIG_member_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
#define SWIG_member_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
#define SWIG_global_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
#define SWIG_global_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
#define SWIG_var_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
#define SWIG_var_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
#define SWIG_dout_fail(code, type) SWIG_DirOutFail(code, SWIG_OutFailFmt(type))
#define SWIG_dout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, SWIG_OutNullRefFmt(type))
#define SWIG_raise(obj, type, desc) SWIG_error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
/*
Macros to define and check the Language dependent Swig object
Use it, for example in Tcl, as
Macros to define language dependent object and the void object.
Use them, for example in Tcl, as
%define_swig_object(Tcl_Obj *)
%define_void_object(NULL)
*/
#define SWIG_Object __NULL__
/* VOID_Object */
%define %define_void_object(Obj)
#define VOID_Object Obj
%enddef
/* SWIG_Object */
%define %define_swig_object(Obj)
#undef SWIG_Object
#define SWIG_Object Obj
%enddef
%define %check_swig_object()
#if SWIG_str(SWIG_Object) == "__NULL__"
#error "SWIG_Object must be defined using %define_swig_object"
#endif
%enddef
/* -----------------------------------------------------------------------------
* Auxiliar macros used to write typemaps
* Auxiliar ugly macros used to write typemaps
* ----------------------------------------------------------------------------- */
/* define a new macro */
%define SWIG_define(Def, Val...)
%#define Def Val
%enddef
/* include C++ or C value */
%define SWIG_cplusplus(cppval, cval)
#ifdef __cplusplus
cppval
#else
cval
#endif
%enddef
/* for loop for macro with one argument */
%define %_formacro_1(macro, arg1,...)
@ -212,6 +148,9 @@ macro(arg1, arg2)
%swig_equal_type and %swig_order_type flagged a type of having equal (==,!=)
and/or order methods (<=,>=,<,>).
*/
#define SWIG_OrderType(Type...) %name_type(OrderType, Type)
#define SWIG_EqualType(Type...) %name_type(EqualType, Type)
#define %swig_equal_type(...) %swig_mark_flag(SWIG_EqualType(__VA_ARGS__))
#define %swig_order_type(...) \
%swig_mark_flag(SWIG_EqualType(__VA_ARGS__)) \
@ -234,11 +173,16 @@ _expr
%enddef
%define %evalif(_x,...)
%_evalif(SWIG_arg(_x),SWIG_arg(__VA_ARGS__))
%_evalif(%arg(_x),%arg(__VA_ARGS__))
%enddef
%define %evalif_2(_x,_y,...)
%_evalif_2(SWIG_arg(_x),SWIG_arg(_y),SWIG_arg(__VA_ARGS__))
%_evalif_2(%arg(_x),%arg(_y),%arg(__VA_ARGS__))
%enddef
/* -----------------------------------------------------------------------------
* Include special macros for fragments
* ----------------------------------------------------------------------------- */
%include <typemaps/fragmacros.swg>

View file

@ -2,22 +2,24 @@
* Language Object * - Just pass straight through unmodified
* ------------------------------------------------------------ */
%check_swig_object()
#if !defined(SWIG_Object)
#error "SWIG_Object must be defined using %define_swig_object"
#endif
%typemap(in) SWIG_Object "$1 = $input;";
%typemap(out,noblock=1) SWIG_Object {
SWIG_set_result($1);
$result = $1;
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIG_Object "$1 = ($input != 0);";
%typemap(throws,noblock=1) SWIG_Object {
SWIG_raise($1, "$type", 0);
%raise($1, "$type", 0);
}
%typemap(constcode,noblock=1) SWIG_Object {
SWIG_set_constant("$symname", $value);
%set_constant("$symname", $value);
}
#ifdef SWIG_DIRECTOR_TYPEMAPS

View file

@ -3,36 +3,39 @@
* ----------------------------------------------------------------------------- */
/* Pointers and arrays */
%typemap(in, noblock=1) SWIGTYPE *, SWIGTYPE [] {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1),$descriptor, $disown) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
%typemap(in, noblock=1) SWIGTYPE * (void *argp), SWIGTYPE [] (void *argp) {
if (SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE *, SWIGTYPE [] "";
%typemap(in, noblock=1) SWIGTYPE* const& ($*ltype temp) {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&temp), $*descriptor, $disown) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$*ltype", $argnum);
%typemap(in, noblock=1) SWIGTYPE* const& (void *argp, $*ltype temp) {
if (SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "$*ltype", $argnum);
}
temp = %reinterpret_cast(argp, $*ltype);
$1 = &temp;
}
/* Reference */
%typemap(in, noblock=1) SWIGTYPE & {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, 0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
%typemap(in, noblock=1) SWIGTYPE & (void *argp) {
if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
}
if (!$1) { SWIG_arg_nullref("$type", $argnum); }
if (!argp) { %argument_nullref("$type", $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
}
/* By value */
%typemap(in,noblock=1) SWIGTYPE ($&ltype argp) {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&argp), $&descriptor, 0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
%typemap(in,noblock=1) SWIGTYPE (void *argp) {
if (SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
}
if (!argp) { SWIG_arg_nullref("$type", $argnum); }
$1 = *argp;
if (!argp) { %argument_nullref("$type", $argnum); }
$1 = *(%reinterpret_cast(argp, $&ltype));
}
/* -----------------------------------------------------------------------------
@ -41,16 +44,16 @@
/* Pointers, references */
%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, $owner));
%set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
}
%typemap(out, noblock=1) SWIGTYPE* const& {
SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*descriptor, $owner));
%set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags));
}
/* Return by value */
%typemap(out, noblock=1) SWIGTYPE {
SWIG_set_result(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN));
%set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
}
/* -----------------------------------------------------------------------------
@ -60,46 +63,46 @@
/* memberin/globalin/varin, for fix arrays. */
%typemap(memberin) SWIGTYPE [ANY] {
$basetype *inp = SWIG_static_cast($input, $basetype *);
$basetype *inp = %static_cast($input, $basetype *);
if (inp) {
$basetype *dest = SWIG_static_cast($1, $basetype *);
$basetype *dest = %static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_member_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY] {
$basetype *inp = SWIG_static_cast($input, $basetype *);
$basetype *inp = %static_cast($input, $basetype *);
if (inp) {
$basetype *dest = SWIG_static_cast($1, $basetype *);
$basetype *dest = %static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_global_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
%typemap(varin,noblock=1) SWIGTYPE [ANY] {
$basetype *inp = 0;
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&inp), $descriptor, 0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
} else if (inp) {
size_t ii = 0;
$basetype *dest = SWIG_static_cast($1, $basetype *);
$basetype *dest = %static_cast($1, $basetype *);
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_var_nullref("$type", "$name");
%variable_nullref("$type", "$name");
}
}
/* memberin/globalin/varin, for fix double arrays. */
%typemap(memberin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
$basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@ -108,18 +111,18 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_member_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
} else {
SWIG_member_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
$basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@ -128,20 +131,20 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_global_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
} else {
SWIG_global_nullref("$type","$name");
%variable_nullref("$type","$name");
}
}
%typemap(varin,noblock=1) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = 0;
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&inp), $descriptor, 0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
} else if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
@ -150,11 +153,11 @@
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_var_nullref("$type", "$name");
%variable_nullref("$type", "$name");
}
}
} else {
SWIG_var_nullref("$type", "$name");
%variable_nullref("$type", "$name");
}
}
@ -162,37 +165,37 @@
%typemap(varin,noblock=1) SWIGTYPE * {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, $descriptor, 0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, &temp, $descriptor, %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($ltype) temp;
}
%typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
{
SWIG_var_fail(SWIG_AttributeError, "$type", "read-only $name");
%variable_fail(SWIG_AttributeError, "$type", "read-only $name");
}
%typemap(varin,noblock=1) SWIGTYPE & {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, $descriptor, 0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, &temp, $descriptor, %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
}
if (!temp) {
SWIG_var_nullref("$type", "$name");
%variable_nullref("$type", "$name");
}
$1 = *(SWIG_reinterpret_cast(temp, $ltype));
$1 = *(%reinterpret_cast(temp, $ltype));
}
%typemap(varin,noblock=1) SWIGTYPE {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, $&descriptor, 0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, &temp, $&descriptor, %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
}
if (!temp) {
SWIG_var_nullref("$type", "$name");
%variable_nullref("$type", "$name");
}
$1 = *(SWIG_reinterpret_cast(temp, $&type));
$1 = *(%reinterpret_cast(temp, $&type));
}
/* -----------------------------------------------------------------------------
@ -201,21 +204,21 @@
/* Pointers and arrays */
%typemap(varout, noblock=1) SWIGTYPE * {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
%set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
}
%typemap(varout, noblock=1) SWIGTYPE [] {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
%set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags));
}
/* References */
%typemap(varout, noblock=1) SWIGTYPE & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $descriptor, 0);
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
}
/* Value */
%typemap(varout, noblock=1) SWIGTYPE {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $&descriptor, 0);
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags));
}
/* ------------------------------------------------------------
@ -237,28 +240,110 @@
$1 = (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0) == SWIG_OK) && (ptr != 0);
}
/* -----------------------------------------------------------------------------
* --- Director typemaps --- *
* ----------------------------------------------------------------------------- */
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorin */
%typemap(directorin,noblock=1) SWIGTYPE* {
$input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE {
$input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE& {
$input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
}
/* directorout */
%typemap(directorout,noblock=1) SWIGTYPE (void * argp) {
if (SWIG_ConvertPtr($input,&argp,$&descriptor, %convertptr_flags) != SWIG_OK) {
%dirout_fail(SWIG_TypeError,"$type");
}
$result = *(%reinterpret_cast(argp, $&ltype));
}
%typemap(directorout,noblock=1) SWIGTYPE *(void *argp), SWIGTYPE [](void *argp) {
if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
%dirout_fail(SWIG_TypeError,"$type");
}
$result = %reinterpret_cast(argp, $ltype);
}
%typemap(directorout,noblock=1) SWIGTYPE &(void *argp) {
if (SWIG_ConvertPtr($input, &argp, $descriptor, $disown | %convertptr_flags) != SWIG_OK) {
%dirout_fail(SWIG_TypeError,"$type");
}
if (!argp) { %dirout_nullref("$type"); }
$result = %reinterpret_cast(argp, $ltype);
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* ------------------------------------------------------------
* --- Constants ---
* ------------------------------------------------------------ */
%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{
%set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
}
%typemap(constcode,noblock=1) SWIGTYPE {
%set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags));
}
/* ------------------------------------------------------------
* --- Exception handling ---
* ------------------------------------------------------------ */
%typemap(throws,noblock=1) SWIGTYPE {
%raise(SWIG_NewPointerObj(%new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE * {
%raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE [ANY] {
%raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE & {
%raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
}
/* ------------------------------------------------------------
* --- CLASS::* typemaps ---
* ------------------------------------------------------------ */
%typemap(in,noblock=1) SWIGTYPE (CLASS::*) {
if (SWIG_ConvertMember($input, SWIG_as_voidptr(&$1), sizeof($type),$descriptor, 0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
if (SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor) != SWIG_OK) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
}
%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
SWIG_set_result(SWIG_NewMemberObj(SWIG_as_voidptr(&$1), sizeof($type), $descriptor));
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
}
%typemap(varin,noblock=1) SWIGTYPE (CLASS::*) {
if (SWIG_ConvertMember($input,SWIG_as_voidptr(&$1), sizeof($type), $descriptor,0) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
}
}
%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
$result = SWIG_NewMemberObj(SWIG_as_voidptr(&$1), sizeof($type), $descriptor);
%set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
}
%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
%set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor));
}
@ -272,104 +357,18 @@
some providences.
*/
%typemap(in, noblock=1) SWIGTYPE ((*)(ANY)) {
if (SWIG_ConvertFunctionPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, 0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
if (SWIG_ConvertFunctionPtr($input, %as_voidptrptr(&$1), $descriptor) != SWIG_OK) {
%argument_fail(SWIG_TypeError,"$type",$argnum);
}
}
%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
SWIG_set_result(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
%set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor));
}
/* -----------------------------------------------------------------------------
* --- Director typemaps --- *
* ----------------------------------------------------------------------------- */
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorin */
%typemap(directorin,noblock=1) SWIGTYPE* {
$input = SWIG_NewPointerObj(SWIG_as_voidptr($1_name), $descriptor, 0);
}
%typemap(directorin,noblock=1) SWIGTYPE {
$input = SWIG_NewPointerObj(SWIG_as_voidptr(&$1_name), $&descriptor, 0);
}
%typemap(directorin,noblock=1) SWIGTYPE& {
$input = SWIG_NewPointerObj(SWIG_as_voidptr(&$1_name), $descriptor, 0);
}
/* directorout */
%typemap(directorout,noblock=1) SWIGTYPE (void * argp) {
if (SWIG_ConvertPtr($input,&argp,$&descriptor, 0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError,"$type");
}
$result = *(SWIG_reinterpret_cast(argp, $&ltype));
}
%typemap(directorout,noblock=1) SWIGTYPE *(void *argp), SWIGTYPE [](void *argp) {
if (SWIG_ConvertPtr($input, &argp, $descriptor, 0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError,"$type");
}
$result = SWIG_reinterpret_cast(argp, $ltype);
}
%typemap(directorout,noblock=1) SWIGTYPE &(void *argp) {
if (SWIG_ConvertPtr($input, &argp, $descriptor, $disown ) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError,"$type");
}
if (!argp) { SWIG_dout_nullref("$type"); }
$result = SWIG_reinterpret_cast(argp, $ltype);
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* ------------------------------------------------------------
* --- Constants ---
* ------------------------------------------------------------ */
%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{
SWIG_set_constant("$symname", SWIG_NewPointerObj(SWIG_as_voidptr($value),$descriptor,0));
}
%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
SWIG_set_constant("$symname", SWIG_NewPackedObj(SWIG_as_voidptr(&$value), sizeof($type), $descriptor, 0));
}
%typemap(constcode,noblock=1) SWIGTYPE {
SWIG_set_constant("$symname", SWIG_NewPointerObj(SWIG_as_voidptr(&$value),$&descriptor,0));
}
%typemap(constcode,noblock=1) SWIGTYPE ((*)(ANY)){
if (sizeof($type) == sizeof(void *)) {
SWIG_set_constant("$symname", SWIG_NewPointerObj((void *)$value, $descriptor, 0));
} else {
SWIG_set_constant("$symname", SWIG_NewPackedObj((void *)$value, sizeof($type), $descriptor, 0));
}
}
/* ------------------------------------------------------------
* --- Exception handling ---
* ------------------------------------------------------------ */
%typemap(throws,noblock=1) SWIGTYPE {
SWIG_raise(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE * {
SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE [ANY] {
SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE & {
SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
%typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){
%set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor));
}
/* ------------------------------------------------------------
@ -384,15 +383,15 @@
/* DISOWN typemap */
%typemap(in, noblock=1) SWIGTYPE *DISOWN {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type", $argnum);
if (SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags) != SWIG_OK) {
%argument_fail(SWIG_TypeError,"$type", $argnum);
}
}
%typemap(varin,noblock=1) SWIGTYPE *DISOWN {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
if (SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags) != SWIG_OK) {
%variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($ltype) temp;
}
@ -400,27 +399,27 @@
/* DYNAMIC typemap */
%typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIG_TypeDynamicCast($descriptor, SWIG_as_voidptrptr(&$1)), $owner));
%set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags));
}
/* INSTANCE typemap */
%typemap(out,noblock=1) SWIGTYPE INSTANCE {
SWIG_set_result(SWIG_NewInstanceObj(SWIG_new_copy($1, $1_ltype), $&1_descriptor,SWIG_POINTER_OWN));
%set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags));
}
%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, $owner));
%set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, 0);
%set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE &INSTANCE {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $1_descriptor, 0);
%set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $1_descriptor, %newinstance_flags));
}
%typemap(varout,noblock=1) SWIGTYPE INSTANCE {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $&1_descriptor, 0);
%set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags));
}

View file

@ -0,0 +1,79 @@
/* -----------------------------------------------------------------------------
* Typemap specializations
* ----------------------------------------------------------------------------- */
/* flags for new/convert methods */
#ifndef %convertptr_flags
%ignore %convertptr_flags;
#define %convertptr_flags 0
#endif
#ifndef %newpointer_flags
%ignore %newpointer_flags;
#define %newpointer_flags 0
#endif
#ifndef %newinstance_flags
%ignore %newinstance_flags;
#define %newinstance_flags 0
#endif
/* output and constant manipulation */
#ifndef %set_varoutput
#define %set_varoutput(obj) $result = obj
#endif
#ifndef %set_output
#define %set_output(obj) $result = obj
#endif
#ifndef %append_output
#define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
#endif
#ifndef %set_constant
#define %set_constant(name,value) SWIG_SetConstant(name,value)
#endif
/* setting an error and exit */
#define %error_block(Block...) %block(Block)
#define %argument_fail(code, type, argn) %error_block(SWIG_Error(code, %argfail_fmt(type, argn)); SWIG_fail)
#define %argument_nullref(type, argn) %error_block(SWIG_Error(SWIG_ValueError, %argnullref_fmt(type, argn)); SWIG_fail)
#define %variable_fail(code, type, name) %error_block(SWIG_Error(code, %varfail_fmt(type, name)); SWIG_fail)
#define %variable_nullref(type, name) %error_block(SWIG_Error(SWIG_ValueError, %varnullref_fmt(type, name)); SWIG_fail)
#ifndef %raise
#define %raise(obj, type, desc) %error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
#endif
#ifdef SWIG_DIRECTOR_TYPEMAPS
#define %dirout_fail(code, type) SWIG_DirOutFail(code, %outfail_fmt(type))
#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
#endif
/* -----------------------------------------------------------------------------
* All the typemaps
* ----------------------------------------------------------------------------- */
%include <typemaps/fragments.swg>
%include <typemaps/exception.swg>
%include <typemaps/swigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/swigobject.swg>
%include <typemaps/valtypes.swg>
%include <typemaps/ptrtypes.swg>
%include <typemaps/inoutlist.swg>
%include <typemaps/primtypes.swg>
%include <typemaps/string.swg>
%include <typemaps/misctypes.swg>
%include <typemaps/enumint.swg>

View file

@ -162,6 +162,6 @@ phased out in future releases.
#ifdef SWIG_INOUT_NODEF
%apply_checkctypes(%typemap_inoutn)
%apply_checkctypes(%typemaps_inoutn)
#endif

View file

@ -2,68 +2,89 @@
* Value typemaps (Type, const Type&) for value types, such as
* fundamental types (int, double), that define the AsVal/From
* methods.
*
* To apply them, just use one of the following macros:
*
* %typemaps_from(FromMeth, FromFrag, Type)
* %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type)
* %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type)
*
* or the simpler and normalize form:
*
* %typemaps_asvalfromn(CheckCode, Type)
*
* Also, you can use the individual typemap definitions:
*
* %value_in_typemap(asval_meth,frag,Type)
* %value_varin_typemap(asval_meth,frag,Type)
* %value_typecheck_typemap(checkcode,asval_meth,frag,Type)
* %value_directorout_typemap(asval_meth,frag,Type)
*
* %value_out_typemap(from_meth,frag,Type)
* %value_varout_typemap(from_meth,frag,Type)
* %value_constcode_typemap(from_meth,frag,Type)
* %value_directorin_typemap(from_meth,frag,Type)
* %value_throws_typemap(from_meth,frag,Type)
*
*---------------------------------------------------------------------*/
/* in */
%define SWIG_VALUE_IN_TYPEMAP(asval_meth,frag,Type...)
%define %value_in_typemap(asval_meth,frag,Type...)
%typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$ltype", $argnum);
} else {
$1 = SWIG_static_cast(val,$ltype);
}
%argument_fail(ecode, "$ltype", $argnum);
}
$1 = %static_cast(val,$ltype);
}
%typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) {
ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$*ltype", $argnum);
} else {
temp = SWIG_static_cast(val, $*ltype);
$1 = &temp;
}
%argument_fail(ecode, "$*ltype", $argnum);
}
temp = %static_cast(val, $*ltype);
$1 = &temp;
}
%enddef
/* out */
%define SWIG_VALUE_OUT_TYPEMAP(from_meth,frag,Type...)
%define %value_out_typemap(from_meth,frag,Type...)
%typemap(out,noblock=1,fragment=frag) Type, const Type {
SWIG_set_result(from_meth(SWIG_static_cast($1,Type)));
%set_output(from_meth(%static_cast($1,Type)));
}
%typemap(out,noblock=1,fragment=frag) const Type& {
SWIG_set_result(from_meth(SWIG_static_cast(*$1,Type)));
%set_output(from_meth(%static_cast(*$1,Type)));
}
%enddef
/* varin */
%define SWIG_VALUE_VARIN_TYPEMAP(asval_meth,frag,Type...)
%define %value_varin_typemap(asval_meth,frag,Type...)
%typemap(varin,noblock=1,fragment=frag) Type {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
SWIG_var_fail(res, "$type", "$name");
} else {
$1 = SWIG_static_cast(val,$ltype);
%variable_fail(res, "$type", "$name");
}
$1 = %static_cast(val,$ltype);
}
%enddef
/* varout */
%define SWIG_VALUE_VAROUT_TYPEMAP(from_meth,frag,Type...)
%define %value_varout_typemap(from_meth,frag,Type...)
%typemap(varout,noblock=1,fragment=frag) Type, const Type& {
$result = from_meth(SWIG_static_cast($1,$basetype));
%set_varoutput(from_meth(%static_cast($1,$basetype)));
}
%enddef
/* constant installation code */
%define SWIG_VALUE_CONSTCODE_TYPEMAP(from_meth,frag,Type...)
%define %value_constcode_typemap(from_meth,frag,Type...)
%typemap(constcode,noblock=1,fragment=frag) Type {
SWIG_set_constant("$symname", from_meth(SWIG_static_cast($value,Type)));
%set_constant("$symname", from_meth(%static_cast($value,Type)));
}
%enddef
@ -72,41 +93,41 @@
/* directorin */
%define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
%define %value_directorin_typemap(from_meth,frag,Type...)
%typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN {
$input = from_meth(SWIG_static_cast(*$1_name,Type));
$input = from_meth(%static_cast(*$1_name,Type));
}
%typemap(directorin,noblock=1,fragment=frag) Type, const Type& {
$input = from_meth(SWIG_static_cast($1_name,Type));
$input = from_meth(%static_cast($1_name,Type));
}
%enddef
/* directorout */
%define SWIG_VALUE_DIRECTOROUT_TYPEMAP(asval_meth,frag,Type...)
%define %value_directorout_typemap(asval_meth,frag,Type...)
%typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
SWIG_dout_fail(res, "$type");
%dirout_fail(res, "$type");
}
*$result = SWIG_static_cast(val, $type);
*$result = %static_cast(val, $type);
}
%typemap(directorout,noblock=1,fragment=frag) Type {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
SWIG_dout_fail(res, "$type");
%dirout_fail(res, "$type");
}
$result = SWIG_static_cast(val,$type);
$result = %static_cast(val,$type);
}
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type val;
int res = asval_meth($input, &val);
if (res != SWIG_OK) {
SWIG_dout_fail(res, "$type");
%dirout_fail(res, "$type");
}
static $basetype temp = SWIG_static_cast(val, $basetype);
static $basetype temp = %static_cast(val, $basetype);
$result = &temp;
}
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
@ -114,23 +135,23 @@
#else
#define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
#define SWIG_VALUE_DIRECTOROUT_TYPEMAP(asval_meth,frag,Type...)
#define %value_directorin_typemap(from_meth,frag,Type...)
#define %value_directorout_typemap(asval_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* throws */
%define SWIG_VALUE_THROWS_TYPEMAP(from_meth,frag,Type...)
%define %value_throws_typemap(from_meth,frag,Type...)
%typemap(throws,noblock=1,fragment=frag) Type {
SWIG_raise(from_meth(SWIG_static_cast($1,Type)), "$type", 0);
%raise(from_meth(%static_cast($1,Type)), "$type", 0);
}
%enddef
/* typecheck */
%define SWIG_VALUE_TYPECHECK_TYPEMAP(check,asval_meth,frag,Type...)
%define %value_typecheck_typemap(check,asval_meth,frag,Type...)
%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& {
$1 = (asval_meth($input, 0) == SWIG_OK);
}
@ -139,25 +160,25 @@
/*---------------------------------------------------------------------
* typemap definition for types with AsVal methods
*---------------------------------------------------------------------*/
%define %typemap_asval(CheckCode, AsValMeth, AsValFrag, Type...)
SWIG_VALUE_IN_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
SWIG_VALUE_VARIN_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
SWIG_VALUE_DIRECTOROUT_TYPEMAP(SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
SWIG_VALUE_TYPECHECK_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
SWIG_VALUE_INPUT_TYPEMAP(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
%define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...)
%value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
%value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
%value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type);
%value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
%value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with from method
*---------------------------------------------------------------------*/
%define %typemap_from(FromMeth, FromFrag, Type...)
SWIG_VALUE_OUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_VAROUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_CONSTCODE_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_DIRECTORIN_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_THROWS_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
%define %typemaps_from(FromMeth, FromFrag, Type...)
%value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type);
%enddef
@ -165,22 +186,22 @@
* typemap definition for types with alval/from method
*---------------------------------------------------------------------*/
%define %typemap_asvalfrom(CheckCode, AsValMeth, FromMeth,
%define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth,
AsValFrag, FromFrag, Type...)
%typemap_asval(SWIG_arg(CheckCode), SWIG_arg(AsValMeth), SWIG_arg(AsValFrag), Type);
%typemap_from(SWIG_arg(FromMeth), SWIG_arg(FromFrag), Type);
SWIG_VALUE_INOUT_TYPEMAP(Type);
%typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type);
%typemaps_from(%arg(FromMeth), %arg(FromFrag), Type);
%value_inout_typemap(Type);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with for 'normalized' asval/from methods
*---------------------------------------------------------------------*/
%define %typemap_asvalfromn(CheckCode, Type...)
%typemap_asvalfrom(SWIG_arg(CheckCode),
%define %typemaps_asvalfromn(CheckCode, Type...)
%typemaps_asvalfrom(%arg(CheckCode),
SWIG_AsVal(Type),
SWIG_From(Type),
SWIG_arg(SWIG_AsVal_frag(Type)),
SWIG_arg(SWIG_From_frag(Type)),
%arg(SWIG_AsVal_frag(Type)),
%arg(SWIG_From_frag(Type)),
Type);
%enddef

View file

@ -2,19 +2,23 @@
* Void * - Accepts any kind of pointer
* ------------------------------------------------------------ */
#if !defined(VOID_Object)
#error "VOID_Object must be defined using %define_void_object"
#endif
/* in */
%typemap(in,noblock=1) void * {
if (SWIG_ConvertPtr($input,SWIG_as_voidptrptr(&$1), 0, $disown) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "$type", $argnum);
if (SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "$type", $argnum);
}
}
%typemap(freearg) void * "";
%typemap(in,noblock=1) void * const& ($*ltype temp) {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError, "Stype", $argnum);
if (SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
%argument_fail(SWIG_TypeError, "Stype", $argnum);
}
$1 = &temp;
}
@ -23,7 +27,7 @@
/* out */
%typemap(out,noblock=1) void {
SWIG_set_result(SWIG_VoidObject());
$result = VOID_Object;
}
/* varin */
@ -31,7 +35,7 @@
%typemap(varin,noblock=1) void * {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN) != SWIG_OK) {
SWIG_var_fail(SWIG_TypeError, "$type", "$name");
%variable_fail(SWIG_TypeError, "$type", "$name");
}
$1 = ($1_ltype) temp;
}
@ -50,9 +54,9 @@
%typemap(directorout,noblock=1) void * (void *argp) {
if (SWIG_ConvertPtr($input, &argp, 0, 0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError,"$type");
%dirout_fail(SWIG_TypeError,"$type");
}
$result = SWIG_reinterpret_cast(argp, $ltype);
$result = %reinterpret_cast(argp, $ltype);
}

View file

@ -0,0 +1,4 @@
%include <typemaps/strings.swg>
%typemaps_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen,
"<wchar.h>", WCHAR_MIN, WCHAR_MAX)