fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / fcd2code / Field.py
blob1d8827fedbfbd181279b58ecfb724b6f1cbd6468
2 import re;
3 import logging;
5 from FCDElement import FCDElement;
7 podTable = {
8 "bool" : True,
10 "Char8" : True,
11 "UChar8" : True,
12 "SChar8" : True,
14 "UInt8" : True,
15 "Int8" : True,
17 "UInt16" : True,
18 "Int16" : True,
20 "UInt32" : True,
21 "Int32" : True,
23 "UInt64" : True,
24 "Int64" : True,
26 "Real16" : True,
27 "Real32" : True,
28 "Real64" : True,
29 "Real128" : True,
31 "Real" : True
34 includeTable = {
35 "Bool" : "Sys",
36 "Int8" : "Sys",
37 "UInt8" : "Sys",
38 "Int16" : "Sys",
39 "UInt16" : "Sys",
40 "Int32" : "Sys",
41 "UInt32" : "Sys",
42 "Int64" : "Sys",
43 "UInt64" : "Sys",
44 "Real16" : "Sys",
45 "Real32" : "Sys",
46 "Fixed32" : "Sys",
47 "Real64" : "Sys",
48 "Real" : "Sys",
50 "Color3f" : "Base",
51 "Color3r" : "Base",
52 "Color3fx" : "Base",
53 "Color4f" : "Base",
54 "Color4r" : "Base",
55 "Color4fx" : "Base",
56 "Color3ub" : "Base",
57 "Color4ub" : "Base",
58 "String" : "Base",
59 "Time" : "Base",
60 "BoxVolume" : "Base",
61 "BitVector" : "Base",
62 "GLenum" : "Base",
63 "Plane" : "Base",
64 "RenderPropBitVector" : "Base",
66 "Matrix" : "Math",
67 "Matrixr" : "Math",
68 "Matrix4d" : "Math",
69 "Matrix4fx" : "Math",
70 "Quaternion" : "Math",
71 "Quaternionr" : "Math",
72 "Quaternionfx" : "Math",
74 "Vec2ub" : "Vec",
75 "Vec2b" : "Vec",
76 "Vec2us" : "Vec",
77 "Vec2s" : "Vec",
78 "Vec2u" : "Vec",
79 "Vec2i" : "Vec",
80 "Vec2f" : "Vec",
81 "Vec2r" : "Vec",
82 "Vec2fx" : "Vec",
83 "Vec2d" : "Vec",
84 "Vec2ld" : "Vec",
86 "Vec3ub" : "Vec",
87 "Vec3b" : "Vec",
88 "Vec3us" : "Vec",
89 "Vec3s" : "Vec",
90 "Vec3u" : "Vec",
91 "Vec3i" : "Vec",
92 "Vec3f" : "Vec",
93 "Vec3r" : "Vec",
94 "Vec3fx" : "Vec",
95 "Vec3d" : "Vec",
96 "Vec3ld" : "Vec",
98 "Vec4ub" : "Vec",
99 "Vec4b" : "Vec",
100 "Vec4us" : "Vec",
101 "Vec4s" : "Vec",
102 "Vec4u" : "Vec",
103 "Vec4i" : "Vec",
104 "Vec4f" : "Vec",
105 "Vec4r" : "Vec",
106 "Vec4fx" : "Vec",
107 "Vec4d" : "Vec",
108 "Vec4ld" : "Vec",
110 "Pnt2ub" : "Vec",
111 "Pnt2b" : "Vec",
112 "Pnt2us" : "Vec",
113 "Pnt2s" : "Vec",
114 "Pnt2f" : "Vec",
115 "Pnt2r" : "Vec",
116 "Pnt2fx" : "Vec",
117 "Pnt2d" : "Vec",
118 "Pnt2ld" : "Vec",
120 "Pnt3ub" : "Vec",
121 "Pnt3b" : "Vec",
122 "Pnt3us" : "Vec",
123 "Pnt3s" : "Vec",
124 "Pnt3f" : "Vec",
125 "Pnt3r" : "Vec",
126 "Pnt3fx" : "Vec",
127 "Pnt3d" : "Vec",
128 "Pnt3ld" : "Vec",
131 "Pnt4ub" : "Vec",
132 "Pnt4b" : "Vec",
133 "Pnt4us" : "Vec",
134 "Pnt4s" : "Vec",
135 "Pnt4f" : "Vec",
136 "Pnt4r" : "Vec",
137 "Pnt4fx" : "Vec",
138 "Pnt4d" : "Vec",
139 "Pnt4ld" : "Vec",
141 "VoidP" : "Sys"
144 class Field(FCDElement):
145 """Represents a <Field/> element from a .fcd file.
148 def __init__(self):
149 super(Field, self).__init__();
150 self.m_log = logging.getLogger("Field");
151 self.m_fieldContainer = None;
152 self.initFCDDict();
154 def initFCDDict(self):
155 """Sets the fcd dictionary to default values.
157 self.setFCD("name", "", True);
158 self.setFCD("category", "", True);
159 self.setFCD("type", "", True);
160 self.setFCD("pointerType", "", True);
161 self.setFCD("typeNamespace", "", True);
162 self.setFCD("cardinality", "", True);
163 self.setFCD("visibility", "external", True);
164 self.setFCD("fieldFlags", "", True);
165 self.setFCD("defaultValue", "", True);
166 self.setFCD("access", "public", True);
167 self.setFCD("defaultHeader", "", True);
168 self.setFCD("fieldHeader", "(AUTO)", True);
169 self.setFCD("typeHeader", "(AUTO)", True);
170 self.setFCD("description", "", True);
171 self.setFCD("linkSParent", "false", True);
172 self.setFCD("linkMParent", "false", True);
173 self.setFCD("removeTo", "", True);
174 self.setFCD("removeToSet", "false", True);
175 self.setFCD("pod", "(AUTO)", True);
176 self.setFCD("storeless", "false", True);
177 self.setFCD("virtual", "false", True);
178 self.setFCD("publicRead", "false", True);
180 self.setFCD("clearMField", "true", True);
182 # are mf access functions for ptr field available (they might be user generated)
183 self.setFCD("hasPushToField", "false", True);
184 self.setFCD("hasAssignMField", "false", True);
185 self.setFCD("hasInsertIntoMField", "false", True);
186 self.setFCD("hasReplaceInMFieldIndex", "false", True);
187 self.setFCD("hasReplaceInMFieldObject", "false", True);
188 self.setFCD("hasRemoveFromMFieldIndex", "false", True);
189 self.setFCD("hasRemoveFromMFieldObject", "false", True);
190 self.setFCD("hasClearField", "false", True);
192 # names of the mf access functions for ptr field
193 self.setFCD("pushToFieldAs", "", True);
194 self.setFCD("assignMFieldAs", "", True);
195 self.setFCD("insertIntoMFieldAs", "", True);
196 self.setFCD("replaceInMFieldIndexAs", "", True);
197 self.setFCD("replaceInMFieldObjectAs", "", True);
198 self.setFCD("removeFromMFieldIndexAs", "", True);
199 self.setFCD("removeFromMFieldObjectAs", "", True);
200 self.setFCD("clearFieldAs", "", True);
202 self.setFCD("ptrFieldAccess", "std", True);
204 self.setFCD("disallowNULL", "false", True);
205 self.setFCD("childParentType", "", True);
206 self.setFCD("linkParentField", "XX", True);
208 self.setFCD("interfaceType", "", True);
209 self.setFCD("customBinCopy", "false", True);
210 self.setFCD("customSync", "false", True);
212 self.setFCD("fromNamespace", "OSG", True);
214 self.setFCD("osg2Ignore", "false", True);
216 def setFieldContainer(self, container):
217 self.m_fieldContainer = container;
219 def getFieldContainer(self):
220 return self.m_fieldContainer;
223 # Common tests
225 def isProtected(self):
226 return self["access"] == "protected";
228 def isPublic(self):
229 return self["access"] == "public";
231 def isPublicRead(self):
232 return self["publicRead"] == "true" or self.isPublic();
234 def isPublicWrite(self):
235 return self.isPublic();
237 def hasAccess(self):
238 return self["access"] != "none";
240 def isSField(self):
241 return self["isSField"];
243 def isMField(self):
244 return self["isMField"];
246 def isPtrField(self):
247 return self["category"] == "pointer";
249 def isChildField(self):
250 return self["pointertype"] == "child";
252 def isParentField(self):
253 return self["pointertype"] == "parent";
256 # Fill out dictionary from in (fcd) dictionary
258 def finalize(self):
260 # make sure old files work
261 if self.getFCD("category") == "":
262 if self.getFCD("type").endswith("Ptr"):
263 self.setFCD("category", "pointer");
264 self.setFCD("type", self.getFCD("type")[:-3]);
266 typeStart = self.getFCD("type").rfind("::");
268 if typeStart != -1:
269 self.setFCD("typeNamespace", self.getFCD("type")[:typeStart]);
270 self.setFCD("type", self.getFCD("type")[typeStart+2:]);
272 self["isStoreless"] = self.getFCD("storeless") == "True";
274 # -----------------------------------------------------------------
275 # Type and Namespace
276 # -----------------------------------------------------------------
278 TypeRaw = self.getFCD("type");
279 TypeRawCaps = self._upcaseFirst(TypeRaw);
281 Type = self.getFCD("type");
282 TypeNS = self.getFCD("typeNamespace");
283 TypeCaps = self._upcaseFirst(Type);
285 self.nsFilePrefix = ""
287 if TypeNS != "" and \
288 TypeNS == self.m_fieldContainer.getFCD("libnamespace") and \
289 TypeNS != "OSG" and \
290 TypeNS != "std" :
292 self.nsFilePrefix = TypeNS
293 TypeNS = ""
295 if TypeNS != "" and not TypeNS.endswith("::"):
296 TypeNS = TypeNS + "::"
298 # -----------------------------------------------------------------
299 # Category
300 # -----------------------------------------------------------------
302 self["category"] = "";
303 self["pointertype"] = "";
304 self["pointerbasetype"] = "";
305 self["isChildField"] = False
306 self["isParentField"] = False
308 if self.getFCD("category") == "data" or self.getFCD("category") == "":
309 self.m_log.info("finalize: \"category\" is empty, assuming \"data\"");
310 FieldType = Type;
311 FieldTypeNS = TypeNS;
312 FieldTypeCaps = TypeCaps;
314 elif self.getFCD("category") == "pointer":
315 self["category"] = "pointer";
316 self["pointertype"] = "internal";
318 TypeCaps = self._upcaseFirst(Type + "Ptr");
319 Type = Type + " *";
320 FieldType = "Unrec" + TypeRaw + "Ptr"; # + "InternalPtr";
321 FieldTypeNS = TypeNS;
322 FieldTypeCaps = "Unrec" + TypeRawCaps + "Ptr"; # + "InternalPtr";
324 elif self.getFCD("category") == "recpointer":
325 self["category"] = "pointer";
326 self["pointertype"] = "internal";
328 TypeCaps = self._upcaseFirst(Type + "Ptr");
329 Type = Type + " *";
330 FieldType = "Rec" + TypeRaw + "Ptr"; # + "InternalPtr";
331 FieldTypeNS = TypeNS;
332 FieldTypeCaps = "Rec" + TypeRawCaps + "Ptr"; # + "InternalPtr";
334 elif self.getFCD("category") == "childpointer":
335 self["category"] = "pointer";
336 self["pointertype"] = "child";
337 self["isChildField"] = True
339 if self.getFCD("childParentType") == "":
340 self["childparenttype"] = "FieldContainer"
341 else:
342 self["childparenttype"] = self.getFCD("childParentType")
344 TypeCaps = self._upcaseFirst(Type + "Ptr");
345 Type = Type + " *";
346 FieldType = "Unrec" + "Child" + TypeRaw + "Ptr";
347 FieldTypeNS = TypeNS;
348 FieldTypeCaps = "Unrec" + "Child" + TypeRawCaps + "Ptr";
350 elif self.getFCD("category") == "parentpointer":
351 self["category"] = "pointer";
352 self["pointertype"] = "parent";
353 self["isParentField"] = True
355 TypeCaps = self._upcaseFirst(Type);
356 Type = Type + " *";
357 FieldType = "Parent" + TypeRaw + "Ptr";
358 self["FieldTypeRaw"] = TypeRaw + "Ptr";
359 FieldTypeNS = TypeNS;
360 FieldTypeCaps = "Parent" + TypeRawCaps + "Ptr";
362 elif self.getFCD("category") == "weakpointer":
363 self["category"] = "pointer";
364 self["pointertype"] = "weak";
366 TypeCaps = self._upcaseFirst(Type + "Ptr");
367 Type = Type + " *";
368 FieldType = "Weak" + TypeRaw + "Ptr"; #TypeRaw + "WeakPtr";
369 FieldTypeNS = TypeNS;
370 FieldTypeCaps = "Weak" + TypeRawCaps + "Ptr"; #TypeRawCaps + "WeakPtr";
371 elif self.getFCD("category") == "uncountedpointer":
372 self["category"] = "pointer";
373 self["pointertype"] = "uncounted";
375 TypeCaps = self._upcaseFirst(Type + "Ptr");
376 Type = Type + " *";
377 FieldType = "Uncounted" + TypeRaw + "Ptr"; #TypeRaw + "WeakPtr";
378 FieldTypeNS = TypeNS;
379 FieldTypeCaps = "Uncounted" + TypeRawCaps + "Ptr"; #TypeRawCaps + "WeakPtr";
381 elif self.getFCD("category") == "custompointer":
382 self["category"] = "pointer";
383 self["pointertype"] = "internal";
384 Type = Type + " *";
385 FieldType = Type;
386 FieldTypeNS = TypeNS;
387 FieldTypeCaps = TypeCaps;
389 else:
390 self.m_log.warning("finalize: \"category\" has invalid value: >%s<",
391 self.getFCD("category"));
393 if TypeNS == "std::":
394 FieldTypeNS = "";
396 self["Type"] = Type;
397 self["TypeNamespace"] = TypeNS;
398 self["TypeNS"] = TypeNS;
399 self["TypeCaps"] = TypeCaps;
401 if self.getFCD("interfaceType") != "":
402 self["FullType"] = self.getFCD("interfaceType");
403 else:
404 self["FullType"] = TypeNS + Type;
406 self["TypeRaw"] = TypeRaw;
408 self["FieldType"] = FieldType;
409 self["FieldTypeNS"] = FieldTypeNS;
410 self["FieldTypeCaps"] = FieldTypeCaps
412 self["linkParentField"] = self.getFCD("linkParentField");
414 if self.getFCD("customBinCopy") == "" or \
415 self.getFCD("customBinCopy") == "false":
417 self["customBinCopy"] = False
418 else:
419 self["customBinCopy"] = True
421 if self.getFCD("customSync") == "" or \
422 self.getFCD("customSync") == "false":
424 self["customSync"] = False
425 else:
426 self["customSync"] = True
430 # -----------------------------------------------------------------
431 # Name and Cardinality
432 # -----------------------------------------------------------------
434 self["Name"] = self.getFCD("name")[0].upper() + self.getFCD("name")[1:];
435 self["DescName"] = self.getFCD("name");
437 if self.getFCD("name") == "id":
438 self.m_log.warning("finalize: invalid field name: >%s<",
439 self.getFCD("name"))
440 self["Name"] = self["Name"] + "_invalidFieldname"
441 self["DescName"] = self["DescName"] + "_invalidFieldname"
443 self["isSField"] = False;
444 self["isMField"] = False;
446 if self.getFCD("cardinality") == "single":
447 self["cardinality"] = "single"
448 self["isSField"] = True;
449 self["CARD"] = "SF";
450 self["VarName"] = "sf" + self["Name"];
451 elif self.getFCD("cardinality") == "multi":
452 self["cardinality"] = "multi"
453 self["isMField"] = True;
454 self["CARD"] = "MF";
455 self["VarName"] = "mf" + self["Name"];
456 else:
457 self.m_log.warning("finalize: \"cardinality\" has invalid value: %s",
458 self.getFCD("cardinality"));
460 if self.getFCD("access") == "protected":
461 self["access"] = "protected";
462 self["isProtected"] = True;
463 elif self.getFCD("access") == "public":
464 self["access"] = "public";
465 self["isPublic"] = True;
466 elif self.getFCD("access") == "none":
467 self["access"] = "none";
468 self["noAccess"] = True;
469 else:
470 self.m_log.warning("finalize: \"access\" has invalid value: >%s<",
471 self.getFCD("access"));
473 #Public Read
474 if self.getFCD("publicRead") == "true" or self["access"] == "public":
475 self["publicRead"] = "true";
476 self["isPublicRead"] = True;
477 else:
478 self["publicRead"] = "false";
479 self["isPublicRead"] = False;
481 #Public Write
482 if "isPublic" in self and self["access"] == "public" and self["pointertype"] != "parent":
483 self["isPublicWrite"] = True;
484 else:
485 self["isPublicWrite"] = False;
487 if self.getFCD("description").strip() == "":
488 self["Description"] = "";
489 self["SafeDescription"] = "\"\"";
490 else:
491 self["Description"] = self._formatString (self.getFCD("description"), 4)
492 self["SafeDescription"] = self._formatSafeString(self.getFCD("description"), 8)
494 if self["isMField"] == True:
495 self["GenFieldFlags"] = "(Field::MFDefaultFlags"
496 else:
497 self["GenFieldFlags"] = "(Field::SFDefaultFlags"
499 if self.getFCD("linkSParent") == "true":
500 self["linkSParent"] = True;
501 self["GenFieldFlags"] = \
502 self["GenFieldFlags"] + " | Field::FLinkParents"
503 else:
504 self["linkSParent"] = False;
506 if self.getFCD("linkMParent") == "true":
507 self["linkMParent"] = True;
508 self["GenFieldFlags"] = \
509 self["GenFieldFlags"] + " | Field::FLinkParents"
510 else:
511 self["linkMParent"] = False;
515 # if ((self.getFCD("header") == "") or
516 # (self.getFCD("header") == "(AUTO)") ):
517 # if self.getFieldContainer().isSystemComponent():
518 # typeInclude = "OSG";
519 # else:
520 # typeInclude = "OpenSG/OSG";
522 # if includeTable.has_key(TypeRawCaps):
523 # typeInclude = typeInclude + includeTable[TypeRawCaps] + "Fields.h"
524 # else:
525 # typeInclude = typeInclude + TypeRawCaps + "Fields.h"
527 # else:
528 # typeInclude = self.getFCD("header");
530 # self["TypeInclude"] = typeInclude;
533 if self.getFieldContainer().isDecoratable() or \
534 self.getFCD("virtual") == "true":
536 self["MethodType"] = "virtual";
538 else:
540 self["MethodType"] = "";
543 isPod = True
545 if self.getFCD("pod") == "(AUTO)":
547 if podTable.has_key(self.getFCD("type")) == True:
548 isPod = podTable[self.getFCD("type")]
549 else:
550 isPod = False
552 elif self.getFCD("pod") == "false":
553 isPod = False
555 if isPod == True:
556 self["RetConst"] = " ";
557 self["RetRef"] = " ";
558 self["ArgRef"] = "";
559 else:
560 self["RetConst"] = "const";
561 self["RetRef"] = "&";
562 self["ArgRef"] = "&";
564 if self.getFCD("defaultValue") != "":
565 if self["category"] == "pointer" and self["cardinality"] == "single":
566 self["TypedDefault"] = self.getFCD("defaultValue");
567 elif self["category"] == "pointer" and self["cardinality"] == "multi":
568 self["TypedDefault"] = "";
569 else:
570 self["TypedDefault"] = \
571 self["FullType"] + "(" + \
572 self.getFCD("defaultValue") + ")";
573 else:
574 if self["category"] == "pointer" and self["cardinality"] == "single":
575 # self["TypedDefault"] = self["TypeNS"] + self["Type"] + "(NULL)";
576 self["TypedDefault"] = "NULL";
577 else:
578 self["TypedDefault"] = "";
580 if self.getFCD("visibility") == "external":
581 self["Visibility"] = "false";
582 elif self.getFCD("visibility") == "internal":
583 self["Visibility"] = "true";
584 # self["GenFieldFlags"] = \
585 # self["GenFieldFlags"] + " | Field::FInternal"
586 else:
587 self.m_log.warning("finalize: \"visibility\" has invalid value: %s",
588 self.getFCD("visibility"));
590 self["writePushToField"] = False;
591 self["hasPushToField"] = False;
592 self["writeAssignMField"] = False;
593 self["hasAssignMField"] = False;
594 self["writeInsertIntoMField"] = False;
595 self["hasInsertIntoMField"] = False;
596 self["writeReplaceInMFieldIndex"] = False;
597 self["hasRemoveFromMFieldIndex"] = False;
598 self["writeReplaceInMFieldObject"] = False;
599 self["hasReplaceInMFieldObject"] = False;
600 self["writeRemoveFromMFieldIndex"] = False;
601 self["hasRemoveFromMFieldIndex"] = False;
602 self["writeRemoveFromMFieldObject"] = False;
603 self["hasRemoveFromMFieldObject"] = False;
604 self["writeClearField"] = False;
605 self["hasClearField"] = False;
607 self["ptrFieldCustomAccess"] = False;
608 self["ptrFieldNullCheckAccess"] = False;
609 self["ptrFieldStandardAccess"] = False;
611 if self.getFCD("ptrFieldAccess") == "std":
612 self["ptrFieldStandardAccess"] = True;
613 self["writePushToField"] = True;
614 self["hasPushToField"] = True;
615 self["writeRemoveFromMFieldIndex"] = True;
616 self["hasRemoveFromMFieldIndex"] = True;
617 self["writeRemoveFromMFieldObject"] = True;
618 self["hasRemoveFromMFieldObject"] = True;
619 self["writeClearField"] = True;
620 self["hasClearField"] = True;
621 self["writeAssignMField"] = True;
622 self["hasAssignMField"] = True;
624 elif self.getFCD("ptrFieldAccess") == "nullCheck":
625 self["ptrFieldNullCheckAccess"] = True;
626 self["writePushToField"] = True;
627 self["hasPushToField"] = True;
628 self["writeAssignMField"] = True;
629 self["hasAssignMField"] = True;
630 self["writeInsertIntoMField"] = True;
631 self["hasInsertIntoMField"] = True;
632 self["writeReplaceInMFieldIndex"] = True;
633 self["hasReplaceInMFieldIndex"] = True;
634 self["writeReplaceInMFieldObject"] = True;
635 self["hasReplaceInMFieldObject"] = True;
636 self["writeRemoveFromMFieldIndex"] = True;
637 self["hasRemoveFromMFieldIndex"] = True;
638 self["writeRemoveFromMFieldObject"] = True;
639 self["hasRemoveFromMFieldObject"] = True;
640 self["writeClearField"] = True;
641 self["hasClearField"] = True;
643 elif self.getFCD("ptrFieldAccess") == "custom":
644 self["ptrFieldCustomAccess"] = True;
645 self["hasPushToField"] = (self.getFCD("hasPushToField") == "true" or
646 self.getFCD("pushToFieldAs") != "" );
647 self["hasAssignMField"] = (self.getFCD("hasAssignMField") == "true" or
648 self.getFCD("assignMFieldAs") != "" );
649 self["hasInsertIntoMField"] = (self.getFCD("hasInsertIntoMField") == "true" or
650 self.getFCD("insertIntoMFieldAs") != "" );
651 self["hasReplaceInMFieldIndex"] = (self.getFCD("hasReplaceInMFieldIndex") == "true" or
652 self.getFCD("replaceInMFieldIndexAs") != "" );
653 self["hasReplaceInMFieldObject"] = (self.getFCD("hasReplaceInMFieldObject") == "true" or
654 self.getFCD("replaceInMFieldObjectAs") != "" );
655 self["hasRemoveFromMFieldIndex"] = (self.getFCD("hasRemoveFromMFieldIndex") == "true" or
656 self.getFCD("removeFromMFieldIndexAs") != "" );
657 self["hasRemoveFromMFieldObject"] = (self.getFCD("hasRemoveFromMFieldObject") == "true" or
658 self.getFCD("removeFromMFieldObjectAs") != "" );
659 self["hasClearField"] = (self.getFCD("hasClearField") == "true" or
660 self.getFCD("clearFieldAs") != "" );
662 else:
663 print "Unknown pointer field acess mode ", self.getFCD("ptrFieldAccess")
664 sys.exit(1)
666 if self["ptrFieldStandardAccess"]:
667 self["GenFieldFlags"] += " | Field::FStdAccess";
668 elif self["ptrFieldNullCheckAccess"]:
669 self["GenFieldFlags"] += " | Field::FNullCheckAccess";
670 elif self["ptrFieldCustomAccess"]:
671 self["GenFieldFlags"] += " | Field::FCustomAccess";
673 self["GenFieldFlags"] = self["GenFieldFlags"] + ")"
674 # No changes to GenFieldFlags past this point!
676 if self.getFCD("pushToFieldAs") != "":
677 self["PushToField"] = self.getFCD("pushToFieldAs");
678 else:
679 self["PushToField"] = "pushTo" + self["Name"];
683 if self.getFCD("assignMFieldAs") != "":
684 self["AssignMField"] = self.getFCD("assignMFieldAs");
685 else:
686 self["AssignMField"] = "assign" + self["Name"];
690 if self.getFCD("insertIntoMFieldAs") != "":
691 self["InsertIntoMField"] = self.getFCD("insertIntoMFieldAs");
692 else:
693 self["InsertIntoMField"] = "insertInto" + self["Name"];
697 if self.getFCD("replaceInMFieldIndexAs") != "":
698 self["ReplaceInMFieldIndex"] = self.getFCD("replaceInMFieldIndexAs");
699 else:
700 self["ReplaceInMFieldIndex"] = "replaceIn" + self["Name"];
704 if self.getFCD("replaceInMFieldObjectAs") != "":
705 self["ReplaceInMFieldObject"] = self.getFCD("replaceInMFieldObjectAs");
706 else:
707 self["ReplaceInMFieldObject"] = "replaceObjIn" + self["Name"];
711 if self.getFCD("removeFromMFieldIndexAs") != "":
712 self["RemoveFromMFieldIndex"] = self.getFCD("removeFromMFieldIndexAs");
713 else:
714 self["RemoveFromMFieldIndex"] = "removeFrom" + self["Name"];
718 if self.getFCD("removeFromMFieldObjectAs") != "":
719 self["RemoveFromMFieldObject"] = self.getFCD("removeFromMFieldObjectAs");
720 else:
721 self["RemoveFromMFieldObject"] = "removeObjFrom" + self["Name"];
725 if self.getFCD("clearFieldAs") != "":
726 self["ClearField"] = self.getFCD("clearFieldAs");
727 else:
728 self["ClearField"] = "clear" + self["Name"];
733 if self.getFCD("removeTo") != "":
734 self.setFCD("removeToSet", True);
735 self["isRemoveToSet"] = True;
736 self["RemoveTo"] = self.getFCD("removeTo");
737 else:
738 self.setFCD("removeToSet", False);
739 self["isRemoveToSet"] = False;
741 if self.getFCD("clearMField") == "true":
742 self["doClearMField"] = True;
743 else:
744 self["doClearMField"] = False;
747 fieldFlagsOverride = False;
748 flags = None,
750 if self.isSField():
751 if self.getFCD("fieldFlags") != "":
752 fieldFlagsOverride = True;
753 else:
754 flags = self["GenFieldFlags"];
756 elif self.isMField():
757 if self.getFCD("fieldFlags") != "":
758 fieldFlagsOverride = True;
759 else:
760 flags = self["GenFieldFlags"];
762 if fieldFlagsOverride:
763 flagsFCD = self.getFCD("fieldFlags").split(",");
764 numFlags = len(flagsFCD);
766 flags = "(";
768 for i, flag in enumerate(flagsFCD):
769 flag = flag.replace(" ", "");
770 flag = flag.replace("\t", "");
771 flag = flag.replace("\n", "");
773 if (i == 0) and (i != numFlags - 1):
774 flags = flags + "Field::" + flag + " |";
775 continue;
777 if i == numFlags - 1:
778 if i != 0:
779 flags = flags + " Field::" + flag;
780 else:
781 flags = flags + "Field::" + flag;
783 continue;
785 flags = flags + " Field::" + flag + " |";
787 flags = flags + ")";
789 self["Flags"] = flags;
791 # Headers
793 if self.getFCD("defaultHeader") != "":
794 self["needDefaultInclude"] = True;
796 if ((self.getFCD("defaultHeader").find("\"") == -1) and
797 (self.getFCD("defaultHeader").find("<") == -1) ):
798 self["DefaultInclude"] = "\"" + self.getFCD("defaultHeader") + "\"";
799 else:
800 self["DefaultInclude"] = self.getFCD("defaultHeader");
801 else:
802 self["needDefaultInclude"] = False;
805 fieldInclude = "";
807 if ((self.getFCD("fieldHeader") == "" ) or
808 (self.getFCD("fieldHeader") == "(AUTO)") ):
810 if self.getFieldContainer().isSystemComponent():
811 fieldInclude = "OSG" + self.nsFilePrefix
812 else:
813 fieldInclude = "OpenSG/OSG" + self.nsFilePrefix
815 if includeTable.has_key(TypeRawCaps):
816 fieldInclude = "\"" + fieldInclude + includeTable[TypeRawCaps] + "Fields.h" + "\""
817 else:
818 fieldInclude = "\"" + fieldInclude + TypeRawCaps + "Fields.h" + "\""
820 else:
821 if ((self.getFCD("fieldHeader").find("\"") == -1) and
822 (self.getFCD("fieldHeader").find("<") == -1) ):
823 fieldInclude = "\"" + self.getFCD("fieldHeader") + "\"";
824 else:
825 fieldInclude = self.getFCD("fieldHeader");
827 self["FieldInclude"] = fieldInclude
828 self["needFieldInclude"] = True;
831 typeInclude = "";
833 if self["category"] == "pointer":
834 if ((self.getFCD("typeHeader") == "") or
835 (self.getFCD("typeHeader") == "(AUTO)") ):
837 if self.getFieldContainer().isSystemComponent():
838 typeInclude = "OSG" + self.nsFilePrefix;
839 else:
840 typeInclude = "OpenSG/OSG" + self.nsFilePrefix;
842 typeInclude = typeInclude + TypeRawCaps;
844 typeInclude = typeInclude.replace("Parent", "");
845 typeInclude = "\"" + typeInclude + ".h" + "\""
847 else:
848 if ((self.getFCD("typeHeader").find("\"") == -1) and
849 (self.getFCD("typeHeader").find("<") == -1) ):
850 typeInclude = "\"" + self.getFCD("typeHeader") + "\"";
851 else:
852 typeInclude = self.getFCD("typeHeader");
854 self["TypeInclude"] = typeInclude;
855 self["needTypeInclude"] = True;
857 else:
858 self["TypeInclude"] = None
859 self["needTypeInclude"] = False
862 # hack for now
863 if self.isPtrField():
864 self["isPtrField"] = True;
867 def _dumpValues(self):
868 self.m_log.info("Field dumpValues:");
869 super(Field, self)._dumpValues(self.m_log);