blob: e452e5adcff631b414abce22cdd402147f0ab189 (
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
|
%module(directors="1") director_exception
%{
#include <string>
class Foo {
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
};
Foo *launder(Foo *f) {
return f;
}
// define dummy director exception classes to prevent spurious errors
// in target languages that do not support directors.
#ifndef SWIG_DIRECTORS
class SWIG_DIRECTOR_EXCEPTION {};
class SWIG_DIRECTOR_METHOD_EXCEPTION: public SWIG_DIRECTOR_EXCEPTION {};
#ifndef SWIG_fail
#define SWIG_fail
#endif
#endif
%}
%include "typemaps.i"
%include "exception.i"
%include "std_string.i"
%feature("director:except") {
if ($error != NULL) {
throw SWIG_DIRECTOR_METHOD_EXCEPTION();
}
}
%exception {
try { $action }
catch (SWIG_DIRECTOR_EXCEPTION &e) { SWIG_fail; }
}
%feature("director") Foo;
class Foo {
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
};
Foo *launder(Foo *f);
|