Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test-app/runtime/src/main/cpp/napi/common/native_api_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ namespace napi_util {
return napi_define_properties(env, object, 1, &desc);
}

inline napi_status define_property_value(napi_env env, napi_value object, const char *propertyName,
napi_value value = nullptr, napi_property_attributes attributes = napi_default_jsproperty, void *data = nullptr) {
return napi_util::define_property(env, object, propertyName, value, nullptr, nullptr, data, attributes);
}

inline napi_status define_property_get_set(napi_env env, napi_value object, const char *propertyName,
napi_callback getter, napi_callback setter, napi_property_attributes attributes = napi_default_jsproperty, void *data = nullptr) {
return napi_util::define_property(env, object, propertyName, nullptr, getter, setter, data, attributes);
}

inline void setPrototypeOf(napi_env env, napi_value object, napi_value prototype) {
napi_value global, global_object, set_proto;

Expand Down
5 changes: 4 additions & 1 deletion test-app/runtime/src/main/cpp/napi/quickjs/source/quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7217,7 +7217,10 @@ static BOOL is_backtrace_needed(JSContext *ctx, JSValueConst obj)

JSValue JS_NewError(JSContext *ctx)
{
return JS_NewObjectClass(ctx, JS_CLASS_ERROR);
JSValue error = JS_NewObjectClass(ctx, JS_CLASS_ERROR);
build_backtrace(ctx, error, NULL, 0, 0, 0);
return error;

}

static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
Expand Down
10 changes: 6 additions & 4 deletions test-app/runtime/src/main/cpp/runtime/metadata/MetadataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ std::vector<MetadataNode::MethodCallbackData *> MetadataNode::SetClassMembersFro
napi_create_function(env, methodName.c_str(), methodName.size(), MethodCallback,
callbackData, &method);

napi_set_named_property(env, prototype, methodName.c_str(), method);
napi_util::define_property_value(env, prototype, methodName.c_str(), method, napi_default_method);
lastMethodName = methodName;
collectedExtensionMethods.emplace(methodName, callbackData);

Expand All @@ -1112,7 +1112,7 @@ std::vector<MetadataNode::MethodCallbackData *> MetadataNode::SetClassMembersFro
napi_value method;
napi_create_function(env, methodName.c_str(), methodName.size(), MethodCallback,
callbackData, &method);
napi_set_named_property(env, prototype, methodName.c_str(), method);
napi_util::define_property_value(env, prototype, methodName.c_str(), method, napi_default_method);
collectedExtensionMethods.emplace(methodName, callbackData);
}

Expand Down Expand Up @@ -1199,7 +1199,8 @@ std::vector<MetadataNode::MethodCallbackData *> MetadataNode::SetClassMembersFro
napi_value method;
napi_create_function(env, methodName.c_str(), methodName.size(), MethodCallback,
callbackData, &method);
napi_set_named_property(env, constructor, methodName.c_str(), method);

napi_util::define_property_value(env, constructor, methodName.c_str(), method, napi_default_method);
lastMethodName = methodName;
}
callbackData->candidates.push_back(std::move(entry));
Expand Down Expand Up @@ -1234,6 +1235,7 @@ std::vector<MetadataNode::MethodCallbackData *> MetadataNode::SetClassMembersFro
ArgConverter::convertToJsString(env, tname));

SetClassAccessor(env, constructor);

return instanceMethodData;
}

Expand Down Expand Up @@ -1992,7 +1994,7 @@ napi_value MetadataNode::MethodCallback(napi_env env, napi_callback_info info) {


if (argc == 0 && methodName == PROP_KEY_VALUEOF) {
return jsThis;
return jsThis;
} else {
// Runtime::GetRuntime(env)->clearPendingError();
bool isFromInterface = initialCallbackData->node->IsNodeTypeInterface();
Expand Down