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

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

#
Swig | 80 lines | 59 code | 21 blank | 0 comment | 0 complexity | bdec83698e43115377fe37ef250d5c94 MD5 | raw file
 1%module(directors="1") director_stl
 2#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
 3
 4%include "std_string.i"
 5%include "std_pair.i"
 6%include "std_vector.i"
 7
 8#ifndef SWIG_STD_DEFAULT_INSTANTIATION
 9%template() std::vector<double>;
10%template() std::vector<int>;
11%template() std::vector<std::string>;
12%template() std::pair<std::string, int>;
13%template() std::pair<int,double>;
14%template() std::pair<double,int>;
15#endif
16
17%feature("director") Foo;
18
19%feature("director:except") {
20#ifndef SWIGPHP
21  if ($error != NULL) {
22#else
23  if ($error == FAILURE) {
24#endif
25    throw Swig::DirectorMethodException();
26  }
27}
28
29%exception {
30  try { $action }
31  catch (...) { SWIG_fail; }
32}
33
34%inline 
35{
36class Foo {
37public:
38  virtual ~Foo() {}
39
40  virtual std::string& bar(std::string& s) 
41  {
42    return s;
43  }
44  
45
46  virtual std::string ping(std::string s) = 0;
47  virtual std::string pong(const std::string& s) 
48  { return std::string("Foo::pong:") + s + ":" + ping(s); }
49
50  std::string tping(std::string s) { return ping(s); }
51  std::string tpong(const std::string& s) { return pong(s); }
52  
53  virtual std::pair<double, int>
54  pident(const std::pair<double, int>& p) { return p; }
55
56  virtual std::vector<int>
57  vident(const std::vector<int>& p) { return p; }
58
59  virtual std::vector<int>
60  vsecond(const std::vector<int>& p, const std::vector<int>& s) { return s; }    
61
62  std::pair<double, int>
63  tpident(const std::pair<double, int>& p) { return pident(p); }
64
65  std::vector<int>
66  tvident(const std::vector<int>& p) { return vident(p); }
67
68  virtual std::vector<int>
69  tvsecond(const std::vector<int>& p, const std::vector<int>& s) { return vsecond(p,s); }
70
71
72  virtual std::vector<std::string>
73  vidents(const std::vector<std::string>& p) { return p; }
74
75  std::vector<std::string>
76  tvidents(const std::vector<std::string>& p) { return vidents(p); }
77  
78};
79
80}