Skip to content

Commit

Permalink
Fix missing constructor for spine.String & SkeletonBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
bofeng-song committed Jul 17, 2024
1 parent 9921a33 commit 361c6b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cocos/spine/lib/spine-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
declare namespace spine {

class String {
constructor(name: string, own: boolean);
constructor(val: String);

Check failure on line 30 in cocos/spine/lib/spine-core.d.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Don't use `String` as a type. Use string instead
length: number;
isEmpty: boolean;
strPtr: number;
Expand Down
9 changes: 9 additions & 0 deletions native/cocos/editor-support/spine-wasm/spine-type-export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ void VECTOR_STD_COPY_SP(std::vector<T> &stdVector, Vector<T> &spVector) {
}
}

String* constructorSpineString(emscripten::val name, bool own) {
std::string tmp = name.as<std::string>();
return new String(tmp.c_str(), own);
}

using SPVectorFloat = Vector<float>;
using SPVectorVectorFloat = Vector<Vector<float>>;
using SPVectorInt = Vector<int>;
Expand Down Expand Up @@ -302,6 +307,9 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("normalize", &Vector2::normalize);

class_<String>("String")
.constructor<>()
.constructor(constructorSpineString)
.constructor<const String &>()
.function("length", &String::length)
.function("isEmpty", &String::isEmpty)
.function("append", select_overload<String&(const String&)>(&String::append))
Expand Down Expand Up @@ -499,6 +507,7 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("setTranslateMix", &PathConstraintData::setTranslateMix);

class_<SkeletonBounds>("SkeletonBounds")
.constructor<>()
.function("update", &SkeletonBounds::update)
.function("aabbContainsPoint", &SkeletonBounds::aabbcontainsPoint)
.function("aabbIntersectsSegment", &SkeletonBounds::aabbintersectsSegment)
Expand Down

0 comments on commit 361c6b4

Please sign in to comment.