66#include " js_native_api_types.h"
77#include " node_api_util.h"
88#import < Foundation/Foundation.h>
9+ #include < cstring>
910#include < objc/objc.h>
1011#include < objc/runtime.h>
1112
2526 size_t argc = cif->argc ;
2627 napi_get_cb_info (env, cbinfo, &argc, cif->argv , nullptr , nullptr );
2728
28- void ** avalues = cif->avalues ;
29+ void *avalues[ cif->argc] ;
2930 void *rvalue = cif->rvalue ;
3031
3132 bool shouldFreeAny = false ;
3435 if (cif->argc > 0 ) {
3536 for (unsigned int i = 0 ; i < cif->argc ; i++) {
3637 shouldFree[i] = false ;
38+ avalues[i] = cif->avalues [i];
3739 cif->argTypes [i]->toNative (env, cif->argv [i], avalues[i], &shouldFree[i],
3840 &shouldFreeAny);
3941 }
@@ -109,7 +111,7 @@ inline void objcNativeCall(napi_env env, napi_value jsThis, MethodCif *cif,
109111 size_t argc = cif->argc ;
110112 napi_get_cb_info (env, cbinfo, &argc, cif->argv , &jsThis, nullptr );
111113
112- void ** avalues = cif->avalues ;
114+ void *avalues[ cif->cif.nargs] ;
113115 void *rvalue = cif->rvalue ;
114116
115117 avalues[0 ] = (void *)&self;
@@ -121,10 +123,7 @@ inline void objcNativeCall(napi_env env, napi_value jsThis, MethodCif *cif,
121123 if (cif->argc > 0 ) {
122124 for (unsigned int i = 0 ; i < cif->argc ; i++) {
123125 shouldFree[i] = false ;
124- napi_valuetype type;
125- napi_typeof (env, cif->argv [i], &type);
126- std::string encoding;
127- cif->argTypes [i]->encode (&encoding);
126+ avalues[i] = cif->avalues [i + 2 ];
128127 cif->argTypes [i]->toNative (env, cif->argv [i], avalues[i + 2 ],
129128 &shouldFree[i], &shouldFreeAny);
130129 }
@@ -167,12 +166,9 @@ inline void objcNativeCall(napi_env env, napi_value jsThis, MethodCif *cif,
167166 method->bridgeData ->getMethodCif (env, method->signature );
168167 }
169168
170- void *avalues[2 ];
169+ void *avalues[2 ] = {&self, &method-> selector } ;
171170 void *rvalue = cif->rvalue ;
172171
173- avalues[0 ] = (void *)&self;
174- avalues[1 ] = (void *)&method->selector ;
175-
176172 objcNativeCall (env, jsThis, cif, self, avalues, rvalue);
177173
178174 if (cif->returnType ->kind == mdTypeInstanceObject) {
@@ -205,11 +201,9 @@ inline void objcNativeCall(napi_env env, napi_value jsThis, MethodCif *cif,
205201 method->bridgeData ->getMethodCif (env, method->setterSignature );
206202 }
207203
208- void ** avalues = cif->avalues ;
204+ void *avalues[ 3 ] = {&self, &method-> setterSelector , cif->avalues [ 2 ]} ;
209205 void *rvalue = nullptr ;
210206
211- avalues[0 ] = (void *)&self;
212- avalues[1 ] = (void *)&method->setterSelector ;
213207 bool shouldFree = false ;
214208 cif->argTypes [0 ]->toNative (env, argv, avalues[2 ], &shouldFree, &shouldFree);
215209
0 commit comments