Two additional special variable are expanded in %exception - $parentname
and $parentsymname git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13870 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
77d9ad5354
commit
2598a1daf2
5 changed files with 68 additions and 5 deletions
|
|
@ -9,6 +9,11 @@ Version 2.0.9 (in progress)
|
||||||
indicate the size of the 'int' type in Go. This is because the
|
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.
|
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
|
2012-09-14: wsfulton
|
||||||
Add new warning if the empty template instantiation is used as a base class, for example:
|
Add new warning if the empty template instantiation is used as a base class, for example:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,16 @@ variables are replaced with.
|
||||||
<td>The fully qualified C/C++ declaration of the method being wrapped including the return type</td>
|
<td>The fully qualified C/C++ declaration of the method being wrapped including the return type</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>$parentname</td>
|
||||||
|
<td>The parent class name (if any) for a method.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>$parentsymname</td>
|
||||||
|
<td>The target language parent class name (if any) for a method.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ public class special_variables_runme {
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
verify(special_variables.ExceptionVars(1.0, 2.0),
|
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(),
|
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),
|
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);
|
ABC a = new ABC(0, 0.0);
|
||||||
verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)");
|
verify(special_variables.getDeclaration(), "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)");
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ std::string ExceptionVars(double i, double j) {
|
||||||
result = $symname(1.0,2.0); // Should expand to ExceptionVars
|
result = $symname(1.0,2.0); // Should expand to ExceptionVars
|
||||||
result = $name(3.0,4.0); // Should expand to Space::exceptionvars
|
result = $name(3.0,4.0); // Should expand to Space::exceptionvars
|
||||||
// above will not compile if the variables are not expanded properly
|
// 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 %{
|
%inline %{
|
||||||
namespace Space {
|
namespace Space {
|
||||||
|
|
@ -49,7 +49,7 @@ std::string exceptionvars(double i, double j) {
|
||||||
result = $name();
|
result = $name();
|
||||||
result = $name(2.0);
|
result = $name(2.0);
|
||||||
// above will not compile if the variables are not expanded properly
|
// 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
|
// $decl
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -104,3 +104,36 @@ struct DirectorTest {
|
||||||
virtual ~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() {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,21 @@ int emit_action_code(Node *n, String *wrappercode, String *eaction) {
|
||||||
Replaceall(tm, "$fulldecl", fulldecl);
|
Replaceall(tm, "$fulldecl", fulldecl);
|
||||||
Delete(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);
|
Printv(wrappercode, tm, "\n", NIL);
|
||||||
Delete(tm);
|
Delete(tm);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue