From cfc8bb89f8f8e25aca1b2eaf3da394ce52fc5956 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 12 Feb 2021 14:41:01 +0100 Subject: [PATCH] Add convenience variable_ensure_slot --- include/wrenpp/vm_fun.hpp | 2 ++ src/vm_fun.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/wrenpp/vm_fun.hpp b/include/wrenpp/vm_fun.hpp index a2b3ee2..f580a59 100644 --- a/include/wrenpp/vm_fun.hpp +++ b/include/wrenpp/vm_fun.hpp @@ -83,6 +83,8 @@ namespace wren { template T* foreign (VM& vm, int slot_num); void variable(VM& vm, const ModuleAndName& mod_and_name, int slot); void variable(VM& vm, const Handle& handle, int slot); + void variable_ensure_slot(VM& vm, const ModuleAndName& mod_and_name, int slot); + void variable_ensure_slot(VM& vm, const Handle& handle, int slot); namespace detail { template struct TType { typedef T type; }; diff --git a/src/vm_fun.cpp b/src/vm_fun.cpp index bd2855b..57fb118 100644 --- a/src/vm_fun.cpp +++ b/src/vm_fun.cpp @@ -79,4 +79,14 @@ namespace wren { void variable (VM& vm, const Handle& handle, int slot) { vm.set_slot_handle(handle, slot); } + + void variable_ensure_slot(VM& vm, const ModuleAndName& mod_and_name, int slot) { + vm.ensure_slots(1); + variable(vm, mod_and_name, slot); + } + + void variable_ensure_slot (VM& vm, const Handle& handle, int slot) { + vm.ensure_slots(1); + variable(vm, handle, slot); + } } //namespace wren