Преглед на файлове

[c] Functions in extension.h are now prefixed with _sp to avoid name collisions with other libraries

badlogic преди 8 години
родител
ревизия
0227513188
променени са 4 файла, в които са добавени 33 реда и са изтрити 32 реда
  1. 1 0
      CHANGELOG.md
  2. 15 15
      spine-c/spine-c/include/spine/extension.h
  3. 16 16
      spine-c/spine-c/src/spine/extension.c
  4. 1 1
      spine-sfml/src/spine/spine-sfml.cpp

+ 1 - 0
CHANGELOG.md

@@ -49,6 +49,7 @@
   * `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
   * 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
  * Fixed renderer to work with 3.6 changes

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

@@ -62,9 +62,9 @@
 #define SPINE_EXTENSION_H_
 
 /* All allocation uses these. */
-#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
-#define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
-#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_realloc(PTR, sizeof(TYPE) * (COUNT)))
+#define MALLOC(TYPE,COUNT) ((TYPE*)_spMalloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
+#define CALLOC(TYPE,COUNT) ((TYPE*)_spCalloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
+#define REALLOC(PTR,TYPE,COUNT) ((TYPE*)_spRealloc(PTR, sizeof(TYPE) * (COUNT)))
 #define NEW(TYPE) CALLOC(TYPE,1)
 
 /* Gets the direct super class. Type safe. */
@@ -83,7 +83,7 @@
 #define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable)
 
 /* 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. */
 #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:
  */
 
-void* _malloc (size_t size, const char* file, int line);
-void* _calloc (size_t num, size_t size, const char* file, int line);
-void* _realloc(void* ptr, size_t size);
-void _free (void* ptr);
-float _random ();
+void* _spMalloc (size_t size, const char* file, int line);
+void* _spCalloc (size_t num, size_t size, const char* file, int line);
+void* _spRealloc(void* ptr, size_t size);
+void _spFree (void* ptr);
+float _spRandom ();
 
-void _setMalloc (void* (*_malloc) (size_t size));
-void _setDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
-void _setRealloc(void* (*_realloc) (void* ptr, size_t size));
-void _setFree (void (*_free) (void* ptr));
-void _setRandom(float (*_random) ());
+void _spSetMalloc (void* (*_malloc) (size_t size));
+void _spSetDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
+void _spSetRealloc(void* (*_realloc) (void* ptr, size_t size));
+void _spSetFree (void (*_free) (void* ptr));
+void _spSetRandom(float (*_random) ());
 
-char* _readFile (const char* path, int* length);
+char* _spReadFile (const char* path, int* length);
 
 
 /*

+ 16 - 16
spine-c/spine-c/src/spine/extension.c

@@ -31,7 +31,7 @@
 #include <spine/extension.h>
 #include <stdio.h>
 
-float _spRandom () {
+float _spInternalRandom () {
 	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* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL;
 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)
 		return debugMallocFunc(size, file, line);
 
 	return mallocFunc(size);
 }
-void* _calloc (size_t num, size_t size, const char* file, int line) {
-	void* ptr = _malloc(num * size, file, line);
+void* _spCalloc (size_t num, size_t size, const char* file, int line) {
+	void* ptr = _spMalloc(num * size, file, line);
 	if (ptr) memset(ptr, 0, num * size);
 	return ptr;
 }
-void* _realloc(void* ptr, size_t size) {
+void* _spRealloc(void* ptr, size_t size) {
 	return reallocFunc(ptr, size);
 }
-void _free (void* ptr) {
+void _spFree (void* ptr) {
 	freeFunc(ptr);
 }
 
-float _random () {
+float _spRandom () {
 	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;
 }
 
-void _setMalloc (void* (*malloc) (size_t size)) {
+void _spSetMalloc (void* (*malloc) (size_t size)) {
 	mallocFunc = malloc;
 }
 
-void _setRealloc (void* (*realloc) (void* ptr, size_t size)) {
+void _spSetRealloc (void* (*realloc) (void* ptr, size_t size)) {
 	reallocFunc = realloc;
 }
 
-void _setFree (void (*free) (void* ptr)) {
+void _spSetFree (void (*free) (void* ptr)) {
 	freeFunc = free;
 }
 
-void _setRandom (float (*random) ()) {
+void _spSetRandom (float (*random) ()) {
 	randomFunc = random;
 }
 
-char* _readFile (const char* path, int* length) {
+char* _spReadFile (const char* path, int* length) {
 	char *data;
 	FILE *file = fopen(path, "rb");
 	if (!file) return 0;
@@ -100,7 +100,7 @@ char* _readFile (const char* path, int* length) {
 }
 
 float _spMath_random(float min, float max) {
-	return min + (max - min) * _random();
+	return min + (max - min) * _spRandom();
 }
 
 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 u = _random();
+	float u = _spRandom();
 	float d = max - min;
 	if (u <= (mode - min) / d) return min + SQRT(u * d * (mode - min));
 	return max - SQRT((1 - u) * d * (max - mode));

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

@@ -56,7 +56,7 @@ void _AtlasPage_disposeTexture (AtlasPage* self){
 }
 
 char* _Util_readFile (const char* path, int* length){
-	return _readFile(path, length);
+	return _spReadFile(path, length);
 }
 
 /**/