1845 lines
57 KiB
MoonBit
1845 lines
57 KiB
MoonBit
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
|
|
|
///|
|
|
fn wasmImportResourceDropSurface(resource : Int) = "wasi-gfx:surface/surface@0.2.0" "[resource-drop]surface"
|
|
|
|
///|
|
|
fn wasmImportConstructorSurface(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[constructor]surface"
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceHeight(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.height"
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceWidth(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.width"
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceRequestSetSize(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) = "wasi-gfx:surface/surface@0.2.0" "[method]surface.request-set-size"
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnResize(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-resize"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-resize"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-resize"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-resize"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(8 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
ignore((ptr, start, length))
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Lift(ptr : Int) -> ResizeEvent {
|
|
|
|
ResizeEvent::{height : (mbt_ffi_load32((ptr) + 0)).reinterpret_as_uint(), width : (mbt_ffi_load32((ptr) + 4)).reinterpret_as_uint()}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[ResizeEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 8)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[ResizeEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamLift(handle : Int) -> @async-core.Stream[ResizeEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnResizeStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnFrame(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-frame"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-frame"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-frame"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-frame"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(1 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
ignore((ptr, start, length))
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Lift(ptr : Int) -> FrameEvent {
|
|
|
|
FrameEvent::{nothing : (mbt_ffi_load8_u((ptr) + 0) != 0)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[FrameEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 1)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[FrameEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamLift(handle : Int) -> @async-core.Stream[FrameEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnFrameStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnPointerUp(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-pointer-up"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-pointer-up"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-pointer-up"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-pointer-up"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(16 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
ignore((ptr, start, length))
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Lift(ptr : Int) -> PointerEvent {
|
|
|
|
PointerEvent::{x : mbt_ffi_loadf64((ptr) + 0), y : mbt_ffi_loadf64((ptr) + 8)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[PointerEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 16)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[PointerEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamLift(handle : Int) -> @async-core.Stream[PointerEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerUpStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnPointerDown(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-pointer-down"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-pointer-down"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-pointer-down"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-pointer-down"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(16 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
ignore((ptr, start, length))
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Lift(ptr : Int) -> PointerEvent {
|
|
|
|
PointerEvent::{x : mbt_ffi_loadf64((ptr) + 0), y : mbt_ffi_loadf64((ptr) + 8)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[PointerEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 16)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[PointerEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamLift(handle : Int) -> @async-core.Stream[PointerEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerDownStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnPointerMove(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-pointer-move"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-pointer-move"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-pointer-move"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-pointer-move"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(16 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
ignore((ptr, start, length))
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Lift(ptr : Int) -> PointerEvent {
|
|
|
|
PointerEvent::{x : mbt_ffi_loadf64((ptr) + 0), y : mbt_ffi_loadf64((ptr) + 8)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[PointerEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 16)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[PointerEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamLift(handle : Int) -> @async-core.Stream[PointerEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnPointerMoveStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnKeyUp(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-key-up"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-key-up"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-key-up"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-key-up"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(20 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
|
|
for i in start..<(start + length) {
|
|
let elem_ptr = ptr + i * 20
|
|
|
|
match (mbt_ffi_load8_u((elem_ptr) + 4)) {
|
|
0 => ()
|
|
1 => {
|
|
mbt_ffi_free(mbt_ffi_load32((elem_ptr) + 8))
|
|
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Lift(ptr : Int) -> KeyEvent {
|
|
|
|
let lifted : Key? = match mbt_ffi_load8_u((ptr) + 0) {
|
|
0 => Option::None
|
|
1 => {
|
|
|
|
Option::Some(Key::from(mbt_ffi_load8_u((ptr) + 1)))
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
let lifted0 : String? = match mbt_ffi_load8_u((ptr) + 4) {
|
|
0 => Option::None
|
|
1 => {
|
|
|
|
let result = mbt_ffi_ptr2str(mbt_ffi_load32((ptr) + 8), mbt_ffi_load32((ptr) + 12))
|
|
|
|
Option::Some(result)
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
KeyEvent::{key : lifted, text : lifted0, alt_key : (mbt_ffi_load8_u((ptr) + 16) != 0), ctrl_key : (mbt_ffi_load8_u((ptr) + 17) != 0), meta_key : (mbt_ffi_load8_u((ptr) + 18) != 0), shift_key : (mbt_ffi_load8_u((ptr) + 19) != 0)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[KeyEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 20)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[KeyEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamLift(handle : Int) -> @async-core.Stream[KeyEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyUpStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
fn wasmImportMethodSurfaceOnKeyDown(p0 : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[method]surface.on-key-down"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Read(handle : Int, buffer_ptr : Int, length : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[async-lower][stream-read-0][method]surface.on-key-down"
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0CancelRead(handle : Int) -> Int = "wasi-gfx:surface/surface@0.2.0" "[stream-cancel-read-0][method]surface.on-key-down"
|
|
|
|
///|
|
|
fn wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0DropReadable(handle : Int) = "wasi-gfx:surface/surface@0.2.0" "[stream-drop-readable-0][method]surface.on-key-down"
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Malloc(length : Int) -> Int {
|
|
let ptr = mbt_ffi_malloc(20 * length)
|
|
ptr
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Reject(
|
|
ptr : Int,
|
|
start : Int,
|
|
length : Int,
|
|
) -> Unit {
|
|
|
|
for i in start..<(start + length) {
|
|
let elem_ptr = ptr + i * 20
|
|
|
|
match (mbt_ffi_load8_u((elem_ptr) + 4)) {
|
|
0 => ()
|
|
1 => {
|
|
mbt_ffi_free(mbt_ffi_load32((elem_ptr) + 8))
|
|
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Lift(ptr : Int) -> KeyEvent {
|
|
|
|
let lifted : Key? = match mbt_ffi_load8_u((ptr) + 0) {
|
|
0 => Option::None
|
|
1 => {
|
|
|
|
Option::Some(Key::from(mbt_ffi_load8_u((ptr) + 1)))
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
let lifted0 : String? = match mbt_ffi_load8_u((ptr) + 4) {
|
|
0 => Option::None
|
|
1 => {
|
|
|
|
let result = mbt_ffi_ptr2str(mbt_ffi_load32((ptr) + 8), mbt_ffi_load32((ptr) + 12))
|
|
|
|
Option::Some(result)
|
|
}
|
|
_ => panic()
|
|
}
|
|
|
|
KeyEvent::{key : lifted, text : lifted0, alt_key : (mbt_ffi_load8_u((ptr) + 16) != 0), ctrl_key : (mbt_ffi_load8_u((ptr) + 17) != 0), meta_key : (mbt_ffi_load8_u((ptr) + 18) != 0), shift_key : (mbt_ffi_load8_u((ptr) + 19) != 0)}
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0ListLift(
|
|
ptr : Int,
|
|
length : Int,
|
|
) -> FixedArray[KeyEvent] {
|
|
|
|
FixedArray::makei(
|
|
length,
|
|
(index) => {
|
|
let ptr = (ptr) + (index * 20)
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Lift(ptr)
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
///|
|
|
priv struct WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource {
|
|
handle : Int
|
|
mut closed : Bool
|
|
mut reading : Bool
|
|
mut read_task : Int
|
|
mut read_buffer : Int
|
|
mut read_discarding : Bool
|
|
mut read_cleanup_done : Bool
|
|
read_cleanup : @async-core.CondVar
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::finish_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
) -> Unit {
|
|
self.reading = false
|
|
self.read_task = 0
|
|
self.read_buffer = 0
|
|
self.read_discarding = false
|
|
// Keep completion latched until a later read starts so every waiter woken
|
|
// by the broadcast can observe it.
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::wait_for_read_cleanup(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
while !self.read_cleanup_done {
|
|
self.read_cleanup.wait()
|
|
}
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::cancel_active_read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if !self.reading {
|
|
return
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
return
|
|
}
|
|
self.read_discarding = true
|
|
let progress_ref = Ref(0)
|
|
@async-core.protect_from_cancel(
|
|
() => {
|
|
progress_ref.val = @async-core.cancel_stream_read(
|
|
self.read_task,
|
|
self.handle,
|
|
() => wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0CancelRead(self.handle),
|
|
)
|
|
},
|
|
) catch {
|
|
_ => ()
|
|
}
|
|
let progress = progress_ref.val
|
|
if progress > 0 && self.read_buffer != 0 {
|
|
wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Reject(self.read_buffer, 0, progress)
|
|
}
|
|
self.read_cleanup_done = true
|
|
self.read_cleanup.broadcast()
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::close(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
) -> Unit noraise {
|
|
if self.closed {
|
|
return
|
|
}
|
|
if self.reading {
|
|
self.cancel_active_read()
|
|
}
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::close_sync(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
) -> Unit {
|
|
if self.closed || self.reading {
|
|
return
|
|
}
|
|
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0DropReadable(self.handle)
|
|
}
|
|
|
|
///|
|
|
async fn WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::read(
|
|
self : WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource,
|
|
count : Int,
|
|
) -> FixedArray[KeyEvent]? {
|
|
if self.closed {
|
|
return None
|
|
}
|
|
if count <= 0 {
|
|
return Some([])
|
|
}
|
|
if self.reading {
|
|
raise @async-core.EndpointBusy::Read
|
|
}
|
|
// `Stream.read` promises at most `count`; bound one canonical allocation.
|
|
let read_count = if count < 64 {
|
|
count
|
|
} else {
|
|
64
|
|
}
|
|
let ptr = wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Malloc(read_count)
|
|
let mut owns_buffer = false
|
|
defer {
|
|
if !owns_buffer {
|
|
mbt_ffi_free(ptr)
|
|
}
|
|
}
|
|
self.reading = true
|
|
self.read_task = @async-core.current_component_task_token()
|
|
self.read_buffer = ptr
|
|
self.read_discarding = false
|
|
self.read_cleanup_done = false
|
|
// Capture cancellation below so canonical read cleanup can inspect the
|
|
// active read state before this reset runs.
|
|
errdefer self.finish_read()
|
|
let outcome = @async-core.handle_cancellation(() =>
|
|
@async-core.suspend_for_stream_read(
|
|
self.handle,
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0Read(self.handle, ptr, read_count),
|
|
),
|
|
) catch {
|
|
err =>
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
} else {
|
|
raise err
|
|
}
|
|
}
|
|
let (progress, end) = match outcome {
|
|
Some(result) => result
|
|
None => {
|
|
self.cancel_active_read()
|
|
if !self.closed {
|
|
self.closed = true
|
|
wasmImportWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0DropReadable(self.handle)
|
|
}
|
|
@async-core.raise_cancellation_signal()
|
|
}
|
|
}
|
|
if self.read_discarding {
|
|
self.wait_for_read_cleanup()
|
|
self.finish_read()
|
|
return None
|
|
}
|
|
if progress == 0 {
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
return None
|
|
}
|
|
return Some([])
|
|
}
|
|
let values = wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0ListLift(ptr, progress)
|
|
owns_buffer = false
|
|
self.finish_read()
|
|
if end {
|
|
self.close()
|
|
}
|
|
Some(values)
|
|
}
|
|
|
|
///|
|
|
fn wasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamLift(handle : Int) -> @async-core.Stream[KeyEvent] {
|
|
let source = WasmWasiGfxSurfaceSurface020MethodSurfaceOnKeyDownStream0StreamSource::{
|
|
handle,
|
|
closed: false,
|
|
reading: false,
|
|
read_task: 0,
|
|
read_buffer: 0,
|
|
read_discarding: false,
|
|
read_cleanup_done: false,
|
|
read_cleanup: CondVar(),
|
|
}
|
|
@async-core.Stream::from_source(
|
|
(count) => source.read(count),
|
|
() => source.close(),
|
|
() => source.close_sync(),
|
|
)
|
|
}
|
|
|
|
///|
|
|
extern "wasm" fn mbt_ffi_free(position : Int) =
|
|
#|(func (param i32) local.get 0 call $moonbit.decref)
|
|
|
|
///|
|
|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
|
#|(func (param i32) (result i32) local.get 0 i32.load)
|
|
|
|
///|
|
|
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
|
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
|
|
|
///|
|
|
extern "wasm" fn mbt_ffi_loadf64(offset : Int) -> Double =
|
|
#|(func (param i32) (result f64) local.get 0 f64.load)
|
|
|
|
///|
|
|
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_ptr2str(ptr : Int, len : Int) -> String =
|
|
#|(func (param i32) (param i32) (result i32)
|
|
#| local.get 0
|
|
#| local.get 1 call $moonbit.init_array16
|
|
#| local.get 0)
|
|
|