Permalink
Browse files

Fix %$ismember %rename predicate for members added via %extend

Bug reported was incorrect renaming of PHP built-in functions, such as
next. See PHPFN in phpkw.swg.

Add some tests for the %rename predicates.
  • Loading branch information...
1 parent fcf8180 commit 9cbd742b66b839d110af9b85ee210d60c7023f68 @wsfulton wsfulton committed Feb 18, 2014
View
@@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.0 (in progress)
============================
+2014-02-15: wsfulton
+ Fix the %$ismember %rename predicates to also apply to members added via %extend.
+
2014-02-16: hfalcic
[Python] Patch #133 - fix crashes/exceptions in exception handling in Python 3.3
@@ -86,6 +86,7 @@ CPP_TEST_BROKEN += \
li_boost_shared_ptr_template \
nested_private \
overload_complicated \
+ rename_camel \
template_default_pointer \
template_private_assignment \
template_expr \
@@ -323,6 +324,7 @@ CPP_TEST_CASES += \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \
+ rename_predicates \
restrict_cplusplus \
return_const_value \
return_value_scope \
@@ -0,0 +1,35 @@
+from rename_predicates import *
+
+r = RenamePredicates(123)
+r.MF_member_function()
+r.MF_static_member_function()
+r.MF_extend_function_before()
+r.MF_extend_function_after()
+GF_global_function()
+
+if r.MV_member_variable != 123:
+ raise RuntimeError("variable wrong")
+r.MV_member_variable = 1234;
+if r.MV_member_variable != 1234:
+ raise RuntimeError("variable wrong")
+
+if cvar.RenamePredicates_MV_static_member_variable != 456:
+ raise RuntimeError("variable wrong")
+cvar.RenamePredicates_MV_static_member_variable = 4567;
+if cvar.RenamePredicates_MV_static_member_variable != 4567:
+ raise RuntimeError("variable wrong")
+
+if cvar.GV_global_variable != 789:
+ raise RuntimeError("variable wrong")
+cvar.GV_global_variable = 7890;
+if cvar.GV_global_variable != 7890:
+ raise RuntimeError("variable wrong")
+
+UC_UPPERCASE()
+LC_lowercase()
+TI_Title()
+FU_FirstUpperCase()
+FL_firstLowerCase()
+CA_CamelCase()
+LC_lowerCamelCase()
+UC_under_case_it()
@@ -0,0 +1,50 @@
+%module rename_predicates
+
+%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() {}
+}
+
+%inline %{
+struct RenamePredicates {
+ RenamePredicates(int v = 0) : member_variable(v) {}
+ void member_function() {}
+ static void static_member_function() {}
+ int member_variable;
+ static int static_member_variable;
+};
+int RenamePredicates::static_member_variable = 456;
+int global_variable = 789;
+void global_function() {}
+%}
+
+%extend RenamePredicates {
+ void extend_function_after() {}
+}
+
+%rename("UC_%(upper)s") "uppercase";
+%rename("LC_%(lower)s") "LOWERcase";
+%rename("TI_%(title)s") "title";
+%rename("FU_%(firstuppercase)s") "firstUpperCase";
+%rename("FL_%(firstlowercase)s") "FirstLowerCase";
+%rename("CA_%(camelcase)s") "camel_Case";
+%rename("LC_%(lowercamelcase)s") "Lower_camel_Case";
+%rename("UC_%(undercase)s") "UnderCaseIt";
+
+%inline %{
+void uppercase() {}
+void LOWERcase() {}
+void title() {}
+void firstUpperCase() {}
+void FirstLowerCase() {}
+void camel_Case() {}
+void Lower_camel_Case() {}
+void UnderCaseIt() {}
+%}
+
View
@@ -356,10 +356,13 @@ static void add_symbols(Node *n) {
}
Delete(prefix);
}
-
- Setattr(n,"ismember","1");
}
}
+
+ if (!isfriend && (inclass || extendmode)) {
+ Setattr(n,"ismember","1");
+ }
+
if (!isfriend && inclass) {
if ((cplus_mode != CPLUS_PUBLIC)) {
only_csymbol = 1;

0 comments on commit 9cbd742

Please sign in to comment.