Skip to content
Open
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
8 changes: 6 additions & 2 deletions source/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,12 @@ void ClassBinder::bind(Context &context)

c += bind_repr(context, Config::get());

std::map<string, string> const &external_add_on_binders = Config::get().add_on_binders();
if( external_add_on_binders.count(qualified_name_without_template) ) c += "\n\t{}(cl);\n"_format(external_add_on_binders.at(qualified_name_without_template));
std::map<string, std::vector<string>> const &external_add_on_binders = Config::get().add_on_binders();
if( external_add_on_binders.count(qualified_name_without_template) ) {
for( auto const& add_on : external_add_on_binders.at(qualified_name_without_template) ) {
c += "\n\t{}(cl);\n"_format(add_on);
}
}

c += bind_nested_classes(context);

Expand Down
4 changes: 2 additions & 2 deletions source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void Config::read(string const &file_name)

if( bind ) {
auto binder_function = split_in_two(name, "Invalid line for add_on_binder specification! Must be: name_of_type + <space or tab> + name_of_binder. Got: " + line);
add_on_binders_[binder_function.first] = trim(binder_function.second);
add_on_binders_[binder_function.first].push_back(trim(binder_function.second));
}
}
else if( token == _binder_for_namespace_ ) {
Expand All @@ -210,7 +210,7 @@ void Config::read(string const &file_name)

if( bind ) {
auto binder_function = split_in_two(name, "Invalid line for add_on_binder_for_namespace specification! Must be: name_of_type + <space or tab> + name_of_binder. Got: " + line);
add_on_binder_for_namespaces_[binder_function.first] = trim(binder_function.second);
add_on_binder_for_namespaces_[binder_function.first].push_back(trim(binder_function.second));
}
} else if ( token == _field_ ) {

Expand Down
10 changes: 6 additions & 4 deletions source/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class Config
}

private:
std::map<string, string> binders_, add_on_binders_;
std::map<string, string> binder_for_namespaces_, add_on_binder_for_namespaces_, custom_trampoline_functions_;

std::map<string, string> binders_, binder_for_namespaces_;
std::map<string, std::vector<string>> add_on_binders_, add_on_binder_for_namespaces_;
std::map<string, string> custom_trampoline_functions_;

std::map<string, std::vector<string> > class_includes_, namespace_includes_;

Expand Down Expand Up @@ -69,10 +71,10 @@ class Config
std::vector<string> buffer_protocols, module_local_namespaces_to_add, module_local_namespaces_to_skip, smart_held_classes;

std::map<string, string> const &binders() const { return binders_; }
std::map<string, string> const &add_on_binders() const { return add_on_binders_; }
std::map<string, std::vector<string>> const &add_on_binders() const { return add_on_binders_; }

std::map<string, string> const &binder_for_namespaces() const { return binder_for_namespaces_; }
std::map<string, string> const &add_on_binder_for_namespaces() const { return add_on_binder_for_namespaces_; }
std::map<string, std::vector<string>> const &add_on_binder_for_namespaces() const { return add_on_binder_for_namespaces_; }

std::set<string> python_builtins, not_python_builtins;

Expand Down
8 changes: 5 additions & 3 deletions source/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,11 @@ void Context::generate(Config const &config)
skip = true;
}

std::map<string, string> const &add_on_binder_for_namespaces = Config::get().add_on_binder_for_namespaces();
if( add_on_binder_for_namespaces.count(namespace_) and code.empty() ) {
if( namespace_entrance[namespace_] == 0 ) code += "\n\t{}(M(\"{}\"));\n"_format(add_on_binder_for_namespaces.at(namespace_), namespace_);
std::map<string, std::vector<string>> const &add_on_binder_for_namespaces = Config::get().add_on_binder_for_namespaces();
if( add_on_binder_for_namespaces.count(namespace_) and code.empty() and namespace_entrance[namespace_] == 0 ) {
for( auto const& add_on : add_on_binder_for_namespaces.at(namespace_) ) {
code += "\n\t{}(M(\"{}\"));\n"_format(add_on, namespace_);
}
}

for( ; code.size() < config.maximum_file_length and i < binders.size() and namespace_ == namespace_from_named_decl(binders[i]->named_decl()); ++i ) {
Expand Down
Loading