mirror of https://github.com/swig/swig
Add %$isextendmember for %rename of members added via %extend
This commit is contained in:
parent
9cbd742b66
commit
c5911cc08d
|
@ -8,6 +8,12 @@ Version 3.0.0 (in progress)
|
|||
2014-02-15: wsfulton
|
||||
Fix the %$ismember %rename predicates to also apply to members added via %extend.
|
||||
|
||||
Add %$isextendmember for %rename of members added via %extend. This can be used to
|
||||
distinguish between normal class/struct members and %extend members. For example
|
||||
'%$ismember, %$not %$isextendmember' will now identify just class/struct members.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2014-02-16: hfalcic
|
||||
[Python] Patch #133 - fix crashes/exceptions in exception handling in Python 3.3
|
||||
|
||||
|
|
|
@ -33,3 +33,10 @@ FL_firstLowerCase()
|
|||
CA_CamelCase()
|
||||
LC_lowerCamelCase()
|
||||
UC_under_case_it()
|
||||
|
||||
ex = ExtendCheck()
|
||||
ex.MF_real_member1()
|
||||
ex.MF_real_member2()
|
||||
ex.EX_EXTENDMETHOD1()
|
||||
ex.EX_EXTENDMETHOD2()
|
||||
ex.EX_EXTENDMETHOD3()
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
%module rename_predicates
|
||||
|
||||
// Test a few of the predicates - %$isfunction etc
|
||||
%rename("AF_%(utitle)s", %$isfunction) "";
|
||||
%rename("MF_%(utitle)s", %$isfunction, %$ismember) "";
|
||||
%rename("GF_%(utitle)s", %$isfunction, %$not %$ismember) "";
|
||||
%rename("MV_%(utitle)s", %$isvariable) "";
|
||||
%rename("GV_%(utitle)s", %$isvariable, %$isglobal) "";
|
||||
|
||||
|
||||
%extend RenamePredicates {
|
||||
void extend_function_before() {}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ void global_function() {}
|
|||
void extend_function_after() {}
|
||||
}
|
||||
|
||||
// Test the various %rename functions - %(upper) etc
|
||||
%rename("UC_%(upper)s") "uppercase";
|
||||
%rename("LC_%(lower)s") "LOWERcase";
|
||||
%rename("TI_%(title)s") "title";
|
||||
|
@ -48,3 +49,23 @@ void Lower_camel_Case() {}
|
|||
void UnderCaseIt() {}
|
||||
%}
|
||||
|
||||
// Test renaming only member functions in %extend
|
||||
%rename("EX_%(upper)s", %$isfunction, %$isextendmember) "";
|
||||
%extend ExtendCheck {
|
||||
void ExtendMethod1() {}
|
||||
}
|
||||
%inline %{
|
||||
struct ExtendCheck {
|
||||
void RealMember1() {}
|
||||
#ifdef SWIG
|
||||
%extend {
|
||||
void ExtendMethod2() {}
|
||||
}
|
||||
#endif
|
||||
void RealMember2() {}
|
||||
};
|
||||
%}
|
||||
%extend ExtendCheck {
|
||||
void ExtendMethod3() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,7 @@ static int NAME(TYPE x) {
|
|||
|
||||
%define %$ismember "match$ismember"="1" %enddef
|
||||
%define %$isglobal %$not %$ismember %enddef
|
||||
%define %$isextendmember "match$isextendmember"="1" %enddef
|
||||
%define %$innamespace "match$parentNode$nodeType"="namespace" %enddef
|
||||
|
||||
%define %$ispublic "match$access"="public" %enddef
|
||||
|
|
|
@ -363,6 +363,10 @@ static void add_symbols(Node *n) {
|
|||
Setattr(n,"ismember","1");
|
||||
}
|
||||
|
||||
if (extendmode) {
|
||||
Setattr(n,"isextendmember","1");
|
||||
}
|
||||
|
||||
if (!isfriend && inclass) {
|
||||
if ((cplus_mode != CPLUS_PUBLIC)) {
|
||||
only_csymbol = 1;
|
||||
|
@ -1392,6 +1396,7 @@ static void mark_nodes_as_extend(Node *n) {
|
|||
for (; n; n = nextSibling(n)) {
|
||||
if (Getattr(n, "template") && Strcmp(nodeType(n), "class") == 0)
|
||||
continue;
|
||||
/* Fix me: extend is not a feature. Replace with isextendmember? */
|
||||
Setattr(n, "feature:extend", "1");
|
||||
mark_nodes_as_extend(firstChild(n));
|
||||
}
|
||||
|
@ -4350,14 +4355,17 @@ cpp_members : cpp_member cpp_members {
|
|||
}
|
||||
}
|
||||
| EXTEND LBRACE {
|
||||
if (cplus_mode != CPLUS_PUBLIC) {
|
||||
Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n");
|
||||
}
|
||||
} cpp_members RBRACE cpp_members {
|
||||
extendmode = 1;
|
||||
if (cplus_mode != CPLUS_PUBLIC) {
|
||||
Swig_error(cparse_file,cparse_line,"%%extend can only be used in a public section\n");
|
||||
}
|
||||
} cpp_members RBRACE {
|
||||
extendmode = 0;
|
||||
} cpp_members {
|
||||
$$ = new_node("extend");
|
||||
mark_nodes_as_extend($4);
|
||||
appendChild($$,$4);
|
||||
set_nextSibling($$,$6);
|
||||
set_nextSibling($$,$7);
|
||||
}
|
||||
| include_directive { $$ = $1; }
|
||||
| empty { $$ = 0;}
|
||||
|
|
Loading…
Reference in New Issue