massive typemap unification

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-18 13:24:15 +00:00
commit 7e5e4fd1f9
144 changed files with 6378 additions and 7248 deletions

16
Lib/typemaps/README Normal file
View file

@ -0,0 +1,16 @@
/* -----------------------------------------------------------------------------
* 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
implicit.swg Allow the use of implicit C++ constructors

79
Lib/typemaps/cdata.swg Normal file
View file

@ -0,0 +1,79 @@
/* -----------------------------------------------------------------------------
* cdata.i
*
* Author(s): David Beazley (beazley@cs.uchicago.edu)
*
* This library file contains macros for manipulating raw C data as strings.
*
* $Header$
* ----------------------------------------------------------------------------- */
%{
typedef struct SWIGCDATA {
char *data;
size_t len;
} SWIGCDATA;
%}
/* -----------------------------------------------------------------------------
* Typemaps for returning binary data
* ----------------------------------------------------------------------------- */
%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA {
$result = SWIG_FromCharPtrAndSize($1.data,$1.len);
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE);
/* -----------------------------------------------------------------------------
* %cdata(TYPE [, NAME])
*
* Convert raw C data to a binary string.
* ----------------------------------------------------------------------------- */
%define %cdata(TYPE,NAME...)
%insert("header") {
#ifdef __cplusplus
extern "C" {
#endif
#if #NAME == ""
static SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements)
#else
static SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements)
#endif
{
SWIGCDATA d;
d.data = (char *) ptr;
#if #TYPE != "void"
d.len = nelements*sizeof(TYPE);
#else
d.len = nelements;
#endif
return d;
}
#ifdef __cplusplus
}
#endif
}
#ifdef __cplusplus
extern "C"
#endif
#if #NAME == ""
SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements = 1);
#else
SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1);
#endif
%enddef
%rename(cdata) ::cdata_void(void *ptr, size_t nelements = 1);
%cdata(void);
/* Memory move function */
void memmove(void *data, const void *indata, size_t inlen);

273
Lib/typemaps/cstring.swg Normal file
View file

@ -0,0 +1,273 @@
/*
* 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 %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, size_t size, int alloc) {
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) (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) 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) 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, size_t n, int alloc) {
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) 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, size_t n, int alloc, 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) 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

64
Lib/typemaps/enumint.swg Normal file
View file

@ -0,0 +1,64 @@
/* ------------------------------------------------------------
* Enums mapped as integer values
* ------------------------------------------------------------ */
%apply int { enum SWIGTYPE };
%apply const int& { const enum SWIGTYPE& };
%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);
} else {
temp = SWIG_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");
} else {
int ecode = SWIG_AsVal(int)($input, SWIG_reinterpret_cast(&$1,int*));
if (ecode != SWIG_OK) {
SWIG_var_fail(ecode, "$type", "$name");
}
}
}
/*
typemaps needed due to unnamed enums
*/
%define SWIG_ENUM_OUT_TYPEMAPS(from_meth,frag)
%typemap(out,noblock=1,fragment=frag) enum SWIGTYPE {
$result = from_meth(($1));
}
%typemap(out,noblock=1,fragment=frag) const enum SWIGTYPE& {
$result = from_meth((*$1));
}
%typemap(varout,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
$result = from_meth($1);
}
%typemap(constcode,noblock=1,fragment=frag) enum SWIGTYPE {
SWIG_set_constant("$symname", from_meth($value));
}
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE *DIRECTORIN {
$input = from_meth(*$1_name);
}
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
$input = from_meth($1_name);
}
%typemap(throws,noblock=1,fragment=frag) enum SWIGTYPE {
SWIG_exception_obj(0,"$type", from_meth($1));
}
%enddef
SWIG_ENUM_OUT_TYPEMAPS(SWIG_From(int),SWIG_From_frag(int));

204
Lib/typemaps/implicit.swg Normal file
View file

@ -0,0 +1,204 @@
/*
The %implict macro allows a SwigType (Class) to be accepted
as an input parameter and use its implicit constructors when needed.
For example:
%implicit(A, int, double, B);
%inline
{
struct B { };
struct A
{
int ii;
A(int i) { ii = 1; }
A(double d) { ii = 2; }
A(const B& b) { ii = 3; }
};
int get(A a) { return a.ii; }
}
Here, you can call 'get' as
get(1) ==> get(A(1))
get(2.0) ==> get(A(2.0))
get(B()) ==> get(A(B()))
and swig will construct an 'A' temporal variable using the
corresponding implicit constructor.
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.
*/
%check_swig_object()
%define %implicit_type(Type...)
%traits_swigtype(Type);
%enddef
%define %implicit_frag(Type...) ,fragment=SWIG_Traits_frag(Type) %enddef
%define %implicit_code(Type...)
if (swig::asval<Type>(obj, 0)) {
Type _v;
swig::asval<Type>(obj, &_v);
if (val) *val = new value_type(_v);
return SWIG_NEWOBJ;
}
%enddef
/* implicit */
%define %implicit(Type, ...)
%formacro_1(%implicit_type,__VA_ARGS__);
%fragment(SWIG_Traits_frag(Type),"header",
fragment="StdTraits"
%formacro_1(%implicit_frag,__VA_ARGS__)) %{
namespace swig {
template <> struct traits<Type > {
typedef pointer_category category;
static const char* type_name() { return "Type"; }
};
template <> struct traits_asptr< Type > {
typedef Type value_type;
static int asptr(SWIG_Object obj, value_type **val) {
Type *vptr;
static swig_type_info* desc = SWIG_TypeQuery("Type *");
if ((SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0) == SWIG_OK)) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
%formacro_1(%implicit_code,__VA_ARGS__)
}
return 0;
}
};
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%enddef
/* implicit_1 */
%define %implicit_1(Type, Imp1)
%traits_swigtype(Imp1);
%fragment(SWIG_Traits_frag(Type),"header",
fragment="StdTraits",
fragment=SWIG_Traits_frag(Imp1)) %{
namespace swig {
template <> struct traits< Type > {
typedef pointer_category category;
static const char* type_name() { return "Type"; }
};
template <> struct traits_asptr< Type > {
typedef Type value_type;
static int asptr(SWIG_Object obj, value_type **val) {
Type *vptr;
static swig_type_info* desc = SWIG_TypeQuery("Type *");
if ((SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0) == SWIG_OK)) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
%implicit_code(Imp1);
}
return 0;
}
};
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%enddef
/* implicit_2 */
%define %implicit_2(Type, Imp1, Imp2)
%traits_swigtype(Imp1);
%traits_swigtype(Imp2);
%fragment(SWIG_Traits_frag(Type),"header",
fragment="StdTraits",
fragment=SWIG_Traits_frag(Imp1),
fragment=SWIG_Traits_frag(Imp2)) %{
namespace swig {
template <> struct traits< Type > {
typedef pointer_category category;
static const char* type_name() { return "Type"; }
};
template <> struct traits_asptr< Type > {
typedef Type value_type;
static int asptr(SWIG_Object obj, value_type **val) {
Type *vptr;
static swig_type_info* desc = SWIG_TypeQuery("Type *");
if ((SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0) == SWIG_OK)) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
%implicit_code(Imp1);
%implicit_code(Imp2);
}
return 0;
}
};
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%enddef
/* implicit_3 */
%define %implicit_3(Type, Imp1, Imp2, Imp3)
%traits_swigtype(Imp1);
%traits_swigtype(Imp2);
%traits_swigtype(Imp3);
%fragment(SWIG_Traits_frag(Type),"header",
fragment="StdTraits",
fragment=SWIG_Traits_frag(Imp1),
fragment=SWIG_Traits_frag(Imp2),
fragment=SWIG_Traits_frag(Imp3)) %{
namespace swig {
template <> struct traits< Type > {
typedef pointer_category category;
static const char* type_name() { return "Type"; }
};
template <> struct traits_asptr< Type > {
typedef Type value_type;
static int asptr(SWIG_Object obj, value_type **val) {
Type *vptr;
static swig_type_info* desc = SWIG_TypeQuery("Type *");
if ((SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0) == SWIG_OK)) {
if (val) *val = vptr;
return SWIG_OLDOBJ;
} else {
%implicit_code(Imp1);
%implicit_code(Imp2);
%implicit_code(Imp3);
}
return 0;
}
};
}
%}
%typemap_traits_ptr(SWIG_CCode(POINTER),Type);
%enddef

278
Lib/typemaps/inoutlist.swg Normal file
View file

@ -0,0 +1,278 @@
/* ------------------------------------------------------------
*
* 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,
* 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);
* %include <typemaps/inoutlist.swg>
*
* while in Python it is used as:
*
* #define SWIG_append_result(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.
*
* If you forget to define SWIG_append_result, 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.
//
//#define SWIG_INOUT_NODEF
//
// Use the following definition to enable the INPUT parameters to
// accept both 'by value' and 'pointer' objects.
//
#define SWIG_INPUT_ACCEPT_PTRS
// ------------------------------------------------------------------------
// Pointer handling
//
// These mappings provide support for input/output arguments and common
// uses for C/C++ pointers.
// ------------------------------------------------------------------------
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
/*
The following methods can be applied to turn a pointer into a simple
"input" value. That is, instead of passing a pointer to an object,
you would use a real value instead.
To use these, suppose you had a C function like this :
double fadd(double *a, double *b) {
return *a+*b;
}
You could wrap it with SWIG as follows :
double fadd(double *INPUT, double *INPUT);
or you can use the %apply directive :
%apply double *INPUT { double *a, double *b };
double fadd(double *a, double *b);
*/
#ifdef SWIG_INPUT_ACCEPT_PTRS
#define SWIG_CheckInputPtr(input,arg,desc,disown) (SWIG_ConvertPtr(input,SWIG_as_voidptrptr(arg),desc,disown) == SWIG_OK)
#else
#define SWIG_CheckInputPtr(input,arg,desc,disown) (0)
#endif
%define _SWIG_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)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$*ltype",$argnum);
}
temp = SWIG_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)) {
Type val;
int ecode = asval_meth($input, &val);
if (ecode != SWIG_OK) {
SWIG_arg_fail(ecode, "$*ltype",$argnum);
}
temp = SWIG_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)));
}
%enddef
%define _SWIG_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);
}
}
%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);
}
if (!$1) {
SWIG_arg_nullref("$type",$argnum);
}
}
%typemap(freearg,noblock=1) Type *INPUT, Type &INPUT {
if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
}
%typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT {
$1 = asptr_meth($input, (Type**)0) != 0;
}
%enddef
// OUTPUT typemaps. These typemaps are used for parameters that
// are output only. The output value is appended to the result as
// a list element.
/*
The following methods can be applied to turn a pointer into an "output"
value. When calling a function, no input value would be given for
a parameter, but an output value would be returned. In the case of
multiple output values, they are returned in the form of a list.
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
returns the integer part in one of its parameters).K:
double modf(double x, double *ip);
You could wrap it with SWIG as follows :
double modf(double x, double *OUTPUT);
or you can use the %apply directive :
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);
The output of the function would be a list containing both output
values.
*/
%define _SWIG_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)));
}
%enddef
// INOUT
// Mappings for an argument that is both an input and output
// parameter
/*
The following methods can be applied to make a function parameter both
an input and output value. This combines the behavior of both the
"INPUT" and "OUTPUT" methods described earlier. Output values are
returned in the form of a list.
For example, suppose you were trying to wrap the following function :
void neg(double *x) {
*x = -(*x);
}
You could wrap it with SWIG as follows :
void neg(double *INOUT);
or you can use the %apply directive :
%apply double *INOUT { double *x };
void neg(double *x);
Unlike C, this mapping does not directly modify the input value.
Rather, the modified input value shows up as the return value of the
function. Thus, to apply this function to a variable you might do
this :
x = neg(x)
Note : previous versions of SWIG used the symbol 'BOTH' to mark
input/output arguments. This is still supported, but will be slowly
phased out in future releases.
*/
%define _SWIG_VALUE_INOUT_TYPEMAP(Type)
%typemap(in) Type *INOUT = Type *INPUT;
%typemap(in) Type &INOUT = Type &INPUT;
%typemap(typecheck) Type *INOUT = Type *INPUT;
%typemap(typecheck) Type &INOUT = Type &INPUT;
%typemap(argout) Type *INOUT = Type *OUTPUT;
%typemap(argout) Type &INOUT = Type &OUTPUT;
%enddef
%define _SWIG_PTR_INOUT_TYPEMAP(Type)
_SWIG_VALUE_INOUT_TYPEMAP(SWIG_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 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 SWIG_VALUE_OUTPUT_TYPEMAP(_f,_ff,...) \
_SWIG_VALUE_OUTPUT_TYPEMAP(SWIG_arg(_f),SWIG_arg(_ff),SWIG_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__))
#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(...)
#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));
%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));
%enddef

View file

@ -0,0 +1,25 @@
/* ------------------------------------------------------------
* --- ANSI/Posix C/C++ types ---
* ------------------------------------------------------------ */
%apply unsigned long { size_t };
%apply const unsigned long& { const size_t& };
%apply unsigned long& { size_t& };
%apply long { ptrdiff_t };
%apply const long& { const ptrdiff_t& };
%apply long& { ptrdiff_t& };
#ifdef __cplusplus
%apply unsigned long { std::size_t };
%apply const unsigned long& { const std::size_t& };
%apply unsigned long& { std::size_t& };
%apply long { std::ptrdiff_t };
%apply const long& { const std::ptrdiff_t& };
%apply long& { std::ptrdiff_t& };
#endif

132
Lib/typemaps/primtypes.swg Normal file
View file

@ -0,0 +1,132 @@
/* ------------------------------------------------------------
* typemap for primitive type with no pointer representation
* ------------------------------------------------------------ */
%define %typemap_primitive(Code, Type...)
%typemap_asvalfromn(SWIG_arg(Code), Type);
%enddef
/* ------------------------------------------------------------
* Primitive Type Macros
* ------------------------------------------------------------ */
/* useful macros to derive typemap declarations from primitive types */
%define _apply_macro(macro, arg2, arg1...)
#if #arg1 != ""
macro(SWIG_arg(arg1),arg2);
#else
macro(arg2);
#endif
%enddef
/* Apply macro to the order types */
%define %apply_ctypes(Macro,...)
_apply_macro(Macro, bool , __VA_ARGS__);
_apply_macro(Macro, signed char , __VA_ARGS__);
_apply_macro(Macro, unsigned char , __VA_ARGS__);
_apply_macro(Macro, short , __VA_ARGS__);
_apply_macro(Macro, unsigned short , __VA_ARGS__);
_apply_macro(Macro, int , __VA_ARGS__);
_apply_macro(Macro, unsigned int , __VA_ARGS__);
_apply_macro(Macro, long , __VA_ARGS__);
_apply_macro(Macro, unsigned long , __VA_ARGS__);
_apply_macro(Macro, long long , __VA_ARGS__);
_apply_macro(Macro, unsigned long long , __VA_ARGS__);
_apply_macro(Macro, float , __VA_ARGS__);
_apply_macro(Macro, double , __VA_ARGS__);
_apply_macro(Macro, char , __VA_ARGS__);
_apply_macro(Macro, wchar_t , __VA_ARGS__);
%enddef
/* apply the Macro(Type) to all the C++ types */
%define %apply_cpptypes(Macro,...)
%apply_ctypes(Macro, __VA_ARGS__)
_apply_macro(Macro, std::string, __VA_ARGS__);
_apply_macro(Macro, std::complex<float>, __VA_ARGS__);
_apply_macro(Macro, std::complex<double>, __VA_ARGS__);
%enddef
/* apply the Macro2(Type1, Type2) to all the C++ types */
%define %apply_cpptypes_2(Macro2)
%apply_cpptypes(%apply_cpptypes, Macro2)
%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);
%enddef
/* ------------------------------------------------------------
* common fragments and macro helpers
* ------------------------------------------------------------ */
%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

160
Lib/typemaps/ptrtypes.swg Normal file
View file

@ -0,0 +1,160 @@
/*
Value typemaps (Type, const Type&) for "Ptr" types, such as swig
wrapped classes, that define the AsPtr/From methods
*/
/* in */
%define SWIG_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); }
$1 = *ptr;
if (res == SWIG_NEWOBJ) SWIG_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); }
$1 = ptr;
}
%typemap(freearg,noblock=1) const Type & {
if (res$argnum == SWIG_NEWOBJ) SWIG_delete($1);
}
%enddef
/* varin */
%define SWIG_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"); }
$1 = *ptr;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
}
%enddef
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorout */
%define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
%typemap(directorargout,fragment=frag) Type *DIRECTOROUT ($*1_ltype temp) {
Type *ptr = 0;
int res = $input ? asptr_meth($input, &ptr) : 0;
if (!res || !ptr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
temp = *ptr;
$result = &temp;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
}
}
%typemap(directorout,fragment=frag) Type {
Type *ptr = 0;
int res = asptr_meth($input, &ptr);
if (!res || !ptr) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
$result = *ptr;
if (res == SWIG_NEWOBJ) SWIG_delete(ptr);
}
}
%typemap(directorout,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
Type *ptr = 0;
int res = asptr_meth($input, &ptr);
if (!res) {
SWIG_dout_fail(SWIG_TypeError,"$type");
} else {
if (!ptr) {
SWIG_dout_nullref("$type");
} else {
if (res == SWIG_NEWOBJ) {
/* Possible thread/reentrant problem here! */
static $*ltype temp = *ptr;
$result = &temp;
SWIG_delete(ptr);
} else {
$result = ptr;
}
}
}
}
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
%enddef
#else
#define SWIG_PTR_DIRECTOROUT_TYPEMAP(asptr_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* typecheck */
%define SWIG_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
SWIG_AsVal(Type)(SWIG_Object obj, Type *val)
{
Type *v = (Type *)0;
int res = SWIG_AsPtr(Type)(obj, &v);
if (!res || !v) return 0;
if (val) {
*val = *v;
if (res == SWIG_NEWOBJ) SWIG_delete(v);
}
return 1;
}
%}
%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);
%enddef
/*
typemap for simple swig types with only 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)),
Type);
%enddef

View file

@ -0,0 +1,69 @@
//
// String
//
/* 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)
{
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;
}
}
}
%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
%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
#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)

505
Lib/typemaps/strings.swg Normal file
View file

@ -0,0 +1,505 @@
//
// Use the macro SWIG_PRESERVE_CARRAY_SIZE if you prefer to preserve
// the size of char arrays, ie
// ------------------------------------------
// C Side => Language Side
// ------------------------------------------
// char name[5] = "hola" => 'hola\0'
//
// the default behaviour is
//
// char name[5] = "hola" => 'hola'
//
//
//#define SWIG_PRESERVE_CARRAY_SIZE
/* ------------------------------------------------------------
* String typemaps for type Char (char or wchar_t)
* ------------------------------------------------------------ */
%define %_typemap_string(Char,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen,
SWIG_AsCharPtr,
SWIG_FromCharPtr,
SWIG_AsCharArray)
/* in */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr)
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);
}
$1 = buf;
}
%typemap(freearg,noblock=1) Char *, const Char * {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (Char *buf, int alloc)
{
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = &temp;
}
%typemap(freearg, noblock=1) Char const*& {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
/* out */
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* {
SWIG_set_result(SWIG_FromCharPtr($1));
}
%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& {
SWIG_set_result(SWIG_FromCharPtr(*$1));
}
/* varin */
%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");
}
if ($1) SWIG_delete_array($1);
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? SWIG_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");
}
if (alloc == SWIG_NEWOBJ) {
$1 = cptr;
} else {
$1 = csize ? SWIG_new_copy_array(cptr, csize, Char) : 0;
}
}
/* varout */
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* {
$result = SWIG_FromCharPtr($1);
}
/* meberin */
%typemap(memberin,noblock=1) Char * {
if ($1) SWIG_delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
} else {
$1 = 0;
}
}
%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);
} else {
$1 = 0;
}
}
/* globalin */
%typemap(globalin,noblock=1) Char * {
if ($1) SWIG_delete_array($1);
if ($input) {
size_t size = SWIG_CharPtrLen($input) + 1;
$1 = SWIG_new_copy_array($input, size, Char);
} else {
$1 = 0;
}
}
%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);
} else {
$1 = 0;
}
}
/* constant */
%typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr)
Char *, Char const*, Char * const, Char const* const {
SWIG_set_constant("$symname", SWIG_FromCharPtr($value));
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorin */
%typemap(directorin,fragment=#SWIG_FromCharPtr,noblock=1)
Char *, Char const*, Char *const, Char const *const,
Char const *&, Char *const &, Char const *const & {
$input = SWIG_FromCharPtr($1_name);
}
/* directorout */
%typemap(directorout,fragment=#SWIG_AsCharPtr,noblock=1) Char * (Char* buf, int alloc) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
}
$result = buf;
}
%typemap(directorout,fragment=#SWIG_AsCharPtr) Char * const& (Char* buf, int alloc) {
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
}
$result = ($1_ltype) &buf;
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* typecheck */
%typemap(typecheck,noblock=1,precedence=SWIG_TYPECHECK_STRING,
fragment=#SWIG_AsCharPtr) Char *, Char const*& {
$1 = (SWIG_AsCharPtr($input, 0, 0) == SWIG_OK);
}
/* throws */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * {
SWIG_exception_obj(0, "$type", SWIG_FromCharPtr($1));
}
/* ------------------------------------------------------------
* Unknown size const Character array Char[ANY] handling
* ------------------------------------------------------------ */
%apply Char* { Char [] };
%apply const Char* { const Char [] };
%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char []
{
SWIG_var_fail(SWIG_AttributeError, "$type", "read-only $name");
}
/* ------------------------------------------------------------
* Fix size Character array Char[ANY] handling
* ------------------------------------------------------------ */
/* memberin and globalin typemaps */
%typemap(memberin,noblock=1) Char [ANY]
{
if ($input) memcpy($1,$input,$1_dim0*sizeof(Char));
else memset($1,0,$1_dim0*sizeof(Char));
}
%typemap(globalin,noblock=1) Char [ANY]
{
if ($input) memcpy($1,$input,$1_dim0*sizeof(Char));
else memset($1,0,$1_dim0*sizeof(Char));
}
/* in */
%typemap(in,noblock=1,fragment=#SWIG_AsCharArray)
Char [ANY] (Char temp[$1_dim0]),
const Char [ANY](Char temp[$1_dim0])
{
if (SWIG_AsCharArray($input, temp, $1_dim0) != SWIG_OK) {
SWIG_arg_fail(SWIG_TypeError,"$type",$argnum);
}
$1 = temp;
}
%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);
}
$1 = &temp;
}
%typemap(out,fragment=#SWIG_FromCharPtrAndSize)
Char [ANY], const Char[ANY]
{
size_t size = $1_dim0;
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
SWIG_set_result(SWIG_FromCharPtrAndSize($1, size));
}
/* varin */
%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");
}
}
/* varout */
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char [ANY], const Char [ANY] {
size_t size = $1_dim0;
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
$result = SWIG_FromCharPtrAndSize($1, size);
}
/* constant */
%typemap(constcode,fragment=#SWIG_FromCharPtrAndSize)
Char [ANY], const Char [ANY]
{
size_t size = $value_dim0;
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($value[size - 1] == '\0')) --size;
%#endif
SWIG_set_constant("$symname", SWIG_FromCharPtrAndSize($value,size));
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorin */
%typemap(directorin,fragment=#SWIG_FromCharPtrAndSize)
Char [ANY], const Char [ANY]
{
size_t size = $1_dim0;
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1_name[size - 1] == '\0')) --size;
%#endif
$input = SWIG_FromCharPtrAndSize($1_name, size);
}
/* directorout */
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray)
Char [ANY] (Char temp[$result_dim0]),
const Char [ANY] (Char temp[$result_dim0])
{
if (SWIG_AsCharArray($input, temp, $result_dim0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError, "$type");
}
$result = temp;
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* typecheck */
%typemap(typecheck,noblock=1,precedence=SWIG_TYPECHECK_STRING,
fragment=#SWIG_AsCharArray)
Char [ANY], const Char[ANY] {
$1 = (SWIG_AsCharArray($input, (Char *)0, $1_dim0) == SWIG_OK);
}
/* throws */
%typemap(throws,fragment=#SWIG_FromCharPtrAndSize)
Char [ANY], const Char[ANY]
{
size_t size = $1_dim0;
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
SWIG_exception_obj(0, "$type", SWIG_FromCharPtrAndSize($1, size));
}
/* -------------------------------------------------------------------
* --- Really fix size Char arrays, including '\0'chars at the end ---
* ------------------------------------------------------------------- */
%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
$result = 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));
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
$input = SWIG_FromCharPtrAndSize($1_name, $1_dim0);
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
{
SWIG_exception_obj(0, "$type", SWIG_FromCharPtrAndSize($1, $1_dim0));
}
/* ------------------------------------------------------------
* --- String & length ---
* ------------------------------------------------------------ */
/* Here len doesn't include the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0),
(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);
}
$1 = SWIG_static_cast(buf, $1_ltype);
$2 = SWIG_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);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
%typemap(freearg) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
/* Here size includes the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0),
(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);
}
$1 = SWIG_static_cast(buf, $1_ltype);
$2 = SWIG_numeric_cast(size, $2_ltype);
}
%typemap(freearg, noblock=1) (Char *STRING, size_t SIZE) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
%typemap(freearg) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
/* reverse order versions */
/* Here len doesn't include the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(size_t LENGTH, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
(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);
}
$2 = SWIG_static_cast(buf, $2_ltype) ;
$1 = SWIG_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);
}
/* old 'int' form */
%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
%typemap(freearg) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
/* Here size includes the '0' terminator */
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
(size_t SIZE, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
(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);
}
$2 = SWIG_static_cast(buf, $2_ltype) ;
$1 = SWIG_numeric_cast(size, $1_ltype) ;
}
%typemap(freearg, noblock=1) (size_t SIZE, Char *STRING) {
if (alloc$argnum == SWIG_NEWOBJ) SWIG_delete_array(buf$argnum);
}
/* old 'int' form */
%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
%typemap(freearg) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
%enddef
%define %typemap_string(Char, CharName,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen)
/* String fragment methods */
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_From##CharName##Ptr(const Char *cptr)
{
return SWIG_FromCharPtrAndSize(cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0));
}
}
%fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_From##CharName##Array(const Char *cptr, size_t size)
{
return SWIG_FromCharPtrAndSize(cptr, 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))
}
%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)
{
Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
if (SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc) == SWIG_OK) {
if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize;
if (csize <= size) {
if (val) {
if (csize) memcpy(val, cptr, csize);
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
}
return SWIG_OK;
}
}
return SWIG_TypeError;
}
}
%_typemap_string(Char,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen,
SWIG_As##CharName##Ptr,
SWIG_From##CharName##Ptr,
SWIG_As##CharName##Array)
%enddef

241
Lib/typemaps/swigmacros.swg Normal file
View file

@ -0,0 +1,241 @@
/* -----------------------------------------------------------------------------
* SWIG API. Portion only visible from SWIG
* ----------------------------------------------------------------------------- */
/* basic preprocessor macros */
#define SWIG_arg(Arg...) Arg
#define SWIG_str(Type...) #Type
#define SWIG_block(Block...) do { Block; } while(0)
/* casting operators */
#ifdef SWIG_NO_CPLUSPLUS_CAST
/* Disable 'modern' cplusplus casting operators */
# ifdef SWIG_CPLUSPLUS_CAST
# undef SWIG_CPLUSPLUS_CAST
# endif
#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)
#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)
#endif /* __cplusplus */
/* macros for allocating/freeing elements */
#if defined(__cplusplus)
# define SWIG_new(Type...) (new Type)
# define SWIG_new_copy(val,Type...) (new Type(val))
# 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
#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)
#endif /* __cplusplus */
/* macros for fragments/typemaps */
#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 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(n, v) SWIG_SetConstantObj(n,v)
/* macros for error manipulation */
#define SWIG_TypeErrorFmt(_type,_name) "expected '"_type"'"
#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 of type '"_type"'"
#define SWIG_ArgNullRefFmt(_type, _argn) "null reference " SWIG_ArgFailFmt(_type, _argn)
#define SWIG_VarNullRefFmt(_type, _name) "null reference " SWIG_VarFailFmt(_type, _name)
#define SWIG_OutNullRefFmt(_type) "null reference " SWIG_OutFailFmt(_type)
#define SWIG_ArgFail(code,type,argn) SWIG_SetErrorMsg(code,SWIG_ArgFailFmt(type, argn))
#define SWIG_VarFail(code,type,name) SWIG_SetErrorMsg(code,SWIG_VarFailFmt(type, name))
#define SWIG_ArgNullRef(type,argn) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_ArgNullRefFmt(type, argn))
#define SWIG_VarNullRef(type,name) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_VarNullRefFmt(type, name))
#define SWIG_OutNullRef(type) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_OutNullRefFmt(type))
#define SWIG_set_errmsg(code,msg...) SWIG_SetErrorMsg(code,msg)
#define SWIG_set_errobj(code,obj) SWIG_SetErrorObj(code,obj)
#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_var_fail)
#define SWIG_var_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_var_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_exception_obj(desc, type, obj) SWIG_error_block(SWIG_ExceptionObj(desc, type, obj); SWIG_fail)
/*
Macros to define and check the Language dependent Swig object
Use it, for example in Tcl, as
%define_swig_object(Tcl_Obj)
*/
#define SWIG_Object __NULL__
%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
* ----------------------------------------------------------------------------- */
/* 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,...)
macro(arg1)
#if #__VA_ARGS__ != "__fordone__"
%_formacro_1(macro, __VA_ARGS__)
#endif
%enddef
/* for loop for macro with one argument */
%define %formacro_1(macro,...)
%_formacro_1(macro,__VA_ARGS__,__fordone__)
%enddef
/* for loop for macro with two arguments */
%define %_formacro_2(macro, arg1, arg2, ...)
macro(arg1, arg2)
#if #__VA_ARGS__ != "__fordone__"
%_formacro_2(macro, __VA_ARGS__)
#endif
%enddef
/* for loop for macro with two arguments */
%define %formacro_2(macro,...)
%_formacro_2(macro, __VA_ARGS__, __fordone__)
%enddef
/*
mark a flag, ie, define a macro name but ignore it in
the interface.
the flags latter can be used with %evalif
*/
%define %swig_mark_flag(x)
%ignore x;
#define x 1
%enddef
/*
%swig_equal_type and %swig_order_type flagged a type of having equal (==,!=)
and/or order methods (<=,>=,<,>).
*/
#define %swig_equal_type(...) %swig_mark_flag(SWIG_EqualType(__VA_ARGS__))
#define %swig_order_type(...) \
%swig_mark_flag(SWIG_EqualType(__VA_ARGS__)) \
%swig_mark_flag(SWIG_OrderType(__VA_ARGS__))
/*
%evalif and %evalif_2 are use to evaluate or process
an expression if the given predicate is 'true' (1).
*/
%define %_evalif(_x,_expr)
#if _x == 1
_expr
#endif
%enddef
%define %_evalif_2(_x,_y,_expr)
#if _x == 1 && _y == 1
_expr
#endif
%enddef
%define %evalif(_x,...)
%_evalif(SWIG_arg(_x),SWIG_arg(__VA_ARGS__))
%enddef
%define %evalif_2(_x,_y,...)
%_evalif_2(SWIG_arg(_x),SWIG_arg(_y),SWIG_arg(__VA_ARGS__))
%enddef

View file

@ -0,0 +1,29 @@
/* ------------------------------------------------------------
* Language Object * - Just pass straight through unmodified
* ------------------------------------------------------------ */
%check_swig_object()
%typemap(in) SWIG_Object "$1 = $input;";
%typemap(out,noblock=1) SWIG_Object {
SWIG_set_result($1);
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIG_Object "$1 = ($input != 0);";
%typemap(throws,noblock=1) SWIG_Object {
SWIG_exception_obj(0, "$type", $1);
}
%typemap(constcode,noblock=1) SWIG_Object {
SWIG_set_constant("$symname", $value);
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
%typemap(directorin) SWIG_Object "$input = $1_name";
%typemap(directorout) SWIG_Object "$result = $input;";
#endif /* SWIG_DIRECTOR_TYPEMAPS */

426
Lib/typemaps/swigtype.swg Normal file
View file

@ -0,0 +1,426 @@
/* -----------------------------------------------------------------------------
* --- Input arguments ---
* ----------------------------------------------------------------------------- */
/* 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(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);
}
$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);
}
if (!$1) { SWIG_arg_nullref("$type", $argnum); }
}
/* 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);
}
if (!argp) { SWIG_arg_nullref("$type", $argnum); }
$1 = *argp;
}
/* -----------------------------------------------------------------------------
* --- Output arguments ---
* ----------------------------------------------------------------------------- */
/* Pointers, references */
%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, $owner));
}
%typemap(out, noblock=1) SWIGTYPE* const& {
SWIG_set_result(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*descriptor, $owner));
}
/* Return by value */
%typemap(out, noblock=1) SWIGTYPE {
SWIG_set_result(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN));
}
/* -----------------------------------------------------------------------------
* --- Variable input ---
* ----------------------------------------------------------------------------- */
/* memberin/globalin/varin, for fix arrays. */
%typemap(memberin) SWIGTYPE [ANY] {
$basetype *inp = SWIG_static_cast($input, $basetype *);
if (inp) {
$basetype *dest = SWIG_static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_member_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY] {
$basetype *inp = SWIG_static_cast($input, $basetype *);
if (inp) {
$basetype *dest = SWIG_static_cast($1, $basetype *);
size_t ii = 0;
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_global_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");
} else if (inp) {
size_t ii = 0;
$basetype *dest = SWIG_static_cast($1, $basetype *);
for (; ii < $dim0; ++ii) dest[ii] = inp[ii];
} else {
SWIG_var_nullref("$type", "$name");
}
}
/* memberin/globalin/varin, for fix double arrays. */
%typemap(memberin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_member_nullref("$type","$name");
}
}
} else {
SWIG_member_nullref("$type","$name");
}
}
%typemap(globalin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = SWIG_static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_global_nullref("$type","$name");
}
}
} else {
SWIG_global_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");
} else if (inp) {
$basetype (*dest)[$dim1] = SWIG_static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
} else {
SWIG_var_nullref("$type", "$name");
}
}
} else {
SWIG_var_nullref("$type", "$name");
}
}
/* Pointers, references, and variable size arrays */
%typemap(varin,noblock=1) SWIGTYPE * {
void *temp = 0;
if (SWIG_ConvertPtr($input, &temp, $descriptor, 0) != SWIG_OK) {
SWIG_var_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");
}
%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 (!temp) {
SWIG_var_nullref("$type", "$name");
}
$1 = *(SWIG_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 (!temp) {
SWIG_var_nullref("$type", "$name");
}
$1 = *(SWIG_reinterpret_cast(temp, $&type));
}
/* -----------------------------------------------------------------------------
* --- Variable output ---
* ----------------------------------------------------------------------------- */
/* Pointers and arrays */
%typemap(varout, noblock=1) SWIGTYPE * {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
}
%typemap(varout, noblock=1) SWIGTYPE [] {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor, 0);
}
/* References */
%typemap(varout, noblock=1) SWIGTYPE & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $descriptor, 0);
}
/* Value */
%typemap(varout, noblock=1) SWIGTYPE {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $&descriptor, 0);
}
/* ------------------------------------------------------------
* --- Typechecking rules ---
* ------------------------------------------------------------ */
%typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
void *ptr = 0;
$1 = (SWIG_ConvertPtr($input, &ptr, $descriptor, 0) == SWIG_OK);
}
%typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & {
void *ptr = 0;
$1 = (SWIG_ConvertPtr($input, &ptr, $descriptor, 0) == SWIG_OK) && (ptr != 0);
}
%typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE {
void *ptr = 0;
$1 = (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0) == SWIG_OK) && (ptr != 0);
}
/* ------------------------------------------------------------
* --- 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);
}
}
%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
SWIG_set_result(SWIG_NewMemberObj(SWIG_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");
}
}
%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
$result = SWIG_NewMemberObj(SWIG_as_voidptr(&$1), sizeof($type), $descriptor);
}
/* ------------------------------------------------------------
* --- function ptr typemaps ---
* ------------------------------------------------------------ */
/*
ISO C++ doesn't allow direct casting of a function ptr to a object
ptr. So, maybe the ptr sizes are not the same, and we need to take
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);
}
}
%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) {
SWIG_set_result(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_exception_obj($&descriptor, "$type", SWIG_NewPointerObj(SWIG_new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN));
}
%typemap(throws,noblock=1) SWIGTYPE * {
SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0));
}
%typemap(throws,noblock=1) SWIGTYPE [ANY] {
SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0));
}
%typemap(throws,noblock=1) SWIGTYPE & {
SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr(&$1),$descriptor,0));
}
/* ------------------------------------------------------------
* --- Special typemaps ---
* ------------------------------------------------------------ */
/* VARARGS_SENTINEL typemap. Used by the %varargs directive. */
%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
/* 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);
}
}
%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");
}
$1 = ($ltype) temp;
}
/* 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));
}
/* INSTANCE typemap */
%typemap(out,noblock=1) SWIGTYPE INSTANCE {
SWIG_set_result(SWIG_NewInstanceObj(SWIG_new_copy($1, $1_ltype), $&1_descriptor,SWIG_POINTER_OWN));
}
%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] {
SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, $owner));
}
%typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr($1), $1_descriptor, 0);
}
%typemap(varout,noblock=1) SWIGTYPE &INSTANCE {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $1_descriptor, 0);
}
%typemap(varout,noblock=1) SWIGTYPE INSTANCE {
$result = SWIG_NewInstanceObj(SWIG_as_voidptr(&$1), $&1_descriptor, 0);
}

167
Lib/typemaps/typemaps.swg Normal file
View file

@ -0,0 +1,167 @@
//
// SWIG Typemap library
// Dave Beazley
// May 5, 1997
//
// Tcl implementation
//
// This library provides standard typemaps for modifying SWIG's behavior.
// With enough entries in this file, I hope that very few people actually
// ever need to write a typemap.
//
// Disclaimer : Unless you really understand how typemaps work, this file
// probably isn't going to make much sense.
//
// ------------------------------------------------------------------------
// Pointer handling
//
// These mappings provide support for input/output arguments and common
// uses for C/C++ pointers.
// ------------------------------------------------------------------------
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
/*
The following methods can be applied to turn a pointer into a simple
"input" value. That is, instead of passing a pointer to an object,
you would use a real value instead.
int *INPUT
short *INPUT
long *INPUT
long long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
unsigned long long *INPUT
unsigned char *INPUT
bool *INPUT
float *INPUT
double *INPUT
To use these, suppose you had a C function like this :
double fadd(double *a, double *b) {
return *a+*b;
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
double fadd(double *INPUT, double *INPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INPUT { double *a, double *b };
double fadd(double *a, double *b);
*/
// OUTPUT typemaps. These typemaps are used for parameters that
// are output only. The output value is appended to the result as
// a list element.
/*
The following methods can be applied to turn a pointer into an "output"
value. When calling a function, no input value would be given for
a parameter, but an output value would be returned. In the case of
multiple output values, they are returned in the form of a Tcl tuple.
int *OUTPUT
short *OUTPUT
long *OUTPUT
long long *OUTPUT
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
unsigned long long *OUTPUT
unsigned char *OUTPUT
bool *OUTPUT
float *OUTPUT
double *OUTPUT
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
returns the integer part in one of its parameters).K:
double modf(double x, double *ip);
You could wrap it with SWIG as follows :
%include <typemaps.i>
double modf(double x, double *OUTPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);
The Tcl output of the function would be a tuple containing both
output values.
*/
// INOUT
// Mappings for an argument that is both an input and output
// parameter
/*
The following methods can be applied to make a function parameter both
an input and output value. This combines the behavior of both the
"INPUT" and "OUTPUT" methods described earlier. Output values are
returned in the form of a Tcl tuple.
int *INOUT
short *INOUT
long *INOUT
long long *INOUT
unsigned int *INOUT
unsigned short *INOUT
unsigned long *INOUT
unsigned long long *INOUT
unsigned char *INOUT
bool *INOUT
float *INOUT
double *INOUT
For example, suppose you were trying to wrap the following function :
void neg(double *x) {
*x = -(*x);
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
void neg(double *INOUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INOUT { double *x };
void neg(double *x);
Unlike C, this mapping does not directly modify the input value (since
this makes no sense in Tcl). Rather, the modified input value shows
up as the return value of the function. Thus, to apply this function
to a Tcl variable you might do this :
x = neg(x)
Note : previous versions of SWIG used the symbol 'BOTH' to mark
input/output arguments. This is still supported, but will be slowly
phased out in future releases.
*/
#ifdef SWIG_INOUT_NODEF
%apply_checkctypes(%typemap_inoutn)
#endif

189
Lib/typemaps/valtypes.swg Normal file
View file

@ -0,0 +1,189 @@
/*---------------------------------------------------------------------
* Value typemaps (Type, const Type&) for value types, such as
* fundamental types (int, double), that define the AsVal/From
* methods.
*---------------------------------------------------------------------*/
/* in */
%define SWIG_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);
}
}
%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;
}
}
%enddef
/* out */
%define SWIG_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)));
}
%typemap(out,noblock=1,fragment=frag) const Type& {
SWIG_set_result(from_meth(SWIG_static_cast(*$1,Type)));
}
%enddef
/* varin */
%define SWIG_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);
}
}
%enddef
/* varout */
%define SWIG_VALUE_VAROUT_TYPEMAP(from_meth,frag,Type...)
%typemap(varout,noblock=1,fragment=frag) Type, const Type& {
$result = from_meth(SWIG_static_cast($1,$basetype));
}
%enddef
/* constant installation code */
%define SWIG_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)));
}
%enddef
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorin */
%define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
%typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN {
$input = from_meth(SWIG_static_cast(*$1_name,Type));
}
%typemap(directorin,noblock=1,fragment=frag) Type, const Type& {
$input = from_meth(SWIG_static_cast($1_name,Type));
}
%enddef
/* directorout */
%define SWIG_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");
} else {
*$result = SWIG_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");
} else {
$result = SWIG_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");
} else {
static $basetype temp = SWIG_static_cast(val, $basetype);
$result = &temp;
}
}
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
%enddef
#else
#define SWIG_VALUE_DIRECTORIN_TYPEMAP(from_meth,frag,Type...)
#define SWIG_VALUE_DIRECTOROUT_TYPEMAP(asval_meth,frag,Type...)
#endif /* SWIG_DIRECTOR_TYPEMAPS */
/* throws */
%define SWIG_VALUE_THROWS_TYPEMAP(from_meth,frag,Type...)
%typemap(throws,noblock=1,fragment=frag) Type {
SWIG_exception_obj(0, "Type", from_meth(SWIG_static_cast($1,$basetype)));
}
%enddef
/* typecheck */
%define SWIG_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);
}
%enddef
/*---------------------------------------------------------------------
* 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);
%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);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with alval/from method
*---------------------------------------------------------------------*/
%define %typemap_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);
%enddef
/*---------------------------------------------------------------------
* typemap definition for types with for 'normalized' asval/from methods
*---------------------------------------------------------------------*/
%define %typemap_asvalfromn(CheckCode, Type...)
%typemap_asvalfrom(SWIG_arg(CheckCode),
SWIG_AsVal(Type),
SWIG_From(Type),
SWIG_arg(SWIG_AsVal_frag(Type)),
SWIG_arg(SWIG_From_frag(Type)),
Type);
%enddef

60
Lib/typemaps/void.swg Normal file
View file

@ -0,0 +1,60 @@
/* ------------------------------------------------------------
* Void * - Accepts any kind of pointer
* ------------------------------------------------------------ */
/* 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);
}
}
%typemap(freearg,noblock=1) 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);
}
$1 = &temp;
}
/* out */
%typemap(out,noblock=1) void {
SWIG_set_result(SWIG_NoneObject());
}
/* varin */
%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");
}
$1 = ($1_ltype) temp;
}
/* typecheck */
%typecheck(SWIG_TYPECHECK_VOIDPTR, noblock=1) void *
{
void *ptr = 0;
$1 = (SWIG_ConvertPtr($input, &ptr, 0, 0) == SWIG_OK);
}
#ifdef SWIG_DIRECTOR_TYPEMAPS
/* directorout */
%typemap(directorout,noblock=1) void * (void *argp) {
if (SWIG_ConvertPtr($input, &argp, 0, 0) != SWIG_OK) {
SWIG_dout_fail(SWIG_TypeError,"$type");
}
$result = SWIG_reinterpret_cast(argp, $ltype);
}
#endif /* SWIG_DIRECTOR_TYPEMAPS */