-
Notifications
You must be signed in to change notification settings - Fork 2
/
foo_bar.i
58 lines (47 loc) · 1.27 KB
/
foo_bar.i
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
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
%module foo_bar
%inline %{
struct FooBar
{
int _foo;
float _bar;
int foo(void) const
{
return _foo;
}
float bar(void) const
{
return _bar;
}
};
%}
%{
bool operator==(const FooBar &lhs, const FooBar &rhs)
{
return (lhs.foo() == rhs.foo()) && (lhs.bar() == rhs.bar());
}
%}
////////////////////////////////////////////////////////////////////////
// This is what a typical registry looks like
////////////////////////////////////////////////////////////////////////
%include <PMC/Registry.i> //include the registration macros
//
// Export swig defintions for converting this object:
// - FooBar is the C++ type as defined in your header files
// - swig_foo_bar is the name of the swig functions DECL_ creates
//
DECL_PMC_SWIG_TYPE(FooBar, swig_foo_bar)
//
// import the python module
// This import statement is needed before the registration step
// The import statement is how it would look in your client code
//
%pythoncode %{
from foo_bar import *
%}
//
// Register the swigged type into PMC:
// - swig_foo_bar is the name of the swig functions made by DECL_
// - FooBar is the name of the python class for your object
//
REG_PMC_SWIG_TYPE(swig_foo_bar, FooBar)