1- header = """
1+ header = """
22/********************************************************************************
33 * *
44 * This file is part of IfcOpenShell. *
@@ -131,6 +131,7 @@ def __init__(self,l):
131131 self .type = express_to_cpp .get (l [3 ],l [3 ])
132132 self .upper = l [2 ]
133133 self .lower = l [1 ]
134+ def is_select_list (self ): return self .type in selections
134135 def __str__ (self ):
135136 if self .type in entity_names :
136137 return "SHARED_PTR< IfcTemplatedEntityList<%s> >" % self .type
@@ -162,6 +163,7 @@ def type_enum(self):
162163class ScalarType :
163164 def __init__ (self ,l ): self .type = express_to_cpp .get (l ,l )
164165 def __str__ (self ): return self .type
166+ def is_select_list (self ): return False
165167 def type_enum (self ):
166168 if self .type in simple_types :
167169 return simple_types [self .type ].type_enum ()
@@ -179,7 +181,8 @@ def __str__(self):
179181 elif generator_mode == 'SOURCE_TO' :
180182 return '{ "%s" }' % '","' .join ([v1 for v1 ,v2 in self .v ])
181183 elif generator_mode == 'SOURCE_FROM' :
182- return "" .join ([' if(s=="%s"%s) return %s::%s;\n ' % (v1 .upper ()," " * (self .maxlen - len (v1 )),"%(name)s" ,v2 ) for v1 ,v2 in self .v ])
184+ return "" .join ([' if(s=="%s"%s) return %s::%s;\n ' % (v1 .upper ()," " * (self .maxlen - len (v1 )),"%(name)s" ,v2 ) for v1 ,v2 in self .v ])
185+ def is_select_list (self ): return False
183186 def __len__ (self ): return len (self .v )
184187 def type_enum (self ):
185188 return "Argument_ENUMERATION"
@@ -188,15 +191,18 @@ def __init__(self,l):
188191 for x in l :
189192 if x in simple_types : selectable_simple_types .add (x )
190193 def __str__ (self ): return "IfcSchemaEntity"
194+ def is_select_list (self ): return False
191195 def type_enum (self ): return "Argument_ENTITY"
192196class BinaryType :
193197 def __init__ (self ,l ): self .l = int (l )
194198 def __str__ (self ): return "char[%s]" % self .l
199+ def is_select_list (self ): return False
195200 def type_enum (self ): raise NotImplementedError ()
196201class InverseType :
197202 def __init__ (self ,l ):
198203 self .name , self .type , self .reference = l
199- def type_enum (self ): return "Argument_ENTITY"
204+ def type_enum (self ): return "Argument_ENTITY"
205+ def is_select_list (self ): return False
200206class Typedef :
201207 def __init__ (self ,l ):
202208 self .name ,self .type = l [1 :3 ]
@@ -228,7 +234,10 @@ def __init__(self,l):
228234 self .name , self .optional , self .type = l
229235 def is_enum (self ): return str (self .type ) in enumerations
230236 def type_str (self ):
231- if str (self .type ) in entity_names :
237+ if self .type .is_select_list ():
238+ # This is extremely hackish indeed
239+ return "IfcEntities"
240+ elif str (self .type ) in entity_names :
232241 return "%(type)s*" % self .__dict__
233242 else :
234243 return "%(type)s::%(type)s" % self .__dict__ if self .is_enum () else self .type
@@ -341,7 +350,7 @@ def get_constructor_implementation(self):
341350 i = len (s ) + 1
342351 b = 0
343352 for a in self .arguments .l :
344- generalize = "->generalize()" if (isinstance (a .type ,ArrayType ) and a .type .is_shared_ptr ()) else ""
353+ generalize = "->generalize()" if (isinstance (a .type ,ArrayType ) and a .type .is_shared_ptr () and not a . type . is_select_list () ) else ""
345354 if isinstance (a .type ,BinaryType ) or (isinstance (a .type ,ArrayType ) and isinstance (a .type .type ,BinaryType )):
346355 continue
347356 s .append ("e->setArgument(%d,v%d_%s%s)" % (b + i - 1 ,b + i ,a .name ,generalize ))
0 commit comments