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

# · Swig · 50 lines · 43 code · 7 blank · 0 comment · 0 complexity · 05225d5018d635e8a087d07fb2b7462e MD5 · raw file

  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. %}