Implement ClassManager
Very similar to CallbackManager in its functioning.
This commit is contained in:
parent
74670f4683
commit
258237cbf3
11 changed files with 218 additions and 30 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "wrenpp/def_configuration.hpp"
|
||||
#include "wrenpp/vm_fun.hpp"
|
||||
#include "wrenpp/callback_manager.hpp"
|
||||
#include "wrenpp/class_manager.hpp"
|
||||
#include <string_view>
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
@ -107,19 +108,6 @@ System.print("You have %(cale.appointment_count()) appointment(s)")
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wren::foreign_class_t foreign_class_fn(
|
||||
wren::VM* vm,
|
||||
std::string_view module,
|
||||
std::string_view class_name
|
||||
) {
|
||||
if (module == "calendar" and class_name == "Calendar") {
|
||||
return wren::make_foreign_class<Calendar>();
|
||||
}
|
||||
else {
|
||||
return {nullptr, nullptr};
|
||||
}
|
||||
}
|
||||
};
|
||||
} //unnamed namespace
|
||||
|
||||
|
@ -131,6 +119,7 @@ int main() {
|
|||
vm.callback_manager().add_callback(true, "calendar", "Calendar", "today()", &Calendar::today)
|
||||
.add_callback(false, "calendar", "Calendar", "add_appointment(_)", wren::make_method_bindable<&Calendar::add_appointment>())
|
||||
.add_callback(false, "calendar", "Calendar", "appointment_count()", wren::make_method_bindable<&Calendar::appointment_count>());
|
||||
vm.class_manager().add_class_maker("calendar", "Calendar", &wren::make_foreign_class<Calendar>);
|
||||
|
||||
vm.interpret("main", g_test_script);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue