1 %module(directors="1") director_property 2 3 %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; 4 5 #ifdef SWIGOCAML 6 %warnfilter(SWIGWARN_PARSE_KEYWORD) method; 7 #endif 8 9 %{ 10 #include <string> 11 12 class Foo { 13 private: 14 std::string a_; 15 public: ~Foo()16 virtual ~Foo() {} ping()17 virtual std::string ping() { return "Foo::ping()"; } pong()18 virtual std::string pong() { return "Foo::pong();" + ping(); } getA()19 virtual std::string getA() { return this->a_; } setA(std::string a)20 virtual void setA(std::string a) { this->a_ = a; } 21 get_self(Foo * slf)22 static Foo* get_self(Foo *slf) {return slf;} 23 24 }; 25 26 %} 27 28 %include <std_string.i> 29 30 %feature("director") Foo; 31 32 33 class Foo { 34 public: 35 virtual ~Foo(); 36 virtual std::string ping(); 37 virtual std::string pong(); 38 virtual std::string getA(); 39 virtual void setA(std::string a); 40 41 static Foo* get_self(Foo *slf); 42 43 }; 44 45 %{ 46 #include <complex> 47 %} 48 %feature("director") A; 49 50 // basic renaming 51 %rename(rg) A::gg; 52 %feature("nodirector") hi::A1::gg; 53 54 %inline %{ 55 56 struct A{ 57 A(std::complex<int> i, double d=0.0) {} 58 A(int i, bool j=false) {} ~AA59 virtual ~A() {} 60 61 virtual int f(int i=0) {return i;} 62 virtual int gg(int i=0) {return i;} 63 }; 64 65 namespace hi { 66 67 struct A1 : public A { AA168 A1(std::complex<int> i, double d=0.0) : A(i, d) {} AA169 A1(int i, bool j=false) : A(i, j) {} 70 71 virtual int ff(int i = 0) {return i;} 72 }; 73 } 74 75 76 %} 77 78 79 %feature("director") MyClass; 80 81 %inline %{ 82 83 typedef void VoidType; 84 85 struct Bar 86 { 87 int x; xBar88 Bar(int _x = 0) : x(_x) 89 { 90 } 91 }; 92 93 94 95 class MyClass { 96 public: 97 MyClass(int a = 0) 98 { 99 } 100 method(VoidType *)101 virtual void method(VoidType *) 102 { 103 } 104 ~MyClass()105 virtual ~MyClass() 106 { 107 } 108 vmethod(Bar b)109 virtual Bar vmethod(Bar b) 110 { 111 b.x += 13; 112 return b; 113 } 114 pmethod(Bar * b)115 virtual Bar* pmethod(Bar *b) 116 { 117 b->x += 12; 118 return b; 119 } 120 cmethod(const Bar & b)121 Bar cmethod(const Bar &b) 122 { 123 return vmethod(b); 124 } 125 get_self(MyClass * c)126 static MyClass *get_self(MyClass *c) 127 { 128 return c; 129 } 130 call_pmethod(MyClass * myclass,Bar * b)131 static Bar * call_pmethod(MyClass *myclass, Bar *b) { 132 return myclass->pmethod(b); 133 } 134 }; 135 136 template<class T> 137 class MyClassT { 138 public: 139 MyClassT(int a = 0) 140 { 141 } 142 method(VoidType *)143 virtual void method(VoidType *) 144 { 145 } 146 ~MyClassT()147 virtual ~MyClassT() 148 { 149 } 150 151 }; 152 153 %} 154 155 %template(MyClassT_i) MyClassT<int>; 156