summaryrefslogtreecommitdiff
path: root/Examples/test-suite/template_int_const.i
blob: e69a53c4ff87d5cbf59071222a55b215124a77a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
%module template_int_const

%warnfilter(SWIGWARN_RUBY_WRONG_NAME) interface_traits;	/* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) module_traits;		/* Ruby, wrong class name */

%inline %{ 
  enum Polarization { UnaryPolarization, BinaryPolarization }; 
  struct interface_traits 
  { 
    static const Polarization polarization = UnaryPolarization; 
  }; 
  template <Polarization P> 
    struct Interface_
    { 
    }; 
 
  typedef unsigned int Category; 
  struct module_traits 
  { 
    static const Category category = 1; 
  }; 
  
  template <Category C> 
    struct Module 
    { 
    }; 
%} 
 
%template(Interface_UP) Interface_<UnaryPolarization>; 
%template(Module_1) Module<1>; 
 
%inline %{ 
  struct ExtInterface1 :  
    Interface_<UnaryPolarization> // works 
  { 
  }; 
  struct ExtInterface2 : 
    Interface_<interface_traits::polarization>  // doesn't work 
  { 
  }; 
  struct ExtModule1 : 
    Module<1>         // works 
  { 
  }; 
  struct ExtModule2 : 
    Module<module_traits::category>    // doesn't work 
  { 
  }; 
%}