Debian Codegraph @

examples/boost_shared_ptr/modulegen.py

raw symbols SCIP
1 #! /usr/bin/env python
2
3 import sys, os
4 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),
5 '..', '..'))
6
7 #import pybindgen
8 #import pybindgen.utils
9 #from pybindgen.typehandlers import base as typehandlers
10 from pybindgen import Module, FileCodeSink, param, retval
11 #from pybindgen import CppMethod, CppConstructor, CppClass, Enum
12 #from pybindgen.function import CustomFunctionWrapper
13 #from pybindgen.cppmethod import CustomCppMethodWrapper
14 from pybindgen import cppclass
15 from pybindgen.typehandlers.smart_ptr import BoostSharedPtr
16
17 #from pybindgen import param, retval
18
19 import pybindgen.settings
20 pybindgen.settings.deprecated_virtuals = False
21
22
23 def my_module_gen(out_file):
24
25 mod = Module('bsp')
26
27 mod.add_include ('"bsp.h"')
28
29 Foo = mod.add_class('Foo', memory_policy=BoostSharedPtr('::Foo'))
30
31 Foo.add_constructor([param('std::string', 'datum')])
32 Foo.add_constructor([])
33 Foo.add_method('get_datum', retval('const std::string'), [])
34 Foo.add_method('set_datum', None, [param('const std::string', 'datum')])
35
36
37 mod.add_function('function_that_takes_foo', None,
38 [param('boost::shared_ptr<Foo>', 'foo')])
39
40 mod.add_function('function_that_returns_foo', retval('boost::shared_ptr<Foo>'), [])
41
42 ## ---- finally, generate the whole thing ----
43 mod.generate(FileCodeSink(out_file))
44
45
46 if __name__ == '__main__':
47 my_module_gen(sys.stdout)
48