From ba4ad76d11c7ceb7afffa40855ec3865f115c055 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Wed, 12 Sep 2018 14:10:53 -0400 Subject: [PATCH] Leave platform-specific type in operator def.n The property get/set sugar for numerical indices has to stay platform- agnostic. That is, we cannot use `uint32_t`, but must instead use `int` in the operator definition, because `int` resolves exactly on both 32-bit and 64-bit platforms. Fixes: https://github.com/nodejs/node-addon-api/issues/337 --- napi-inl.h | 6 +++--- napi.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index 59362e704..85c380d6a 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -783,8 +783,8 @@ inline Object::PropertyLValue Object::operator [](const std::string return PropertyLValue(*this, utf8name); } -inline Object::PropertyLValue Object::operator [](uint32_t index) { - return PropertyLValue(*this, index); +inline Object::PropertyLValue Object::operator [](int index) { + return PropertyLValue(*this, index); } inline Value Object::operator [](const char* utf8name) const { @@ -795,7 +795,7 @@ inline Value Object::operator [](const std::string& utf8name) const { return Get(utf8name); } -inline Value Object::operator [](uint32_t index) const { +inline Value Object::operator [](int index) const { return Get(index); } diff --git a/napi.h b/napi.h index 531d1c358..bb7142546 100644 --- a/napi.h +++ b/napi.h @@ -395,8 +395,8 @@ namespace Napi { ); /// Gets or sets an indexed property or array element. - PropertyLValue operator []( - uint32_t index /// Property / element index + PropertyLValue operator []( + int index /// Property / element index ); /// Gets a named property. @@ -411,7 +411,7 @@ namespace Napi { /// Gets an indexed property or array element. Value operator []( - uint32_t index ///< Property / element index + int index ///< Property / element index ) const; /// Checks whether a property is present.