@@ -69,6 +69,16 @@ Value CallWithVector(const CallbackInfo& info) {
69
69
return MaybeUnwrap (func.Call (args));
70
70
}
71
71
72
+ Value CallWithVectorUsingCppWrapper (const CallbackInfo& info) {
73
+ Function func = info[0 ].As <Function>();
74
+ std::vector<Value> args;
75
+ args.reserve (3 );
76
+ args.push_back (info[1 ]);
77
+ args.push_back (info[2 ]);
78
+ args.push_back (info[3 ]);
79
+ return MaybeUnwrap (func.Call (args));
80
+ }
81
+
72
82
Value CallWithCStyleArray (const CallbackInfo& info) {
73
83
Function func = info[0 ].As <Function>();
74
84
std::vector<napi_value> args;
@@ -108,6 +118,17 @@ Value CallWithReceiverAndVector(const CallbackInfo& info) {
108
118
return MaybeUnwrap (func.Call (receiver, args));
109
119
}
110
120
121
+ Value CallWithReceiverAndVectorUsingCppWrapper (const CallbackInfo& info) {
122
+ Function func = info[0 ].As <Function>();
123
+ Value receiver = info[1 ];
124
+ std::vector<Value> args;
125
+ args.reserve (3 );
126
+ args.push_back (info[2 ]);
127
+ args.push_back (info[3 ]);
128
+ args.push_back (info[4 ]);
129
+ return MaybeUnwrap (func.Call (receiver, args));
130
+ }
131
+
111
132
Value CallWithInvalidReceiver (const CallbackInfo& info) {
112
133
Function func = info[0 ].As <Function>();
113
134
return MaybeUnwrapOr (func.Call (Value (), std::initializer_list<napi_value>{}),
@@ -213,11 +234,15 @@ Object InitFunction(Env env) {
213
234
Function::New (env, ValueCallbackWithData, nullptr , &testData);
214
235
exports[" callWithArgs" ] = Function::New (env, CallWithArgs);
215
236
exports[" callWithVector" ] = Function::New (env, CallWithVector);
237
+ exports[" callWithVectorUsingCppWrapper" ] =
238
+ Function::New (env, CallWithVectorUsingCppWrapper);
216
239
exports[" callWithCStyleArray" ] = Function::New (env, CallWithCStyleArray);
217
240
exports[" callWithReceiverAndCStyleArray" ] =
218
241
Function::New (env, CallWithReceiverAndCStyleArray);
219
242
exports[" callWithReceiverAndArgs" ] = Function::New (env, CallWithReceiverAndArgs);
220
243
exports[" callWithReceiverAndVector" ] = Function::New (env, CallWithReceiverAndVector);
244
+ exports[" callWithReceiverAndVectorUsingCppWrapper" ] =
245
+ Function::New (env, CallWithReceiverAndVectorUsingCppWrapper);
221
246
exports[" callWithInvalidReceiver" ] = Function::New (env, CallWithInvalidReceiver);
222
247
exports[" callConstructorWithArgs" ] = Function::New (env, CallConstructorWithArgs);
223
248
exports[" callConstructorWithVector" ] = Function::New (env, CallConstructorWithVector);
@@ -246,13 +271,17 @@ Object InitFunction(Env env) {
246
271
Function::New<ValueCallbackWithData>(env, nullptr , &testData);
247
272
exports[" callWithArgs" ] = Function::New<CallWithArgs>(env);
248
273
exports[" callWithVector" ] = Function::New<CallWithVector>(env);
274
+ exports[" callWithVectorUsingCppWrapper" ] =
275
+ Function::New<CallWithVectorUsingCppWrapper>(env);
249
276
exports[" callWithCStyleArray" ] = Function::New<CallWithCStyleArray>(env);
250
277
exports[" callWithReceiverAndCStyleArray" ] =
251
278
Function::New<CallWithReceiverAndCStyleArray>(env);
252
279
exports[" callWithReceiverAndArgs" ] =
253
280
Function::New<CallWithReceiverAndArgs>(env);
254
281
exports[" callWithReceiverAndVector" ] =
255
282
Function::New<CallWithReceiverAndVector>(env);
283
+ exports[" callWithReceiverAndVectorUsingCppWrapper" ] =
284
+ Function::New<CallWithReceiverAndVectorUsingCppWrapper>(env);
256
285
exports[" callWithInvalidReceiver" ] =
257
286
Function::New<CallWithInvalidReceiver>(env);
258
287
exports[" callConstructorWithArgs" ] =
0 commit comments