From 988e5c21e98b097f7bdc76cf7f1bed497c967d15 Mon Sep 17 00:00:00 2001 From: legendecas Date: Wed, 18 Sep 2019 20:50:55 +0800 Subject: [PATCH] src: enabling BigInt API with NAPI_EXPERIMENTAL Strictly aligning with Node.js header js_native_api.h in which napi_bigint related apis were nested in NAPI_EXPERIMENTAL. --- napi-inl.h | 8 ++++---- napi.h | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index d23fc83f7..f399733e6 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -376,9 +376,9 @@ inline bool Value::IsNumber() const { return Type() == napi_number; } -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL inline bool Value::IsBigInt() const { return Type() == napi_bigint; } @@ -613,9 +613,9 @@ inline double Number::DoubleValue() const { return result; } -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL //////////////////////////////////////////////////////////////////////////////// // BigInt Class //////////////////////////////////////////////////////////////////////////////// diff --git a/napi.h b/napi.h index d70270e54..3f2e2b03a 100644 --- a/napi.h +++ b/napi.h @@ -111,9 +111,9 @@ namespace Napi { class Value; class Boolean; class Number; -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL class BigInt; #endif // NAPI_EXPERIMENTAL #if (NAPI_VERSION > 4) @@ -139,9 +139,9 @@ namespace Napi { typedef TypedArrayOf Uint32Array; ///< Typed-array of unsigned 32-bit integers typedef TypedArrayOf Float32Array; ///< Typed-array of 32-bit floating-point values typedef TypedArrayOf Float64Array; ///< Typed-array of 64-bit floating-point values -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL typedef TypedArrayOf BigInt64Array; ///< Typed array of signed 64-bit integers typedef TypedArrayOf BigUint64Array; ///< Typed array of unsigned 64-bit integers #endif // NAPI_EXPERIMENTAL @@ -244,9 +244,9 @@ namespace Napi { bool IsNull() const; ///< Tests if a value is a null JavaScript value. bool IsBoolean() const; ///< Tests if a value is a JavaScript boolean. bool IsNumber() const; ///< Tests if a value is a JavaScript number. -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL bool IsBigInt() const; ///< Tests if a value is a JavaScript bigint. #endif // NAPI_EXPERIMENTAL #if (NAPI_VERSION > 4) @@ -321,9 +321,9 @@ namespace Napi { double DoubleValue() const; ///< Converts a Number value to a 64-bit floating-point value. }; -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL /// A JavaScript bigint value. class BigInt : public Value { public: @@ -851,9 +851,9 @@ namespace Napi { : std::is_same::value ? napi_uint32_array : std::is_same::value ? napi_float32_array : std::is_same::value ? napi_float64_array -// currently experimental guard with version of NAPI_VERSION that it is +// currently experimental guard with definition of NAPI_EXPERIMENTAL that it is // released in once it is no longer experimental -#if (NAPI_VERSION > 2147483646) +#ifdef NAPI_EXPERIMENTAL : std::is_same::value ? napi_bigint64_array : std::is_same::value ? napi_biguint64_array #endif // NAPI_EXPERIMENTAL