@@ -234,30 +234,30 @@ static const int kAccessorFieldCount = 3;
234234// info.
235235class CallbackWrapper {
236236 public:
237- CallbackWrapper (napi_value thisArg, int argsLength, void * data)
237+ CallbackWrapper (napi_value thisArg, size_t argsLength, void * data)
238238 : _this(thisArg), _argsLength(argsLength), _data(data) {}
239239
240240 virtual napi_value Holder () = 0;
241241 virtual bool IsConstructCall () = 0;
242- virtual void Args (napi_value* buffer, int bufferlength) = 0;
242+ virtual void Args (napi_value* buffer, size_t bufferlength) = 0;
243243 virtual void SetReturnValue (napi_value v) = 0;
244244
245245 napi_value This () { return _this; }
246246
247- int ArgsLength () { return _argsLength; }
247+ size_t ArgsLength () { return _argsLength; }
248248
249249 void * Data () { return _data; }
250250
251251 protected:
252252 const napi_value _this;
253- const int _argsLength;
253+ const size_t _argsLength;
254254 void * _data;
255255};
256256
257257template <typename T, int I>
258258class CallbackWrapperBase : public CallbackWrapper {
259259 public:
260- CallbackWrapperBase (const T& cbinfo, const int argsLength)
260+ CallbackWrapperBase (const T& cbinfo, const size_t argsLength)
261261 : CallbackWrapper(JsValueFromV8LocalValue(cbinfo.This()),
262262 argsLength,
263263 nullptr ),
@@ -312,9 +312,9 @@ class FunctionCallbackWrapper
312312 bool IsConstructCall () override { return _cbinfo.IsConstructCall (); }
313313
314314 /* virtual*/
315- void Args (napi_value* buffer, int bufferlength) override {
316- int i = 0 ;
317- int min = std::min (bufferlength, _argsLength);
315+ void Args (napi_value* buffer, size_t bufferlength) override {
316+ size_t i = 0 ;
317+ size_t min = std::min (bufferlength, _argsLength);
318318
319319 for (; i < min; i += 1 ) {
320320 buffer[i] = v8impl::JsValueFromV8LocalValue (_cbinfo[i]);
@@ -351,11 +351,11 @@ class GetterCallbackWrapper
351351 : CallbackWrapperBase(cbinfo, 0 ) {}
352352
353353 /* virtual*/
354- void Args (napi_value* buffer, int bufferlength) override {
354+ void Args (napi_value* buffer, size_t bufferlength) override {
355355 if (bufferlength > 0 ) {
356356 napi_value undefined =
357357 v8impl::JsValueFromV8LocalValue (v8::Undefined (_cbinfo.GetIsolate ()));
358- for (int i = 0 ; i < bufferlength; i += 1 ) {
358+ for (size_t i = 0 ; i < bufferlength; i += 1 ) {
359359 buffer[i] = undefined;
360360 }
361361 }
@@ -383,14 +383,14 @@ class SetterCallbackWrapper
383383 : CallbackWrapperBase(cbinfo, 1 ), _value(value) {}
384384
385385 /* virtual*/
386- void Args (napi_value* buffer, int bufferlength) override {
386+ void Args (napi_value* buffer, size_t bufferlength) override {
387387 if (bufferlength > 0 ) {
388388 buffer[0 ] = v8impl::JsValueFromV8LocalValue (_value);
389389
390390 if (bufferlength > 1 ) {
391391 napi_value undefined = v8impl::JsValueFromV8LocalValue (
392392 v8::Undefined (_cbinfo.GetIsolate ()));
393- for (int i = 1 ; i < bufferlength; i += 1 ) {
393+ for (size_t i = 1 ; i < bufferlength; i += 1 ) {
394394 buffer[i] = undefined;
395395 }
396396 }
@@ -659,7 +659,7 @@ napi_status napi_define_class(napi_env e,
659659 const char * utf8name,
660660 napi_callback constructor,
661661 void * data,
662- int property_count,
662+ size_t property_count,
663663 const napi_property_descriptor* properties,
664664 napi_value* result) {
665665 NAPI_PREAMBLE (e);
@@ -683,8 +683,8 @@ napi_status napi_define_class(napi_env e,
683683 CHECK_NEW_FROM_UTF8 (isolate, namestring, utf8name);
684684 tpl->SetClassName (namestring);
685685
686- int staticPropertyCount = 0 ;
687- for (int i = 0 ; i < property_count; i++) {
686+ size_t staticPropertyCount = 0 ;
687+ for (size_t i = 0 ; i < property_count; i++) {
688688 const napi_property_descriptor* p = properties + i;
689689
690690 if ((p->attributes & napi_static_property) != 0 ) {
@@ -738,7 +738,7 @@ napi_status napi_define_class(napi_env e,
738738 std::vector<napi_property_descriptor> staticDescriptors;
739739 staticDescriptors.reserve (staticPropertyCount);
740740
741- for (int i = 0 ; i < property_count; i++) {
741+ for (size_t i = 0 ; i < property_count; i++) {
742742 const napi_property_descriptor* p = properties + i;
743743 if ((p->attributes & napi_static_property) != 0 ) {
744744 staticDescriptors.push_back (*p);
@@ -991,7 +991,7 @@ napi_status napi_get_element(napi_env e,
991991
992992napi_status napi_define_properties (napi_env e,
993993 napi_value object,
994- int property_count,
994+ size_t property_count,
995995 const napi_property_descriptor* properties) {
996996 NAPI_PREAMBLE (e);
997997
@@ -1000,7 +1000,7 @@ napi_status napi_define_properties(napi_env e,
10001000 v8::Local<v8::Object> obj =
10011001 v8impl::V8LocalValueFromJsValue (object).As <v8::Object>();
10021002
1003- for (int i = 0 ; i < property_count; i++) {
1003+ for (size_t i = 0 ; i < property_count; i++) {
10041004 const napi_property_descriptor* p = &properties[i];
10051005
10061006 v8::Local<v8::Name> name;
@@ -1138,7 +1138,7 @@ napi_status napi_create_array(napi_env e, napi_value* result) {
11381138}
11391139
11401140napi_status napi_create_array_with_length (napi_env e,
1141- int length,
1141+ size_t length,
11421142 napi_value* result) {
11431143 NAPI_PREAMBLE (e);
11441144 CHECK_ARG (result);
@@ -1151,7 +1151,7 @@ napi_status napi_create_array_with_length(napi_env e,
11511151
11521152napi_status napi_create_string_utf8 (napi_env e,
11531153 const char * s,
1154- int length,
1154+ size_t length,
11551155 napi_value* result) {
11561156 NAPI_PREAMBLE (e);
11571157 CHECK_ARG (result);
@@ -1166,7 +1166,7 @@ napi_status napi_create_string_utf8(napi_env e,
11661166
11671167napi_status napi_create_string_utf16 (napi_env e,
11681168 const char16_t * s,
1169- int length,
1169+ size_t length,
11701170 napi_value* result) {
11711171 NAPI_PREAMBLE (e);
11721172 CHECK_ARG (result);
@@ -1335,7 +1335,7 @@ napi_status napi_get_true(napi_env e, napi_value* result) {
13351335napi_status napi_get_cb_info (
13361336 napi_env e, // [in] NAPI environment handle
13371337 napi_callback_info cbinfo, // [in] Opaque callback-info handle
1338- int * argc, // [in-out] Specifies the size of the provided argv array
1338+ size_t * argc, // [in-out] Specifies the size of the provided argv array
13391339 // and receives the actual count of args.
13401340 napi_value* argv, // [out] Array of values
13411341 napi_value* thisArg, // [out] Receives the JS 'this' arg for the call
@@ -1358,7 +1358,7 @@ napi_status napi_get_cb_info(
13581358
13591359napi_status napi_get_cb_args_length (napi_env e,
13601360 napi_callback_info cbinfo,
1361- int * result) {
1361+ size_t * result) {
13621362 // Omit NAPI_PREAMBLE and GET_RETURN_STATUS because no V8 APIs are called.
13631363 CHECK_ARG (result);
13641364
@@ -1387,7 +1387,7 @@ napi_status napi_is_construct_call(napi_env e,
13871387napi_status napi_get_cb_args (napi_env e,
13881388 napi_callback_info cbinfo,
13891389 napi_value* buffer,
1390- int bufferlength) {
1390+ size_t bufferlength) {
13911391 // Omit NAPI_PREAMBLE and GET_RETURN_STATUS because no V8 APIs are called.
13921392 CHECK_ARG (buffer);
13931393
@@ -1427,7 +1427,7 @@ napi_status napi_get_cb_data(napi_env e,
14271427napi_status napi_call_function (napi_env e,
14281428 napi_value recv,
14291429 napi_value func,
1430- int argc,
1430+ size_t argc,
14311431 const napi_value* argv,
14321432 napi_value* result) {
14331433 NAPI_PREAMBLE (e);
@@ -1439,7 +1439,7 @@ napi_status napi_call_function(napi_env e,
14391439
14401440 v8::Handle<v8::Value> v8recv = v8impl::V8LocalValueFromJsValue (recv);
14411441
1442- for (int i = 0 ; i < argc; i++) {
1442+ for (size_t i = 0 ; i < argc; i++) {
14431443 args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
14441444 }
14451445
@@ -1606,7 +1606,7 @@ napi_status napi_get_value_bool(napi_env e, napi_value value, bool* result) {
16061606// Gets the number of CHARACTERS in the string.
16071607napi_status napi_get_value_string_length (napi_env e,
16081608 napi_value value,
1609- int * result) {
1609+ size_t * result) {
16101610 NAPI_PREAMBLE (e);
16111611 CHECK_ARG (result);
16121612
@@ -1621,7 +1621,7 @@ napi_status napi_get_value_string_length(napi_env e,
16211621// Gets the number of BYTES in the UTF-8 encoded representation of the string.
16221622napi_status napi_get_value_string_utf8_length (napi_env e,
16231623 napi_value value,
1624- int * result) {
1624+ size_t * result) {
16251625 NAPI_PREAMBLE (e);
16261626 CHECK_ARG (result);
16271627
@@ -1640,8 +1640,8 @@ napi_status napi_get_value_string_utf8_length(napi_env e,
16401640napi_status napi_get_value_string_utf8 (napi_env e,
16411641 napi_value value,
16421642 char * buf,
1643- int bufsize,
1644- int * result) {
1643+ size_t bufsize,
1644+ size_t * result) {
16451645 NAPI_PREAMBLE (e);
16461646
16471647 v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue (value);
@@ -1661,7 +1661,7 @@ napi_status napi_get_value_string_utf8(napi_env e,
16611661// the string.
16621662napi_status napi_get_value_string_utf16_length (napi_env e,
16631663 napi_value value,
1664- int * result) {
1664+ size_t * result) {
16651665 NAPI_PREAMBLE (e);
16661666 CHECK_ARG (result);
16671667
@@ -1683,8 +1683,8 @@ napi_status napi_get_value_string_utf16_length(napi_env e,
16831683napi_status napi_get_value_string_utf16 (napi_env e,
16841684 napi_value value,
16851685 char16_t * buf,
1686- int bufsize,
1687- int * result) {
1686+ size_t bufsize,
1687+ size_t * result) {
16881688 NAPI_PREAMBLE (e);
16891689 CHECK_ARG (result);
16901690
@@ -2008,7 +2008,7 @@ napi_status napi_escape_handle(napi_env e,
20082008
20092009napi_status napi_new_instance (napi_env e,
20102010 napi_value constructor,
2011- int argc,
2011+ size_t argc,
20122012 const napi_value* argv,
20132013 napi_value* result) {
20142014 NAPI_PREAMBLE (e);
@@ -2018,7 +2018,7 @@ napi_status napi_new_instance(napi_env e,
20182018 v8::Local<v8::Context> context = isolate->GetCurrentContext ();
20192019
20202020 std::vector<v8::Handle<v8::Value>> args (argc);
2021- for (int i = 0 ; i < argc; i++) {
2021+ for (size_t i = 0 ; i < argc; i++) {
20222022 args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
20232023 }
20242024
@@ -2091,7 +2091,7 @@ napi_status napi_instanceof(napi_env e,
20912091napi_status napi_make_callback (napi_env e,
20922092 napi_value recv,
20932093 napi_value func,
2094- int argc,
2094+ size_t argc,
20952095 const napi_value* argv,
20962096 napi_value* result) {
20972097 NAPI_PREAMBLE (e);
@@ -2103,7 +2103,7 @@ napi_status napi_make_callback(napi_env e,
21032103 v8::Local<v8::Function> v8func =
21042104 v8impl::V8LocalValueFromJsValue (func).As <v8::Function>();
21052105 std::vector<v8::Handle<v8::Value>> args (argc);
2106- for (int i = 0 ; i < argc; i++) {
2106+ for (size_t i = 0 ; i < argc; i++) {
21072107 args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
21082108 }
21092109
0 commit comments