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

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

#
Swig | 47 lines | 37 code | 10 blank | 0 comment | 0 complexity | b231ee23be0ccfc017ef374f19a705e2 MD5 | raw file
 1%module disown
 2
 3%{
 4#include <iostream>
 5%}
 6
 7#pragma SWIG nowarn=SWIGWARN_TYPEMAP_APPLY_UNDEF
 8
 9%apply SWIGTYPE *DISOWN { A *disown };
10
11%inline {
12  struct A
13  {
14    ~A()
15    {
16      // std::cout <<"delete A" << std::endl;
17    }
18    
19    
20  };
21  
22  class B
23  {
24    A *_a;
25  public:
26    B() : _a(0)
27    {
28    }
29    
30    ~B()
31    {
32      if (_a) {
33	// std::cout <<"delete A from B" << std::endl;	
34	delete _a;
35      }
36      // std::cout <<"delete B" << std::endl;      
37    }
38
39    int acquire(A *disown) 
40    {
41      // std::cout <<"acquire A" << std::endl;      
42      _a = disown;    
43      return 5;      
44    }
45    
46  };
47}