~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Examples/test-suite/director_stl.i

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-11-15 14:00:28 UTC
  • mfrom: (1.2.9 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091115140028-me7amr2rie8zz1xn
Tags: 1.3.40-2ubuntu1
* Merge from Debian testing (LP: #356529), remaining changes:
  - Drop libchicken-dev from the build-depends (it's in universe)
  - Remove Pike from package description and from configure flags
  - drop "--without-mzscheme", we don't have it in our build-depends
  - use php-config5
  - Clean Runtime/ as well.
  - debian/rules (clean): Remove Lib/ocaml/swigp4.ml.
* debian/rules: Remove hardcoded python version.
* Remove upper limit for python from Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
{
 
36
class Foo {
 
37
public:
 
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
}