PageRenderTime 34ms CodeModel.GetById 20ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/newobject1.i

#
Swig | 51 lines | 38 code | 7 blank | 6 comment | 0 complexity | ed4c8de87e881346ccc5da8607d792dd MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1/**
 2 * The purpose of this test is to confirm that a language module
 3 * correctly handles the case when C++ class member functions (of both
 4 * the static and non-static persuasion) have been tagged with the
 5 * %newobject directive.
 6 */
 7
 8%module newobject1
 9
10%newobject Foo::makeFoo();
11%newobject Foo::makeMore();
12
13%inline %{
14class Foo
15{
16private:
17    Foo(const Foo&);
18    Foo& operator=(const Foo&);
19private:
20    static int m_fooCount;
21protected:
22    Foo() {
23        m_fooCount++;
24    }
25public:
26    // Factory function (static)
27    static Foo *makeFoo() {
28        return new Foo;
29    }
30    
31    // Factory function (regular)
32    Foo *makeMore() {
33        return new Foo;
34    }
35    
36    // Return the number of instances
37    static int fooCount() {
38        return m_fooCount;
39    }
40    
41    // Destructor
42    ~Foo() {
43        m_fooCount--;
44    }
45};
46%}
47
48%{
49// Static member initialization (not wrapped)
50int Foo::m_fooCount = 0;
51%}