A wasm interpreter written in rust that interops with beat saber.
this library behaves similar to OpenGL in how functions are called
Here are the true types of type aliases, for ffi however, these concrete types are only to tell you which functions should be given what values.
type ScriptFnMap = HashMap<String, ScriptFnMetadata>
type TuringInstance = Turing<CsFns>
type TuringInit = Result<Turing<CsFns>>
frees a rust-allocated string.
registers functions that rust needs to work with interop. valid functions are:
abort(err_type: *const c_char, err_msg: *const c_char)log_info(*const c_char)log_warn(*const c_char)log_critical(*const c_char)log_debug(*const c_char)free_cs_string(*const c_char)
add_param_types_to_fn_data(data: *mut ScriptFnMetadata, params: *mut DataType, params_count: u32) -> *const c_char
name should be in one of these formats:
ClassName:methodNameClassName.functionNamefunction_namecase style doesn't matter, only the:and.
load_script(turing: *mut TuringInstance, source: *const c_char, loaded_capabilities: *mut *const c_char, capability_count: u32) -> FfiParam
This will either load the wasm or lua engine based on the source's file extension.
call_fn(turing: *mut TuringInstance, name: *const c_char, params: *mut Params, expected_return_type: DataType) -> FfiParam
Will automatically call the appropriate functions based on the current code engine.
Bypasses the params system entirely to call on_update if it's loaded.
This function may return an error string, so check if it's non-null
Same as fast_call_update but calls on_fixed_update instead
returns a semantic version in the form of (major: u32, minor: u16, patch: u16) in that specific packing order
pub enum DataType {
I8 = 1,
I16 = 2,
I32 = 3,
I64 = 4,
U8 = 5,
U16 = 6,
U32 = 7,
U64 = 8,
F32 = 9,
F64 = 10,
Bool = 11,
RustString = 12,
ExtString = 13,
Object = 14,
RustError = 15,
ExtError = 16,
Void = 17,
}
pub union RawParam {
I8: i8,
I16: i16,
I32: i32,
I64: i64,
U8: u8,
U16: u16,
U32: u32,
U64: u64,
F32: f32,
F64: f64,
Bool: bool,
RustString: *const c_char,
ExtString: *const c_char,
Object: *const c_void,
RustError: *const c_char,
ExtError: *const c_char,
Void: (),
}
pub struct FfiParam {
type_id: DataType,
value: RawParam,
}Download the mingw-64 package and compile using:
cargo x w