PageRenderTime 69ms CodeModel.GetById 39ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 45 lines | 35 code | 10 blank | 0 comment | 0 complexity | d0ec88e1b4cc136c538fad42af7b388a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_enum
  2. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo<int>; /* Ruby, wrong class name */
  3. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) foo<double>; /* Ruby, wrong class name */
  4. %inline %{
  5. template<class T> class foo {
  6. public:
  7. enum { FOO, BAR };
  8. };
  9. %}
  10. %template(foo_i) foo<int>;
  11. %template(foo_d) foo<double>;
  12. #ifdef SWIGD
  13. // Workaround for the D module which uses the literal value in the generated wrapper code.
  14. %dconstvalue("3") Manta::ColorSpace<Manta::RGBTraits>::NumComponents;
  15. #endif
  16. %inline {
  17. namespace Manta {
  18. template<typename Traits> class ColorSpace {
  19. public:
  20. typedef typename Traits::ComponentType ComponentType;
  21. enum { NumComponents = Traits::NumComponents};
  22. ComponentType data[NumComponents];
  23. };
  24. }
  25. namespace Manta {
  26. class RGBTraits {
  27. public:
  28. typedef float ComponentType;
  29. enum {NumComponents = 3};
  30. };
  31. }
  32. }
  33. namespace Manta {
  34. %template(Color) ColorSpace<RGBTraits>;
  35. };