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 1039 additions and 596 deletions

View file

@ -0,0 +1,17 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SWIGOPT = -I../Include
SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L.. -lgifplot
INCLUDES = -I../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' LIBS='$(LIBS)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c
clean:
rm -f *.o *.out *.so *.a *.dll *.dylib *.exe *_wrap* *_proxy* *~ runme
check: all

View file

@ -0,0 +1,15 @@
/* Oh what the heck, let's just grab the whole darn header file
and see what happens. */
%module gifplot
%{
/* Note: You still need this part because the %include directive
merely causes SWIG to interpret the contents of a file. It doesn't
include the right include headers for the resulting C code */
#include "../Include/gifplot.h"
%}
%include gifplot.h

View file

@ -1,4 +1,5 @@
# see top-level Makefile.in
class
simple
class
std_vector
exception

View file

@ -0,0 +1,30 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
RUNME = runme.c
PROXY = example_proxy.c
INCLUDES =
MEMTOOL = valgrind --leak-check=full
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INCLUDES='$(INCLUDES)' c_cpp
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
run:
env LD_LIBRARY_PATH=. ./runme
memchk:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXXFLAGS='-g' INCLUDES='$(INCLUDES)' c_cpp
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' CFLAGS='-g' c_compile
env LD_LIBRARY_PATH=. $(MEMTOOL) ./runme
clean:
rm -f *.o *.out *.so *.a *.dll *.dylib *.exe *_wrap* *_proxy* *~ runme
check: all

View file

@ -0,0 +1,2 @@
/* File : example.c */

View file

@ -0,0 +1,18 @@
/* File : example.h */
#include <string>
#include <vector>
class A {
public:
A() : name(""), value(0) {}
A(std::string str, int i) : name(str), value(i) {}
std::string name;
int value;
};
class Klass {
public:
std::vector<int> vi;
std::vector<A> va;
};

View file

@ -0,0 +1,14 @@
/* File : example.i */
%module example
%include <std_string.i>
%include <std_vector.i>
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"
%template(Vint) std::vector<int>;
%template(VA) std::vector<A>;

View file

@ -0,0 +1,37 @@
#include "example_proxy.h"
int main() {
Klass *klass = new_Klass();
Vint *vint = Klass_vi_get(klass);
VA *va = Klass_va_get(klass);
printf("Vector of ints:\n");
printf("size=%d\ncapacity=%d\n\n", Vint_size(vint), Vint_capacity(vint));
int i;
for (i = 0; i < 10; i++)
Vint_push_back(vint, i*i);
printf("size=%d\ncapacity=%d\n\n", Vint_size(vint), Vint_capacity(vint));
for (i = 0; i < Vint_size(vint); i++)
printf("%d%c", Vint_at(vint, i), i+1 == Vint_size(vint) ? '\n' : ',');
Vint_clear(vint);
Vint_reserve(vint, 100);
printf("\nsize=%d\ncapacity=%d\n", Vint_size(vint), Vint_capacity(vint));
printf("\nVector of objects:\n");
for (i = 0; i < 10; i++) {
A *a = new_A_std_string_i("hello", i);
VA_push_back(va, a);
}
for (i = 0; i < VA_size(va); i++) {
A *a = VA_at(va, i);
printf("%s %d\n", A_name_get(a), A_value_get(a));
}
SWIG_exit(0);
}

View file

@ -10,23 +10,29 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@/..
top_builddir = @top_builddir@/..
C_TEST_CASES =
CPP_TEST_CASES = cast_operator \
char_strings \
exception_order \
exception_partial_info \
enums \
enum_plus
include $(srcdir)/../common.mk
#
# BROKEN TEST CASES:
# default_constructor - last case: when using %extend generates 2 ctors wrappers,
# default_constructor - last case fail: using %extend generates 2 ctors wrappers,
# both using new, while the class constructor is private
# extend* - directive %extend is not fully supported yet
# li* - not supported at all yet
# long_long_apply - no INPUT, OUTPUT, INOUT typemaps defined
# template* - not fully supported yet
#
CPP_TEST_BROKEN_CXX = default_constructor
include $(srcdir)/../common.mk
C_CPP_TEST_BROKEN = \
default_constructor \
extend \
extend_default \
extend_placement \
li_attribute \
li_boost_shared_ptr \
li_carrays \
li_cdata \
li_windows \
long_long_apply
INTERFACEDIR = ../../

View file

@ -1,12 +1,12 @@
#include <stdio.h>
#include "cast_operator/cast_operator_proxy.h"
int main() {
A *a = new_A();
if (strcmp(A_tochar(a), "hi"))
fprintf(stderr, "cast failed\n");
delete_A(a);
SWIG_exit(0);
}
#include <stdio.h>
#include "cast_operator/cast_operator_proxy.h"
int main() {
A *a = new_A();
if (strcmp(A_tochar(a), "hi"))
fprintf(stderr, "cast failed\n");
delete_A(a);
SWIG_exit(0);
}

View file

@ -73,6 +73,7 @@ INTERFACEDIR = ../
# Broken C++ test cases. (Can be run individually using make testcase.cpptest.)
CPP_TEST_BROKEN += \
abstract_access \
constants \
cpp_broken \
exception_partial_info \

View file

@ -15,6 +15,11 @@ see bottom for a set of possible tests
SWIGWARN_IGNORE_OPERATOR_LOR);
#endif
#if defined(SWIGC)
%warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ,
SWIGWARN_IGNORE_OPERATOR_PLUSPLUS);
#endif
#if !defined(SWIGLUA) && !defined(SWIGR)
%rename(Equal) operator =;
%rename(PlusEqual) operator +=;

View file

@ -27,6 +27,19 @@ std::string ExceptionVars(double i, double j) {
%}
%rename(ExceptionVars) Space::exceptionvars;
#ifdef SWIGC
%exception Space::exceptionvars %{
$action
result = (char*)$symname(1.0,2.0).c_str(); // Should expand to ExceptionVars
result = (char*)$name(3.0,4.0).c_str(); // Should expand to Space::exceptionvars
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
%}
#else
%exception Space::exceptionvars %{
$action
result = $symname(1.0,2.0); // Should expand to ExceptionVars
@ -34,6 +47,9 @@ std::string ExceptionVars(double i, double j) {
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
%}
#endif
%inline %{
namespace Space {
std::string exceptionvars(double i, double j) {
@ -43,6 +59,20 @@ std::string exceptionvars(double i, double j) {
%}
#ifdef SWIGC
%exception Space::overloadedmethod %{
$action
result = (char*)Space::$symname(1.0).c_str();
result = (char*)$name().c_str();
result = (char*)$name(2.0).c_str();
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
// $decl
%}
#else
%exception Space::overloadedmethod %{
$action
result = Space::$symname(1.0);
@ -53,6 +83,8 @@ std::string exceptionvars(double i, double j) {
// $decl
%}
#endif
%inline %{
namespace Space {
std::string overloadedmethod(double j) {

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>

Some files were not shown because too many files have changed in this diff Show more