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 a574fc17fcc..b73f05e5391 100644 --- a/native/cocos/editor-support/spine-wasm/spine-type-export.cpp +++ b/native/cocos/editor-support/spine-wasm/spine-type-export.cpp @@ -1,21 +1,22 @@ -#include #include -#include +#include "spine-wasm.h" +#include "spine-skeleton-instance.h" +#include #include #include -#include "spine-skeleton-instance.h" -#include "spine-wasm.h" +#include using namespace emscripten; using namespace spine; namespace { -std::string STRING_SP2STD(const spine::String &str) { +std::string STRING_SP2STD(const spine::String& str) { std::string stdStr(str.buffer(), str.length()); return stdStr; } -const spine::String STRING_STD2SP(const std::string &str) { + +const spine::String STRING_STD2SP(const std::string& str) { const spine::String spString(str.c_str()); return spString; } @@ -44,23 +45,23 @@ std::vector VECTOR_SP2STD2(Vector container) { EMSCRIPTEN_BINDINGS(spine) { register_vector("VectorFloat"); - register_vector("VectorBoneData"); - register_vector("VectorBone"); - register_vector("VectorSkinEntry"); - register_vector("VectorSlotData"); - register_vector("VectorSlot"); - register_vector("VectorAnimation"); - register_vector("VectorSkin"); - register_vector("VectorEventData"); - register_vector("VectorEvent"); - register_vector("VectorConstraintData"); - register_vector("VectorIkConstraint"); - register_vector("VectorPathConstraint"); - register_vector("VectorTransformConstraint"); - register_vector("VectorIkConstraintData"); - register_vector("VectorTransformConstraintData"); - register_vector("VectorPathConstraintData"); - register_vector("VectorTrackEntry"); + register_vector("VectorBoneData"); + register_vector("VectorBone"); + register_vector("VectorSkinEntry"); + register_vector("VectorSlotData"); + register_vector("VectorSlot"); + register_vector("VectorAnimation"); + register_vector("VectorSkin"); + register_vector("VectorEventData"); + register_vector("VectorEvent"); + register_vector("VectorConstraintData"); + register_vector("VectorIkConstraint"); + register_vector("VectorPathConstraint"); + register_vector("VectorTransformConstraint"); + register_vector("VectorIkConstraintData"); + register_vector("VectorTransformConstraintData"); + register_vector("VectorPathConstraintData"); + register_vector("VectorTrackEntry"); enum_("TimelineType") .value("rotate", TimelineType_Rotate) @@ -78,7 +79,7 @@ EMSCRIPTEN_BINDINGS(spine) { .value("pathConstraintSpacing", TimelineType_PathConstraintSpacing) .value("pathConstraintMix", TimelineType_PathConstraintMix) .value("twoColor", TimelineType_TwoColor); - + enum_("MixDirection") .value("mixIn", MixDirection_In) .value("mixOut", MixDirection_Out); @@ -147,9 +148,8 @@ EMSCRIPTEN_BINDINGS(spine) { .value("Path", AttachmentType_Path) .value("Point", AttachmentType_Point) .value("Clipping", AttachmentType_Clipping); - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// // class_("Vector") // .constructor<>() // .constructor() @@ -169,42 +169,44 @@ EMSCRIPTEN_BINDINGS(spine) { .class_function("cosDeg", &MathUtil::cosDeg) .class_function("sinDeg", &MathUtil::sinDeg) .class_function("signum", &MathUtil::sign); - //.class_function("toInt", &MathUtil::toInt) - //.class_function("cbrt", &MathUtil::randomTriangular) - //.class_function("randomTriangular", &MathUtil::randomTriangular) - //.class_function("randomTriangularWith", &MathUtil::randomTriangular); + //.class_function("toInt", &MathUtil::toInt) + //.class_function("cbrt", &MathUtil::randomTriangular) + //.class_function("randomTriangular", &MathUtil::randomTriangular) + //.class_function("randomTriangularWith", &MathUtil::randomTriangular); class_("Color") .constructor<>() .constructor() - .function("set", static_cast(&Color::set)) + .function("set", static_cast(&Color::set)) //.function("setFromColor", static_cast(&Color::set)) //no need - .function("add", static_cast(&Color::add)) + .function("add", static_cast(&Color::add)) .function("clamp", &Color::clamp) .property("r", &Color::r) .property("g", &Color::g) .property("b", &Color::b) .property("a", &Color::a); - + class_("Interpolation") .function("apply", &Interpolation::apply, pure_virtual()); + class_("Triangulator") .constructor<>() .function("triangulate", &Triangulator::triangulate) .function("decompose", &Triangulator::decompose, allow_raw_pointers()); + class_("ConstraintData") - .constructor() - .function("getName", optional_override([](ConstraintData &obj) { return STRING_SP2STD(obj.getName()); })) + .constructor() + .function("getName", optional_override([](ConstraintData &obj) { return STRING_SP2STD(obj.getName());})) .function("getOrder", &ConstraintData::getOrder) .function("setOrder", &ConstraintData::setOrder) .function("getSkinRequired", &ConstraintData::isSkinRequired) .function("setSkinRequired", &ConstraintData::setSkinRequired); class_>("IkConstraintData") - .constructor() - .function("getBones", optional_override([](IkConstraintData &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) + .constructor() + .function("getBones", optional_override([](IkConstraintData &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) .function("getTarget", &IkConstraintData::getTarget, allow_raw_pointer()) .function("setTarget", &IkConstraintData::setTarget, allow_raw_pointer()) .function("getBendDirection", &IkConstraintData::getBendDirection) @@ -221,8 +223,8 @@ EMSCRIPTEN_BINDINGS(spine) { .function("setSoftness", &IkConstraintData::setSoftness); class_>("PathConstraintData") - .constructor() - .function("getBones", optional_override([](PathConstraintData &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) + .constructor() + .function("getBones", optional_override([](PathConstraintData &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) .function("getTarget", &PathConstraintData::getTarget, allow_raw_pointer()) .function("setTarget", &PathConstraintData::setTarget, allow_raw_pointer()) .function("getPositionMode", &PathConstraintData::getPositionMode) @@ -263,29 +265,30 @@ EMSCRIPTEN_BINDINGS(spine) { .function("getHeight", &SkeletonBounds::getHeight); class_("Event") - .constructor() + .constructor() .function("getData", &Event::getData) .function("getIntValue", &Event::getIntValue) .function("getFloatValue", &Event::getFloatValue) - .function("getStringValue", optional_override([](Event &obj) { return STRING_SP2STD(obj.getStringValue()); })) + .function("getStringValue",optional_override([](Event &obj) { return STRING_SP2STD(obj.getStringValue());})) .function("getTime", &Event::getTime) .function("getVolume", &Event::getVolume) - .function("getBalance", &Event::getBalance); + .function("getBalance", &Event::getBalance); class_("EventData") .constructor() - .function("getName", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getName()); })) + .function("getName", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getName());})) .function("getIntValue", &EventData::getIntValue) .function("getFloatValue", &EventData::getFloatValue) - .function("getStringValue", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getStringValue()); })) - .function("getAudioPath", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getAudioPath()); })) + .function("getStringValue", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getStringValue());})) + .function("getAudioPath", optional_override([](EventData &obj) { return STRING_SP2STD(obj.getAudioPath());})) .function("getVolume", &EventData::getVolume) .function("getBalance", &EventData::getBalance); + class_("Attachment") - .function("getName", optional_override([](Attachment &obj) { return STRING_SP2STD(obj.getName()); })); + .function("getName", optional_override([](Attachment &obj) { return STRING_SP2STD(obj.getName());})); - // pure_virtual and raw pointer + // pure_virtual and raw pointer class_>("VertexAttachment") //.constructor() .function("getProp_id", &VertexAttachment::getId) @@ -299,21 +302,21 @@ EMSCRIPTEN_BINDINGS(spine) { .function("copyTo", &VertexAttachment::copyTo, allow_raw_pointer()); class_>("BoundingBoxAttachment") - .constructor() - .function("getName", optional_override([](BoundingBoxAttachment &obj) { return STRING_SP2STD(obj.getName()); })) + .constructor() + .function("getName", optional_override([](BoundingBoxAttachment &obj) { return STRING_SP2STD(obj.getName());})) .function("copy", &BoundingBoxAttachment::copy, allow_raw_pointers()); - //.function("getProp_color", &BoundingBoxAttachment::getColor) + //.function("getProp_color", &BoundingBoxAttachment::getColor) class_>("ClippingAttachment") - .constructor() + .constructor() .function("getEndSlot", &ClippingAttachment::getEndSlot, allow_raw_pointer()) .function("copy", &ClippingAttachment::copy, allow_raw_pointer()); - //.function("getProp_color", &ClippingAttachment::getColor) + //.function("getProp_color", &ClippingAttachment::getColor) class_>("MeshAttachment") - .constructor() + .constructor() //.function("getProp_region", &MeshAttachment::getRegion) - .function("getPath", optional_override([](MeshAttachment &obj) { return STRING_SP2STD(obj.getPath()); })) + .function("getPath", optional_override([](MeshAttachment &obj) { return STRING_SP2STD(obj.getPath());})) .function("getRegionUVs", &MeshAttachment::getRegionUVs) .function("getUVs", &MeshAttachment::getUVs) .function("getTriangles", &MeshAttachment::getTriangles) @@ -330,15 +333,15 @@ EMSCRIPTEN_BINDINGS(spine) { .function("newLinkedMesh", &MeshAttachment::newLinkedMesh, allow_raw_pointer()); class_>("PathAttachment") - .constructor() - .function("getLengths", optional_override([](PathAttachment &obj) { return VECTOR_SP2STD(obj.getLengths()); })) + .constructor() + .function("getLengths", optional_override([](PathAttachment &obj) { return VECTOR_SP2STD(obj.getLengths());})) .function("getClosed", &PathAttachment::isClosed) .function("getConstantSpeed", &PathAttachment::isConstantSpeed) //.function("getProp_color", &MeshAttachment::getColor) // no color .function("copy", &PathAttachment::copy, allow_raw_pointers()); class_>("PointAttachment") - .constructor() + .constructor() .function("getX", &PointAttachment::getX) .function("getY", &PointAttachment::getY) .function("getRotation", &PointAttachment::getRotation) @@ -350,8 +353,9 @@ EMSCRIPTEN_BINDINGS(spine) { //class_("HasRendererObject") // .constructor<>(); + class_>("RegionAttachment") - .constructor() + .constructor() // static U4: number; // static V4: number; // ....... @@ -363,7 +367,7 @@ EMSCRIPTEN_BINDINGS(spine) { .function("getWidth", &RegionAttachment::getWidth) .function("getHeight", &RegionAttachment::getHeight) .function("getColor", &RegionAttachment::getColor) - .function("getPath", optional_override([](RegionAttachment &obj) { return STRING_SP2STD(obj.getPath()); })) + .function("getPath", optional_override([](RegionAttachment &obj) { return STRING_SP2STD(obj.getPath());})) .function("getRendererObject", &RegionAttachment::getRendererObject, allow_raw_pointer()) //.function("getProp_region", &PointAttachment::getRegion) .function("getOffset", &RegionAttachment::getOffset) @@ -373,6 +377,7 @@ EMSCRIPTEN_BINDINGS(spine) { //.function("setRegion", &RegionAttachment::setRegion) // have no setRegion .function("copy", &RegionAttachment::copy, allow_raw_pointer()); + // class_("AttachmentLoader") // .constructor<>() // .function("newClippingAttachment", &AttachmentLoader::newClippingAttachment, pure_virtual(), allow_raw_pointer()) @@ -382,19 +387,20 @@ EMSCRIPTEN_BINDINGS(spine) { // .function("newMeshAttachment", &AttachmentLoader::newMeshAttachment, pure_virtual(), allow_raw_pointer()) // .function("newRegionAttachment", &AttachmentLoader::newRegionAttachment, pure_virtual(), allow_raw_pointer()); + class_>("AtlasAttachmentLoader") - .constructor() + .constructor() .function("newRegionAttachment", &AtlasAttachmentLoader::newRegionAttachment, allow_raw_pointer()) .function("newMeshAttachment", &AtlasAttachmentLoader::newMeshAttachment, allow_raw_pointer()) .function("newBoundingBoxAttachment", &AtlasAttachmentLoader::newBoundingBoxAttachment, allow_raw_pointer()) .function("newPathAttachment", &AtlasAttachmentLoader::newPathAttachment, allow_raw_pointer()) .function("newPointAttachment", &AtlasAttachmentLoader::newPointAttachment, allow_raw_pointer()) .function("newClippingAttachment", &AtlasAttachmentLoader::newClippingAttachment, allow_raw_pointer()); - //.function("getProp_atlas") + //.function("getProp_atlas") class_("TextureAtlasPage") - .constructor() - .function("getName", optional_override([](AtlasPage &obj) { return STRING_SP2STD((const String)obj.name); })) + .constructor() + .function("getName", optional_override([](AtlasPage &obj) { return STRING_SP2STD((const String)obj.name);})) .property("minFilter", &AtlasPage::minFilter) .property("magFilter", &AtlasPage::magFilter) .property("uWrap", &AtlasPage::uWrap) @@ -405,29 +411,30 @@ EMSCRIPTEN_BINDINGS(spine) { class_("TextureAtlasRegion") //.property("page", &AtlasRegion::page) - .function("getName", optional_override([](AtlasRegion &obj) { return STRING_SP2STD((const String)obj.name); })) + .function("getName", optional_override([](AtlasRegion &obj) { return STRING_SP2STD((const String)obj.name);})) .property("x", &AtlasRegion::x) .property("y", &AtlasRegion::y) .property("index", &AtlasRegion::index) .property("rotate", &AtlasRegion::rotate) .property("degrees", &AtlasRegion::degrees); - //.property("texture", &AtlasRegion::height) + //.property("texture", &AtlasRegion::height) + class_("TextureAtlas") - .constructor() + .constructor() //.function("getProp_pages") //.function("getProp_regions") - .function("findRegion", optional_override([](Atlas &obj, const std::string &name) { return obj.findRegion(STRING_STD2SP(name)); }), allow_raw_pointers()); - //.function("dispose"); + .function("findRegion", optional_override([](Atlas &obj, const std::string& name) { return obj.findRegion(STRING_STD2SP(name));}), allow_raw_pointers()); + //.function("dispose"); class_>("Pow") .constructor() .function("apply", &PowInterpolation::apply); - + class_>("PowOut") .constructor() .function("apply", &PowInterpolation::apply); - + // class_("Vector2") // .constructor() // .function("set", static_cast(&Vector2::set)) @@ -437,9 +444,9 @@ EMSCRIPTEN_BINDINGS(spine) { // .property("y", &Vector2::y); class_("BoneData") - .constructor() + .constructor() .function("getIndex", &BoneData::getIndex) - .function("getName", optional_override([](BoneData &obj) { return STRING_SP2STD(obj.getName()); })) + .function("getName", optional_override([](BoneData &obj) { return STRING_SP2STD(obj.getName());})) .function("getParent", &BoneData::getParent, allow_raw_pointer()) .function("getLength", &BoneData::getLength) .function("getX", &BoneData::getX) @@ -451,64 +458,64 @@ EMSCRIPTEN_BINDINGS(spine) { .function("getShearY", &BoneData::getShearY) .function("getTransformMode", &BoneData::getTransformMode) .function("getSkinRequired", &BoneData::isSkinRequired); - //.function("getProp_color", &BoneData::isSkinRequired) // have no color - + //.function("getProp_color", &BoneData::isSkinRequired) // have no color + class_("SlotData") - .constructor() + .constructor() .function("getIndex", &SlotData::getIndex) - .function("getName", optional_override([](SlotData &obj) { return STRING_SP2STD(obj.getName()); })) + .function("getName", optional_override([](SlotData &obj) { return STRING_SP2STD(obj.getName());})) .function("getBoneData", &SlotData::getBoneData) .function("getColor", &SlotData::getColor) .function("getDarkColor", &SlotData::getDarkColor) .function("getBlendMode", &SlotData::getBlendMode); - + class_("Updatable") .function("update", &Updatable::update, pure_virtual()) .function("isActive", &Updatable::isActive, pure_virtual()); class_>("IkConstraint") .constructor() - .function("getData", &IkConstraint::getData) - .function("getBones", optional_override([](IkConstraint &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) - .function("getTarget", &IkConstraint::getTarget, allow_raw_pointer()) + .function("getData", &IkConstraint::getData) + .function("getBones", optional_override([](IkConstraint &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) + .function("getTarget", &IkConstraint::getTarget, allow_raw_pointer()) .function("setTarget", &IkConstraint::setTarget, allow_raw_pointer()) - .function("getBendDirection", &IkConstraint::getBendDirection) + .function("getBendDirection", &IkConstraint::getBendDirection) .function("setBendDirection", &IkConstraint::setBendDirection) - .function("getCompress", &IkConstraint::getCompress) + .function("getCompress", &IkConstraint::getCompress) .function("setCompress", &IkConstraint::setCompress) - .function("getStretch", &IkConstraint::getStretch) + .function("getStretch", &IkConstraint::getStretch) .function("setStretch", &IkConstraint::setStretch) - .function("getMix", &IkConstraint::getMix) + .function("getMix", &IkConstraint::getMix) .function("setMix", &IkConstraint::setMix) - .function("getSoftness", &IkConstraint::getSoftness) + .function("getSoftness", &IkConstraint::getSoftness) .function("setSoftness", &IkConstraint::setSoftness) - .function("getActive", &IkConstraint::isActive) + .function("getActive", &IkConstraint::isActive) .function("setActive", &IkConstraint::setActive) - .function("isActive", &IkConstraint::isActive) - .function("apply", static_cast(&IkConstraint::apply)) + .function("isActive", &IkConstraint::isActive) + .function("apply", static_cast(&IkConstraint::apply)) .function("update", &IkConstraint::update) //.function("apply1", static_cast(&IkConstraint::apply)) //.function("apply2", static_cast(&IkConstraint::apply)) ; class_>("PathConstraint") - .constructor() + .constructor() // private but no need, just wrap in js // static const float EPSILON; // static const int NONE; // static const int BEFORE; // static const int AFTER; - .function("getData", &PathConstraint::getData) - .function("getBones", optional_override([](PathConstraint &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) - .function("getTarget", &PathConstraint::getTarget, allow_raw_pointer()) + .function("getData", &PathConstraint::getData) + .function("getBones", optional_override([](PathConstraint &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) + .function("getTarget", &PathConstraint::getTarget, allow_raw_pointer()) .function("setTarget", &PathConstraint::setTarget, allow_raw_pointer()) - .function("getPosition", &PathConstraint::getPosition) + .function("getPosition", &PathConstraint::getPosition) .function("setPosition", &PathConstraint::setPosition) - .function("getSpacing", &PathConstraint::getSpacing) + .function("getSpacing", &PathConstraint::getSpacing) .function("setSpacing", &PathConstraint::setSpacing) - .function("getRotateMix", &PathConstraint::getRotateMix) + .function("getRotateMix", &PathConstraint::getRotateMix) .function("setRotateMix", &PathConstraint::setRotateMix) - .function("getTranslateMix", &PathConstraint::getTranslateMix) + .function("getTranslateMix", &PathConstraint::getTranslateMix) .function("getTranslateMix", &PathConstraint::setTranslateMix) //.function("getProp_spaces", &PathConstraint::spaces) //.function("getProp_positions", &PathConstraint::positions) @@ -516,11 +523,11 @@ EMSCRIPTEN_BINDINGS(spine) { //.function("getProp_curves", &PathConstraint::curves) //.function("getProp_lengths", &PathConstraint::lengths) //.function("getProp_segments", &PathConstraint::segments) - .function("getActive", &PathConstraint::isActive) - .function("isActive", &PathConstraint::isActive) + .function("getActive", &PathConstraint::isActive) + .function("isActive", &PathConstraint::isActive) .function("setActive", &PathConstraint::setActive) - .function("apply", &PathConstraint::apply) - .function("update", &PathConstraint::update) + .function("apply", &PathConstraint::apply) + .function("update", &PathConstraint::update) //.function("computeWorldPositions", &PathConstraint::computeWorldPositions) //.function("addBeforePosition", &PathConstraint::addBeforePosition) //.function("addAfterPosition", &PathConstraint::addAfterPosition) @@ -528,8 +535,8 @@ EMSCRIPTEN_BINDINGS(spine) { ; class_>("TransformConstraintData") - .constructor() - .function("getBones", optional_override([](TransformConstraintData &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) + .constructor() + .function("getBones", optional_override([](TransformConstraintData &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) .function("getTarget", &TransformConstraintData::getTarget, allow_raw_pointer()) .function("getRotateMix", &TransformConstraintData::getRotateMix) .function("getTranslateMix", &TransformConstraintData::getTranslateMix) @@ -547,7 +554,7 @@ EMSCRIPTEN_BINDINGS(spine) { class_>("TransformConstraint") .constructor() .function("getData", &TransformConstraint::getData) - .function("getBones", optional_override([](TransformConstraint &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) + .function("getBones", optional_override([](TransformConstraint &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) .function("getTarget", &TransformConstraint::getTarget, allow_raw_pointer()) .function("getRotateMix", &TransformConstraint::getRotateMix) .function("getTranslateMix", &TransformConstraint::getTranslateMix) @@ -558,10 +565,11 @@ EMSCRIPTEN_BINDINGS(spine) { .function("isActive", &TransformConstraint::isActive) .function("apply", &TransformConstraint::apply) .function("update", &TransformConstraint::update); - //.function("applyAbsoluteWorld", &TransformConstraint::applyAbsoluteWorld) - //.function("applyRelativeWorld", &TransformConstraint::applyRelativeWorld) - //.function("applyAbsoluteLocal", &TransformConstraint::applyAbsoluteLocal) - //.function("applyRelativeLocal", &TransformConstraint::applyRelativeLocal) + //.function("applyAbsoluteWorld", &TransformConstraint::applyAbsoluteWorld) + //.function("applyRelativeWorld", &TransformConstraint::applyRelativeWorld) + //.function("applyAbsoluteLocal", &TransformConstraint::applyAbsoluteLocal) + //.function("applyRelativeLocal", &TransformConstraint::applyRelativeLocal) + class_>("Bone") .constructor() @@ -595,7 +603,7 @@ EMSCRIPTEN_BINDINGS(spine) { .function("isActive", &Bone::isActive) .function("update", &Bone::update) .function("updateWorldTransform", select_overload(&Bone::updateWorldTransform)) - .function("updateWorldTransformWith", select_overload(&Bone::updateWorldTransform)) + .function("updateWorldTransformWith", select_overload(&Bone::updateWorldTransform)) .function("setToSetupPose", &Bone::setToSetupPose) .function("getWorldRotationX", &Bone::getWorldRotationX) .function("getWorldRotationY", &Bone::getWorldRotationY) @@ -645,37 +653,34 @@ EMSCRIPTEN_BINDINGS(spine) { .function("setToSetupPose", &Slot::setToSetupPose); class_("Skin") - .constructor() - .function("getName", optional_override([](Skin &obj) { return STRING_SP2STD(obj.getName()); })) - .function("getBones", optional_override([](Skin &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) - .function("getConstraints", optional_override([](Skin &obj) { return VECTOR_SP2STD(obj.getConstraints()); }), allow_raw_pointers()) - .function("setAttachment", optional_override([](Skin &obj, size_t index, const std::string &name, Attachment *attachment) { return obj.setAttachment(index, STRING_STD2SP(name), attachment); }), allow_raw_pointers()) + .constructor() + .function("getName", optional_override([](Skin &obj) { return STRING_SP2STD(obj.getName());})) + .function("getBones", optional_override([](Skin &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) + .function("getConstraints", optional_override([](Skin &obj) { return VECTOR_SP2STD(obj.getConstraints());}), allow_raw_pointers()) + .function("setAttachment", optional_override([](Skin &obj, size_t index, const std::string& name, Attachment *attachment) { return obj.setAttachment(index, STRING_STD2SP(name), attachment); }), allow_raw_pointers()) .function("addSkin", select_overload(&Skin::addSkin), allow_raw_pointers()) .function("copySkin", select_overload(&Skin::copySkin), allow_raw_pointers()) - .function("getAttachment", optional_override([](Skin &obj, size_t slotIndex, const std::string &name) { - return obj.getAttachment(slotIndex, STRING_STD2SP(name)); - }), - allow_raw_pointers()) + .function("getAttachment", optional_override([](Skin &obj, size_t slotIndex, const std::string& name) { + return obj.getAttachment(slotIndex, STRING_STD2SP(name)); + }), allow_raw_pointers()) .function("getAttachments", optional_override([](Skin &obj) { - std::vector entriesVector; - auto entries = obj.getAttachments(); - while (entries.hasNext()) { - entriesVector.push_back(&entries.next()); - } - return entriesVector; - }), - allow_raw_pointers()) - .function("removeAttachment", optional_override([](Skin &obj, size_t index, const std::string &name) { obj.removeAttachment(index, STRING_STD2SP(name)); })) + std::vector entriesVector; + auto entries = obj.getAttachments(); + while (entries.hasNext()) { + entriesVector.push_back(&entries.next()); + } + return entriesVector; + }), allow_raw_pointers()) + .function("removeAttachment", optional_override([](Skin &obj, size_t index, const std::string& name) { obj.removeAttachment(index, STRING_STD2SP(name)); })) .function("getAttachmentsForSlot", optional_override([](Skin &obj, size_t index) { - std::vector entriesVector; - auto entries = obj.getAttachments(); - while (entries.hasNext()) { - Skin::AttachmentMap::Entry &entry = entries.next(); - if (entry._slotIndex == index) entriesVector.push_back(&entry); - } - return entriesVector; - }), - allow_raw_pointers()) + std::vector entriesVector; + auto entries = obj.getAttachments(); + while (entries.hasNext()) { + Skin::AttachmentMap::Entry &entry = entries.next(); + if (entry._slotIndex == index) entriesVector.push_back(&entry); + } + return entriesVector; + }), allow_raw_pointers()) //.function("clear", &Skin::clear); // have no clear //.function("attachAll", &Skin::attachAll) ; @@ -683,8 +688,9 @@ EMSCRIPTEN_BINDINGS(spine) { class_("SkinEntry") .constructor() .property("slotIndex", &Skin::AttachmentMap::Entry::_slotIndex) - .function("getName", optional_override([](Skin::AttachmentMap::Entry &obj) { return STRING_SP2STD((const String)obj._name); })) - .function("getAttachment", optional_override([](Skin::AttachmentMap::Entry &obj) { return obj._attachment; }), allow_raw_pointers()); + .function("getName", optional_override([](Skin::AttachmentMap::Entry &obj) { return STRING_SP2STD((const String)obj._name);})) + .function("getAttachment", optional_override([](Skin::AttachmentMap::Entry &obj) { return obj._attachment;}), allow_raw_pointers()) + ; class_("SkeletonClipping") .constructor<>() @@ -692,45 +698,45 @@ EMSCRIPTEN_BINDINGS(spine) { .function("getClippedTriangles", &SkeletonClipping::getClippedTriangles) .function("getUVs", &SkeletonClipping::getClippedUVs) .function("clipStart", &SkeletonClipping::clipStart, allow_raw_pointers()) - .function("clipEndWithSlot", select_overload(&SkeletonClipping::clipEnd)) + .function("clipEndWithSlot", select_overload(&SkeletonClipping::clipEnd)) .function("clipEnd", select_overload(&SkeletonClipping::clipEnd)) .function("isClipping", &SkeletonClipping::isClipping); - //.function("clipTriangles", &SkeletonClipping::clipTriangles, allow_raw_pointers()); //paramters not match - //.function("clip", &SkeletonClipping::clip) - //.class_function("makeClockwise", &SkeletonClipping::makeClockwise) + //.function("clipTriangles", &SkeletonClipping::clipTriangles, allow_raw_pointers()); //paramters not match + //.function("clip", &SkeletonClipping::clip) + //.class_function("makeClockwise", &SkeletonClipping::makeClockwise) class_("SkeletonData") .constructor<>() - .function("getName", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getName()); })) - .function("getBones", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) - .function("getSlots", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getSlots()); }), allow_raw_pointers()) - .function("getSkins", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getSkins()); }), allow_raw_pointers()) + .function("getName", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getName());})) + .function("getBones", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) + .function("getSlots", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getSlots());}), allow_raw_pointers()) + .function("getSkins", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getSkins());}), allow_raw_pointers()) .function("getDefaultSkin", &SkeletonData::getDefaultSkin, allow_raw_pointer()) - .function("getEvents", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getEvents()); }), allow_raw_pointers()) - .function("getAnimations", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getAnimations()); }), allow_raw_pointers()) - .function("getIkConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getIkConstraints()); }), allow_raw_pointers()) - .function("getTransformConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getTransformConstraints()); }), allow_raw_pointers()) - .function("getPathConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getPathConstraints()); }), allow_raw_pointers()) + .function("getEvents", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getEvents());}), allow_raw_pointers()) + .function("getAnimations", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getAnimations());}), allow_raw_pointers()) + .function("getIkConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getIkConstraints());}), allow_raw_pointers()) + .function("getTransformConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getTransformConstraints());}), allow_raw_pointers()) + .function("getPathConstraints", optional_override([](SkeletonData &obj) { return VECTOR_SP2STD(obj.getPathConstraints());}), allow_raw_pointers()) .function("getX", &SkeletonData::getX) .function("getY", &SkeletonData::getY) .function("getWidth", &SkeletonData::getWidth) .function("getHeight", &SkeletonData::getHeight) - .function("getVersion", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getVersion()); })) - .function("getHash", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getHash()); })) + .function("getVersion", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getVersion());})) + .function("getHash", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getHash());})) .function("getFps", &SkeletonData::getFps) - .function("getImagesPath", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getImagesPath()); })) - .function("getAudioPath", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getAudioPath()); })) - .function("findBone", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findBone(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findBoneIndex", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findBoneIndex(STRING_STD2SP(name)); })) - .function("findSlot", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findSlot(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findSlotIndex", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findSlotIndex(STRING_STD2SP(name)); })) - .function("findSkin", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findSkin(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findEvent", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findEvent(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findAnimation", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findAnimation(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findIkConstraint", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findIkConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findTransformConstraint", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findTransformConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findPathConstraint", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findPathConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findPathConstraintIndex", optional_override([](SkeletonData &obj, const std::string &name) { return obj.findPathConstraintIndex(STRING_STD2SP(name)); })); + .function("getImagesPath", optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getImagesPath());})) + .function("getAudioPath",optional_override([](SkeletonData &obj) { return STRING_SP2STD(obj.getAudioPath());})) + .function("findBone", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findBone(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findBoneIndex", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findBoneIndex(STRING_STD2SP(name));})) + .function("findSlot", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findSlot(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findSlotIndex", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findSlotIndex(STRING_STD2SP(name));})) + .function("findSkin", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findSkin(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findEvent", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findEvent(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findAnimation", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findAnimation(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findIkConstraint", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findIkConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findTransformConstraint", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findTransformConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findPathConstraint", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findPathConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findPathConstraintIndex", optional_override([](SkeletonData &obj, const std::string& name) { return obj.findPathConstraintIndex(STRING_STD2SP(name));})); class_("Timeline") // to fix apply @@ -764,7 +770,7 @@ EMSCRIPTEN_BINDINGS(spine) { .function("getPropertyId", &TranslateTimeline::getPropertyId) .function("setFrame", &TranslateTimeline::setFrame) .function("apply", &TranslateTimeline::apply, allow_raw_pointers()); - + class_>("ScaleTimeline") .constructor() .function("getPropertyId", &ScaleTimeline::getPropertyId) @@ -782,7 +788,7 @@ EMSCRIPTEN_BINDINGS(spine) { //static const int PREV_ROTATION = -1; //static const int ROTATION = 1; .function("getBoneIndex", &RotateTimeline::getBoneIndex) - .function("getFrames", optional_override([](RotateTimeline &obj) { return VECTOR_SP2STD(obj.getFrames()); })) + .function("getFrames", optional_override([](RotateTimeline &obj) { return VECTOR_SP2STD(obj.getFrames());})) .function("getPropertyId", &RotateTimeline::getPropertyId) .function("setFrame", &RotateTimeline::setFrame) .function("apply", &RotateTimeline::apply, allow_raw_pointers()); @@ -800,10 +806,10 @@ EMSCRIPTEN_BINDINGS(spine) { // static const int B; // static const int A; .function("getSlotIndex", &ColorTimeline::getSlotIndex) - .function("getFrames", optional_override([](ColorTimeline &obj) { return VECTOR_SP2STD(obj.getFrames()); })) + .function("getFrames", optional_override([](ColorTimeline &obj) { return VECTOR_SP2STD(obj.getFrames());})) .function("getPropertyId", &ColorTimeline::getPropertyId) .function("setFrame", &ColorTimeline::setFrame) - .function("apply", &ColorTimeline::apply, allow_raw_pointers()); + .function("apply", &ColorTimeline::apply, allow_raw_pointers()); class_>("TwoColorTimeline") .constructor() @@ -817,19 +823,19 @@ EMSCRIPTEN_BINDINGS(spine) { class_>("AttachmentTimeline") .constructor() .function("getSlotIndex", &AttachmentTimeline::getSlotIndex) - .function("getFrames", optional_override([](AttachmentTimeline &obj) { return VECTOR_SP2STD((Vector &)obj.getFrames()); })) + .function("getFrames", optional_override([](AttachmentTimeline &obj) { return VECTOR_SP2STD((Vector &)obj.getFrames());})) //.function("getProp_attachmentNames", &AttachmentTimeline::getAttachmentNames) .function("getPropertyId", &AttachmentTimeline::getPropertyId) .function("getFrameCount", &AttachmentTimeline::getFrameCount) .function("setFrame", &AttachmentTimeline::setFrame) .function("apply", &AttachmentTimeline::apply, allow_raw_pointers()); - //.function("setAttachment", &AttachmentTimeline::setAttachment) //have no setAttachment + //.function("setAttachment", &AttachmentTimeline::setAttachment) //have no setAttachment class_>("DeformTimeline") .constructor() .function("getSlotIndex", &DeformTimeline::getSlotIndex) .function("getAttachment", &DeformTimeline::getAttachment, allow_raw_pointer()) - .function("getFrames", optional_override([](DeformTimeline &obj) { return VECTOR_SP2STD((Vector &)obj.getFrames()); })) + .function("getFrames", optional_override([](DeformTimeline &obj) { return VECTOR_SP2STD((Vector &)obj.getFrames());})) .function("getFrameVertices", &DeformTimeline::getVertices) .function("getPropertyId", &DeformTimeline::getPropertyId) .function("setFrame", &DeformTimeline::setFrame) @@ -837,8 +843,8 @@ EMSCRIPTEN_BINDINGS(spine) { class_>("EventTimeline") .constructor() - .function("getFrames", optional_override([](EventTimeline &obj) { return VECTOR_SP2STD2(obj.getFrames()); })) - .function("getEvents", optional_override([](EventTimeline &obj) { return VECTOR_SP2STD(obj.getEvents()); }), allow_raw_pointers()) + .function("getFrames", optional_override([](EventTimeline &obj) { return VECTOR_SP2STD2(obj.getFrames());})) + .function("getEvents", optional_override([](EventTimeline &obj) { return VECTOR_SP2STD(obj.getEvents());}), allow_raw_pointers()) .function("getPropertyId", &EventTimeline::getPropertyId) .function("getFrameCount", &EventTimeline::getFrameCount) .function("setFrame", &EventTimeline::setFrame, allow_raw_pointers()) @@ -846,7 +852,7 @@ EMSCRIPTEN_BINDINGS(spine) { class_>("DrawOrderTimeline") .constructor() - .function("getFrames", optional_override([](DrawOrderTimeline &obj) { return VECTOR_SP2STD(obj.getFrames()); })) + .function("getFrames", optional_override([](DrawOrderTimeline &obj) { return VECTOR_SP2STD(obj.getFrames());})) //.function("getProp_drawOrders", &EventTimeline::getDrawOrders) .function("getPropertyId", &DrawOrderTimeline::getPropertyId) .function("getFrameCount", &DrawOrderTimeline::getFrameCount) @@ -942,102 +948,96 @@ EMSCRIPTEN_BINDINGS(spine) { .constructor() .function("getDefaultMix", &AnimationStateData::getDefaultMix) .function("getSkeletonData", &AnimationStateData::getSkeletonData, allow_raw_pointers()) - .function("setMix", optional_override([](AnimationStateData &obj, std::string fromName, std::string toName, float duration) { - .function("setMixWith", optional_override([](AnimationStateData &obj, Animation *from, Animation *to, float duration) { return obj.setMix(from, to, duration); }), allow_raw_pointers()) - .function("getMix", &AnimationStateData::getMix, allow_raw_pointers()); - - // .function("setMixWith", &Skeleton::setMixWith_Export) - //.function("getMix", &Skeleton::setMix_Export); - - class_("AnimationState") - .constructor() - // static variables - // .class_function("getProp_emptyAnimation",&AnimationState::getEmptyAnimation, allow_raw_pointers()) // private - .function("getData", &AnimationState::getData, allow_raw_pointers()) - .function("getTracks", optional_override([](AnimationState &obj) { return VECTOR_SP2STD(obj.getTracks()); }), allow_raw_pointers()) - .function("getTimeScale", &AnimationState::getTimeScale) - .function("setTimeScale", &AnimationState::setTimeScale) - //.function("getProp_unkeyedState") - //.function("getProp_events") - //.function("getProp_listeners") - //.function("getProp_queue") - //.function("getProp_queue") - //.function("getProp_propertyIDs", &AnimationState::getPropertyIDs) - //.function("getProp_animationsChanged", &AnimationState::getAnimationsChanged) - //.function("getProp_trackEntryPool", &AnimationState::getTrackEntryPool) - .function("update", &AnimationState::update) - //.function("updateMixingFrom", &AnimationState::updateMixingFrom, allow_raw_pointers()) //private - .function("apply", &AnimationState::apply) - // .function("applyMixingFrom", &AnimationState::applyMixingFrom, allow_raw_pointers()) //private - //.function("applyAttachmentTimeline", &AnimationState::applyAttachmentTimeline) // have no - //.function("setAttachment", &AnimationState::setAttachment) // have no - // .class_function("applyRotateTimeline", &AnimationState::applyRotateTimeline, allow_raw_pointers()) - // .function("queueEvents", &AnimationState::queueEvents, allow_raw_pointers()) - .function("clearTracks", &AnimationState::clearTracks) - .function("clearTrack", &AnimationState::clearTrack) - //.function("setCurrent", &AnimationState::setCurrent, allow_raw_pointers()) // private - .function("setAnimation", optional_override([](AnimationState &obj, uint32_t trackIndex, const std::string &animName, bool loop) { return obj.setAnimation(trackIndex, STRING_STD2SP(animName), loop); }), allow_raw_pointers()) - .function("setAnimationWith", optional_override([](AnimationState &obj, uint32_t trackIndex, Animation *animation, bool loop) { return obj.setAnimation(trackIndex, animation, loop); }), allow_raw_pointers()) - .function("addAnimation", optional_override([](AnimationState &obj, uint32_t trackIndex, const std::string &animName, bool loop, float delay) { return obj.addAnimation(trackIndex, STRING_STD2SP(animName), loop, delay); }), allow_raw_pointers()) - .function("addAnimationWith", optional_override([](AnimationState &obj, uint32_t trackIndex, Animation *animation, bool loop, float delay) { return obj.addAnimation(trackIndex, animation, loop, delay); }), allow_raw_pointers()) - .function("setEmptyAnimation", &AnimationState::setEmptyAnimation, allow_raw_pointers()) - .function("addEmptyAnimation", &AnimationState::addEmptyAnimation, allow_raw_pointers()) - .function("setEmptyAnimations", &AnimationState::setEmptyAnimations) - //.function("expandToIndex", &AnimationState::expandToIndex, allow_raw_pointers()) // private - //.function("trackEntry", &AnimationState::newTrackEntry, allow_raw_pointers()) // private - //.function("disposeNext", &AnimationState::disposeNext) // private - //.function("_animationsChanged", &AnimationState::animationsChanged) // private - //.function("computeHold", &AnimationState::computeHold, allow_raw_pointer()) // private - .function("getCurrent", &AnimationState::getCurrent, allow_raw_pointer()); + .function("setMix", optional_override([](AnimationStateData &obj, const std::string& fromName, const std::string& toName, float duration) { + return obj.setMix(STRING_STD2SP(fromName), STRING_STD2SP(toName), duration);})) + .function("setMixWith", optional_override([](AnimationStateData &obj, Animation* from, Animation* to, float duration) { + return obj.setMix(from, to, duration);}), allow_raw_pointers()) + .function("getMix", &AnimationStateData::getMix, allow_raw_pointers()); + + class_("AnimationState") + .constructor() + // static variables + // .class_function("getProp_emptyAnimation",&AnimationState::getEmptyAnimation, allow_raw_pointers()) // private + .function("getData", &AnimationState::getData, allow_raw_pointers()) + .function("getTracks", optional_override([](AnimationState &obj) { return VECTOR_SP2STD(obj.getTracks());}), allow_raw_pointers()) + .function("getTimeScale", &AnimationState::getTimeScale) + .function("setTimeScale", &AnimationState::setTimeScale) + //.function("getProp_unkeyedState") + //.function("getProp_events") + //.function("getProp_listeners") + //.function("getProp_queue") + //.function("getProp_queue") + //.function("getProp_propertyIDs", &AnimationState::getPropertyIDs) + //.function("getProp_animationsChanged", &AnimationState::getAnimationsChanged) + //.function("getProp_trackEntryPool", &AnimationState::getTrackEntryPool) + .function("update", &AnimationState::update) + //.function("updateMixingFrom", &AnimationState::updateMixingFrom, allow_raw_pointers()) //private + .function("apply", &AnimationState::apply) + // .function("applyMixingFrom", &AnimationState::applyMixingFrom, allow_raw_pointers()) //private + //.function("applyAttachmentTimeline", &AnimationState::applyAttachmentTimeline) // have no + //.function("setAttachment", &AnimationState::setAttachment) // have no + // .class_function("applyRotateTimeline", &AnimationState::applyRotateTimeline, allow_raw_pointers()) + // .function("queueEvents", &AnimationState::queueEvents, allow_raw_pointers()) + .function("clearTracks", &AnimationState::clearTracks) + .function("clearTrack", &AnimationState::clearTrack) + //.function("setCurrent", &AnimationState::setCurrent, allow_raw_pointers()) // private + .function("setAnimation", optional_override([](AnimationState &obj, uint32_t trackIndex, const std::string& animName, bool loop) { return obj.setAnimation(trackIndex, STRING_STD2SP(animName), loop);}), allow_raw_pointers()) + .function("setAnimationWith", optional_override([](AnimationState &obj, uint32_t trackIndex, Animation* animation, bool loop) { return obj.setAnimation(trackIndex, animation, loop);}), allow_raw_pointers()) + .function("addAnimation", optional_override([](AnimationState &obj, uint32_t trackIndex, const std::string& animName, bool loop, float delay) { return obj.addAnimation(trackIndex, STRING_STD2SP(animName), loop, delay);}), allow_raw_pointers()) + .function("addAnimationWith", optional_override([](AnimationState &obj, uint32_t trackIndex, Animation* animation, bool loop, float delay) { return obj.addAnimation(trackIndex, animation, loop, delay);}), allow_raw_pointers()) + .function("setEmptyAnimation", &AnimationState::setEmptyAnimation, allow_raw_pointers()) + .function("addEmptyAnimation", &AnimationState::addEmptyAnimation, allow_raw_pointers()) + .function("setEmptyAnimations", &AnimationState::setEmptyAnimations) + //.function("expandToIndex", &AnimationState::expandToIndex, allow_raw_pointers()) // private + //.function("trackEntry", &AnimationState::newTrackEntry, allow_raw_pointers()) // private + //.function("disposeNext", &AnimationState::disposeNext) // private + //.function("_animationsChanged", &AnimationState::animationsChanged) // private + //.function("computeHold", &AnimationState::computeHold, allow_raw_pointer()) // private + .function("getCurrent", &AnimationState::getCurrent, allow_raw_pointer()); //.function("addListener", &AnimationState::addListener) //.function("removeListener", &AnimationState::removeListener) //.function("clearListeners", &AnimationState::clearListeners) // no have clearListeners // .function("clearListenerNotifications", &AnimationState::clearListenerNotifications); // no have clearListenerNotifications - class_("Animation") - .constructor &, float>() - .function("getName", optional_override([](Animation &obj) { return STRING_SP2STD(obj.getName()); })) - .function("getTimelines", optional_override([](Animation &obj) { return VECTOR_SP2STD(obj.getTimelines()); })) - //.function("getProp_timelineIds", &Animation::getTimelines) - .function("getDuration", &Animation::getDuration) - .function("setDuration", &Animation::setDuration) - .function("hasTimeline", &Animation::hasTimeline) - .function("apply", &Animation::apply, allow_raw_pointers()) - // .class_function("binarySearch", &Animation::binarySearch) - // .class_function("linearSearch", &Animation::linearSearch) - ; - - // private - // class_("EventQueue") - // .constructor& >() - // .function("start", &EventQueue::start, allow_raw_pointers()) - // .function("interrupt", &EventQueue::interrupt, allow_raw_pointers()) - // .function("end", &EventQueue::end, allow_raw_pointers()) - // .function("dispose", &EventQueue::dispose, allow_raw_pointers()) - // .function("complete", &EventQueue::complete, allow_raw_pointers()) - // .function("event", &EventQueue::event, allow_raw_pointers()) - // .function("drain", &EventQueue::drain) - // //.function("clear") - - // class_("AnimationStateListener") - - // class_("AnimationStateAdapter") + class_("Animation") + .constructor &, float>() + .function("getName", optional_override([](Animation &obj) { return STRING_SP2STD(obj.getName());})) + .function("getTimelines", optional_override([](Animation &obj) { return VECTOR_SP2STD(obj.getTimelines());})) + //.function("getProp_timelineIds", &Animation::getTimelines) + .function("getDuration", &Animation::getDuration) + .function("setDuration", &Animation::setDuration) + .function("hasTimeline", &Animation::hasTimeline) + .function("apply", &Animation::apply, allow_raw_pointers()) + // .class_function("binarySearch", &Animation::binarySearch) + // .class_function("linearSearch", &Animation::linearSearch) + ; + + // private + // class_("EventQueue") + // .constructor& >() + // .function("start", &EventQueue::start, allow_raw_pointers()) + // .function("interrupt", &EventQueue::interrupt, allow_raw_pointers()) + // .function("end", &EventQueue::end, allow_raw_pointers()) + // .function("dispose", &EventQueue::dispose, allow_raw_pointers()) + // .function("complete", &EventQueue::complete, allow_raw_pointers()) + // .function("event", &EventQueue::event, allow_raw_pointers()) + // .function("drain", &EventQueue::drain) + // //.function("clear") + + // class_("AnimationStateListener") + + // class_("AnimationStateAdapter") + class_("Skeleton") .constructor() .function("getData", &Skeleton::getData, allow_raw_pointer()) - .function("getBones", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getBones()); }), allow_raw_pointers()) - .function("getSlots", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getSlots()); }), allow_raw_pointers()) - .function("getDrawOrder", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getDrawOrder()); }), allow_raw_pointers()) - .function("getIkConstraints", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getIkConstraints()); }), allow_raw_pointers()) - .function("getTransformConstraints", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getTransformConstraints()); }), allow_raw_pointers()) - .function("getPathConstraints", optional_override([](Skeleton &obj) { - return VECTOR_SP2STD(obj.getPathConstraints()); }), allow_raw_pointers()) + .function("getBones", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getBones());}), allow_raw_pointers()) + .function("getSlots", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getSlots());}), allow_raw_pointers()) + .function("getDrawOrder", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getDrawOrder());}), allow_raw_pointers()) + .function("getIkConstraints", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getIkConstraints());}), allow_raw_pointers()) + .function("getTransformConstraints", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getTransformConstraints());}), allow_raw_pointers()) + .function("getPathConstraints", optional_override([](Skeleton &obj) { return VECTOR_SP2STD(obj.getPathConstraints());}), allow_raw_pointers()) .function("getUpdateCacheList", &Skeleton::getUpdateCacheList, allow_raw_pointer()) //.function("getProp_updateCacheReset", Skeleton::) .function("getSkin", &Skeleton::getSkin, allow_raw_pointer()) @@ -1060,127 +1060,128 @@ EMSCRIPTEN_BINDINGS(spine) { .function("setBonesToSetupPose", &Skeleton::setBonesToSetupPose) .function("setSlotsToSetupPose", &Skeleton::setSlotsToSetupPose) .function("getRootBone", &Skeleton::getRootBone, allow_raw_pointer()) - .function("findBone", optional_override([](Skeleton &obj, const std::string& name) { - return obj.findBone(STRING_STD2SP(name));}), allow_raw_pointers()) - .function("findBoneIndex", optional_override([](Skeleton &obj, const std::string& name) { - return obj.findBoneIndex(STRING_STD2SP(name));})) - .function("findSlot", optional_override([](Skeleton &obj, const std::string& name) { - return obj.findSlot(STRING_STD2SP(name));}), allow_raw_pointers()) - .function("findSlotIndex", optional_override([](Skeleton &obj, const std::string& name) { - return obj.findSlotIndex(STRING_STD2SP(name));})) - .function("setSkinByName", optional_override([](Skeleton &obj, const std::string& name) { - return obj.setSkin(STRING_STD2SP(name));})) - .function("setSkin", static_cast(&Skeleton::setSkin), allow_raw_pointer()) - .function("getAttachmentByName", optional_override([](Skeleton &obj, std::string slotName, std::string attachmentName) { - .function("getAttachment", optional_override([](Skeleton &obj, int slotIndex, std::string attachmentName) { - .function("setAttachment", optional_override([](Skeleton &obj, std::string slotName, std::string attachmentName) { - .function("findIkConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findIkConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findTransformConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findTransformConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - .function("findPathConstraint", optional_override([](Skeleton &obj, const std::string &name) { return obj.findPathConstraint(STRING_STD2SP(name)); }), allow_raw_pointers()) - //.function("getBounds", &Skeleton::getBounds) - .function("update", &Skeleton::update); - - // incomplete - // class_("SkeletonBinary") - // .constructor() - // .function("setProp_scale", &SkeletonBinary::setScale); - //.function("getProp_scale", &SkeletonBinary::getScale) - //.function("readSkeletonData", &SkeletonBinary::readSkeletonData) - //.function("setCurve", &SkeletonBinary::setCurve); - // incomplete - - // class_("SkeletonJson") - // .constructor() - // .constructor(); - //.function("readSkeletonData", &SkeletonJson::readSkeletonData) - //.function("getProp_scale", &SkeletonJson::getScale) - - class_("VertexEffect") - .function("begin", &VertexEffect::begin, pure_virtual()) - //.function("transform", &VertexEffect::transform, pure_virtual()) - .function("end", &VertexEffect::end, pure_virtual()); - - class_>("JitterEffect") - .constructor() - .function("getJitterX", &JitterVertexEffect::getJitterX) - .function("setJitterX", &JitterVertexEffect::setJitterX) - .function("getJitterY", &JitterVertexEffect::getJitterY) - .function("setJitterY", &JitterVertexEffect::setJitterY) - .function("begin", &JitterVertexEffect::begin) - //.function("transform", &JitterVertexEffect::transform) - .function("end", &JitterVertexEffect::end); - - class_>("SwirlEffect") - .constructor() - .function("getCenterX", &SwirlVertexEffect::getCenterX) - .function("setCenterX", &SwirlVertexEffect::setCenterX) - .function("getCenterY", &SwirlVertexEffect::getCenterY) - .function("setCenterY", &SwirlVertexEffect::setCenterY) - .function("getRadius", &SwirlVertexEffect::getRadius) - .function("setRadius", &SwirlVertexEffect::setRadius) - .function("getAngle", &SwirlVertexEffect::getAngle) - .function("setAngle", &SwirlVertexEffect::setAngle) - .function("begin", &SwirlVertexEffect::begin) - //.function("transform", &SwirlVertexEffect::transform) - .function("end", &SwirlVertexEffect::end); - - class_("SlotMesh") - .property("vCount", &SlotMesh::vCount) - .property("iCount", &SlotMesh::iCount) - .property("blendMode", &SlotMesh::blendMode) - .property("textureID", &SlotMesh::textureID); - - register_vector("VectorSlotMesh"); - class_("SpineModel") - .property("vCount", &SpineModel::vCount) - .property("iCount", &SpineModel::iCount) - .property("vPtr", &SpineModel::vPtr) - .property("iPtr", &SpineModel::iPtr) - .function("getMeshes", &SpineModel::getMeshes); - - class_("SpineDebugShape") - .property("type", &SpineDebugShape::type) - .property("vOffset", &SpineDebugShape::vOffset) - .property("vCount", &SpineDebugShape::vCount) - .property("iOffset", &SpineDebugShape::iOffset) - .property("iCount", &SpineDebugShape::iCount); - - register_vector("VectorDebugShape"); - class_("SkeletonInstance") - .constructor<>() - .function("initSkeleton", &SpineSkeletonInstance::initSkeleton, allow_raw_pointers()) - .function("setAnimation", &SpineSkeletonInstance::setAnimation, allow_raw_pointers()) - .function("setSkin", &SpineSkeletonInstance::setSkin) - .function("updateAnimation", &SpineSkeletonInstance::updateAnimation) - .function("updateRenderData", &SpineSkeletonInstance::updateRenderData, allow_raw_pointer()) - .function("setPremultipliedAlpha", &SpineSkeletonInstance::setPremultipliedAlpha) - .function("setUseTint", &SpineSkeletonInstance::setUseTint) - .function("setColor", &SpineSkeletonInstance::setColor) - .function("setJitterEffect", &SpineSkeletonInstance::setJitterEffect, allow_raw_pointer()) - .function("setSwirlEffect", &SpineSkeletonInstance::setSwirlEffect, allow_raw_pointer()) - .function("clearEffect", &SpineSkeletonInstance::clearEffect) - .function("getAnimationState", &SpineSkeletonInstance::getAnimationState, allow_raw_pointer()) - .function("setMix", &SpineSkeletonInstance::setMix) - .function("setListener", &SpineSkeletonInstance::setListener) - .function("setDebugMode", &SpineSkeletonInstance::setDebugMode) - .function("getDebugShapes", &SpineSkeletonInstance::getDebugShapes) - .function("resizeSlotRegion", &SpineSkeletonInstance::resizeSlotRegion) - .function("setSlotTexture", &SpineSkeletonInstance::setSlotTexture); + .function("findBone", optional_override([](Skeleton &obj, const std::string& name) { return obj.findBone(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findBoneIndex", optional_override([](Skeleton &obj, const std::string& name) { return obj.findBoneIndex(STRING_STD2SP(name));})) + .function("findSlot", optional_override([](Skeleton &obj, const std::string& name) { return obj.findSlot(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findSlotIndex", optional_override([](Skeleton &obj, const std::string& name) { return obj.findSlotIndex(STRING_STD2SP(name));})) + .function("setSkinByName", optional_override([](Skeleton &obj, const std::string& name) { return obj.setSkin(STRING_STD2SP(name));})) + .function("setSkin", static_cast(&Skeleton::setSkin), allow_raw_pointer()) + .function("getAttachmentByName", optional_override([](Skeleton &obj, const std::string& slotName, const std::string& attachmentName) { + return obj.getAttachment(STRING_STD2SP(slotName), STRING_STD2SP(attachmentName));}), allow_raw_pointers()) + .function("getAttachment", optional_override([](Skeleton &obj, int slotIndex, const std::string& attachmentName) { + return obj.getAttachment(slotIndex, STRING_STD2SP(attachmentName));}),allow_raw_pointers()) + .function("setAttachment", optional_override([](Skeleton &obj, const std::string& slotName, const std::string& attachmentName) { + return obj.setAttachment(STRING_STD2SP(slotName), STRING_STD2SP(attachmentName));})) + .function("findIkConstraint", optional_override([](Skeleton &obj, const std::string& name) { return obj.findIkConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findTransformConstraint", optional_override([](Skeleton &obj, const std::string& name) { return obj.findTransformConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + .function("findPathConstraint", optional_override([](Skeleton &obj, const std::string& name) { return obj.findPathConstraint(STRING_STD2SP(name));}), allow_raw_pointers()) + //.function("getBounds", &Skeleton::getBounds) + .function("update", &Skeleton::update); + + // incomplete + // class_("SkeletonBinary") + // .constructor() + // .function("setProp_scale", &SkeletonBinary::setScale); + //.function("getProp_scale", &SkeletonBinary::getScale) + //.function("readSkeletonData", &SkeletonBinary::readSkeletonData) + //.function("setCurve", &SkeletonBinary::setCurve); + // incomplete + + // class_("SkeletonJson") + // .constructor() + // .constructor(); + //.function("readSkeletonData", &SkeletonJson::readSkeletonData) + //.function("getProp_scale", &SkeletonJson::getScale) + + + + class_("VertexEffect") + .function("begin", &VertexEffect::begin, pure_virtual()) + //.function("transform", &VertexEffect::transform, pure_virtual()) + .function("end", &VertexEffect::end, pure_virtual()); + + class_>("JitterEffect") + .constructor() + .function("getJitterX", &JitterVertexEffect::getJitterX) + .function("setJitterX", &JitterVertexEffect::setJitterX) + .function("getJitterY", &JitterVertexEffect::getJitterY) + .function("setJitterY", &JitterVertexEffect::setJitterY) + .function("begin", &JitterVertexEffect::begin) + //.function("transform", &JitterVertexEffect::transform) + .function("end", &JitterVertexEffect::end); + + class_>("SwirlEffect") + .constructor() + .function("getCenterX", &SwirlVertexEffect::getCenterX) + .function("setCenterX", &SwirlVertexEffect::setCenterX) + .function("getCenterY", &SwirlVertexEffect::getCenterY) + .function("setCenterY", &SwirlVertexEffect::setCenterY) + .function("getRadius", &SwirlVertexEffect::getRadius) + .function("setRadius", &SwirlVertexEffect::setRadius) + .function("getAngle", &SwirlVertexEffect::getAngle) + .function("setAngle", &SwirlVertexEffect::setAngle) + .function("begin", &SwirlVertexEffect::begin) + //.function("transform", &SwirlVertexEffect::transform) + .function("end", &SwirlVertexEffect::end); + + class_("SlotMesh") + .property("vCount", &SlotMesh::vCount) + .property("iCount", &SlotMesh::iCount) + .property("blendMode", &SlotMesh::blendMode) + .property("textureID", &SlotMesh::textureID) + ; + + register_vector("VectorSlotMesh"); + class_("SpineModel") + .property("vCount", &SpineModel::vCount) + .property("iCount", &SpineModel::iCount) + .property("vPtr", &SpineModel::vPtr) + .property("iPtr", &SpineModel::iPtr) + .function("getMeshes", &SpineModel::getMeshes); + + class_("SpineDebugShape") + .property("type", &SpineDebugShape::type) + .property("vOffset", &SpineDebugShape::vOffset) + .property("vCount", &SpineDebugShape::vCount) + .property("iOffset", &SpineDebugShape::iOffset) + .property("iCount", &SpineDebugShape::iCount); + + register_vector("VectorDebugShape"); + class_("SkeletonInstance") + .constructor<>() + .function("initSkeleton", &SpineSkeletonInstance::initSkeleton, allow_raw_pointers()) + .function("setAnimation", &SpineSkeletonInstance::setAnimation, allow_raw_pointers()) + .function("setSkin", &SpineSkeletonInstance::setSkin) + .function("updateAnimation", &SpineSkeletonInstance::updateAnimation) + .function("updateRenderData", &SpineSkeletonInstance::updateRenderData, allow_raw_pointer()) + .function("setPremultipliedAlpha", &SpineSkeletonInstance::setPremultipliedAlpha) + .function("setUseTint", &SpineSkeletonInstance::setUseTint) + .function("setColor", &SpineSkeletonInstance::setColor) + .function("setJitterEffect", &SpineSkeletonInstance::setJitterEffect, allow_raw_pointer()) + .function("setSwirlEffect", &SpineSkeletonInstance::setSwirlEffect, allow_raw_pointer()) + .function("clearEffect", &SpineSkeletonInstance::clearEffect) + .function("getAnimationState", &SpineSkeletonInstance::getAnimationState, allow_raw_pointer()) + .function("setMix", &SpineSkeletonInstance::setMix) + .function("setListener", &SpineSkeletonInstance::setListener) + .function("setDebugMode", &SpineSkeletonInstance::setDebugMode) + .function("getDebugShapes", &SpineSkeletonInstance::getDebugShapes) + .function("resizeSlotRegion", &SpineSkeletonInstance::resizeSlotRegion) + .function("setSlotTexture", &SpineSkeletonInstance::setSlotTexture); } EMSCRIPTEN_BINDINGS(cocos_spine) { - class_("SpineWasmUtil") - .class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit) - .class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy) - .class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory) - .class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers()) - .class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers()) - .class_function("createSpineSkeletonDataWithBinary", &SpineWasmUtil::createSpineSkeletonDataWithBinary, allow_raw_pointers()) - .class_function("registerSpineSkeletonDataWithUUID", &SpineWasmUtil::registerSpineSkeletonDataWithUUID, allow_raw_pointers()) - .class_function("destroySpineSkeletonDataWithUUID", &SpineWasmUtil::destroySpineSkeletonDataWithUUID) - .class_function("destroySpineInstance", &SpineWasmUtil::destroySpineInstance, allow_raw_pointers()) - .class_function("getCurrentListenerID", &SpineWasmUtil::getCurrentListenerID) - .class_function("getCurrentEventType", &SpineWasmUtil::getCurrentEventType) - .class_function("getCurrentTrackEntry", &SpineWasmUtil::getCurrentTrackEntry, allow_raw_pointers()) - .class_function("getCurrentEvent", &SpineWasmUtil::getCurrentEvent, allow_raw_pointers()); + class_("SpineWasmUtil") + .class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit) + .class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy) + .class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory) + .class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers()) + .class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers()) + .class_function("createSpineSkeletonDataWithBinary", &SpineWasmUtil::createSpineSkeletonDataWithBinary, allow_raw_pointers()) + .class_function("registerSpineSkeletonDataWithUUID", &SpineWasmUtil::registerSpineSkeletonDataWithUUID, allow_raw_pointers()) + .class_function("destroySpineSkeletonDataWithUUID", &SpineWasmUtil::destroySpineSkeletonDataWithUUID) + .class_function("destroySpineInstance", &SpineWasmUtil::destroySpineInstance, allow_raw_pointers()) + .class_function("getCurrentListenerID", &SpineWasmUtil::getCurrentListenerID) + .class_function("getCurrentEventType", &SpineWasmUtil::getCurrentEventType) + .class_function("getCurrentTrackEntry", &SpineWasmUtil::getCurrentTrackEntry, allow_raw_pointers()) + .class_function("getCurrentEvent", &SpineWasmUtil::getCurrentEvent, allow_raw_pointers()); }