| 1 |
|
| 2 |
|
| 3 |
import sys, os |
| 4 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 5 |
'..', '..')) |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
from pybindgen import Module, FileCodeSink, param, retval |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
from pybindgen import cppclass |
| 15 |
from pybindgen.typehandlers.smart_ptr import BoostSharedPtr |
| 16 |
|
| 17 |
|
| 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 |
|
| 43 |
mod.generate(FileCodeSink(out_file)) |
| 44 |
|
| 45 |
|
| 46 |
if __name__ == '__main__': |
| 47 |
my_module_gen(sys.stdout) |
| 48 |
|