Refactor so that make_method_bindable also accepts free functions now

This includes pointers to static member functions too of course.
`make_method_bindable` got renamed into the more generic
`make_function_bindable` because it deals with all functions
now, not only member functions.
This commit is contained in:
King_DuckZ 2022-05-19 15:05:18 +02:00
commit 8a721494b1
3 changed files with 64 additions and 31 deletions

View file

@ -121,17 +121,15 @@ int main() {
MyConf conf;
wren::VM vm(&conf, nullptr);
vm.callback_manager()
//.add_callback(true, "calendar", "Calendar", "today()", [](){return &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>);
//.add_callback(false, "calendar", "Calendar", "appointment_count()", wren::detail::MakeMethodBindable<&Calendar::appointment_count>());
.add_callback(true, "calendar", "Calendar", "today()", [](){return &Calendar::today;})
.add_callback(false, "calendar", "Calendar", "add_appointment(_)", wren::make_function_bindable<&Calendar::add_appointment>)
.add_callback(false, "calendar", "Calendar", "appointment_count()", wren::make_function_bindable<&Calendar::appointment_count>);
vm.class_manager().add_class_maker("calendar", "Calendar", wren::make_foreign_class<Calendar>);
vm.interpret("main", g_test_script);
Calendar* const cale = std::get<0>(wren::variables<Calendar>(vm, MN<"main", "cale">));
cale->print_appointments();
wren::make_wren_object<Calendar, "calendar">(vm);
return 0;
}