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
This commit is contained in:
parent
a826cdda4e
commit
b25f28938b
2 changed files with 4 additions and 49 deletions
45
Lib/c/c.swg
45
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;"
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue