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 =========================================================================*/
17 #include "vtkParseInternal.h"
18 #include "vtkParseExtras.h"
23 /* -------------------------------------------------------------------- */
26 int vtkWrap_IsVoid(ValueInfo *val)
33 return ((val->Type & VTK_PARSE_UNQUALIFIED_TYPE) == VTK_PARSE_VOID);
36 int vtkWrap_IsVoidFunction(ValueInfo *val)
38 unsigned int t = (val->Type & VTK_PARSE_UNQUALIFIED_TYPE);
39 return (t == VTK_PARSE_FUNCTION);
42 int vtkWrap_IsVoidPointer(ValueInfo *val)
44 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
45 return (t == VTK_PARSE_VOID && vtkWrap_IsPointer(val));
48 int vtkWrap_IsCharPointer(ValueInfo *val)
50 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
51 return (t == VTK_PARSE_CHAR && vtkWrap_IsPointer(val));
54 int vtkWrap_IsVTKObject(ValueInfo *val)
56 unsigned int t = (val->Type & VTK_PARSE_UNQUALIFIED_TYPE);
57 return (t == VTK_PARSE_OBJECT_PTR &&
58 val->Class[0] == 'v' && strncmp(val->Class, "vtk", 3) == 0);
61 int vtkWrap_IsSpecialObject(ValueInfo *val)
63 unsigned int t = (val->Type & VTK_PARSE_UNQUALIFIED_TYPE);
64 return ((t == VTK_PARSE_OBJECT ||
65 t == VTK_PARSE_OBJECT_REF) &&
66 val->Class[0] == 'v' && strncmp(val->Class, "vtk", 3) == 0);
69 int vtkWrap_IsQtObject(ValueInfo *val)
71 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
72 if (t == VTK_PARSE_QOBJECT &&
73 val->Class[0] == 'Q' && isupper(val->Class[1]))
80 int vtkWrap_IsQtEnum(ValueInfo *val)
82 unsigned int t = (val->Type & VTK_PARSE_UNQUALIFIED_TYPE);
83 if ((t == VTK_PARSE_QOBJECT || t == VTK_PARSE_QOBJECT_REF) &&
84 val->Class[0] == 'Q' && strncmp("Qt::", val->Class, 4) == 0)
92 /* -------------------------------------------------------------------- */
93 /* The base types, all are mutually exclusive. */
95 int vtkWrap_IsObject(ValueInfo *val)
97 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
98 return (t == VTK_PARSE_OBJECT ||
99 t == VTK_PARSE_QOBJECT);
102 int vtkWrap_IsFunction(ValueInfo *val)
104 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
105 return (t == VTK_PARSE_FUNCTION);
108 int vtkWrap_IsStream(ValueInfo *val)
110 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
111 return (t == VTK_PARSE_ISTREAM ||
112 t == VTK_PARSE_OSTREAM);
115 int vtkWrap_IsNumeric(ValueInfo *val)
117 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
119 t = (t & ~VTK_PARSE_UNSIGNED);
122 case VTK_PARSE_FLOAT:
123 case VTK_PARSE_DOUBLE:
125 case VTK_PARSE_SHORT:
128 case VTK_PARSE_ID_TYPE:
129 case VTK_PARSE_LONG_LONG:
130 case VTK_PARSE___INT64:
131 case VTK_PARSE_SIGNED_CHAR:
132 case VTK_PARSE_SSIZE_T:
140 int vtkWrap_IsString(ValueInfo *val)
142 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
143 return (t == VTK_PARSE_STRING ||
144 t == VTK_PARSE_UNICODE_STRING);
147 /* -------------------------------------------------------------------- */
150 int vtkWrap_IsBool(ValueInfo *val)
152 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
153 return (t == VTK_PARSE_BOOL);
156 int vtkWrap_IsChar(ValueInfo *val)
158 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
159 return (t == VTK_PARSE_CHAR);
162 int vtkWrap_IsInteger(ValueInfo *val)
164 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
166 if (t != VTK_PARSE_UNSIGNED_CHAR)
168 t = (t & ~VTK_PARSE_UNSIGNED);
172 case VTK_PARSE_SHORT:
175 case VTK_PARSE_ID_TYPE:
176 case VTK_PARSE_LONG_LONG:
177 case VTK_PARSE___INT64:
178 case VTK_PARSE_UNSIGNED_CHAR:
179 case VTK_PARSE_SIGNED_CHAR:
180 case VTK_PARSE_SSIZE_T:
187 int vtkWrap_IsRealNumber(ValueInfo *val)
189 unsigned int t = (val->Type & VTK_PARSE_BASE_TYPE);
190 return (t == VTK_PARSE_FLOAT || t == VTK_PARSE_DOUBLE);
193 /* -------------------------------------------------------------------- */
194 /* These are mutually exclusive, as well. */
196 int vtkWrap_IsScalar(ValueInfo *val)
198 unsigned int i = (val->Type & VTK_PARSE_POINTER_MASK);
202 int vtkWrap_IsPointer(ValueInfo *val)
204 unsigned int i = (val->Type & VTK_PARSE_POINTER_MASK);
205 return (i == VTK_PARSE_POINTER && val->Count == 0 &&
206 val->CountHint == 0 && val->NumberOfDimensions <= 1);
209 int vtkWrap_IsArray(ValueInfo *val)
211 unsigned int i = (val->Type & VTK_PARSE_POINTER_MASK);
212 return (i == VTK_PARSE_POINTER && val->NumberOfDimensions <= 1 &&
213 (val->Count != 0 || val->CountHint != 0));
216 int vtkWrap_IsNArray(ValueInfo *val)
219 unsigned int i = (val->Type & VTK_PARSE_POINTER_MASK);
220 if (i != VTK_PARSE_ARRAY || val->NumberOfDimensions <= 1)
224 for (j = 0; j < val->NumberOfDimensions; j++)
226 if (val->Dimensions[j] == NULL || val->Dimensions[j][0] == '\0')
235 /* -------------------------------------------------------------------- */
236 /* Other type properties, not mutually exclusive. */
238 int vtkWrap_IsNonConstRef(ValueInfo *val)
240 return ((val->Type & VTK_PARSE_REF) != 0 &&
241 (val->Type & VTK_PARSE_CONST) == 0);
244 int vtkWrap_IsConstRef(ValueInfo *val)
246 return ((val->Type & VTK_PARSE_REF) != 0 &&
247 (val->Type & VTK_PARSE_CONST) != 0);
250 int vtkWrap_IsRef(ValueInfo *val)
252 return ((val->Type & VTK_PARSE_REF) != 0);
255 int vtkWrap_IsConst(ValueInfo *val)
257 return ((val->Type & VTK_PARSE_CONST) != 0);
260 /* -------------------------------------------------------------------- */
263 int vtkWrap_IsNewInstance(ValueInfo *val)
265 return ((val->Type & VTK_PARSE_NEWINSTANCE) != 0);
268 /* -------------------------------------------------------------------- */
269 /* Constructor/Destructor checks */
271 int vtkWrap_IsConstructor(ClassInfo *c, FunctionInfo *f)
275 const char *cp = c->Name;
277 if (cp && f->Name && !vtkWrap_IsDestructor(c, f))
279 /* remove namespaces and template parameters from the name */
280 m = vtkParse_UnscopedNameLength(cp);
281 while (cp[m] == ':' && cp[m+1] == ':')
284 m = vtkParse_UnscopedNameLength(cp);
286 for (i = 0; i < m; i++)
294 return (i == strlen(f->Name) && strncmp(cp, f->Name, i) == 0);
300 int vtkWrap_IsDestructor(ClassInfo *c, FunctionInfo *f)
305 if (c->Name && f->Name)
308 for (i = 0; cp[i] != '\0' && cp[i] != '('; i++)
320 int vtkWrap_IsSetVectorMethod(FunctionInfo *f)
322 if (f->Macro && strncmp(f->Macro, "vtkSetVector", 12) == 0)
330 int vtkWrap_IsGetVectorMethod(FunctionInfo *f)
332 if (f->Macro && strncmp(f->Macro, "vtkGetVector", 12) == 0)
340 /* -------------------------------------------------------------------- */
341 /* Argument counting */
343 int vtkWrap_CountWrappedArgs(FunctionInfo *f)
345 int totalArgs = f->NumberOfArguments;
348 (f->Arguments[0]->Type & VTK_PARSE_BASE_TYPE)
349 == VTK_PARSE_FUNCTION)
353 else if (totalArgs == 1 &&
354 (f->Arguments[0]->Type & VTK_PARSE_UNQUALIFIED_TYPE)
363 int vtkWrap_CountRequiredArgs(FunctionInfo *f)
365 int requiredArgs = 0;
369 totalArgs = vtkWrap_CountWrappedArgs(f);
371 for (i = 0; i < totalArgs; i++)
373 if (f->Arguments[i]->Value == NULL ||
374 vtkWrap_IsArray(f->Arguments[i]) ||
375 vtkWrap_IsNArray(f->Arguments[i]))
384 /* -------------------------------------------------------------------- */
385 /* Check whether the class is derived from vtkObjectBase. */
387 int vtkWrap_IsVTKObjectBaseType(
388 HierarchyInfo *hinfo, const char *classname)
390 HierarchyEntry *entry;
394 entry = vtkParseHierarchy_FindEntry(hinfo, classname);
397 if (vtkParseHierarchy_IsTypeOf(hinfo, entry, "vtkObjectBase"))
405 /* fallback if no HierarchyInfo */
406 if (strncmp("vtk", classname, 3) == 0)
414 /* -------------------------------------------------------------------- */
415 /* Check if the WRAP_SPECIAL flag is set for the class. */
417 int vtkWrap_IsSpecialType(
418 HierarchyInfo *hinfo, const char *classname)
420 HierarchyEntry *entry;
424 entry = vtkParseHierarchy_FindEntry(hinfo, classname);
425 if (entry && vtkParseHierarchy_GetProperty(entry, "WRAP_SPECIAL"))
432 /* fallback if no HierarchyInfo */
433 if (strncmp("vtk", classname, 3) == 0)
441 /* -------------------------------------------------------------------- */
442 /* Check if the class is derived from superclass */
444 int vtkWrap_IsTypeOf(
445 HierarchyInfo *hinfo, const char *classname, const char *superclass)
447 HierarchyEntry *entry;
449 if (strcmp(classname, superclass) == 0)
456 entry = vtkParseHierarchy_FindEntry(hinfo, classname);
457 if (entry && vtkParseHierarchy_IsTypeOf(hinfo, entry, superclass))
466 /* -------------------------------------------------------------------- */
467 /* Make a guess about whether a class is wrapped */
469 int vtkWrap_IsClassWrapped(
470 HierarchyInfo *hinfo, const char *classname)
474 HierarchyEntry *entry;
475 entry = vtkParseHierarchy_FindEntry(hinfo, classname);
479 if (!vtkParseHierarchy_GetProperty(entry, "WRAP_EXCLUDE") ||
480 vtkParseHierarchy_GetProperty(entry, "WRAP_SPECIAL"))
486 else if (strncmp("vtk", classname, 3) == 0)
494 /* -------------------------------------------------------------------- */
495 /* Check whether the destructor is public */
496 int vtkWrap_HasPublicDestructor(ClassInfo *data)
501 for (i = 0; i < data->NumberOfFunctions; i++)
503 func = data->Functions[i];
505 if (vtkWrap_IsDestructor(data, func) &&
506 func->Access != VTK_ACCESS_PUBLIC)
515 /* -------------------------------------------------------------------- */
516 /* Check whether the copy constructor is public */
517 int vtkWrap_HasPublicCopyConstructor(ClassInfo *data)
522 for (i = 0; i < data->NumberOfFunctions; i++)
524 func = data->Functions[i];
526 if (vtkWrap_IsConstructor(data, func) &&
527 func->NumberOfArguments == 1 &&
528 func->Arguments[0]->Class &&
529 strcmp(func->Arguments[0]->Class, data->Name) == 0 &&
530 func->Access != VTK_ACCESS_PUBLIC)
539 /* -------------------------------------------------------------------- */
540 /* This sets the CountHint for vtkDataArray methods where the
541 * tuple size is equal to GetNumberOfComponents. */
542 void vtkWrap_FindCountHints(
543 ClassInfo *data, HierarchyInfo *hinfo)
546 const char *countMethod;
547 const char *classname;
548 FunctionInfo *theFunc;
549 HierarchyEntry *entry;
553 /* add hints for array GetTuple methods */
554 if (vtkWrap_IsTypeOf(hinfo, data->Name, "vtkDataArray"))
556 countMethod = "GetNumberOfComponents()";
558 for (i = 0; i < data->NumberOfFunctions; i++)
560 theFunc = data->Functions[i];
562 if ((strcmp(theFunc->Name, "GetTuple") == 0 ||
563 strcmp(theFunc->Name, "GetTupleValue") == 0) &&
564 theFunc->ReturnValue && theFunc->ReturnValue->Count == 0 &&
565 theFunc->NumberOfArguments == 1 &&
566 theFunc->Arguments[0]->Type == VTK_PARSE_ID_TYPE)
568 theFunc->ReturnValue->CountHint = countMethod;
570 else if ((strcmp(theFunc->Name, "SetTuple") == 0 ||
571 strcmp(theFunc->Name, "SetTupleValue") == 0 ||
572 strcmp(theFunc->Name, "GetTuple") == 0 ||
573 strcmp(theFunc->Name, "GetTupleValue") == 0 ||
574 strcmp(theFunc->Name, "InsertTuple") == 0 ||
575 strcmp(theFunc->Name, "InsertTupleValue") == 0) &&
576 theFunc->NumberOfArguments == 2 &&
577 theFunc->Arguments[0]->Type == VTK_PARSE_ID_TYPE &&
578 theFunc->Arguments[1]->Count == 0)
580 theFunc->Arguments[1]->CountHint = countMethod;
582 else if ((strcmp(theFunc->Name, "InsertNextTuple") == 0 ||
583 strcmp(theFunc->Name, "InsertNextTupleValue") == 0) &&
584 theFunc->NumberOfArguments == 1 &&
585 theFunc->Arguments[0]->Count == 0)
587 theFunc->Arguments[0]->CountHint = countMethod;
592 /* add hints for interpolator Interpolate methods */
593 if (vtkWrap_IsTypeOf(hinfo, data->Name, "vtkAbstractImageInterpolator"))
595 countMethod = "GetNumberOfComponents()";
597 for (i = 0; i < data->NumberOfFunctions; i++)
599 theFunc = data->Functions[i];
601 if (strcmp(theFunc->Name, "Interpolate") == 0 &&
602 theFunc->NumberOfArguments == 2 &&
603 theFunc->Arguments[0]->Type == (VTK_PARSE_DOUBLE_PTR|VTK_PARSE_CONST) &&
604 theFunc->Arguments[0]->Count == 3 &&
605 theFunc->Arguments[1]->Type == VTK_PARSE_DOUBLE_PTR &&
606 theFunc->Arguments[1]->Count == 0)
608 theFunc->Arguments[1]->CountHint = countMethod;
613 for (i = 0; i < data->NumberOfFunctions; i++)
615 theFunc = data->Functions[i];
617 /* hints for constructors that take arrays */
618 if (vtkWrap_IsConstructor(data, theFunc) &&
619 theFunc->NumberOfArguments == 1 &&
620 vtkWrap_IsPointer(theFunc->Arguments[0]) &&
621 vtkWrap_IsNumeric(theFunc->Arguments[0]) &&
622 theFunc->Arguments[0]->Count == 0 &&
625 entry = vtkParseHierarchy_FindEntry(hinfo, data->Name);
626 if (entry && vtkParseHierarchy_IsTypeOfTemplated(
627 hinfo, entry, data->Name, "vtkTuple", &classname))
629 /* attempt to get count from template parameter */
632 m = strlen(classname);
633 if (m > 2 && classname[m - 1] == '>' &&
634 isdigit(classname[m-2]) && (classname[m-3] == ' ' ||
635 classname[m-3] == ',' || classname[m-3] == '<'))
637 digit = classname[m-2];
638 theFunc->Arguments[0]->Count = digit - '0';
639 vtkParse_AddStringToArray(
640 &theFunc->Arguments[0]->Dimensions,
641 &theFunc->Arguments[0]->NumberOfDimensions,
642 vtkParse_DuplicateString(&digit, 1));
644 free((char *)classname);
649 /* hints for operator[] index range */
650 if (theFunc->IsOperator && theFunc->Name &&
651 strcmp(theFunc->Name, "operator[]") == 0)
653 if (vtkWrap_IsTypeOf(hinfo, data->Name, "vtkTuple"))
655 theFunc->SizeHint = "GetSize()";
657 else if (vtkWrap_IsTypeOf(hinfo, data->Name, "vtkArrayCoordinates") ||
658 vtkWrap_IsTypeOf(hinfo, data->Name, "vtkArrayExtents") ||
659 vtkWrap_IsTypeOf(hinfo, data->Name, "vtkArraySort"))
661 theFunc->SizeHint = "GetDimensions()";
663 else if (vtkWrap_IsTypeOf(hinfo, data->Name, "vtkArrayExtentsList") ||
664 vtkWrap_IsTypeOf(hinfo, data->Name, "vtkArrayWeights"))
666 theFunc->SizeHint = "GetCount()";
672 /* -------------------------------------------------------------------- */
673 /* This sets the NewInstance hint for generator methods. */
674 void vtkWrap_FindNewInstanceMethods(
675 ClassInfo *data, HierarchyInfo *hinfo)
678 FunctionInfo *theFunc;
680 for (i = 0; i < data->NumberOfFunctions; i++)
682 theFunc = data->Functions[i];
683 if (theFunc->Name && theFunc->ReturnValue &&
684 vtkWrap_IsVTKObject(theFunc->ReturnValue) &&
685 vtkWrap_IsVTKObjectBaseType(hinfo, theFunc->ReturnValue->Class))
687 if (strcmp(theFunc->Name, "NewInstance") == 0 ||
688 strcmp(theFunc->Name, "CreateInstance") == 0 ||
689 (strcmp(theFunc->Name, "CreateImageReader2") == 0 &&
690 strcmp(data->Name, "vtkImageReader2Factory") == 0) ||
691 (strcmp(theFunc->Name, "CreateDataArray") == 0 &&
692 strcmp(data->Name, "vtkDataArray") == 0) ||
693 (strcmp(theFunc->Name, "CreateArray") == 0 &&
694 strcmp(data->Name, "vtkAbstractArray") == 0) ||
695 (strcmp(theFunc->Name, "CreateArray") == 0 &&
696 strcmp(data->Name, "vtkArray") == 0) ||
697 (strcmp(theFunc->Name, "GetQueryInstance") == 0 &&
698 strcmp(data->Name, "vtkSQLDatabase") == 0) ||
699 (strcmp(theFunc->Name, "CreateFromURL") == 0 &&
700 strcmp(data->Name, "vtkSQLDatabase") == 0) ||
701 (strcmp(theFunc->Name, "MakeTransform") == 0 &&
702 vtkWrap_IsTypeOf(hinfo, data->Name, "vtkAbstractTransform")))
704 theFunc->ReturnValue->Type |= VTK_PARSE_NEWINSTANCE;
711 /* -------------------------------------------------------------------- */
712 /* Expand all typedef types that are used in function arguments */
713 void vtkWrap_ExpandTypedefs(ClassInfo *data, HierarchyInfo *hinfo)
716 FunctionInfo *funcInfo;
717 const char *newclass;
719 n = data->NumberOfSuperClasses;
720 for (i = 0; i < n; i++)
722 newclass = vtkParseHierarchy_ExpandTypedefsInName(
723 hinfo, data->SuperClasses[i], NULL);
724 if (newclass != data->SuperClasses[i])
726 data->SuperClasses[i] =
727 vtkParse_DuplicateString(newclass, strlen(newclass));
728 free((char *)newclass);
732 n = data->NumberOfFunctions;
733 for (i = 0; i < n; i++)
735 funcInfo = data->Functions[i];
736 if (funcInfo->Access == VTK_ACCESS_PUBLIC)
738 for (j = 0; j < funcInfo->NumberOfArguments; j++)
740 vtkParseHierarchy_ExpandTypedefsInValue(
741 hinfo, funcInfo->Arguments[j], data->Name);
743 if (funcInfo->ReturnValue)
745 vtkParseHierarchy_ExpandTypedefsInValue(
746 hinfo, funcInfo->ReturnValue, data->Name);
753 /* -------------------------------------------------------------------- */
754 /* get the type name */
756 const char *vtkWrap_GetTypeName(ValueInfo *val)
758 unsigned int aType = val->Type;
759 const char *aClass = val->Class;
761 /* print the type itself */
762 switch (aType & VTK_PARSE_BASE_TYPE)
764 case VTK_PARSE_FLOAT: return "float";
765 case VTK_PARSE_DOUBLE: return "double";
766 case VTK_PARSE_INT: return "int";
767 case VTK_PARSE_SHORT: return "short";
768 case VTK_PARSE_LONG: return "long";
769 case VTK_PARSE_VOID: return "void ";
770 case VTK_PARSE_CHAR: return "char";
771 case VTK_PARSE_UNSIGNED_INT: return "unsigned int";
772 case VTK_PARSE_UNSIGNED_SHORT: return "unsigned short";
773 case VTK_PARSE_UNSIGNED_LONG: return "unsigned long";
774 case VTK_PARSE_UNSIGNED_CHAR: return "unsigned char";
775 case VTK_PARSE_ID_TYPE: return "vtkIdType";
776 case VTK_PARSE_LONG_LONG: return "long long";
777 case VTK_PARSE___INT64: return "__int64";
778 case VTK_PARSE_UNSIGNED_LONG_LONG: return "unsigned long long";
779 case VTK_PARSE_UNSIGNED___INT64: return "unsigned __int64";
780 case VTK_PARSE_SIGNED_CHAR: return "signed char";
781 case VTK_PARSE_BOOL: return "bool";
782 case VTK_PARSE_UNICODE_STRING: return "vtkUnicodeString";
783 case VTK_PARSE_SSIZE_T: return "ssize_t";
784 case VTK_PARSE_SIZE_T: return "size_t";
790 /* -------------------------------------------------------------------- */
791 /* variable declarations */
793 void vtkWrap_DeclareVariable(
794 FILE *fp, ValueInfo *val, const char *name, int i, int flags)
804 aType = (val->Type & VTK_PARSE_UNQUALIFIED_TYPE);
806 /* do nothing for void */
807 if (aType == VTK_PARSE_VOID ||
808 (aType & VTK_PARSE_BASE_TYPE) == VTK_PARSE_FUNCTION)
813 /* add a couple spaces */
816 /* for const * return types, prepend with const */
817 if ((flags & VTK_WRAP_RETURN) != 0)
819 if ((val->Type & VTK_PARSE_CONST) != 0 &&
820 (aType & VTK_PARSE_INDIRECT) != 0)
822 fprintf(fp,"const ");
825 /* do the same for "const char *" with initializer */
828 if ((val->Type & VTK_PARSE_CONST) != 0 &&
829 aType == VTK_PARSE_CHAR_PTR &&
831 strcmp(val->Value, "0") != 0 &&
832 strcmp(val->Value, "NULL") != 0)
834 fprintf(fp,"const ");
838 /* print the type name */
839 fprintf(fp, "%s ", vtkWrap_GetTypeName(val));
842 if ((flags & VTK_WRAP_RETURN) != 0)
844 /* ref and pointer return values are stored as pointers */
845 if ((aType & VTK_PARSE_INDIRECT) == VTK_PARSE_POINTER ||
846 (aType & VTK_PARSE_INDIRECT) == VTK_PARSE_REF)
853 /* objects refs and pointers are always handled via pointers,
854 * other refs are passed by value */
855 if (aType == VTK_PARSE_CHAR_PTR ||
856 aType == VTK_PARSE_VOID_PTR ||
857 aType == VTK_PARSE_OBJECT_PTR ||
858 aType == VTK_PARSE_OBJECT_REF ||
859 aType == VTK_PARSE_OBJECT ||
860 vtkWrap_IsQtObject(val))
864 /* arrays of unknown size are handled via pointers */
865 else if (val->CountHint)
871 /* the variable name */
874 fprintf(fp,"%s%i", name, i);
878 fprintf(fp,"%s", name);
881 if ((flags & VTK_WRAP_ARG) != 0)
883 /* print the array decorators */
884 if (((aType & VTK_PARSE_POINTER_MASK) != 0) &&
885 aType != VTK_PARSE_CHAR_PTR &&
886 aType != VTK_PARSE_VOID_PTR &&
887 aType != VTK_PARSE_OBJECT_PTR &&
888 !vtkWrap_IsQtObject(val) &&
889 val->CountHint == NULL)
891 if (val->NumberOfDimensions == 1 && val->Count > 0)
893 fprintf(fp, "[%d]", val->Count);
897 for (j = 0; j < val->NumberOfDimensions; j++)
899 fprintf(fp, "[%s]", val->Dimensions[j]);
904 /* add a default value */
907 fprintf(fp, " = %s", val->Value);
909 else if (aType == VTK_PARSE_CHAR_PTR ||
910 aType == VTK_PARSE_VOID_PTR ||
911 aType == VTK_PARSE_OBJECT_PTR ||
912 aType == VTK_PARSE_OBJECT_REF ||
913 aType == VTK_PARSE_OBJECT ||
914 vtkWrap_IsQtObject(val))
916 fprintf(fp, " = NULL");
918 else if (val->CountHint)
920 fprintf(fp, " = NULL");
922 else if (aType == VTK_PARSE_BOOL)
924 fprintf(fp, " = false");
928 /* finish off with a semicolon */
929 if ((flags & VTK_WRAP_NOSEMI) == 0)
935 void vtkWrap_DeclareVariableSize(
936 FILE *fp, ValueInfo *val, const char *name, int i)
944 sprintf(idx, "%d", i);
947 if (val->NumberOfDimensions > 1)
950 " static int %s%s[%d] = ",
951 name, idx, val->NumberOfDimensions);
953 for (j = 0; j < val->NumberOfDimensions; j++)
955 fprintf(fp, "%c %s", ((j == 0) ? '{' : ','), val->Dimensions[j]);
958 fprintf(fp, " };\n");
960 else if (val->Count != 0 || val->CountHint)
963 " %sint %s%s = %d;\n",
964 (val->CountHint ? "" : "const "), name, idx,
965 (val->CountHint ? 0 : val->Count));
967 else if (val->NumberOfDimensions == 1)
970 " const int %s%s = %s;\n",
971 name, idx, val->Dimensions[0]);