import source from 1.3.40
[external/swig.git] / Examples / test-suite / private_assign.i
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 #include <stdlib.h>
8 %}
9
10 %inline %{
11    class Foo {
12    private:
13        Foo &operator=(const Foo &f) {
14            return *this;
15        }
16    public:
17        void bar() { }
18    };
19
20    Foo blah() {
21       return Foo();
22    }
23
24   class Bar : protected Foo
25   {
26   };
27
28 %}
29
30 #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_NEW // operator new
31
32 %inline %{
33   class TROOT {
34   protected:
35      void *operator new(size_t l) { return malloc(sizeof(TROOT)); }
36    
37     int prot_meth() 
38     {
39       return 1;
40     }
41     
42   public:
43     TROOT()
44     {
45     }
46
47     TROOT(const char *name, const char *title, void *initfunc = 0)
48     {
49     }
50   };
51
52   class A : protected TROOT
53   {
54   };
55   
56 %}
57
58 #ifdef SWIGPYTHON
59
60 // This case only works in python
61 %inline %{
62    struct FooBar : Foo 
63    {
64    };
65    
66    FooBar bar;
67    
68 %}
69
70
71 #endif