Add support for member function pointers with ref-qualifiers
This commit is contained in:
parent
7e4717320b
commit
eb68e4375d
4 changed files with 195 additions and 45 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
%module cpp11_ref_qualifiers
|
%module cpp11_ref_qualifiers
|
||||||
|
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra2;
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra3;
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc2;
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc3;
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc5;
|
||||||
|
|
||||||
%include <std_string.i>
|
%include <std_string.i>
|
||||||
|
|
||||||
%ignore Host::h() const &;
|
%ignore Host::h() const &;
|
||||||
|
|
@ -89,3 +95,114 @@ struct ConversionOperators2 {
|
||||||
virtual operator string() && { return std::move(string()); }
|
virtual operator string() && { return std::move(string()); }
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct Funcs {
|
||||||
|
short FF(bool) { return 0; }
|
||||||
|
short CC(bool) const & { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class MemberFuncPtrs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// member ref-qualified function pointers, unnamed parameters
|
||||||
|
int aaa1(short (Funcs::*)(bool) &) const;
|
||||||
|
int aaa2(short (Funcs::* const *&)(bool) &) const;
|
||||||
|
int aaa3(short (Funcs::* *&)(bool) &) const;
|
||||||
|
int aaa4(short (Funcs::* *const&)(bool) &) const;
|
||||||
|
int aaa5(short (Funcs::* &)(bool) &) const;
|
||||||
|
int aaa6(short (Funcs::* const)(bool) &) const;
|
||||||
|
int aaa7(short (Funcs::* const&)(bool) &) const;
|
||||||
|
|
||||||
|
// member cv-qualified and ref-qualified function pointers, unnamed parameters
|
||||||
|
int bbb1(short (Funcs::*)(bool) const &) const;
|
||||||
|
int bbb2(short (Funcs::* const *&)(bool) const &) const;
|
||||||
|
int bbb3(short (Funcs::* *&)(bool) const &) const;
|
||||||
|
int bbb4(short (Funcs::* *const&)(bool) const &) const;
|
||||||
|
int bbb5(short (Funcs::* &)(bool) const &) const;
|
||||||
|
int bbb6(short (Funcs::* const)(bool) const &) const;
|
||||||
|
int bbb7(short (Funcs::* const&)(bool) const &) const;
|
||||||
|
|
||||||
|
// member ref-qualified function pointers, named parameters
|
||||||
|
int qqq1(short (Funcs::* qq1)(bool) &) const;
|
||||||
|
int qqq2(short (Funcs::* const *& qq2)(bool) &) const;
|
||||||
|
int qqq3(short (Funcs::* *& qq3)(bool) &) const;
|
||||||
|
int qqq4(short (Funcs::* *const& qq4)(bool) &) const;
|
||||||
|
int qqq5(short (Funcs::* & qq5)(bool) &) const;
|
||||||
|
int qqq6(short (Funcs::* const qq6)(bool) &) const;
|
||||||
|
int qqq7(short (Funcs::* const& qq7)(bool) &) const;
|
||||||
|
|
||||||
|
// member cv-qualified and ref-qualified function pointers, named parameters
|
||||||
|
int rrr1(short (Funcs::* rr1)(bool) const &) const;
|
||||||
|
int rrr2(short (Funcs::* const *& rr2)(bool) const &) const;
|
||||||
|
int rrr3(short (Funcs::* *& rr3)(bool) const &) const;
|
||||||
|
int rrr4(short (Funcs::* *const& rr4)(bool) const &) const;
|
||||||
|
int rrr5(short (Funcs::* & rr5)(bool) const &) const;
|
||||||
|
int rrr6(short (Funcs::* const rr6)(bool) const &) const;
|
||||||
|
int rrr7(short (Funcs::* const& rr7)(bool) const &) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// member ref-qualified function pointers, unnamed parameters
|
||||||
|
int MemberFuncPtrs::aaa1(short (Funcs::*)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa3(short (Funcs::* *&)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa4(short (Funcs::* *const&)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa5(short (Funcs::* &)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa6(short (Funcs::* const)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::aaa7(short (Funcs::* const&)(bool) &) const { return 0; }
|
||||||
|
|
||||||
|
// member cv-qualified and ref-qualified function pointers, unnamed parameters
|
||||||
|
int MemberFuncPtrs::bbb1(short (Funcs::*)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb2(short (Funcs::* const *&)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb3(short (Funcs::* *&)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb4(short (Funcs::* *const&)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb5(short (Funcs::* &)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb6(short (Funcs::* const)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::bbb7(short (Funcs::* const&)(bool) const &) const { return 0; }
|
||||||
|
|
||||||
|
// member ref-qualified function pointers, named parameters
|
||||||
|
int MemberFuncPtrs::qqq1(short (Funcs::* qq1)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::qqq2(short (Funcs::* const *& qq2)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::qqq3(short (Funcs::* *& qq3)(bool) &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::qqq4(short (Funcs::* *const& qq4)(bool) &) const { return 0; }
|
||||||
|
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; }
|
||||||
|
|
||||||
|
// member cv-qualified and ref-qualified function pointers, named parameters
|
||||||
|
int MemberFuncPtrs::rrr1(short (Funcs::* rr1)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr2(short (Funcs::* const *& rr2)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr3(short (Funcs::* *& rr3)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr4(short (Funcs::* *const& rr4)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr5(short (Funcs::* & rr5)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr6(short (Funcs::* const rr6)(bool) const &) const { return 0; }
|
||||||
|
int MemberFuncPtrs::rrr7(short (Funcs::* const& rr7)(bool) const &) const { return 0; }
|
||||||
|
|
||||||
|
// member cv-qualified and ref-qualified pointer variables
|
||||||
|
short (Funcs::* cc1)(bool) const & = &Funcs::CC;
|
||||||
|
|
||||||
|
short (Funcs::* const * ccextra2)(bool) const & = &cc1;
|
||||||
|
short (Funcs::* * ccextra3)(bool) const & = &cc1;
|
||||||
|
short (Funcs::* *const ccextra4)(bool) const & = &cc1;
|
||||||
|
|
||||||
|
short (Funcs::* const *& cc2)(bool) const & = ccextra2;
|
||||||
|
short (Funcs::* *& cc3)(bool) const & = ccextra3;
|
||||||
|
short (Funcs::* *const& cc4)(bool) const & = ccextra4;
|
||||||
|
short (Funcs::* & cc5)(bool) const & = cc1;
|
||||||
|
short (Funcs::* const cc6)(bool) const & = &Funcs::CC;
|
||||||
|
short (Funcs::* const& cc7)(bool) const & = cc1;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
struct Funktions {
|
||||||
|
int addByValue(const int &a, int b) const & { return a+b; }
|
||||||
|
int * addByPointer(const int &a, int b) const & { static int val; val = a+b; return &val; }
|
||||||
|
int & addByReference(const int &a, int b) const & { static int val; val = a+b; return val; }
|
||||||
|
};
|
||||||
|
|
||||||
|
int call1(int (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
|
||||||
|
//int call2(int * (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return *(f.*d)(a, b); }
|
||||||
|
//int call3(int & (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
|
||||||
|
%}
|
||||||
|
%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) const & = &Funktions::addByValue;
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ public:
|
||||||
int qqq7(short (Funcs::* const& qq7)(bool)) const;
|
int qqq7(short (Funcs::* const& qq7)(bool)) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// member const function pointers, unnamed parameters
|
// member const function pointers, unnamed parameters
|
||||||
int MemberFuncPtrs::aaa1(short (Funcs::* )(bool) const) const { return 0; }
|
int MemberFuncPtrs::aaa1(short (Funcs::* )(bool) const) const { return 0; }
|
||||||
int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) const) const { return 0; }
|
int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) const) const { return 0; }
|
||||||
int MemberFuncPtrs::aaa3(short (Funcs::* *& )(bool) const) const { return 0; }
|
int MemberFuncPtrs::aaa3(short (Funcs::* *& )(bool) const) const { return 0; }
|
||||||
|
|
|
||||||
|
|
@ -1897,10 +1897,10 @@ constant_directive : CONSTANT identifier EQUAL definetype SEMI {
|
||||||
}
|
}
|
||||||
/* Member const function pointers . eg.
|
/* Member const function pointers . eg.
|
||||||
%constant short (Funcs::*pmf)(bool) const = &Funcs::F; */
|
%constant short (Funcs::*pmf)(bool) const = &Funcs::F; */
|
||||||
| CONSTANT type direct_declarator LPAREN parms RPAREN CONST_QUAL def_args SEMI {
|
| CONSTANT type direct_declarator LPAREN parms RPAREN cv_ref_qualifier def_args SEMI {
|
||||||
if (($8.type != T_ERROR) && ($8.type != T_SYMBOL)) {
|
if (($8.type != T_ERROR) && ($8.type != T_SYMBOL)) {
|
||||||
SwigType_add_function($2, $5);
|
SwigType_add_function($2, $5);
|
||||||
SwigType_add_qualifier($2, "const");
|
SwigType_push($2, $7.qualifier);
|
||||||
SwigType_push($2, $3.type);
|
SwigType_push($2, $3.type);
|
||||||
/* Sneaky callback function trick */
|
/* Sneaky callback function trick */
|
||||||
if (SwigType_isfunction($2)) {
|
if (SwigType_isfunction($2)) {
|
||||||
|
|
@ -5118,12 +5118,13 @@ parameter_declarator : declarator def_args {
|
||||||
}
|
}
|
||||||
/* Member const function pointer parameters. eg.
|
/* Member const function pointer parameters. eg.
|
||||||
int f(short (Funcs::*parm)(bool) const); */
|
int f(short (Funcs::*parm)(bool) const); */
|
||||||
| direct_declarator LPAREN parms RPAREN CONST_QUAL {
|
| direct_declarator LPAREN parms RPAREN cv_ref_qualifier {
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
t = NewStringEmpty();
|
t = NewStringEmpty();
|
||||||
SwigType_add_function(t,$3);
|
SwigType_add_function(t,$3);
|
||||||
SwigType_add_qualifier(t, "const");
|
if ($5.qualifier)
|
||||||
|
SwigType_push(t, $5.qualifier);
|
||||||
if (!$$.have_parms) {
|
if (!$$.have_parms) {
|
||||||
$$.parms = $3;
|
$$.parms = $3;
|
||||||
$$.have_parms = 1;
|
$$.have_parms = 1;
|
||||||
|
|
@ -5812,12 +5813,12 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
|
||||||
$$.have_parms = 1;
|
$$.have_parms = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| direct_abstract_declarator LPAREN parms RPAREN type_qualifier {
|
| direct_abstract_declarator LPAREN parms RPAREN cv_ref_qualifier {
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
t = NewStringEmpty();
|
t = NewStringEmpty();
|
||||||
SwigType_add_function(t,$3);
|
SwigType_add_function(t,$3);
|
||||||
SwigType_push(t, $5);
|
SwigType_push(t, $5.qualifier);
|
||||||
if (!$$.type) {
|
if (!$$.type) {
|
||||||
$$.type = t;
|
$$.type = t;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -544,10 +544,9 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
||||||
String *element = 0;
|
String *element = 0;
|
||||||
String *nextelement;
|
String *nextelement;
|
||||||
String *forwardelement;
|
String *forwardelement;
|
||||||
String *member_const_function_element = 0;
|
SwigType *member_function_qualifiers = 0;
|
||||||
List *elements;
|
List *elements;
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int member_const_function = 0;
|
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
/* stringify the id expanding templates, for example when the id is a fully qualified templated class name */
|
/* stringify the id expanding templates, for example when the id is a fully qualified templated class name */
|
||||||
|
|
@ -578,14 +577,12 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
||||||
forwardelement = 0;
|
forwardelement = 0;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(element)) {
|
if (SwigType_isqualifier(element)) {
|
||||||
if (!member_const_function) {
|
if (!member_function_qualifiers) {
|
||||||
DOH *q = 0;
|
DOH *q = 0;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result, 0, " ");
|
Insert(result, 0, " ");
|
||||||
Insert(result, 0, q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
Delete(q);
|
||||||
} else {
|
|
||||||
member_const_function = 0;
|
|
||||||
}
|
}
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Insert(result, 0, "*");
|
Insert(result, 0, "*");
|
||||||
|
|
@ -602,19 +599,27 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(nextelement)) {
|
{
|
||||||
member_const_function_element = nextelement;
|
String *next3elements = NewStringEmpty();
|
||||||
member_const_function = 1;
|
int j;
|
||||||
|
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||||
|
Append(next3elements, Getitem(elements, j));
|
||||||
|
}
|
||||||
|
if (SwigType_isfunction(next3elements))
|
||||||
|
member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||||
|
Delete(next3elements);
|
||||||
}
|
}
|
||||||
Delete(q);
|
Delete(q);
|
||||||
} else if (SwigType_isreference(element)) {
|
} else if (SwigType_isreference(element)) {
|
||||||
Insert(result, 0, "&");
|
if (!member_function_qualifiers)
|
||||||
|
Insert(result, 0, "&");
|
||||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
} else if (SwigType_isrvalue_reference(element)) {
|
} else if (SwigType_isrvalue_reference(element)) {
|
||||||
Insert(result, 0, "&&");
|
if (!member_function_qualifiers)
|
||||||
|
Insert(result, 0, "&&");
|
||||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
|
|
@ -639,12 +644,13 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
||||||
Append(result, ",");
|
Append(result, ",");
|
||||||
}
|
}
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
if (member_const_function_element) {
|
if (member_function_qualifiers) {
|
||||||
String *p = SwigType_str(member_const_function_element, 0);
|
String *p = SwigType_str(member_function_qualifiers, 0);
|
||||||
Append(result, " ");
|
Append(result, " ");
|
||||||
Append(result, p);
|
Append(result, p);
|
||||||
Delete(p);
|
Delete(p);
|
||||||
member_const_function_element = 0;
|
Delete(member_function_qualifiers);
|
||||||
|
member_function_qualifiers = 0;
|
||||||
}
|
}
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -678,7 +684,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
int notypeconv = 0;
|
int notypeconv = 0;
|
||||||
int memberpointer = 0;
|
int ignore_member_function_qualifiers = 0;
|
||||||
|
|
||||||
result = NewStringEmpty();
|
result = NewStringEmpty();
|
||||||
tc = Copy(s);
|
tc = Copy(s);
|
||||||
|
|
@ -705,6 +711,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
||||||
tc = td;
|
tc = td;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = SwigType_split(tc);
|
elements = SwigType_split(tc);
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
|
|
||||||
|
|
@ -714,18 +721,34 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
||||||
/* when we see a function, we need to preserve the following types */
|
/* when we see a function, we need to preserve the following types */
|
||||||
if (SwigType_isfunction(element)) {
|
if (SwigType_isfunction(element)) {
|
||||||
notypeconv = 1;
|
notypeconv = 1;
|
||||||
|
ignore_member_function_qualifiers = 0;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(element)) {
|
if (ignore_member_function_qualifiers) {
|
||||||
if (memberpointer)
|
/* cv-qualifiers and ref-qualifiers up until the f() element have already been added */
|
||||||
Append(result, element);
|
} else if (SwigType_isqualifier(element)) {
|
||||||
/* otherwise ignore */
|
/* swallow cv-qualifiers */
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Append(result, element);
|
Append(result, element);
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
} else if (SwigType_ismemberpointer(element)) {
|
} else if (SwigType_ismemberpointer(element)) {
|
||||||
Append(result, element);
|
Append(result, element);
|
||||||
|
{
|
||||||
|
String *next3elements = NewStringEmpty();
|
||||||
|
int j;
|
||||||
|
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||||
|
Append(next3elements, Getitem(elements, j));
|
||||||
|
}
|
||||||
|
if (SwigType_isfunction(next3elements)) {
|
||||||
|
SwigType *member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||||
|
/* compilers won't let us cast from a member function without qualifiers to one with qualifiers, so the qualifiers are kept in the ltype */
|
||||||
|
if (member_function_qualifiers)
|
||||||
|
Append(result, member_function_qualifiers);
|
||||||
|
Delete(member_function_qualifiers);
|
||||||
|
ignore_member_function_qualifiers = 1;
|
||||||
|
}
|
||||||
|
Delete(next3elements);
|
||||||
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
memberpointer = 1;
|
|
||||||
} else if (SwigType_isreference(element)) {
|
} else if (SwigType_isreference(element)) {
|
||||||
if (notypeconv) {
|
if (notypeconv) {
|
||||||
Append(result, element);
|
Append(result, element);
|
||||||
|
|
@ -764,13 +787,14 @@ SwigType *SwigType_ltype(const SwigType *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* SwigType_lstr(DOH *s, DOH *id)
|
* SwigType_lstr()
|
||||||
*
|
*
|
||||||
* Produces a type-string that is suitable as a lvalue in an expression.
|
* Produces a type-string that is suitable as a lvalue in an expression.
|
||||||
* That is, a type that can be freely assigned a value without violating
|
* That is, a type that can be freely assigned a value without violating
|
||||||
* any C assignment rules.
|
* any C assignment rules.
|
||||||
*
|
*
|
||||||
* - Qualifiers such as 'const' and 'volatile' are stripped.
|
* - Qualifiers such as 'const' and 'volatile' are stripped.
|
||||||
|
* Except for member function cv-qualifiers and ref-qualifiers.
|
||||||
* - Arrays are converted into a *single* pointer (i.e.,
|
* - Arrays are converted into a *single* pointer (i.e.,
|
||||||
* double [][] becomes double *).
|
* double [][] becomes double *).
|
||||||
* - References are converted into a pointer.
|
* - References are converted into a pointer.
|
||||||
|
|
@ -800,7 +824,7 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||||
String *element = 0;
|
String *element = 0;
|
||||||
String *nextelement;
|
String *nextelement;
|
||||||
String *forwardelement;
|
String *forwardelement;
|
||||||
String *member_const_function_element = 0;
|
String *member_function_qualifiers = 0;
|
||||||
SwigType *td, *tc = 0;
|
SwigType *td, *tc = 0;
|
||||||
const SwigType *rs;
|
const SwigType *rs;
|
||||||
List *elements;
|
List *elements;
|
||||||
|
|
@ -809,7 +833,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
int isreference = 0;
|
int isreference = 0;
|
||||||
int isfunction = 0;
|
int isfunction = 0;
|
||||||
int member_const_function = 0;
|
|
||||||
|
|
||||||
result = NewStringEmpty();
|
result = NewStringEmpty();
|
||||||
|
|
||||||
|
|
@ -858,15 +881,13 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||||
forwardelement = 0;
|
forwardelement = 0;
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(element)) {
|
if (SwigType_isqualifier(element)) {
|
||||||
if (!member_const_function) {
|
if (!member_function_qualifiers) {
|
||||||
DOH *q = 0;
|
DOH *q = 0;
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result, 0, " ");
|
Insert(result, 0, " ");
|
||||||
Insert(result, 0, q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
Delete(q);
|
||||||
clear = 0;
|
clear = 0;
|
||||||
} else {
|
|
||||||
member_const_function = 0;
|
|
||||||
}
|
}
|
||||||
} else if (SwigType_ispointer(element)) {
|
} else if (SwigType_ispointer(element)) {
|
||||||
Insert(result, 0, "*");
|
Insert(result, 0, "*");
|
||||||
|
|
@ -880,32 +901,42 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||||
Insert(result, 0, "::*");
|
Insert(result, 0, "::*");
|
||||||
q = SwigType_parm(element);
|
q = SwigType_parm(element);
|
||||||
Insert(result, 0, q);
|
Insert(result, 0, q);
|
||||||
Delete(q);
|
|
||||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
if (SwigType_isqualifier(nextelement)) {
|
{
|
||||||
member_const_function_element = nextelement;
|
String *next3elements = NewStringEmpty();
|
||||||
member_const_function = 1;
|
int j;
|
||||||
|
for (j = i + 1; j < i + 4 && j < nelements; j++) {
|
||||||
|
Append(next3elements, Getitem(elements, j));
|
||||||
|
}
|
||||||
|
if (SwigType_isfunction(next3elements))
|
||||||
|
member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
|
||||||
|
Delete(next3elements);
|
||||||
}
|
}
|
||||||
firstarray = 0;
|
firstarray = 0;
|
||||||
|
Delete(q);
|
||||||
} else if (SwigType_isreference(element)) {
|
} else if (SwigType_isreference(element)) {
|
||||||
Insert(result, 0, "&");
|
if (!member_function_qualifiers) {
|
||||||
|
Insert(result, 0, "&");
|
||||||
|
if (!isfunction)
|
||||||
|
isreference = 1;
|
||||||
|
}
|
||||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
if (!isfunction)
|
|
||||||
isreference = 1;
|
|
||||||
} else if (SwigType_isrvalue_reference(element)) {
|
} else if (SwigType_isrvalue_reference(element)) {
|
||||||
Insert(result, 0, "&&");
|
if (!member_function_qualifiers) {
|
||||||
|
Insert(result, 0, "&&");
|
||||||
|
if (!isfunction)
|
||||||
|
isreference = 1;
|
||||||
|
}
|
||||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||||
Insert(result, 0, "(");
|
Insert(result, 0, "(");
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
}
|
}
|
||||||
if (!isfunction)
|
|
||||||
isreference = 1;
|
|
||||||
clear = 0;
|
clear = 0;
|
||||||
} else if (SwigType_isarray(element)) {
|
} else if (SwigType_isarray(element)) {
|
||||||
DOH *size;
|
DOH *size;
|
||||||
|
|
@ -935,12 +966,13 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||||
}
|
}
|
||||||
Append(result, ")");
|
Append(result, ")");
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
if (member_const_function_element) {
|
if (member_function_qualifiers) {
|
||||||
String *p = SwigType_str(member_const_function_element, 0);
|
String *p = SwigType_str(member_function_qualifiers, 0);
|
||||||
Append(result, " ");
|
Append(result, " ");
|
||||||
Append(result, p);
|
Append(result, p);
|
||||||
Delete(p);
|
Delete(p);
|
||||||
member_const_function_element = 0;
|
Delete(member_function_qualifiers);
|
||||||
|
member_function_qualifiers = 0;
|
||||||
clear = 0;
|
clear = 0;
|
||||||
}
|
}
|
||||||
isfunction = 1;
|
isfunction = 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue