Debian Codegraph @

examples/std_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
16 #from pybindgen import param, retval
17
18 import pybindgen.settings
19 pybindgen.settings.deprecated_virtuals = False
20
21
22 def my_module_gen(out_file):
23
24 mod = Module('sp')
25
26 mod.add_include ('"sp.h"')
27
28 Foo = mod.add_class('Foo', memory_policy=cppclass.SharedPtr('::Foo'))
29
30 Foo.add_constructor([param('std::string', 'datum')])
31 Foo.add_constructor([])
32 Foo.add_method('get_datum', retval('const std::string'), [])
33 Foo.add_method('set_datum', None, [param('const std::string', 'datum')])
34
35
36 mod.add_function('function_that_takes_foo', None,
37 [param('std::shared_ptr<Foo>', 'foo')])
38
39 mod.add_function('function_that_returns_foo', retval('std::shared_ptr<Foo>'), [])
40
41 ## ---- finally, generate the whole thing ----
42 mod.generate(FileCodeSink(out_file))
43
44
45 if __name__ == '__main__':
46 my_module_gen(sys.stdout)
47