feat: make all nodes work with new runtime

This commit is contained in:
Max Richter
2026-01-23 01:14:09 +01:00
parent 47882a832d
commit a497a46674
23 changed files with 494 additions and 244 deletions

View File

@@ -11,51 +11,38 @@ pub fn decode_float(bits: i32) -> f32 {
}
#[inline]
pub unsafe fn read_i32(ptr: *const i32) -> i32 {
*ptr
}
#[inline]
pub unsafe fn read_f32(ptr: *const i32) -> f32 {
f32::from_bits(*ptr as u32)
}
#[inline]
pub unsafe fn read_bool(ptr: *const i32) -> bool {
*ptr != 0
}
#[inline]
pub unsafe fn read_vec3(ptr: *const i32) -> [f32; 3] {
let p = ptr as *const f32;
[p.read(), p.add(1).read(), p.add(2).read()]
}
#[inline]
pub unsafe fn read_i32_slice(ptr: *const i32, len: usize) -> Vec<i32> {
std::slice::from_raw_parts(ptr, len).to_vec()
}
#[inline]
pub unsafe fn read_f32_slice(ptr: *const i32, len: usize) -> Vec<f32> {
std::slice::from_raw_parts(ptr as *const f32, len).to_vec()
}
#[inline]
pub unsafe fn read_f32_default(ptr: *const i32, default: f32) -> f32 {
if ptr.is_null() {
default
} else {
read_f32(ptr)
pub fn read_i32(ptr: i32) -> i32 {
unsafe {
let _ptr = ptr as *const i32;
*_ptr
}
}
#[inline]
pub unsafe fn read_i32_default(ptr: *const i32, default: i32) -> i32 {
if ptr.is_null() {
default
} else {
read_i32(ptr)
pub fn read_f32(ptr: i32) -> f32 {
unsafe {
let _ptr = ptr as *const i32;
f32::from_bits(*_ptr as u32)
}
}
#[inline]
pub fn read_i32_slice(tuple: (i32, i32)) -> Vec<i32> {
unsafe {
let start = tuple.0 as *const i32;
let end = tuple.1 as *const i32;
let len = (end as usize - start as usize) / 4;
std::slice::from_raw_parts(start, len).to_vec()
}
}
#[inline]
pub fn read_f32_slice(tuple: (i32, i32)) -> Vec<f32> {
unsafe {
let start = tuple.0 as *const f32;
let end = tuple.1 as *const f32;
let len = (end as usize - start as usize) / 4;
std::slice::from_raw_parts(start, len).to_vec()
}
}

View File

@@ -27,7 +27,6 @@ export function createWasmWrapper(buffer: ArrayBuffer, memory: WebAssembly.Memor
exports = instance.exports as NodariumExports;
function execute(outputPos: number, args: number[]): number {
console.log('WASM_WRAPPER', { outputPos, args });
return exports.execute(outputPos, ...args);
}