Skip to content

Commit

Permalink
capi: Add a note about error code and returned value correspondence
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Apr 19, 2021
1 parent 5027151 commit 1211ae6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/fizzy/fizzy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ extern "C" {
/// Error codes.
typedef enum FizzyErrorCode
{
/// Success.
FizzySuccess = 0,
/// Malformed module.
FizzyErrorMalformedModule,
/// Invalid module.
FizzyErrorInvalidModule,
/// Instantiation failed.
FizzyErrorInstantiationFailed,
/// Other error.
FizzyErrorOther
} FizzyErrorCode;

Expand Down Expand Up @@ -257,6 +262,9 @@ typedef struct FizzyImportedGlobal
/// @param error Pointer to store detailed error information at. Can be NULL if error
/// information is not required.
/// @return true if module is valid, false otherwise.
///
/// @note FizzyError::code will be ::FizzySuccess if function returns `true` and will not be
/// ::FizzySuccess otherwise.
bool fizzy_validate(
const uint8_t* wasm_binary, size_t wasm_binary_size, FizzyError* error) FIZZY_NOEXCEPT;

Expand All @@ -267,6 +275,9 @@ bool fizzy_validate(
/// @param error Pointer to store detailed error information at. Can be NULL if error
/// information is not required.
/// @return non-NULL pointer to module in case of success, NULL otherwise.
///
/// @note FizzyError::code will be ::FizzySuccess if function returns non-NULL
/// will and will not be ::FizzySuccess otherwise.
const FizzyModule* fizzy_parse(
const uint8_t* wasm_binary, size_t wasm_binary_size, FizzyError* error) FIZZY_NOEXCEPT;

Expand Down Expand Up @@ -434,6 +445,10 @@ bool fizzy_module_has_start_function(const FizzyModule* module) FIZZY_NOEXCEPT;
/// No validation is done on the number of globals passed in, nor on their order.
/// When number of passed globals or their order is different from the one defined by the
/// module, behaviour is undefined.
///
/// @note
/// FizzyError::code will be ::FizzySuccess if function returns non-NULL pointer and will not be
/// ::FizzySuccess otherwise.
FizzyInstance* fizzy_instantiate(const FizzyModule* module,
const FizzyExternalFunction* imported_functions, size_t imported_functions_size,
const FizzyExternalTable* imported_table, const FizzyExternalMemory* imported_memory,
Expand Down Expand Up @@ -483,6 +498,10 @@ FizzyInstance* fizzy_instantiate(const FizzyModule* module,
/// FizzyImportedFunction::module, FizzyImportedFunction::name, FizzyImportedGlobal::module,
/// FizzyImportedGlobal::name strings need to be valid only until fizzy_resolve_instantiate()
/// returns.
///
/// @note
/// FizzyError::code will be ::FizzySuccess if function returns non-NULL pointer and will not be
/// ::FizzySuccess otherwise.
FizzyInstance* fizzy_resolve_instantiate(const FizzyModule* module,
const FizzyImportedFunction* imported_functions, size_t imported_functions_size,
const FizzyExternalTable* imported_table, const FizzyExternalMemory* imported_memory,
Expand Down

0 comments on commit 1211ae6

Please sign in to comment.