Salome HOME
Merge from BR_PORTING_VTK6 01/03/2013
[modules/paravis.git] / src / ParaView / vtkParseData.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkParseData.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 May 2010
19   under the terms of the Visualization Toolkit 2008 copyright.
20 -------------------------------------------------------------------------*/
21
22 /*
23   Data structures used by vtkParse.
24 */
25
26 #ifndef VTK_PARSE_DATA_H
27 #define VTK_PARSE_DATA_H
28
29 #include "vtkParseType.h"
30 #include "vtkParseString.h"
31
32 /* legacy */
33 #ifndef VTK_PARSE_LEGACY_REMOVE
34 #define MAX_ARGS 20
35 #endif
36
37 /**
38  * Access flags
39  */
40 typedef enum _parse_access_t
41 {
42   VTK_ACCESS_PUBLIC    = 0,
43   VTK_ACCESS_PROTECTED = 1,
44   VTK_ACCESS_PRIVATE   = 2
45 } parse_access_t;
46
47 /**
48  * ItemType constants
49  */
50 typedef enum _parse_item_t
51 {
52   VTK_NAMESPACE_INFO = 1,
53   VTK_CLASS_INFO     = 2,
54   VTK_STRUCT_INFO    = 3,
55   VTK_UNION_INFO     = 4,
56   VTK_ENUM_INFO      = 5,
57   VTK_FUNCTION_INFO  = 6,
58   VTK_VARIABLE_INFO  = 7,
59   VTK_CONSTANT_INFO  = 8,
60   VTK_TYPEDEF_INFO   = 9,
61   VTK_USING_INFO     = 10
62 } parse_item_t;
63
64 /**
65  * ItemInfo just contains an index
66  */
67 typedef struct _ItemInfo
68 {
69   parse_item_t   Type;
70   int            Index;
71 } ItemInfo;
72
73 /* forward declarations */
74 struct _ValueInfo;
75 struct _FunctionInfo;
76 struct _FileInfo;
77 typedef struct _ValueInfo ValueInfo;
78 typedef struct _FunctionInfo FunctionInfo;
79 typedef struct _FileInfo FileInfo;
80
81 /**
82  * TemplateInfo holds template definitions
83  */
84 typedef struct _TemplateInfo
85 {
86   int            NumberOfParameters;
87   ValueInfo    **Parameters;
88 } TemplateInfo;
89
90 /**
91  * ValueInfo is for typedefs, constants, variables,
92  * function parameters, and return values
93  *
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.
97  */
98 struct _ValueInfo
99 {
100   parse_item_t   ItemType;
101   parse_access_t Access;
102   const char    *Name;
103   const char    *Comment;
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 };
116
117 /**
118  * FunctionInfo is for functions and methods
119  */
120 struct _FunctionInfo
121 {
122   parse_item_t   ItemType;
123   parse_access_t Access;
124   const char    *Name;
125   const char    *Comment;
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[] */
134   int            IsOperator;
135   int            IsVariadic;
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 */
154 #endif
155 };
156
157 /**
158  * EnumInfo is for enums
159  * Constants are at the same level as the Enum, not inside it.
160  */
161 typedef struct _EnumInfo
162 {
163   parse_item_t   ItemType;
164   parse_access_t Access;
165   const char    *Name;
166   const char    *Comment;
167 } EnumInfo;
168
169 /**
170  * UsingInfo is for using directives
171  */
172 typedef struct _UsingInfo
173 {
174   parse_item_t   ItemType;
175   parse_access_t Access;
176   const char    *Name;     /* null for using whole namespace */
177   const char    *Comment;
178   const char    *Scope;    /* the namespace or class */
179 } UsingInfo;
180
181 /**
182  * ClassInfo is for classes, structs, unions, and namespaces
183  */
184 typedef struct _ClassInfo
185 {
186   parse_item_t   ItemType;
187   parse_access_t Access;
188   const char    *Name;
189   const char    *Comment;
190   TemplateInfo  *Template;
191   int            NumberOfSuperClasses;
192   const char   **SuperClasses;
193   int            NumberOfItems;
194   ItemInfo      *Items;
195   int            NumberOfClasses;
196   struct _ClassInfo **Classes;
197   int            NumberOfFunctions;
198   FunctionInfo **Functions;
199   int            NumberOfConstants;
200   ValueInfo    **Constants;
201   int            NumberOfVariables;
202   ValueInfo    **Variables;
203   int            NumberOfEnums;
204   EnumInfo     **Enums;
205   int            NumberOfTypedefs;
206   ValueInfo    **Typedefs;
207   int            NumberOfUsings;
208   UsingInfo    **Usings;
209   int            NumberOfNamespaces;
210   struct _ClassInfo **Namespaces;
211   int            IsAbstract;
212   int            HasDelete;
213 } ClassInfo;
214
215 /**
216  * Namespace is for namespaces
217  */
218 typedef struct _ClassInfo NamespaceInfo;
219
220 /**
221  * FileInfo is for header files
222  */
223 struct _FileInfo
224 {
225   const char *FileName;
226   const char *NameComment;
227   const char *Description;
228   const char *Caveats;
229   const char *SeeAlso;
230
231   int NumberOfIncludes;
232   struct _FileInfo **Includes;
233   ClassInfo *MainClass;
234   NamespaceInfo *Contents;
235   StringCache *Strings;
236 };
237
238
239 #ifdef __cplusplus
240 extern "C" {
241 #endif
242
243 /**
244  * Initializer methods
245  */
246 /*@{*/
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);
255 /*@}*/
256
257 /**
258  * Copy methods
259  *
260  * Strings are not deep-copied, they are assumed to be persistent.
261  */
262 /*@{*/
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);
270 /*@}*/
271
272 /**
273  * Free methods
274  *
275  * Strings are not freed, they are assumed to be persistent.
276  */
277 /*@{*/
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);
286 /*@}*/
287
288
289 /**
290  * Add a string to an array of strings, grow array as necessary.
291  */
292 void vtkParse_AddStringToArray(
293   const char ***valueArray, int *count, const char *value);
294
295 /**
296  * Expand the Item array for classes and namespaces.
297  */
298 void vtkParse_AddItemToArray(
299   ItemInfo **valueArray, int *count, parse_item_t type, int idx);
300
301
302 /**
303  * Add various items to the structs.
304  */
305 /*@{*/
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);
324 /*@}*/
325
326 /**
327  * Add default constructors to a class if they do not already exist
328  */
329 void vtkParse_AddDefaultConstructors(ClassInfo *data, StringCache *cache);
330
331 #ifdef __cplusplus
332 } /* extern "C" */
333 #endif
334
335 #endif