VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkParsePreprocess.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright (c) 2010 David Gobbi. 00017 00018 Contributed to the VisualizationToolkit by the author in June 2010 00019 under the terms of the Visualization Toolkit 2008 copyright. 00020 -------------------------------------------------------------------------*/ 00021 00043 #ifndef VTK_PARSE_PREPROCESS_H 00044 #define VTK_PARSE_PREPROCESS_H 00045 00049 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) 00050 typedef __int64 preproc_int_t; 00051 typedef unsigned __int64 preproc_uint_t; 00052 #else 00053 typedef long long preproc_int_t; 00054 typedef unsigned long long preproc_uint_t; 00055 #endif 00056 00060 typedef struct _MacroInfo 00061 { 00062 const char *Name; 00063 const char *Definition; 00064 const char *Comment; /* unused */ 00065 int NumberOfParameters; /* only if IsFunction == 1 */ 00066 const char **Parameters; /* symbols for parameters */ 00067 int IsFunction; /* this macro requires arguments */ 00068 int IsExternal; /* this macro is from an included file */ 00069 int IsExcluded; /* do not expand this macro */ 00070 } MacroInfo; 00071 00076 typedef struct _PreprocessInfo 00077 { 00078 const char *FileName; /* the file that is being parsed */ 00079 MacroInfo ***MacroHashTable; /* hash table for macro lookup */ 00080 int NumberOfIncludeDirectories; 00081 const char **IncludeDirectories; 00082 int NumberOfIncludeFiles; /* all included files */ 00083 const char **IncludeFiles; 00084 int IsExternal; /* label all macros as "external" */ 00085 int ConditionalDepth; /* internal state variable */ 00086 int ConditionalDone; /* internal state variable */ 00087 } PreprocessInfo; 00088 00092 enum _preproc_platform_t { 00093 VTK_PARSE_NATIVE = 0, 00094 }; 00095 00099 enum _preproc_return_t { 00100 VTK_PARSE_OK = 0, 00101 VTK_PARSE_SKIP = 1, /* skip next block */ 00102 VTK_PARSE_PREPROC_DOUBLE = 2, /* encountered a double */ 00103 VTK_PARSE_PREPROC_FLOAT = 3, /* encountered a float */ 00104 VTK_PARSE_PREPROC_STRING = 4, /* encountered a string */ 00105 VTK_PARSE_MACRO_UNDEFINED = 5, /* macro lookup failed */ 00106 VTK_PARSE_MACRO_REDEFINED = 6, /* attempt to redefine a macro */ 00107 VTK_PARSE_FILE_NOT_FOUND = 7, /* include file not found */ 00108 VTK_PARSE_FILE_OPEN_ERROR = 8, /* include file not readable */ 00109 VTK_PARSE_FILE_READ_ERROR = 9, /* error during read */ 00110 VTK_PARSE_MACRO_NUMARGS = 10, /* wrong number of args to func macro */ 00111 VTK_PARSE_SYNTAX_ERROR = 11 /* any and all syntax errors */ 00112 }; 00113 00117 #define VTK_PARSE_FATAL_ERROR 0xF8 00118 00119 #ifdef __cplusplus 00120 extern "C" { 00121 #endif 00122 00133 int vtkParsePreprocess_HandleDirective( 00134 PreprocessInfo *info, const char *directive); 00135 00145 int vtkParsePreprocess_EvaluateExpression( 00146 PreprocessInfo *info, const char *text, 00147 preproc_int_t *val, int *is_unsigned); 00148 00154 void vtkParsePreprocess_AddStandardMacros( 00155 PreprocessInfo *info, int platform); 00156 00161 int vtkParsePreprocess_AddMacro( 00162 PreprocessInfo *info, const char *name, const char *definition); 00163 00168 int vtkParsePreprocess_RemoveMacro( 00169 PreprocessInfo *info, const char *name); 00170 00174 MacroInfo *vtkParsePreprocess_GetMacro( 00175 PreprocessInfo *info, const char *name); 00176 00182 const char *vtkParsePreprocess_ExpandMacro( 00183 PreprocessInfo *info, MacroInfo *macro, const char *argstring); 00184 00188 void vtkParsePreprocess_FreeMacroExpansion( 00189 PreprocessInfo *info, MacroInfo *macro, const char *text); 00190 00195 const char *vtkParsePreprocess_ProcessString( 00196 PreprocessInfo *info, const char *text); 00197 00204 void vtkParsePreprocess_FreeProcessedString( 00205 PreprocessInfo *info, const char *text); 00206 00211 void vtkParsePreprocess_IncludeDirectory( 00212 PreprocessInfo *info, const char *name); 00213 00221 const char *vtkParsePreprocess_FindIncludeFile( 00222 PreprocessInfo *info, const char *filename, int system_first, 00223 int *already_loaded); 00224 00228 void vtkParsePreprocess_InitMacro(MacroInfo *symbol); 00229 00233 void vtkParsePreprocess_FreeMacro(MacroInfo *macro); 00234 00238 void vtkParsePreprocess_Init( 00239 PreprocessInfo *info, const char *filename); 00240 00244 void vtkParsePreprocess_Free(PreprocessInfo *info); 00245 00246 #ifdef __cplusplus 00247 } /* extern "C" */ 00248 #endif 00249 00250 #endif