MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getAs_impl

Method getAs_impl

python/engine/PythonEngine.cpp:261–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void* PythonEngine::getAs_impl(ScriptObject& obj, const std::type_info& ti) {
262
263 auto val = std::any_cast<PythonObject>(obj.object);
264
265 void* return_value = nullptr;
266
267 const auto& type_name = getRegisteredTypeName(ti);
268
269 auto* type = SWIG_Python_TypeQuery(type_name.c_str());
270
271 if (!type) {
272 throw std::runtime_error("Unable to find type in SWIG");
273 }
274
275 const auto result = SWIG_Python_ConvertPtr(val.obj_, &return_value, type, 0);
276
277 if (!SWIG_IsOK(result)) {
278 throw std::runtime_error(fmt::format("Error getting object from SWIG/Python of supposed type {}, {}\n", ti.name(), type_name.c_str()));
279 }
280
281 return return_value;
282}
283
284bool PythonEngine::getAs_impl_bool(ScriptObject& obj) {
285 auto val = std::any_cast<PythonObject>(obj.object);

Callers

nothing calls this directly

Calls 1

nameMethod · 0.45

Tested by

no test coverage detected