Updated spine-c struct definitions to allow for forward declarations.

This commit is contained in:
NathanSweet 2014-11-18 03:40:20 +01:00
parent 1fa410bb53
commit fb214ee276
20 changed files with 45 additions and 54 deletions

View File

@ -41,7 +41,7 @@ extern "C" {
typedef struct spTimeline spTimeline; typedef struct spTimeline spTimeline;
struct spSkeleton; struct spSkeleton;
typedef struct { typedef struct spAnimation {
const char* const name; const char* const name;
float duration; float duration;
@ -114,7 +114,7 @@ typedef spTimeline Timeline;
/**/ /**/
typedef struct { typedef struct spCurveTimeline {
spTimeline super; spTimeline super;
float* curves; /* type, x, y, ... */ float* curves; /* type, x, y, ... */
} spCurveTimeline; } spCurveTimeline;
@ -143,7 +143,11 @@ typedef struct spBaseTimeline {
int const framesCount; int const framesCount;
float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */ float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */
int boneIndex; int boneIndex;
} spRotateTimeline; } spBaseTimeline;
/**/
typedef struct spBaseTimeline spRotateTimeline;
spRotateTimeline* spRotateTimeline_create (int framesCount); spRotateTimeline* spRotateTimeline_create (int framesCount);
@ -185,7 +189,7 @@ typedef spScaleTimeline ScaleTimeline;
/**/ /**/
typedef struct { typedef struct spColorTimeline {
spCurveTimeline super; spCurveTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, r, g, b, a, ... */ float* const frames; /* time, r, g, b, a, ... */
@ -204,7 +208,7 @@ typedef spColorTimeline ColorTimeline;
/**/ /**/
typedef struct { typedef struct spAttachmentTimeline {
spTimeline super; spTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, ... */ float* const frames; /* time, ... */
@ -225,7 +229,7 @@ typedef spAttachmentTimeline AttachmentTimeline;
/**/ /**/
typedef struct { typedef struct spEventTimeline {
spTimeline super; spTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, ... */ float* const frames; /* time, ... */
@ -244,7 +248,7 @@ typedef spEventTimeline EventTimeline;
/**/ /**/
typedef struct { typedef struct spDrawOrderTimeline {
spTimeline super; spTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, ... */ float* const frames; /* time, ... */
@ -264,7 +268,7 @@ typedef spDrawOrderTimeline DrawOrderTimeline;
/**/ /**/
typedef struct { typedef struct spFFDTimeline {
spCurveTimeline super; spCurveTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, ... */ float* const frames; /* time, ... */
@ -286,7 +290,7 @@ typedef spFFDTimeline FFDTimeline;
/**/ /**/
typedef struct { typedef struct spIkConstraintTimeline {
spCurveTimeline super; spCurveTimeline super;
int const framesCount; int const framesCount;
float* const frames; /* time, mix, bendDirection, ... */ float* const frames; /* time, mix, bendDirection, ... */
@ -306,7 +310,7 @@ typedef spIkConstraintTimeline IkConstraintTimeline;
/**/ /**/
typedef struct { typedef struct spFlipTimeline {
spTimeline super; spTimeline super;
int const x; int const x;
int const framesCount; int const framesCount;

View File

@ -38,7 +38,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spAnimationStateData {
spSkeletonData* const skeletonData; spSkeletonData* const skeletonData;
float defaultMix; float defaultMix;
const void* const entries; const void* const entries;

View File

@ -38,7 +38,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spAtlasAttachmentLoader {
spAttachmentLoader super; spAttachmentLoader super;
spAtlas* atlas; spAtlas* atlas;
} spAtlasAttachmentLoader; } spAtlasAttachmentLoader;

View File

@ -35,19 +35,16 @@
extern "C" { extern "C" {
#endif #endif
struct spSlot;
typedef enum { typedef enum {
SP_ATTACHMENT_REGION, SP_ATTACHMENT_BOUNDING_BOX, SP_ATTACHMENT_MESH, SP_ATTACHMENT_SKINNED_MESH SP_ATTACHMENT_REGION, SP_ATTACHMENT_BOUNDING_BOX, SP_ATTACHMENT_MESH, SP_ATTACHMENT_SKINNED_MESH
} spAttachmentType; } spAttachmentType;
typedef struct spAttachment spAttachment; typedef struct spAttachment {
struct spAttachment {
const char* const name; const char* const name;
const spAttachmentType type; const spAttachmentType type;
const void* const vtable; const void* const vtable;
}; } spAttachment;
void spAttachment_dispose (spAttachment* self); void spAttachment_dispose (spAttachment* self);

View File

@ -38,8 +38,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spAttachmentLoader spAttachmentLoader; typedef struct spAttachmentLoader {
struct spAttachmentLoader {
const char* error1; const char* error1;
const char* error2; const char* error2;
@ -51,7 +50,7 @@ struct spAttachmentLoader {
vtable(0) { vtable(0) {
} }
#endif #endif
}; } spAttachmentLoader;
void spAttachmentLoader_dispose (spAttachmentLoader* self); void spAttachmentLoader_dispose (spAttachmentLoader* self);

View File

@ -39,12 +39,11 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spBoundingBoxAttachment spBoundingBoxAttachment; typedef struct spBoundingBoxAttachment {
struct spBoundingBoxAttachment {
spAttachment super; spAttachment super;
int verticesCount; int verticesCount;
float* vertices; float* vertices;
}; } spBoundingBoxAttachment;
spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name); spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name);
void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spBone* bone, float* vertices); void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spBone* bone, float* vertices);

View File

@ -37,13 +37,12 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spEvent spEvent; typedef struct spEvent {
struct spEvent {
spEventData* const data; spEventData* const data;
int intValue; int intValue;
float floatValue; float floatValue;
const char* stringValue; const char* stringValue;
}; } spEvent;
spEvent* spEvent_create (spEventData* data); spEvent* spEvent_create (spEventData* data);
void spEvent_dispose (spEvent* self); void spEvent_dispose (spEvent* self);

View File

@ -35,13 +35,12 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spEventData spEventData; typedef struct spEventData {
struct spEventData {
const char* const name; const char* const name;
int intValue; int intValue;
float floatValue; float floatValue;
const char* stringValue; const char* stringValue;
}; } spEventData;
spEventData* spEventData_create (const char* name); spEventData* spEventData_create (const char* name);
void spEventData_dispose (spEventData* self); void spEventData_dispose (spEventData* self);

View File

@ -40,8 +40,7 @@ extern "C" {
struct spSkeleton; struct spSkeleton;
typedef struct spIkConstraint spIkConstraint; typedef struct spIkConstraint {
struct spIkConstraint {
spIkConstraintData* const data; spIkConstraintData* const data;
int bonesCount; int bonesCount;
@ -50,7 +49,7 @@ struct spIkConstraint {
spBone* target; spBone* target;
int bendDirection; int bendDirection;
float mix; float mix;
}; } spIkConstraint;
spIkConstraint* spIkConstraint_create (spIkConstraintData* data, const struct spSkeleton* skeleton); spIkConstraint* spIkConstraint_create (spIkConstraintData* data, const struct spSkeleton* skeleton);
void spIkConstraint_dispose (spIkConstraint* self); void spIkConstraint_dispose (spIkConstraint* self);

View File

@ -37,8 +37,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spIkConstraintData spIkConstraintData; typedef struct spIkConstraintData {
struct spIkConstraintData {
const char* const name; const char* const name;
int bonesCount; int bonesCount;
@ -47,7 +46,7 @@ struct spIkConstraintData {
spBoneData* target; spBoneData* target;
int bendDirection; int bendDirection;
float mix; float mix;
}; } spIkConstraintData;
spIkConstraintData* spIkConstraintData_create (const char* name); spIkConstraintData* spIkConstraintData_create (const char* name);
void spIkConstraintData_dispose (spIkConstraintData* self); void spIkConstraintData_dispose (spIkConstraintData* self);

View File

@ -39,8 +39,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spMeshAttachment spMeshAttachment; typedef struct spMeshAttachment {
struct spMeshAttachment {
spAttachment super; spAttachment super;
const char* path; const char* path;
@ -67,7 +66,7 @@ struct spMeshAttachment {
int edgesCount; int edgesCount;
int* edges; int* edges;
float width, height; float width, height;
}; } spMeshAttachment;
spMeshAttachment* spMeshAttachment_create (const char* name); spMeshAttachment* spMeshAttachment_create (const char* name);
void spMeshAttachment_updateUVs (spMeshAttachment* self); void spMeshAttachment_updateUVs (spMeshAttachment* self);

View File

@ -43,8 +43,7 @@ typedef enum {
SP_VERTEX_X1 = 0, SP_VERTEX_Y1, SP_VERTEX_X2, SP_VERTEX_Y2, SP_VERTEX_X3, SP_VERTEX_Y3, SP_VERTEX_X4, SP_VERTEX_Y4 SP_VERTEX_X1 = 0, SP_VERTEX_Y1, SP_VERTEX_X2, SP_VERTEX_Y2, SP_VERTEX_X3, SP_VERTEX_Y3, SP_VERTEX_X4, SP_VERTEX_Y4
} spVertexIndex; } spVertexIndex;
typedef struct spRegionAttachment spRegionAttachment; typedef struct spRegionAttachment {
struct spRegionAttachment {
spAttachment super; spAttachment super;
const char* path; const char* path;
float x, y, scaleX, scaleY, rotation, width, height; float x, y, scaleX, scaleY, rotation, width, height;
@ -57,7 +56,7 @@ struct spRegionAttachment {
float offset[8]; float offset[8];
float uvs[8]; float uvs[8];
}; } spRegionAttachment;
spRegionAttachment* spRegionAttachment_create (const char* name); spRegionAttachment* spRegionAttachment_create (const char* name);
void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate);

View File

@ -40,8 +40,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spSkeleton spSkeleton; typedef struct spSkeleton {
struct spSkeleton {
spSkeletonData* const data; spSkeletonData* const data;
int bonesCount; int bonesCount;
@ -60,7 +59,7 @@ struct spSkeleton {
float time; float time;
int/*bool*/flipX, flipY; int/*bool*/flipX, flipY;
float x, y; float x, y;
}; } spSkeleton;
spSkeleton* spSkeleton_create (spSkeletonData* data); spSkeleton* spSkeleton_create (spSkeletonData* data);
void spSkeleton_dispose (spSkeleton* self); void spSkeleton_dispose (spSkeleton* self);

View File

@ -38,7 +38,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spPolygon {
float* const vertices; float* const vertices;
int count; int count;
int capacity; int capacity;
@ -60,7 +60,7 @@ typedef spPolygon Polygon;
/**/ /**/
typedef struct { typedef struct spSkeletonBounds {
int count; int count;
spBoundingBoxAttachment** boundingBoxes; spBoundingBoxAttachment** boundingBoxes;
spPolygon** polygons; spPolygon** polygons;

View File

@ -42,7 +42,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spSkeletonData {
const char* version; const char* version;
const char* hash; const char* hash;
float width, height; float width, height;

View File

@ -41,7 +41,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spSkeletonJson {
float scale; float scale;
spAttachmentLoader* attachmentLoader; spAttachmentLoader* attachmentLoader;
const char* const error; const char* const error;

View File

@ -39,7 +39,7 @@ extern "C" {
struct spSkeleton; struct spSkeleton;
typedef struct { typedef struct spSkin {
const char* const name; const char* const name;
} spSkin; } spSkin;

View File

@ -38,8 +38,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct spSkinnedMeshAttachment spSkinnedMeshAttachment; typedef struct spSkinnedMeshAttachment {
struct spSkinnedMeshAttachment {
spAttachment super; spAttachment super;
const char* path; const char* path;
@ -70,7 +69,7 @@ struct spSkinnedMeshAttachment {
int edgesCount; int edgesCount;
int* edges; int* edges;
float width, height; float width, height;
}; } spSkinnedMeshAttachment;
spSkinnedMeshAttachment* spSkinnedMeshAttachment_create (const char* name); spSkinnedMeshAttachment* spSkinnedMeshAttachment_create (const char* name);
void spSkinnedMeshAttachment_updateUVs (spSkinnedMeshAttachment* self); void spSkinnedMeshAttachment_updateUVs (spSkinnedMeshAttachment* self);

View File

@ -37,7 +37,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct spSlotData {
const char* const name; const char* const name;
const spBoneData* const boneData; const spBoneData* const boneData;
const char* attachmentName; const char* attachmentName;

View File

@ -124,7 +124,7 @@ char* _readFile (const char* path, int* length);
/**/ /**/
typedef struct { typedef struct _spAnimationState {
spAnimationState super; spAnimationState super;
spEvent** events; spEvent** events;