PageRenderTime 6ms CodeModel.GetById 5ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Examples/test-suite/private_assign.i

#
Swig | 68 lines | 50 code | 18 blank | 0 comment | 0 complexity | 8c77808ee791a95cc75f9eeb1287d9e8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1// A class with a private assignment operator.
 2// This is rare, but sometimes used with singletons and
 3// objects that have complicated state.
 4
 5%module private_assign
 6
 7%inline %{
 8   class Foo {
 9   private:
10       Foo &operator=(const Foo &f) {
11           return *this;
12       }
13   public:
14       void bar() { }
15   };
16
17   Foo blah() {
18      return Foo();
19   }
20
21  class Bar : protected Foo
22  {
23  };
24
25%}
26
27#pragma SWIG nowarn=350 // operator new
28
29%inline %{
30  class TROOT {
31  protected:
32     void *operator new(size_t l) { return malloc(sizeof(TROOT)); }
33   
34    int prot_meth() 
35    {
36      return 1;
37    }
38    
39  public:
40    TROOT()
41    {
42    }
43
44    TROOT(const char *name, const char *title, void *initfunc = 0)
45    {
46    }
47  };
48
49  class A : protected TROOT
50  {
51  };
52  
53%}
54
55#ifdef SWIGPYTHON
56
57// This case only works in python
58%inline %{
59   struct FooBar : Foo 
60   {
61   };
62   
63   FooBar bar;
64   
65%}
66
67
68#endif