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 */
115 int IsPack; /* for pack expansions */
119 * FunctionInfo is for functions and methods
123 parse_item_t ItemType;
124 parse_access_t Access;
127 const char *Class; /* class name for methods */
128 const char *Signature; /* function signature as text */
129 TemplateInfo *Template; /* template parameters, or NULL */
130 int NumberOfParameters;
131 ValueInfo **Parameters;
132 ValueInfo *ReturnValue; /* NULL for constructors and destructors */
133 const char *Macro; /* the macro that defined this function */
134 const char *SizeHint; /* hint the size e.g. for operator[] */
137 int IsLegacy; /* marked as a legacy method or function */
138 int IsStatic; /* methods only */
139 int IsVirtual; /* methods only */
140 int IsPureVirtual; /* methods only */
141 int IsConst; /* methods only */
142 int IsDeleted; /* methods only */
143 int IsFinal; /* methods only */
144 int IsExplicit; /* constructors only */
145 #ifndef VTK_PARSE_LEGACY_REMOVE
146 int NumberOfArguments; /* legacy */
147 unsigned int ArgTypes[MAX_ARGS]; /* legacy */
148 const char *ArgClasses[MAX_ARGS];/* legacy */
149 int ArgCounts[MAX_ARGS]; /* legacy */
150 unsigned int ReturnType; /* legacy */
151 const char *ReturnClass; /* legacy */
152 int HaveHint; /* legacy */
153 int HintSize; /* legacy */
154 int ArrayFailure;/* legacy */
155 int IsPublic; /* legacy */
156 int IsProtected; /* legacy */
161 * UsingInfo is for using directives
163 typedef struct _UsingInfo
165 parse_item_t ItemType;
166 parse_access_t Access;
167 const char *Name; /* null for using whole namespace */
169 const char *Scope; /* the namespace or class */
173 * ClassInfo is for classes, structs, unions, and namespaces
175 typedef struct _ClassInfo
177 parse_item_t ItemType;
178 parse_access_t Access;
181 TemplateInfo *Template;
182 int NumberOfSuperClasses;
183 const char **SuperClasses;
187 struct _ClassInfo **Classes;
188 int NumberOfFunctions;
189 FunctionInfo **Functions;
190 int NumberOfConstants;
191 ValueInfo **Constants;
192 int NumberOfVariables;
193 ValueInfo **Variables;
195 struct _ClassInfo **Enums;
196 int NumberOfTypedefs;
197 ValueInfo **Typedefs;
200 int NumberOfNamespaces;
201 struct _ClassInfo **Namespaces;
208 * EnumInfo is for enums
209 * For scoped enums, the constants are in the enum itself, but for
210 * standard enums, the constants are at the same level as the enum.
212 typedef struct _ClassInfo EnumInfo;
215 * Namespace is for namespaces
217 typedef struct _ClassInfo NamespaceInfo;
220 * FileInfo is for header files
224 const char *FileName;
225 const char *NameComment;
226 const char *Description;
230 int NumberOfIncludes;
231 struct _FileInfo **Includes;
232 ClassInfo *MainClass;
233 NamespaceInfo *Contents;
234 StringCache *Strings;
243 * Initializer methods
246 void vtkParse_InitFile(FileInfo *file_info);
247 void vtkParse_InitNamespace(NamespaceInfo *namespace_info);
248 void vtkParse_InitClass(ClassInfo *cls);
249 void vtkParse_InitFunction(FunctionInfo *func);
250 void vtkParse_InitValue(ValueInfo *val);
251 void vtkParse_InitEnum(EnumInfo *item);
252 void vtkParse_InitUsing(UsingInfo *item);
253 void vtkParse_InitTemplate(TemplateInfo *arg);
259 * Strings are not deep-copied, they are assumed to be persistent.
262 void vtkParse_CopyNamespace(NamespaceInfo *data, const NamespaceInfo *orig);
263 void vtkParse_CopyClass(ClassInfo *data, const ClassInfo *orig);
264 void vtkParse_CopyFunction(FunctionInfo *data, const FunctionInfo *orig);
265 void vtkParse_CopyValue(ValueInfo *data, const ValueInfo *orig);
266 void vtkParse_CopyEnum(EnumInfo *data, const EnumInfo *orig);
267 void vtkParse_CopyUsing(UsingInfo *data, const UsingInfo *orig);
268 void vtkParse_CopyTemplate(TemplateInfo *data, const TemplateInfo *orig);
274 * Strings are not freed, they are assumed to be persistent.
277 void vtkParse_FreeFile(FileInfo *file_info);
278 void vtkParse_FreeNamespace(NamespaceInfo *namespace_info);
279 void vtkParse_FreeClass(ClassInfo *cls);
280 void vtkParse_FreeFunction(FunctionInfo *func);
281 void vtkParse_FreeValue(ValueInfo *val);
282 void vtkParse_FreeEnum(EnumInfo *item);
283 void vtkParse_FreeUsing(UsingInfo *item);
284 void vtkParse_FreeTemplate(TemplateInfo *arg);
289 * Add a string to an array of strings, grow array as necessary.
291 void vtkParse_AddStringToArray(
292 const char ***valueArray, int *count, const char *value);
295 * Expand the Item array for classes and namespaces.
297 void vtkParse_AddItemToArray(
298 ItemInfo **valueArray, int *count, parse_item_t type, int idx);
302 * Add various items to the structs.
305 void vtkParse_AddIncludeToFile(FileInfo *info, FileInfo *item);
306 void vtkParse_AddClassToClass(ClassInfo *info, ClassInfo *item);
307 void vtkParse_AddFunctionToClass(ClassInfo *info, FunctionInfo *item);
308 void vtkParse_AddEnumToClass(ClassInfo *info, EnumInfo *item);
309 void vtkParse_AddConstantToClass(ClassInfo *info, ValueInfo *item);
310 void vtkParse_AddVariableToClass(ClassInfo *info, ValueInfo *item);
311 void vtkParse_AddTypedefToClass(ClassInfo *info, ValueInfo *item);
312 void vtkParse_AddUsingToClass(ClassInfo *info, UsingInfo *item);
313 void vtkParse_AddNamespaceToNamespace(NamespaceInfo *info,NamespaceInfo *item);
314 void vtkParse_AddClassToNamespace(NamespaceInfo *info, ClassInfo *item);
315 void vtkParse_AddFunctionToNamespace(NamespaceInfo *info, FunctionInfo *item);
316 void vtkParse_AddEnumToNamespace(NamespaceInfo *info, EnumInfo *item);
317 void vtkParse_AddConstantToNamespace(NamespaceInfo *info, ValueInfo *item);
318 void vtkParse_AddVariableToNamespace(NamespaceInfo *info, ValueInfo *item);
319 void vtkParse_AddTypedefToNamespace(NamespaceInfo *info, ValueInfo *item);
320 void vtkParse_AddUsingToNamespace(NamespaceInfo *info, UsingInfo *item);
321 void vtkParse_AddParameterToFunction(FunctionInfo *info, ValueInfo *item);
322 void vtkParse_AddParameterToTemplate(TemplateInfo *info, ValueInfo *item);
326 * Add default constructors to a class if they do not already exist
328 void vtkParse_AddDefaultConstructors(ClassInfo *data, StringCache *cache);