Struct wren::VM
[−]
[src]
pub struct VM { /* fields omitted */ }
Wrapper around WrenVM
. Refer to wren.h
for info on each function.
Some functions have some additional safety features. In particular:
Functions that retrieve slot values will perform type checking and return an Option.
wrenEnsureSlots
is called automatically where needed.Functions that operate on lists will validate their parameters.
Methods
impl VM
[src]
fn new(cfg: Configuration) -> VM
Create a new VM.
unsafe fn from_ptr(ptr: *mut WrenVM) -> VM
Create a wrapper around an existing WrenVM pointer.
This is mainly used by function wrapping macros.
fn collect_garbage(&mut self)
Maps to wrenCollectGarbage
.
fn interpret(&mut self, source: &str) -> InterpretResult
Maps to wrenInterpret
.
fn interpret_file(&mut self, path: &str) -> Result<InterpretResult, Error>
Convenience function that loads a script from a file and interprets it.
fn make_call_handle(&mut self, signature: &str) -> Handle
Maps to wrenMakeCallHandle
.
fn call(&mut self, method: &Handle) -> InterpretResult
Maps to wrenCall
.
fn get_slot_count(&mut self) -> i32
Maps to wrenGetSlotCount
.
fn get_slot_type(&mut self, slot: i32) -> Type
Maps to wrenGetSlotType
.
fn get_slot_bool(&mut self, slot: i32) -> Option<bool>
Maps to wrenGetSlotBool
.
Returns None
if the value in slot
isn't a bool.
fn get_slot_bytes(&mut self, slot: i32) -> Option<&[u8]>
Maps to wrenGetSlotBytes
.
Returns None
if the value in slot
isn't a string.
fn get_slot_double(&mut self, slot: i32) -> Option<f64>
Maps to wrenGetSlotDouble
.
Returns None
if the value in slot
isn't a number.
fn get_slot_foreign(&mut self, slot: i32) -> Option<Pointer>
Maps to wrenGetSlotForeign
.
Returns None
if the value in slot
isn't a foreign object.
unsafe fn get_slot_foreign_typed<T>(&mut self, slot: i32) -> &mut T
Convenience function that calls wrenGetSlotForeign
and casts the result.
This function uses mem::transmute
internally and is therefore very unsafe.
fn get_slot_string(&mut self, slot: i32) -> Option<&str>
Maps to wrenGetSlotString
.
Returns None
if the value in slot
isn't a string.
fn get_slot_handle(&mut self, slot: i32) -> Option<Handle>
Maps to wrenGetSlotHandle
.
fn set_slot_bool(&mut self, slot: i32, value: bool)
Maps to wrenSetSlotBool
.
fn set_slot_bytes(&mut self, slot: i32, bytes: &[u8])
Maps to wrenSetSlotBytes
.
fn set_slot_double(&mut self, slot: i32, value: f64)
Maps to wrenSetSlotDouble
.
fn set_slot_new_foreign(
&mut self,
slot: i32,
class_slot: i32,
size: usize
) -> Pointer
&mut self,
slot: i32,
class_slot: i32,
size: usize
) -> Pointer
Maps to wrenSetSlotNewForeign
.
fn set_slot_new_foreign_typed<T>(
&mut self,
slot: i32,
class_slot: i32
) -> *mut T
&mut self,
slot: i32,
class_slot: i32
) -> *mut T
Convenience function that calls wrenSetSlotNewForeign
using type information.
fn set_slot_new_list(&mut self, slot: i32)
Maps to wrenSetSlotNewList
.
fn set_slot_null(&mut self, slot: i32)
Maps to wrenSetSlotNull
.
fn set_slot_string(&mut self, slot: i32, s: &str)
Maps to wrenSetSlotString
.
fn set_slot_handle(&mut self, slot: i32, handle: &Handle)
Maps to wrenSetSlotHandle
.
fn get_list_count(&mut self, slot: i32) -> i32
Maps to wrenGetListCount
.
fn get_list_element(&mut self, list_slot: i32, index: i32, element_slot: i32)
Maps to wrenGetListElement
.
fn insert_in_list(&mut self, list_slot: i32, index: i32, element_slot: i32)
Maps to wrenInsertInList
.
fn get_variable(&mut self, module: &str, name: &str, slot: i32)
Maps to wrenGetVariable
.
fn abort_fiber(&mut self, slot: i32)
Maps to wrenAbortFiber
.
fn get_user_data(&mut self) -> Pointer
Maps to wrenGetUserData
.
fn set_user_data(&mut self, data: Pointer)
Maps to wrenSetUserData
.