mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:02:29 +00:00
Property transfer ownership of schema from py to c++ upon register_schema()
This commit is contained in:
@@ -160,9 +160,6 @@ def create_entity(type, schema="IFC4", *args, **kwargs):
|
|||||||
return e
|
return e
|
||||||
|
|
||||||
|
|
||||||
gcroot = []
|
|
||||||
|
|
||||||
|
|
||||||
def register_schema(schema):
|
def register_schema(schema):
|
||||||
"""Registers a custom IFC schema
|
"""Registers a custom IFC schema
|
||||||
|
|
||||||
@@ -177,7 +174,8 @@ def register_schema(schema):
|
|||||||
ifcopenshell.register_schema(schema)
|
ifcopenshell.register_schema(schema)
|
||||||
ifcopenshell.file(schema="IFC_CUSTOM")
|
ifcopenshell.file(schema="IFC_CUSTOM")
|
||||||
"""
|
"""
|
||||||
gcroot.append(schema)
|
schema.schema.this.disown()
|
||||||
|
schema.disown()
|
||||||
ifcopenshell_wrapper.register_schema(schema.schema)
|
ifcopenshell_wrapper.register_schema(schema.schema)
|
||||||
register_schema_attributes(schema.schema)
|
register_schema_attributes(schema.schema)
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class LateBoundSchemaInstantiator:
|
|||||||
for attr_name, decl_type, optional in attribute_definitions:
|
for attr_name, decl_type, optional in attribute_definitions:
|
||||||
attributes.append(w.attribute(attr_name, decl_type, optional))
|
attributes.append(w.attribute(attr_name, decl_type, optional))
|
||||||
self.declarations[str(name)].set_attributes(attributes, is_derived)
|
self.declarations[str(name)].set_attributes(attributes, is_derived)
|
||||||
self.cache.append(attributes)
|
self.cache.extend(attributes)
|
||||||
|
|
||||||
def inverse_attributes(self, name, inv_attrs):
|
def inverse_attributes(self, name, inv_attrs):
|
||||||
attributes = []
|
attributes = []
|
||||||
@@ -100,6 +100,7 @@ class LateBoundSchemaInstantiator:
|
|||||||
en.attributes()[attribute_entity_index],
|
en.attributes()[attribute_entity_index],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
self.cache.extend(attributes)
|
||||||
self.declarations[str(name)].set_inverse_attributes(attributes)
|
self.declarations[str(name)].set_inverse_attributes(attributes)
|
||||||
|
|
||||||
def entity_subtypes(self, name, tys):
|
def entity_subtypes(self, name, tys):
|
||||||
@@ -110,6 +111,10 @@ class LateBoundSchemaInstantiator:
|
|||||||
override_schema_name or self.schema_name, list(self.declarations.values()), None
|
override_schema_name or self.schema_name, list(self.declarations.values()), None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def disown(self):
|
||||||
|
for elem in self.cache + list(self.declarations.values()):
|
||||||
|
elem.this.disown()
|
||||||
|
|
||||||
|
|
||||||
class EarlyBoundCodeWriter:
|
class EarlyBoundCodeWriter:
|
||||||
def __init__(self, schema_name):
|
def __init__(self, schema_name):
|
||||||
|
|||||||
Reference in New Issue
Block a user