PageRenderTime 24ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 53 lines | 42 code | 11 blank | 0 comment | 0 complexity | c4308a519f55358a130b6c676132df92 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Test the nspace feature and %extend
  2. %module nspace_extend
  3. // nspace feature only supported by these languages
  4. #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
  5. #if defined(SWIGJAVA)
  6. SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
  7. #endif
  8. %nspace;
  9. %extend Outer::Inner1::Color {
  10. Color() { return new Outer::Inner1::Color(); }
  11. virtual ~Color() { delete $self; }
  12. static Color* create() { return new Outer::Inner1::Color(); }
  13. Color(const Color& other) { return new Outer::Inner1::Color(other); }
  14. void colorInstanceMethod(double d) {}
  15. static void colorStaticMethod(double d) {}
  16. }
  17. %inline %{
  18. namespace Outer {
  19. namespace Inner1 {
  20. struct Color {
  21. };
  22. }
  23. namespace Inner2 {
  24. struct Color {
  25. };
  26. }
  27. }
  28. %}
  29. %extend Outer::Inner2::Color {
  30. Color() { return new Outer::Inner2::Color(); }
  31. ~Color() { delete $self; }
  32. static Color* create() { return new Outer::Inner2::Color(); }
  33. Color(const Color& other) { return new Outer::Inner2::Color(other); }
  34. void colorInstanceMethod(double d) {}
  35. static void colorStaticMethod(double d) {}
  36. void colors(const Inner1::Color& col1a,
  37. const Outer::Inner1::Color& col1b,
  38. const Color &col2a,
  39. const Inner2::Color& col2b,
  40. const Outer::Inner2::Color& col2c) {}
  41. }
  42. #endif