Browse Source

[cpp] Fix inconsistens getters/setters wrt nullability

Mario Zechner 1 tháng trước cách đây
mục cha
commit
a0bcb01a2a

+ 2 - 2
spine-c/src/generated/mesh_attachment.cpp

@@ -88,9 +88,9 @@ void spine_mesh_attachment_set_path(spine_mesh_attachment self, const char *inVa
 	return (spine_texture_region) _self->getRegion();
 }
 
-void spine_mesh_attachment_set_region(spine_mesh_attachment self, spine_texture_region region) {
+void spine_mesh_attachment_set_region(spine_mesh_attachment self, /*@null*/ spine_texture_region region) {
 	MeshAttachment *_self = (MeshAttachment *) self;
-	_self->setRegion(*((TextureRegion *) region));
+	_self->setRegion((TextureRegion *) region);
 }
 
 /*@null*/ spine_sequence spine_mesh_attachment_get_sequence(spine_mesh_attachment self) {

+ 1 - 1
spine-c/src/generated/mesh_attachment.h

@@ -30,7 +30,7 @@ SPINE_C_API spine_color spine_mesh_attachment_get_color(spine_mesh_attachment se
 SPINE_C_API const char *spine_mesh_attachment_get_path(spine_mesh_attachment self);
 SPINE_C_API void spine_mesh_attachment_set_path(spine_mesh_attachment self, const char *inValue);
 SPINE_C_API /*@null*/ spine_texture_region spine_mesh_attachment_get_region(spine_mesh_attachment self);
-SPINE_C_API void spine_mesh_attachment_set_region(spine_mesh_attachment self, spine_texture_region region);
+SPINE_C_API void spine_mesh_attachment_set_region(spine_mesh_attachment self, /*@null*/ spine_texture_region region);
 SPINE_C_API /*@null*/ spine_sequence spine_mesh_attachment_get_sequence(spine_mesh_attachment self);
 SPINE_C_API void spine_mesh_attachment_set_sequence(spine_mesh_attachment self, /*@null*/ spine_sequence sequence);
 SPINE_C_API /*@null*/ spine_mesh_attachment spine_mesh_attachment_get_parent_mesh(spine_mesh_attachment self);

+ 2 - 2
spine-c/src/generated/region_attachment.cpp

@@ -123,9 +123,9 @@ void spine_region_attachment_set_path(spine_region_attachment self, const char *
 	return (spine_texture_region) _self->getRegion();
 }
 
-void spine_region_attachment_set_region(spine_region_attachment self, spine_texture_region region) {
+void spine_region_attachment_set_region(spine_region_attachment self, /*@null*/ spine_texture_region region) {
 	RegionAttachment *_self = (RegionAttachment *) self;
-	_self->setRegion(*((TextureRegion *) region));
+	_self->setRegion((TextureRegion *) region);
 }
 
 /*@null*/ spine_sequence spine_region_attachment_get_sequence(spine_region_attachment self) {

+ 1 - 1
spine-c/src/generated/region_attachment.h

@@ -37,7 +37,7 @@ SPINE_C_API spine_color spine_region_attachment_get_color(spine_region_attachmen
 SPINE_C_API const char *spine_region_attachment_get_path(spine_region_attachment self);
 SPINE_C_API void spine_region_attachment_set_path(spine_region_attachment self, const char *inValue);
 SPINE_C_API /*@null*/ spine_texture_region spine_region_attachment_get_region(spine_region_attachment self);
-SPINE_C_API void spine_region_attachment_set_region(spine_region_attachment self, spine_texture_region region);
+SPINE_C_API void spine_region_attachment_set_region(spine_region_attachment self, /*@null*/ spine_texture_region region);
 SPINE_C_API /*@null*/ spine_sequence spine_region_attachment_get_sequence(spine_region_attachment self);
 SPINE_C_API void spine_region_attachment_set_sequence(spine_region_attachment self, /*@null*/ spine_sequence sequence);
 SPINE_C_API spine_array_float spine_region_attachment_get_offset(spine_region_attachment self);

+ 1 - 1
spine-cpp/include/spine/MeshAttachment.h

@@ -83,7 +83,7 @@ namespace spine {
 
 		TextureRegion *getRegion();
 
-		void setRegion(TextureRegion &region);
+		void setRegion(TextureRegion *region);
 
 		Sequence *getSequence();
 

+ 1 - 1
spine-cpp/include/spine/RegionAttachment.h

@@ -104,7 +104,7 @@ namespace spine {
 
 		TextureRegion *getRegion();
 
-		void setRegion(TextureRegion &region);
+		void setRegion(TextureRegion *region);
 
 		Sequence *getSequence();
 

+ 2 - 2
spine-cpp/src/spine/AtlasAttachmentLoader.cpp

@@ -61,7 +61,7 @@ RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const S
 	} else {
 		AtlasRegion *region = findRegion(path);
 		if (!region) return NULL;
-		attachment->setRegion(*region);
+		attachment->setRegion(region);
 	}
 	return attachment;
 }
@@ -75,7 +75,7 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin
 	} else {
 		AtlasRegion *region = findRegion(path);
 		if (!region) return NULL;
-		attachment->setRegion(*region);
+		attachment->setRegion(region);
 	}
 	return attachment;
 }

+ 4 - 4
spine-cpp/src/spine/MeshAttachment.cpp

@@ -157,8 +157,8 @@ TextureRegion *MeshAttachment::getRegion() {
 	return _region;
 }
 
-void MeshAttachment::setRegion(TextureRegion &region) {
-	_region = &region;
+void MeshAttachment::setRegion(TextureRegion *region) {
+	_region = region;
 }
 
 Sequence *MeshAttachment::getSequence() {
@@ -220,7 +220,7 @@ Attachment &MeshAttachment::copy() {
 	if (_parentMesh) return newLinkedMesh();
 
 	MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
-	copy->setRegion(*_region);
+	copy->setRegion(_region);
 	copy->setSequence(_sequence != NULL ? &_sequence->copy() : NULL);
 	copy->_path = _path;
 	copy->_color.set(_color);
@@ -240,7 +240,7 @@ Attachment &MeshAttachment::copy() {
 
 MeshAttachment &MeshAttachment::newLinkedMesh() {
 	MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
-	copy->setRegion(*_region);
+	copy->setRegion(_region);
 	copy->_path = _path;
 	copy->_color.set(_color);
 	copy->_timelineAttachment = this->_timelineAttachment;

+ 2 - 2
spine-cpp/src/spine/RegionAttachment.cpp

@@ -242,8 +242,8 @@ TextureRegion *RegionAttachment::getRegion() {
 	return _region;
 }
 
-void RegionAttachment::setRegion(TextureRegion &region) {
-	_region = &region;
+void RegionAttachment::setRegion(TextureRegion *region) {
+	_region = region;
 }
 
 Sequence *RegionAttachment::getSequence() {

+ 2 - 2
spine-cpp/src/spine/Sequence.cpp

@@ -65,7 +65,7 @@ void Sequence::apply(SlotPose *slot, Attachment *attachment) {
 	if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
 		RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
 		if (regionAttachment->getRegion() != region) {
-			regionAttachment->setRegion(*region);
+			regionAttachment->setRegion(region);
 			regionAttachment->updateRegion();
 		}
 	}
@@ -73,7 +73,7 @@ void Sequence::apply(SlotPose *slot, Attachment *attachment) {
 	if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
 		MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment);
 		if (meshAttachment->getRegion() != region) {
-			meshAttachment->setRegion(*region);
+			meshAttachment->setRegion(region);
 			meshAttachment->updateRegion();
 		}
 	}