summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Middelschulte <leif.middelschulte@gmail.com>2012-08-17 17:22:06 +0000
committerLeif Middelschulte <leif.middelschulte@gmail.com>2012-08-17 17:22:06 +0000
commitb25f28938bd610e602a20f65adf1503df941c11d (patch)
treec4f87ad93a5f5dfd4aa933d8b0aaf895dc1fab09
parenta826cdda4e7d1b7c18b3d577751c3d1b82ffb195 (diff)
downloadswig-b25f28938bd610e602a20f65adf1503df941c11d.tar.gz
Reuse 'ctype' typemap to cast wrapper calls. Reduces number of typemaps for the cost of unnecessary casts (e.g. 'int' to 'int').
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13640 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Lib/c/c.swg45
-rw-r--r--Source/Modules/c.cxx8
2 files changed, 4 insertions, 49 deletions
diff --git a/Lib/c/c.swg b/Lib/c/c.swg
index c47310a21..82490e0e1 100644
--- a/Lib/c/c.swg
+++ b/Lib/c/c.swg
@@ -363,51 +363,6 @@
%typemap(ctype, fragment="stdbool_inc") bool & "$1_ltype"
%typemap(ctype, fragment="stdbool_inc") const bool & "$1_ltype const"
-// typemaps for function parameters
-%typemap(wrap_call) void, short, int, long, long long, char, float, double ""
-%typemap(wrap_call) unsigned short, unsigned int, unsigned long, unsigned long long, unsigned char ""
-%typemap(wrap_call) void *, short *, int *, long *, long long *, char *, float *, double * ""
-%typemap(wrap_call) void **, short **, int **, long **, long long **, char **, float **, double ** ""
-%typemap(wrap_call) unsigned short *, unsigned int *, unsigned long *, unsigned long long *, unsigned char * ""
-%typemap(wrap_call) unsigned short **, unsigned int **, unsigned long **, unsigned long long **, unsigned char ** ""
-%typemap(wrap_call) short &, int &, long &, long long &, char &, float &, double & ""
-%typemap(wrap_call) unsigned short &, unsigned int &, unsigned long &, unsigned long long &, unsigned char & ""
-%typemap(wrap_call) const short, const int, const long, const long long, const char, const float, const double ""
-%typemap(wrap_call) const short &, const int &, const long &, const long long &, const char &, const float &, const double & ""
-%typemap(wrap_call) const unsigned short, const unsigned int, const unsigned long, const unsigned long long, const unsigned char ""
-%typemap(wrap_call) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned long long &, const unsigned char & ""
-%typemap(wrap_call) const void *, const short *, const int *, const long *, const long long *, const char *, const float *, const double * ""
-%typemap(wrap_call) short *&, int *&, long *&, long long *&, char *&, float *&, double *& ""
-%typemap(wrap_call) const short *&, const int *&, const long *&, const long long *&, const char *&, const float *&, const double *& " **"
-%typemap(wrap_call) short [ANY], int [ANY], long [ANY], long long [ANY], char [ANY], float [ANY], double [ANY], unsigned char [ANY], unsigned int [ANY] "/*aaa*/ "
-%typemap(wrap_call) void * [ANY], short * [ANY], int * [ANY], long * [ANY], long long * [ANY], char * [ANY], float * [ANY], double * [ANY] "/*bbb*/ "
-
-// size_t
-%typemap(wrap_call) size_t, const size_t ""
-%typemap(wrap_call) size_t*, size_t&, size_t[ANY], size_t[] ""
-%typemap(wrap_call) const size_t&, const size_t*, const size_t[ANY], const size_t[] ""
-%typemap(wrap_call) size_t**, size_t*&, size_t*[ANY], size_t[ANY][ANY] ""
-%typemap(wrap_call) const size_t**, const size_t*&, const size_t*[ANY], const size_t[ANY][ANY] ""
-
-// special cases of array passing - does not intended to be used for objects
-%typemap(wrap_call) SWIGTYPE [] ""
-%typemap(wrap_call) SWIGTYPE ((&)[ANY]) " **"
-
-%typemap(wrap_call) void [ANY][ANY], short [ANY][ANY], int [ANY][ANY], long [ANY][ANY], char [ANY][ANY], float [ANY][ANY], double [ANY][ANY] ""
-%typemap(wrap_call) SWIGTYPE "(SwigObj *)"
-%typemap(wrap_call) SWIGTYPE * "(SwigObj *)"
-%typemap(wrap_call) SWIGTYPE & "(SwigObj *)"
-%typemap(wrap_call) SWIGTYPE [ANY][ANY], SWIGTYPE ** "/* whoa */ (SwigObj ***)"
-%typemap(wrap_call) SWIGTYPE *[ANY] "/*ooooh*/ (SwigObj **)"
-%typemap(wrap_call) SWIGTYPE *& "/* *& */ (SwigObj **)"
-%typemap(wrap_call) enum SWIGTYPE ""
-%typemap(wrap_call) enum SWIGTYPE &, enum SWIGTYPE * ""
-%typemap(wrap_call, fragment="fptr_decl", fragment="fptr_decl_proxy") SWIGTYPE (CLASS::*) "(SWIG_CPP_FP)"
-
-%typemap(wrap_call, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool *, bool * [ANY] "$1_type"
-%typemap(wrap_call, fragment="stdbool_inc") bool & ""
-%typemap(wrap_call, fragment="stdbool_inc") const bool & " const"
-
%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;"
diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx
index 7a3bee04b..006542b35 100644
--- a/Source/Modules/c.cxx
+++ b/Source/Modules/c.cxx
@@ -903,7 +903,7 @@ ready:
//Swig_typemap_attach_parms("in", parms, 0);
// attach typemaps to cast wrapper call with proxy types
- Swig_typemap_attach_parms("wrap_call", parms, 0);
+ Swig_typemap_attach_parms("ctype", parms, 0);
// prepare function definition
for (p = parms, gencomma = 0; p; ) {
@@ -932,13 +932,13 @@ ready:
Printf(arg_name, "c%s", lname);
// set the appropriate type for parameter
- if ((tm = Getattr(p, "tmap:wrap_call"))) {
- Printv(c_parm_type, tm, NIL);
+ if ((tm = Getattr(p, "tmap:ctype"))) {
+ Printv(c_parm_type, NewString("("), tm, NewString(")"), NIL);
// template handling
Replaceall(c_parm_type, "$tt", SwigType_lstr(type, 0));
}
else {
- Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No wrap_call typemap defined for %s\n", SwigType_str(type, 0));
+ Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(type, 0));
}
/*