mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-18 03:11:21 +00:00
Remove unused API functions
This commit is contained in:
@ -157,13 +157,6 @@ pub unsafe extern "C" fn wasmer_validate(
|
|||||||
wasmer_runtime_core::validate(bytes)
|
wasmer_runtime_core::validate(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new ImportObject and returns a pointer to it.
|
|
||||||
/// The caller owns the object and should call `wasmer_import_object_destroy` to free it.
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn wasmer_import_object_new() -> *mut wasmer_import_object_t {
|
|
||||||
Box::into_raw(Box::new(ImportObject::new())) as *mut wasmer_import_object_t
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new Memory for the given descriptor and initializes the given
|
/// Creates a new Memory for the given descriptor and initializes the given
|
||||||
/// pointer to pointer to a pointer to the new memory.
|
/// pointer to pointer to a pointer to the new memory.
|
||||||
///
|
///
|
||||||
@ -364,15 +357,6 @@ pub extern "C" fn wasmer_global_destroy(global: *mut wasmer_global_t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Frees memory for the given ImportObject
|
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn wasmer_import_object_destroy(import_object: *mut wasmer_import_object_t) {
|
|
||||||
if !import_object.is_null() {
|
|
||||||
drop(unsafe { Box::from_raw(import_object as *mut ImportObject) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Frees memory for the given Memory
|
/// Frees memory for the given Memory
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -901,53 +885,6 @@ pub unsafe extern "C" fn wasmer_func_call(
|
|||||||
// let named_export = &*(export as *mut NamedExport);
|
// let named_export = &*(export as *mut NamedExport);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// Registers a `func` with provided `name` and `namespace` into the ImportObject.
|
|
||||||
///
|
|
||||||
/// Returns `wasmer_result_t::WASMER_OK` upon success.
|
|
||||||
///
|
|
||||||
/// Returns `wasmer_result_t::WASMER_ERROR` upon failure. Use `wasmer_last_error_length`
|
|
||||||
/// and `wasmer_last_error_message` to get an error message.
|
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern "C" fn wasmer_imports_set_import_func(
|
|
||||||
import_object: *mut wasmer_import_object_t,
|
|
||||||
namespace: *const c_char,
|
|
||||||
name: *const c_char,
|
|
||||||
func: extern "C" fn(data: *mut c_void),
|
|
||||||
params: *const wasmer_value_tag,
|
|
||||||
params_len: c_int,
|
|
||||||
returns: *const wasmer_value_tag,
|
|
||||||
returns_len: c_int,
|
|
||||||
) {
|
|
||||||
let mut import_object = unsafe { Box::from_raw(import_object as *mut ImportObject) };
|
|
||||||
let namespace_c = unsafe { CStr::from_ptr(namespace) };
|
|
||||||
let namespace_r = namespace_c.to_str().unwrap();
|
|
||||||
let name_c = unsafe { CStr::from_ptr(name) };
|
|
||||||
let name_r = name_c.to_str().unwrap();
|
|
||||||
|
|
||||||
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);
|
|
||||||
let returns: Vec<Type> = returns.iter().cloned().map(|x| x.into()).collect();
|
|
||||||
|
|
||||||
let export = Export::Function {
|
|
||||||
func: unsafe { FuncPointer::new(func as _) },
|
|
||||||
ctx: Context::Internal,
|
|
||||||
signature: Arc::new(FuncSig::new(params, returns)),
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO handle existing namespace
|
|
||||||
// let maybe_namespace = import_object.get_namespace(namespace_r);
|
|
||||||
// if let Some(n) = maybe_namespace {
|
|
||||||
// n.insert(name_r, export);
|
|
||||||
// } else {
|
|
||||||
let mut namespace = Namespace::new();
|
|
||||||
namespace.insert(name_r, export);
|
|
||||||
import_object.register(namespace_r, namespace);
|
|
||||||
Box::into_raw(import_object);
|
|
||||||
// };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the memory within the context at the index `memory_idx`.
|
/// Gets the memory within the context at the index `memory_idx`.
|
||||||
/// The index is always 0 until multiple memories are supported.
|
/// The index is always 0 until multiple memories are supported.
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
|
@ -27,7 +27,6 @@ void print_str(wasmer_instance_context_t *ctx, int32_t ptr, int32_t len)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// wasmer_import_object_t *import_object = wasmer_import_object_new();
|
|
||||||
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[] = {};
|
||||||
|
|
||||||
@ -50,10 +49,6 @@ int main()
|
|||||||
import.value.func = func;
|
import.value.func = func;
|
||||||
wasmer_import_t imports[] = {import};
|
wasmer_import_t imports[] = {import};
|
||||||
|
|
||||||
|
|
||||||
// wasmer_imports_set_import_func(import_object, "env", "print_str", print_str, params_sig, 2, returns_sig, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// Read the wasm file bytes
|
// Read the wasm file bytes
|
||||||
FILE *file = fopen("wasm_sample_app.wasm", "r");
|
FILE *file = fopen("wasm_sample_app.wasm", "r");
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
@ -92,7 +87,5 @@ int main()
|
|||||||
// wasmer_func_destroy(func);
|
// wasmer_func_destroy(func);
|
||||||
// printf("Destroy instance\n");
|
// printf("Destroy instance\n");
|
||||||
// wasmer_instance_destroy(instance);
|
// wasmer_instance_destroy(instance);
|
||||||
// printf("Destroy import object\n");
|
|
||||||
// wasmer_import_object_destroy(import_object);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -27,8 +27,6 @@ enum wasmer_value_tag {
|
|||||||
};
|
};
|
||||||
typedef uint32_t wasmer_value_tag;
|
typedef uint32_t wasmer_value_tag;
|
||||||
|
|
||||||
typedef struct wasmer_import_object_t wasmer_import_object_t;
|
|
||||||
|
|
||||||
typedef struct wasmer_instance_context_t wasmer_instance_context_t;
|
typedef struct wasmer_instance_context_t wasmer_instance_context_t;
|
||||||
|
|
||||||
typedef struct wasmer_instance_t wasmer_instance_t;
|
typedef struct wasmer_instance_t wasmer_instance_t;
|
||||||
@ -228,32 +226,6 @@ wasmer_global_t *wasmer_global_new(wasmer_value_t value, bool mutable_);
|
|||||||
*/
|
*/
|
||||||
void wasmer_global_set(wasmer_global_t *global, wasmer_value_t value);
|
void wasmer_global_set(wasmer_global_t *global, wasmer_value_t value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Frees memory for the given ImportObject
|
|
||||||
*/
|
|
||||||
void wasmer_import_object_destroy(wasmer_import_object_t *import_object);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ImportObject and returns a pointer to it.
|
|
||||||
* The caller owns the object and should call `wasmer_import_object_destroy` to free it.
|
|
||||||
*/
|
|
||||||
wasmer_import_object_t *wasmer_import_object_new(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a `func` with provided `name` and `namespace` into the ImportObject.
|
|
||||||
* Returns `wasmer_result_t::WASMER_OK` upon success.
|
|
||||||
* Returns `wasmer_result_t::WASMER_ERROR` upon failure. Use `wasmer_last_error_length`
|
|
||||||
* and `wasmer_last_error_message` to get an error message.
|
|
||||||
*/
|
|
||||||
void wasmer_imports_set_import_func(wasmer_import_object_t *import_object,
|
|
||||||
const char *namespace_,
|
|
||||||
const char *name,
|
|
||||||
void (*func)(void *data),
|
|
||||||
const wasmer_value_tag *params,
|
|
||||||
int params_len,
|
|
||||||
const wasmer_value_tag *returns,
|
|
||||||
int returns_len);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls an instances exported function by `name` with the provided parameters.
|
* Calls an instances exported function by `name` with the provided parameters.
|
||||||
* Results are set using the provided `results` pointer.
|
* Results are set using the provided `results` pointer.
|
||||||
|
@ -24,8 +24,6 @@ enum class wasmer_value_tag : uint32_t {
|
|||||||
WASM_F64,
|
WASM_F64,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wasmer_import_object_t;
|
|
||||||
|
|
||||||
struct wasmer_instance_context_t;
|
struct wasmer_instance_context_t;
|
||||||
|
|
||||||
struct wasmer_instance_t;
|
struct wasmer_instance_t;
|
||||||
@ -189,26 +187,6 @@ wasmer_global_t *wasmer_global_new(wasmer_value_t value, bool mutable_);
|
|||||||
/// Sets the value stored by the given Global
|
/// Sets the value stored by the given Global
|
||||||
void wasmer_global_set(wasmer_global_t *global, wasmer_value_t value);
|
void wasmer_global_set(wasmer_global_t *global, wasmer_value_t value);
|
||||||
|
|
||||||
/// Frees memory for the given ImportObject
|
|
||||||
void wasmer_import_object_destroy(wasmer_import_object_t *import_object);
|
|
||||||
|
|
||||||
/// Creates a new ImportObject and returns a pointer to it.
|
|
||||||
/// The caller owns the object and should call `wasmer_import_object_destroy` to free it.
|
|
||||||
wasmer_import_object_t *wasmer_import_object_new();
|
|
||||||
|
|
||||||
/// Registers a `func` with provided `name` and `namespace` into the ImportObject.
|
|
||||||
/// Returns `wasmer_result_t::WASMER_OK` upon success.
|
|
||||||
/// Returns `wasmer_result_t::WASMER_ERROR` upon failure. Use `wasmer_last_error_length`
|
|
||||||
/// and `wasmer_last_error_message` to get an error message.
|
|
||||||
void wasmer_imports_set_import_func(wasmer_import_object_t *import_object,
|
|
||||||
const char *namespace_,
|
|
||||||
const char *name,
|
|
||||||
void (*func)(void *data),
|
|
||||||
const wasmer_value_tag *params,
|
|
||||||
int params_len,
|
|
||||||
const wasmer_value_tag *returns,
|
|
||||||
int returns_len);
|
|
||||||
|
|
||||||
/// Calls an instances exported function by `name` with the provided parameters.
|
/// Calls an instances exported function by `name` with the provided parameters.
|
||||||
/// Results are set using the provided `results` pointer.
|
/// Results are set using the provided `results` pointer.
|
||||||
/// Returns `wasmer_result_t::WASMER_OK` upon success.
|
/// Returns `wasmer_result_t::WASMER_OK` upon success.
|
||||||
|
Reference in New Issue
Block a user