Many major improvements. Almost all testsuite compiles now.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11189 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2009-04-15 23:30:16 +00:00
commit 32e03aa13d
25 changed files with 1052 additions and 609 deletions

View file

@ -8,7 +8,7 @@
// WARNING: passing function pointers from C as parameters of type (or as
// return values) SWIGTYPE (CLASS::*) causes cast of C function to type
// void(*)() and it is user's responsibility to properly handle this
// function's arguments and return value.
// function's arguments and return value. See 'cpp_basic' test for details.
%insert("runtime") "clabels.swg"
%insert("proxy_header") "cproxy.swg"
@ -28,25 +28,25 @@
%fragment("stdbool_inc", "proxy_header") {#include <stdbool.h>}
// typemaps for function parameters
%typemap(ctype) void, short, int, long, long long, char, float, double "$1_ltype"
%typemap(ctype) unsigned short, unsigned int, unsigned long, unsigned long long, unsigned char "$1_ltype"
%typemap(ctype) void *, short *, int *, long *, long long *, char *, float *, double * "$1_ltype"
%typemap(ctype) void **, short **, int **, long **, long long **, char **, float **, double ** "$1_ltype"
%typemap(ctype) unsigned short *, unsigned int *, unsigned long *, unsigned long long *, unsigned char * "$1_ltype"
%typemap(ctype) unsigned short **, unsigned int **, unsigned long **, unsigned long long **, unsigned char ** "$1_type"
%typemap(ctype) short &, int &, long &, long long &, char &, float &, double & "$1_ltype"
%typemap(ctype) unsigned short &, unsigned int &, unsigned long &, unsigned long long &, unsigned char & "$1_ltype"
%typemap(ctype) const short, const int, const long, const long long, const char, const float, const double "$1_ltype"
%typemap(ctype) const short &, const int &, const long &, const long long &, const char &, const float &, const double & "$1_ltype"
%typemap(ctype) const unsigned short, const unsigned int, const unsigned long, const unsigned long long, const unsigned char "$1_type"
%typemap(ctype) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned long long &, const unsigned char & "$1_ltype"
%typemap(ctype) const void *, const short *, const int *, const long *, const long long *, const char *, const float *, const double * "$1_type"
%typemap(ctype) short *&, int *&, long *&, long long *&, char *&, float *&, double *& "$1_ltype"
%typemap(ctype) const short *&, const int *&, const long *&, const long long *&, const char *&, const float *&, const double *& "$1_basetype **"
%typemap(ctype) short [ANY], int [ANY], long [ANY], long long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], unsigned int [ANY] "/*aaa*/ $1_ltype"
%typemap(ctype) void * [ANY], short * [ANY], int * [ANY], long * [ANY], long long * [ANY], char * [ANY], float * [ANY], double * [ANY] "/*bbb*/ $1_ltype"
%typemap(ctype) void, short, int, long, char, float, double "$1_ltype"
%typemap(ctype) unsigned short, unsigned int, unsigned long, unsigned char "$1_ltype"
%typemap(ctype) void *, short *, int *, long *, char *, float *, double * "$1_ltype"
%typemap(ctype) void **, short **, int **, long **, char **, float **, double ** "$1_ltype"
%typemap(ctype) unsigned short *, unsigned int *, unsigned long *, unsigned char * "$1_ltype"
%typemap(ctype) unsigned short **, unsigned int **, unsigned long **, unsigned char ** "$1_type"
%typemap(ctype) short &, int &, long &, char &, float &, double & "$1_ltype"
%typemap(ctype) unsigned short &, unsigned int &, unsigned long &, unsigned char & "$1_ltype"
%typemap(ctype) const short &, const int &, const long &, const char &, const float &, const double & "$1_ltype"
%typemap(ctype) const short, const int, const long, const char, const float, const double "$1_ltype"
%typemap(ctype) const unsigned short, const unsigned int, const unsigned long, const unsigned char "$1_type"
%typemap(ctype) const void *, const short *, const int *, const long *, const char *, const float *, const double * "/*hhhh*/$1_type"
%typemap(ctype) short *&, int *&, long *&, char *&, float *&, double *& "$1_ltype"
%typemap(ctype) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$1_basetype **"
%typemap(ctype) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], unsigned int [ANY] "/*aaa*/ $1_ltype"
%typemap(ctype) void * [ANY], short * [ANY], int * [ANY], long * [ANY], char * [ANY], float * [ANY], double * [ANY] "/*bbb*/ $1_ltype"
// special cases of array passing - does not work for objects
// special cases of array passing - does not intended to be used for objects
%typemap(ctype) SWIGTYPE [] "$1_ltype"
%typemap(ctype) SWIGTYPE ((&)[ANY]) "$1_basetype **"
@ -54,40 +54,41 @@
%typemap(ctype) SWIGTYPE "SwigObj *"
%typemap(ctype) SWIGTYPE * "SwigObj *"
%typemap(ctype) SWIGTYPE & "SwigObj *"
%typemap(ctype) SWIGTYPE [ANY][ANY], SWIGTYPE ** "/* whoa */ $*1_ltype *"
%typemap(ctype) SWIGTYPE *[ANY] "/*ooooh*/ $*1_ltype"
//%typemap(ctype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***"
%typemap(ctype) SWIGTYPE [ANY][ANY], SWIGTYPE ** "/* whoa */ SwigObj ***"
%typemap(ctype) SWIGTYPE *[ANY] "/*ooooh*/ SwigObj **"
%typemap(ctype) SWIGTYPE *& "/* *& */ SwigObj **"
%typemap(ctype) enum SWIGTYPE "int"
%typemap(ctype) enum SWIGTYPE & "int *"
%typemap(ctype, fragment="fptr_decl", fragment="fptr_decl_proxy") SWIGTYPE (CLASS::*) "SWIG_CPP_FP"
%typemap(ctype, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool *, bool * [ANY] "$1_type"
%typemap(ctype, fragment="stdbool_inc") bool & "$1_ltype"
%typemap(ctype, fragment="stdbool_inc") const bool & "$1_ltype const"
%typemap(in) short, int, long, char, float, double "$1 = ($1_ltype) $input;"
%typemap(in) void *, short *, int *, long *, char *, float *, double * "$1 = ($1_ltype) $input;"
%typemap(in) void **, short **, int **, long **, char **, float **, double ** "$1 = ($1_basetype **) $input;"
%typemap(in) unsigned short *, unsigned int *, unsigned long *, unsigned char * "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short **, unsigned int **, unsigned long **, unsigned char ** "$1 = ($1_ltype) $input;"
%typemap(in) const void *, const short *, const int *, const long *, const char *, const float *, const double * "$1 = ($1_ltype) $input;"
%typemap(in) const unsigned short *, const unsigned int *, const unsigned long *, const unsigned char * "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short, unsigned int, unsigned long, unsigned char "$1 = ($1_ltype) $input;"
%typemap(in) short &, int &, long &, char &, float &, double &, bool & "$1 = ($1_ltype) $input;"
%typemap(in) const short &, const int &, const long &, const char &, const float &, const double & "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short &, unsigned int &, unsigned long &, unsigned char & "$1 = ($1_ltype) $input;"
%typemap(in) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned char & "$1 = ($1_ltype) $input;"
%typemap(in) short, int, long, long long, char, float, double "$1 = ($1_ltype) $input;"
%typemap(in) void *, short *, int *, long *, long long *, char *, float *, double * "$1 = ($1_ltype) $input;"
%typemap(in) void **, short **, int **, long **, long long **, char **, float **, double ** "$1 = ($1_basetype **) $input;"
%typemap(in) unsigned short *, unsigned int *, unsigned long *, unsigned long long *, unsigned char * "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short **, unsigned int **, unsigned long **, unsigned long long **, unsigned char ** "$1 = ($1_ltype) $input;"
%typemap(in) const void *, const short *, const int *, const long *, const long long *, const char *, const float *, const double * "$1 = ($1_ltype) $input;"
%typemap(in) const unsigned short *, const unsigned int *, const unsigned long *, const unsigned long long *, const unsigned char * "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short, unsigned int, unsigned long, unsigned long long, unsigned char "$1 = ($1_ltype) $input;"
%typemap(in) short &, int &, long &, long long &, char &, float &, double &, bool & "$1 = ($1_ltype) $input;"
%typemap(in) const short &, const int &, const long &, const long long &, const char &, const float &, const double & "$1 = ($1_ltype) $input;"
%typemap(in) unsigned short &, unsigned int &, unsigned long &, unsigned long long &, unsigned char & "$1 = ($1_ltype) $input;"
%typemap(in) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned long long &, const unsigned char & "$1 = ($1_ltype) $input;"
%typemap(in) short *&, int *&, long *&, char *&, float *&, double *& "$1 = ($1_ltype) $input;"
%typemap(in) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$1 = ($1_ltype) $input;"
%typemap(in) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY] "$1 = ($1_basetype *) $input;"
%typemap(in) void * [ANY], short * [ANY], int * [ANY], long * [ANY], char * [ANY], float * [ANY], double * [ANY] "$1 = ($1_basetype *) $input;"
%typemap(in) short *&, int *&, long *&, long long *&, char *&, float *&, double *& "$1 = ($1_ltype) $input;"
%typemap(in) const short *&, const int *&, const long *&, const long *&, const char *&, const float *&, const double *& "$1 = ($1_ltype) $input;"
%typemap(in) short [ANY], int [ANY], long [ANY], long long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY] "$1 = ($1_basetype *) $input;"
%typemap(in) void * [ANY], short * [ANY], int * [ANY], long * [ANY], long long * [ANY], char * [ANY], float * [ANY], double * [ANY] "$1 = ($1_basetype *) $input;"
%typemap(in, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool * "$1 = ($1_ltype) $input;"
%typemap(in, fragment="stdbool_inc") bool & "$1 = ($1_basetype *) $input;"
%typemap(in, fragment="stdbool_inc") const bool &, const bool * "$1 = ($1_basetype *) $input;"
%typemap(in) enum SWIGTYPE "$1 = ($1_type) $input;"
%typemap(in) enum SWIGTYPE "$1 = ($1_ltype) $input;"
%typemap(in) enum SWIGTYPE & "$1 = ($1_ltype) $input;"
%typemap(in) SWIGTYPE [] "$1 = ($1_ltype) $input;"
%typemap(in) SWIGTYPE ((&)[ANY]) "$1 = ($1_ltype) $input;"
@ -142,13 +143,10 @@
$1 = ($1_ltype) 0;
}
/*
* unsupported yet
%typemap(freearg) SWIGTYPE * [ANY], SWIGTYPE * [ANY][ANY], SWIGTYPE **, SWIGTYPE *** {
if ($input)
free($input);
}
*/
%typemap(in) SWIGTYPE & {
if ($input)
@ -166,70 +164,151 @@
// typemaps for return values
%typemap(couttype) void, short, int, long, char, float, double "$1_ltype"
%typemap(couttype) unsigned short, unsigned int, unsigned long, unsigned char, signed char "$1_ltype"
%typemap(couttype) void *, short *, int *, long *, char *, float *, double*, unsigned char *, signed char * "$1_ltype"
%typemap(couttype) const short, const int, const long, const char, const float, const double "$1_ltype"
%typemap(couttype) const void *, const short *, const int *, const long *, const char *, const float *, const double * "$1_ltype"
%typemap(couttype) short &, int &, long &, char &, float &, double & "$1_ltype"
%typemap(couttype) const short &, const int &, const long &, const char &, const float &, const double & "$1_basetype const *"
%typemap(couttype) short *&, int *&, long *&, char *&, float *&, double *& "$1_ltype"
%typemap(couttype) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$1_ltype"
%typemap(couttype) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], signed char [ANY], unsigned int [ANY] "$1_ltype"
%typemap(couttype) short * [ANY], int * [ANY], long * [ANY], char * [ANY], float * [ANY], double * [ANY] "/*builtin * [ANY]*/ $1_ltype"
%typemap(couttype) short **, int **, long **, char **, float **, double ** "$1_ltype"
// void
%typemap(couttype) void "void"
%typemap(couttype) void*, const void* "void *"
// short
%typemap(couttype) short, const short "short"
%typemap(couttype) short*, short&, short[ANY], short[] "short *"
%typemap(couttype) const short&, const short*, const short[ANY], const short[] "const short *"
%typemap(couttype) unsigned short "unsigned short"
%typemap(couttype) const unsigned short "const unsigned short"
%typemap(couttype) unsigned short*, unsigned short&, unsigned short*, unsigned short[ANY], unsigned short[] "unsigned short *"
%typemap(couttype) const unsigned short*, const unsigned short&, const unsigned short[ANY], const unsigned short[] "const unsigned short *"
%typemap(couttype) short**, short*&, short*[ANY], short[ANY][ANY] "short **"
%typemap(couttype) const short**, const short*&, const short*[ANY], const short[ANY][ANY] "const short **"
%typemap(couttype) unsigned short**, unsigned short*&, unsigned short*[ANY], unsigned short[ANY][ANY] "unsigned short **"
%typemap(couttype) const unsigned short**,const unsigned short*&, const unsigned short[ANY][ANY] "const unsigned short **"
// int
%typemap(couttype) int, const int "int"
%typemap(couttype) int*, int&, int[ANY], int[] "int *"
%typemap(couttype) const int&, const int*, const int[ANY], const int[] "const int *"
%typemap(couttype) unsigned int "unsigned int"
%typemap(couttype) const unsigned int "unsigned int"
%typemap(couttype) unsigned int*, unsigned int&, unsigned int*, unsigned int[ANY], unsigned int[] "unsigned int *"
%typemap(couttype) const unsigned int*, const unsigned int&, const unsigned int[ANY], const unsigned int[] "const unsigned int *"
%typemap(couttype) int**, int*&, int*[ANY], int[ANY][ANY] "int **"
%typemap(couttype) const int**, const int*&, const int*[ANY], const int[ANY][ANY] "const int **"
%typemap(couttype) unsigned int**, unsigned int*&, unsigned int*[ANY], unsigned int[ANY][ANY] "unsigned int **"
%typemap(couttype) const unsigned int**,const unsigned int*&, const unsigned int[ANY][ANY] "const unsigned int **"
// long
%typemap(couttype) long, const long "long"
%typemap(couttype) long*, long&, long[ANY], long[] "long *"
%typemap(couttype) const long&, const long*, const long[ANY], const long[] "const long *"
%typemap(couttype) unsigned long "unsigned long"
%typemap(couttype) const unsigned long "const unsigned long"
%typemap(couttype) unsigned long*, unsigned long&, unsigned long*, unsigned long[ANY], unsigned long[] "unsigned long *"
%typemap(couttype) const unsigned long*, const unsigned long&, const unsigned long[ANY], const unsigned long[] "const unsigned long *"
%typemap(couttype) long**, long*&, long*[ANY], long[ANY][ANY] "long **"
%typemap(couttype) const long**, const long*&, const long*[ANY], const long[ANY][ANY] "const long **"
%typemap(couttype) unsigned long**, unsigned long*&, unsigned long*[ANY], unsigned long[ANY][ANY] "unsigned long **"
%typemap(couttype) const unsigned long**,const unsigned long*&, const unsigned long[ANY][ANY] "const unsigned long **"
// long long
%typemap(couttype) long long, const long long "long long"
%typemap(couttype) long long*, long long&, long long[ANY], long long[] "long long *"
%typemap(couttype) const long long&, const long long*, const long long[ANY], const long long[] "const long long *"
%typemap(couttype) unsigned long long "unsigned long long"
%typemap(couttype) const unsigned long long "const unsigned long long"
%typemap(couttype) unsigned long long*, unsigned long long&, unsigned long long*, unsigned long long[ANY], unsigned long long[] "unsigned long long *"
%typemap(couttype) const unsigned long long*, const unsigned long long&, const unsigned long long[ANY], const unsigned long long[] "const unsigned long long *"
%typemap(couttype) long long**, long long*&, long long*[ANY], long long[ANY][ANY] "long long **"
%typemap(couttype) const long long**, const long long*&, const long long*[ANY], const long long[ANY][ANY] "const long long **"
%typemap(couttype) unsigned long long**, unsigned long long*&, unsigned long long*[ANY], unsigned long long[ANY][ANY] "unsigned long long **"
%typemap(couttype) const unsigned long long**,const unsigned long long*&, const unsigned long long[ANY][ANY] "const unsigned long long **"
// char: signed/unsigned
%typemap(couttype) char, const char "char"
%typemap(couttype) char*, char&, char[ANY], char[] "$1_ltype"
%typemap(couttype) const char&, const char*, const char[ANY], const char[] "const char *"
%typemap(couttype) char**, char*&, char*[ANY], char[ANY][ANY] "char **"
%typemap(couttype) const char**, const char*&, const char*[ANY], const char[ANY][ANY] "char **"
%typemap(couttype) signed char**, signed char*&, signed char*[ANY], signed char[ANY][ANY] "signed char **"
%typemap(couttype) const signed char**, const signed char*&, const signed char[ANY][ANY] "const signed char **"
%typemap(couttype) signed char "signed char"
%typemap(couttype) const signed char "const signed char"
%typemap(couttype) signed char*, signed char&, signed char*, signed char[ANY], signed char[] "signed char *"
%typemap(couttype) const signed char*, const signed char&, const signed char[ANY], const signed char[] "const $1_ltype"
%typemap(couttype) unsigned char**, unsigned char*&, unsigned char*[ANY], unsigned char[ANY][ANY] "unsigned char **"
%typemap(couttype) const unsigned char**, const unsigned char*&, const unsigned char[ANY][ANY] "const unsigned char **"
%typemap(couttype) unsigned char "unsigned char"
%typemap(couttype) const unsigned char "const unsigned char"
%typemap(couttype) unsigned char*, unsigned char&, unsigned char*, unsigned char[ANY], unsigned char[] "unsigned char *"
%typemap(couttype) const unsigned char*, const unsigned char&, const unsigned char[ANY], const unsigned char[] "const unsigned char *"
// float
%typemap(couttype) float, const float "float"
%typemap(couttype) float*, float&, float[ANY], float[] "float *"
%typemap(couttype) const float&, const float*, const float[ANY], const float[] "const float *"
%typemap(couttype) float**, float*&, const float*&, float*[ANY], float[ANY][ANY] "float **"
%typemap(couttype) const float**, const float*[ANY], const float[ANY][ANY] "const float **"
// double
%typemap(couttype) double, const double "double"
%typemap(couttype) double*, double&, double[ANY], double[] "double *"
%typemap(couttype) const double&, const double*, const double[ANY], const double[] "const double *"
%typemap(couttype) double**, double*&, const double*&, double*[ANY], double[ANY][ANY] "double **"
%typemap(couttype) const double**, const double*[ANY], const double[ANY][ANY] "const double **"
// objects
%typemap(couttype) SWIGTYPE "SwigObj *"
%typemap(couttype) SWIGTYPE * "/*aaaaaa*/SwigObj *"
%typemap(couttype) SWIGTYPE & "SwigObj *"
%typemap(couttype) SWIGTYPE *& "SwigObj **"
%typemap(couttype) SWIGTYPE [ANY] "/*SWIGTYPE [ANY]*/ SwigObj **"
%typemap(couttype) SWIGTYPE * [ANY], SWIGTYPE ** "/*SWIGTYPE *[ANY]/** */ SwigObj **"
//%typemap(couttype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***"
%typemap(couttype) SWIGTYPE * [ANY] "/*SWIGTYPE *[ANY] */ SwigObj **"
%typemap(couttype) SWIGTYPE ** "/*SWIGTYPE ** */ SwigObj **"
%typemap(couttype) enum SWIGTYPE "int"
%typemap(couttype) enum SWIGTYPE &, enum SWIGTYPE * "int *"
%typemap(couttype, fragment="fptr_decl") SWIGTYPE (CLASS::*) "SWIG_CPP_FP"
%typemap(couttype, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$1_ltype"
%typemap(couttype, fragment="stdbool_inc") bool & "$1_basetype*"
%typemap(couttype, fragment="stdbool_inc") const bool & "$1_basetype const *"
%typemap(out) short, int, long, char, float, double "$result = $1;"
%typemap(out) void*, short*, int*, long*, char*, float*, double* "$result = $1;"
%typemap(out) const short, const int, const long, const char, const float, const double "$result = ($1_ltype) $1;"
%typemap(out) const void *, const short *, const int *, const long *, const char *, const float *, const double * "$result = ($1_ltype) $1;"
%typemap(out) unsigned short, unsigned int, unsigned long, unsigned char, signed char "$result = $1;"
%typemap(out) unsigned short *, unsigned int *, unsigned long *, unsigned char *, signed char * "$result = $1;"
%typemap(out) short &, int &, long &, char &, float &, double & "$result = $1;"
%typemap(out) unsigned short &, unsigned int &, unsigned long &, unsigned char &, signed char & "$result = $1;"
%typemap(out) const short &, const int &, const long &, const char &, const float &, const double & "$result = $1;"
%typemap(out) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned char &, const signed char & "$result = $1;"
%typemap(out) short *&, int *&, long *&, char *&, float *&, double *& "$result = $1;"
%typemap(out) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$result = $1;"
%typemap(out) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], signed char [ANY], unsigned int [ANY] "$result = $1;"
%typemap(out) short * [ANY], int * [ANY], long * [ANY], char * [ANY], float * [ANY], double * [ANY] "$result = $1;"
%typemap(out) short **, int **, long **, char **, float **, double ** "$result = $1;"
%typemap(out) short, int, long, long long, char, float, double "$result = $1;"
%typemap(out) void*, short*, int*, long*, long long *, char*, float*, double* "$result = $1;"
%typemap(out) const short, const int, const long, const long long, const char, const float, const double "$result = ($1_ltype) $1;"
%typemap(out) const void *, const short *, const int *, const long *, const long long *, const char *, const float *, const double * "$result = ($1_ltype) $1;"
%typemap(out) unsigned short, unsigned int, unsigned long, unsigned long long, unsigned char, signed char "$result = $1;"
%typemap(out) unsigned short *, unsigned int *, unsigned long *, unsigned long long *, unsigned char *, signed char * "$result = $1;"
%typemap(out) short &, int &, long &, long long &, char &, float &, double & "$result = $1;"
%typemap(out) unsigned short &, unsigned int &, unsigned long &, unsigned long long &, unsigned char &, signed char & "$result = $1;"
%typemap(out) const short &, const int &, const long &, const long long &, const char &, const float &, const double & "$result = $1;"
%typemap(out) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned long long &, const unsigned char &, const signed char & "$result = $1;"
%typemap(out) short *&, int *&, long *&, long long *&, char *&, float *&, double *& "$result = $1;"
%typemap(out) const short *&, const int *&, const long *&, const long long *&, const char *&, const float *&, const double *& "$result = $1;"
%typemap(out) short [ANY], int [ANY], long [ANY], long long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], signed char [ANY], unsigned int [ANY] "$result = $1;"
%typemap(out) short * [ANY], int * [ANY], long * [ANY], long long * [ANY], char * [ANY], float * [ANY], double * [ANY] "$result = $1;"
%typemap(out) short **, int **, long **, long long **, char **, float **, double ** "$result = $1;"
%typemap(out) void ""
%typemap(out, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$result = ($1_ltype) $1;"
%typemap(out, fragment="stdbool_inc") bool &, const bool & "$result = $1;"
%typemap(out) enum SWIGTYPE "$result = ($1_ltype) $1;"
%typemap(out) enum SWIGTYPE "$result = (int) $1;"
%typemap(out) enum SWIGTYPE &, enum SWIGTYPE * "$result = (int *) &$1;"
%typemap(out) SWIGTYPE (CLASS::*) {
*($&1_ltype) &$result = $1;
}
%typemap(out) SWIGTYPE *&, SWIGTYPE ** {
$result = &SWIG_temporary;
static SwigObj* _ptr = (SwigObj*) SWIG_create_object(SWIG_STR($1_basetype));
$result = &_ptr;
(*result)->obj = (void*) $1;
}
%typemap(out) SWIGTYPE {
$result = SWIG_temporary;
$result = (SwigObj*) SWIG_create_object(SWIG_STR($1_basetype));
$result->obj = (void*) &$1;
}
%typemap(out) SWIGTYPE *, SWIGTYPE & {
$result = SWIG_temporary;
$result = (SwigObj*) SWIG_create_object(SWIG_STR($1_basetype));
$result->obj = (void*) $1;
}
@ -257,65 +336,68 @@
$result = (SwigObj**) 0;
}
// typemaps for 'cppresult'
// this needs refactoring -- see 'couttype' typemaps
%typemap(cppouttype) void, short, int, long, long long, char, float, double "$1_ltype"
%typemap(cppouttype) unsigned short, unsigned int, unsigned long, unsigned long long, unsigned char, signed char "$1_ltype"
%typemap(cppouttype) void *, short *, int *, long *, long long *, char *, float *, double*, unsigned char *, unsigned int *, unsigned long *, unsigned char *, signed char * "$1_ltype"
%typemap(cppouttype) const short, const int, const long, const long long, const char, const float, const double "$1_ltype"
%typemap(cppouttype) const void *, const short *, const int *, const long *, const long long *, const char *, const float *, const double * "$1_ltype"
%typemap(cppouttype) short &, int &, long &, long long &, char &, float &, double &, unsigned short &, unsigned int &, unsigned long &, unsigned long long &, unsigned char &, signed char & "$1_ltype"
%typemap(cppouttype) const short &, const int &, const long &, const long long &, const char &, const float &, const double & "$1_ltype"
%typemap(cppouttype) short *&, int *&, long *&, long long *&, char *&, float *&, double *& "$1_ltype"
%typemap(cppouttype) const short *&, const int *&, const long *&, const long long *&, const char *&, const float *&, const double *& "$1_ltype"
%typemap(cppouttype) short [ANY], int [ANY], long [ANY], long long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], signed char [ANY], unsigned int [ANY] "$1_ltype"
%typemap(cppouttype) const char* "const char *"
%typemap(cppouttype) const unsigned char* "const unsigned char *"
%typemap(cppouttype) const signed char* "const signed char *"
%typemap(cppouttype) short * [ANY], int * [ANY], long * [ANY], long long * [ANY], char * [ANY], float * [ANY], double * [ANY] "/*builtin * [ANY]*/ $1_ltype"
%typemap(cppouttype) short **, int **, long **, long long **, char **, float **, double ** "$1_ltype"
%typemap(cppouttype, retobj="1") SWIGTYPE "$1_ltype *"
%typemap(cppouttype) SWIGTYPE * "$1_ltype"
%typemap(cppouttype) const SWIGTYPE * "const $1_ltype"
%typemap(cppouttype) SWIGTYPE & "$1_ltype"
%typemap(cppouttype) SWIGTYPE *& "$1_ltype"
%typemap(cppouttype) SWIGTYPE [ANY] "$1_ltype"
%typemap(cppouttype) SWIGTYPE * [ANY] "/*SWIGTYPE *[ANY] */ $1_ltype"
%typemap(cppouttype) SWIGTYPE ** "/*SWIGTYPE ** */ $1_basetype **"
%typemap(cppouttype, retobj="1") enum SWIGTYPE "int"
%typemap(cppouttype) enum SWIGTYPE * "int *"
%typemap(cppouttype) enum SWIGTYPE & "int *"
%typemap(cppouttype, fragment="fptr_decl") SWIGTYPE (CLASS::*) "$1_ltype"
%typemap(cppouttype, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$1_ltype"
%typemap(cppouttype, fragment="stdbool_inc") bool & "$1_basetype*"
%typemap(cppouttype, fragment="stdbool_inc") const bool & "$1_basetype const *"
// templates typemaps - in progress...
/*
* 2+ dim arrays - not supported yet
%typemap(out) SWIGTYPE * [ANY][ANY], SWIGTYPE *** {
if ($1) {
$result = (SwigObj***) malloc($1_dim0 * $1_dim1 * sizeof(SwigObj*));
size_t i = 0, j = 0;
for ( ; i < $1_dim0; ++i) {
for ( ; j < $1_dim1; ++j) {
if ($1[i][j]) {
$result[i][j] = SWIG_create_object(SWIG_STR($1_ltype));
$result[i][j]->obj = (void*) $1[i][j];
}
else
$result[i][j] = (SwigObj*) 0;
}
}
}
else
$result = (SwigObj***) 0;
}*/
%typemap(ctype) SWIGTYPE<T>, const SWIGTYPE<T> &, const SWIGTYPE<T> * "SwigObj *"
%typemap(in) SWIGTYPE<T>, const SWIGTYPE<T> &, const SWIGTYPE<T> * { $1 = ($1_ltype) $input; }
%typemap(out) SWIGTYPE<T>, const SWIGTYPE<T> &, const SWIGTYPE<T> * "$result = ($1_ltype) $1;"
#ifdef SWIG_C_EXCEPT
%typemap(cppouttype) SWIGTYPE<T>, const SWIGTYPE<T> &, const SWIGTYPE<T> * "$1_ltype"
*/
//%define size_t unsigned long %enddef
%apply unsigned long { size_t };
%apply const unsigned long & { const size_t & };
#ifdef SWIG_CPPMODE
#ifdef SWIG_C_EXCEPT
%insert("runtime") %{
typedef struct {
void *obj;
const char **typenames;
} SwigObj;
%}
%include "cexcept.swg"
#ifdef SWIG_CPPMODE
%insert("runtime") %{
SwigObj *SWIG_temporary = (SwigObj *) malloc(sizeof(SwigObj));
%}
#endif
#else
%insert("runtime") %{
typedef struct {
void *obj;
} SwigObj;
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORTC int SWIG_exit(int code) {
exit(code);
}
#ifdef __cplusplus
}
#endif
%}
#ifdef SWIG_CPPMODE
%insert("runtime") %{
SwigObj *SWIG_temporary = (SwigObj *) malloc(sizeof(SwigObj));
%}
#endif
%insert("proxy_header") %{
typedef struct {
@ -324,5 +406,61 @@ typedef struct {
} SwigObj;
%}
#endif
%include "cexcept.swg"
#else
%insert("runtime") %{
typedef struct {
void *obj;
} SwigObj;
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORTC int SWIG_exit(int code) { exit(code); }
#ifdef __cplusplus
}
#endif
%}
%insert("proxy_header") %{
typedef struct {
void *obj;
} SwigObj;
%}
#endif
%insert(runtime) %{
SwigObj *SWIG_temporary = (SwigObj *) malloc(sizeof(SwigObj));
%}
%insert("proxy_header") %{
#include <stdarg.h>
#define SWIG_MAKE_DELETE(Name,Obj) void Name(Obj *op1, ...) {\
Obj *obj;\
va_list vl;\
va_start(vl, op1);\
do {\
obj = va_arg(vl, Obj *);\
delete_##Obj(obj);\
} while (obj);\
va_end(vl);\
}
%}
#else
%insert("runtime") %{
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORTC int SWIG_exit(int code) { exit(code); }
#ifdef __cplusplus
}
#endif
%}
#endif

View file

@ -1,260 +1,265 @@
/* -----------------------------------------------------------------------------
* clabels.swg
*
* Exception handling code and typemaps for C module.
* ----------------------------------------------------------------------------- */
%typemap(throws) BASIC_INT_TYPES {
char error_msg[256];
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
SWIG_CThrowException(0, error_msg);
}
%apply BASIC_INT_TYPES { int, long, short, unsigned int, unsigned long, unsigned short, int &, long &, short &, unsigned int &, unsigned long &, unsigned short & };
%typemap(throws) char *, const char * {
SWIG_CThrowException(0, $1);
}
// this should match only SwigObj objects
%typemap(throws) SWIGTYPE {
SwigObj *c_ex;
c_ex = SWIG_create_object(SWIG_STR($1_basetype));
c_ex->obj = (void*) &$1;
SWIG_CThrowException(c_ex, "C++ $1_type exception thrown");
}
%typemap(throws) SWIGTYPE * {
SwigObj *c_ex;
c_ex = SWIG_create_object(SWIG_STR($1_basetype));
c_ex->obj = (void*) $1;
SWIG_CThrowException(c_ex, "C++ $1_type exception thrown");
}
%insert("runtime") %{
#define SWIG_MAX_RT_STACK 256
#define SWIG_REGISTRY_INIT 256
SWIGINTERN SwigObj **SWIG_registry_base = 0;
SWIGINTERN SwigObj **SWIG_registry = 0;
SWIGINTERN int SWIG_registry_size = SWIG_REGISTRY_INIT;
SWIGINTERN SwigObj *SWIG_create_object(const char *classname);
SWIGINTERN void SWIG_destroy_object(SwigObj *object);
SWIGEXPORTC struct SWIG_exc_struct {
int code;
char *msg;
SwigObj *klass;
int handled;
} SWIG_exc = { 0, 0, 0, 0 };
SWIGEXPORTC jmp_buf SWIG_rt_env;
SWIGEXPORTC int SWIG_rt_init = 0;
SWIGINTERN jmp_buf SWIG_cpp_back_env;
SWIGINTERN jmp_buf *SWIG_rt_stack_base = 0;
SWIGINTERN jmp_buf *SWIG_rt_stack_ptr = 0;
SWIGINTERN void SWIG_rt_stack_push() {
// TODO: check for stack overflow
memcpy(SWIG_rt_stack_ptr, SWIG_rt_env, sizeof(SWIG_rt_env));
SWIG_rt_stack_ptr++;
}
SWIGINTERN void SWIG_rt_stack_pop() {
if (SWIG_rt_stack_ptr == SWIG_rt_stack_base)
return;
SWIG_rt_stack_ptr--;
memcpy(SWIG_rt_env, SWIG_rt_stack_ptr, sizeof(SWIG_rt_env));
}
SWIGINTERN void SWIG_add_registry_entry(SwigObj *entry) {
if (SWIG_registry_base == 0) {
SWIG_registry_base = SWIG_registry = (SwigObj **) malloc(SWIG_registry_size * sizeof(SwigObj *));
memset(SWIG_registry_base, 0, SWIG_registry_size * sizeof(SwigObj *));
}
*SWIG_registry = entry;
SWIG_registry++;
if ((SWIG_registry - SWIG_registry_base) == SWIG_registry_size) {
SWIG_registry = SWIG_registry_base;
SWIG_registry_size += SWIG_REGISTRY_INIT;
int new_size = SWIG_registry_size * sizeof(SwigObj *);
SWIG_registry_base = (SwigObj **) malloc(new_size);
memset(SWIG_registry_base, 0, new_size);
memcpy(SWIG_registry_base, SWIG_registry, (SWIG_registry_size - SWIG_REGISTRY_INIT) * sizeof(SwigObj *));
free(SWIG_registry);
SWIG_registry = SWIG_registry_base + (SWIG_registry_size - SWIG_REGISTRY_INIT);
}
}
SWIGINTERN void SWIG_remove_registry_entry(SwigObj *entry) {
int i;
for (i = 0; i < SWIG_registry_size; ++i) {
if (*(SWIG_registry_base + i) == entry) {
*(SWIG_registry_base + i) = 0;
break;
}
}
}
SWIGINTERN void SWIG_cleanup() {
if (SWIG_rt_stack_base)
free(SWIG_rt_stack_base);
if (SWIG_exc.msg)
free(SWIG_exc.msg);
if (SWIG_exc.klass) {
if (SWIG_exc.klass->typenames)
free(SWIG_exc.klass->typenames);
free(SWIG_exc.klass);
}
int i;
if (SWIG_registry_base) {
for (i = 0; i < SWIG_registry_size; ++i) {
if (*(SWIG_registry_base + i)) {
SWIG_destroy_object(*(SWIG_registry_base + i));
*(SWIG_registry_base + i) = 0;
}
}
}
free(SWIG_registry_base);
SWIG_registry_base = 0;
}
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORTC void SWIG_rt_try() {
SWIG_rt_stack_push();
}
SWIGEXPORTC int SWIG_rt_catch(const char *type) {
int result = 0;
if (!type || (strcmp("SWIG_AnyException", type) == 0)) {
result = 1;
}
else if (SWIG_exc.klass) {
int i = 0;
while (SWIG_exc.klass->typenames[i]) {
if (strcmp(SWIG_exc.klass->typenames[i++], type) == 0) {
result = 1;
break;
}
}
}
if (result) {
SWIG_rt_stack_pop();
SWIG_exc.handled = 1;
}
return result;
}
SWIGEXPORTC void SWIG_rt_throw(SwigObj *klass, const char *msg) {
if (SWIG_exc.msg) {
free(SWIG_exc.msg);
SWIG_exc.msg = (char *) 0;
}
if (msg) {
SWIG_exc.msg = (char *) malloc(strlen(msg) + 1);
strcpy(SWIG_exc.msg, msg);
}
SWIG_exc.klass = klass;
SWIG_exc.handled = 0;
longjmp(SWIG_rt_env, 1);
}
SWIGEXPORTC void SWIG_rt_unhandled() {
if (SWIG_exc.msg) {
free(SWIG_exc.msg);
SWIG_exc.msg = 0;
}
SWIG_rt_stack_pop();
longjmp(SWIG_rt_env, SWIG_exc.code);
}
SWIGEXPORTC void SWIG_rt_endtry() {
if (SWIG_exc.handled) {
if (setjmp(SWIG_rt_env) == 0) {
SWIG_rt_stack_push();
longjmp(SWIG_cpp_back_env, 1);
}
}
else {
SWIG_rt_stack_pop(); // pop the SWIG_try context
}
}
SWIGEXPORTC int SWIG_exit(int code) {
SWIG_cleanup();
exit(code);
}
#ifdef __cplusplus
}
#endif
SWIGINTERN void SWIG_terminate() {
fprintf(stderr, "Unhandled exception: %s\n%s\nExitting...\n",
SWIG_exc.klass->typenames[0],
SWIG_exc.msg ? SWIG_exc.msg : "");
SWIG_exit(SWIG_exc.code);
}
SWIGINTERN void SWIG_runtime_init() {
int i, code;
if (!SWIG_rt_init) {
SWIG_rt_init = 1;
SWIG_rt_stack_base = SWIG_rt_stack_ptr = (jmp_buf *) malloc(sizeof(jmp_buf) * SWIG_MAX_RT_STACK);
if (SWIG_exc.code = setjmp(SWIG_rt_env)) {
// deallocate C++ exception
if (setjmp(SWIG_rt_env) == 0) {
SWIG_rt_stack_push();
SWIG_exc.handled = 1;
longjmp(SWIG_cpp_back_env, 1);
}
SWIG_terminate();
}
}
}
#define SWIG_CThrowException(klass, msg) \
if (setjmp(SWIG_cpp_back_env) == 0) \
SWIG_rt_throw((SwigObj *) klass, msg);
%}
%insert("proxy_header") %{
// special value indicating any type of exception like 'catch(...)'
#define SWIG_AnyException "SWIG_AnyException"
#include <setjmp.h>
SWIGIMPORT jmp_buf SWIG_rt_env;
typedef struct {
void *obj;
const char **typenames;
} SwigObj;
SWIGIMPORT struct SWIG_exc_struct {
int code;
char *msg;
SwigObj *klass;
} SWIG_exc;
SWIGIMPORT void SWIG_rt_try();
SWIGIMPORT int SWIG_rt_catch(const char *type);
SWIGIMPORT void SWIG_rt_throw(SwigObj *klass, const char * msg);
SWIGIMPORT int SWIG_rt_unhandled();
SWIGIMPORT void SWIG_rt_endtry();
SWIGIMPORT int SWIG_exit(int code);
#define SWIG_try \
SWIG_rt_try(); \
if ((SWIG_exc.code = setjmp(SWIG_rt_env)) == 0)
#define SWIG_catch(type) else if (SWIG_rt_catch(#type))
#define SWIG_throw(klass) SWIG_rt_throw((SwigObj *) klass, 0);
#define SWIG_throw_msg(klass, msg) SWIG_rt_throw((SwigObj *) klass, msg);
#define SWIG_endtry else SWIG_rt_unhandled(); SWIG_rt_endtry();
%}
/* -----------------------------------------------------------------------------
* clabels.swg
*
* Exception handling code and typemaps for C module.
* ----------------------------------------------------------------------------- */
%typemap(throws) BASIC_INT_TYPES {
char error_msg[256];
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
SWIG_CThrowException(0, error_msg);
}
%apply BASIC_INT_TYPES { int, long, short, unsigned int, unsigned long, unsigned short, int &, long &, short &, unsigned int &, unsigned long &, unsigned short & };
%typemap(throws) char *, const char * {
SWIG_CThrowException(0, $1);
}
// this should match only SwigObj objects
%typemap(throws) SWIGTYPE {
SwigObj *c_ex;
c_ex = SWIG_create_object(SWIG_STR($1_basetype));
c_ex->obj = (void*) &$1;
SWIG_CThrowException(c_ex, "C++ $1_type exception thrown");
}
%typemap(throws) SWIGTYPE * {
SwigObj *c_ex;
c_ex = SWIG_create_object(SWIG_STR($1_basetype));
c_ex->obj = (void*) $1;
SWIG_CThrowException(c_ex, "C++ $1_type exception thrown");
}
%insert("runtime") %{
#define SWIG_MAX_RT_STACK 256
#define SWIG_REGISTRY_INIT 256
SWIGINTERN SwigObj **SWIG_registry_base = 0;
SWIGINTERN SwigObj **SWIG_registry = 0;
SWIGINTERN int SWIG_registry_size = SWIG_REGISTRY_INIT;
SWIGINTERN SwigObj *SWIG_create_object(const char *classname);
SWIGINTERN void SWIG_destroy_object(SwigObj *object);
SWIGINTERN void SWIG_free_SwigObj(SwigObj *object);
SWIGEXPORTC struct SWIG_exc_struct {
int code;
char *msg;
SwigObj *klass;
int handled;
} SWIG_exc = { 0, 0, 0, 0 };
SWIGEXPORTC jmp_buf SWIG_rt_env;
SWIGEXPORTC int SWIG_rt_init = 0;
SWIGINTERN jmp_buf SWIG_cpp_back_env;
SWIGINTERN jmp_buf *SWIG_rt_stack_base = 0;
SWIGINTERN jmp_buf *SWIG_rt_stack_ptr = 0;
SWIGINTERN void SWIG_rt_stack_push() {
// TODO: check for stack overflow
memcpy(SWIG_rt_stack_ptr, SWIG_rt_env, sizeof(SWIG_rt_env));
SWIG_rt_stack_ptr++;
}
SWIGINTERN void SWIG_rt_stack_pop() {
if (SWIG_rt_stack_ptr == SWIG_rt_stack_base)
return;
SWIG_rt_stack_ptr--;
memcpy(SWIG_rt_env, SWIG_rt_stack_ptr, sizeof(SWIG_rt_env));
}
SWIGINTERN void SWIG_add_registry_entry(SwigObj *entry) {
if (SWIG_registry_base == 0) {
SWIG_registry_base = SWIG_registry = (SwigObj **) malloc(SWIG_registry_size * sizeof(SwigObj *));
memset(SWIG_registry_base, 0, SWIG_registry_size * sizeof(SwigObj *));
}
*SWIG_registry = entry;
SWIG_registry++;
if ((SWIG_registry - SWIG_registry_base) == SWIG_registry_size) {
SWIG_registry = SWIG_registry_base;
SWIG_registry_size += SWIG_REGISTRY_INIT;
int new_size = SWIG_registry_size * sizeof(SwigObj *);
SWIG_registry_base = (SwigObj **) malloc(new_size);
memset(SWIG_registry_base, 0, new_size);
memcpy(SWIG_registry_base, SWIG_registry, (SWIG_registry_size - SWIG_REGISTRY_INIT) * sizeof(SwigObj *));
free(SWIG_registry);
SWIG_registry = SWIG_registry_base + (SWIG_registry_size - SWIG_REGISTRY_INIT);
}
}
SWIGINTERN void SWIG_remove_registry_entry(SwigObj *entry) {
int i;
for (i = 0; i < SWIG_registry_size; ++i) {
if (*(SWIG_registry_base + i) == entry) {
*(SWIG_registry_base + i) = 0;
break;
}
}
}
SWIGINTERN void SWIG_free_SwigObj(SwigObj *object) {
if (object) {
if (object->typenames)
free(object->typenames);
free(object);
object = (SwigObj *) 0;
}
}
SWIGINTERN void SWIG_cleanup() {
if (SWIG_rt_stack_base)
free(SWIG_rt_stack_base);
if (SWIG_exc.msg)
free(SWIG_exc.msg);
if (SWIG_exc.klass) {
if (SWIG_exc.klass->typenames)
free(SWIG_exc.klass->typenames);
free(SWIG_exc.klass);
}
int i;
if (SWIG_registry_base) {
for (i = 0; i < SWIG_registry_size; ++i) {
if (*(SWIG_registry_base + i)) {
SWIG_free_SwigObj(*(SWIG_registry_base + i));
*(SWIG_registry_base + i) = 0;
}
}
}
free(SWIG_registry_base);
SWIG_registry_base = 0;
}
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORTC void SWIG_rt_try() {
SWIG_rt_stack_push();
}
SWIGEXPORTC int SWIG_rt_catch(const char *type) {
int result = 0;
if (!type || (strcmp("SWIG_AnyException", type) == 0)) {
result = 1;
}
else if (SWIG_exc.klass) {
int i = 0;
while (SWIG_exc.klass->typenames[i]) {
if (strcmp(SWIG_exc.klass->typenames[i++], type) == 0) {
result = 1;
break;
}
}
}
if (result) {
SWIG_rt_stack_pop();
SWIG_exc.handled = 1;
}
return result;
}
SWIGEXPORTC void SWIG_rt_throw(SwigObj *klass, const char *msg) {
if (SWIG_exc.msg) {
free(SWIG_exc.msg);
SWIG_exc.msg = (char *) 0;
}
if (msg) {
SWIG_exc.msg = (char *) malloc(strlen(msg) + 1);
strcpy(SWIG_exc.msg, msg);
}
SWIG_exc.klass = klass;
SWIG_exc.handled = 0;
longjmp(SWIG_rt_env, 1);
}
SWIGEXPORTC void SWIG_rt_unhandled() {
if (SWIG_exc.msg) {
free(SWIG_exc.msg);
SWIG_exc.msg = 0;
}
SWIG_rt_stack_pop();
longjmp(SWIG_rt_env, SWIG_exc.code);
}
SWIGEXPORTC void SWIG_rt_endtry() {
if (SWIG_exc.handled) {
if (setjmp(SWIG_rt_env) == 0) {
SWIG_rt_stack_push();
longjmp(SWIG_cpp_back_env, 1);
}
}
else {
SWIG_rt_stack_pop(); // pop the SWIG_try context
}
}
SWIGEXPORTC int SWIG_exit(int code) {
SWIG_cleanup();
exit(code);
}
#ifdef __cplusplus
}
#endif
SWIGINTERN void SWIG_terminate() {
fprintf(stderr, "Unhandled exception: %s\n%s\nExitting...\n",
SWIG_exc.klass->typenames[0],
SWIG_exc.msg ? SWIG_exc.msg : "");
SWIG_exit(SWIG_exc.code);
}
SWIGINTERN void SWIG_runtime_init() {
int i, code;
if (!SWIG_rt_init) {
SWIG_rt_init = 1;
SWIG_rt_stack_base = SWIG_rt_stack_ptr = (jmp_buf *) malloc(sizeof(jmp_buf) * SWIG_MAX_RT_STACK);
if (SWIG_exc.code = setjmp(SWIG_rt_env)) {
// deallocate C++ exception
if (setjmp(SWIG_rt_env) == 0) {
SWIG_rt_stack_push();
SWIG_exc.handled = 1;
longjmp(SWIG_cpp_back_env, 1);
}
SWIG_terminate();
}
}
}
#define SWIG_CThrowException(klass, msg) \
if (setjmp(SWIG_cpp_back_env) == 0) \
SWIG_rt_throw((SwigObj *) klass, msg);
%}
%insert("proxy_header") %{
// special value indicating any type of exception like 'catch(...)'
#define SWIG_AnyException "SWIG_AnyException"
#include <setjmp.h>
SWIGIMPORT jmp_buf SWIG_rt_env;
SWIGIMPORT struct SWIG_exc_struct {
int code;
char *msg;
SwigObj *klass;
} SWIG_exc;
SWIGIMPORT void SWIG_rt_try();
SWIGIMPORT int SWIG_rt_catch(const char *type);
SWIGIMPORT void SWIG_rt_throw(SwigObj *klass, const char * msg);
SWIGIMPORT int SWIG_rt_unhandled();
SWIGIMPORT void SWIG_rt_endtry();
SWIGIMPORT int SWIG_exit(int code);
#define SWIG_try \
SWIG_rt_try(); \
if ((SWIG_exc.code = setjmp(SWIG_rt_env)) == 0)
#define SWIG_catch(type) else if (SWIG_rt_catch(#type))
#define SWIG_throw(klass) SWIG_rt_throw((SwigObj *) klass, 0);
#define SWIG_throw_msg(klass, msg) SWIG_rt_throw((SwigObj *) klass, msg);
#define SWIG_endtry else SWIG_rt_unhandled(); SWIG_rt_endtry();
%}

View file

@ -17,3 +17,4 @@
# endif
#endif
#include <stdio.h>

4
Lib/c/std_common.i Normal file
View file

@ -0,0 +1,4 @@
%include <std_except.i>
%apply size_t { std::size_t };
%apply const size_t& { const std::size_t & };

34
Lib/c/std_except.i Normal file
View file

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* std_except.i
*
* Typemaps used by the STL wrappers that throw exceptions.
* These typemaps are used when methods are declared with an STL exception specification, such as
* size_t at() const throw (std::out_of_range);
* ----------------------------------------------------------------------------- */
%{
#include <stdexcept>
%}
namespace std
{
%ignore exception;
struct exception {};
}
/*
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::invalid_argument "SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, $1.what());\n return $null;"
%typemap(throws) std::length_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;"
%typemap(throws) std::logic_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::out_of_range "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;"
%typemap(throws) std::overflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;"
%typemap(throws) std::range_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;"
%typemap(throws) std::runtime_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::underflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;"
*/

1
Lib/c/std_map.i Normal file
View file

@ -0,0 +1 @@
%include <std/std_map.i>

1
Lib/c/std_pair.i Normal file
View file

@ -0,0 +1 @@
%include <std/std_pair.i>

View file

@ -16,6 +16,8 @@ class string;
%typemap(couttype) string "char *"
%typemap(couttype) const string & "char *"
%typemap(couttype) string * "char *"
%typemap(cppouttype, retobj="1") string "std::string*"
%typemap(cppouttype) const string &, string * "std::string*"
%typemap(in) string {
if ($input) {
@ -50,4 +52,3 @@ class string;
}
}

64
Lib/c/std_vector.i Normal file
View file

@ -0,0 +1,64 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* std_vector.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%{
#include <vector>
#include <stdexcept>
%}
// C module specific: $tt expands to the type the template is instantiated
%typemap(ctype) std::vector<T> "$tt"
%typemap(in) std::vector<T> "$1 = ($1_ltype) $input;"
%typemap(out) std::vector<T> "$result = ($1_ltype) $1;"
%typemap(cppouttype) std::vector<T> "$1_ltype"
namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef T value_type;
typedef const value_type& const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
bool empty() const;
void clear();
void push_back(const value_type& x);
const_reference at(size_type i);
};
%define specialize_std_vector(T)
template<> class vector<T> {
public:
typedef size_t size_type;
typedef T value_type;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
bool empty() const;
void clear();
void push_back(T x) { this->push_back(x); }
T at(size_type i) { return this->at(i); }
};
%enddef
specialize_std_vector(int);
specialize_std_vector(bool);
/*specialize_std_vector(long);
specialize_std_vector(char);
specialize_std_vector(double);
specialize_std_vector(int*);
specialize_std_vector(char*);*/
}

12
Lib/c/stl.i Normal file
View file

@ -0,0 +1,12 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

12
Lib/c/typemaps.i Normal file
View file

@ -0,0 +1,12 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* typemaps.i
*
* Pointer handling
* These mappings provide support for input/output arguments and common
* uses for C/C++ pointers.
* ----------------------------------------------------------------------------- */
%include <typemaps/typemaps.swg>