فهرست منبع

Fixed up remaining issues to make spine-c C89.

NathanSweet 12 سال پیش
والد
کامیت
e64b3c201a

+ 2 - 2
spine-c/.cproject

@@ -19,7 +19,7 @@
 						<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.1244859277" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
 							<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.2141344127" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
 							<builder buildPath="${workspace_loc:/spine-ctest/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.2012621380" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
-							<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1379375071" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
+							<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1379375071" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
 								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1840963518" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
 							</tool>
 							<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1581759609" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
@@ -39,7 +39,7 @@
 									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
 								</option>
-								<option id="gnu.c.compiler.option.misc.other.1829716988" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
+								<option id="gnu.c.compiler.option.misc.other.1829716988" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -std=c89" valueType="string"/>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.603555848" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 							</tool>
 							<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.1030541714" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug"/>

+ 3 - 3
spine-c/include/spine/RegionAttachment.h

@@ -45,9 +45,9 @@ struct RegionAttachment {
 	float x, y, scaleX, scaleY, rotation, width, height;
 
 	void* texture;
-	float regionOffsetX, regionOffsetY; // Pixels stripped from the bottom left, unrotated.
-	float regionWidth, regionHeight; // Unrotated, stripped size.
-	float regionOriginalWidth, regionOriginalHeight; // Unrotated, unstripped size.
+	float regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */
+	float regionWidth, regionHeight; /* Unrotated, stripped size. */
+	float regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped size. */
 
 	float offset[8];
 	float vertices[8];

+ 7 - 7
spine-c/include/spine/extension.h

@@ -116,8 +116,8 @@ char* _readFile (const char* path, int* length);
 
 /**/
 
-void _AttachmentLoader_init (AttachmentLoader* self, //
-		void (*dispose) (AttachmentLoader* self), //
+void _AttachmentLoader_init (AttachmentLoader* self, /**/
+		void (*dispose) (AttachmentLoader* self), /**/
 		Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name));
 void _AttachmentLoader_deinit (AttachmentLoader* self);
 void _AttachmentLoader_setError (AttachmentLoader* self, const char* error1, const char* error2);
@@ -125,21 +125,21 @@ void _AttachmentLoader_setUnknownTypeError (AttachmentLoader* self, AttachmentTy
 
 /**/
 
-void _Attachment_init (Attachment* self, const char* name, AttachmentType type, //
+void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/
 		void (*dispose) (Attachment* self));
 void _Attachment_deinit (Attachment* self);
 
 /**/
 
-void _Timeline_init (Timeline* self, //
-		void (*dispose) (Timeline* self), //
+void _Timeline_init (Timeline* self, /**/
+		void (*dispose) (Timeline* self), /**/
 		void (*apply) (const Timeline* self, Skeleton* skeleton, float time, float alpha));
 void _Timeline_deinit (Timeline* self);
 
 /**/
 
-void _CurveTimeline_init (CurveTimeline* self, int frameCount, //
-		void (*dispose) (Timeline* self), //
+void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/
+		void (*dispose) (Timeline* self), /**/
 		void (*apply) (const Timeline* self, Skeleton* skeleton, float time, float alpha));
 void _CurveTimeline_deinit (CurveTimeline* self);
 

+ 13 - 6
spine-c/src/spine/Animation.c

@@ -51,7 +51,11 @@ void Animation_dispose (Animation* self) {
 void Animation_apply (const Animation* self, Skeleton* skeleton, float time, int/*bool*/loop) {
 	int i, n = self->timelineCount;
 
+#ifdef __STDC_VERSION__
 	if (loop && self->duration) time = fmodf(time, self->duration);
+#else
+	if (loop && self->duration) time = fmod(time, self->duration);
+#endif
 
 	for (i = 0; i < n; ++i)
 		Timeline_apply(self->timelines[i], skeleton, time, 1);
@@ -60,7 +64,11 @@ void Animation_apply (const Animation* self, Skeleton* skeleton, float time, int
 void Animation_mix (const Animation* self, Skeleton* skeleton, float time, int/*bool*/loop, float alpha) {
 	int i, n = self->timelineCount;
 
+#ifdef __STDC_VERSION__
 	if (loop && self->duration) time = fmodf(time, self->duration);
+#else
+	if (loop && self->duration) time = fmod(time, self->duration);
+#endif
 
 	for (i = 0; i < n; ++i)
 		Timeline_apply(self->timelines[i], skeleton, time, alpha);
@@ -73,8 +81,8 @@ typedef struct _TimelineVtable {
 	void (*dispose) (Timeline* self);
 } _TimelineVtable;
 
-void _Timeline_init (Timeline* self, //
-		void (*dispose) (Timeline* self), //
+void _Timeline_init (Timeline* self, /**/
+		void (*dispose) (Timeline* self), /**/
 		void (*apply) (const Timeline* self, Skeleton* skeleton, float time, float alpha)) {
 	CONST_CAST(_TimelineVtable*, self->vtable) = NEW(_TimelineVtable);
 	VTABLE(Timeline, self) ->dispose = dispose;
@@ -99,8 +107,8 @@ static const float CURVE_LINEAR = 0;
 static const float CURVE_STEPPED = -1;
 static const int CURVE_SEGMENTS = 10;
 
-void _CurveTimeline_init (CurveTimeline* self, int frameCount, //
-		void (*dispose) (Timeline* self), //
+void _CurveTimeline_init (CurveTimeline* self, int frameCount, /**/
+		void (*dispose) (Timeline* self), /**/
 		void (*apply) (const Timeline* self, Skeleton* skeleton, float time, float alpha)) {
 	_Timeline_init(SUPER(self), dispose, apply);
 	self->curves = CALLOC(float, (frameCount - 1) * 6);
@@ -213,7 +221,7 @@ void _BaseTimeline_dispose (Timeline* timeline) {
 }
 
 /* Many timelines have structure identical to struct BaseTimeline and extend CurveTimeline. **/
-struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, //
+struct BaseTimeline* _BaseTimeline_create (int frameCount, int frameSize, /**/
 		void (*apply) (const Timeline* self, Skeleton* skeleton, float time, float alpha)) {
 
 	struct BaseTimeline* self = NEW(struct BaseTimeline);
@@ -446,7 +454,6 @@ void _AttachmentTimeline_apply (const Timeline* timeline, Skeleton* skeleton, fl
 
 	if (time < self->frames[0]) return; /* Time is before first frame. */
 
-	frameIndex;
 	if (time >= self->frames[self->framesLength - 1]) /* Time is after last frame. */
 		frameIndex = self->framesLength - 1;
 	else

+ 1 - 1
spine-c/src/spine/Attachment.c

@@ -35,7 +35,7 @@ typedef struct _AttachmentVtable {
 	void (*dispose) (Attachment* self);
 } _AttachmentVtable;
 
-void _Attachment_init (Attachment* self, const char* name, AttachmentType type, //
+void _Attachment_init (Attachment* self, const char* name, AttachmentType type, /**/
 		void (*dispose) (Attachment* self)) {
 
 	CONST_CAST(_AttachmentVtable*, self->vtable) = NEW(_AttachmentVtable);

+ 2 - 2
spine-c/src/spine/AttachmentLoader.c

@@ -36,8 +36,8 @@ typedef struct _AttachmentLoaderVtable {
 	void (*dispose) (AttachmentLoader* self);
 } _AttachmentLoaderVtable;
 
-void _AttachmentLoader_init (AttachmentLoader* self, //
-		void (*dispose) (AttachmentLoader* self), //
+void _AttachmentLoader_init (AttachmentLoader* self, /**/
+		void (*dispose) (AttachmentLoader* self), /**/
 		Attachment* (*newAttachment) (AttachmentLoader* self, Skin* skin, AttachmentType type, const char* name)) {
 	CONST_CAST(_AttachmentLoaderVtable*, self->vtable) = NEW(_AttachmentLoaderVtable);
 	VTABLE(AttachmentLoader, self) ->dispose = dispose;

+ 5 - 0
spine-c/src/spine/Bone.c

@@ -73,8 +73,13 @@ void Bone_updateWorldTransform (Bone* self, int flipX, int flipY) {
 		CONST_CAST(float, self->worldRotation) = self->rotation;
 	}
 	radians = (float)(self->worldRotation * 3.1415926535897932385 / 180);
+#ifdef __STDC_VERSION__
 	cosine = cosf(radians);
 	sine = sinf(radians);
+#else
+	cosine = cos(radians);
+	sine = sin(radians);
+#endif
 	CONST_CAST(float, self->m00) = cosine * self->worldScaleX;
 	CONST_CAST(float, self->m10) = sine * self->worldScaleX;
 	CONST_CAST(float, self->m01) = -sine * self->worldScaleY;

+ 6 - 1
spine-c/src/spine/RegionAttachment.c

@@ -69,8 +69,13 @@ void RegionAttachment_updateOffset (RegionAttachment* self) {
 	float localX2 = localX + self->regionWidth * regionScaleX;
 	float localY2 = localY + self->regionHeight * regionScaleY;
 	float radians = (float)(self->rotation * 3.1415926535897932385 / 180);
+#ifdef __STDC_VERSION__
 	float cosine = cosf(radians);
 	float sine = sinf(radians);
+#else
+	float cosine = cos(radians);
+	float sine = sin(radians);
+#endif
 	float localXCos = localX * cosine + self->x;
 	float localXSin = localX * sine;
 	float localYCos = localY * cosine + self->y;
@@ -104,4 +109,4 @@ void RegionAttachment_updateVertices (RegionAttachment* self, Slot* slot) {
 
 #ifdef __cplusplus
 }
-#endif
+#endif