PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

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

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