@@ -234,30 +234,30 @@ static const int kAccessorFieldCount = 3;
234
234
// info.
235
235
class CallbackWrapper {
236
236
public:
237
- CallbackWrapper (napi_value thisArg, int argsLength, void * data)
237
+ CallbackWrapper (napi_value thisArg, size_t argsLength, void * data)
238
238
: _this(thisArg), _argsLength(argsLength), _data(data) {}
239
239
240
240
virtual napi_value Holder () = 0;
241
241
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;
243
243
virtual void SetReturnValue (napi_value v) = 0;
244
244
245
245
napi_value This () { return _this; }
246
246
247
- int ArgsLength () { return _argsLength; }
247
+ size_t ArgsLength () { return _argsLength; }
248
248
249
249
void * Data () { return _data; }
250
250
251
251
protected:
252
252
const napi_value _this;
253
- const int _argsLength;
253
+ const size_t _argsLength;
254
254
void * _data;
255
255
};
256
256
257
257
template <typename T, int I>
258
258
class CallbackWrapperBase : public CallbackWrapper {
259
259
public:
260
- CallbackWrapperBase (const T& cbinfo, const int argsLength)
260
+ CallbackWrapperBase (const T& cbinfo, const size_t argsLength)
261
261
: CallbackWrapper(JsValueFromV8LocalValue(cbinfo.This()),
262
262
argsLength,
263
263
nullptr ),
@@ -312,9 +312,9 @@ class FunctionCallbackWrapper
312
312
bool IsConstructCall () override { return _cbinfo.IsConstructCall (); }
313
313
314
314
/* 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);
318
318
319
319
for (; i < min; i += 1 ) {
320
320
buffer[i] = v8impl::JsValueFromV8LocalValue (_cbinfo[i]);
@@ -351,11 +351,11 @@ class GetterCallbackWrapper
351
351
: CallbackWrapperBase(cbinfo, 0 ) {}
352
352
353
353
/* virtual*/
354
- void Args (napi_value* buffer, int bufferlength) override {
354
+ void Args (napi_value* buffer, size_t bufferlength) override {
355
355
if (bufferlength > 0 ) {
356
356
napi_value undefined =
357
357
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 ) {
359
359
buffer[i] = undefined;
360
360
}
361
361
}
@@ -383,14 +383,14 @@ class SetterCallbackWrapper
383
383
: CallbackWrapperBase(cbinfo, 1 ), _value(value) {}
384
384
385
385
/* virtual*/
386
- void Args (napi_value* buffer, int bufferlength) override {
386
+ void Args (napi_value* buffer, size_t bufferlength) override {
387
387
if (bufferlength > 0 ) {
388
388
buffer[0 ] = v8impl::JsValueFromV8LocalValue (_value);
389
389
390
390
if (bufferlength > 1 ) {
391
391
napi_value undefined = v8impl::JsValueFromV8LocalValue (
392
392
v8::Undefined (_cbinfo.GetIsolate ()));
393
- for (int i = 1 ; i < bufferlength; i += 1 ) {
393
+ for (size_t i = 1 ; i < bufferlength; i += 1 ) {
394
394
buffer[i] = undefined;
395
395
}
396
396
}
@@ -659,7 +659,7 @@ napi_status napi_define_class(napi_env e,
659
659
const char * utf8name,
660
660
napi_callback constructor,
661
661
void * data,
662
- int property_count,
662
+ size_t property_count,
663
663
const napi_property_descriptor* properties,
664
664
napi_value* result) {
665
665
NAPI_PREAMBLE (e);
@@ -683,8 +683,8 @@ napi_status napi_define_class(napi_env e,
683
683
CHECK_NEW_FROM_UTF8 (isolate, namestring, utf8name);
684
684
tpl->SetClassName (namestring);
685
685
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++) {
688
688
const napi_property_descriptor* p = properties + i;
689
689
690
690
if ((p->attributes & napi_static_property) != 0 ) {
@@ -738,7 +738,7 @@ napi_status napi_define_class(napi_env e,
738
738
std::vector<napi_property_descriptor> staticDescriptors;
739
739
staticDescriptors.reserve (staticPropertyCount);
740
740
741
- for (int i = 0 ; i < property_count; i++) {
741
+ for (size_t i = 0 ; i < property_count; i++) {
742
742
const napi_property_descriptor* p = properties + i;
743
743
if ((p->attributes & napi_static_property) != 0 ) {
744
744
staticDescriptors.push_back (*p);
@@ -991,7 +991,7 @@ napi_status napi_get_element(napi_env e,
991
991
992
992
napi_status napi_define_properties (napi_env e,
993
993
napi_value object,
994
- int property_count,
994
+ size_t property_count,
995
995
const napi_property_descriptor* properties) {
996
996
NAPI_PREAMBLE (e);
997
997
@@ -1000,7 +1000,7 @@ napi_status napi_define_properties(napi_env e,
1000
1000
v8::Local<v8::Object> obj =
1001
1001
v8impl::V8LocalValueFromJsValue (object).As <v8::Object>();
1002
1002
1003
- for (int i = 0 ; i < property_count; i++) {
1003
+ for (size_t i = 0 ; i < property_count; i++) {
1004
1004
const napi_property_descriptor* p = &properties[i];
1005
1005
1006
1006
v8::Local<v8::Name> name;
@@ -1138,7 +1138,7 @@ napi_status napi_create_array(napi_env e, napi_value* result) {
1138
1138
}
1139
1139
1140
1140
napi_status napi_create_array_with_length (napi_env e,
1141
- int length,
1141
+ size_t length,
1142
1142
napi_value* result) {
1143
1143
NAPI_PREAMBLE (e);
1144
1144
CHECK_ARG (result);
@@ -1151,7 +1151,7 @@ napi_status napi_create_array_with_length(napi_env e,
1151
1151
1152
1152
napi_status napi_create_string_utf8 (napi_env e,
1153
1153
const char * s,
1154
- int length,
1154
+ size_t length,
1155
1155
napi_value* result) {
1156
1156
NAPI_PREAMBLE (e);
1157
1157
CHECK_ARG (result);
@@ -1166,7 +1166,7 @@ napi_status napi_create_string_utf8(napi_env e,
1166
1166
1167
1167
napi_status napi_create_string_utf16 (napi_env e,
1168
1168
const char16_t * s,
1169
- int length,
1169
+ size_t length,
1170
1170
napi_value* result) {
1171
1171
NAPI_PREAMBLE (e);
1172
1172
CHECK_ARG (result);
@@ -1335,7 +1335,7 @@ napi_status napi_get_true(napi_env e, napi_value* result) {
1335
1335
napi_status napi_get_cb_info (
1336
1336
napi_env e, // [in] NAPI environment handle
1337
1337
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
1339
1339
// and receives the actual count of args.
1340
1340
napi_value* argv, // [out] Array of values
1341
1341
napi_value* thisArg, // [out] Receives the JS 'this' arg for the call
@@ -1358,7 +1358,7 @@ napi_status napi_get_cb_info(
1358
1358
1359
1359
napi_status napi_get_cb_args_length (napi_env e,
1360
1360
napi_callback_info cbinfo,
1361
- int * result) {
1361
+ size_t * result) {
1362
1362
// Omit NAPI_PREAMBLE and GET_RETURN_STATUS because no V8 APIs are called.
1363
1363
CHECK_ARG (result);
1364
1364
@@ -1387,7 +1387,7 @@ napi_status napi_is_construct_call(napi_env e,
1387
1387
napi_status napi_get_cb_args (napi_env e,
1388
1388
napi_callback_info cbinfo,
1389
1389
napi_value* buffer,
1390
- int bufferlength) {
1390
+ size_t bufferlength) {
1391
1391
// Omit NAPI_PREAMBLE and GET_RETURN_STATUS because no V8 APIs are called.
1392
1392
CHECK_ARG (buffer);
1393
1393
@@ -1427,7 +1427,7 @@ napi_status napi_get_cb_data(napi_env e,
1427
1427
napi_status napi_call_function (napi_env e,
1428
1428
napi_value recv,
1429
1429
napi_value func,
1430
- int argc,
1430
+ size_t argc,
1431
1431
const napi_value* argv,
1432
1432
napi_value* result) {
1433
1433
NAPI_PREAMBLE (e);
@@ -1439,7 +1439,7 @@ napi_status napi_call_function(napi_env e,
1439
1439
1440
1440
v8::Handle <v8::Value> v8recv = v8impl::V8LocalValueFromJsValue (recv);
1441
1441
1442
- for (int i = 0 ; i < argc; i++) {
1442
+ for (size_t i = 0 ; i < argc; i++) {
1443
1443
args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
1444
1444
}
1445
1445
@@ -1606,7 +1606,7 @@ napi_status napi_get_value_bool(napi_env e, napi_value value, bool* result) {
1606
1606
// Gets the number of CHARACTERS in the string.
1607
1607
napi_status napi_get_value_string_length (napi_env e,
1608
1608
napi_value value,
1609
- int * result) {
1609
+ size_t * result) {
1610
1610
NAPI_PREAMBLE (e);
1611
1611
CHECK_ARG (result);
1612
1612
@@ -1621,7 +1621,7 @@ napi_status napi_get_value_string_length(napi_env e,
1621
1621
// Gets the number of BYTES in the UTF-8 encoded representation of the string.
1622
1622
napi_status napi_get_value_string_utf8_length (napi_env e,
1623
1623
napi_value value,
1624
- int * result) {
1624
+ size_t * result) {
1625
1625
NAPI_PREAMBLE (e);
1626
1626
CHECK_ARG (result);
1627
1627
@@ -1640,8 +1640,8 @@ napi_status napi_get_value_string_utf8_length(napi_env e,
1640
1640
napi_status napi_get_value_string_utf8 (napi_env e,
1641
1641
napi_value value,
1642
1642
char * buf,
1643
- int bufsize,
1644
- int * result) {
1643
+ size_t bufsize,
1644
+ size_t * result) {
1645
1645
NAPI_PREAMBLE (e);
1646
1646
1647
1647
v8::Local<v8::Value> val = v8impl::V8LocalValueFromJsValue (value);
@@ -1661,7 +1661,7 @@ napi_status napi_get_value_string_utf8(napi_env e,
1661
1661
// the string.
1662
1662
napi_status napi_get_value_string_utf16_length (napi_env e,
1663
1663
napi_value value,
1664
- int * result) {
1664
+ size_t * result) {
1665
1665
NAPI_PREAMBLE (e);
1666
1666
CHECK_ARG (result);
1667
1667
@@ -1683,8 +1683,8 @@ napi_status napi_get_value_string_utf16_length(napi_env e,
1683
1683
napi_status napi_get_value_string_utf16 (napi_env e,
1684
1684
napi_value value,
1685
1685
char16_t * buf,
1686
- int bufsize,
1687
- int * result) {
1686
+ size_t bufsize,
1687
+ size_t * result) {
1688
1688
NAPI_PREAMBLE (e);
1689
1689
CHECK_ARG (result);
1690
1690
@@ -2008,7 +2008,7 @@ napi_status napi_escape_handle(napi_env e,
2008
2008
2009
2009
napi_status napi_new_instance (napi_env e,
2010
2010
napi_value constructor,
2011
- int argc,
2011
+ size_t argc,
2012
2012
const napi_value* argv,
2013
2013
napi_value* result) {
2014
2014
NAPI_PREAMBLE (e);
@@ -2018,7 +2018,7 @@ napi_status napi_new_instance(napi_env e,
2018
2018
v8::Local<v8::Context> context = isolate->GetCurrentContext ();
2019
2019
2020
2020
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++) {
2022
2022
args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
2023
2023
}
2024
2024
@@ -2091,7 +2091,7 @@ napi_status napi_instanceof(napi_env e,
2091
2091
napi_status napi_make_callback (napi_env e,
2092
2092
napi_value recv,
2093
2093
napi_value func,
2094
- int argc,
2094
+ size_t argc,
2095
2095
const napi_value* argv,
2096
2096
napi_value* result) {
2097
2097
NAPI_PREAMBLE (e);
@@ -2103,7 +2103,7 @@ napi_status napi_make_callback(napi_env e,
2103
2103
v8::Local<v8::Function> v8func =
2104
2104
v8impl::V8LocalValueFromJsValue (func).As <v8::Function>();
2105
2105
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++) {
2107
2107
args[i] = v8impl::V8LocalValueFromJsValue (argv[i]);
2108
2108
}
2109
2109
0 commit comments