Provide concrete C++ implementations for all multidimensional aggregate types in IFC4

This commit is contained in:
Thomas Krijnen
2015-06-16 12:58:07 +00:00
parent f70b37137d
commit 4f60c7d48c
12 changed files with 196 additions and 51 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ class Implementation:
select = arg['list_instance_type'] == "IfcUtil::IfcBaseClass"
express = mapping.flatten_type_string(arg['list_instance_type']) in mapping.express_to_cpp_typemapping
if arg['is_enum']: return templates.get_attr_stmt_enum
elif arg['is_nested']: return templates.get_attr_stmt_nested_array
elif arg['is_nested'] and arg['is_templated_list']: return templates.get_attr_stmt_nested_array
elif arg['is_templated_list'] and not (select or simple or express): return templates.get_attr_stmt_array
elif arg['non_optional_type'].endswith('*'): return templates.get_attr_stmt_entity
else: return templates.get_attr_stmt
+9 -4
View File
@@ -17,6 +17,7 @@
# #
###############################################################################
import sys
import nodes
import templates
@@ -35,7 +36,7 @@ class Mapping:
supported_argument_types = {
'INT', 'BOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
'AGGREGATE_OF_INT', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE'
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
}
def __init__(self, schema):
@@ -96,9 +97,12 @@ class Mapping:
ty = _make_argument_type(type.type)
if ty == "UNKNOWN": return "UNKNOWN"
return "AGGREGATE_OF_" + ty
else: raise ValueError
else:
raise ValueError("Unable to map type %r for attribute %r" % (type, attr))
ty = _make_argument_type(attr.type if hasattr(attr, 'type') else attr)
if ty not in self.supported_argument_types: ty = 'UNKNOWN'
if ty not in self.supported_argument_types:
print("Attribute %r mapped as 'unknown'" % (type, attr), file=sys.stderr)
ty = 'UNKNOWN'
return "IfcUtil::Argument_%s" % ty
def get_type_dep(self, type):
@@ -121,7 +125,8 @@ class Mapping:
if self.schema.is_select(attr_type.type):
type_str = templates.untyped_list
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
type_str = templates.array_type % {
tmpl = templates.nested_array_type if is_nested_list else templates.array_type
type_str = tmpl % {
'instance_type' : ty,
'lower' : attr_type.bounds.lower,
'upper' : attr_type.bounds.upper
+1
View File
@@ -409,6 +409,7 @@ constructor_single_initlist = "%(class_name)s::%(class_name)s(%(arguments)s) : %
cast_function = "%(class_name)s::operator %(return_type)s() const { %(body)s }"
array_type = "std::vector< %(instance_type)s > /*[%(lower)s:%(upper)s]*/"
nested_array_type = "std::vector< std::vector< %(instance_type)s > >"
list_type = "IfcTemplatedEntityList< %(instance_type)s >::ptr"
list_list_type = "IfcTemplatedEntityListList< %(instance_type)s >::ptr"
untyped_list = "IfcEntityList::ptr"