Updated imports required for jq. Added get_str method in VarArgs

This commit is contained in:
Syrus
2019-05-18 12:38:22 -07:00
parent 4ddffb8285
commit 8f345dc284
8 changed files with 97 additions and 48 deletions

View File

@ -1,5 +1,7 @@
use std::mem;
use wasmer_runtime_core::{types::WasmExternType, vm::Ctx};
// use std::ffi::CStr;
use std::os::raw::c_char;
#[repr(transparent)]
#[derive(Copy, Clone)]
@ -13,6 +15,14 @@ impl VarArgs {
self.pointer += mem::size_of::<T>() as u32;
unsafe { (ptr as *const T).read() }
}
// pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr {
pub fn get_str(&mut self, ctx: &mut Ctx) -> *const c_char {
let ptr_addr: u32 = self.get(ctx);
let ptr = emscripten_memory_pointer!(ctx.memory(0), ptr_addr) as *const c_char;
ptr
// unsafe { CStr::from_ptr(ptr) }
}
}
unsafe impl WasmExternType for VarArgs {