From 49c898e120ff5114681a557d069addaf783952a5 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Thu, 28 Nov 2024 14:32:52 +0800 Subject: [PATCH 1/6] add aki enum/class/struct snippets Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 11 +++++ .../snippets/aki_class_snippets.json | 40 +++++++++++++++++++ .../snippets/aki_enum_snippets.json | 21 ++++++++++ .../snippets/aki_struct_snippets.json | 40 +++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/vscode_plugin/snippets/aki_class_snippets.json create mode 100644 src/vscode_plugin/snippets/aki_enum_snippets.json create mode 100644 src/vscode_plugin/snippets/aki_struct_snippets.json diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index a4f5456e..32991cd6 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -139,6 +139,17 @@ { "language": "cpp", "path": "./snippets/napi_variable_snippets.json" + { + "language": "cpp", + "path": "./snippets/aki_class_snippets.json" + }, + { + "language": "cpp", + "path": "./snippets/aki_struct_snippets.json" + }, + { + "language": "cpp", + "path": "./snippets/aki_enum_snippets.json" } ] }, diff --git a/src/vscode_plugin/snippets/aki_class_snippets.json b/src/vscode_plugin/snippets/aki_class_snippets.json new file mode 100644 index 00000000..bfd0321d --- /dev/null +++ b/src/vscode_plugin/snippets/aki_class_snippets.json @@ -0,0 +1,40 @@ +{ + "Aki class": { + "prefix": "akiclass", + "body": [ + "class A {", + " public:", + " A() {", + " value_ = -1;", + " result = -1;", + " };", + " explicit A(double test) { value_ = test; }", + " ~A() = default;", + " static double MultiplyObject(A obj1, A obj2) { return obj1.value_ * obj2.value_; }", + " double Multiply(double mult) {", + " value_ *= mult;", + " return value_;", + " }", + " double GetValue() const { return value_; }", + " void SetValue(double value) { value_ = value; }", + " double result;", + " private:", + " double value_;", + "}; // A", + "// Bind class A.", + "JSBIND_CLASS(A) {", + " // Bind default constructor of class.", + " JSBIND_CONSTRUCTOR<>();", + " // Bind a parameterized constructor of class.", + " JSBIND_CONSTRUCTOR();", + " // Bind member method of class.", + " JSBIND_METHOD(MultiplyObject);", + " JSBIND_METHOD(Multiply);", + " // Listen to class member properties in C++.", + " JSBIND_FIELD(\"value\", GetValue, SetValue);", + " // Bind member property of class.", + " JSBIND_PROPERTY(result);", + "}" + ] + } +} \ No newline at end of file diff --git a/src/vscode_plugin/snippets/aki_enum_snippets.json b/src/vscode_plugin/snippets/aki_enum_snippets.json new file mode 100644 index 00000000..aeb1719c --- /dev/null +++ b/src/vscode_plugin/snippets/aki_enum_snippets.json @@ -0,0 +1,21 @@ +{ + "Aki enum": { + "prefix": "akienum", + "body": [ + "enum TypeFlags { NONE, NUM, STRING, BUTT = -1 };", + "// Bind C++ enum", + "JSBIND_ENUM(TypeFlags) {", + " // Bind C++ enum value.", + " JSBIND_ENUM_VALUE(NONE);", + " JSBIND_ENUM_VALUE(NUM);", + " JSBIND_ENUM_VALUE(STRING);", + "}", + "TypeFlags Passing(TypeFlags flag) { return flag; }", + "JSBIND_ADDON(entry)", + "JSBIND_GLOBAL() {", + " // Bind global function of using enum value.", + " JSBIND_FUNCTION(Passing);", + "}" + ] + } +} \ No newline at end of file diff --git a/src/vscode_plugin/snippets/aki_struct_snippets.json b/src/vscode_plugin/snippets/aki_struct_snippets.json new file mode 100644 index 00000000..f6d5594a --- /dev/null +++ b/src/vscode_plugin/snippets/aki_struct_snippets.json @@ -0,0 +1,40 @@ +{ + "Aki struct": { + "prefix": "akistruct", + "body": [ + "struct B {", + " public:", + " B() {", + " value_ = -1;", + " result = -1;", + " };", + " explicit B(double test) { value_ = test; }", + " ~B() = default;", + " static double MultiplyObject(B obj1, B obj2) { return obj1.value_ * obj2.value_; }", + " double Multiply(double mult) {", + " value_ *= mult;", + " return value_;", + " }", + " double GetValue() const { return value_; }", + " void SetValue(double value) { value_ = value; }", + " double result;", + " private:", + " double value_;", + "}; // B", + "// Bind struct B.", + "JSBIND_CLASS(B) {", + " // Bind default constructor of struct.", + " JSBIND_CONSTRUCTOR<>();", + " // Bind a parameterized constructor of struct.", + " JSBIND_CONSTRUCTOR();", + " // Bind member method of struct.", + " JSBIND_METHOD(MultiplyObject);", + " JSBIND_METHOD(Multiply);", + " // Listen to struct member properties in C++.", + " JSBIND_FIELD(\"value\", GetValue, SetValue);", + " // Bind member property of struct.", + " JSBIND_PROPERTY(result);", + "}" + ] + } +} \ No newline at end of file -- Gitee From 3ff1f8337227a28ff19407e426c75a547a38bd26 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Fri, 29 Nov 2024 17:34:22 +0800 Subject: [PATCH 2/6] resolve conflict Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index 32991cd6..56353168 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -139,18 +139,7 @@ { "language": "cpp", "path": "./snippets/napi_variable_snippets.json" - { - "language": "cpp", - "path": "./snippets/aki_class_snippets.json" - }, - { - "language": "cpp", - "path": "./snippets/aki_struct_snippets.json" - }, - { - "language": "cpp", - "path": "./snippets/aki_enum_snippets.json" - } + } ] }, "scripts": { -- Gitee From e1d03c583536344b610a23b94854923ec3897195 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Fri, 29 Nov 2024 17:45:02 +0800 Subject: [PATCH 3/6] resolve conflict Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index caf5523e..61cb1dda 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -140,18 +140,6 @@ "language": "cpp", "path": "./snippets/napi_variable_snippets.json" }, - { - "language": "cpp", - "path": "./snippets/aki_class_snippets.json" - }, - { - "language": "cpp", - "path": "./snippets/aki_struct_snippets.json" - }, - { - "language": "cpp", - "path": "./snippets/aki_enum_snippets.json" - }, { "language": "cpp", "path": "./snippets/napi_external_snippets.json" -- Gitee From ca5fbb56f003126a65b7ce0f4c898193b6151740 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Fri, 29 Nov 2024 17:45:48 +0800 Subject: [PATCH 4/6] resolve conflict Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index 61cb1dda..7a5d0cd1 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -147,7 +147,7 @@ { "language": "cpp", "path": "./snippets/napi_error_snippets.json" - } + }, ] }, "scripts": { -- Gitee From 130dd6ffb8ed0aabc80f88ef4b99486f5606c492 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Fri, 29 Nov 2024 17:47:36 +0800 Subject: [PATCH 5/6] resolve conflict Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index 7a5d0cd1..4ea90887 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -148,6 +148,7 @@ "language": "cpp", "path": "./snippets/napi_error_snippets.json" }, + } ] }, "scripts": { -- Gitee From bb00f89f7a4ec0ecc443c76e2eee9bc513589ca4 Mon Sep 17 00:00:00 2001 From: gou-jingjing Date: Fri, 29 Nov 2024 17:48:40 +0800 Subject: [PATCH 6/6] resolve conflict Signed-off-by: gou-jingjing --- src/vscode_plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index 4ea90887..d20723e5 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -148,7 +148,7 @@ "language": "cpp", "path": "./snippets/napi_error_snippets.json" }, - } + } ] }, "scripts": { -- Gitee