VTK
vtkParsePreprocess.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkParsePreprocess.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright (c) 2010 David Gobbi.
17 
18  Contributed to the VisualizationToolkit by the author in June 2010
19  under the terms of the Visualization Toolkit 2008 copyright.
20 -------------------------------------------------------------------------*/
21 
43 #ifndef VTK_PARSE_PREPROCESS_H
44 #define VTK_PARSE_PREPROCESS_H
45 
46 #include "vtkParseString.h"
47 
51 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
52 typedef __int64 preproc_int_t;
53 typedef unsigned __int64 preproc_uint_t;
54 #else
55 typedef long long preproc_int_t;
56 typedef unsigned long long preproc_uint_t;
57 #endif
58 
62 typedef struct _MacroInfo
63 {
64  const char *Name;
65  const char *Definition;
66  const char *Comment; /* unused */
67  int NumberOfParameters; /* only if IsFunction == 1 */
68  const char **Parameters; /* symbols for parameters */
69  int IsFunction; /* this macro requires arguments */
70  int IsVariadic; /* this macro can take unlimited arguments */
71  int IsExternal; /* this macro is from an included file */
72  int IsExcluded; /* do not expand this macro */
74 
79 typedef struct _PreprocessInfo
80 {
81  const char *FileName; /* the file that is being parsed */
82  MacroInfo ***MacroHashTable; /* hash table for macro lookup */
84  const char **IncludeDirectories;
85  int NumberOfIncludeFiles; /* all included files */
86  const char **IncludeFiles;
87  StringCache *Strings; /* to aid string allocation */
88  int IsExternal; /* label all macros as "external" */
89  int ConditionalDepth; /* internal state variable */
90  int ConditionalDone; /* internal state variable */
92 
98 };
99 
105  VTK_PARSE_SKIP = 1, /* skip next block */
106  VTK_PARSE_PREPROC_DOUBLE = 2, /* encountered a double */
107  VTK_PARSE_PREPROC_FLOAT = 3, /* encountered a float */
108  VTK_PARSE_PREPROC_STRING = 4, /* encountered a string */
109  VTK_PARSE_MACRO_UNDEFINED = 5, /* macro lookup failed */
110  VTK_PARSE_MACRO_REDEFINED = 6, /* attempt to redefine a macro */
111  VTK_PARSE_FILE_NOT_FOUND = 7, /* include file not found */
112  VTK_PARSE_FILE_OPEN_ERROR = 8, /* include file not readable */
113  VTK_PARSE_FILE_READ_ERROR = 9, /* error during read */
114  VTK_PARSE_MACRO_NUMARGS = 10, /* wrong number of args to func macro */
115  VTK_PARSE_SYNTAX_ERROR = 11, /* any and all syntax errors */
116  VTK_PARSE_OUT_OF_MEMORY = 12 /* out-of-memory */
117 };
118 
122 #define VTK_PARSE_FATAL_ERROR 0xF8
123 
124 #ifdef __cplusplus
125 extern "C" {
126 #endif
127 
139  PreprocessInfo *info, const char *directive);
140 
151  PreprocessInfo *info, const char *text,
152  preproc_int_t *val, int *is_unsigned);
153 
160  PreprocessInfo *info, int platform);
161 
167  PreprocessInfo *info, const char *name, const char *definition);
168 
174  PreprocessInfo *info, const char *name);
175 
180  PreprocessInfo *info, const char *name);
181 
188  PreprocessInfo *info, MacroInfo *macro, const char *argstring);
189 
194  PreprocessInfo *info, MacroInfo *macro, const char *text);
195 
201  PreprocessInfo *info, const char *text);
202 
210  PreprocessInfo *info, const char *text);
211 
217  PreprocessInfo *info, const char *name);
218 
227  PreprocessInfo *info, const char *filename, int system_first,
228  int *already_loaded);
229 
234 
239 
244  PreprocessInfo *info, const char *filename);
245 
250 
251 #ifdef __cplusplus
252 } /* extern "C" */
253 #endif
254 
255 #endif
vtkParsePreprocess_ProcessString
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 occurr...
_MacroInfo::IsFunction
int IsFunction
Definition: vtkParsePreprocess.h:69
_PreprocessInfo::NumberOfIncludeFiles
int NumberOfIncludeFiles
Definition: vtkParsePreprocess.h:85
VTK_PARSE_PREPROC_FLOAT
@ VTK_PARSE_PREPROC_FLOAT
Definition: vtkParsePreprocess.h:107
VTK_PARSE_SKIP
@ VTK_PARSE_SKIP
Definition: vtkParsePreprocess.h:105
vtkParsePreprocess_FreeProcessedString
void vtkParsePreprocess_FreeProcessedString(PreprocessInfo *info, const char *text)
Free a processed string.
_MacroInfo::Definition
const char * Definition
Definition: vtkParsePreprocess.h:65
vtkParsePreprocess_EvaluateExpression
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 ...
vtkParsePreprocess_FreeMacroExpansion
void vtkParsePreprocess_FreeMacroExpansion(PreprocessInfo *info, MacroInfo *macro, const char *text)
Free an expanded macro.
VTK_PARSE_FILE_OPEN_ERROR
@ VTK_PARSE_FILE_OPEN_ERROR
Definition: vtkParsePreprocess.h:112
vtkParsePreprocess_IncludeDirectory
void vtkParsePreprocess_IncludeDirectory(PreprocessInfo *info, const char *name)
Add an include directory.
PreprocessInfo
struct _PreprocessInfo PreprocessInfo
Contains all symbols defined thus far (including those defined in any included header files).
_MacroInfo
Struct to describe a preprocessor symbol.
Definition: vtkParsePreprocess.h:63
_MacroInfo::IsVariadic
int IsVariadic
Definition: vtkParsePreprocess.h:70
_MacroInfo::Parameters
const char ** Parameters
Definition: vtkParsePreprocess.h:68
_MacroInfo::Name
const char * Name
Definition: vtkParsePreprocess.h:64
VTK_PARSE_MACRO_REDEFINED
@ VTK_PARSE_MACRO_REDEFINED
Definition: vtkParsePreprocess.h:110
vtkParsePreprocess_InitMacro
void vtkParsePreprocess_InitMacro(MacroInfo *symbol)
Initialize a preprocessor symbol struct.
preproc_int_t
long long preproc_int_t
This file provides subroutines to assist in preprocessing C/C++ header files.
Definition: vtkParsePreprocess.h:55
_MacroInfo::NumberOfParameters
int NumberOfParameters
Definition: vtkParsePreprocess.h:67
VTK_PARSE_PREPROC_DOUBLE
@ VTK_PARSE_PREPROC_DOUBLE
Definition: vtkParsePreprocess.h:106
_PreprocessInfo::ConditionalDone
int ConditionalDone
Definition: vtkParsePreprocess.h:90
_MacroInfo::IsExcluded
int IsExcluded
Definition: vtkParsePreprocess.h:72
_MacroInfo::IsExternal
int IsExternal
Definition: vtkParsePreprocess.h:71
VTK_PARSE_NATIVE
@ VTK_PARSE_NATIVE
Definition: vtkParsePreprocess.h:97
vtkgl::val
GLuint GLfloat * val
Definition: vtkgl.h:13789
vtkParsePreprocess_AddStandardMacros
void vtkParsePreprocess_AddStandardMacros(PreprocessInfo *info, int platform)
Add all standard preprocessor symbols.
vtkParsePreprocess_GetMacro
MacroInfo * vtkParsePreprocess_GetMacro(PreprocessInfo *info, const char *name)
Return a preprocessor symbol struct, or NULL if not found.
vtkgl::name
GLuint const GLchar * name
Definition: vtkgl.h:11983
_PreprocessInfo::MacroHashTable
MacroInfo *** MacroHashTable
Definition: vtkParsePreprocess.h:82
_PreprocessInfo::IncludeDirectories
const char ** IncludeDirectories
Definition: vtkParsePreprocess.h:84
_MacroInfo::Comment
const char * Comment
Definition: vtkParsePreprocess.h:66
VTK_PARSE_FILE_NOT_FOUND
@ VTK_PARSE_FILE_NOT_FOUND
Definition: vtkParsePreprocess.h:111
_PreprocessInfo::FileName
const char * FileName
Definition: vtkParsePreprocess.h:81
_StringCache
StringCache provides a simple way of allocating strings centrally.
Definition: vtkParseString.h:209
VTK_PARSE_PREPROC_STRING
@ VTK_PARSE_PREPROC_STRING
Definition: vtkParsePreprocess.h:108
MacroInfo
struct _MacroInfo MacroInfo
Struct to describe a preprocessor symbol.
VTK_PARSE_OUT_OF_MEMORY
@ VTK_PARSE_OUT_OF_MEMORY
Definition: vtkParsePreprocess.h:116
VTK_PARSE_OK
@ VTK_PARSE_OK
Definition: vtkParsePreprocess.h:104
vtkParsePreprocess_Init
void vtkParsePreprocess_Init(PreprocessInfo *info, const char *filename)
Initialize a preprocessor struct.
_PreprocessInfo
Contains all symbols defined thus far (including those defined in any included header files).
Definition: vtkParsePreprocess.h:80
_PreprocessInfo::NumberOfIncludeDirectories
int NumberOfIncludeDirectories
Definition: vtkParsePreprocess.h:83
VTK_PARSE_MACRO_UNDEFINED
@ VTK_PARSE_MACRO_UNDEFINED
Definition: vtkParsePreprocess.h:109
VTK_PARSE_SYNTAX_ERROR
@ VTK_PARSE_SYNTAX_ERROR
Definition: vtkParsePreprocess.h:115
vtkParsePreprocess_FreeMacro
void vtkParsePreprocess_FreeMacro(MacroInfo *macro)
Free a preprocessor macro struct.
_PreprocessInfo::IsExternal
int IsExternal
Definition: vtkParsePreprocess.h:88
_preproc_return_t
_preproc_return_t
Directive return values.
Definition: vtkParsePreprocess.h:103
VTK_PARSE_FILE_READ_ERROR
@ VTK_PARSE_FILE_READ_ERROR
Definition: vtkParsePreprocess.h:113
vtkX3D::info
@ info
Definition: vtkX3D.h:376
_PreprocessInfo::IncludeFiles
const char ** IncludeFiles
Definition: vtkParsePreprocess.h:86
vtkParsePreprocess_Free
void vtkParsePreprocess_Free(PreprocessInfo *info)
Free a preprocessor struct and its contents;.
vtkParsePreprocess_AddMacro
int vtkParsePreprocess_AddMacro(PreprocessInfo *info, const char *name, const char *definition)
Add a preprocessor symbol, including a definition.
vtkParsePreprocess_FindIncludeFile
const char * vtkParsePreprocess_FindIncludeFile(PreprocessInfo *info, const char *filename, int system_first, int *already_loaded)
Find an include file in the path.
_preproc_platform_t
_preproc_platform_t
Platforms.
Definition: vtkParsePreprocess.h:96
vtkParsePreprocess_RemoveMacro
int vtkParsePreprocess_RemoveMacro(PreprocessInfo *info, const char *name)
Remove a preprocessor symbol.
_PreprocessInfo::Strings
StringCache * Strings
Definition: vtkParsePreprocess.h:87
vtkParsePreprocess_ExpandMacro
const char * vtkParsePreprocess_ExpandMacro(PreprocessInfo *info, MacroInfo *macro, const char *argstring)
Expand a macro.
vtkParsePreprocess_HandleDirective
int vtkParsePreprocess_HandleDirective(PreprocessInfo *info, const char *directive)
Handle a preprocessor directive.
vtkParseString.h
preproc_uint_t
unsigned long long preproc_uint_t
Definition: vtkParsePreprocess.h:56
VTK_PARSE_MACRO_NUMARGS
@ VTK_PARSE_MACRO_NUMARGS
Definition: vtkParsePreprocess.h:114
_PreprocessInfo::ConditionalDepth
int ConditionalDepth
Definition: vtkParsePreprocess.h:89