Add support for returning a pre-existing foreign object from a foreign method

This is potentially subject to change in the near
future. This commit adds support for returning
an instance (currently wrapped in ForeignObject<>)
of a foreign object that is already instantiated.
The object returned this way simply gets selected
by handle into slot 0 of C Wren.
Conversely, returning just a naked object causes
wrenpp to make a Wren-accessible copy of it.
This commit is contained in:
King_DuckZ 2024-05-28 08:25:19 +02:00
commit 2c99251b27
13 changed files with 223 additions and 17 deletions

View file

@ -128,7 +128,7 @@ int main() {
vm.interpret("main", g_test_script);
Calendar* const cale = std::get<0>(wren::variables<Calendar>(vm, MN<"main", "cale">));
Calendar* const cale = std::get<0>(wren::variables<Calendar>(vm, MN<"main", "cale">)).data();
cale->print_appointments();
return 0;