Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/pluginplay/detail_/submodule_request_pimpl.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,25 @@ bool SubmoduleRequestPIMPL::satisfies_property_type(rtti_type type) {
inline void SubmoduleRequestPIMPL::set_module(module_ptr ptr) {
if(!ptr) throw std::runtime_error("Pointer does not contain a module");
// Type will check that a property type was set
if(ptr->property_types().count(type()) == 0) {
bool suitable = (ptr->property_types().count(type()) > 0);

// Work around for libc++ typeid inconsistency in Python
if(!suitable) {
for(const auto& property_type_info : ptr->property_types()) {
if(type().name() == property_type_info.name() ||
std::strcmp(type().name(), property_type_info.name()) == 0) {
suitable = true;
break;
}
}
}

if(!suitable) {
std::string msg("Module does not satisfy property type: ");
msg += utilities::printing::Demangler::demangle(type());
throw std::runtime_error(msg);
}

m_module_ = ptr;
}

Expand Down
8 changes: 8 additions & 0 deletions src/pluginplay/module/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ void Module::add_property_type_(pluginplay::type::rtti prop_type) {

void Module::check_property_type_(type::rtti prop_type) {
if(property_types().count(prop_type)) return;

// Work around for libc++ typeid inconsistency in Python
for(const auto& m_prop_type : property_types()) {
if(prop_type.name() == m_prop_type.name() ||
std::strcmp(prop_type.name(), m_prop_type.name()) == 0)
return;
}

std::string msg = "Module does not satisfy property type ";
msg += utilities::printing::Demangler::demangle(prop_type);
throw std::runtime_error(msg);
Expand Down