Allow chaining calls to add_class_maker()

This commit is contained in:
King_DuckZ 2022-05-14 18:06:35 +02:00
parent 258237cbf3
commit 036dd57524
2 changed files with 4 additions and 2 deletions

View file

@ -79,7 +79,7 @@ namespace wren {
ClassManager(); ClassManager();
~ClassManager() noexcept; ~ClassManager() noexcept;
void add_class_maker (std::string_view module_name, std::string_view class_name, make_foreign_class_t); ClassManager& add_class_maker (std::string_view module_name, std::string_view class_name, make_foreign_class_t);
foreign_class_t make_class(std::string_view module_name, std::string_view class_name); foreign_class_t make_class(std::string_view module_name, std::string_view class_name);
private: private:

View file

@ -74,7 +74,7 @@ namespace wren {
ClassManager::ClassManager() = default; ClassManager::ClassManager() = default;
ClassManager::~ClassManager() noexcept = default; ClassManager::~ClassManager() noexcept = default;
void ClassManager::add_class_maker (std::string_view module_name, std::string_view class_name, make_foreign_class_t maker) { ClassManager& ClassManager::add_class_maker (std::string_view module_name, std::string_view class_name, make_foreign_class_t maker) {
using detail::TempClassName; using detail::TempClassName;
using detail::ClassNameOwning; using detail::ClassNameOwning;
@ -83,6 +83,8 @@ namespace wren {
m_classes.insert(it_found, std::make_pair(ClassNameOwning{module_name, class_name}, maker)); m_classes.insert(it_found, std::make_pair(ClassNameOwning{module_name, class_name}, maker));
else else
it_found->second = maker; it_found->second = maker;
return *this;
} }
foreign_class_t ClassManager::make_class (std::string_view module_name, std::string_view class_name) { foreign_class_t ClassManager::make_class (std::string_view module_name, std::string_view class_name) {