1 /*=========================================================================
3 Program: Visualization Toolkit
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
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.
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16 Copyright (c) 2010 David Gobbi.
18 Contributed to the VisualizationToolkit by the author in May 2010
19 under the terms of the Visualization Toolkit 2008 copyright.
20 -------------------------------------------------------------------------*/
23 Data structures used by vtkParse.
26 #ifndef VTK_PARSE_DATA_H
27 #define VTK_PARSE_DATA_H
29 #include "vtkParseType.h"
30 #include "vtkParseString.h"
33 #ifndef VTK_PARSE_LEGACY_REMOVE
40 typedef enum _parse_access_t
42 VTK_ACCESS_PUBLIC = 0,
43 VTK_ACCESS_PROTECTED = 1,
44 VTK_ACCESS_PRIVATE = 2
50 typedef enum _parse_item_t
52 VTK_NAMESPACE_INFO = 1,
57 VTK_FUNCTION_INFO = 6,
58 VTK_VARIABLE_INFO = 7,
59 VTK_CONSTANT_INFO = 8,
65 * ItemInfo just contains an index
67 typedef struct _ItemInfo
73 /* forward declarations */
77 typedef struct _ValueInfo ValueInfo;
78 typedef struct _FunctionInfo FunctionInfo;
79 typedef struct _FileInfo FileInfo;
82 * TemplateInfo holds template definitions
84 typedef struct _TemplateInfo
86 int NumberOfParameters;
87 ValueInfo **Parameters;
91 * ValueInfo is for typedefs, constants, variables,
92 * function parameters, and return values
94 * Note that Dimensions is an array of char pointers, in
95 * order to support dimensions that are sized according to
96 * template parameter values or according to named constants.
100 parse_item_t ItemType;
101 parse_access_t Access;
104 const char *Value; /* for vars or default paramter values */
105 unsigned int Type; /* as defined in vtkParseType.h */
106 const char *Class; /* classname for type */
107 int Count; /* total number of values, if known */
108 const char *CountHint; /* hint about how to get the count */
109 int NumberOfDimensions; /* dimensionality for arrays */
110 const char **Dimensions; /* dimensions for arrays */
111 FunctionInfo *Function; /* for function pointer values */
112 TemplateInfo *Template; /* template parameters, or NULL */
113 int IsStatic; /* for class variables only */
114 int IsEnum; /* for constants only */
118 * FunctionInfo is for functions and methods
122 parse_item_t ItemType;
123 parse_access_t Access;
126 const char *Class; /* class name for methods */
127 const char *Signature; /* function signature as text */
128 TemplateInfo *Template; /* template parameters, or NULL */
129 int NumberOfParameters;
130 ValueInfo **Parameters;
131 ValueInfo *ReturnValue; /* NULL for constructors and destructors */
132 const char *Macro; /* the macro that defined this function */
133 const char *SizeHint; /* hint the size e.g. for operator[] */
136 int IsLegacy; /* marked as a legacy method or function */
137 int IsStatic; /* methods only */
138 int IsVirtual; /* methods only */
139 int IsPureVirtual; /* methods only */
140 int IsConst; /* methods only */
141 int IsExplicit; /* constructors only */
142 #ifndef VTK_PARSE_LEGACY_REMOVE
143 int NumberOfArguments; /* legacy */
144 unsigned int ArgTypes[MAX_ARGS]; /* legacy */
145 const char *ArgClasses[MAX_ARGS];/* legacy */
146 int ArgCounts[MAX_ARGS]; /* legacy */
147 unsigned int ReturnType; /* legacy */
148 const char *ReturnClass; /* legacy */
149 int HaveHint; /* legacy */
150 int HintSize; /* legacy */
151 int ArrayFailure;/* legacy */
152 int IsPublic; /* legacy */
153 int IsProtected; /* legacy */
158 * EnumInfo is for enums
159 * Constants are at the same level as the Enum, not inside it.
161 typedef struct _EnumInfo
163 parse_item_t ItemType;
164 parse_access_t Access;
170 * UsingInfo is for using directives
172 typedef struct _UsingInfo
174 parse_item_t ItemType;
175 parse_access_t Access;
176 const char *Name; /* null for using whole namespace */
178 const char *Scope; /* the namespace or class */
182 * ClassInfo is for classes, structs, unions, and namespaces
184 typedef struct _ClassInfo
186 parse_item_t ItemType;
187 parse_access_t Access;
190 TemplateInfo *Template;
191 int NumberOfSuperClasses;
192 const char **SuperClasses;
196 struct _ClassInfo **Classes;
197 int NumberOfFunctions;
198 FunctionInfo **Functions;
199 int NumberOfConstants;
200 ValueInfo **Constants;
201 int NumberOfVariables;
202 ValueInfo **Variables;
205 int NumberOfTypedefs;
206 ValueInfo **Typedefs;
209 int NumberOfNamespaces;
210 struct _ClassInfo **Namespaces;
216 * Namespace is for namespaces
218 typedef struct _ClassInfo NamespaceInfo;
221 * FileInfo is for header files
225 const char *FileName;
226 const char *NameComment;
227 const char *Description;
231 int NumberOfIncludes;
232 struct _FileInfo **Includes;
233 ClassInfo *MainClass;
234 NamespaceInfo *Contents;
235 StringCache *Strings;
244 * Initializer methods
247 void vtkParse_InitFile(FileInfo *file_info);
248 void vtkParse_InitNamespace(NamespaceInfo *namespace_info);
249 void vtkParse_InitClass(ClassInfo *cls);
250 void vtkParse_InitFunction(FunctionInfo *func);
251 void vtkParse_InitValue(ValueInfo *val);
252 void vtkParse_InitEnum(EnumInfo *item);
253 void vtkParse_InitUsing(UsingInfo *item);
254 void vtkParse_InitTemplate(TemplateInfo *arg);
260 * Strings are not deep-copied, they are assumed to be persistent.
263 void vtkParse_CopyNamespace(NamespaceInfo *data, const NamespaceInfo *orig);
264 void vtkParse_CopyClass(ClassInfo *data, const ClassInfo *orig);
265 void vtkParse_CopyFunction(FunctionInfo *data, const FunctionInfo *orig);
266 void vtkParse_CopyValue(ValueInfo *data, const ValueInfo *orig);
267 void vtkParse_CopyEnum(EnumInfo *data, const EnumInfo *orig);
268 void vtkParse_CopyUsing(UsingInfo *data, const UsingInfo *orig);
269 void vtkParse_CopyTemplate(TemplateInfo *data, const TemplateInfo *orig);
275 * Strings are not freed, they are assumed to be persistent.
278 void vtkParse_FreeFile(FileInfo *file_info);
279 void vtkParse_FreeNamespace(NamespaceInfo *namespace_info);
280 void vtkParse_FreeClass(ClassInfo *cls);
281 void vtkParse_FreeFunction(FunctionInfo *func);
282 void vtkParse_FreeValue(ValueInfo *val);
283 void vtkParse_FreeEnum(EnumInfo *item);
284 void vtkParse_FreeUsing(UsingInfo *item);
285 void vtkParse_FreeTemplate(TemplateInfo *arg);
290 * Add a string to an array of strings, grow array as necessary.
292 void vtkParse_AddStringToArray(
293 const char ***valueArray, int *count, const char *value);
296 * Expand the Item array for classes and namespaces.
298 void vtkParse_AddItemToArray(
299 ItemInfo **valueArray, int *count, parse_item_t type, int idx);
303 * Add various items to the structs.
306 void vtkParse_AddIncludeToFile(FileInfo *info, FileInfo *item);
307 void vtkParse_AddClassToClass(ClassInfo *info, ClassInfo *item);
308 void vtkParse_AddFunctionToClass(ClassInfo *info, FunctionInfo *item);
309 void vtkParse_AddEnumToClass(ClassInfo *info, EnumInfo *item);
310 void vtkParse_AddConstantToClass(ClassInfo *info, ValueInfo *item);
311 void vtkParse_AddVariableToClass(ClassInfo *info, ValueInfo *item);
312 void vtkParse_AddTypedefToClass(ClassInfo *info, ValueInfo *item);
313 void vtkParse_AddUsingToClass(ClassInfo *info, UsingInfo *item);
314 void vtkParse_AddNamespaceToNamespace(NamespaceInfo *info,NamespaceInfo *item);
315 void vtkParse_AddClassToNamespace(NamespaceInfo *info, ClassInfo *item);
316 void vtkParse_AddFunctionToNamespace(NamespaceInfo *info, FunctionInfo *item);
317 void vtkParse_AddEnumToNamespace(NamespaceInfo *info, EnumInfo *item);
318 void vtkParse_AddConstantToNamespace(NamespaceInfo *info, ValueInfo *item);
319 void vtkParse_AddVariableToNamespace(NamespaceInfo *info, ValueInfo *item);
320 void vtkParse_AddTypedefToNamespace(NamespaceInfo *info, ValueInfo *item);
321 void vtkParse_AddUsingToNamespace(NamespaceInfo *info, UsingInfo *item);
322 void vtkParse_AddParameterToFunction(FunctionInfo *info, ValueInfo *item);
323 void vtkParse_AddParameterToTemplate(TemplateInfo *info, ValueInfo *item);
327 * Add default constructors to a class if they do not already exist
329 void vtkParse_AddDefaultConstructors(ClassInfo *data, StringCache *cache);