VTK
|
Go to the source code of this file.
Classes | |
struct | _MacroInfo |
Struct to describe a preprocessor symbol. More... | |
struct | _PreprocessInfo |
Contains all symbols defined thus far (including those defined in any included header files). More... | |
Defines | |
#define | VTK_PARSE_FATAL_ERROR 0xF8 |
Bitfield for fatal errors. | |
Typedefs | |
typedef long long | preproc_int_t |
This file provides subroutines to assist in preprocessing C/C++ header files. | |
typedef unsigned long long | preproc_uint_t |
typedef struct _MacroInfo | MacroInfo |
Struct to describe a preprocessor symbol. | |
typedef struct _PreprocessInfo | PreprocessInfo |
Contains all symbols defined thus far (including those defined in any included header files). | |
Enumerations | |
enum | _preproc_platform_t { VTK_PARSE_NATIVE = 0 } |
Platforms. More... | |
enum | _preproc_return_t { VTK_PARSE_OK = 0, VTK_PARSE_SKIP = 1, VTK_PARSE_PREPROC_DOUBLE = 2, VTK_PARSE_PREPROC_FLOAT = 3, VTK_PARSE_PREPROC_STRING = 4, VTK_PARSE_MACRO_UNDEFINED = 5, VTK_PARSE_MACRO_REDEFINED = 6, VTK_PARSE_FILE_NOT_FOUND = 7, VTK_PARSE_FILE_OPEN_ERROR = 8, VTK_PARSE_FILE_READ_ERROR = 9, VTK_PARSE_MACRO_NUMARGS = 10, VTK_PARSE_SYNTAX_ERROR = 11 } |
Directive return values. More... | |
Functions | |
int | vtkParsePreprocess_HandleDirective (PreprocessInfo *info, const char *directive) |
Handle a preprocessor directive. | |
int | vtkParsePreprocess_EvaluateExpression (PreprocessInfo *info, const char *text, preproc_int_t *val, int *is_unsigned) |
Evaluate a preprocessor expression, providing an integer result in "val", and whether it is unsigned in "is_unsigned". | |
void | vtkParsePreprocess_AddStandardMacros (PreprocessInfo *info, int platform) |
Add all standard preprocessor symbols. | |
int | vtkParsePreprocess_AddMacro (PreprocessInfo *info, const char *name, const char *definition) |
Add a preprocessor symbol, including a definition. | |
int | vtkParsePreprocess_RemoveMacro (PreprocessInfo *info, const char *name) |
Remove a preprocessor symbol. | |
MacroInfo * | vtkParsePreprocess_GetMacro (PreprocessInfo *info, const char *name) |
Return a preprocessor symbol struct, or NULL if not found. | |
const char * | vtkParsePreprocess_ExpandMacro (PreprocessInfo *info, MacroInfo *macro, const char *argstring) |
Expand a macro. | |
void | vtkParsePreprocess_FreeMacroExpansion (PreprocessInfo *info, MacroInfo *macro, const char *text) |
Free an expanded macro. | |
const char * | vtkParsePreprocess_ProcessString (PreprocessInfo *info, const char *text) |
Fully process a string with the preprocessor, and return a new string or NULL if a fatal error occurred. | |
void | vtkParsePreprocess_FreeProcessedString (PreprocessInfo *info, const char *text) |
Free a processed string. | |
void | vtkParsePreprocess_IncludeDirectory (PreprocessInfo *info, const char *name) |
Add an include directory. | |
const char * | vtkParsePreprocess_FindIncludeFile (PreprocessInfo *info, const char *filename, int system_first, int *already_loaded) |
Find an include file in the path. | |
void | vtkParsePreprocess_InitMacro (MacroInfo *symbol) |
Initialize a preprocessor symbol struct. | |
void | vtkParsePreprocess_FreeMacro (MacroInfo *macro) |
Free a preprocessor macro struct. | |
void | vtkParsePreprocess_Init (PreprocessInfo *info, const char *filename) |
Initialize a preprocessor struct. | |
void | vtkParsePreprocess_Free (PreprocessInfo *info) |
Free a preprocessor struct and its contents;. |
#define VTK_PARSE_FATAL_ERROR 0xF8 |
Bitfield for fatal errors.
Definition at line 117 of file vtkParsePreprocess.h.
typedef long long preproc_int_t |
This file provides subroutines to assist in preprocessing C/C++ header files.
It evaluates preprocessor directives and stores a list of all preprocessor macros.
The preprocessing is done in-line while the file is being parsed. Macros that are defined in the file are stored but are not automatically expanded. The parser can query the macro definitions, expand them into plain text, or ask the preprocessor to evaluate them and return an integer result.
The typical usage of this preprocessor is that the main parser will pass any lines that begin with '#' to the vtkParsePreprocess_HandleDirective() function, which will evaluate the line and provide a return code. The return code will tell the main parser if a syntax error or macro lookup error occurred, and will also let the parser know if an #if or #else directive requires that the next block of code be skipped. The preprocessor int type. Use the compiler's longest int type.
Definition at line 53 of file vtkParsePreprocess.h.
typedef unsigned long long preproc_uint_t |
Definition at line 54 of file vtkParsePreprocess.h.
typedef struct _MacroInfo MacroInfo |
Struct to describe a preprocessor symbol.
typedef struct _PreprocessInfo PreprocessInfo |
Contains all symbols defined thus far (including those defined in any included header files).
enum _preproc_platform_t |
Platforms.
Always choose native unless crosscompiling.
Definition at line 92 of file vtkParsePreprocess.h.
enum _preproc_return_t |
Directive return values.
Definition at line 99 of file vtkParsePreprocess.h.
int vtkParsePreprocess_HandleDirective | ( | PreprocessInfo * | info, |
const char * | directive | ||
) |
Handle a preprocessor directive.
Return value VTK_PARSE_OK means that no errors occurred, while VTK_PARSE_SKIP means that a conditional directive was encountered and the next code block should be skipped. The preprocessor has an internal state machine that keeps track of conditional if/else/endif directives. All other return values indicate errors, and it is up to the parser to decide which errors are fatal. The preprocessor only considers syntax errors and I/O errors to be fatal.
int vtkParsePreprocess_EvaluateExpression | ( | PreprocessInfo * | info, |
const char * | text, | ||
preproc_int_t * | val, | ||
int * | is_unsigned | ||
) |
Evaluate a preprocessor expression, providing an integer result in "val", and whether it is unsigned in "is_unsigned".
A return value of VTK_PARSE_OK means that no errors occurred, while VTK_PREPROC_DOUBLE, VTK_PREPROC_FLOAT, and VTK_PREPROC_STRING indicate that the preprocessor encountered a non-integer value. Error return values are VTK_PARSE_MACRO_UNDEFINED and VTK_PARSE_SYNTAX_ERRORS. Undefined macros evaluate to zero.
void vtkParsePreprocess_AddStandardMacros | ( | PreprocessInfo * | info, |
int | platform | ||
) |
Add all standard preprocessor symbols.
Use VTK_PARSE_NATIVE as the platform. In the future, other platform specifiers might be added to allow crosscompiling.
int vtkParsePreprocess_AddMacro | ( | PreprocessInfo * | info, |
const char * | name, | ||
const char * | definition | ||
) |
Add a preprocessor symbol, including a definition.
Return values are VTK_PARSE_OK and VTK_PARSE_MACRO_REDEFINED.
int vtkParsePreprocess_RemoveMacro | ( | PreprocessInfo * | info, |
const char * | name | ||
) |
Remove a preprocessor symbol.
Return values are VTK_PARSE_OK and VTK_PARSE_MACRO_UNDEFINED.
MacroInfo* vtkParsePreprocess_GetMacro | ( | PreprocessInfo * | info, |
const char * | name | ||
) |
Return a preprocessor symbol struct, or NULL if not found.
const char* vtkParsePreprocess_ExpandMacro | ( | PreprocessInfo * | info, |
MacroInfo * | macro, | ||
const char * | argstring | ||
) |
Expand a macro.
A function macro must be given an argstring with args in parentheses, otherwise the argstring can be NULL. returns NULL if the wrong number of arguments were given.
void vtkParsePreprocess_FreeMacroExpansion | ( | PreprocessInfo * | info, |
MacroInfo * | macro, | ||
const char * | text | ||
) |
Free an expanded macro.
const char* vtkParsePreprocess_ProcessString | ( | PreprocessInfo * | info, |
const char * | text | ||
) |
Fully process a string with the preprocessor, and return a new string or NULL if a fatal error occurred.
void vtkParsePreprocess_FreeProcessedString | ( | PreprocessInfo * | info, |
const char * | text | ||
) |
Free a processed string.
Only call this method if the string returned by ProcessString is different from the original string, because ProcessString will just return the original string if no processing was needed.
void vtkParsePreprocess_IncludeDirectory | ( | PreprocessInfo * | info, |
const char * | name | ||
) |
Add an include directory.
The directories that were added first will be searched first.
const char* vtkParsePreprocess_FindIncludeFile | ( | PreprocessInfo * | info, |
const char * | filename, | ||
int | system_first, | ||
int * | already_loaded | ||
) |
Find an include file in the path.
If system_first is set, then the current directory is ignored unless it is explicitly in the path. A null return value indicates that the file was not found. If already_loaded is set, then the file was already loaded. This preprocessor never loads the same file twice.
void vtkParsePreprocess_InitMacro | ( | MacroInfo * | symbol | ) |
Initialize a preprocessor symbol struct.
void vtkParsePreprocess_FreeMacro | ( | MacroInfo * | macro | ) |
Free a preprocessor macro struct.
void vtkParsePreprocess_Init | ( | PreprocessInfo * | info, |
const char * | filename | ||
) |
Initialize a preprocessor struct.
void vtkParsePreprocess_Free | ( | PreprocessInfo * | info | ) |
Free a preprocessor struct and its contents;.