PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 132 lines | 99 code | 33 blank | 0 comment | 0 complexity | ad15052487490a668cd58d44713ae72f MD5 | raw file
  1%module smart_pointer_extend
  2
  3%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi::CBase::z;	/* Ruby, wrong const name */
  4
  5%inline %{
  6  namespace hi
  7  {
  8    struct CBase
  9    {
 10      static int hello() 
 11      {
 12	return 1;
 13      }
 14      int x;
 15      static const int z = 1;
 16    };
 17
 18    class CDerived : public CBase
 19    {
 20    };
 21
 22    class CPtr
 23    {
 24    public:
 25      CDerived* operator->(void) {return 0;}
 26    };
 27
 28    int get_hello(CPtr ptr)
 29    {
 30      return ptr->hello();
 31    }
 32
 33    class CPtrConst
 34    {
 35    public:
 36      const CDerived* operator->() const {return 0;};
 37    };
 38    
 39  }
 40  
 41%}
 42
 43%extend hi::CBase {
 44  int foo(void) {return 1;};
 45  int bar(void) {return 2;};
 46  int boo(int i) {return i;};
 47}
 48
 49%extend hi::CDerived {
 50  int foo(void) {return 1;};
 51}
 52
 53
 54
 55%extend Foo
 56{
 57  int extension(int i, int j) { return i; }
 58  int extension(int i) { return i; }
 59  int extension() { return 1; }
 60}
 61
 62%inline %{
 63  struct Foo {
 64  };
 65  
 66  class Bar {
 67    Foo *f;
 68  public:
 69    Bar(Foo *f) : f(f) { }
 70    Foo *operator->() {
 71      return f;
 72    }
 73  };
 74%}
 75
 76
 77
 78%extend CFoo
 79{
 80public:
 81    static void StatFun() {};
 82    static void StatFun(int i) {};
 83
 84    static void HoHoHo(int i, int j) {};
 85}
 86
 87%inline %{
 88
 89class CFoo
 90{
 91};
 92
 93class CPtrFoo
 94{
 95public:
 96    CFoo* operator->(void) {return 0;};
 97};
 98
 99%}
100
101
102
103%inline %{
104  namespace foo {
105    
106    class DFoo;
107    
108    class DPtrFoo
109    {
110      DFoo *p;
111    public:
112      DPtrFoo(DFoo *ptr) : p(ptr)
113      {
114      }
115      
116      DFoo* operator->(void) {return p;};
117    };
118    
119    class DFoo
120    {
121    public:
122      void F(void) {};
123    };
124  }
125%}
126
127
128
129%extend foo::DFoo {
130  static int SExt(int i = 1) {return i;};
131  int Ext(int i = 2) {return i;};
132}