PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/namespace_class.i

#
Swig | 307 lines | 234 code | 71 blank | 2 comment | 0 complexity | cfa3cdede8f572cd6ee94fe7165cfc0d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module namespace_class
  2. %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
  3. #ifdef SWIGD
  4. %warnfilter(SWIGWARN_IGNORE_OPERATOR_LT);
  5. #endif
  6. %inline %{
  7. template<class T> void foobar(T t) {}
  8. namespace test {
  9. template<class T> void barfoo(T t) {}
  10. }
  11. %}
  12. %template(FooBarInt) ::foobar<int>;
  13. %template(BarFooInt) test::barfoo<int>;
  14. %inline %{
  15. template <class C>
  16. struct Bar_T
  17. {
  18. };
  19. namespace test {
  20. enum Hello {
  21. Hi
  22. };
  23. struct Test;
  24. struct Bar {
  25. Hello foo(Hello h) {
  26. return h;
  27. }
  28. };
  29. namespace hola {
  30. struct Bor;
  31. struct Foo;
  32. struct Foobar;
  33. template <class T> struct BarT {
  34. };
  35. template <class T> class FooT;
  36. }
  37. template <class T>
  38. class hola::FooT {
  39. public:
  40. Hello foo(Hello h) {
  41. return h;
  42. }
  43. T bar(T h) {
  44. return h;
  45. }
  46. };
  47. namespace hola {
  48. template <> class FooT<double>;
  49. template <> class FooT<int>;
  50. }
  51. template <>
  52. class hola::FooT<double> {
  53. public:
  54. double moo(double h) {
  55. return h;
  56. }
  57. };
  58. int a;
  59. struct hola::Foo : Bar {
  60. Hello bar(Hello h) {
  61. return h;
  62. }
  63. };
  64. }
  65. struct test::Test {
  66. Hello foo(Hello h) {
  67. return h;
  68. }
  69. };
  70. struct test::hola::Bor {
  71. Hello foo(Hello h) {
  72. return h;
  73. }
  74. };
  75. namespace test {
  76. struct hola::Foobar : Bar {
  77. Hello bar(Hello h) {
  78. return h;
  79. }
  80. };
  81. }
  82. template <>
  83. class test::hola::FooT<int> {
  84. public:
  85. int quack(int h) {
  86. return h;
  87. }
  88. };
  89. %}
  90. namespace test
  91. {
  92. namespace hola {
  93. %template(FooT_i) FooT<int>;
  94. }
  95. %template(FooT_H) hola::FooT<Hello>;
  96. }
  97. %template(FooT_d) ::test::hola::FooT<double>;
  98. %template(BarT_H) test::hola::BarT<test::Hello>;
  99. %inline %{
  100. namespace hi {
  101. namespace hello {
  102. template <class T> struct PooT;
  103. }
  104. namespace hello {
  105. template <class T> struct PooT
  106. {
  107. };
  108. }
  109. }
  110. %}
  111. %template(Poo_i) hi::hello::PooT<int>;
  112. %inline %{
  113. template <class T> struct BooT {
  114. };
  115. namespace test {
  116. typedef ::BooT<Hello> BooT_H;
  117. }
  118. %}
  119. namespace test {
  120. %template(BooT_H) ::BooT<Hello>;
  121. }
  122. %template(BooT_i) ::BooT<int>;
  123. %inline %{
  124. namespace jafar {
  125. namespace jmath {
  126. class EulerT3D {
  127. public:
  128. static void hello(){}
  129. template<class VecFrame, class Vec, class VecRes>
  130. static void toFrame(const VecFrame& frame_, const Vec&v_,const VecRes& vRes){}
  131. template<class T>
  132. void operator ()(T& x){}
  133. template<class T>
  134. void operator < (T& x){}
  135. template<class T>
  136. operator Bar_T<T> () {}
  137. };
  138. }
  139. }
  140. %}
  141. %template(toFrame) jafar::jmath::EulerT3D::toFrame<int,int,int>;
  142. %template(callint) jafar::jmath::EulerT3D::operator()<int>;
  143. %template(lessint) jafar::jmath::EulerT3D::operator < <int>;
  144. %template(callfooi) jafar::jmath::EulerT3D::operator() <test::hola::FooT<int> >;
  145. %template(lessfooi) jafar::jmath::EulerT3D::operator < < test::hola::FooT<int> >;
  146. %inline %{
  147. namespace {
  148. /* the unnamed namespace is 'private', so, the following
  149. declarations shouldn't be wrapped */
  150. class Private1
  151. {
  152. };
  153. }
  154. namespace a
  155. {
  156. namespace
  157. {
  158. class Private2
  159. {
  160. };
  161. }
  162. }
  163. %}
  164. // %copyctor doesn't work with nested class workaround
  165. %nocopyctor;
  166. %inline %{
  167. class Ala {
  168. public :
  169. Ala() {}
  170. class Ola {
  171. public:
  172. Ola() {}
  173. void eek() {}
  174. };
  175. template <class T>
  176. static void hi()
  177. {
  178. }
  179. };
  180. %}
  181. %rename(Ala__Ola) Ala::Ola;
  182. class Ala::Ola {
  183. public:
  184. Ola() {}
  185. void eek() {}
  186. };
  187. %template(hi) Ala::hi<int>;
  188. %extend jafar::jmath::EulerT3D
  189. {
  190. }
  191. %rename(FLACFile) TagLib::FLAC::File;
  192. %inline {
  193. namespace TagLib
  194. {
  195. class File {
  196. public:
  197. File() {}
  198. };
  199. class AudioProperties {
  200. };
  201. class AudioPropertiesFile {
  202. public:
  203. typedef TagLib::File File;
  204. };
  205. namespace FLAC
  206. {
  207. class File;
  208. class Properties : public AudioProperties {
  209. public:
  210. Properties(File *) {}
  211. };
  212. class PropertiesFile : public AudioPropertiesFile {
  213. public:
  214. PropertiesFile(File * = 0) {}
  215. };
  216. namespace bar {
  217. class PropertiesFree : public AudioProperties {
  218. public:
  219. PropertiesFree(File *) {}
  220. };
  221. }
  222. class FooFilePrivate : private PropertiesFile {
  223. public:
  224. FooFilePrivate(File *) {}
  225. };
  226. class FooFile : public PropertiesFile {
  227. public:
  228. FooFile(File *) {}
  229. };
  230. class File {
  231. public:
  232. File() {}
  233. };
  234. }
  235. }
  236. }