VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Wrapping/Tools/vtkParsePreprocess.h
Go to the documentation of this file.
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 
00046 #include "vtkParseString.h"
00047 
00051 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
00052 typedef __int64 preproc_int_t;
00053 typedef unsigned __int64 preproc_uint_t;
00054 #else
00055 typedef long long preproc_int_t;
00056 typedef unsigned long long preproc_uint_t;
00057 #endif
00058 
00062 typedef struct _MacroInfo
00063 {
00064   const char    *Name;
00065   const char    *Definition;
00066   const char    *Comment; /* unused */
00067   int            NumberOfParameters; /* only if IsFunction == 1 */
00068   const char   **Parameters; /* symbols for parameters */
00069   int            IsFunction; /* this macro requires arguments */
00070   int            IsVariadic; /* this macro can take unlimited arguments */
00071   int            IsExternal; /* this macro is from an included file */
00072   int            IsExcluded; /* do not expand this macro */
00073 } MacroInfo;
00074 
00079 typedef struct _PreprocessInfo
00080 {
00081   const char    *FileName;         /* the file that is being parsed */
00082   MacroInfo   ***MacroHashTable;   /* hash table for macro lookup */
00083   int            NumberOfIncludeDirectories;
00084   const char   **IncludeDirectories;
00085   int            NumberOfIncludeFiles; /* all included files */
00086   const char   **IncludeFiles;
00087   StringCache   *Strings;          /* to aid string allocation */
00088   int            IsExternal;       /* label all macros as "external" */
00089   int            ConditionalDepth; /* internal state variable */
00090   int            ConditionalDone;  /* internal state variable */
00091 } PreprocessInfo;
00092 
00096 enum _preproc_platform_t {
00097   VTK_PARSE_NATIVE = 0
00098 };
00099 
00103 enum _preproc_return_t {
00104   VTK_PARSE_OK = 0,
00105   VTK_PARSE_SKIP = 1,            /* skip next block */
00106   VTK_PARSE_PREPROC_DOUBLE = 2,  /* encountered a double */
00107   VTK_PARSE_PREPROC_FLOAT = 3,   /* encountered a float */
00108   VTK_PARSE_PREPROC_STRING = 4,  /* encountered a string */
00109   VTK_PARSE_MACRO_UNDEFINED = 5, /* macro lookup failed */
00110   VTK_PARSE_MACRO_REDEFINED = 6, /* attempt to redefine a macro */
00111   VTK_PARSE_FILE_NOT_FOUND = 7,  /* include file not found */
00112   VTK_PARSE_FILE_OPEN_ERROR = 8, /* include file not readable */
00113   VTK_PARSE_FILE_READ_ERROR = 9, /* error during read */
00114   VTK_PARSE_MACRO_NUMARGS = 10,  /* wrong number of args to func macro */
00115   VTK_PARSE_SYNTAX_ERROR = 11,   /* any and all syntax errors */
00116   VTK_PARSE_OUT_OF_MEMORY = 12   /* out-of-memory */
00117 };
00118 
00122 #define VTK_PARSE_FATAL_ERROR 0xF8
00123 
00124 #ifdef __cplusplus
00125 extern "C" {
00126 #endif
00127 
00138 int vtkParsePreprocess_HandleDirective(
00139   PreprocessInfo *info, const char *directive);
00140 
00150 int vtkParsePreprocess_EvaluateExpression(
00151   PreprocessInfo *info, const char *text,
00152   preproc_int_t *val, int *is_unsigned);
00153 
00159 void vtkParsePreprocess_AddStandardMacros(
00160   PreprocessInfo *info, int platform);
00161 
00166 int vtkParsePreprocess_AddMacro(
00167   PreprocessInfo *info, const char *name, const char *definition);
00168 
00173 int vtkParsePreprocess_RemoveMacro(
00174   PreprocessInfo *info, const char *name);
00175 
00179 MacroInfo *vtkParsePreprocess_GetMacro(
00180   PreprocessInfo *info, const char *name);
00181 
00187 const char *vtkParsePreprocess_ExpandMacro(
00188   PreprocessInfo *info, MacroInfo *macro, const char *argstring);
00189 
00193 void vtkParsePreprocess_FreeMacroExpansion(
00194   PreprocessInfo *info, MacroInfo *macro, const char *text);
00195 
00200 const char *vtkParsePreprocess_ProcessString(
00201   PreprocessInfo *info, const char *text);
00202 
00209 void vtkParsePreprocess_FreeProcessedString(
00210   PreprocessInfo *info, const char *text);
00211 
00216 void vtkParsePreprocess_IncludeDirectory(
00217   PreprocessInfo *info, const char *name);
00218 
00226 const char *vtkParsePreprocess_FindIncludeFile(
00227   PreprocessInfo *info, const char *filename, int system_first,
00228   int *already_loaded);
00229 
00233 void vtkParsePreprocess_InitMacro(MacroInfo *symbol);
00234 
00238 void vtkParsePreprocess_FreeMacro(MacroInfo *macro);
00239 
00243 void vtkParsePreprocess_Init(
00244   PreprocessInfo *info, const char *filename);
00245 
00249 void vtkParsePreprocess_Free(PreprocessInfo *info);
00250 
00251 #ifdef __cplusplus
00252 } /* extern "C" */
00253 #endif
00254 
00255 #endif