Debian Codegraph @

examples/g/modulegen.py

raw symbols SCIP
1 #! /usr/bin/env python
2
3 import sys
4
5 import pybindgen
6 from pybindgen import ReturnValue, Parameter, Module, Function, FileCodeSink
7
8 def my_module_gen(out_file):
9 mod = Module('g')
10 mod.add_include('"g.h"')
11
12 mod.add_function('GDoA', None, [])
13 G = mod.add_cpp_namespace("G")
14 G.add_function('GDoB', None, [])
15 GInner = G.add_cpp_namespace("GInner")
16 GInner.add_function('GDoC', None, [])
17
18 G.add_include('<fstream>')
19
20 ofstream = G.add_class('ofstream', foreign_cpp_namespace='::std')
21 ofstream.add_enum('openmode', [
22 ('app', 'std::ios_base::app'),
23 ('ate', 'std::ios_base::ate'),
24 ('binary', 'std::ios_base::binary'),
25 ('in', 'std::ios_base::in'),
26 ('out', 'std::ios_base::out'),
27 ('trunc', 'std::ios_base::trunc'),
28 ])
29 ofstream.add_constructor([Parameter.new("const char *", 'filename'),
30 Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")])
31 ofstream.add_method('close', None, [])
32
33 mod.generate(FileCodeSink(out_file))
34
35 if __name__ == '__main__':
36 my_module_gen(sys.stdout)