From fae952d73c680045a1d16eabc51e806092c43b46 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Mon, 16 Mar 2015 19:56:51 +0100 Subject: [PATCH] Docs, accept empty string for std::string refs that can be null in the C API. --- spine-c/include/spine/Skeleton.h | 3 ++- spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp | 4 ++-- spine-cocos2dx/3/src/spine/SkeletonRenderer.h | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spine-c/include/spine/Skeleton.h b/spine-c/include/spine/Skeleton.h index 6e0951878..d46cda7d2 100644 --- a/spine-c/include/spine/Skeleton.h +++ b/spine-c/include/spine/Skeleton.h @@ -117,7 +117,8 @@ int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName); spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName); /* Returns 0 if the slot or attachment was not found. */ spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName); -/* Returns 0 if the slot or attachment was not found. */ +/* Returns 0 if the slot or attachment was not found. + * @param attachmentName May be 0. */ int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName); /* Returns 0 if the IK constraint was not found. */ diff --git a/spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp b/spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp index b1d4b6c3b..07c7b3144 100644 --- a/spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp +++ b/spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp @@ -346,14 +346,14 @@ spSlot* SkeletonRenderer::findSlot (const std::string& slotName) const { } bool SkeletonRenderer::setSkin (const std::string& skinName) { - return spSkeleton_setSkinByName(_skeleton, skinName.c_str()) ? true : false; + return spSkeleton_setSkinByName(_skeleton, skinName.empty() ? 0 : skinName.c_str()) ? true : false; } spAttachment* SkeletonRenderer::getAttachment (const std::string& slotName, const std::string& attachmentName) const { return spSkeleton_getAttachmentForSlotName(_skeleton, slotName.c_str(), attachmentName.c_str()); } bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) { - return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.c_str()) ? true : false; + return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.empty() ? 0 : attachmentName.c_str()) ? true : false; } spSkeleton* SkeletonRenderer::getSkeleton () { diff --git a/spine-cocos2dx/3/src/spine/SkeletonRenderer.h b/spine-cocos2dx/3/src/spine/SkeletonRenderer.h index 6cabc4ca9..9a7696817 100644 --- a/spine-cocos2dx/3/src/spine/SkeletonRenderer.h +++ b/spine-cocos2dx/3/src/spine/SkeletonRenderer.h @@ -77,12 +77,13 @@ public: /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are * attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found. - * @param skin May be 0.*/ + * @param skin May be empty string ("") for no skin.*/ bool setSkin (const std::string& skinName); /* Returns 0 if the slot or attachment was not found. */ spAttachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const; - /* Returns false if the slot or attachment was not found. */ + /* Returns false if the slot or attachment was not found. + * @param attachmentName May be empty string ("") for no attachment. */ bool setAttachment (const std::string& slotName, const std::string& attachmentName); // --- BlendProtocol