diff --git a/include/wrenpp/vm_fun.hpp b/include/wrenpp/vm_fun.hpp index f0ea7c9..61b48f0 100644 --- a/include/wrenpp/vm_fun.hpp +++ b/include/wrenpp/vm_fun.hpp @@ -33,6 +33,9 @@ namespace wren { template R call (VM& vm, const ModuleAndName& object, const Handle& method, const Args&... args); + template + R call (VM& vm, const Handle& object, const char (&method)[N], const Args&... args); + template R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args); @@ -165,7 +168,7 @@ namespace wren { } template - inline R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args) { + inline R call (VM& vm, const Handle& object, const char (&method)[N], const Args&... args) { const constexpr char dummy_name_buff[N] = {0}; const constexpr auto params = dhandy::bt::string(dummy_name_buff) + dhandy::bt::make_string("(") + @@ -177,4 +180,12 @@ namespace wren { std::copy(params.data() + N - 1, params.data() + params.size() + 1, cat_buff + N - 1); return call(vm, object, vm.make_call_handle(cat_buff), args...); } + + template + inline R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args) { + vm.ensure_slots(sizeof...(args) + 1); + variable(vm, object, 0); + Handle obj_handle = vm.slot_handle(0); + return call(vm, obj_handle, method, args...); + } } //namespace wren