VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
49 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
50 typedef __int64 preproc_int_t;
51 typedef unsigned __int64 preproc_uint_t;
52 #else
53 typedef long long preproc_int_t;
54 typedef unsigned long long preproc_uint_t;
55 #endif
56 
60 typedef struct _MacroInfo
61 {
62  const char *Name;
63  const char *Definition;
64  const char *Comment; /* unused */
65  int NumberOfParameters; /* only if IsFunction == 1 */
66  const char **Parameters; /* symbols for parameters */
67  int IsFunction; /* this macro requires arguments */
68  int IsExternal; /* this macro is from an included file */
69  int IsExcluded; /* do not expand this macro */
70 } MacroInfo;
71 
76 typedef struct _PreprocessInfo
77 {
78  const char *FileName; /* the file that is being parsed */
79  MacroInfo ***MacroHashTable; /* hash table for macro lookup */
81  const char **IncludeDirectories;
82  int NumberOfIncludeFiles; /* all included files */
83  const char **IncludeFiles;
84  int IsExternal; /* label all macros as "external" */
85  int ConditionalDepth; /* internal state variable */
86  int ConditionalDone; /* internal state variable */
88 
94 };
95 
101  VTK_PARSE_SKIP = 1, /* skip next block */
102  VTK_PARSE_PREPROC_DOUBLE = 2, /* encountered a double */
103  VTK_PARSE_PREPROC_FLOAT = 3, /* encountered a float */
104  VTK_PARSE_PREPROC_STRING = 4, /* encountered a string */
105  VTK_PARSE_MACRO_UNDEFINED = 5, /* macro lookup failed */
106  VTK_PARSE_MACRO_REDEFINED = 6, /* attempt to redefine a macro */
107  VTK_PARSE_FILE_NOT_FOUND = 7, /* include file not found */
108  VTK_PARSE_FILE_OPEN_ERROR = 8, /* include file not readable */
109  VTK_PARSE_FILE_READ_ERROR = 9, /* error during read */
110  VTK_PARSE_MACRO_NUMARGS = 10, /* wrong number of args to func macro */
111  VTK_PARSE_SYNTAX_ERROR = 11 /* any and all syntax errors */
112 };
113 
117 #define VTK_PARSE_FATAL_ERROR 0xF8
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
134  PreprocessInfo *info, const char *directive);
135 
146  PreprocessInfo *info, const char *text,
147  preproc_int_t *val, int *is_unsigned);
148 
155  PreprocessInfo *info, int platform);
156 
162  PreprocessInfo *info, const char *name, const char *definition);
163 
169  PreprocessInfo *info, const char *name);
170 
175  PreprocessInfo *info, const char *name);
176 
183  PreprocessInfo *info, MacroInfo *macro, const char *argstring);
184 
189  PreprocessInfo *info, MacroInfo *macro, const char *text);
190 
196  PreprocessInfo *info, const char *text);
197 
205  PreprocessInfo *info, const char *text);
206 
212  PreprocessInfo *info, const char *name);
213 
222  PreprocessInfo *info, const char *filename, int system_first,
223  int *already_loaded);
224 
229 
234 
239  PreprocessInfo *info, const char *filename);
240 
245 
246 #ifdef __cplusplus
247 } /* extern "C" */
248 #endif
249 
250 #endif
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...
_preproc_platform_t
Platforms.
Contains all symbols defined thus far (including those defined in any included header files)...
const char * Name
void vtkParsePreprocess_InitMacro(MacroInfo *symbol)
Initialize a preprocessor symbol struct.
MacroInfo * vtkParsePreprocess_GetMacro(PreprocessInfo *info, const char *name)
Return a preprocessor symbol struct, or NULL if not found.
int vtkParsePreprocess_HandleDirective(PreprocessInfo *info, const char *directive)
Handle a preprocessor directive.
struct _PreprocessInfo PreprocessInfo
Contains all symbols defined thus far (including those defined in any included header files)...
struct _MacroInfo MacroInfo
Struct to describe a preprocessor symbol.
_preproc_return_t
Directive return values.
Struct to describe a preprocessor symbol.
void vtkParsePreprocess_Init(PreprocessInfo *info, const char *filename)
Initialize a preprocessor struct.
const char * FileName
unsigned long long preproc_uint_t
const char * vtkParsePreprocess_FindIncludeFile(PreprocessInfo *info, const char *filename, int system_first, int *already_loaded)
Find an include file in the path.
const char ** IncludeDirectories
void vtkParsePreprocess_Free(PreprocessInfo *info)
Free a preprocessor struct and its contents;.
const char * Comment
MacroInfo *** MacroHashTable
void vtkParsePreprocess_AddStandardMacros(PreprocessInfo *info, int platform)
Add all standard preprocessor symbols.
void vtkParsePreprocess_FreeProcessedString(PreprocessInfo *info, const char *text)
Free a processed string.
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.
long long preproc_int_t
This file provides subroutines to assist in preprocessing C/C++ header files.
const char ** IncludeFiles
const char ** Parameters
const char * vtkParsePreprocess_ExpandMacro(PreprocessInfo *info, MacroInfo *macro, const char *argstring)
Expand a macro.
void vtkParsePreprocess_FreeMacro(MacroInfo *macro)
Free a preprocessor macro struct.
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 ...
void vtkParsePreprocess_FreeMacroExpansion(PreprocessInfo *info, MacroInfo *macro, const char *text)
Free an expanded macro.
void vtkParsePreprocess_IncludeDirectory(PreprocessInfo *info, const char *name)
Add an include directory.
const char * Definition