mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
[c] Functions in extension.h are now prefixed with _sp to avoid name collisions with other libraries
This commit is contained in:
parent
6e7c6ebc07
commit
0227513188
@ -49,6 +49,7 @@
|
|||||||
* `AnimationState#apply` returns boolean indicating if any timeline was applied or not.
|
* `AnimationState#apply` returns boolean indicating if any timeline was applied or not.
|
||||||
* `Animation#apply` and `Timeline#apply`` now take enums `MixPose` and `MixDirection` instead of booleans
|
* `Animation#apply` and `Timeline#apply`` now take enums `MixPose` and `MixDirection` instead of booleans
|
||||||
* Added `spVertexEffect` and corresponding implementations `spJitterVertexEffect` and `spSwirlVertexEffect`. Create/dispose through the corresponding `spXXXVertexEffect_create()/dispose()` functions. Set on framework/engine specific renderer. See changes for spine-c based frameworks/engines below.
|
* Added `spVertexEffect` and corresponding implementations `spJitterVertexEffect` and `spSwirlVertexEffect`. Create/dispose through the corresponding `spXXXVertexEffect_create()/dispose()` functions. Set on framework/engine specific renderer. See changes for spine-c based frameworks/engines below.
|
||||||
|
* Functions in `extension.h` are not prefixed with `_sp` instead of just `_` to avoid interference with other libraries.
|
||||||
|
|
||||||
### Cocos2d-X
|
### Cocos2d-X
|
||||||
* Fixed renderer to work with 3.6 changes
|
* Fixed renderer to work with 3.6 changes
|
||||||
|
|||||||
@ -62,9 +62,9 @@
|
|||||||
#define SPINE_EXTENSION_H_
|
#define SPINE_EXTENSION_H_
|
||||||
|
|
||||||
/* All allocation uses these. */
|
/* All allocation uses these. */
|
||||||
#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
|
#define MALLOC(TYPE,COUNT) ((TYPE*)_spMalloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
|
||||||
#define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
|
#define CALLOC(TYPE,COUNT) ((TYPE*)_spCalloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
|
||||||
#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_realloc(PTR, sizeof(TYPE) * (COUNT)))
|
#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_spRealloc(PTR, sizeof(TYPE) * (COUNT)))
|
||||||
#define NEW(TYPE) CALLOC(TYPE,1)
|
#define NEW(TYPE) CALLOC(TYPE,1)
|
||||||
|
|
||||||
/* Gets the direct super class. Type safe. */
|
/* Gets the direct super class. Type safe. */
|
||||||
@ -83,7 +83,7 @@
|
|||||||
#define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable)
|
#define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable)
|
||||||
|
|
||||||
/* Frees memory. Can be used on const types. */
|
/* Frees memory. Can be used on const types. */
|
||||||
#define FREE(VALUE) _free((void*)VALUE)
|
#define FREE(VALUE) _spFree((void*)VALUE)
|
||||||
|
|
||||||
/* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */
|
/* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */
|
||||||
#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)MALLOC(char, strlen(FROM) + 1), FROM)
|
#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)MALLOC(char, strlen(FROM) + 1), FROM)
|
||||||
@ -164,19 +164,19 @@ char* _spUtil_readFile (const char* path, int* length);
|
|||||||
* Internal API available for extension:
|
* Internal API available for extension:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void* _malloc (size_t size, const char* file, int line);
|
void* _spMalloc (size_t size, const char* file, int line);
|
||||||
void* _calloc (size_t num, size_t size, const char* file, int line);
|
void* _spCalloc (size_t num, size_t size, const char* file, int line);
|
||||||
void* _realloc(void* ptr, size_t size);
|
void* _spRealloc(void* ptr, size_t size);
|
||||||
void _free (void* ptr);
|
void _spFree (void* ptr);
|
||||||
float _random ();
|
float _spRandom ();
|
||||||
|
|
||||||
void _setMalloc (void* (*_malloc) (size_t size));
|
void _spSetMalloc (void* (*_malloc) (size_t size));
|
||||||
void _setDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
|
void _spSetDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
|
||||||
void _setRealloc(void* (*_realloc) (void* ptr, size_t size));
|
void _spSetRealloc(void* (*_realloc) (void* ptr, size_t size));
|
||||||
void _setFree (void (*_free) (void* ptr));
|
void _spSetFree (void (*_free) (void* ptr));
|
||||||
void _setRandom(float (*_random) ());
|
void _spSetRandom(float (*_random) ());
|
||||||
|
|
||||||
char* _readFile (const char* path, int* length);
|
char* _spReadFile (const char* path, int* length);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
float _spRandom () {
|
float _spInternalRandom () {
|
||||||
return rand() / (float)RAND_MAX;
|
return rand() / (float)RAND_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,51 +39,51 @@ static void* (*mallocFunc) (size_t size) = malloc;
|
|||||||
static void* (*reallocFunc) (void* ptr, size_t size) = realloc;
|
static void* (*reallocFunc) (void* ptr, size_t size) = realloc;
|
||||||
static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL;
|
static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL;
|
||||||
static void (*freeFunc) (void* ptr) = free;
|
static void (*freeFunc) (void* ptr) = free;
|
||||||
static float (*randomFunc) () = _spRandom;
|
static float (*randomFunc) () = _spInternalRandom;
|
||||||
|
|
||||||
void* _malloc (size_t size, const char* file, int line) {
|
void* _spMalloc (size_t size, const char* file, int line) {
|
||||||
if(debugMallocFunc)
|
if(debugMallocFunc)
|
||||||
return debugMallocFunc(size, file, line);
|
return debugMallocFunc(size, file, line);
|
||||||
|
|
||||||
return mallocFunc(size);
|
return mallocFunc(size);
|
||||||
}
|
}
|
||||||
void* _calloc (size_t num, size_t size, const char* file, int line) {
|
void* _spCalloc (size_t num, size_t size, const char* file, int line) {
|
||||||
void* ptr = _malloc(num * size, file, line);
|
void* ptr = _spMalloc(num * size, file, line);
|
||||||
if (ptr) memset(ptr, 0, num * size);
|
if (ptr) memset(ptr, 0, num * size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
void* _realloc(void* ptr, size_t size) {
|
void* _spRealloc(void* ptr, size_t size) {
|
||||||
return reallocFunc(ptr, size);
|
return reallocFunc(ptr, size);
|
||||||
}
|
}
|
||||||
void _free (void* ptr) {
|
void _spFree (void* ptr) {
|
||||||
freeFunc(ptr);
|
freeFunc(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
float _random () {
|
float _spRandom () {
|
||||||
return randomFunc();
|
return randomFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) {
|
void _spSetDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) {
|
||||||
debugMallocFunc = malloc;
|
debugMallocFunc = malloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setMalloc (void* (*malloc) (size_t size)) {
|
void _spSetMalloc (void* (*malloc) (size_t size)) {
|
||||||
mallocFunc = malloc;
|
mallocFunc = malloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setRealloc (void* (*realloc) (void* ptr, size_t size)) {
|
void _spSetRealloc (void* (*realloc) (void* ptr, size_t size)) {
|
||||||
reallocFunc = realloc;
|
reallocFunc = realloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setFree (void (*free) (void* ptr)) {
|
void _spSetFree (void (*free) (void* ptr)) {
|
||||||
freeFunc = free;
|
freeFunc = free;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setRandom (float (*random) ()) {
|
void _spSetRandom (float (*random) ()) {
|
||||||
randomFunc = random;
|
randomFunc = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* _readFile (const char* path, int* length) {
|
char* _spReadFile (const char* path, int* length) {
|
||||||
char *data;
|
char *data;
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
if (!file) return 0;
|
if (!file) return 0;
|
||||||
@ -100,7 +100,7 @@ char* _readFile (const char* path, int* length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float _spMath_random(float min, float max) {
|
float _spMath_random(float min, float max) {
|
||||||
return min + (max - min) * _random();
|
return min + (max - min) * _spRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
float _spMath_randomTriangular(float min, float max) {
|
float _spMath_randomTriangular(float min, float max) {
|
||||||
@ -108,7 +108,7 @@ float _spMath_randomTriangular(float min, float max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float _spMath_randomTriangularWith(float min, float max, float mode) {
|
float _spMath_randomTriangularWith(float min, float max, float mode) {
|
||||||
float u = _random();
|
float u = _spRandom();
|
||||||
float d = max - min;
|
float d = max - min;
|
||||||
if (u <= (mode - min) / d) return min + SQRT(u * d * (mode - min));
|
if (u <= (mode - min) / d) return min + SQRT(u * d * (mode - min));
|
||||||
return max - SQRT((1 - u) * d * (max - mode));
|
return max - SQRT((1 - u) * d * (max - mode));
|
||||||
|
|||||||
@ -56,7 +56,7 @@ void _AtlasPage_disposeTexture (AtlasPage* self){
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* _Util_readFile (const char* path, int* length){
|
char* _Util_readFile (const char* path, int* length){
|
||||||
return _readFile(path, length);
|
return _spReadFile(path, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user