PageRenderTime 43ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 51 lines | 38 code | 7 blank | 6 comment | 0 complexity | ed4c8de87e881346ccc5da8607d792dd MD5 | raw file
 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%}