1pub const MAX_FLAT_PARAMS: usize = 16;
26
27pub const MAX_FLAT_ASYNC_PARAMS: usize = 4;
30
31pub const MAX_FLAT_RESULTS: usize = 1;
35
36pub const PREPARE_ASYNC_NO_RESULT: u32 = u32::MAX;
40
41pub const PREPARE_ASYNC_WITH_RESULT: u32 = u32::MAX - 1;
46
47pub const START_FLAG_ASYNC_CALLEE: i32 = 1 << 0;
53
54mod artifacts;
55mod info;
56mod intrinsic;
57mod names;
58mod types;
59mod vmcomponent_offsets;
60pub use self::artifacts::*;
61pub use self::info::*;
62pub use self::intrinsic::*;
63pub use self::names::*;
64pub use self::types::*;
65pub use self::vmcomponent_offsets::*;
66
67#[cfg(feature = "compile")]
68mod compiler;
69#[cfg(feature = "compile")]
70pub mod dfg;
71#[cfg(feature = "compile")]
72mod translate;
73#[cfg(feature = "compile")]
74mod types_builder;
75#[cfg(feature = "compile")]
76pub use self::compiler::*;
77#[cfg(feature = "compile")]
78pub use self::translate::*;
79#[cfg(feature = "compile")]
80pub use self::types_builder::*;
81
82#[macro_export]
85macro_rules! foreach_builtin_component_function {
86 ($mac:ident) => {
87 $mac! {
88 resource_new32(vmctx: vmctx, caller_instance: u32, resource: u32, rep: u32) -> u64;
89 resource_rep32(vmctx: vmctx, caller_instance: u32, resource: u32, idx: u32) -> u64;
90
91 resource_drop(vmctx: vmctx, caller_instance: u32, resource: u32, idx: u32) -> u64;
96
97 resource_transfer_own(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
98 resource_transfer_borrow(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
99 resource_enter_call(vmctx: vmctx);
100 resource_exit_call(vmctx: vmctx) -> bool;
101
102 #[cfg(feature = "component-model-async")]
103 backpressure_set(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
104 #[cfg(feature = "component-model-async")]
105 backpressure_modify(vmctx: vmctx, caller_instance: u32, increment: u8) -> bool;
106 #[cfg(feature = "component-model-async")]
107 task_return(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, storage: ptr_u8, storage_len: size) -> bool;
108 #[cfg(feature = "component-model-async")]
109 task_cancel(vmctx: vmctx, caller_instance: u32) -> bool;
110 #[cfg(feature = "component-model-async")]
111 waitable_set_new(vmctx: vmctx, caller_instance: u32) -> u64;
112 #[cfg(feature = "component-model-async")]
113 waitable_set_wait(vmctx: vmctx, caller_instance: u32, options: u32, set: u32, payload: u32) -> u64;
114 #[cfg(feature = "component-model-async")]
115 waitable_set_poll(vmctx: vmctx, caller_instance: u32, options: u32, set: u32, payload: u32) -> u64;
116 #[cfg(feature = "component-model-async")]
117 waitable_set_drop(vmctx: vmctx, caller_instance: u32, set: u32) -> bool;
118 #[cfg(feature = "component-model-async")]
119 waitable_join(vmctx: vmctx, caller_instance: u32, set: u32, waitable: u32) -> bool;
120 #[cfg(feature = "component-model-async")]
121 thread_yield(vmctx: vmctx, caller_instance: u32, cancellable: u8) -> u32;
122 #[cfg(feature = "component-model-async")]
123 subtask_drop(vmctx: vmctx, caller_instance: u32, task_id: u32) -> bool;
124 #[cfg(feature = "component-model-async")]
125 subtask_cancel(vmctx: vmctx, caller_instance: u32, async_: u8, task_id: u32) -> u64;
126 #[cfg(feature = "component-model-async")]
127 prepare_call(
128 vmctx: vmctx,
129 memory: ptr_u8,
130 start: ptr_u8,
131 return_: ptr_u8,
132 caller_instance: u32,
133 callee_instance: u32,
134 task_return_type: u32,
135 string_encoding: u32,
136 result_count_or_max_if_async: u32,
137 storage: ptr_u8,
138 storage_len: size
139 ) -> bool;
140 #[cfg(feature = "component-model-async")]
141 sync_start(vmctx: vmctx, callback: ptr_u8, storage: ptr_u8, storage_len: size, callee: ptr_u8, param_count: u32) -> bool;
142 #[cfg(feature = "component-model-async")]
143 async_start(vmctx: vmctx, callback: ptr_u8, post_return: ptr_u8, callee: ptr_u8, param_count: u32, result_count: u32, flags: u32) -> u64;
144 #[cfg(feature = "component-model-async")]
145 future_new(vmctx: vmctx, caller_instance: u32, ty: u32) -> u64;
146 #[cfg(feature = "component-model-async")]
147 future_write(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, future: u32, address: u32) -> u64;
148 #[cfg(feature = "component-model-async")]
149 future_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, future: u32, address: u32) -> u64;
150 #[cfg(feature = "component-model-async")]
151 future_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
152 #[cfg(feature = "component-model-async")]
153 future_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
154 #[cfg(feature = "component-model-async")]
155 future_drop_writable(vmctx: vmctx, caller_instance: u32, ty: u32, writer: u32) -> bool;
156 #[cfg(feature = "component-model-async")]
157 future_drop_readable(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32) -> bool;
158 #[cfg(feature = "component-model-async")]
159 stream_new(vmctx: vmctx, caller_instance: u32, ty: u32) -> u64;
160 #[cfg(feature = "component-model-async")]
161 stream_write(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, stream: u32, address: u32, count: u32) -> u64;
162 #[cfg(feature = "component-model-async")]
163 stream_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, stream: u32, address: u32, count: u32) -> u64;
164 #[cfg(feature = "component-model-async")]
165 stream_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
166 #[cfg(feature = "component-model-async")]
167 stream_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
168 #[cfg(feature = "component-model-async")]
169 stream_drop_writable(vmctx: vmctx, caller_instance: u32, ty: u32, writer: u32) -> bool;
170 #[cfg(feature = "component-model-async")]
171 stream_drop_readable(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32) -> bool;
172 #[cfg(feature = "component-model-async")]
173 flat_stream_write(vmctx: vmctx, caller_instance: u32, ty: u32, options:u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
174 #[cfg(feature = "component-model-async")]
175 flat_stream_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
176 #[cfg(feature = "component-model-async")]
177 error_context_new(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, debug_msg_address: u32, debug_msg_len: u32) -> u64;
178 #[cfg(feature = "component-model-async")]
179 error_context_debug_message(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, err_ctx_handle: u32, debug_msg_address: u32) -> bool;
180 #[cfg(feature = "component-model-async")]
181 error_context_drop(vmctx: vmctx, caller_instance: u32, ty: u32, err_ctx_handle: u32) -> bool;
182 #[cfg(feature = "component-model-async")]
183 future_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
184 #[cfg(feature = "component-model-async")]
185 stream_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
186 #[cfg(feature = "component-model-async")]
187 error_context_transfer(vmctx: vmctx, src_idx: u32, src_table: u32, dst_table: u32) -> u64;
188 #[cfg(feature = "component-model-async")]
189 context_get(vmctx: vmctx, caller_instance: u32, slot: u32) -> u64;
190 #[cfg(feature = "component-model-async")]
191 context_set(vmctx: vmctx, caller_instance: u32, slot: u32, val: u32) -> bool;
192
193 trap(vmctx: vmctx, code: u8) -> bool;
194
195 utf8_to_utf8(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8) -> bool;
196 utf16_to_utf16(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u16) -> bool;
197 latin1_to_latin1(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8) -> bool;
198 latin1_to_utf16(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u16) -> bool;
199 utf8_to_utf16(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u16) -> size;
200 utf16_to_utf8(vmctx: vmctx, src: ptr_u16, src_len: size, dst: ptr_u8, dst_len: size, ret2: ptr_size) -> size;
201 latin1_to_utf8(vmctx: vmctx, src: ptr_u8, src_len: size, dst: ptr_u8, dst_len: size, ret2: ptr_size) -> size;
202 utf16_to_compact_probably_utf16(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u16) -> size;
203 utf8_to_latin1(vmctx: vmctx, src: ptr_u8, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
204 utf16_to_latin1(vmctx: vmctx, src: ptr_u16, len: size, dst: ptr_u8, ret2: ptr_size) -> size;
205 utf8_to_compact_utf16(vmctx: vmctx, src: ptr_u8, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
206 utf16_to_compact_utf16(vmctx: vmctx, src: ptr_u16, src_len: size, dst: ptr_u16, dst_len: size, bytes_so_far: size) -> size;
207 }
208 };
209}
210
211declare_builtin_index! {
213 pub struct ComponentBuiltinFunctionIndex: foreach_builtin_component_function;
215}