mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 16:20:49 +00:00
Make import_func_new/destroy not const
This commit is contained in:
parent
6570bd433d
commit
628caf0a74
@ -1142,7 +1142,7 @@ pub unsafe extern "C" fn wasmer_import_func_new(
|
||||
params_len: c_int,
|
||||
returns: *const wasmer_value_tag,
|
||||
returns_len: c_int,
|
||||
) -> *const wasmer_import_func_t {
|
||||
) -> *mut wasmer_import_func_t {
|
||||
let params: &[wasmer_value_tag] = slice::from_raw_parts(params, params_len as usize);
|
||||
let params: Vec<Type> = params.iter().cloned().map(|x| x.into()).collect();
|
||||
let returns: &[wasmer_value_tag] = slice::from_raw_parts(returns, returns_len as usize);
|
||||
@ -1153,7 +1153,7 @@ pub unsafe extern "C" fn wasmer_import_func_new(
|
||||
ctx: Context::Internal,
|
||||
signature: Arc::new(FuncSig::new(params, returns)),
|
||||
});
|
||||
Box::into_raw(export) as *const wasmer_import_func_t
|
||||
Box::into_raw(export) as *mut wasmer_import_func_t
|
||||
}
|
||||
|
||||
/// Sets the params buffer to the parameter types of the given wasmer_import_func_t
|
||||
|
@ -31,7 +31,7 @@ int main()
|
||||
wasmer_value_tag returns_sig[] = {};
|
||||
|
||||
printf("Creating new func\n");
|
||||
const wasmer_import_func_t *func = wasmer_import_func_new((void (*)(void *)) print_str, params_sig, 2, returns_sig, 0);
|
||||
wasmer_import_func_t *func = wasmer_import_func_new((void (*)(void *)) print_str, params_sig, 2, returns_sig, 0);
|
||||
wasmer_import_t import;
|
||||
|
||||
char *module_name = "env";
|
||||
|
@ -32,7 +32,7 @@ int main()
|
||||
// of our `print_str` host function
|
||||
wasmer_value_tag params_sig[] = {WASM_I32, WASM_I32};
|
||||
wasmer_value_tag returns_sig[] = {};
|
||||
const wasmer_import_func_t *func = wasmer_import_func_new((void (*)(void *)) print_str, params_sig, 2, returns_sig, 0);
|
||||
wasmer_import_func_t *func = wasmer_import_func_new((void (*)(void *)) print_str, params_sig, 2, returns_sig, 0);
|
||||
|
||||
// Create module name for our imports
|
||||
// represented in bytes for UTF-8 compatability
|
||||
|
@ -319,17 +319,17 @@ int wasmer_import_descriptors_len(wasmer_import_descriptors_t *exports);
|
||||
/**
|
||||
* Frees memory for the given Func
|
||||
*/
|
||||
void wasmer_import_func_destroy(const wasmer_import_func_t *func);
|
||||
void wasmer_import_func_destroy(wasmer_import_func_t *func);
|
||||
|
||||
/**
|
||||
* Creates new func
|
||||
* The caller owns the object and should call `wasmer_import_func_destroy` to free it.
|
||||
*/
|
||||
const wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
|
||||
const wasmer_value_tag *params,
|
||||
int params_len,
|
||||
const wasmer_value_tag *returns,
|
||||
int returns_len);
|
||||
wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
|
||||
const wasmer_value_tag *params,
|
||||
int params_len,
|
||||
const wasmer_value_tag *returns,
|
||||
int returns_len);
|
||||
|
||||
/**
|
||||
* Sets the params buffer to the parameter types of the given wasmer_import_func_t
|
||||
|
@ -256,15 +256,15 @@ wasmer_import_descriptor_t *wasmer_import_descriptors_get(wasmer_import_descript
|
||||
int wasmer_import_descriptors_len(wasmer_import_descriptors_t *exports);
|
||||
|
||||
/// Frees memory for the given Func
|
||||
void wasmer_import_func_destroy(const wasmer_import_func_t *func);
|
||||
void wasmer_import_func_destroy(wasmer_import_func_t *func);
|
||||
|
||||
/// Creates new func
|
||||
/// The caller owns the object and should call `wasmer_import_func_destroy` to free it.
|
||||
const wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
|
||||
const wasmer_value_tag *params,
|
||||
int params_len,
|
||||
const wasmer_value_tag *returns,
|
||||
int returns_len);
|
||||
wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
|
||||
const wasmer_value_tag *params,
|
||||
int params_len,
|
||||
const wasmer_value_tag *returns,
|
||||
int returns_len);
|
||||
|
||||
/// Sets the params buffer to the parameter types of the given wasmer_import_func_t
|
||||
/// Returns `wasmer_result_t::WASMER_OK` upon success.
|
||||
|
Loading…
x
Reference in New Issue
Block a user