mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
IfcParseWrapper: use swig feature to override base classes
Needed to make all attributes be resolvable statically.
This commit is contained in:
@@ -21,6 +21,8 @@ from typing import Any, Literal, Union
|
|||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
from ifcopenshell.entity_instance import entity_instance_mixin
|
||||||
|
from ifcopenshell.file import file_mixin
|
||||||
|
|
||||||
# `std::vector<xxx>` usually translated to `tuple[xxx, ...]`.
|
# `std::vector<xxx>` usually translated to `tuple[xxx, ...]`.
|
||||||
|
|
||||||
@@ -873,7 +875,7 @@ class entity(declaration):
|
|||||||
def subtypes(self) -> tuple[entity, ...]: ...
|
def subtypes(self) -> tuple[entity, ...]: ...
|
||||||
def supertype(self) -> Union[entity, None]: ...
|
def supertype(self) -> Union[entity, None]: ...
|
||||||
|
|
||||||
class entity_instance:
|
class entity_instance(entity_instance_mixin):
|
||||||
def __init__(self, *args, **kwargs): ...
|
def __init__(self, *args, **kwargs): ...
|
||||||
file: ifcopenshell.file
|
file: ifcopenshell.file
|
||||||
"""Reference to IFC file to prevent it's garbage collection, if entity is still used."""
|
"""Reference to IFC file to prevent it's garbage collection, if entity is still used."""
|
||||||
@@ -966,7 +968,7 @@ class face:
|
|||||||
def matrix(self): ...
|
def matrix(self): ...
|
||||||
def print_impl(self, o, indent): ...
|
def print_impl(self, o, indent): ...
|
||||||
|
|
||||||
class file:
|
class file(file_mixin):
|
||||||
def FreshId(self): ...
|
def FreshId(self): ...
|
||||||
def __init__(self, *args): ...
|
def __init__(self, *args): ...
|
||||||
def add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
def add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
||||||
|
|||||||
@@ -991,44 +991,22 @@ static bool express_Base_equals(const express::Base* self, const express::Base*
|
|||||||
%include "../ifcparse/spf_header.h"
|
%include "../ifcparse/spf_header.h"
|
||||||
|
|
||||||
%pythoncode %{
|
%pythoncode %{
|
||||||
### hack hack hack
|
from .file import file_mixin as _file_mixin_base
|
||||||
### we trick swig into inheriting from our own extension class
|
|
||||||
### that way we do not constantly need to decorate/undecorate
|
|
||||||
# @todo is there no official way to do this?
|
|
||||||
_old_object = object
|
|
||||||
from .file import file_mixin as custom_base
|
|
||||||
object = custom_base
|
|
||||||
%}
|
%}
|
||||||
|
%feature("python:abc", "_file_mixin_base") ifcopenshell::file;
|
||||||
|
|
||||||
%include "../ifcparse/file.h"
|
%include "../ifcparse/file.h"
|
||||||
%template(instance_streamer) ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>;
|
%template(instance_streamer) ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>;
|
||||||
|
|
||||||
%pythoncode %{
|
|
||||||
### hack hack hack
|
|
||||||
### restore
|
|
||||||
object = _old_object
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include "../ifcparse/file_open_status.h"
|
%include "../ifcparse/file_open_status.h"
|
||||||
|
|
||||||
%pythoncode %{
|
%pythoncode %{
|
||||||
### hack hack hack
|
from .entity_instance import entity_instance_mixin as _entity_instance_mixin_base
|
||||||
### we trick swig into inheriting from our own extension class
|
|
||||||
### that way we do not constantly need to decorate/undecorate
|
|
||||||
# @todo is there no official way to do this?
|
|
||||||
_old_object = object
|
|
||||||
from .entity_instance import entity_instance_mixin as custom_base
|
|
||||||
object = custom_base
|
|
||||||
%}
|
%}
|
||||||
|
%feature("python:abc", "_entity_instance_mixin_base") express::Base;
|
||||||
|
|
||||||
%include "../ifcparse/express.h"
|
%include "../ifcparse/express.h"
|
||||||
|
|
||||||
%pythoncode %{
|
|
||||||
### hack hack hack
|
|
||||||
### restore
|
|
||||||
object = _old_object
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include "../ifcparse/schema.h"
|
%include "../ifcparse/schema.h"
|
||||||
%include "../serializers/RocksDbSerializer.h"
|
%include "../serializers/RocksDbSerializer.h"
|
||||||
%include "../ifcparse/logger.h"
|
%include "../ifcparse/logger.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user