Skip to content

Commit 12462db

Browse files
jimpoVeykril
authored andcommitted
Remove unsupported functions
Remove public functions that cannot be implemented with the new wasm3 public API.
1 parent 9eb9bf4 commit 12462db

File tree

3 files changed

+0
-95
lines changed

3 files changed

+0
-95
lines changed

src/function.rs

-5
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ where
100100
Args: WasmArgs,
101101
Ret: WasmType,
102102
{
103-
/// The name of the import module of this function.
104-
pub fn import_module_name(&self) -> &str {
105-
unsafe { cstr_to_str(self.raw.as_ref().import.moduleUtf8) }
106-
}
107-
108103
/// The name of this function.
109104
pub fn name(&self) -> &str {
110105
unsafe { cstr_to_str(self.raw.as_ref().name) }

src/module.rs

-30
Original file line numberDiff line numberDiff line change
@@ -164,36 +164,6 @@ impl<'rt> Module<'rt> {
164164
Function::from_raw(self.rt, func).and_then(Function::compile)
165165
}
166166

167-
/// Looks up a function by its index in this module.
168-
///
169-
/// # Errors
170-
///
171-
/// This function will return an error in the following situations:
172-
///
173-
/// * a memory allocation failed
174-
/// * the index is out of bounds
175-
/// * the function has been found but the signature did not match
176-
pub fn function<Args, Ret>(&self, function_index: usize) -> Result<Function<'rt, Args, Ret>>
177-
where
178-
Args: crate::WasmArgs,
179-
Ret: crate::WasmType,
180-
{
181-
let func = unsafe {
182-
slice::from_raw_parts_mut(
183-
if (*self.raw).functions.is_null() {
184-
NonNull::dangling().as_ptr()
185-
} else {
186-
(*self.raw).functions
187-
},
188-
(*self.raw).numFunctions as usize,
189-
)
190-
.get(function_index)
191-
.map(NonNull::from)
192-
.ok_or(Error::FunctionNotFound)?
193-
};
194-
Function::from_raw(self.rt, func).and_then(Function::compile)
195-
}
196-
197167
/// The name of this module.
198168
pub fn name(&self) -> &str {
199169
unsafe { cstr_to_str((*self.raw).name) }

src/runtime.rs

-60
Original file line numberDiff line numberDiff line change
@@ -91,46 +91,6 @@ impl Runtime {
9191
.unwrap_or(Err(Error::FunctionNotFound))
9292
}
9393

94-
/// Searches for a module with the given name in the runtime's loaded modules.
95-
///
96-
/// Using this over searching through [`Runtime::modules`] is a bit more efficient as it
97-
/// works on the underlying CStrings directly and doesn't require an upfront length calculation.
98-
///
99-
/// [`Runtime::modules`]: struct.Runtime.html#method.modules
100-
pub fn find_module<'rt>(&'rt self, name: &str) -> Result<Module<'rt>> {
101-
unsafe {
102-
let mut module = ptr::NonNull::new(self.raw.as_ref().modules);
103-
while let Some(raw_mod) = module {
104-
if eq_cstr_str(raw_mod.as_ref().name, name) {
105-
return Ok(Module::from_raw(self, raw_mod.as_ptr()));
106-
}
107-
108-
module = ptr::NonNull::new(raw_mod.as_ref().next);
109-
}
110-
Err(Error::ModuleNotFound)
111-
}
112-
}
113-
114-
/// Returns an iterator over the runtime's loaded modules.
115-
pub fn modules<'rt>(&'rt self) -> impl Iterator<Item = Module<'rt>> + 'rt {
116-
// pointer could get invalidated if modules can become unloaded
117-
// pushing new modules into the runtime while this iterator exists is fine as its backed by a linked list meaning it wont get invalidated.
118-
let mut module = unsafe { ptr::NonNull::new(self.raw.as_ref().modules) };
119-
core::iter::from_fn(move || {
120-
let next = unsafe { module.and_then(|module| ptr::NonNull::new(module.as_ref().next)) };
121-
mem::replace(&mut module, next).map(|raw| Module::from_raw(self, raw.as_ptr()))
122-
})
123-
}
124-
125-
/// Resizes the number of allocatable pages to num_pages.
126-
///
127-
/// # Errors
128-
///
129-
/// This function will error out if it failed to resize memory allocation.
130-
pub fn resize_memory(&self, num_pages: u32) -> Result<()> {
131-
Error::from_ffi_res(unsafe { ffi::ResizeMemory(self.raw.as_ptr(), num_pages) })
132-
}
133-
13494
/// Returns the raw memory of this runtime.
13595
///
13696
/// # Safety
@@ -160,26 +120,6 @@ impl Runtime {
160120
};
161121
ptr::slice_from_raw_parts_mut(data, len)
162122
}
163-
164-
/// Returns the stack of this runtime.
165-
pub fn stack(&self) -> *const [ffi::m3slot_t] {
166-
unsafe {
167-
ptr::slice_from_raw_parts(
168-
self.raw.as_ref().stack.cast::<ffi::m3slot_t>(),
169-
self.raw.as_ref().numStackSlots as usize,
170-
)
171-
}
172-
}
173-
174-
/// Returns the stack of this runtime.
175-
pub fn stack_mut(&self) -> *mut [ffi::m3slot_t] {
176-
unsafe {
177-
ptr::slice_from_raw_parts_mut(
178-
self.raw.as_ref().stack.cast::<ffi::m3slot_t>(),
179-
self.raw.as_ref().numStackSlots as usize,
180-
)
181-
}
182-
}
183123
}
184124

185125
impl Runtime {

0 commit comments

Comments
 (0)