From 4843ddd95e1dc4b93bf6238149211b8338bd5dfc Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 30 Apr 2020 23:18:41 +0200 Subject: [PATCH] Add overload for Handle --- include/wrenpp/vm_fun.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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