Objects that receive generated C/C++ code lines, reindents them, and writes them to a file, memory, or another code sink object.
Bases: object
Abstract base class for code sinks
Constructor
>>> sink = MemoryCodeSink()
>>> sink.writeln("foo();")
>>> sink.writeln("if (true) {")
>>> sink.indent()
>>> sink.writeln("bar();")
>>> sink.unindent()
>>> sink.writeln("zbr();")
>>> print sink.flush().rstrip()
foo();
if (true) {
bar();
zbr();
>>> sink = MemoryCodeSink()
>>> sink.writeln("foo();")
>>> sink.writeln()
>>> sink.writeln("bar();")
>>> print len(sink.flush().split("\n"))
4
Add a certain ammount of indentation to all lines written from now on and until unindent() is called
Revert indentation level to the value before last indent() call
Write one or more lines of code
Bases: pybindgen.typehandlers.codesink.CodeSink
A code sink that writes to a file-like object
Parameters: | file – a file like object |
---|
Write one or more lines of code
Bases: pybindgen.typehandlers.codesink.CodeSink
A code sink that keeps the code in memory, and can later flush the code to another code sink
Constructor
Flushes the code and returns the formatted output as a return value string
Flushes code to another code sink :param sink: another CodeSink instance
Write one or more lines of code
Bases: pybindgen.typehandlers.codesink.CodeSink
A code sink that discards all content. Useful to ‘test’ if code generation would work without actually generating anything.
Constructor
Flushes the code and returns the formatted output as a return value string
Flushes code to another code sink :param sink: another CodeSink instance
Write one or more lines of code