!172 quickjs engine support stopPropagation

Merge pull request !172 from laoyitong/OpenHarmony-3.0-LTS
This commit is contained in:
openharmony_ci
2021-09-28 09:57:37 +00:00
committed by Gitee
3 changed files with 15 additions and 3 deletions
@@ -30,7 +30,11 @@ void JsStopPropagation(const v8::FunctionCallbackInfo<v8::Value>& info)
#elif USE_QUICKJS_ENGINE
JSValue JsStopPropagation(JSContext* ctx, JSValueConst new_target, int argc, JSValueConst* arg)
{
LOGD("JsStopPropagation trigger");
auto eventInfo = static_cast<BaseEventInfo*>(JS_GetOpaque3(new_target));
if (eventInfo) {
LOGD("JsStopPropagation is trigger");
eventInfo->SetStopPropagation(true);
}
return JS_UNDEFINED;
}
@@ -38,6 +42,11 @@ JSValue JsStopPropagation(JSContext* ctx, JSValueConst new_target, int argc, JSV
Local<JSValueRef> JsStopPropagation(
EcmaVM* vm, Local<JSValueRef> thisObj, const Local<JSValueRef> argv[], int32_t argc, void* data)
{
auto eventInfo = static_cast<BaseEventInfo*>(panda::Local<panda::ObjectRef>(thisObj)->GetNativePointerField(0));
if (eventInfo) {
LOGD("JsStopPropagation is trigger");
eventInfo->SetStopPropagation(true);
}
return JSValueRef::Undefined(vm);
}
#endif
@@ -222,7 +222,7 @@ QJSRef<QJSValue> QJSFunction::Call(QJSRef<QJSValue> thisVal, int argc, QJSRef<QJ
JSValue QJSFunction::New(FunctionCallback func)
{
return JS_UNDEFINED;
return JS_NewCFunction(QJSContext::Current(), func, "", 1);
}
QJSArray::QJSArray() {}
@@ -34,7 +34,10 @@ U* QJSObject::Unwrap() const
}
template<typename U>
void QJSObject::Wrap(U* data) const {}
void QJSObject::Wrap(U* data) const
{
JS_SetOpaque(GetHandle(), data);
}
template<typename T>
T QJSValue::ToNumber() const