This commit is contained in:
1 parent
ccb809bdc3
commit
7caadb3f7f
59 files changed
+7495
-16
No files matched your search
@@ -0,0 +1,38 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportResourceDropBuffer(resource : Int) = "wasi-gfx:frame-buffer/frame-buffer@0.2.0" "[resource-drop]buffer"
|
||||
|
||||
///|
|
||||
fn wasmImportMethodBufferGetWithCopy(p0 : Int, p1 : Int) = "wasi-gfx:frame-buffer/frame-buffer@0.2.0" "[method]buffer.get-with-copy"
|
||||
|
||||
///|
|
||||
fn wasmImportMethodBufferSetWithCopy(p0 : Int, p1 : Int, p2 : Int) = "wasi-gfx:frame-buffer/frame-buffer@0.2.0" "[method]buffer.set-with-copy"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,16 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "moonplasma/desktop/interface/wasi-gfx/frame-buffer/frame-buffer"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub(all) struct Buffer(Int32)
|
||||
pub fn Buffer::drop(Self) -> Unit
|
||||
pub fn Buffer::get_with_copy(Self) -> FixedArray[Byte]
|
||||
pub fn Buffer::set_with_copy(Self, FixedArray[Byte]) -> Unit
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -0,0 +1,36 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct Buffer(Int) derive()
|
||||
|
||||
///|
|
||||
/// Drops a resource handle.
|
||||
pub fn Buffer::drop(self : Buffer) -> Unit {
|
||||
let Buffer(resource) = self
|
||||
wasmImportResourceDropBuffer(resource)
|
||||
}
|
||||
///|
|
||||
/// TODO: This should be replaced with something that doesn't require a copy.
|
||||
pub fn Buffer::get_with_copy(self : Buffer) -> FixedArray[Byte] {
|
||||
|
||||
let Buffer(handle) = self
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportMethodBufferGetWithCopy(handle, return_area);
|
||||
|
||||
let result = mbt_ffi_ptr2bytes(mbt_ffi_load32((return_area) + 0), mbt_ffi_load32((return_area) + 4))
|
||||
let ret = result
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn Buffer::set_with_copy(self : Buffer, val : FixedArray[Byte]) -> Unit {
|
||||
|
||||
let Buffer(handle) = self
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(val)
|
||||
|
||||
wasmImportMethodBufferSetWithCopy(handle, ptr, val.length());
|
||||
mbt_ffi_free(ptr)
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user