| 1 |
|
| 2 |
|
| 3 |
import sys |
| 4 |
|
| 5 |
import pybindgen |
| 6 |
from pybindgen import ReturnValue, Parameter, Module, Function, FileCodeSink |
| 7 |
from pybindgen import CppMethod, CppConstructor, CppClass, Enum |
| 8 |
from pybindgen import cppclass |
| 9 |
|
| 10 |
def my_module_gen(out_file): |
| 11 |
|
| 12 |
mod = Module('d') |
| 13 |
mod.add_include('"d.h"') |
| 14 |
|
| 15 |
D = mod.add_class('D', memory_policy=cppclass.FreeFunctionPolicy('DDestroy')) |
| 16 |
D.add_instance_attribute('d', ReturnValue.new('bool')) |
| 17 |
D.add_function_as_constructor("DCreate", ReturnValue.new("D*", caller_owns_return=True), []) |
| 18 |
mod.add_function('DDoA', None, [Parameter.new('D*', 'd', transfer_ownership=False)]) |
| 19 |
mod.add_function('DDoB', None, [Parameter.new('D&', 'd', direction=Parameter.DIRECTION_IN)]) |
| 20 |
mod.add_function('DDoC', None, [Parameter.new('const D&', 'd', |
| 21 |
direction=Parameter.DIRECTION_IN)]) |
| 22 |
|
| 23 |
|
| 24 |
mod.generate(FileCodeSink(out_file) ) |
| 25 |
|
| 26 |
if __name__ == '__main__': |
| 27 |
my_module_gen(sys.stdout) |