Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Feb 1, 2021
1 parent b640a8c commit 0861b73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 74 deletions.
4 changes: 4 additions & 0 deletions lib/c-api/wasmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ typedef struct {
} wasmer_wasi_map_dir_entry_t;
#endif

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/**
* Creates a new Module from the given wasm bytes.
*
Expand Down
84 changes: 10 additions & 74 deletions lib/c-api/wasmer_wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ typedef struct wasi_env_t wasi_env_t;
typedef struct wasm_named_extern_t wasm_named_extern_t;
#endif

#if defined(WASMER_WASI_ENABLED)
typedef struct {
uintptr_t size;
wasm_named_extern_t **data;
} wasm_named_extern_vec_t;
#endif

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
Expand All @@ -154,20 +161,6 @@ void wasi_config_capture_stderr(wasi_config_t *config);
void wasi_config_capture_stdout(wasi_config_t *config);
#endif

/**
*Represents a vector of `wasm_named_extern_t`.
*
*Read the documentation of [`wasm_named_extern_t`] to see more concrete examples.
*/
typedef struct {
uintptr_t size;
wasm_named_extern_t **data;
} wasm_named_extern_vec_t;

#if defined(WASMER_WASI_ENABLED)
void wasi_config_arg(wasi_config_t *config, const char *arg);
#endif

#if defined(WASMER_WASI_ENABLED)
void wasi_config_env(wasi_config_t *config, const char *key, const char *value);
#endif
Expand Down Expand Up @@ -257,97 +250,40 @@ void wasm_module_name(const wasm_module_t *module, wasm_name_t *out);
bool wasm_module_set_name(wasm_module_t *module, const wasm_name_t *name);

#if defined(WASMER_WASI_ENABLED)
/**
* Non-standard function to get the module name of a
* `wasm_named_extern_t`.
*/
const wasm_name_t *wasm_named_extern_module(const wasm_named_extern_t *named_extern);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
* Non-standard function to get the name of a `wasm_named_extern_t`.
*/
const wasm_name_t *wasm_named_extern_name(const wasm_named_extern_t *named_extern);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
* Non-standard function to get the wrapped extern of a
* `wasm_named_extern_t`.
*/
const wasm_extern_t *wasm_named_extern_unwrap(const wasm_named_extern_t *named_extern);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
*Performs a deep copy of a vector of [`wasm_named_extern_t`].
*/
void wasm_named_extern_vec_copy(wasm_named_extern_vec_t *out_ptr,
const wasm_named_extern_vec_t *in_ptr);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
*Deletes a vector of [`wasm_named_extern_t`].
*
*# Example
*
*See the [`wasm_named_extern_vec_t`] type to get an example.
*/
void wasm_named_extern_vec_delete(wasm_named_extern_vec_t *ptr);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
*Creates a new vector of [`wasm_named_extern_t`].
*/
void wasm_named_extern_vec_new(wasm_named_extern_vec_t *out,
uintptr_t length,
wasm_named_extern_t *const *init);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
*Creates an empty vector of [`wasm_named_extern_t`].
*
*# Example
*
*```rust # use inline_c::assert_c; # fn main() { # (assert_c! { # #include "tests/wasmer_wasm.h" # int main() { // Creates an empty vector of `wasm_named_extern_t`. wasm_named_extern_vec_t vector; wasm_named_extern_vec_new_empty(&vector);
*
* // Check that it is empty. assert(vector.size == 0);
*
* // Free it. wasm_named_extern_vec_delete(&vector); } # }) # .success(); # } ```
*/
void wasm_named_extern_vec_new_empty(wasm_named_extern_vec_t *out);
#endif

#if defined(WASMER_WASI_ENABLED)
/**
*Creates a new uninitialized vector of [`wasm_named_extern_t`].
*
*# Example
*
*```rust # use inline_c::assert_c; # fn main() { # (assert_c! { # #include "tests/wasmer_wasm.h" # int main() { // Creates an empty vector of `wasm_named_extern_t`. wasm_named_extern_vec_t vector; wasm_named_extern_vec_new_uninitialized(&vector, 3);
*
* // Check that it contains 3 items. assert(vector.size == 3);
*
* // Free it. wasm_named_extern_vec_delete(&vector); } # }) # .success(); # } ```
*/
void wasm_named_extern_vec_new_uninitialized(wasm_named_extern_vec_t *out,
uintptr_t length);
#endif

/**
* Gets the length in bytes of the last error if any, zero otherwise.
*
* This can be used to dynamically allocate a buffer with the correct number of
* bytes needed to store a message.
*
* # Example
*
* See this module's documentation to get a complete example.
*/
void wasm_named_extern_vec_new_uninitialized(wasm_named_extern_vec_t *out, uintptr_t length);
#endif

int wasmer_last_error_length(void);

int wasmer_last_error_message(char *buffer, int length);
Expand Down

0 comments on commit 0861b73

Please sign in to comment.