Example code for an external emitter for Python bindings. More...
#include "../fbdoc_options.bi"
Go to the source code of this file.
Macros | |
#define | NEW_ENTRY /* Code(NL & NL & "# " & MID(.Fnam, INSTRREV(.Fnam, SLASH) + 1) & ": " & .LineNo) */ |
Macro to place a comment in to the output (file name and line number) More... | |
Functions | |
SUB | genNLiteral (BYREF_AS_STRING T) |
Transform number literals. More... | |
FUNCTION_AS_STRING | genCType (BYVAL_AS_Parser_PTR P) |
Transform a FB type in to a ctype. More... | |
SUB_CDECL | py_entryListPara (BYVAL_AS_Parser_PTR P) |
Emitter to extract the types of a parameter list. More... | |
SUB_CDECL | py_emitEnumNames (BYVAL_AS_Parser_PTR P) |
Emitter to generate a line for a ENUM block entry. More... | |
SUB_CDECL | py_emitBlockNames (BYVAL_AS_Parser_PTR P) |
Emitter to generate a line for a TYPE / UNION block entry. More... | |
SUB_CDECL | py_function (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is on top of a function body. More... | |
SUB_CDECL | py_declare (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at a variable declaration. More... | |
SUB_CDECL | py_enum (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at the start of a ENUM block. More... | |
SUB_CDECL | py_union (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at the start of a UNION block. More... | |
SUB_CDECL | py_class (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at the start of a TYPE block. More... | |
SUB_CDECL | py_define (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at an #DEFINE line or at the start of a #MACRO More... | |
SUB_CDECL | py_include (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at an #INCLUDE line. More... | |
SUB_CDECL | py_init (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at an #INCLUDE line. More... | |
SUB_CDECL | py_exit (BYVAL_AS_Parser_PTR P) |
Emitter called when the Parser is at an #INCLUDE line. More... | |
SUB_CDECL | py_CTOR (BYVAL_AS_Options_PTR O) |
Constructor called before the first input gets parsed. More... | |
SUB_CDECL | EmitterInit (BYVAL_AS_EmitterIF_PTR Emi, BYREF_AS_STRING Par) |
Initialize the EmitterIF and evaluate parameters. More... | |
Variables | |
LONG | ENUM_COUNT |
A counter for ENUM blocks. More... | |
STRING | T0 |
The first type block. More... | |
STRING | T1 |
The second type block. More... | |
STRING | T2 |
The list of type names (, separated) More... | |
STRING | CLASSES |
The list of class names (!"\\n" separated) More... | |
STRING | LIBRARY |
The name of the binary to build. More... | |
STRING | HEADER |
The header for the output. More... | |
Example code for an external emitter for Python bindings.
This file contains example source code for an external emitter. The emitter outputs Python declarations from the FB headers, in order to generate Python bindings based on ctypes for libraries compiled in FB.
Definition in file py_ctypes.bas.
#define NEW_ENTRY /* Code(NL & NL & "# " & MID(.Fnam, INSTRREV(.Fnam, SLASH) + 1) & ": " & .LineNo) */ |
Macro to place a comment in to the output (file name and line number)
Definition at line 17 of file py_ctypes.bas.
SUB genNLiteral | ( | BYREF_AS_STRING | T | ) |
Transform number literals.
T | The string to work on |
This procedure checks a string for numerical literals and transforms the FB notation to Python equivalents.
Definition at line 38 of file py_ctypes.bas.
FUNCTION_AS_STRING genCType | ( | BYVAL_AS_Parser_PTR | P | ) |
Transform a FB type in to a ctype.
P | The parser calling this emitter |
This function transforms a FB type in to the ctypes equivalent in case of a standard type. Otherwise the original type symbol gets returned. Pointers get enclosed by POINTER(...)
, but ZSTRING PTR
gets transformed to c_char_p
.
Definition at line 63 of file py_ctypes.bas.
SUB_CDECL py_entryListPara | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter to extract the types of a parameter list.
P | The parser calling this emitter |
This emitter collects the types of the parameter list in global variable T2
, to be used in py_function().
Definition at line 100 of file py_ctypes.bas.
SUB_CDECL py_emitEnumNames | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter to generate a line for a ENUM block entry.
P | The parser calling this emitter |
This emitter gets called when the parser is in a block (ENUM
). It generates a line for each member and stores it (them) in the out variable.
Definition at line 116 of file py_ctypes.bas.
SUB_CDECL py_emitBlockNames | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter to generate a line for a TYPE / UNION block entry.
P | The parser calling this emitter |
This emitter gets called when the parser is in a block (TYPE UNION
). It generates a line for each member and stores it (them) in the output variable.
Definition at line 151 of file py_ctypes.bas.
SUB_CDECL py_function | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is on top of a function body.
P | The parser calling this emitter |
FIXME
Definition at line 199 of file py_ctypes.bas.
SUB_CDECL py_declare | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at a variable declaration.
P | The parser calling this emitter |
FIXME
Definition at line 234 of file py_ctypes.bas.
SUB_CDECL py_enum | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at the start of a ENUM block.
P | The parser calling this emitter |
FIXME
Definition at line 255 of file py_ctypes.bas.
SUB_CDECL py_union | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at the start of a UNION block.
P | The parser calling this emitter |
FIXME
Definition at line 271 of file py_ctypes.bas.
SUB_CDECL py_class | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at the start of a TYPE block.
P | The parser calling this emitter |
FIXME
Definition at line 286 of file py_ctypes.bas.
SUB_CDECL py_define | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at an #DEFINE
line or at the start of a #MACRO
P | The parser calling this emitter |
FIXME
Definition at line 313 of file py_ctypes.bas.
SUB_CDECL py_include | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at an #INCLUDE
line.
P | The parser calling this emitter |
FIXME
Definition at line 339 of file py_ctypes.bas.
SUB_CDECL py_init | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at an #INCLUDE
line.
P | The parser calling this emitter |
FIXME
Definition at line 353 of file py_ctypes.bas.
SUB_CDECL py_exit | ( | BYVAL_AS_Parser_PTR | P | ) |
Emitter called when the Parser is at an #INCLUDE
line.
P | The parser calling this emitter |
FIXME
Definition at line 365 of file py_ctypes.bas.
SUB_CDECL py_CTOR | ( | BYVAL_AS_Options_PTR | O | ) |
Constructor called before the first input gets parsed.
O | The Options UDT calling this constructor |
FIXME
Definition at line 377 of file py_ctypes.bas.
SUB_CDECL EmitterInit | ( | BYVAL_AS_EmitterIF_PTR | Emi, |
BYREF_AS_STRING | Par | ||
) |
Initialize the EmitterIF and evaluate parameters.
Emi | The newly created EmitterIF to fill with our callbacks |
Par | Additional command line parameters, not parsed by fb-doc |
FIXME
Definition at line 404 of file py_ctypes.bas.
LONG ENUM_COUNT |
A counter for ENUM blocks.
Definition at line 19 of file py_ctypes.bas.
STRING T0 |
The first type block.
Definition at line 21 of file py_ctypes.bas.
STRING T1 |
The second type block.
Definition at line 21 of file py_ctypes.bas.
STRING T2 |
The list of type names (,
separated)
Definition at line 21 of file py_ctypes.bas.
STRING CLASSES |
The list of class names (!"\\n"
separated)
Definition at line 21 of file py_ctypes.bas.
STRING LIBRARY |
The name of the binary to build.
Definition at line 21 of file py_ctypes.bas.
STRING HEADER |
The header for the output.
Definition at line 21 of file py_ctypes.bas.