diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/binaryen-c.cpp | 96 | ||||
-rw-r--r-- | src/binaryen-c.h | 92 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 4 | ||||
-rw-r--r-- | test/example/c-api-relooper-unreachable-if.cpp | 4 | ||||
-rw-r--r-- | test/example/c-api-unused-mem.cpp | 4 |
6 files changed, 102 insertions, 99 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b1a925f..cea49dd55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Current Trunk `BinaryenElementSegmentGetLength`. - `BinaryenGetFunctionTableSegmentData` is replaced with `BinaryenElementSegmentGetData`. +- Boolean values in the C API now should use `bool` instead of `int`. v100 ---- diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index d6701f540..1b3f11e22 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -902,7 +902,7 @@ BinaryenExpressionRef BinaryenGlobalSet(BinaryenModuleRef module, } BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module, uint32_t bytes, - int8_t signed_, + bool signed_, uint32_t offset, uint32_t align, BinaryenType type, @@ -1275,7 +1275,7 @@ BinaryenExpressionRef BinaryenI31New(BinaryenModuleRef module, BinaryenExpressionRef BinaryenI31Get(BinaryenModuleRef module, BinaryenExpressionRef i31, - int signed_) { + bool signed_) { return static_cast<Expression*>( Builder(*(Module*)module).makeI31Get((Expression*)i31, signed_ != 0)); } @@ -1613,12 +1613,12 @@ BinaryenExpressionRef BinaryenCallRemoveOperandAt(BinaryenExpressionRef expr, assert(expression->is<Call>()); return static_cast<Call*>(expression)->operands.removeAt(index); } -int BinaryenCallIsReturn(BinaryenExpressionRef expr) { +bool BinaryenCallIsReturn(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Call>()); return static_cast<Call*>(expression)->isReturn; } -void BinaryenCallSetReturn(BinaryenExpressionRef expr, int isReturn) { +void BinaryenCallSetReturn(BinaryenExpressionRef expr, bool isReturn) { auto* expression = (Expression*)expr; assert(expression->is<Call>()); static_cast<Call*>(expression)->isReturn = isReturn != 0; @@ -1700,12 +1700,12 @@ BinaryenCallIndirectRemoveOperandAt(BinaryenExpressionRef expr, assert(expression->is<CallIndirect>()); return static_cast<CallIndirect*>(expression)->operands.removeAt(index); } -int BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr) { +bool BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<CallIndirect>()); return static_cast<CallIndirect*>(expression)->isReturn; } -void BinaryenCallIndirectSetReturn(BinaryenExpressionRef expr, int isReturn) { +void BinaryenCallIndirectSetReturn(BinaryenExpressionRef expr, bool isReturn) { auto* expression = (Expression*)expr; assert(expression->is<CallIndirect>()); static_cast<CallIndirect*>(expression)->isReturn = isReturn != 0; @@ -1744,7 +1744,7 @@ void BinaryenLocalGetSetIndex(BinaryenExpressionRef expr, BinaryenIndex index) { static_cast<LocalGet*>(expression)->index = index; } // LocalSet -int BinaryenLocalSetIsTee(BinaryenExpressionRef expr) { +bool BinaryenLocalSetIsTee(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<LocalSet>()); return static_cast<LocalSet*>(expression)->isTee(); @@ -1822,22 +1822,22 @@ void BinaryenMemoryGrowSetDelta(BinaryenExpressionRef expr, static_cast<MemoryGrow*>(expression)->delta = (Expression*)deltaExpr; } // Load -int BinaryenLoadIsAtomic(BinaryenExpressionRef expr) { +bool BinaryenLoadIsAtomic(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Load>()); return static_cast<Load*>(expression)->isAtomic; } -void BinaryenLoadSetAtomic(BinaryenExpressionRef expr, int isAtomic) { +void BinaryenLoadSetAtomic(BinaryenExpressionRef expr, bool isAtomic) { auto* expression = (Expression*)expr; assert(expression->is<Load>()); static_cast<Load*>(expression)->isAtomic = isAtomic != 0; } -int BinaryenLoadIsSigned(BinaryenExpressionRef expr) { +bool BinaryenLoadIsSigned(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Load>()); return static_cast<Load*>(expression)->signed_; } -void BinaryenLoadSetSigned(BinaryenExpressionRef expr, int isSigned) { +void BinaryenLoadSetSigned(BinaryenExpressionRef expr, bool isSigned) { auto* expression = (Expression*)expr; assert(expression->is<Load>()); static_cast<Load*>(expression)->signed_ = isSigned != 0; @@ -1885,12 +1885,12 @@ void BinaryenLoadSetPtr(BinaryenExpressionRef expr, static_cast<Load*>(expression)->ptr = (Expression*)ptrExpr; } // Store -int BinaryenStoreIsAtomic(BinaryenExpressionRef expr) { +bool BinaryenStoreIsAtomic(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Store>()); return static_cast<Store*>(expression)->isAtomic; } -void BinaryenStoreSetAtomic(BinaryenExpressionRef expr, int isAtomic) { +void BinaryenStoreSetAtomic(BinaryenExpressionRef expr, bool isAtomic) { auto* expression = (Expression*)expr; assert(expression->is<Store>()); static_cast<Store*>(expression)->isAtomic = isAtomic != 0; @@ -2934,7 +2934,7 @@ BinaryenExpressionRef BinaryenTryRemoveCatchBodyAt(BinaryenExpressionRef expr, assert(expression->is<Try>()); return static_cast<Try*>(expression)->catchBodies.removeAt(index); } -int BinaryenTryHasCatchAll(BinaryenExpressionRef expr) { +bool BinaryenTryHasCatchAll(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Try>()); return static_cast<Try*>(expression)->hasCatchAll(); @@ -2950,7 +2950,7 @@ void BinaryenTrySetDelegateTarget(BinaryenExpressionRef expr, assert(expression->is<Try>()); static_cast<Try*>(expression)->delegateTarget = delegateTarget; } -int BinaryenTryIsDelegate(BinaryenExpressionRef expr) { +bool BinaryenTryIsDelegate(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<Try>()); return static_cast<Try*>(expression)->isDelegate(); @@ -3122,12 +3122,12 @@ void BinaryenI31GetSetI31(BinaryenExpressionRef expr, assert(i31Expr); static_cast<I31Get*>(expression)->i31 = (Expression*)i31Expr; } -int BinaryenI31GetIsSigned(BinaryenExpressionRef expr) { +bool BinaryenI31GetIsSigned(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; assert(expression->is<I31Get>()); return static_cast<I31Get*>(expression)->signed_; } -void BinaryenI31GetSetSigned(BinaryenExpressionRef expr, int signed_) { +void BinaryenI31GetSetSigned(BinaryenExpressionRef expr, bool signed_) { auto* expression = (Expression*)expr; assert(expression->is<I31Get>()); static_cast<I31Get*>(expression)->signed_ = signed_ != 0; @@ -3183,12 +3183,12 @@ BinaryenFunctionRef BinaryenGetFunctionByIndex(BinaryenModuleRef module, BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, - int8_t mutable_, + bool mutable_, BinaryenExpressionRef init) { auto* ret = new Global(); ret->setExplicitName(name); ret->type = Type(type); - ret->mutable_ = !!mutable_; + ret->mutable_ = mutable_; ret->init = (Expression*)init; ((Module*)module)->addGlobal(ret); return ret; @@ -3274,13 +3274,13 @@ void BinaryenAddGlobalImport(BinaryenModuleRef module, const char* externalModuleName, const char* externalBaseName, BinaryenType globalType, - int mutable_) { + bool mutable_) { auto* ret = new Global(); ret->name = internalName; ret->module = externalModuleName; ret->base = externalBaseName; ret->type = Type(globalType); - ret->mutable_ = mutable_ != 0; + ret->mutable_ = mutable_; ((Module*)module)->addGlobal(ret); } void BinaryenAddEventImport(BinaryenModuleRef module, @@ -3470,11 +3470,11 @@ void BinaryenSetMemory(BinaryenModuleRef module, BinaryenIndex maximum, const char* exportName, const char** segments, - int8_t* segmentPassive, + bool* segmentPassive, BinaryenExpressionRef* segmentOffsets, BinaryenIndex* segmentSizes, BinaryenIndex numSegments, - uint8_t shared) { + bool shared) { auto* wasm = (Module*)module; wasm->memory.initial = initial; wasm->memory.max = int32_t(maximum); // Make sure -1 extends. @@ -3541,8 +3541,8 @@ size_t BinaryenGetMemorySegmentByteLength(BinaryenModuleRef module, } return segments[id].data.size(); } -int BinaryenGetMemorySegmentPassive(BinaryenModuleRef module, - BinaryenIndex id) { +bool BinaryenGetMemorySegmentPassive(BinaryenModuleRef module, + BinaryenIndex id) { const auto& segments = ((Module*)module)->memory.segments; if (segments.size() <= id) { Fatal() << "invalid segment id."; @@ -3612,8 +3612,8 @@ void BinaryenModulePrintAsmjs(BinaryenModuleRef module) { glue.emitPost(); } -int BinaryenModuleValidate(BinaryenModuleRef module) { - return WasmValidator().validate(*(Module*)module) ? 1 : 0; +bool BinaryenModuleValidate(BinaryenModuleRef module) { + return WasmValidator().validate(*(Module*)module); } void BinaryenModuleOptimize(BinaryenModuleRef module) { @@ -3635,21 +3635,21 @@ void BinaryenSetShrinkLevel(int level) { globalPassOptions.shrinkLevel = level; } -int BinaryenGetDebugInfo(void) { return globalPassOptions.debugInfo; } +bool BinaryenGetDebugInfo(void) { return globalPassOptions.debugInfo; } -void BinaryenSetDebugInfo(int on) { globalPassOptions.debugInfo = on != 0; } +void BinaryenSetDebugInfo(bool on) { globalPassOptions.debugInfo = on != 0; } -int BinaryenGetLowMemoryUnused(void) { +bool BinaryenGetLowMemoryUnused(void) { return globalPassOptions.lowMemoryUnused; } -void BinaryenSetLowMemoryUnused(int on) { +void BinaryenSetLowMemoryUnused(bool on) { globalPassOptions.lowMemoryUnused = on != 0; } -int BinaryenGetFastMath(void) { return globalPassOptions.fastMath; } +bool BinaryenGetFastMath(void) { return globalPassOptions.fastMath; } -void BinaryenSetFastMath(int value) { globalPassOptions.fastMath = value != 0; } +void BinaryenSetFastMath(bool value) { globalPassOptions.fastMath = value; } const char* BinaryenGetPassArgument(const char* key) { assert(key); @@ -3697,11 +3697,11 @@ void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size) { globalPassOptions.inlining.oneCallerInlineMaxSize = size; } -int BinaryenGetAllowInliningFunctionsWithLoops(void) { +bool BinaryenGetAllowInliningFunctionsWithLoops(void) { return globalPassOptions.inlining.allowFunctionsWithLoops; } -void BinaryenSetAllowInliningFunctionsWithLoops(int enabled) { +void BinaryenSetAllowInliningFunctionsWithLoops(bool enabled) { globalPassOptions.inlining.allowFunctionsWithLoops = enabled; } @@ -3874,8 +3874,8 @@ BinaryenType BinaryenFunctionGetVar(BinaryenFunctionRef func, BinaryenIndex BinaryenFunctionGetNumLocals(BinaryenFunctionRef func) { return ((Function*)func)->getNumLocals(); } -int BinaryenFunctionHasLocalName(BinaryenFunctionRef func, - BinaryenIndex index) { +bool BinaryenFunctionHasLocalName(BinaryenFunctionRef func, + BinaryenIndex index) { return ((Function*)func)->hasLocalName(index); } const char* BinaryenFunctionGetLocalName(BinaryenFunctionRef func, @@ -3941,7 +3941,7 @@ BinaryenIndex BinaryenTableGetInitial(BinaryenTableRef table) { void BinaryenTableSetInitial(BinaryenTableRef table, BinaryenIndex initial) { ((Table*)table)->initial = initial; } -int BinaryenTableHasMax(BinaryenTableRef table) { +bool BinaryenTableHasMax(BinaryenTableRef table) { return ((Table*)table)->hasMax(); } BinaryenIndex BinaryenTableGetMax(BinaryenTableRef table) { @@ -3968,7 +3968,7 @@ void BinaryenElementSegmentSetTable(BinaryenElementSegmentRef elem, const char* table) { ((ElementSegment*)elem)->table = table; } -int BinayenElementSegmentIsPassive(BinaryenElementSegmentRef elem) { +bool BinayenElementSegmentIsPassive(BinaryenElementSegmentRef elem) { return ((ElementSegment*)elem)->table.isNull(); } @@ -3982,7 +3982,7 @@ const char* BinaryenGlobalGetName(BinaryenGlobalRef global) { BinaryenType BinaryenGlobalGetType(BinaryenGlobalRef global) { return ((Global*)global)->type.getID(); } -int BinaryenGlobalIsMutable(BinaryenGlobalRef global) { +bool BinaryenGlobalIsMutable(BinaryenGlobalRef global) { return ((Global*)global)->mutable_; } BinaryenExpressionRef BinaryenGlobalGetInitExpr(BinaryenGlobalRef global) { @@ -4264,9 +4264,9 @@ ExpressionRunnerRef ExpressionRunnerCreate(BinaryenModuleRef module, new CExpressionRunner((Module*)module, flags, maxDepth, maxLoopIterations)); } -int ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, - BinaryenIndex index, - BinaryenExpressionRef value) { +bool ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, + BinaryenIndex index, + BinaryenExpressionRef value) { auto* R = (CExpressionRunner*)runner; auto setFlow = R->visit(value); if (!setFlow.breaking()) { @@ -4276,9 +4276,9 @@ int ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, return 0; } -int ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner, - const char* name, - BinaryenExpressionRef value) { +bool ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner, + const char* name, + BinaryenExpressionRef value) { auto* R = (CExpressionRunner*)runner; auto setFlow = R->visit(value); if (!setFlow.breaking()) { @@ -4308,9 +4308,9 @@ ExpressionRunnerRunAndDispose(ExpressionRunnerRef runner, // ========= Utilities ========= // -void BinaryenSetColorsEnabled(int enabled) { Colors::setEnabled(enabled); } +void BinaryenSetColorsEnabled(bool enabled) { Colors::setEnabled(enabled); } -int BinaryenAreColorsEnabled() { return Colors::isEnabled(); } +bool BinaryenAreColorsEnabled() { return Colors::isEnabled(); } #ifdef __EMSCRIPTEN__ // Override atexit - we don't need any global ctors to actually run, and diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 1841c919e..0dff91f93 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -43,6 +43,7 @@ #ifndef wasm_binaryen_c_h #define wasm_binaryen_c_h +#include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -666,7 +667,7 @@ BINARYEN_API BinaryenExpressionRef BinaryenGlobalSet( // to bytes) BINARYEN_API BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module, uint32_t bytes, - int8_t signed_, + bool signed_, uint32_t offset, uint32_t align, BinaryenType type, @@ -839,7 +840,7 @@ BINARYEN_API BinaryenExpressionRef BinaryenI31New(BinaryenModuleRef module, BinaryenExpressionRef value); BINARYEN_API BinaryenExpressionRef BinaryenI31Get(BinaryenModuleRef module, BinaryenExpressionRef i31, - int signed_); + bool signed_); // TODO (gc): ref.test // TODO (gc): ref.cast // TODO (gc): br_on_cast @@ -1040,10 +1041,10 @@ BinaryenCallInsertOperandAt(BinaryenExpressionRef expr, BINARYEN_API BinaryenExpressionRef BinaryenCallRemoveOperandAt(BinaryenExpressionRef expr, BinaryenIndex index); // Gets whether the specified `call` expression is a tail call. -BINARYEN_API int BinaryenCallIsReturn(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenCallIsReturn(BinaryenExpressionRef expr); // Sets whether the specified `call` expression is a tail call. BINARYEN_API void BinaryenCallSetReturn(BinaryenExpressionRef expr, - int isReturn); + bool isReturn); // CallIndirect @@ -1090,10 +1091,10 @@ BinaryenCallIndirectInsertOperandAt(BinaryenExpressionRef expr, BINARYEN_API BinaryenExpressionRef BinaryenCallIndirectRemoveOperandAt( BinaryenExpressionRef expr, BinaryenIndex index); // Gets whether the specified `call_indirect` expression is a tail call. -BINARYEN_API int BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenCallIndirectIsReturn(BinaryenExpressionRef expr); // Sets whether the specified `call_indirect` expression is a tail call. BINARYEN_API void BinaryenCallIndirectSetReturn(BinaryenExpressionRef expr, - int isReturn); + bool isReturn); // Gets the parameter types of the specified `call_indirect` expression. BINARYEN_API BinaryenType BinaryenCallIndirectGetParams(BinaryenExpressionRef expr); @@ -1119,7 +1120,7 @@ BINARYEN_API void BinaryenLocalGetSetIndex(BinaryenExpressionRef expr, // Gets whether a `local.set` tees its value (is a `local.tee`). True if the // expression has a type other than `none`. -BINARYEN_API int BinaryenLocalSetIsTee(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenLocalSetIsTee(BinaryenExpressionRef expr); // Gets the local index of a `local.set` or `local.tee` expression. BINARYEN_API BinaryenIndex BinaryenLocalSetGetIndex(BinaryenExpressionRef expr); // Sets the local index of a `local.set` or `local.tee` expression. @@ -1166,15 +1167,15 @@ BINARYEN_API void BinaryenMemoryGrowSetDelta(BinaryenExpressionRef expr, // Load // Gets whether a `load` expression is atomic (is an `atomic.load`). -BINARYEN_API int BinaryenLoadIsAtomic(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenLoadIsAtomic(BinaryenExpressionRef expr); // Sets whether a `load` expression is atomic (is an `atomic.load`). BINARYEN_API void BinaryenLoadSetAtomic(BinaryenExpressionRef expr, - int isAtomic); + bool isAtomic); // Gets whether a `load` expression operates on a signed value (`_s`). -BINARYEN_API int BinaryenLoadIsSigned(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenLoadIsSigned(BinaryenExpressionRef expr); // Sets whether a `load` expression operates on a signed value (`_s`). BINARYEN_API void BinaryenLoadSetSigned(BinaryenExpressionRef expr, - int isSigned); + bool isSigned); // Gets the constant offset of a `load` expression. BINARYEN_API uint32_t BinaryenLoadGetOffset(BinaryenExpressionRef expr); // Sets the constant offset of a `load` expression. @@ -1200,10 +1201,10 @@ BINARYEN_API void BinaryenLoadSetPtr(BinaryenExpressionRef expr, // Store // Gets whether a `store` expression is atomic (is an `atomic.store`). -BINARYEN_API int BinaryenStoreIsAtomic(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenStoreIsAtomic(BinaryenExpressionRef expr); // Sets whether a `store` expression is atomic (is an `atomic.store`). BINARYEN_API void BinaryenStoreSetAtomic(BinaryenExpressionRef expr, - int isAtomic); + bool isAtomic); // Gets the number of bytes stored by a `store` expression. BINARYEN_API uint32_t BinaryenStoreGetBytes(BinaryenExpressionRef expr); // Sets the number of bytes stored by a `store` expression. @@ -1808,7 +1809,7 @@ BINARYEN_API void BinaryenTryInsertCatchBodyAt(BinaryenExpressionRef expr, BINARYEN_API BinaryenExpressionRef BinaryenTryRemoveCatchBodyAt(BinaryenExpressionRef expr, BinaryenIndex index); // Gets whether a `try` expression has a catch_all clause. -BINARYEN_API int BinaryenTryHasCatchAll(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenTryHasCatchAll(BinaryenExpressionRef expr); // Gets the target label of a `delegate`. BINARYEN_API const char* BinaryenTryGetDelegateTarget(BinaryenExpressionRef expr); @@ -1816,7 +1817,7 @@ BinaryenTryGetDelegateTarget(BinaryenExpressionRef expr); BINARYEN_API void BinaryenTrySetDelegateTarget(BinaryenExpressionRef expr, const char* delegateTarget); // Gets whether a `try` expression is a try-delegate. -BINARYEN_API int BinaryenTryIsDelegate(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenTryIsDelegate(BinaryenExpressionRef expr); // Throw @@ -1923,10 +1924,10 @@ BinaryenI31GetGetI31(BinaryenExpressionRef expr); BINARYEN_API void BinaryenI31GetSetI31(BinaryenExpressionRef expr, BinaryenExpressionRef i31Expr); // Gets whether an `i31.get` expression returns a signed value (`_s`). -BINARYEN_API int BinaryenI31GetIsSigned(BinaryenExpressionRef expr); +BINARYEN_API bool BinaryenI31GetIsSigned(BinaryenExpressionRef expr); // Sets whether an `i31.get` expression returns a signed value (`_s`). BINARYEN_API void BinaryenI31GetSetSigned(BinaryenExpressionRef expr, - int signed_); + bool signed_); // Functions @@ -1984,7 +1985,7 @@ BINARYEN_API void BinaryenAddGlobalImport(BinaryenModuleRef module, const char* externalModuleName, const char* externalBaseName, BinaryenType globalType, - int mutable_); + bool mutable_); BINARYEN_API void BinaryenAddEventImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, @@ -2038,7 +2039,7 @@ BINARYEN_REF(Global); BINARYEN_API BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, - int8_t mutable_, + bool mutable_, BinaryenExpressionRef init); // Gets a global reference by name. Returns NULL if the global does not exist. BINARYEN_API BinaryenGlobalRef BinaryenGetGlobal(BinaryenModuleRef module, @@ -2119,11 +2120,11 @@ BINARYEN_API void BinaryenSetMemory(BinaryenModuleRef module, BinaryenIndex maximum, const char* exportName, const char** segments, - int8_t* segmentPassive, + bool* segmentPassive, BinaryenExpressionRef* segmentOffsets, BinaryenIndex* segmentSizes, BinaryenIndex numSegments, - uint8_t shared); + bool shared); // Memory segments. Query utilities. @@ -2132,8 +2133,8 @@ BINARYEN_API uint32_t BinaryenGetMemorySegmentByteOffset(BinaryenModuleRef module, BinaryenIndex id); BINARYEN_API size_t BinaryenGetMemorySegmentByteLength(BinaryenModuleRef module, BinaryenIndex id); -BINARYEN_API int BinaryenGetMemorySegmentPassive(BinaryenModuleRef module, - BinaryenIndex id); +BINARYEN_API bool BinaryenGetMemorySegmentPassive(BinaryenModuleRef module, + BinaryenIndex id); BINARYEN_API void BinaryenCopyMemorySegmentData(BinaryenModuleRef module, BinaryenIndex id, char* buffer); @@ -2166,7 +2167,7 @@ BINARYEN_API void BinaryenModulePrintAsmjs(BinaryenModuleRef module); // Validate a module, showing errors on problems. // @return 0 if an error occurred, 1 if validated succesfully -BINARYEN_API int BinaryenModuleValidate(BinaryenModuleRef module); +BINARYEN_API bool BinaryenModuleValidate(BinaryenModuleRef module); // Runs the standard optimization passes on the module. Uses the currently set // global optimize and shrink level. @@ -2190,29 +2191,29 @@ BINARYEN_API void BinaryenSetShrinkLevel(int level); // Gets whether generating debug information is currently enabled or not. // Applies to all modules, globally. -BINARYEN_API int BinaryenGetDebugInfo(void); +BINARYEN_API bool BinaryenGetDebugInfo(void); // Enables or disables debug information in emitted binaries. // Applies to all modules, globally. -BINARYEN_API void BinaryenSetDebugInfo(int on); +BINARYEN_API void BinaryenSetDebugInfo(bool on); // Gets whether the low 1K of memory can be considered unused when optimizing. // Applies to all modules, globally. -BINARYEN_API int BinaryenGetLowMemoryUnused(void); +BINARYEN_API bool BinaryenGetLowMemoryUnused(void); // Enables or disables whether the low 1K of memory can be considered unused // when optimizing. Applies to all modules, globally. -BINARYEN_API void BinaryenSetLowMemoryUnused(int on); +BINARYEN_API void BinaryenSetLowMemoryUnused(bool on); // Gets whether fast math optimizations are enabled, ignoring for example // corner cases of floating-point math like NaN changes. // Applies to all modules, globally. -BINARYEN_API int BinaryenGetFastMath(void); +BINARYEN_API bool BinaryenGetFastMath(void); // Enables or disables fast math optimizations, ignoring for example // corner cases of floating-point math like NaN changes. // Applies to all modules, globally. -BINARYEN_API void BinaryenSetFastMath(int value); +BINARYEN_API void BinaryenSetFastMath(bool value); // Gets the value of the specified arbitrary pass argument. // Applies to all modules, globally. @@ -2252,11 +2253,11 @@ BINARYEN_API void BinaryenSetOneCallerInlineMaxSize(BinaryenIndex size); // Gets whether functions with loops are allowed to be inlined. // Applies to all modules, globally. -BINARYEN_API int BinaryenGetAllowInliningFunctionsWithLoops(void); +BINARYEN_API bool BinaryenGetAllowInliningFunctionsWithLoops(void); // Sets whether functions with loops are allowed to be inlined. // Applies to all modules, globally. -BINARYEN_API void BinaryenSetAllowInliningFunctionsWithLoops(int enabled); +BINARYEN_API void BinaryenSetAllowInliningFunctionsWithLoops(bool enabled); // Runs the specified passes on the module. Uses the currently set global // optimize and shrink level. @@ -2364,8 +2365,8 @@ BINARYEN_API BinaryenType BinaryenFunctionGetVar(BinaryenFunctionRef func, BINARYEN_API BinaryenIndex BinaryenFunctionGetNumLocals(BinaryenFunctionRef func); // Tests if the local at the specified index has a name. -BINARYEN_API int BinaryenFunctionHasLocalName(BinaryenFunctionRef func, - BinaryenIndex index); +BINARYEN_API bool BinaryenFunctionHasLocalName(BinaryenFunctionRef func, + BinaryenIndex index); // Gets the name of the local at the specified index. BINARYEN_API const char* BinaryenFunctionGetLocalName(BinaryenFunctionRef func, BinaryenIndex index); @@ -2415,7 +2416,7 @@ BINARYEN_API BinaryenIndex BinaryenTableGetInitial(BinaryenTableRef table); BINARYEN_API void BinaryenTableSetInitial(BinaryenTableRef table, BinaryenIndex initial); // Tests whether the specified `Table` has a maximum number of pages. -BINARYEN_API int BinaryenTableHasMax(BinaryenTableRef table); +BINARYEN_API bool BinaryenTableHasMax(BinaryenTableRef table); // Gets the maximum number of pages of the specified `Table`. BINARYEN_API BinaryenIndex BinaryenTableGetMax(BinaryenTableRef table); // Sets the maximum number of pages of the specified `Table`. @@ -2449,7 +2450,8 @@ BINARYEN_API const char* BinaryenElementSegmentGetData(BinaryenElementSegmentRef elem, BinaryenIndex dataId); // Returns true if the specified elem segment is passive -BINARYEN_API int BinayenElementSegmentIsPassive(BinaryenElementSegmentRef elem); +BINARYEN_API bool +BinayenElementSegmentIsPassive(BinaryenElementSegmentRef elem); // // ========== Global Operations ========== @@ -2461,7 +2463,7 @@ BINARYEN_API const char* BinaryenGlobalGetName(BinaryenGlobalRef global); // be `NULL` if the signature is implicit. BINARYEN_API BinaryenType BinaryenGlobalGetType(BinaryenGlobalRef global); // Returns true if the specified `Global` is mutable. -BINARYEN_API int BinaryenGlobalIsMutable(BinaryenGlobalRef global); +BINARYEN_API bool BinaryenGlobalIsMutable(BinaryenGlobalRef global); // Gets the initialization expression of the specified `Global`. BINARYEN_API BinaryenExpressionRef BinaryenGlobalGetInitExpr(BinaryenGlobalRef global); @@ -2646,17 +2648,17 @@ ExpressionRunnerCreate(BinaryenModuleRef module, // effects. For example, if the expression also sets a local, this side effect // will also happen (not affected by any flags). Returns `true` if the // expression actually evaluates to a constant. -BINARYEN_API int ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, - BinaryenIndex index, - BinaryenExpressionRef value); +BINARYEN_API bool ExpressionRunnerSetLocalValue(ExpressionRunnerRef runner, + BinaryenIndex index, + BinaryenExpressionRef value); // Sets a known global value to use. Order matters if expressions have side // effects. For example, if the expression also sets a local, this side effect // will also happen (not affected by any flags). Returns `true` if the // expression actually evaluates to a constant. -BINARYEN_API int ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner, - const char* name, - BinaryenExpressionRef value); +BINARYEN_API bool ExpressionRunnerSetGlobalValue(ExpressionRunnerRef runner, + const char* name, + BinaryenExpressionRef value); // Runs the expression and returns the constant value expression it evaluates // to, if any. Otherwise returns `NULL`. Also disposes the runner. @@ -2668,10 +2670,10 @@ BINARYEN_API BinaryenExpressionRef ExpressionRunnerRunAndDispose( // // Enable or disable coloring for the Wasm printer -BINARYEN_API void BinaryenSetColorsEnabled(int enabled); +BINARYEN_API void BinaryenSetColorsEnabled(bool enabled); // Query whether color is enable for the Wasm printer -BINARYEN_API int BinaryenAreColorsEnabled(); +BINARYEN_API bool BinaryenAreColorsEnabled(); #ifdef __cplusplus } // extern "C" #endif diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index fa23a47ce..32b6fe6d9 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -870,7 +870,7 @@ void test_core() { // Memory. One per module const char* segments[] = { "hello, world", "I am passive" }; - int8_t segmentPassive[] = { 0, 1 }; + bool segmentPassive[] = { false, true }; BinaryenExpressionRef segmentOffsets[] = { BinaryenConst(module, BinaryenLiteralInt32(10)), NULL }; BinaryenIndex segmentSizes[] = { 12, 12 }; BinaryenSetMemory(module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 1); @@ -1367,7 +1367,7 @@ void test_for_each() { const char* segments[] = { "hello, world", "segment data 2" }; const uint32_t expected_offsets[] = { 10, 125 }; - int8_t segmentPassive[] = { 0, 0 }; + bool segmentPassive[] = { false, false }; BinaryenIndex segmentSizes[] = { 12, 14 }; BinaryenExpressionRef segmentOffsets[] = { diff --git a/test/example/c-api-relooper-unreachable-if.cpp b/test/example/c-api-relooper-unreachable-if.cpp index 329b0e3b7..5e93d9d16 100644 --- a/test/example/c-api-relooper-unreachable-if.cpp +++ b/test/example/c-api-relooper-unreachable-if.cpp @@ -16,7 +16,7 @@ int main() { BinaryenModuleAutoDrop(the_module); { const char* segments[] = { 0 }; - int8_t segmentPassive[] = { 0 }; + bool segmentPassive[] = { false }; BinaryenExpressionRef segmentOffsets[] = { 0 }; BinaryenIndex segmentSizes[] = { 0 }; BinaryenSetMemory(the_module, 256, 256, "memory", segments, segmentPassive, segmentOffsets, segmentSizes, 0, 0); @@ -437,7 +437,7 @@ int main() { { const char* segments[] = { 0 }; BinaryenExpressionRef segmentOffsets[] = { 0 }; - int8_t segmentPassive[] = { 0 }; + bool segmentPassive[] = { false }; BinaryenIndex segmentSizes[] = { 0 }; BinaryenSetMemory(the_module, 1, 1, NULL, segments, segmentPassive, segmentOffsets, segmentSizes, 0, 0); } diff --git a/test/example/c-api-unused-mem.cpp b/test/example/c-api-unused-mem.cpp index 17e8004eb..c540d15c1 100644 --- a/test/example/c-api-unused-mem.cpp +++ b/test/example/c-api-unused-mem.cpp @@ -17,7 +17,7 @@ int main() { BinaryenModuleAutoDrop(the_module); { const char* segments[] = { 0 }; - int8_t segmentPassive[] = { 0 }; + bool segmentPassive[] = { false }; BinaryenExpressionRef segmentOffsets[] = { 0 }; BinaryenIndex segmentSizes[] = { 0 }; BinaryenSetMemory(the_module, 256, 256, "memory", segments, segmentPassive, segmentOffsets, segmentSizes, 0, 0); @@ -60,7 +60,7 @@ int main() { BinaryenAddFunctionExport(the_module, "main", "main"); { const char* segments[] = { 0 }; - int8_t segmentPassive[] = { 0 }; + bool segmentPassive[] = { false }; BinaryenExpressionRef segmentOffsets[] = { 0 }; BinaryenIndex segmentSizes[] = { 0 }; BinaryenSetMemory(the_module, 1024, 1024, NULL, segments, segmentPassive, segmentOffsets, segmentSizes, 0, 0); |