summaryrefslogtreecommitdiff
path: root/Examples/test-suite/director_smartptr.i
blob: 9d0be80f0faf5f382c0d271e7460b3069d73ef48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%module(directors="1") director_smartptr

#ifdef SWIGJAVA
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
#endif

%{
#include <boost/shared_ptr.hpp>
#include <string>

class FooBar {
public:
  FooBar() {}
  FooBar(const FooBar&) {}
  virtual ~FooBar() {}

  std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
};

class Foo {
public:
  virtual ~Foo() {}
  virtual std::string ping() { return "Foo::ping()"; }
  virtual std::string pong() { return "Foo::pong();" + ping(); }
  virtual std::string upcall(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
  virtual Foo makeFoo() { return Foo(); }
  virtual FooBar makeFooBar() { return FooBar(); }

  static std::string callPong(Foo &foo) { return foo.pong(); }
  static std::string callUpcall(Foo &foo, FooBar* fooBarPtr) { return foo.upcall(fooBarPtr); }
  static Foo* get_self(Foo *self_) {return self_;}
};

%}

#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)

%include <std_string.i>
%include <boost_shared_ptr.i>

%shared_ptr(Foo)

%feature("director") Foo;

class FooBar {
public:
  FooBar();
  FooBar(const FooBar&);
  virtual ~FooBar();
  
  std::string FooBarDo();
  
};

class Foo
{
public:
  virtual ~Foo();
  virtual std::string ping();
  virtual std::string pong();
  virtual std::string upcall(FooBar* fooBarPtr);
  virtual Foo makeFoo();
  virtual FooBar makeFooBar();
 
  static std::string callPong(Foo &foo);
  static std::string callUpcall(Foo &foo, FooBar* fooBarPtr);
  static Foo* get_self(Foo *self_);
};

#endif