![]() |
GirToBac
0.2
Create FB Headers from GObject Introspection *.gir files
|
Main source code file. More...
Go to the source code of this file.
Classes | |
class | UserUDT |
TYPE struct used the parsers. More... | |
Macros | |
#define | NL /* !"\n" & */ |
New line character macro (for better readability) More... | |
#define | _START_PARSER(_N_) |
Macro to start a parser. More... | |
#define | _END_PARSER(_N_) |
Macro to complete a start parser and open an end parser. More... | |
#define | _NEW_PARSER(_N_) |
Macro to complete an end parser and initialize the GMarkupParser UDT. More... | |
#define | _START_FUNC() |
Generate code to start parsing a function. More... | |
#define | _END_FUNC() |
Generate code to end parsing a function. More... | |
#define | PARSE(_N_) |
Macro to run a parser. More... | |
Enumerations | |
enum | TypeFlags { TYPE_VAR, TYPE_SUB, TYPE_FUN, TYPE_VARARG, TYPE_ARRAY, TYPE_LIST } |
ENUM used to specify a type. More... | |
Functions | |
FUNCTION_AS_CONST_gchar_PTR | find_value (BYVAL_AS_CONST_gchar_PTR Nam, BYVAL_AS_CONST_gchar_PTR_PTR AttNams, BYVAL_AS_CONST_gchar_PTR_PTR AttVals) |
Find an attribute by its name. More... | |
FUNCTION_AS_STRING | fb_type (BYVAL_AS_ANY_PTR Ud) |
Generate an FB type. More... | |
SUB_CDECL | start_type (BYVAL_AS_GMarkupParseContext_PTR, BYVAL_AS_CONST_gchar_PTR, BYVAL_AS_CONST_gchar_PTR_PTR, BYVAL_AS_CONST_gchar_PTR_PTR, BYVAL_AS_gpointer, BYVAL_AS_GError_PTR_PTR) |
Forward declaration (due to circular references) More... | |
SUB_CDECL | end_type (BYVAL_AS_GMarkupParseContext_PTR, BYVAL_AS_CONST_gchar_PTR, BYVAL_AS_gpointer, BYVAL_AS_GError_PTR_PTR) |
Forward declaration (due to circular references) More... | |
SUB_CDECL | para_parser () |
The GMarkupParser for the parameter lists. More... | |
SUB_CDECL | func_parser () |
The GMarkupParser for the functions (function, method, constructor, callback) More... | |
SUB_CDECL | type_parser () |
The GMarkupParser for the types. More... | |
SUB_CDECL | class_parser () |
The GMarkupParser for the interfaces, records and classes (OOP style -> ToDo) More... | |
SUB_CDECL | udt_parser () |
The GMarkupParser for the interfaces, records and classes (C-like style) More... | |
SUB_CDECL | unio_parser () |
The GMarkupParser for the union blocks. More... | |
SUB_CDECL | enum_parser () |
The GMarkupParser for the enum blocks. More... | |
SUB_CDECL | pass1_parser () |
The GMarkupParser for the first pass. More... | |
SUB_CDECL | passX_parser () |
The GMarkupParser for the second pass. More... | |
SUB_CDECL | pass4_parser () |
The GMarkupParser for last pass. More... | |
int | main () |
Variables | |
const VAR | OOP = 0 |
a flag to generate classic (C-like) headers or OOP style (currently only classic style is supported) More... | |
static GMarkupParser | Skip_parser = TYPE(NULL, NULL, NULL, NULL, NULL) |
The GMarkupParser for skipping XML-tags. More... | |
static GMarkupParser | Type_parser = TYPE(@start_type, @end_type, NULL, NULL, NULL) |
The GMarkupParser for the type XML-tags. More... | |
Main source code file.
This file contains the main source code. Compile this file with the FreeBasic compiler fbc to create an executable GirToBac tool.
The main content of this file are different parsers used by the GMarkupParser . Each parser is declared as a UDT containing five function adresses. Only two are used here (start_element and end_element). For better readability macros are used for the relapsing part of the function declarations and the UDT declarations of each parser. Additionally, labels are placed in front of each parser to get a mark in the IDE labels list for easy jumping between the parser definitions. (The labels aren't used in the source code.)
Definition in file GirToBac.bas.
#define NL /* !"\n" & */ |
New line character macro (for better readability)
Definition at line 161 of file GirToBac.bas.
#define _START_PARSER | ( | _N_ | ) |
Macro to start a parser.
Each parser uses the same parameter list for the start function. This macro generates the code for such a procedure (SUB) and opens a WITH block to support access to the UserUDT data.
It's designed to be used in combination with the _END_PARSER() macro.
Definition at line 173 of file GirToBac.bas.
#define _END_PARSER | ( | _N_ | ) |
Macro to complete a start parser and open an end parser.
Each parser uses the same code for ending a start function and the same parameter list for the end function. This macro generates the code to finish the start procedure (END WITH/END SUB), open an end procedure (SUB with constant parameter list) and opens a WITH block to support access to the UserUDT data.
It's designed to be used after the _START_PARSER() macro and in combination with the _NEW_PARSER() macro.
Definition at line 196 of file GirToBac.bas.
#define _NEW_PARSER | ( | _N_ | ) |
Macro to complete an end parser and initialize the GMarkupParser UDT.
Each parser uses the same code for ending an end procedure. This macro generates the code to finish the end procedure and generates a structure (TYPE) to use the parser. This TYPE contains two functions (procedures for start and end of a XML tag).
It's designed to be used after the _END_PARSER() macro.
Definition at line 223 of file GirToBac.bas.
#define _START_FUNC | ( | ) |
Generate code to start parsing a function.
This macro is used to start the function parser. The snipped is used several times, so this macro makes it unique (single source).
Definition at line 245 of file GirToBac.bas.
#define _END_FUNC | ( | ) |
Generate code to end parsing a function.
This macro is used to end the function parser. The snipped is used several times, so this macro makes it unique (single source).
Definition at line 263 of file GirToBac.bas.
#define PARSE | ( | _N_ | ) |
Macro to run a parser.
This macro creates a parser context and runs the given parser once.
Definition at line 917 of file GirToBac.bas.
enum TypeFlags |
ENUM used to specify a type.
These enums are used to specify a type. This may be an return value from a function, a parameter in a parameter list or a member field in a TYPE or UNION.
Definition at line 81 of file GirToBac.bas.
FUNCTION_AS_CONST_gchar_PTR find_value | ( | BYVAL_AS_CONST_gchar_PTR | Nam, |
BYVAL_AS_CONST_gchar_PTR_PTR | AttNams, | ||
BYVAL_AS_CONST_gchar_PTR_PTR | AttVals | ||
) |
Find an attribute by its name.
Nam | The attribute name |
AttNams | The GLib array of attribute names (zero terminated) |
AttVals | The GLib array of attribute values |
The GLib XML parser lists all attributes found in a tag and their values in the arrays AttNams and AttVals. This function finds an attribute by its name and returns its value. Otherwise it returns zero if the specified attribute isn't present.
Definition at line 147 of file GirToBac.bas.
FUNCTION_AS_STRING fb_type | ( | BYVAL_AS_ANY_PTR | Ud | ) |
Generate an FB type.
Ud | The data in the UserUDT |
Type declarations may need adaptions. We have to follow the rules defined in the *.GirToBac file to change some types. Also they may contain '*' characters to be translated to 'PTR' strings for FB.
In seldom cases a *.gir declaration doesn't contain an entry for a C type. Then we try repairing it by using the type used in the namespace instead.
Definition at line 287 of file GirToBac.bas.
SUB_CDECL start_type | ( | BYVAL_AS_GMarkupParseContext_PTR | , |
BYVAL_AS_CONST_gchar_PTR | , | ||
BYVAL_AS_CONST_gchar_PTR_PTR | , | ||
BYVAL_AS_CONST_gchar_PTR_PTR | , | ||
BYVAL_AS_gpointer | , | ||
BYVAL_AS_GError_PTR_PTR | |||
) |
Forward declaration (due to circular references)
SUB_CDECL end_type | ( | BYVAL_AS_GMarkupParseContext_PTR | , |
BYVAL_AS_CONST_gchar_PTR | , | ||
BYVAL_AS_gpointer | , | ||
BYVAL_AS_GError_PTR_PTR | |||
) |
Forward declaration (due to circular references)
SUB_CDECL para_parser | ( | ) |
The GMarkupParser for the parameter lists.
Definition at line 338 of file GirToBac.bas.
SUB_CDECL func_parser | ( | ) |
The GMarkupParser for the functions (function, method, constructor, callback)
Definition at line 376 of file GirToBac.bas.
SUB_CDECL type_parser | ( | ) |
The GMarkupParser for the types.
Definition at line 400 of file GirToBac.bas.
SUB_CDECL class_parser | ( | ) |
The GMarkupParser for the interfaces, records and classes (OOP style -> ToDo)
Definition at line 455 of file GirToBac.bas.
SUB_CDECL udt_parser | ( | ) |
The GMarkupParser for the interfaces, records and classes (C-like style)
Definition at line 575 of file GirToBac.bas.
SUB_CDECL unio_parser | ( | ) |
The GMarkupParser for the union blocks.
Definition at line 626 of file GirToBac.bas.
SUB_CDECL enum_parser | ( | ) |
The GMarkupParser for the enum blocks.
Definition at line 672 of file GirToBac.bas.
SUB_CDECL pass1_parser | ( | ) |
The GMarkupParser for the first pass.
Definition at line 692 of file GirToBac.bas.
SUB_CDECL passX_parser | ( | ) |
The GMarkupParser for the second pass.
Definition at line 771 of file GirToBac.bas.
SUB_CDECL pass4_parser | ( | ) |
The GMarkupParser for last pass.
Definition at line 883 of file GirToBac.bas.
int main | ( | ) |
const VAR OOP = 0 |
a flag to generate classic (C-like) headers or OOP style (currently only classic style is supported)
Definition at line 71 of file GirToBac.bas.
|
static |
The GMarkupParser for skipping XML-tags.
Definition at line 234 of file GirToBac.bas.
|
static |
The GMarkupParser for the type XML-tags.
Definition at line 334 of file GirToBac.bas.