Update codegen

This commit is contained in:
Thomas Krijnen
2025-02-21 16:13:21 +01:00
parent da4e86a1d5
commit fb1d78b311
2 changed files with 13 additions and 13 deletions
@@ -119,7 +119,7 @@ class Implementation(codegen.Base):
null_check = ""
if arg["is_optional"]:
attr_check = (
"if(data_.get_attribute_value(%d).isNull()) { return %%s; }"
"if(get_attribute_value(%d).isNull()) { return %%s; }"
% (arg["index"] - 1,)
)
if "boost::optional" in arg["full_type"]:
@@ -246,9 +246,9 @@ class Implementation(codegen.Base):
)
superclass_num_attrs = (
"%s(IfcEntityInstanceData(storage_t(%%d)))" % type.supertypes[0]
"%s(IfcEntityInstanceData(in_memory_attribute_storage(%%d)))" % type.supertypes[0]
if len(type.supertypes) == 1
else "IfcUtil::IfcBaseEntity(IfcEntityInstanceData(storage_t(%d)))"
else "IfcUtil::IfcBaseEntity(IfcEntityInstanceData(in_memory_attribute_storage(%d)))"
) % len(constructor_arguments)
write(
@@ -120,7 +120,7 @@ public:
simpletype_impl_comment = "// Function implementations for %(name)s"
simpletype_impl_argument_type = 'if (i == 0) { return %(attr_type)s; } else { throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); }'
simpletype_impl_argument = "return data_.get_attribute_value(i);"
simpletype_impl_argument = "return get_attribute_value(i);"
simpletype_impl_is_with_supertype = "return v == %(class_name)s_type || %(superclass)s::is(v);"
simpletype_impl_is_without_supertype = "return v == %(class_name)s_type;"
simpletype_impl_type = "return *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);"
@@ -130,9 +130,9 @@ simpletype_impl_constructor = (
"data_ = new IfcEntityInstanceData(%(schema_name_upper)s_types[%(index_in_schema)d]); set_attribute_value(0, v);"
)
simpletype_impl_constructor_templated = "data_ = new IfcEntityInstanceData(%(schema_name_upper)s_types[%(index_in_schema)d]); set_attribute_value(0, v->generalize());"
simpletype_impl_cast = "return data_.get_attribute_value(0);"
simpletype_impl_cast = "return get_attribute_value(0);"
simpletype_impl_cast_templated = (
"aggregate_of_instance::ptr es = data_.get_attribute_value(0); return es->as< %(underlying_type)s >();"
"aggregate_of_instance::ptr es = get_attribute_value(0); return es->as< %(underlying_type)s >();"
)
simpletype_impl_declaration = "return *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);"
@@ -204,7 +204,7 @@ const char* %(schema_name)s::%(name)s::ToString(Value v) {
}
%(schema_name)s::%(name)s::operator %(schema_name)s::%(name)s::Value() const {
return (%(schema_name)s::%(name)s::Value) data_.storage_.get<EnumerationReference>(0).index();
return (%(schema_name)s::%(name)s::Value) ((EnumerationReference) get_attribute_value(0)).index();
}
"""
@@ -245,13 +245,13 @@ parent_type_stmt = " if(v==%(name)s%(padding)s) { return %(parent)s; }"
parent_type_test = " || %s::is(v)"
optional_attr_stmt = "return !data_.get_attribute_value(%(index)d).isNull();"
optional_attr_stmt = "return !get_attribute_value(%(index)d).isNull();"
get_attr_stmt = "%(null_check)s %(non_optional_type)s v = data_.get_attribute_value(%(index)d); return v;"
get_attr_stmt_enum = "%(null_check)s return %(non_optional_type)s::FromString(data_.get_attribute_value(%(index)d));"
get_attr_stmt_entity = "%(null_check)s return ((IfcUtil::IfcBaseClass*)(data_.get_attribute_value(%(index)d)))->as<%(non_optional_type_no_pointer)s>(true);"
get_attr_stmt_array = "%(null_check)s aggregate_of_instance::ptr es = data_.get_attribute_value(%(index)d); return es->as< %(list_instance_type)s >();"
get_attr_stmt_nested_array = "%(null_check)s aggregate_of_aggregate_of_instance::ptr es = data_.get_attribute_value(%(index)d); return es->as< %(list_instance_type)s >();"
get_attr_stmt = "%(null_check)s %(non_optional_type)s v = get_attribute_value(%(index)d); return v;"
get_attr_stmt_enum = "%(null_check)s return %(non_optional_type)s::FromString(get_attribute_value(%(index)d));"
get_attr_stmt_entity = "%(null_check)s return ((IfcUtil::IfcBaseClass*)(get_attribute_value(%(index)d)))->as<%(non_optional_type_no_pointer)s>(true);"
get_attr_stmt_array = "%(null_check)s aggregate_of_instance::ptr es = get_attribute_value(%(index)d); return es->as< %(list_instance_type)s >();"
get_attr_stmt_nested_array = "%(null_check)s aggregate_of_aggregate_of_instance::ptr es = get_attribute_value(%(index)d); return es->as< %(list_instance_type)s >();"
get_inverse = "if (!file_) { return nullptr; } return file_->getInverse(id_, %(schema_name_upper)s_types[%(type_index)d], %(index)d)->as<%(type)s>();"