From c7109915f453b81206f3da6d00666a4efab23feb Mon Sep 17 00:00:00 2001 From: bofeng-song Date: Thu, 18 Jul 2024 11:19:04 +0800 Subject: [PATCH] Fix missing constructor for spine.String & SkeletonBounds (#17376) * Fix missing constructor for spine.String & SkeletonBounds --- cocos/spine/lib/spine-core.d.ts | 2 ++ .../cocos/editor-support/spine-wasm/spine-type-export.cpp | 8 ++++++++ native/external-config.json | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos/spine/lib/spine-core.d.ts b/cocos/spine/lib/spine-core.d.ts index 55e14a954ae..0abe29e8027 100644 --- a/cocos/spine/lib/spine-core.d.ts +++ b/cocos/spine/lib/spine-core.d.ts @@ -26,6 +26,8 @@ declare namespace spine { class String { + constructor(name: string, own: boolean); + constructor(val: spine.String); length: number; isEmpty: boolean; strPtr: number; diff --git a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp b/native/cocos/editor-support/spine-wasm/spine-type-export.cpp index 4fc0eac3c8d..c8d8be95860 100644 --- a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp +++ b/native/cocos/editor-support/spine-wasm/spine-type-export.cpp @@ -60,6 +60,10 @@ void VECTOR_STD_COPY_SP(std::vector &stdVector, Vector &spVector) { } } +String* constructorSpineString(emscripten::val name, bool own) { + return new String(name.as().c_str(), own); +} + using SPVectorFloat = Vector; using SPVectorVectorFloat = Vector>; using SPVectorInt = Vector; @@ -302,6 +306,9 @@ EMSCRIPTEN_BINDINGS(spine) { .function("normalize", &Vector2::normalize); class_("String") + .constructor<>() + .constructor(constructorSpineString) + .constructor() .function("length", &String::length) .function("isEmpty", &String::isEmpty) .function("append", select_overload(&String::append)) @@ -499,6 +506,7 @@ EMSCRIPTEN_BINDINGS(spine) { .function("setTranslateMix", &PathConstraintData::setTranslateMix); class_("SkeletonBounds") + .constructor<>() .function("update", &SkeletonBounds::update) .function("aabbContainsPoint", &SkeletonBounds::aabbcontainsPoint) .function("aabbIntersectsSegment", &SkeletonBounds::aabbintersectsSegment) diff --git a/native/external-config.json b/native/external-config.json index c2416bbfd75..45b7100d021 100644 --- a/native/external-config.json +++ b/native/external-config.json @@ -3,6 +3,6 @@ "type": "github", "owner": "cocos-creator", "name": "engine-native-external", - "checkout": "v3.8.4-1" + "checkout": "v3.8.4-2" } } \ No newline at end of file