From e64b3c201a09a30963b57f4e1815a0faf951ed7a Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Thu, 25 Apr 2013 23:19:02 +0200 Subject: [PATCH] Fixed up remaining issues to make spine-c C89. --- spine-c/.cproject | 4 ++-- spine-c/include/spine/RegionAttachment.h | 6 +++--- spine-c/include/spine/extension.h | 14 +++++++------- spine-c/src/spine/Animation.c | 19 +++++++++++++------ spine-c/src/spine/Attachment.c | 2 +- spine-c/src/spine/AttachmentLoader.c | 4 ++-- spine-c/src/spine/Bone.c | 5 +++++ spine-c/src/spine/RegionAttachment.c | 7 ++++++- 8 files changed, 39 insertions(+), 22 deletions(-) diff --git a/spine-c/.cproject b/spine-c/.cproject index b8e4a0253..f33397ccc 100644 --- a/spine-c/.cproject +++ b/spine-c/.cproject @@ -19,7 +19,7 @@ - + @@ -39,7 +39,7 @@ - diff --git a/spine-c/include/spine/RegionAttachment.h b/spine-c/include/spine/RegionAttachment.h index e37c5a537..7193f43e5 100644 --- a/spine-c/include/spine/RegionAttachment.h +++ b/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]; diff --git a/spine-c/include/spine/extension.h b/spine-c/include/spine/extension.h index 94a9d7a9a..7642f4603 100644 --- a/spine-c/include/spine/extension.h +++ b/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); diff --git a/spine-c/src/spine/Animation.c b/spine-c/src/spine/Animation.c index 98d352897..c244e93e3 100644 --- a/spine-c/src/spine/Animation.c +++ b/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 diff --git a/spine-c/src/spine/Attachment.c b/spine-c/src/spine/Attachment.c index fb122cd3d..331e2cbc9 100644 --- a/spine-c/src/spine/Attachment.c +++ b/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); diff --git a/spine-c/src/spine/AttachmentLoader.c b/spine-c/src/spine/AttachmentLoader.c index 2a1bcf227..65e1d4e43 100644 --- a/spine-c/src/spine/AttachmentLoader.c +++ b/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; diff --git a/spine-c/src/spine/Bone.c b/spine-c/src/spine/Bone.c index 8a7b27f42..a3e6034ea 100644 --- a/spine-c/src/spine/Bone.c +++ b/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; diff --git a/spine-c/src/spine/RegionAttachment.c b/spine-c/src/spine/RegionAttachment.c index 1b97d948c..1f551ce0f 100644 --- a/spine-c/src/spine/RegionAttachment.c +++ b/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 \ No newline at end of file +#endif