-
-
Notifications
You must be signed in to change notification settings - Fork 900
Expand file tree
/
Copy pathtypemaps_out.i
More file actions
178 lines (160 loc) · 6.95 KB
/
typemaps_out.i
File metadata and controls
178 lines (160 loc) · 6.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
%typemap(out) aggregate_of_instance::ptr {
const unsigned size = $1 ? $1->size() : 0;
$result = PyTuple_New(size);
for (unsigned i = 0; i < size; ++i) {
PyTuple_SetItem($result, i, pythonize((*$1)[i]));
}
}
%typemap(out) aggregate_of_aggregate_of_instance::ptr {
const unsigned size = $1 ? $1->size() : 0;
$result = PyTuple_New(size);
for (unsigned i = 0; i < size; ++i) {
const auto& r_i = *(result->begin() + i);
PyTuple_SetItem($result, i, pythonize_vector(r_i));
}
}
%typemap(out) IfcUtil::ArgumentType {
$result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
}
%typemap(out) IfcParse::declaration* {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0);
}
%typemap(out) IfcParse::parameter_type* {
if ($1->as_named_type()) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_named_type()), SWIGTYPE_p_IfcParse__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);
} else if ($1->as_aggregation_type()) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_aggregation_type()), SWIGTYPE_p_IfcParse__aggregation_type, 0);
} else {
$result = SWIG_Py_Void();
}
}
%typemap(out) IfcParse::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 {
// The SWIG %exception directive does not take care
// of our typemap. So the attribute conversion block
// is wrapped in a try-catch block manually.
try {
$result = $1.apply_visitor([](const auto& v){
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>) {
return pythonize(std::string(v.value()));
} 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>) {
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>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else {
return pythonize(v);
}
});
} catch(IfcParse::IfcException& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch(...) {
SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
}
}
%define CREATE_VECTOR_TYPEMAP_OUT(template_type)
%typemap(out) std::vector<template_type> {
$result = pythonize_vector<std::vector<template_type>>($1);
}
%typemap(out) const std::vector<template_type>& {
$result = pythonize_vector<std::vector<template_type>>(*$1);
}
%typemap(out) std::vector<std::vector<template_type>> {
$result = pythonize_vector<std::vector<std::vector<template_type>>>($1);
}
%typemap(out) const std::vector<std::vector<template_type>>& {
$result = pythonize_vector<std::vector<std::vector<template_type>>>(*$1);
}
%typemap(out) std::vector<std::vector<std::vector<template_type>>> {
$result = pythonize_vector<std::vector<std::vector<std::vector<template_type>>>>($1);
}
%typemap(out) const std::vector<std::vector<std::vector<template_type>>>& {
$result = pythonize_vector<std::vector<std::vector<std::vector<template_type>>>>(*$1);
}
%enddef
CREATE_VECTOR_TYPEMAP_OUT(bool)
CREATE_VECTOR_TYPEMAP_OUT(int)
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(IfcGeom::ConversionResultShape *)
%typemap(out) ifcopenshell::geometry::Settings::value_variant_t {
pythonizing_visitor vis;
$result = $1.apply_visitor(vis);
}
%typemap(out) ifcopenshell::geometry::SerializerSettings::value_variant_t {
pythonizing_visitor vis;
$result = $1.apply_visitor(vis);
}
%typemap(out) std::pair<const char*, size_t> {
$result = PyBytes_FromStringAndSize($1.first, $1.second);
}
%define vector_of_item(item_name)
%typemap(out) const std::vector<item_name::ptr>& {
$result = PyTuple_New((*$1).size());
for (int i = 0; i < (*$1).size(); ++i) {
PyTuple_SetItem($result, i, item_to_pyobject((*$1).at(i)));
}
};
%typemap(out) std::vector<item_name::ptr> {
const auto& v = (std::vector<item_name::ptr>) $1;
$result = PyTuple_New(v.size());
for (int i = 0; i < v.size(); ++i) {
PyTuple_SetItem($result, i, item_to_pyobject(v[i]));
}
};
%typemap(out) const item_name::ptr& {
$result = item_to_pyobject(*$1);
};
%enddef
vector_of_item(ifcopenshell::geometry::taxonomy::item)
vector_of_item(ifcopenshell::geometry::taxonomy::boolean_result)
vector_of_item(ifcopenshell::geometry::taxonomy::bspline_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::bspline_surface)
vector_of_item(ifcopenshell::geometry::taxonomy::circle)
vector_of_item(ifcopenshell::geometry::taxonomy::collection)
vector_of_item(ifcopenshell::geometry::taxonomy::colour)
vector_of_item(ifcopenshell::geometry::taxonomy::cylinder)
vector_of_item(ifcopenshell::geometry::taxonomy::direction3)
vector_of_item(ifcopenshell::geometry::taxonomy::edge)
vector_of_item(ifcopenshell::geometry::taxonomy::ellipse)
vector_of_item(ifcopenshell::geometry::taxonomy::extrusion)
vector_of_item(ifcopenshell::geometry::taxonomy::face)
vector_of_item(ifcopenshell::geometry::taxonomy::line)
vector_of_item(ifcopenshell::geometry::taxonomy::loft)
vector_of_item(ifcopenshell::geometry::taxonomy::loop)
vector_of_item(ifcopenshell::geometry::taxonomy::matrix4)
vector_of_item(ifcopenshell::geometry::taxonomy::node)
vector_of_item(ifcopenshell::geometry::taxonomy::offset_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::piecewise_function)
vector_of_item(ifcopenshell::geometry::taxonomy::plane)
vector_of_item(ifcopenshell::geometry::taxonomy::point3)
vector_of_item(ifcopenshell::geometry::taxonomy::revolve)
vector_of_item(ifcopenshell::geometry::taxonomy::shell)
vector_of_item(ifcopenshell::geometry::taxonomy::solid)
vector_of_item(ifcopenshell::geometry::taxonomy::sphere)
vector_of_item(ifcopenshell::geometry::taxonomy::torus)
vector_of_item(ifcopenshell::geometry::taxonomy::style)
vector_of_item(ifcopenshell::geometry::taxonomy::sweep_along_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::geom_item)