Remove completely broken handling of member function pointers

Member function pointers can't possibly be represented as function pointers,
they have a strictly bigger size and attempting to do it resulted in code
which, with a lot of bad casts, compiled, but crashed during run-time.

The proper solution is to represent C++ method pointers with an appropriate
opaque type, but for now this remains broken -- just make it explicitly broken
instead of pretending that it works when it actually has no chance to.

Let "namespace_spaces" unit test pass, as it's not really related to the
function pointers, by adding an explicit SWIGC test to it.
This commit is contained in:
Vadim Zeitlin 2016-04-20 18:38:34 +02:00
parent 11fbdba9de
commit e8c6bfbc8f
2 changed files with 3 additions and 10 deletions

View File

@ -16,7 +16,9 @@ public:
int blah(int x);
int spam(int x);
Integer bar(Integer x);
#ifndef SWIGC
void (Foo:: *func_ptr) (int);
#endif
};
inline Foo :: Foo () {}

View File

@ -5,11 +5,6 @@
* c.swg
* ----------------------------------------------------------------------------- */
// 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. See 'cpp_basic' test for details.
%insert("runtime") "clabels.swg"
%insert("proxy_header") "cproxy.swg"
@ -24,8 +19,6 @@
#define SWIG_contract_assert(expr, msg) if(!(expr)) { printf("%s\n", msg); SWIG_exit(0); } else
%}
%fragment("fptr_decl", "runtime") {typedef void(*SWIG_CPP_FP)();}
%fragment("fptr_decl_proxy", "proxy_header") {typedef void(*SWIG_CPP_FP)();}
%fragment("stdbool_inc", "proxy_header") {#include <stdbool.h>}
%define same_macro_all_primitive_types_but_void(macro_name, TM)
@ -135,7 +128,6 @@ explicit_same_type_all_primitive_types_but_void(ctype);
%typemap(ctype) SWIGTYPE ** "/*SWIGTYPE ** */ $1_ltype **"
%typemap(ctype) enum SWIGTYPE "int"
%typemap(ctype) enum SWIGTYPE &, enum SWIGTYPE * "int *"
%typemap(ctype, fragment="fptr_decl") SWIGTYPE (CLASS::*) "SWIG_CPP_FP"
%typemap(ctype, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$1_ltype"
%typemap(ctype, fragment="stdbool_inc") bool & "$1_ltype"
@ -166,7 +158,6 @@ explicit_same_type_unconsted_all_primitive_types_but_void(cmodtype);
%typemap(cmodtype) SWIGTYPE *& "/* *& */ SwigObj **"
%typemap(cmodtype) enum SWIGTYPE "int"
%typemap(cmodtype) enum SWIGTYPE &, enum SWIGTYPE * "int *"
%typemap(cmodtype, fragment="fptr_decl", fragment="fptr_decl_proxy") SWIGTYPE (CLASS::*) "SWIG_CPP_FP"
%typemap(cmodtype, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool *, bool * [ANY] "$1_type"
%typemap(cmodtype, fragment="stdbool_inc") bool & "$1_ltype"
@ -323,7 +314,7 @@ explicit_same_type_unconsted_all_primitive_types_but_void(cppouttype);
%typemap(cppouttype) SWIGTYPE ** "/*SWIGTYPE ** */ $1_basetype **"
%typemap(cppouttype, retobj="1") enum SWIGTYPE "int"
%typemap(cppouttype) enum SWIGTYPE &, enum SWIGTYPE * "int *"
%typemap(cppouttype, fragment="fptr_decl") SWIGTYPE (CLASS::*) "$1_ltype"
%typemap(cppouttype) 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*"