From 4b478eebd4591d2971e5468c5a26944cf92b9d8c Mon Sep 17 00:00:00 2001 From: Mikhail Bystretskiy Date: Wed, 7 Aug 2024 11:39:00 +0300 Subject: [PATCH 1/2] Support for Ark_Int64 in Java interop code --- interop/src/cpp/types/signatures.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/interop/src/cpp/types/signatures.cc b/interop/src/cpp/types/signatures.cc index 0bbfc09a4..5b48b3136 100644 --- a/interop/src/cpp/types/signatures.cc +++ b/interop/src/cpp/types/signatures.cc @@ -39,6 +39,7 @@ KOALA_INTEROP_TYPEDEF(func, lang, "KInt", "I", "int") \ KOALA_INTEROP_TYPEDEF(func, lang, "KUInt", "I", "int") \ KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int32", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int64", "J", "long") \ KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Boolean", "I", "int") \ KOALA_INTEROP_TYPEDEF(func, lang, "KNativePointer", "J", "long") \ KOALA_INTEROP_TYPEDEF(func, lang, "Ark_NativePointer", "J", "long") \ -- Gitee From 4c53f668594cb6df3d882bc3f2d32e52ed3c3b2f Mon Sep 17 00:00:00 2001 From: Mikhail Bystretskiy Date: Wed, 7 Aug 2024 11:39:26 +0300 Subject: [PATCH 2/2] TreeNode for dummy libace in idlize --- arkoala/framework/native/src/tree.h | 82 ++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/arkoala/framework/native/src/tree.h b/arkoala/framework/native/src/tree.h index 7effcf330..12bc60271 100644 --- a/arkoala/framework/native/src/tree.h +++ b/arkoala/framework/native/src/tree.h @@ -20,14 +20,16 @@ #include #include +namespace DummyLibAce { + using std::string; const int UndefinedDimensionUnit = -1; struct Dimension { - ArkUI_Float32 value = 0; - ArkUI_Int32 unit = UndefinedDimensionUnit; + Ark_Float32 value = 0; + Ark_Int32 unit = UndefinedDimensionUnit; }; struct TreeNode { @@ -35,6 +37,7 @@ struct TreeNode { static int _globalId; static string _noAttribute; string _name; + GENERATED_Ark_NodeType _type; int _peerId; int _flags; // Id of our peer. @@ -48,14 +51,14 @@ struct TreeNode { std::vector _children; std::unordered_map _attributes; TreeNode* _parent; - ArkUI_Float32 _width; - ArkUI_Float32 _height; - ArkUI_Float32 _x; - ArkUI_Float32 _y; + Ark_Float32 _width; + Ark_Float32 _height; + Ark_Float32 _x; + Ark_Float32 _y; public: - TreeNode(const string& name, int peerId, int flags) : - _name(name), _peerId(peerId), _flags(flags), _id(_globalId++), _updaterId(0), _indexerId(0), _parent(nullptr) {} + TreeNode(const string& name, GENERATED_Ark_NodeType type, int peerId, int flags) : + _name(name), _type(type), _peerId(peerId), _flags(flags), _id(_globalId++), _updaterId(0), _indexerId(0), _parent(nullptr) {} ~TreeNode() {} @@ -95,18 +98,38 @@ struct TreeNode { return 0; } - ArkUI_Int32 measure(ArkUIVMContext vmContext, ArkUI_Float32* data); - ArkUI_Int32 layout(ArkUIVMContext vmContext, ArkUI_Float32* data); - ArkUI_Int32 draw(ArkUIVMContext vmContext, ArkUI_Float32* data); + Ark_Int32 measure(Ark_VMContext vmContext, Ark_Float32* data); + Ark_Int32 layout(Ark_VMContext vmContext, Ark_Float32* data); + Ark_Int32 draw(Ark_VMContext vmContext, Ark_Float32* data); - void setMeasureWidthValue(ArkUI_Int32 value); - ArkUI_Int32 getMeasureWidthValue(); - void setMeasureHeightValue(ArkUI_Int32 value); - ArkUI_Int32 getMeasureHeightValue(); - void setXValue(ArkUI_Int32 value); - ArkUI_Int32 getXValue(); - void setYValue(ArkUI_Int32 value); - ArkUI_Int32 getYValue(); + void setMeasureWidthValue(Ark_Int32 value) { + if (measureResult != nullptr) measureResult[0] = value; + _width = value; + } + Ark_Int32 getMeasureWidthValue() { + return (measureResult == nullptr) ? 0 : measureResult[0]; + } + void setMeasureHeightValue(Ark_Int32 value) { + if (measureResult != nullptr) measureResult[1] = value; + _height = value; + } + Ark_Int32 getMeasureHeightValue() { + return (measureResult == nullptr) ? 0 : measureResult[1]; + } + void setXValue(Ark_Int32 value) { + if (layoutResult != nullptr) layoutResult[0] = value; + _x = value; + } + Ark_Int32 getXValue() { + return (layoutResult == nullptr) ? 0 : layoutResult[0]; + } + void setYValue(Ark_Int32 value) { + if (layoutResult != nullptr) layoutResult[1] = value; + _y = value; + } + Ark_Int32 getYValue() { + return (layoutResult == nullptr) ? 0 : layoutResult[1]; + } void removeChild(TreeNode* node) { auto it = std::find(_children.begin(), _children.end(), node); @@ -118,14 +141,23 @@ struct TreeNode { int insertChildAfter(TreeNode* node, TreeNode* sibling) { auto it = std::find(_children.begin(), _children.end(), sibling); - _children.insert(it, node); + if (it == _children.end()) { + fprintf(stderr, "Sibling node %p not found among children\n", sibling); + throw "Error"; + } + auto next = std::next(it); + _children.insert(next, node); node->setParent(this); return 0; } int insertChildBefore(TreeNode* node, TreeNode* sibling) { auto it = std::find(_children.begin(), _children.end(), sibling); - _children.insert(std::prev(it, 1), node); + if (it == _children.end()) { + fprintf(stderr, "Sibling node %p not found among children\n", sibling); + throw "Error"; + } + _children.insert(it, node); node->setParent(this); return 0; } @@ -154,7 +186,9 @@ struct TreeNode { Dimension dimensionWidth; Dimension dimensionHeight; - ArkUI_Int32 alignment = 0; - ArkUI_Float32* measureResult = nullptr; - ArkUI_Float32* layoutResult = nullptr; + Ark_Int32 alignment = 0; + Ark_Float32* measureResult = nullptr; + Ark_Float32* layoutResult = nullptr; }; + +} \ No newline at end of file -- Gitee