diff --git a/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp b/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp index 2e7e3399e51884131eaa3c1930fb80f5b3882236..dfcfad1696334576e6c2b127a6b696ed5155d04e 100644 --- a/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/common_method_modifier.cpp @@ -47,6 +47,7 @@ #include "core/interfaces/native/utility/callback_helper.h" #include "core/interfaces/native/generated/interface/ui_node_api.h" #include "core/interfaces/native/implementation/color_metrics_peer.h" +#include "core/interfaces/native/implementation/dismiss_popup_action_peer.h" #include "core/interfaces/native/implementation/drag_event_peer.h" #include "core/interfaces/native/implementation/focus_axis_event_peer.h" #include "core/interfaces/native/implementation/gesture_group_interface_peer.h" @@ -114,32 +115,39 @@ RefPtr CreateProxyNode(const RefPtr& recognizer) { + Ark_GestureRecognizer peer = nullptr; auto tapRecognizer = AceType::DynamicCast(recognizer); if (tapRecognizer) { - return reinterpret_cast(Converter::ArkValue(tapRecognizer)); + peer = Converter::ArkValue(tapRecognizer); + return peer; } auto longPressRecognizer = AceType::DynamicCast(recognizer); if (longPressRecognizer) { - return reinterpret_cast( - Converter::ArkValue(longPressRecognizer)); + peer = Converter::ArkValue(longPressRecognizer); + return peer; } auto panRecognizer = AceType::DynamicCast(recognizer); if (panRecognizer) { - return reinterpret_cast(Converter::ArkValue(panRecognizer)); + peer = Converter::ArkValue(panRecognizer); + return peer; } auto pinchRecognizer = AceType::DynamicCast(recognizer); if (pinchRecognizer) { - return reinterpret_cast(Converter::ArkValue(pinchRecognizer)); + peer = Converter::ArkValue(pinchRecognizer); + return peer; } auto swipeRecognizer = AceType::DynamicCast(recognizer); if (swipeRecognizer) { - return reinterpret_cast(Converter::ArkValue(swipeRecognizer)); + peer = Converter::ArkValue(swipeRecognizer); + return peer; } auto rotationRecognizer = AceType::DynamicCast(recognizer); if (rotationRecognizer) { - return reinterpret_cast(Converter::ArkValue(rotationRecognizer)); + peer = Converter::ArkValue(rotationRecognizer); + return peer; } - return Converter::ArkValue(recognizer); + peer = Converter::ArkValue(recognizer); + return peer; } } struct EdgesParamOptions { @@ -472,15 +480,6 @@ Dimension ClampAngleDimension(const std::optional& angle, float minAn } namespace GeneratedModifier { -const GENERATED_ArkUIGestureRecognizerAccessor* GetGestureRecognizerAccessor(); -const GENERATED_ArkUITapRecognizerAccessor* GetTapRecognizerAccessor(); -const GENERATED_ArkUILongPressRecognizerAccessor* GetLongPressRecognizerAccessor(); -const GENERATED_ArkUIPanRecognizerAccessor* GetPanRecognizerAccessor(); -const GENERATED_ArkUIPinchRecognizerAccessor* GetPinchRecognizerAccessor(); -const GENERATED_ArkUISwipeRecognizerAccessor* GetSwipeRecognizerAccessor(); -const GENERATED_ArkUIRotationRecognizerAccessor* GetRotationRecognizerAccessor(); -const GENERATED_ArkUIDismissPopupActionAccessor* GetDismissPopupActionAccessor(); - namespace CommonMethodModifier { void BackgroundEffect1Impl( Ark_NativePointer node, const Opt_BackgroundEffectOptions* options, const Opt_SystemAdaptiveOptions* sysOptions); @@ -1698,70 +1697,63 @@ void AssignArkValue(Ark_TouchTestInfo& dst, const OHOS::Ace::NG::TouchTestInfo& // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_GestureRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetGestureRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_TapRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetTapRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_LongPressRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetLongPressRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_PanRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetPanRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_PinchRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetPinchRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_SwipeRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetSwipeRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } // this creates the peer for Materialized object. DO NOT FORGET TO RELEASE IT void AssignArkValue(Ark_RotationRecognizer &dst, const RefPtr& src) { - auto accessor = GeneratedModifier::GetRotationRecognizerAccessor(); - CHECK_NULL_VOID(accessor); - dst = accessor->ctor(); + dst = PeerUtils::CreatePeer(); if (dst) { + dst->IncRefCount(); dst->Update(src); } } @@ -1800,24 +1792,6 @@ void AssignArkValue(Ark_FingerInfo& dst, const FingerInfo& src) dst.hand.tag = InteropTag::INTEROP_TAG_OBJECT; dst.hand.value = static_cast(src.operatingHand_); } - -template<> -template<> -ArkArrayHolder::ArkArrayHolder(const std::list& data) -{ - std::transform(data.begin(), data.end(), std::back_inserter(data_), [](const FingerInfo& src) { - return OHOS::Ace::NG::Converter::ArkValue(src); - }); -} - -template<> -template<> -ArkArrayHolder::ArkArrayHolder(const std::list>& data) -{ - std::transform(data.begin(), data.end(), std::back_inserter(data_), [](const RefPtr& src) { - return OHOS::Ace::NG::CreateArkGestureRecognizer(src); - }); -} } // namespace Converter } // namespace OHOS::Ace::NG @@ -2052,10 +2026,10 @@ void OnChildTouchTestImpl(Ark_NativePointer node, item.subRect.SetHeight(PipelineBase::Px2VpWithCurrentDensity(item.subRect.Height())); } - Converter::ArkArrayHolder holder(touchInfoUpd); + auto arkTouchInfo = Converter::ArkValue(touchInfoUpd, Converter::FC); auto resultOpt = callback.InvokeWithOptConvertResult( - holder.ArkValue() + arkTouchInfo ); static const NG::TouchResult defaultRes{ NG::TouchTestStrategy::DEFAULT, "" }; return resultOpt.value_or(defaultRes); @@ -4919,8 +4893,7 @@ void OnGestureRecognizerJudgeBegin1Impl(Ark_NativePointer node, auto arkGestEvent = Converter::ArkValue(info); auto arkValCurrent = CreateArkGestureRecognizer(current); - Converter::ArkArrayHolder holderOthers(others); - auto arkValOthers = holderOthers.ArkValue(); + auto arkValOthers = Converter::ArkValue(others, Converter::FC); auto resultOpt = callback.InvokeWithOptConvertResult(arkGestEvent, arkValCurrent, arkValOthers); return resultOpt.value_or(defVal); @@ -4951,8 +4924,7 @@ void ShouldBuiltInRecognizerParallelWithImpl(Ark_NativePointer node, PipelineContext::SetCallBackNode(node); auto arkValCurrent = Converter::ArkValue(current); - Converter::ArkArrayHolder holderOthers(others); - auto arkValOthers = holderOthers.ArkValue(); + auto arkValOthers = ArkValue(others, Converter::FC); auto resultOpt = callback.InvokeWithOptConvertResult, Ark_GestureRecognizer, Callback_GestureRecognizer_Void>(arkValCurrent, arkValOthers); return resultOpt.value_or(nullptr); @@ -5503,12 +5475,9 @@ void BindPopupImpl(Ark_NativePointer node, }, [&popupParam](const Callback_DismissPopupAction_Void& value) { auto callback = [arkCallback = CallbackHelper(value)](int32_t reason) { - Ark_DismissPopupAction parameter = GetDismissPopupActionAccessor()->construct(); - auto reasonValue = Converter::ArkValue( - static_cast(reason)); - GetDismissPopupActionAccessor()->setReason(parameter, reasonValue); + auto parameter = PeerUtils::CreatePeer(); + parameter->reason = static_cast(reason); arkCallback.InvokeSync(parameter); - GetDismissPopupActionAccessor()->destroyPeer(parameter); }; popupParam->SetOnWillDismiss(std::move(callback)); popupParam->SetInteractiveDismiss(true); diff --git a/frameworks/core/interfaces/native/implementation/gesture_recognizer_peer_impl.h b/frameworks/core/interfaces/native/implementation/gesture_recognizer_peer_impl.h index 1542a904b45d0bc941260f5ff9fe33a8df00145c..1998a7b0afc72d836a3104773593df0456f2d5d9 100755 --- a/frameworks/core/interfaces/native/implementation/gesture_recognizer_peer_impl.h +++ b/frameworks/core/interfaces/native/implementation/gesture_recognizer_peer_impl.h @@ -22,7 +22,9 @@ const int32_t DEFAULT_FINGERS = 1; const bool DEFAULT_LIMIT = false; -struct GestureRecognizerPeer { +struct GestureRecognizerPeer : public OHOS::Ace::AceType { + DECLARE_ACE_TYPE(GestureRecognizerPeer, OHOS::Ace::AceType); +public: OHOS::Ace::WeakPtr GetRecognizer() { return recognizer_; @@ -53,6 +55,8 @@ private: }; struct MultiFingerRecognizerPeer : public GestureRecognizerPeer { + DECLARE_ACE_TYPE(MultiFingerRecognizerPeer, GestureRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { GestureRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/long_press_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/long_press_recognizer_peer.h index 52cd2333ca1602b6b6b144043627d49a8941270f..0b9503fc31536f9b67abf12d23ae9fe9a98ee0c2 100644 --- a/frameworks/core/interfaces/native/implementation/long_press_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/long_press_recognizer_peer.h @@ -24,6 +24,8 @@ const int32_t DEFAULT_LONG_PRESS_DURATION = 500; const bool DEFAULT_REPEAT = false; struct LongPressRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(LongPressRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/pan_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/pan_recognizer_peer.h index 6a6d4396694b7df9d52d21cc185ec70c5844df26..94fcbf15b13a8019eca07bf0bc4c94652736e15d 100755 --- a/frameworks/core/interfaces/native/implementation/pan_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/pan_recognizer_peer.h @@ -30,6 +30,8 @@ using OHOS::Ace::PanDirection; using OHOS::Ace::PanGestureOption; struct PanRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(PanRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/pinch_gesture_interface_accessor.cpp b/frameworks/core/interfaces/native/implementation/pinch_gesture_interface_accessor.cpp index f024bb85e196d67cae593e04bf1b505e56fad58e..a9e3a31412ae36eee40bce29eb9c3b424e0ff592 100644 --- a/frameworks/core/interfaces/native/implementation/pinch_gesture_interface_accessor.cpp +++ b/frameworks/core/interfaces/native/implementation/pinch_gesture_interface_accessor.cpp @@ -94,7 +94,7 @@ Ark_PinchGestureInterface OnActionCancel0Impl(Ark_PinchGestureInterface peer, { CHECK_NULL_RETURN(peer && peer->gesture && event, peer); auto callback = [arkCallback = CallbackHelper(*event)](GestureEvent& info) { - arkCallback.Invoke(); + arkCallback.InvokeSync(); }; peer->gesture->SetOnActionCancelId(std::move(callback)); return peer; diff --git a/frameworks/core/interfaces/native/implementation/pinch_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/pinch_recognizer_peer.h index 452d671beeaac3c45a3a64ca490ffd529e338d6e..b2be64612871f9187151124541487a55f47f51b8 100644 --- a/frameworks/core/interfaces/native/implementation/pinch_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/pinch_recognizer_peer.h @@ -22,6 +22,8 @@ const double DEFAULT_DISTANCE = 5.0; struct PinchRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(PinchRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/rotation_gesture_interface_accessor.cpp b/frameworks/core/interfaces/native/implementation/rotation_gesture_interface_accessor.cpp index 815f2e2ad94ff15acba57aef9dfb201a2f32a543..1d9aa4e4e9194b7676c35a47759daa58101aa691 100644 --- a/frameworks/core/interfaces/native/implementation/rotation_gesture_interface_accessor.cpp +++ b/frameworks/core/interfaces/native/implementation/rotation_gesture_interface_accessor.cpp @@ -94,7 +94,7 @@ Ark_RotationGestureInterface OnActionCancel0Impl(Ark_RotationGestureInterface pe { CHECK_NULL_RETURN(peer && peer->gesture && event, peer); auto onActionCancel = [arkCallback = CallbackHelper(*event)](GestureEvent& info) { - arkCallback.Invoke(); + arkCallback.InvokeSync(); }; peer->gesture->SetOnActionCancelId(std::move(onActionCancel)); return peer; diff --git a/frameworks/core/interfaces/native/implementation/rotation_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/rotation_recognizer_peer.h index 0a0a669ee2ed43144c8b8fde3f7de6b656217d60..ad6d8b36ad00c1e082f7f15950730de2892c3fac 100644 --- a/frameworks/core/interfaces/native/implementation/rotation_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/rotation_recognizer_peer.h @@ -21,6 +21,8 @@ const double DEFAULT_ANGLE = 1.0; struct RotationRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(RotationRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/swipe_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/swipe_recognizer_peer.h index 06d5eb06b661f011a7cbfe1d6b875c588b05c7ab..1dba41d4416e3a76ae5e40428720c58e7e14feda 100644 --- a/frameworks/core/interfaces/native/implementation/swipe_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/swipe_recognizer_peer.h @@ -23,6 +23,8 @@ const double DEFAULT_SPEED = 100.0; const OHOS::Ace::SwipeDirection DEFAULT_DIRECT = { .type = OHOS::Ace::SwipeDirection::ALL }; struct SwipeRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(SwipeRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer); diff --git a/frameworks/core/interfaces/native/implementation/tap_recognizer_peer.h b/frameworks/core/interfaces/native/implementation/tap_recognizer_peer.h index 4c49e3e115683ff42d848a98faa9ff6ea4a3a5d7..cc49193d1ae09a51d512a599da152045736c4214 100644 --- a/frameworks/core/interfaces/native/implementation/tap_recognizer_peer.h +++ b/frameworks/core/interfaces/native/implementation/tap_recognizer_peer.h @@ -21,6 +21,8 @@ const int32_t DEFAULT_COUNT = 1; struct TapRecognizerPeer : public MultiFingerRecognizerPeer { + DECLARE_ACE_TYPE(TapRecognizerPeer, MultiFingerRecognizerPeer); +public: void Update(const OHOS::Ace::RefPtr& recognizer) { MultiFingerRecognizerPeer::Update(recognizer);