Add support for foreign types to get()
wren::get() can now be used to get foreign types by pointer. Invoking get<A>() will return an A*. With this change it's now possible to use variables() to get mixed foreign and core types.
This commit is contained in:
parent
90d93d2583
commit
34d2317f11
3 changed files with 49 additions and 16 deletions
|
@ -130,13 +130,13 @@ cale.add_appointment("go get a haircut")
|
|||
} //unnamed namespace
|
||||
|
||||
int main() {
|
||||
typedef wren::ModuleAndName MN;
|
||||
|
||||
MyConf conf;
|
||||
wren::VM vm(&conf, nullptr);
|
||||
vm.interpret("main", g_test_script);
|
||||
|
||||
vm.ensure_slots(1);
|
||||
wren::variable(vm, {"main", "cale"}, 0);
|
||||
const auto cale = wren::foreign<Calendar>(vm, 0);
|
||||
Calendar* const cale = std::get<0>(wren::variables<Calendar>(vm, MN{"main", "cale"}));
|
||||
cale->print_appointments();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue