diff --git a/include/wrenpp/vm_fun.hpp b/include/wrenpp/vm_fun.hpp index f580a59..c897e81 100644 --- a/include/wrenpp/vm_fun.hpp +++ b/include/wrenpp/vm_fun.hpp @@ -142,6 +142,9 @@ namespace wren { variable(vm, name, slot_num); } + //Sets arguments so wren is ready to perform a function call. It doesn't + //touch at slot 0, so eventual objects for method calls must be set + //manually template inline void set_for_call (std::integer_sequence, VM& vm, const Args&... args) { vm.ensure_slots(sizeof...(Args)); @@ -248,6 +251,7 @@ namespace wren { template inline R call (VM& vm, const Handle& object, const Handle& method, const Args&... args) { detail::set_for_call(std::make_integer_sequence(), vm, args...); + vm.set_slot_handle(object, 0); vm.call(method); if constexpr (not std::is_same::value) { return get(vm, 0);