Skip to content

Commit 81efc84

Browse files
authored
Merge pull request #784 from wasmx/error-code-note
capi: Add a note about error code and returned value relation
2 parents 5027151 + 1211ae6 commit 81efc84

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

include/fizzy/fizzy.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ extern "C" {
2424
/// Error codes.
2525
typedef enum FizzyErrorCode
2626
{
27+
/// Success.
2728
FizzySuccess = 0,
29+
/// Malformed module.
2830
FizzyErrorMalformedModule,
31+
/// Invalid module.
2932
FizzyErrorInvalidModule,
33+
/// Instantiation failed.
3034
FizzyErrorInstantiationFailed,
35+
/// Other error.
3136
FizzyErrorOther
3237
} FizzyErrorCode;
3338

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

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

@@ -434,6 +445,10 @@ bool fizzy_module_has_start_function(const FizzyModule* module) FIZZY_NOEXCEPT;
434445
/// No validation is done on the number of globals passed in, nor on their order.
435446
/// When number of passed globals or their order is different from the one defined by the
436447
/// module, behaviour is undefined.
448+
///
449+
/// @note
450+
/// FizzyError::code will be ::FizzySuccess if function returns non-NULL pointer and will not be
451+
/// ::FizzySuccess otherwise.
437452
FizzyInstance* fizzy_instantiate(const FizzyModule* module,
438453
const FizzyExternalFunction* imported_functions, size_t imported_functions_size,
439454
const FizzyExternalTable* imported_table, const FizzyExternalMemory* imported_memory,
@@ -483,6 +498,10 @@ FizzyInstance* fizzy_instantiate(const FizzyModule* module,
483498
/// FizzyImportedFunction::module, FizzyImportedFunction::name, FizzyImportedGlobal::module,
484499
/// FizzyImportedGlobal::name strings need to be valid only until fizzy_resolve_instantiate()
485500
/// returns.
501+
///
502+
/// @note
503+
/// FizzyError::code will be ::FizzySuccess if function returns non-NULL pointer and will not be
504+
/// ::FizzySuccess otherwise.
486505
FizzyInstance* fizzy_resolve_instantiate(const FizzyModule* module,
487506
const FizzyImportedFunction* imported_functions, size_t imported_functions_size,
488507
const FizzyExternalTable* imported_table, const FizzyExternalMemory* imported_memory,

0 commit comments

Comments
 (0)