mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-01 09:26:26 +00:00
Restructure and rename
This commit is contained in:
@@ -142,15 +142,15 @@
|
||||
|
||||
// Conversion functions to convert STL vectors into Python objects
|
||||
%{
|
||||
swig_type_info* declaration_type_to_swig(const IfcParse::declaration* t) {
|
||||
swig_type_info* declaration_type_to_swig(const ifcopenshell::declaration* t) {
|
||||
if (t->as_entity()) {
|
||||
return SWIGTYPE_p_IfcParse__entity;
|
||||
return SWIGTYPE_p_ifcopenshell__entity;
|
||||
} else if (t->as_type_declaration()) {
|
||||
return SWIGTYPE_p_IfcParse__type_declaration;
|
||||
return SWIGTYPE_p_ifcopenshell__type_declaration;
|
||||
} else if (t->as_select_type()) {
|
||||
return SWIGTYPE_p_IfcParse__select_type;
|
||||
return SWIGTYPE_p_ifcopenshell__select_type;
|
||||
} else if (t->as_enumeration_type()) {
|
||||
return SWIGTYPE_p_IfcParse__enumeration_type;
|
||||
return SWIGTYPE_p_ifcopenshell__enumeration_type;
|
||||
} else {
|
||||
throw std::runtime_error("Unexpected declaration type");
|
||||
}
|
||||
@@ -163,10 +163,10 @@
|
||||
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
|
||||
PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); }
|
||||
PyObject* pythonize(const express::Base& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(new express::Base(t)), SWIGTYPE_p_express__Base, SWIG_POINTER_OWN); }
|
||||
PyObject* pythonize(const IfcParse::attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__attribute, 0); }
|
||||
PyObject* pythonize(const IfcParse::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__inverse_attribute, 0); }
|
||||
PyObject* pythonize(const IfcParse::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__entity, 0); }
|
||||
PyObject* pythonize(const IfcParse::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); }
|
||||
PyObject* pythonize(const ifcopenshell::attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__attribute, 0); }
|
||||
PyObject* pythonize(const ifcopenshell::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__inverse_attribute, 0); }
|
||||
PyObject* pythonize(const ifcopenshell::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__entity, 0); }
|
||||
PyObject* pythonize(const ifcopenshell::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); }
|
||||
// @nb ownership
|
||||
PyObject* pythonize(const IfcGeom::ConversionResultShape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcGeom__ConversionResultShape, SWIG_POINTER_OWN); }
|
||||
// PyObject* pythonize(const IfcGeom::ConversionResultShape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcGeom__ConversionResultShape, 0); }
|
||||
|
||||
@@ -73,15 +73,15 @@ CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
|
||||
|
||||
// @todo use macros.
|
||||
|
||||
%typemap(in) const std::vector<const IfcParse::declaration*>& {
|
||||
%typemap(in) const std::vector<const ifcopenshell::declaration*>& {
|
||||
if (PySequence_Check($input)) {
|
||||
$1 = new std::vector<const IfcParse::declaration*>;
|
||||
$1 = new std::vector<const ifcopenshell::declaration*>;
|
||||
for(Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
|
||||
PyObject* element = PySequence_GetItem($input, i);
|
||||
void *arg = 0;
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_IfcParse__declaration, 0);
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_ifcopenshell__declaration, 0);
|
||||
Py_DECREF(element);
|
||||
auto decl = static_cast<const IfcParse::declaration*>(SWIG_IsOK(res) ? arg : 0);
|
||||
auto decl = static_cast<const ifcopenshell::declaration*>(SWIG_IsOK(res) ? arg : 0);
|
||||
if (decl) {
|
||||
$1->push_back(decl);
|
||||
} else {
|
||||
@@ -93,15 +93,15 @@ CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) const std::vector<const IfcParse::entity*>& {
|
||||
%typemap(in) const std::vector<const ifcopenshell::entity*>& {
|
||||
if (PySequence_Check($input)) {
|
||||
$1 = new std::vector<const IfcParse::entity*>;
|
||||
$1 = new std::vector<const ifcopenshell::entity*>;
|
||||
for(Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
|
||||
PyObject* element = PySequence_GetItem($input, i);
|
||||
void *arg = 0;
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_IfcParse__entity, 0);
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_ifcopenshell__entity, 0);
|
||||
Py_DECREF(element);
|
||||
auto decl = static_cast<const IfcParse::entity*>(SWIG_IsOK(res) ? arg : 0);
|
||||
auto decl = static_cast<const ifcopenshell::entity*>(SWIG_IsOK(res) ? arg : 0);
|
||||
if (decl) {
|
||||
$1->push_back(decl);
|
||||
} else {
|
||||
@@ -113,15 +113,15 @@ CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) const std::vector<const IfcParse::attribute*>& {
|
||||
%typemap(in) const std::vector<const ifcopenshell::attribute*>& {
|
||||
if (PySequence_Check($input)) {
|
||||
$1 = new std::vector<const IfcParse::attribute*>;
|
||||
$1 = new std::vector<const ifcopenshell::attribute*>;
|
||||
for(Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
|
||||
PyObject* element = PySequence_GetItem($input, i);
|
||||
void *arg = 0;
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_IfcParse__attribute, 0);
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_ifcopenshell__attribute, 0);
|
||||
Py_DECREF(element);
|
||||
auto decl = static_cast<const IfcParse::attribute*>(SWIG_IsOK(res) ? arg : 0);
|
||||
auto decl = static_cast<const ifcopenshell::attribute*>(SWIG_IsOK(res) ? arg : 0);
|
||||
if (decl) {
|
||||
$1->push_back(decl);
|
||||
} else {
|
||||
@@ -133,15 +133,15 @@ CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) const std::vector<const IfcParse::inverse_attribute*>& {
|
||||
%typemap(in) const std::vector<const ifcopenshell::inverse_attribute*>& {
|
||||
if (PySequence_Check($input)) {
|
||||
$1 = new std::vector<const IfcParse::inverse_attribute*>;
|
||||
$1 = new std::vector<const ifcopenshell::inverse_attribute*>;
|
||||
for(Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
|
||||
PyObject* element = PySequence_GetItem($input, i);
|
||||
void *arg = 0;
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_IfcParse__inverse_attribute, 0);
|
||||
int res = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_ifcopenshell__inverse_attribute, 0);
|
||||
Py_DECREF(element);
|
||||
auto decl = static_cast<const IfcParse::inverse_attribute*>(SWIG_IsOK(res) ? arg : 0);
|
||||
auto decl = static_cast<const ifcopenshell::inverse_attribute*>(SWIG_IsOK(res) ? arg : 0);
|
||||
if (decl) {
|
||||
$1->push_back(decl);
|
||||
} else {
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
%typemap(out) IfcUtil::ArgumentType {
|
||||
$result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
|
||||
%typemap(out) ifcopenshell::argument_type {
|
||||
$result = SWIG_Python_str_FromChar(ifcopenshell::argument_type_to_string($1));
|
||||
}
|
||||
|
||||
%typemap(out) IfcParse::declaration* {
|
||||
%typemap(out) ifcopenshell::declaration* {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0);
|
||||
}
|
||||
|
||||
%typemap(out) const IfcParse::declaration& {
|
||||
%typemap(out) const ifcopenshell::declaration& {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0);
|
||||
}
|
||||
|
||||
%typemap(out) IfcParse::parameter_type* {
|
||||
%typemap(out) ifcopenshell::parameter_type* {
|
||||
if ($1->as_named_type()) {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_named_type()), SWIGTYPE_p_IfcParse__named_type, 0);
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_named_type()), SWIGTYPE_p_ifcopenshell__named_type, 0);
|
||||
} else if ($1->as_simple_type()) {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_simple_type()), SWIGTYPE_p_IfcParse__simple_type, 0);
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_simple_type()), SWIGTYPE_p_ifcopenshell__simple_type, 0);
|
||||
} else if ($1->as_aggregation_type()) {
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_aggregation_type()), SWIGTYPE_p_IfcParse__aggregation_type, 0);
|
||||
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_aggregation_type()), SWIGTYPE_p_ifcopenshell__aggregation_type, 0);
|
||||
} else {
|
||||
$result = SWIG_Py_Void();
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) IfcParse::simple_type::data_type {
|
||||
%typemap(out) ifcopenshell::simple_type::data_type {
|
||||
static const char* const data_type_strings[] = {"binary", "boolean", "integer", "logical", "number", "real", "string"};
|
||||
$result = SWIG_Python_str_FromChar(data_type_strings[(int)$1]);
|
||||
}
|
||||
|
||||
%typemap(out) AttributeValue {
|
||||
%typemap(out) attribute_value {
|
||||
// The SWIG %exception directive does not take care
|
||||
// of our typemap. So the attribute conversion block
|
||||
// is wrapped in a try-catch block manually.
|
||||
@@ -36,26 +36,26 @@
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
if constexpr (is_std_vector_v<U>) {
|
||||
return pythonize_vector(v);
|
||||
} else if constexpr (std::is_same_v<U, EnumerationReference>) {
|
||||
} else if constexpr (std::is_same_v<U, enumeration_reference>) {
|
||||
return pythonize(std::string(v.value()));
|
||||
} else if constexpr (std::is_same_v<U, Derived>) {
|
||||
} else if constexpr (std::is_same_v<U, derived>) {
|
||||
if (feature_use_attribute_value_derived) {
|
||||
return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
return static_cast<PyObject*>(Py_None);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, Blank>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, blank>) {
|
||||
Py_INCREF(Py_None);
|
||||
return static_cast<PyObject*>(Py_None);
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, Derived> || std::is_same_v<U, Blank>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, derived> || std::is_same_v<U, blank>) {
|
||||
Py_INCREF(Py_None);
|
||||
return static_cast<PyObject*>(Py_None);
|
||||
} else {
|
||||
return pythonize(v);
|
||||
}
|
||||
});
|
||||
} catch(IfcParse::IfcException& e) {
|
||||
} catch(ifcopenshell::exception& e) {
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
|
||||
@@ -90,10 +90,10 @@ CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(double)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(std::string)
|
||||
// CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::Material)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::attribute const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::inverse_attribute const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::entity const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::declaration const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::attribute const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::inverse_attribute const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::entity const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::declaration const *)
|
||||
CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::ConversionResultShape *)
|
||||
|
||||
%typemap(out) ifcopenshell::geometry::Settings::value_variant_t {
|
||||
|
||||
Reference in New Issue
Block a user