1 %module(directors="1") special_variables
2 
3 %include <std_string.i>
4 
5 // will fail to compile if $symname is not expanded
6 %typemap(argout) int i {
7   $symname(99);
8 }
9 
10 %{
11 #define KKK_testmethod testmethod
12 #define KKK_teststaticmethod KKK::teststaticmethod
13 %}
14 
15 %inline %{
testmethod(int i)16 void testmethod(int i) {}
17 struct KKK {
testmethodKKK18   void testmethod(int i) {}
teststaticmethodKKK19   static void teststaticmethod(int i) {}
20 };
21 %}
22 
23 %{
ExceptionVars(double i,double j)24 std::string ExceptionVars(double i, double j) {
25   return "a1";
26 }
27 %}
28 
29 %rename(ExceptionVars) Space::exceptionvars;
30 %exception Space::exceptionvars %{
31   $action
32   result = $symname(1.0,2.0); // Should expand to ExceptionVars
33   result = $name(3.0,4.0); // Should expand to Space::exceptionvars
34   // above will not compile if the variables are not expanded properly
35   result = "$action  $name  $symname  $overname $wrapname $parentclassname $parentclasssymname";
36 %}
37 %inline %{
38 namespace Space {
exceptionvars(double i,double j)39 std::string exceptionvars(double i, double j) {
40   return "b2";
41 }
42 }
43 %}
44 
45 
46 %exception Space::overloadedmethod %{
47   $action
48   result = Space::$symname(1.0);
49   result = $name();
50   result = $name(2.0);
51   // above will not compile if the variables are not expanded properly
52   result = "$action  $name  $symname  $overname $wrapname $parentclassname $parentclasssymname";
53   // $decl
54 %}
55 
56 %inline %{
57 namespace Space {
overloadedmethod(double j)58   std::string overloadedmethod(double j) {
59     return "c3";
60   }
overloadedmethod()61   std::string overloadedmethod() {
62     return "d4";
63   }
64 }
65 std::string declaration;
66 %}
67 
68 %exception {
69   $action
70   declaration = "$fulldecl $decl";
71 }
72 
73 %inline %{
74 namespace SpaceNamespace {
75   struct ABC {
ABCABC76     ABC(int a, double b) {}
ABCABC77     ABC() {}
staticmethodABC78     static short * staticmethod(int x, bool b) { return 0; }
79     short * instancemethod(int x, bool b = false) { return 0; }
constmethodABC80     short * constmethod(int x) const { return 0; }
81   };
82   template<typename T> struct Template {
tmethodTemplate83     std::string tmethod(T t) { return ""; }
84   };
globtemplate(Template<ABC> t)85   void globtemplate(Template<ABC> t) {}
86 }
87 %}
88 
89 %template(TemplateABC) SpaceNamespace::Template<SpaceNamespace::ABC>;
90 
91 /////////////////////////////////// directors /////////////////////////////////
92 %{
DirectorTest_director_testmethod(int i)93 void DirectorTest_director_testmethod(int i) {}
DirectorTest_director_testmethodSwigExplicitDirectorTest(int i)94 void DirectorTest_director_testmethodSwigExplicitDirectorTest(int i) {}
95 %}
96 %typemap(directorargout) int i {
97   $symname(99);
98 }
99 %feature("director") DirectorTest;
100 %inline %{
director_testmethod(int i)101 void director_testmethod(int i) {}
102 struct DirectorTest {
director_testmethodDirectorTest103   virtual void director_testmethod(int i) {}
~DirectorTestDirectorTest104   virtual ~DirectorTest() {}
105 };
106 %}
107 
108 
109 /////////////////////////////////// parentclasssymname parentclassname /////////////////////////////////
110 %exception instance_def {
111   $action
112   $parentclasssymname_aaa();
113   $parentclassname_bbb();
114   // above will not compile if the variables are not expanded properly
115 }
116 %exception static_def {
117   $action
118   $parentclasssymname_aaa();
119   $parentclassname_bbb();
120   // above will not compile if the variables are not expanded properly
121 }
122 
123 %{
DEFNewName_aaa()124 void DEFNewName_aaa() {}
125 namespace SpaceNamespace {
DEF_bbb()126   void DEF_bbb() {}
127 }
128 %}
129 
130 %rename(DEFNewName) DEF;
131 %inline %{
132 namespace SpaceNamespace {
133   struct DEF : ABC {
instance_defDEF134     void instance_def() {}
static_defDEF135     static void static_def() {}
136   };
137 }
138 %}
139 
140