Add convenience variable_ensure_slot

This commit is contained in:
King_DuckZ 2021-02-12 14:41:01 +01:00
parent 52d9210400
commit cfc8bb89f8
2 changed files with 12 additions and 0 deletions

View file

@ -83,6 +83,8 @@ namespace wren {
template <typename T> 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 <typename T> struct TType { typedef T type; };

View file

@ -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