Fix IfcBinary default instantiation as part of select

This commit is contained in:
Thomas Krijnen
2018-01-23 11:59:24 +01:00
parent a53ffd2662
commit 844428fefd
2 changed files with 21 additions and 8 deletions
+10 -5
View File
@@ -36,7 +36,7 @@ class SchemaClass(codegen.Base):
aggr_type = type.aggregate_type
make_bound = lambda b: -1 if b == '?' else int(b)
bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper))
decl_type = get_declared_type(type.type)
decl_type = get_declared_type(type.type, emitted_names)
return "new aggregation_type(aggregation_type::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(decl_type)s)" % locals()
elif isinstance(type, nodes.BinaryType):
return "new simple_type(simple_type::binary_type)"
@@ -93,10 +93,14 @@ class SchemaClass(codegen.Base):
statements.append('schema_definition* populate_schema() {')
emitted_types = set()
while len(emitted_types) < len(mapping.schema.simpletypes):
# while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}):
while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}):
for name, type in mapping.schema.simpletypes.items():
if name in emitted_types: continue
# No support for types refering to entities :(
if name == "IfcPropertySetDefinitionSet": continue
try:
declared_type = get_declared_type(type, emitted_types)
except UnmetDependenciesException:
@@ -133,10 +137,11 @@ class SchemaClass(codegen.Base):
while len(emitted_selects) < len(mapping.schema.selects):
for name, type in mapping.schema.selects.items():
if name in emitted_selects: continue
if set(type.values) < emmited:
type_values = sorted(set(type.values) - {"IfcPropertySetDefinitionSet"})
if set(type_values) < emmited:
statements.append(' {')
statements.append(' std::vector<const declaration*> items; items.reserve(%d);' % len(type.values))
statements.extend(map(lambda v: ' items.push_back(%s_type);' % v, sorted(type.values)))
statements.append(' std::vector<const declaration*> items; items.reserve(%d);' % len(type_values))
statements.extend(map(lambda v: ' items.push_back(%s_type);' % v, sorted(type_values)))
statements.append(' %(name)s_type = new select_type(IfcSchema::Type::%(name)s, items);' % locals())
statements.append(' }')
emitted_selects.add(name)
+11 -3
View File
@@ -290,8 +290,6 @@ public:
bool processed = false;
if (elem_type->as_named_type()) {
auto entity = elem_type->as_named_type()->declared_type()->as_entity();
std::cerr << elem_type->as_named_type()->declared_type()->name() << std::endl;
std::cerr << attr_->toString() << std::endl;
if (entity != nullptr) {
std::vector<IfcUtil::IfcBaseClass*> empty;
t(empty);
@@ -474,7 +472,17 @@ public:
break;
}
default:
throw std::runtime_error("Unexpected type encountered");
{
// TK: Ifc4 IfcValue select valuations can result into H5T_OPAQUE types for
// IfcBinary. This is not likely an issue, as these are simply padding values.
// TODO: Use H5T_BITSET for binary instead?
// const char* class_names[] = {"H5T_NO_CLASS", "H5T_INTEGER", "H5T_FLOAT", "H5T_TIME", "H5T_STRING", "H5T_BITFIELD", "H5T_OPAQUE", "H5T_COMPOUND", "H5T_REFERENCE", "H5T_ENUM", "H5T_VLEN", "H5T_ARRAY", "H5T_NCLASSES"};
// throw std::runtime_error(std::string("Unexpected type encountered ") + class_names[((int)datatype_.getClass())+1]);
memset(ptr, 0, datatype_.getSize());
advance(ptr, datatype_.getSize());
}
}
}
};