Fix wrapping of references/pointers and qualifiers to member pointers

Also fix Go wrapping of member const function pointers.
This commit is contained in:
William S Fulton 2017-03-16 21:04:38 +00:00
commit 72ba741d1c
21 changed files with 70 additions and 42 deletions

View file

@ -1,5 +1,11 @@
%module member_funcptr_galore
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) extra2;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) extra3;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp2;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp3;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp5;
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
@ -185,7 +191,6 @@ int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool)) const { return 0; }
int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool)) const { return 0; }
int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool)) const { return 0; }
#if !defined(SWIGGO)
// member function pointer variables
short (Funcs::* pp1)(bool) = &Funcs::FF;
@ -199,5 +204,4 @@ short (Funcs::* *const& pp4)(bool) = extra4;
short (Funcs::* & pp5)(bool) = pp1;
short (Funcs::* const pp6)(bool) = &Funcs::FF;
short (Funcs::* const& pp7)(bool) = pp1;
#endif
%}

View file

@ -48,24 +48,18 @@ public:
typedef double (Shape::*PerimeterFunc_td)(void);
extern double do_op(Shape *s, double (Shape::*m)(void));
#if !defined(SWIGGO)
extern double do_op_td(Shape *s, PerimeterFunc_td m);
#endif
/* Functions that return member pointers */
extern double (Shape::*areapt())(void);
extern double (Shape::*perimeterpt())(void);
#if !defined(SWIGGO)
extern PerimeterFunc_td perimeterpt_td();
#endif
/* Global variables that are member pointers */
extern double (Shape::*areavar)(void);
extern double (Shape::*perimetervar)(void);
#if !defined(SWIGGO)
extern PerimeterFunc_td perimetervar_td;
#endif
%}
%{

View file

@ -49,24 +49,18 @@ public:
typedef double (Shape::*PerimeterFunc_td)(void) const;
extern double do_op(Shape *s, double (Shape::*m)(void) const);
#if !defined(SWIGGO)
extern double do_op_td(Shape *s, PerimeterFunc_td m);
#endif
/* Functions that return member pointers */
extern double (Shape::*areapt())(void) const;
extern double (Shape::*perimeterpt())(void) const;
#if !defined(SWIGGO)
extern PerimeterFunc_td perimeterpt_td();
#endif
/* Global variables that are member pointers */
extern double (Shape::*areavar)(void) const;
extern double (Shape::*perimetervar)(void) const;
#if !defined(SWIGGO)
extern PerimeterFunc_td perimetervar_td;
#endif
%}
%{
@ -124,11 +118,9 @@ PerimeterFunc_td perimetervar_td = &Shape::perimeter;
/* Some constants */
#if !defined(SWIGGO)
%constant double (Shape::*AREAPT)(void) const = &Shape::area;
%constant double (Shape::*PERIMPT)(void) const = &Shape::perimeter;
%constant double (Shape::*NULLPT)(void) const = 0;
#endif
/*
%inline %{
@ -152,8 +144,6 @@ int call1(int (Funktions::*d)(const int &, int) const, int a, int b) { Funktions
//int call3(int & (Funktions::*d)(const int &, int) const, int a, int b) { Funktions f; return (f.*d)(a, b); }
%}
#if !defined(SWIGGO)
%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) const = &Funktions::addByValue;
#endif
//%constant int * (Funktions::*ADD_BY_POINTER)(const int &, int) const = &Funktions::addByPointer;
//%constant int & (Funktions::*ADD_BY_REFERENCE)(const int &, int) const = &Funktions::addByReference;