Make import_func_new/destroy not const

This commit is contained in:
Brandon Fish
2019-03-07 22:59:11 -06:00
parent 6570bd433d
commit 628caf0a74
5 changed files with 16 additions and 16 deletions

View File

@ -1142,7 +1142,7 @@ pub unsafe extern "C" fn wasmer_import_func_new(
params_len: c_int, params_len: c_int,
returns: *const wasmer_value_tag, returns: *const wasmer_value_tag,
returns_len: c_int, 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: &[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 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); 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, ctx: Context::Internal,
signature: Arc::new(FuncSig::new(params, returns)), 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 /// Sets the params buffer to the parameter types of the given wasmer_import_func_t

View File

@ -31,7 +31,7 @@ int main()
wasmer_value_tag returns_sig[] = {}; wasmer_value_tag returns_sig[] = {};
printf("Creating new func\n"); 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; wasmer_import_t import;
char *module_name = "env"; char *module_name = "env";

View File

@ -32,7 +32,7 @@ int main()
// of our `print_str` host function // of our `print_str` host function
wasmer_value_tag params_sig[] = {WASM_I32, WASM_I32}; wasmer_value_tag params_sig[] = {WASM_I32, WASM_I32};
wasmer_value_tag returns_sig[] = {}; 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 // Create module name for our imports
// represented in bytes for UTF-8 compatability // represented in bytes for UTF-8 compatability

View File

@ -319,13 +319,13 @@ int wasmer_import_descriptors_len(wasmer_import_descriptors_t *exports);
/** /**
* Frees memory for the given Func * 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 * Creates new func
* The caller owns the object and should call `wasmer_import_func_destroy` to free it. * 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), wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
const wasmer_value_tag *params, const wasmer_value_tag *params,
int params_len, int params_len,
const wasmer_value_tag *returns, const wasmer_value_tag *returns,

View File

@ -256,11 +256,11 @@ wasmer_import_descriptor_t *wasmer_import_descriptors_get(wasmer_import_descript
int wasmer_import_descriptors_len(wasmer_import_descriptors_t *exports); int wasmer_import_descriptors_len(wasmer_import_descriptors_t *exports);
/// Frees memory for the given Func /// 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 /// Creates new func
/// The caller owns the object and should call `wasmer_import_func_destroy` to free it. /// 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), wasmer_import_func_t *wasmer_import_func_new(void (*func)(void *data),
const wasmer_value_tag *params, const wasmer_value_tag *params,
int params_len, int params_len,
const wasmer_value_tag *returns, const wasmer_value_tag *returns,