Skip to content

Commit 4d9ea40

Browse files
committed
quickjs: fix function names
1 parent 08cc78e commit 4d9ea40

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test-app/runtime/src/main/cpp/napi/quickjs/quickjs-api.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,15 +2895,15 @@ napi_set_property_descriptor(napi_env env, napi_value object, napi_property_desc
28952895
} else if (descriptor.method) {
28962896
flags |= JS_PROP_HAS_VALUE;
28972897
napi_value function = NULL;
2898-
napi_create_function(env, NULL, 0, descriptor.method, descriptor.data, &function);
2898+
napi_create_function(env, descriptor.utf8name, NAPI_AUTO_LENGTH, descriptor.method, descriptor.data, &function);
28992899
if (function) {
29002900
value = *((JSValue *) function);
29012901
}
29022902
} else if (descriptor.getter || descriptor.setter) {
29032903
if (descriptor.getter) {
29042904
napi_value getter = NULL;
29052905
flags |= JS_PROP_HAS_GET;
2906-
napi_create_function(env, NULL, 0, descriptor.getter, descriptor.data, &getter);
2906+
napi_create_function(env, descriptor.utf8name, NAPI_AUTO_LENGTH, descriptor.getter, descriptor.data, &getter);
29072907
if (getter) {
29082908
getterValue = *((JSValue *) getter);
29092909
}
@@ -2912,7 +2912,7 @@ napi_set_property_descriptor(napi_env env, napi_value object, napi_property_desc
29122912
if (descriptor.setter) {
29132913
napi_value setter = NULL;
29142914
flags |= JS_PROP_HAS_SET;
2915-
napi_create_function(env, NULL, 0, descriptor.setter, descriptor.data, &setter);
2915+
napi_create_function(env, descriptor.utf8name, NAPI_AUTO_LENGTH, descriptor.setter, descriptor.data, &setter);
29162916
if (setter) {
29172917
setterValue = *((JSValue *) setter);
29182918
}
@@ -3009,6 +3009,8 @@ napi_status napi_call_function(napi_env env, napi_value thisValue, napi_value fu
30093009
for (size_t i = 0; i < argc; ++i) {
30103010
args[i] = *((JSValue *) argv[i]);
30113011
}
3012+
3013+
30123014
returnValue = JS_Call(env->context, jsFunction, jsThis, (int) argc,
30133015
args);
30143016
if (argc > 8) mi_free(args);
@@ -3054,13 +3056,16 @@ CallCFunction(JSContext *context, JSValueConst thisVal, int argc, JSValueConst *
30543056
struct napi_callback_info__ callbackInfo = {JSUndefined, thisVal, argv, functionInfo->data,
30553057
argc};
30563058

3059+
30573060
napi_handle_scope__ handleScope;
30583061
handleScope.type = HANDLE_STACK_ALLOCATED;
30593062
handleScope.handleCount = 0;
30603063
handleScope.escapeCalled = false;
30613064
SLIST_INIT(&handleScope.handleList);
30623065
LIST_INSERT_HEAD(&env->handleScopeList, &handleScope, node);
30633066

3067+
3068+
30643069
napi_value result = functionInfo->callback(env, &callbackInfo);
30653070

30663071
if (useGlobalValue) {
@@ -3132,15 +3137,9 @@ napi_create_function(napi_env env, const char *utf8name, size_t length, napi_cal
31323137
RETURN_STATUS_IF_FALSE(!JS_IsException(functionValue), napi_pending_exception)
31333138

31343139
if (utf8name && strcmp(utf8name, "") != 0) {
3135-
int returnStatus = JS_DefinePropertyValue(env->context, functionValue, env->atoms.name,
3140+
JS_DefinePropertyValue(env->context, functionValue, env->atoms.name,
31363141
JS_NewString(env->context, utf8name),
31373142
JS_PROP_CONFIGURABLE);
3138-
3139-
if (TRUTHY(returnStatus == -1)) {
3140-
JS_FreeValue(env->context, functionValue);
3141-
3142-
return napi_set_last_error(env, napi_pending_exception, NULL, 0, NULL);
3143-
}
31443143
}
31453144

31463145
return CreateScopedResult(env, functionValue, result);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy