diff --git a/CHANGES.current b/CHANGES.current index b864b2aa2..08603bd5d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,11 @@ Version 2.0.9 (in progress) indicate the size of the 'int' type in Go. This is because the size of the type is changing from Go 1.0 to Go 1.1 for x86_64. +2012-09-14: wsfulton + Additional new special variables in %exception are expanded as follows: + $parentname - The parent class name (if any) for a method. + $parentsymname - The target language parent class name (if any) for a method. + 2012-09-14: wsfulton Add new warning if the empty template instantiation is used as a base class, for example: diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index b98fbfc88..c903f24fa 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -479,6 +479,16 @@ variables are replaced with.
diff --git a/Examples/test-suite/java/special_variables_runme.java b/Examples/test-suite/java/special_variables_runme.java index eb9f093bd..703e6fb0d 100644 --- a/Examples/test-suite/java/special_variables_runme.java +++ b/Examples/test-suite/java/special_variables_runme.java @@ -15,13 +15,13 @@ public class special_variables_runme { public static void main(String argv[]) { verify(special_variables.ExceptionVars(1.0, 2.0), - "result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars Java_special_1variables_special_1variablesJNI_ExceptionVars"); + "result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars Java_special_1variables_special_1variablesJNI_ExceptionVars "); verify(special_variables.overloadedmethod(), - "result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_11"); + "result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_11 "); verify(special_variables.overloadedmethod(10.0), - "result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_10"); + "result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 Java_special_1variables_special_1variablesJNI_overloadedmethod_1_1SWIG_10 "); ABC a = new ABC(0, 0.0); verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)"); diff --git a/Examples/test-suite/special_variables.i b/Examples/test-suite/special_variables.i index 071365710..aa1db0461 100644 --- a/Examples/test-suite/special_variables.i +++ b/Examples/test-suite/special_variables.i @@ -32,7 +32,7 @@ std::string ExceptionVars(double i, double j) { result = $symname(1.0,2.0); // Should expand to ExceptionVars result = $name(3.0,4.0); // Should expand to Space::exceptionvars // above will not compile if the variables are not expanded properly - result = "$action $name $symname $overname $wrapname"; + result = "$action $name $symname $overname $wrapname $parentclassname $parentclasssymname"; %} %inline %{ namespace Space { @@ -49,7 +49,7 @@ std::string exceptionvars(double i, double j) { result = $name(); result = $name(2.0); // above will not compile if the variables are not expanded properly - result = "$action $name $symname $overname $wrapname"; + result = "$action $name $symname $overname $wrapname $parentclassname $parentclasssymname"; // $decl %} @@ -104,3 +104,36 @@ struct DirectorTest { virtual ~DirectorTest() {} }; %} + + +/////////////////////////////////// parentclasssymname parentclassname ///////////////////////////////// +%exception instance_def { + $action + $parentclasssymname_aaa(); + $parentclassname_bbb(); + // above will not compile if the variables are not expanded properly +} +%exception static_def { + $action + $parentclasssymname_aaa(); + $parentclassname_bbb(); + // above will not compile if the variables are not expanded properly +} + +%{ +void DEFNewName_aaa() {} +namespace SpaceNamespace { + void DEF_bbb() {} +} +%} + +%rename(DEFNewName) DEF; +%inline %{ +namespace SpaceNamespace { + struct DEF : ABC { + void instance_def() {} + static void static_def() {} + }; +} +%} + diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 7d7f66eaf..5c81a17cd 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -381,6 +381,21 @@ int emit_action_code(Node *n, String *wrappercode, String *eaction) { Replaceall(tm, "$fulldecl", fulldecl); Delete(fulldecl); } + + Node *parentnode = parentNode(n); + Node *parentclass = (parentnode && Equal(nodeType(parentnode), "class")) ? parentnode : 0; + if (Strstr(tm, "$parentclasssymname")) { + String *parentclasssymname = 0; + if (parentclass) + parentclasssymname = Getattr(parentclass, "sym:name"); + Replaceall(tm, "$parentclasssymname", parentclasssymname ? parentclasssymname : ""); + } + if (Strstr(tm, "$parentclassname")) { + String *parentclassname = 0; + if (parentclass) + parentclassname = Getattr(parentclass, "name"); + Replaceall(tm, "$parentclassname", parentclassname ? parentclassname : ""); + } } Printv(wrappercode, tm, "\n", NIL); Delete(tm);