PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Examples/test-suite/template_int_const.i

#
Swig | 50 lines | 43 code | 7 blank | 0 comment | 0 complexity | a537ac5174cf54e7c8a19067331a3e4d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_int_const
  2. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) interface_traits; /* Ruby, wrong class name */
  3. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) module_traits; /* Ruby, wrong class name */
  4. %inline %{
  5. enum Polarization { UnaryPolarization, BinaryPolarization };
  6. struct interface_traits
  7. {
  8. static const Polarization polarization = UnaryPolarization;
  9. };
  10. template <Polarization P>
  11. struct Interface
  12. {
  13. };
  14. typedef unsigned int Category;
  15. struct module_traits
  16. {
  17. static const Category category = 1;
  18. };
  19. template <Category C>
  20. struct Module
  21. {
  22. };
  23. %}
  24. %template(Interface_UP) Interface<UnaryPolarization>;
  25. %template(Module_1) Module<1>;
  26. %inline %{
  27. struct ExtInterface1 :
  28. Interface<UnaryPolarization> // works
  29. {
  30. };
  31. struct ExtInterface2 :
  32. Interface<interface_traits::polarization> // doesn't work
  33. {
  34. };
  35. struct ExtModule1 :
  36. Module<1> // works
  37. {
  38. };
  39. struct ExtModule2 :
  40. Module<module_traits::category> // doesn't work
  41. {
  42. };
  43. %}