Browse Source

[cpp] Constructor nullability.

Mario Zechner 1 month ago
parent
commit
854b6f9a2a

+ 167 - 0
spine-c/codegen/last-nullable.md

@@ -2852,6 +2852,173 @@ For each unchecked checkbox (now with implementations inlined):
   84:	public void setAttachment (@Null Attachment attachment) {
   85-		if (this.attachment == attachment) return;
   86-		if (!(attachment instanceof VertexAttachment newAttachment) || !(this.attachment instanceof VertexAttachment oldAttachment)
+  87-			|| newAttachment.getTimelineAttachment() != oldAttachment.getTimelineAttachment()) deform.clear();
+  88-		this.attachment = attachment;
+  89-		sequenceIndex = -1;
+  90-	}
+  91-
+  92-	public IntArray getDeform () {
+  93-		return deform;
+  94-	}
+  ```
+- [x] [../../spine-cpp/include/spine/RTTI.h:43](../../spine-cpp/include/spine/RTTI.h#L43) RTTI::RTTI(const char * className, const RTTI & baseRTTI, const RTTI * interface1, const RTTI * interface2, const RTTI * interface3) // takes nullable parameter 'interface1': const RTTI *; takes nullable parameter 'interface2': const RTTI *; takes nullable parameter 'interface3': const RTTI *
+  ```cpp
+  ../../spine-cpp/src/spine/RTTI.cpp:35
+  35:RTTI::RTTI(const char *className) : _className(className), _pBaseRTTI(NULL), _interfaceCount(0) {
+  36-	_interfaces[0] = NULL;
+  37-	_interfaces[1] = NULL;
+  38-	_interfaces[2] = NULL;
+  39-}
+  40-
+  41:RTTI::RTTI(const char *className, const RTTI &baseRTTI) : _className(className), _pBaseRTTI(&baseRTTI), _interfaceCount(0) {
+  42-	_interfaces[0] = NULL;
+  43-	_interfaces[1] = NULL;
+  44-	_interfaces[2] = NULL;
+  ```
+  ```java
+  NOT FOUND - searched for class "RTTI" (from C++ "RTTI") and method "RTTI" across all Java files
+  ```
+- [x] [../../spine-cpp/include/spine/SequenceTimeline.h:50](../../spine-cpp/include/spine/SequenceTimeline.h#L50) SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment * attachment) // takes nullable parameter 'attachment': Attachment *
+  ```cpp
+  ../../spine-cpp/src/spine/SequenceTimeline.cpp:46
+  46:SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment)
+  47-	: Timeline(frameCount, ENTRIES), SlotTimeline(), _slotIndex(slotIndex), _attachment((HasTextureRegion *) attachment) {
+  48-	int sequenceId = 0;
+  49-	if (attachment->getRTTI().instanceOf(RegionAttachment::rtti)) sequenceId = ((RegionAttachment *) attachment)->getSequence()->getId();
+  50-	if (attachment->getRTTI().instanceOf(MeshAttachment::rtti)) sequenceId = ((MeshAttachment *) attachment)->getSequence()->getId();
+  51-	PropertyId ids[] = {((PropertyId) Property_Sequence << 32) | ((slotIndex << 16 | sequenceId) & 0xffffffff)};
+  52-	setPropertyIds(ids, 1);
+  53-}
+  54-
+  55-SequenceTimeline::~SequenceTimeline() {
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java:1705
+  1705:		public SequenceTimeline (int frameCount, int slotIndex, Attachment attachment) {
+  1706-			super(frameCount,
+  1707-				Property.sequence.ordinal() + "|" + slotIndex + "|" + ((HasTextureRegion)attachment).getSequence().getId());
+  1708-			this.slotIndex = slotIndex;
+  1709-			this.attachment = (HasTextureRegion)attachment;
+  1710-		}
+  1711-
+  1712-		public int getFrameEntries () {
+  1713-			return ENTRIES;
+  1714-		}
+  ```
+- [x] [../../spine-cpp/include/spine/SkeletonBinary.h:118](../../spine-cpp/include/spine/SkeletonBinary.h#L118) SkeletonBinary::SkeletonBinary(Atlas * atlas) // takes nullable parameter 'atlas': Atlas *
+  ```cpp
+  ../../spine-cpp/src/spine/SkeletonBinary.cpp:82
+  82:SkeletonBinary::SkeletonBinary(Atlas *atlas)
+  83-	: _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _error(), _scale(1), _ownsLoader(true) {
+  84-}
+  85-
+  86:SkeletonBinary::SkeletonBinary(AttachmentLoader *attachmentLoader, bool ownsLoader)
+  87-	: _attachmentLoader(attachmentLoader), _error(), _scale(1), _ownsLoader(ownsLoader) {
+  88-	assert(_attachmentLoader != NULL);
+  89-}
+  90-
+  91-SkeletonBinary::~SkeletonBinary() {
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java:173
+  173:	public SkeletonBinary (AttachmentLoader attachmentLoader) {
+  174-		super(attachmentLoader);
+  175-	}
+  176-
+  177:	public SkeletonBinary (TextureAtlas atlas) {
+  178-		super(atlas);
+  179-	}
+  180-
+  181-	public SkeletonData readSkeletonData (FileHandle file) {
+  182-		if (file == null) throw new IllegalArgumentException("file cannot be null.");
+  ```
+- [x] [../../spine-cpp/include/spine/SkeletonBinary.h:120](../../spine-cpp/include/spine/SkeletonBinary.h#L120) SkeletonBinary::SkeletonBinary(AttachmentLoader * attachmentLoader, bool ownsLoader) // takes nullable parameter 'attachmentLoader': AttachmentLoader *
+  ```cpp
+  ../../spine-cpp/src/spine/SkeletonBinary.cpp:82
+  82:SkeletonBinary::SkeletonBinary(Atlas *atlas)
+  83-	: _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _error(), _scale(1), _ownsLoader(true) {
+  84-}
+  85-
+  86:SkeletonBinary::SkeletonBinary(AttachmentLoader *attachmentLoader, bool ownsLoader)
+  87-	: _attachmentLoader(attachmentLoader), _error(), _scale(1), _ownsLoader(ownsLoader) {
+  88-	assert(_attachmentLoader != NULL);
+  89-}
+  90-
+  91-SkeletonBinary::~SkeletonBinary() {
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java:173
+  173:	public SkeletonBinary (AttachmentLoader attachmentLoader) {
+  174-		super(attachmentLoader);
+  175-	}
+  176-
+  177:	public SkeletonBinary (TextureAtlas atlas) {
+  178-		super(atlas);
+  179-	}
+  180-
+  181-	public SkeletonData readSkeletonData (FileHandle file) {
+  182-		if (file == null) throw new IllegalArgumentException("file cannot be null.");
+  ```
+- [x] [../../spine-cpp/include/spine/SkeletonJson.h:70](../../spine-cpp/include/spine/SkeletonJson.h#L70) SkeletonJson::SkeletonJson(Atlas * atlas) // takes nullable parameter 'atlas': Atlas *
+  ```cpp
+  ../../spine-cpp/src/spine/SkeletonJson.cpp:124
+  124:SkeletonJson::SkeletonJson(Atlas *atlas) : _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
+  125-}
+  126-
+  127:SkeletonJson::SkeletonJson(AttachmentLoader *attachmentLoader, bool ownsLoader)
+  128-	: _attachmentLoader(attachmentLoader), _scale(1), _ownsLoader(ownsLoader) {
+  129-	assert(_attachmentLoader != NULL);
+  130-}
+  131-
+  132-SkeletonJson::~SkeletonJson() {
+  133-	ArrayUtils::deleteElements(_linkedMeshes);
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java:128
+  128:	public SkeletonJson (AttachmentLoader attachmentLoader) {
+  129-		super(attachmentLoader);
+  130-	}
+  131-
+  132:	public SkeletonJson (TextureAtlas atlas) {
+  133-		super(atlas);
+  134-	}
+  135-
+  136-	public SkeletonData readSkeletonData (FileHandle file) {
+  137-		if (file == null) throw new IllegalArgumentException("file cannot be null.");
+  ```
+- [x] [../../spine-cpp/include/spine/SkeletonJson.h:72](../../spine-cpp/include/spine/SkeletonJson.h#L72) SkeletonJson::SkeletonJson(AttachmentLoader * attachmentLoader, bool ownsLoader) // takes nullable parameter 'attachmentLoader': AttachmentLoader *
+  ```cpp
+  ../../spine-cpp/src/spine/SkeletonJson.cpp:124
+  124:SkeletonJson::SkeletonJson(Atlas *atlas) : _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
+  125-}
+  126-
+  127:SkeletonJson::SkeletonJson(AttachmentLoader *attachmentLoader, bool ownsLoader)
+  128-	: _attachmentLoader(attachmentLoader), _scale(1), _ownsLoader(ownsLoader) {
+  129-	assert(_attachmentLoader != NULL);
+  130-}
+  131-
+  132-SkeletonJson::~SkeletonJson() {
+  133-	ArrayUtils::deleteElements(_linkedMeshes);
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java:128
+  128:	public SkeletonJson (AttachmentLoader attachmentLoader) {
+  129-		super(attachmentLoader);
+  130-	}
+  131-
+  132:	public SkeletonJson (TextureAtlas atlas) {
+  133-		super(atlas);
+  134-	}
+  135-
+  136-	public SkeletonData readSkeletonData (FileHandle file) {
+  137-		if (file == null) throw new IllegalArgumentException("file cannot be null.");
+  ```
+  ```
+  ```java
+  ../../spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SlotPose.java:84
+  84:	public void setAttachment (@Null Attachment attachment) {
+  85-		if (this.attachment == attachment) return;
+  86-		if (!(attachment instanceof VertexAttachment newAttachment) || !(this.attachment instanceof VertexAttachment oldAttachment)
   87-			|| newAttachment.getTimelineAttachment() != oldAttachment.getTimelineAttachment()) {
   88-			deform.clear();
   89-		}

+ 3 - 3
spine-cpp/include/spine/AnimationState.h

@@ -398,7 +398,7 @@ namespace spine {
 		friend class EventQueue;
 
 	public:
-		explicit AnimationState(AnimationStateData *data);
+		explicit AnimationState(AnimationStateData &data);
 
 		~AnimationState();
 
@@ -437,7 +437,7 @@ namespace spine {
 		/// @return
 		/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
 		/// after AnimationState.Dispose.
-		TrackEntry &setAnimation(size_t trackIndex, Animation *animation, bool loop);
+		TrackEntry &setAnimation(size_t trackIndex, Animation &animation, bool loop);
 
 		/// Queues an animation by name.
 		///
@@ -452,7 +452,7 @@ namespace spine {
 		///
 		/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
 		/// after AnimationState.Dispose
-		TrackEntry &addAnimation(size_t trackIndex, Animation *animation, bool loop, float delay);
+		TrackEntry &addAnimation(size_t trackIndex, Animation &animation, bool loop, float delay);
 
 		/// Sets an empty animation for a track, discarding any queued animations, and sets the track entry's
 		/// TrackEntry::getMixDuration(). An empty animation has no timelines and serves as a placeholder for mixing in or out.

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

@@ -46,7 +46,7 @@ namespace spine {
 		friend class AnimationState;
 
 	public:
-		explicit AnimationStateData(SkeletonData *skeletonData);
+		explicit AnimationStateData(SkeletonData &skeletonData);
 
 		/// The SkeletonData to look up animations when they are specified by name.
 		SkeletonData &getSkeletonData();

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

@@ -46,7 +46,7 @@ namespace spine {
 	/// Spine Runtimes Guide.
 	class SP_API AtlasAttachmentLoader : public AttachmentLoader {
 	public:
-		explicit AtlasAttachmentLoader(Atlas *atlas);
+		explicit AtlasAttachmentLoader(Atlas &atlas);
 
 		virtual RegionAttachment *newRegionAttachment(Skin &skin, const String &name, const String &path, Sequence *sequence);
 

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

@@ -44,7 +44,7 @@ namespace spine {
 		RTTI_DECL
 
 	public:
-		explicit DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment *attachment);
+		explicit DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment &attachment);
 
 		/// Sets the time and vertices for the specified frame.
 		void setFrame(int frameIndex, float time, Array<float> &vertices);

+ 2 - 2
spine-cpp/include/spine/LinkedMesh.h

@@ -42,9 +42,9 @@ namespace spine {
 		friend class SkeletonJson;
 
 	public:
-		LinkedMesh(MeshAttachment *mesh, const int skinIndex, size_t slotIndex, const String &parent, bool inheritTimelines);
+		LinkedMesh(MeshAttachment &mesh, const int skinIndex, size_t slotIndex, const String &parent, bool inheritTimelines);
 
-		LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritTimelines);
+		LinkedMesh(MeshAttachment &mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritTimelines);
 
 	private:
 		MeshAttachment *_mesh;

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

@@ -47,7 +47,7 @@ namespace spine {
 		RTTI_DECL
 
 	public:
-		explicit SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment);
+		explicit SequenceTimeline(size_t frameCount, int slotIndex, Attachment &attachment);
 
 		virtual ~SequenceTimeline();
 

+ 2 - 2
spine-cpp/include/spine/SkeletonBinary.h

@@ -115,9 +115,9 @@ namespace spine {
 		static const int CURVE_STEPPED = 1;
 		static const int CURVE_BEZIER = 2;
 
-		explicit SkeletonBinary(Atlas *atlas);
+		explicit SkeletonBinary(Atlas &atlas);
 
-		explicit SkeletonBinary(AttachmentLoader *attachmentLoader, bool ownsLoader = false);
+		explicit SkeletonBinary(AttachmentLoader &attachmentLoader, bool ownsLoader = false);
 
 		~SkeletonBinary();
 

+ 2 - 2
spine-cpp/include/spine/SkeletonJson.h

@@ -67,9 +67,9 @@ namespace spine {
 
 	class SP_API SkeletonJson : public SpineObject {
 	public:
-		explicit SkeletonJson(Atlas *atlas);
+		explicit SkeletonJson(Atlas &atlas);
 
-		explicit SkeletonJson(AttachmentLoader *attachmentLoader, bool ownsLoader = false);
+		explicit SkeletonJson(AttachmentLoader &attachmentLoader, bool ownsLoader = false);
 
 		~SkeletonJson();
 

+ 1 - 1
spine-cpp/spine-cpp-lite/spine-cpp-lite.cpp

@@ -610,7 +610,7 @@ spine_skeleton_drawable spine_skeleton_drawable_create(spine_skeleton_data skele
 	drawable->skeleton = (spine_skeleton) new (__FILE__, __LINE__) Skeleton((SkeletonData *) skeletonData);
 	AnimationStateData *stateData = new (__FILE__, __LINE__) AnimationStateData((SkeletonData *) skeletonData);
 	drawable->animationStateData = (spine_animation_state_data) stateData;
-	AnimationState *state = new (__FILE__, __LINE__) AnimationState(stateData);
+	AnimationState *state = new (__FILE__, __LINE__) AnimationState(*stateData);
 	drawable->animationState = (spine_animation_state) state;
 	state->setManualTrackEntryDisposal(true);
 	EventListener *listener = new EventListener();

+ 11 - 15
spine-cpp/src/spine/AnimationState.cpp

@@ -431,8 +431,8 @@ void EventQueue::drain() {
 	_drainDisabled = false;
 }
 
-AnimationState::AnimationState(AnimationStateData *data)
-	: _data(data), _queue(EventQueue::newEventQueue(*this)), _animationsChanged(false), _listener(dummyOnAnimationEventFunc), _listenerObject(NULL),
+AnimationState::AnimationState(AnimationStateData &data)
+	: _data(&data), _queue(EventQueue::newEventQueue(*this)), _animationsChanged(false), _listener(dummyOnAnimationEventFunc), _listenerObject(NULL),
 	  _unkeyedState(0), _timeScale(1), _manualTrackEntryDisposal(false) {
 }
 
@@ -652,16 +652,14 @@ void AnimationState::clearTrack(size_t trackIndex) {
 TrackEntry &AnimationState::setAnimation(size_t trackIndex, const String &animationName, bool loop) {
 	Animation *animation = _data->_skeletonData->findAnimation(animationName);
 	assert(animation != NULL);
-	return setAnimation(trackIndex, animation, loop);
+	return setAnimation(trackIndex, *animation, loop);
 }
 
-TrackEntry &AnimationState::setAnimation(size_t trackIndex, Animation *animation, bool loop) {
-	assert(animation != NULL);
-
+TrackEntry &AnimationState::setAnimation(size_t trackIndex, Animation &animation, bool loop) {
 	bool interrupt = true;
 	TrackEntry *current = expandToIndex(trackIndex);
 	if (current != NULL) {
-		if (current->_nextTrackLast == -1 && current->_animation == animation) {
+		if (current->_nextTrackLast == -1 && current->_animation == &animation) {
 			// Don't mix from an entry that was never applied.
 			_tracks[trackIndex] = current->_mixingFrom;
 			_queue->interrupt(current);
@@ -674,7 +672,7 @@ TrackEntry &AnimationState::setAnimation(size_t trackIndex, Animation *animation
 		}
 	}
 
-	TrackEntry *entry = newTrackEntry(trackIndex, animation, loop, current);
+	TrackEntry *entry = newTrackEntry(trackIndex, &animation, loop, current);
 	setCurrent(trackIndex, entry, interrupt);
 	_queue->drain();
 
@@ -684,18 +682,16 @@ TrackEntry &AnimationState::setAnimation(size_t trackIndex, Animation *animation
 TrackEntry &AnimationState::addAnimation(size_t trackIndex, const String &animationName, bool loop, float delay) {
 	Animation *animation = _data->_skeletonData->findAnimation(animationName);
 	assert(animation != NULL);
-	return addAnimation(trackIndex, animation, loop, delay);
+	return addAnimation(trackIndex, *animation, loop, delay);
 }
 
-TrackEntry &AnimationState::addAnimation(size_t trackIndex, Animation *animation, bool loop, float delay) {
-	assert(animation != NULL);
-
+TrackEntry &AnimationState::addAnimation(size_t trackIndex, Animation &animation, bool loop, float delay) {
 	TrackEntry *last = expandToIndex(trackIndex);
 	if (last != NULL) {
 		while (last->_next != NULL) last = last->_next;
 	}
 
-	TrackEntry *entry = newTrackEntry(trackIndex, animation, loop, last);
+	TrackEntry *entry = newTrackEntry(trackIndex, &animation, loop, last);
 
 	if (last == NULL) {
 		setCurrent(trackIndex, entry, true);
@@ -712,14 +708,14 @@ TrackEntry &AnimationState::addAnimation(size_t trackIndex, Animation *animation
 }
 
 TrackEntry &AnimationState::setEmptyAnimation(size_t trackIndex, float mixDuration) {
-	TrackEntry &entry = setAnimation(trackIndex, AnimationState::getEmptyAnimation(), false);
+	TrackEntry &entry = setAnimation(trackIndex, *AnimationState::getEmptyAnimation(), false);
 	entry._mixDuration = mixDuration;
 	entry._trackEnd = mixDuration;
 	return entry;
 }
 
 TrackEntry &AnimationState::addEmptyAnimation(size_t trackIndex, float mixDuration, float delay) {
-	TrackEntry &entry = addAnimation(trackIndex, AnimationState::getEmptyAnimation(), false, delay);
+	TrackEntry &entry = addAnimation(trackIndex, *AnimationState::getEmptyAnimation(), false, delay);
 	if (delay <= 0) entry._delay = MathUtil::max(entry._delay + entry._mixDuration - mixDuration, 0.0f);
 	entry._mixDuration = mixDuration;
 	entry._trackEnd = mixDuration;

+ 1 - 1
spine-cpp/src/spine/AnimationStateData.cpp

@@ -33,7 +33,7 @@
 
 using namespace spine;
 
-AnimationStateData::AnimationStateData(SkeletonData *skeletonData) : _skeletonData(skeletonData), _defaultMix(0) {
+AnimationStateData::AnimationStateData(SkeletonData &skeletonData) : _skeletonData(&skeletonData), _defaultMix(0) {
 }
 
 void AnimationStateData::setMix(const String &fromName, const String &toName, float duration) {

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

@@ -40,7 +40,7 @@
 
 using namespace spine;
 
-AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
+AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas &atlas) : AttachmentLoader(), _atlas(&atlas) {
 }
 
 bool loadSequence(Atlas *atlas, const String &basePath, Sequence *sequence) {

+ 3 - 3
spine-cpp/src/spine/DeformTimeline.cpp

@@ -43,9 +43,9 @@ using namespace spine;
 
 RTTI_IMPL(DeformTimeline, CurveTimeline)
 
-DeformTimeline::DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment *attachment)
-	: SlotCurveTimeline(frameCount, 1, bezierCount, slotIndex), _attachment(attachment) {
-	PropertyId ids[] = {((PropertyId) Property_Deform << 32) | ((slotIndex << 16 | attachment->_id) & 0xffffffff)};
+DeformTimeline::DeformTimeline(size_t frameCount, size_t bezierCount, int slotIndex, VertexAttachment &attachment)
+	: SlotCurveTimeline(frameCount, 1, bezierCount, slotIndex), _attachment(&attachment) {
+	PropertyId ids[] = {((PropertyId) Property_Deform << 32) | ((slotIndex << 16 | attachment._id) & 0xffffffff)};
 	setPropertyIds(ids, 1);
 
 	_vertices.ensureCapacity(frameCount);

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

@@ -33,10 +33,10 @@
 
 using namespace spine;
 
-LinkedMesh::LinkedMesh(MeshAttachment *mesh, const int skinIndex, size_t slotIndex, const String &parent, bool inheritTimelines)
-	: _mesh(mesh), _skinIndex(skinIndex), _skin(""), _slotIndex(slotIndex), _parent(parent), _inheritTimelines(inheritTimelines) {
+LinkedMesh::LinkedMesh(MeshAttachment &mesh, const int skinIndex, size_t slotIndex, const String &parent, bool inheritTimelines)
+	: _mesh(&mesh), _skinIndex(skinIndex), _skin(""), _slotIndex(slotIndex), _parent(parent), _inheritTimelines(inheritTimelines) {
 }
 
-LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritTimelines)
-	: _mesh(mesh), _skinIndex(-1), _skin(skin), _slotIndex(slotIndex), _parent(parent), _inheritTimelines(inheritTimelines) {
+LinkedMesh::LinkedMesh(MeshAttachment &mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritTimelines)
+	: _mesh(&mesh), _skinIndex(-1), _skin(skin), _slotIndex(slotIndex), _parent(parent), _inheritTimelines(inheritTimelines) {
 }

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

@@ -43,11 +43,11 @@ using namespace spine;
 
 RTTI_IMPL_MULTI(SequenceTimeline, Timeline, SlotTimeline)
 
-SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment *attachment)
-	: Timeline(frameCount, ENTRIES), SlotTimeline(), _slotIndex(slotIndex), _attachment((HasTextureRegion *) attachment) {
+SequenceTimeline::SequenceTimeline(size_t frameCount, int slotIndex, Attachment &attachment)
+	: Timeline(frameCount, ENTRIES), SlotTimeline(), _slotIndex(slotIndex), _attachment((HasTextureRegion *) &attachment) {
 	int sequenceId = 0;
-	if (attachment->getRTTI().instanceOf(RegionAttachment::rtti)) sequenceId = ((RegionAttachment *) attachment)->getSequence()->getId();
-	if (attachment->getRTTI().instanceOf(MeshAttachment::rtti)) sequenceId = ((MeshAttachment *) attachment)->getSequence()->getId();
+	if (attachment.getRTTI().instanceOf(RegionAttachment::rtti)) sequenceId = ((RegionAttachment *) &attachment)->getSequence()->getId();
+	if (attachment.getRTTI().instanceOf(MeshAttachment::rtti)) sequenceId = ((MeshAttachment *) &attachment)->getSequence()->getId();
 	PropertyId ids[] = {((PropertyId) Property_Sequence << 32) | ((slotIndex << 16 | sequenceId) & 0xffffffff)};
 	setPropertyIds(ids, 1);
 }

+ 6 - 7
spine-cpp/src/spine/SkeletonBinary.cpp

@@ -79,13 +79,12 @@
 
 using namespace spine;
 
-SkeletonBinary::SkeletonBinary(Atlas *atlas)
+SkeletonBinary::SkeletonBinary(Atlas &atlas)
 	: _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _error(), _scale(1), _ownsLoader(true) {
 }
 
-SkeletonBinary::SkeletonBinary(AttachmentLoader *attachmentLoader, bool ownsLoader)
-	: _attachmentLoader(attachmentLoader), _error(), _scale(1), _ownsLoader(ownsLoader) {
-	assert(_attachmentLoader != NULL);
+SkeletonBinary::SkeletonBinary(AttachmentLoader &attachmentLoader, bool ownsLoader)
+	: _attachmentLoader(&attachmentLoader), _error(), _scale(1), _ownsLoader(ownsLoader) {
 }
 
 SkeletonBinary::~SkeletonBinary() {
@@ -682,7 +681,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput &input, Skin &skin, int slo
 				mesh->setWidth(width * scale);
 				mesh->setHeight(height * scale);
 			}
-			_linkedMeshes.add(new (__FILE__, __LINE__) LinkedMesh(mesh, skinIndex, slotIndex, parent, inheritTimelines));
+			_linkedMeshes.add(new (__FILE__, __LINE__) LinkedMesh(*mesh, skinIndex, slotIndex, parent, inheritTimelines));
 			return mesh;
 		}
 		case AttachmentType_Path: {
@@ -1236,7 +1235,7 @@ Animation *SkeletonBinary::readAnimation(DataInput &input, const String &name, S
 						int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size();
 
 						DeformTimeline *timeline = new (__FILE__, __LINE__)
-							DeformTimeline(frameCount, input.readInt(true), slotIndex, vertexAttachment);
+							DeformTimeline(frameCount, input.readInt(true), slotIndex, *vertexAttachment);
 
 						float time = input.readFloat();
 						for (int frame = 0, bezier = 0;; ++frame) {
@@ -1280,7 +1279,7 @@ Animation *SkeletonBinary::readAnimation(DataInput &input, const String &name, S
 						break;
 					}
 					case ATTACHMENT_SEQUENCE: {
-						SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frameCount, slotIndex, attachment);
+						SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frameCount, slotIndex, *attachment);
 						for (int frame = 0; frame < frameCount; frame++) {
 							float time = input.readFloat();
 							int modeAndIndex = input.readInt();

+ 6 - 7
spine-cpp/src/spine/SkeletonJson.cpp

@@ -121,12 +121,11 @@ static float propertyScale(const char *type, float scale) {
 		return 1;
 }
 
-SkeletonJson::SkeletonJson(Atlas *atlas) : _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
+SkeletonJson::SkeletonJson(Atlas &atlas) : _attachmentLoader(new(__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
 }
 
-SkeletonJson::SkeletonJson(AttachmentLoader *attachmentLoader, bool ownsLoader)
-	: _attachmentLoader(attachmentLoader), _scale(1), _ownsLoader(ownsLoader) {
-	assert(_attachmentLoader != NULL);
+SkeletonJson::SkeletonJson(AttachmentLoader &attachmentLoader, bool ownsLoader)
+	: _attachmentLoader(&attachmentLoader), _scale(1), _ownsLoader(ownsLoader) {
 }
 
 SkeletonJson::~SkeletonJson() {
@@ -675,7 +674,7 @@ Attachment *SkeletonJson::readAttachment(Json *map, Skin *skin, int slotIndex, c
 			const char *parent = Json::getString(map, "parent", NULL);
 			if (parent) {
 				LinkedMesh *linkedMesh = new (__FILE__, __LINE__)
-					LinkedMesh(mesh, Json::getString(map, "skin", NULL), slotIndex, parent, Json::getBoolean(map, "timelines", true));
+					LinkedMesh(*mesh, Json::getString(map, "skin", NULL), slotIndex, parent, Json::getBoolean(map, "timelines", true));
 				_linkedMeshes.add(linkedMesh);
 				return mesh;
 			}
@@ -1262,7 +1261,7 @@ Animation *SkeletonJson::readAnimation(Json *map, SkeletonData *skeletonData) {
 						Array<float> &vertices = vertexAttachment->_vertices;
 						int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size();
 
-						DeformTimeline *timeline = new (__FILE__, __LINE__) DeformTimeline(frames, frames, slotIndex, vertexAttachment);
+						DeformTimeline *timeline = new (__FILE__, __LINE__) DeformTimeline(frames, frames, slotIndex, *vertexAttachment);
 						float time = Json::getFloat(keyMap, "time", 0);
 						for (int frame = 0, bezier = 0;; frame++) {
 							Array<float> deform;
@@ -1305,7 +1304,7 @@ Animation *SkeletonJson::readAnimation(Json *map, SkeletonData *skeletonData) {
 						}
 						timelines.add(timeline);
 					} else if (timelineName == "sequence") {
-						SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frames, slotIndex, attachment);
+						SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frames, slotIndex, *attachment);
 						float lastDelay = 0;
 						for (int frame = 0; keyMap != NULL; keyMap = keyMap->_next, frame++) {
 							float delay = Json::getFloat(keyMap, "delay", lastDelay);

+ 5 - 5
spine-cpp/tests/HeadlessTest.cpp

@@ -90,10 +90,10 @@ int main(int argc, char *argv[]) {
 	SkeletonData *skeletonData = nullptr;
 
 	if (strstr(skeletonPath, ".json") != nullptr) {
-		SkeletonJson json(atlas);
+		SkeletonJson json(*atlas);
 		skeletonData = json.readSkeletonDataFile(skeletonPath);
 	} else {
-		SkeletonBinary binary(atlas);
+		SkeletonBinary binary(*atlas);
 		skeletonData = binary.readSkeletonDataFile(skeletonPath);
 	}
 
@@ -111,8 +111,8 @@ int main(int argc, char *argv[]) {
 	AnimationStateData *stateData = nullptr;
 	if (animationName != nullptr) {
 		// Create animation state only when needed
-		stateData = new AnimationStateData(skeletonData);
-		state = new AnimationState(stateData);
+		stateData = new AnimationStateData(*skeletonData);
+		state = new AnimationState(*stateData);
 
 		// Find and set animation
 		Animation *animation = skeletonData->findAnimation(animationName);
@@ -122,7 +122,7 @@ int main(int argc, char *argv[]) {
 			delete atlas;
 			return 1;
 		}
-		state->setAnimation(0, animation, true);
+		state->setAnimation(0, *animation, true);
 		// Update and apply
 		state->update(0.016f);
 		state->apply(skeleton);