PageRenderTime 22ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/project/jni/third_party/fcollada/files/FUtils/Platforms.h

https://code.google.com/p/androido3d/
C Header | 261 lines | 182 code | 42 blank | 37 comment | 22 complexity | 00ef8e0edd322019477045031e75638c MD5 | raw file
Possible License(s): LGPL-3.0, BSD-3-Clause
  1. /*
  2. Copyright (C) 2005-2007 Feeling Software Inc.
  3. Portions of the code are:
  4. Copyright (C) 2005-2007 Sony Computer Entertainment America
  5. MIT License: http://www.opensource.org/licenses/mit-license.php
  6. */
  7. /*
  8. Based on the FS Import classes:
  9. Copyright (C) 2005-2006 Feeling Software Inc
  10. Copyright (C) 2005-2006 Autodesk Media Entertainment
  11. MIT License: http://www.opensource.org/licenses/mit-license.php
  12. */
  13. #ifndef _FU_PLATFORMS_H_
  14. #define _FU_PLATFORMS_H_
  15. #ifdef FCOLLADA_DLL
  16. #ifdef WIN32
  17. // Disable the "private member not available for export" warning,
  18. // because I don't feel like writing interfaces
  19. #pragma warning(disable:4251)
  20. #ifdef FCOLLADA_INTERNAL
  21. #define FCOLLADA_EXPORT __declspec(dllexport)
  22. #define FCOLLADA_LOCAL
  23. #else
  24. #define FCOLLADA_EXPORT __declspec(dllimport)
  25. #define FCOLLADA_LOCAL
  26. #endif // FCOLLADA_INTERNAL
  27. #elif defined(__APPLE__) || defined(LINUX)
  28. #define FCOLLADA_EXPORT __attribute__((visibility("default")))
  29. #define FCOLLADA_LOCAL __attribute__((visibility("hidden")))
  30. #endif
  31. #else // FCOLLADA_DLL
  32. #define FCOLLADA_EXPORT
  33. #define FCOLLADA_LOCAL
  34. #endif // FCOLLADA_DLL
  35. #ifdef __PPU__
  36. #define UNICODE
  37. #endif // __PPU__
  38. // Ensure that both UNICODE and _UNICODE are set.
  39. #ifdef UNICODE
  40. #ifndef _UNICODE
  41. #define _UNICODE
  42. #endif
  43. #else
  44. #ifdef _UNICODE
  45. #define UNICODE
  46. #endif
  47. #endif
  48. #ifndef _INC_MATH
  49. #include <math.h>
  50. #endif // _INC_MATH
  51. #ifdef WIN32
  52. #pragma warning(disable:4702)
  53. #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
  54. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
  55. #endif
  56. #include <windows.h>
  57. #include <stdio.h>
  58. #include <wchar.h>
  59. #else
  60. #ifdef __APPLE__
  61. #include <ctype.h>
  62. #include <wctype.h>
  63. #include <unistd.h>
  64. #include <string.h>
  65. #include <wchar.h>
  66. #include <stdint.h>
  67. #else // __APPLE__
  68. #if defined(LINUX) || defined(__PPU__) || defined(__ANDROID__)
  69. #include <ctype.h>
  70. #include <wctype.h>
  71. #include <unistd.h>
  72. #include <string.h>
  73. #include <wchar.h>
  74. #include <stdarg.h>
  75. #include <malloc.h>
  76. #include <stdlib.h>
  77. #include <stdio.h>
  78. #include <stdint.h>
  79. #else // OTHER...
  80. #error "Unsupported platform."
  81. #endif // LINUX || __PPU__ || __ANDROID__
  82. #endif // __APPLE__
  83. #endif // WIN32
  84. // begin Google change (by piman@)
  85. // Comment out int* and uint* definitions, they conflict with Chrome's
  86. // definitions. Instead use the same as <base/basictypes.h>
  87. #if !defined(__APPLE__) && !defined(__ANDROID__)
  88. #include <base/basictypes.h>
  89. #else
  90. // end Google change
  91. // Cross-platform type definitions
  92. #ifdef WIN32
  93. typedef signed char int8;
  94. typedef short int16;
  95. typedef long int32;
  96. typedef __int64 int64;
  97. typedef unsigned char uint8;
  98. typedef unsigned short uint16;
  99. typedef unsigned long uint32;
  100. typedef unsigned __int64 uint64;
  101. #else // For LINUX and __APPLE__
  102. typedef int8_t int8;
  103. typedef int16_t int16;
  104. typedef int32_t int32;
  105. typedef int64_t int64;
  106. typedef uint8_t uint8;
  107. typedef uint16_t uint16;
  108. typedef uint32_t uint32;
  109. typedef uint64_t uint64;
  110. typedef uint8_t byte;
  111. #ifndef _CLIMITS_
  112. #include <climits>
  113. #endif // _CLIMITS_
  114. #endif // PLATFORMS
  115. // begin Google change (by piman@)
  116. #endif
  117. // end Google change
  118. // Important functions that some OSes have missing!
  119. #if defined(__APPLE__) || defined (LINUX) || defined(__ANDROID__)
  120. inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
  121. inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
  122. inline int wcsicmp(const wchar_t* s1, const wchar_t* s2) { wchar_t c1 = *s1, c2 = *s2; while (c1 != 0 && c2 != 0) { if (c1 >= 'a' && c1 <= 'z') c1 -= 'a' + 'A'; if (c2 >= 'a' && c2 <= 'z') c2 -= 'a' + 'A'; if (c2 < c1) return -1; else if (c2 > c1) return 1; c1 = *(++s1); c2 = *(++s2); } return 0; }
  123. #ifndef isinf
  124. #define isinf __isinff
  125. #endif
  126. #define _stricmp strcasecmp
  127. #define _getcwd getcwd
  128. #define _chdir chdir
  129. #elif defined(__PPU__)
  130. #define glClearDepth glClearDepthf
  131. #endif // __APPLE__ and LINUX and __ANDROID__
  132. // Cross-platform needed functions
  133. #ifdef WIN32
  134. #define snprintf _snprintf
  135. #define vsnwprintf _vsnwprintf
  136. #if _MSC_VER >= 1500
  137. // VC 9 doesn't like it when you define vsnprintf to be _vsnprintf
  138. #define snwprintf _snwprintf_s
  139. #elif _MSC_VER >= 1400 // VC 8
  140. #define snwprintf _snwprintf_s
  141. #define vsnprintf _vsnprintf
  142. #else
  143. #define snwprintf _snwprintf
  144. #define vsnprintf _vsnprintf
  145. #endif // _MSC_VER
  146. #define strlower _strlwr
  147. #else // WIN32
  148. #define vsnwprintf vswprintf
  149. #define snwprintf swprintf
  150. #endif // WIN32
  151. // For Doxygen purposes, we stopped using the "using namespace std;" statement and use shortcuts instead.
  152. // fstring and character definition
  153. #ifdef UNICODE
  154. #define fchar wchar_t
  155. #define FC(a) L ## a
  156. #define fstrlen wcslen
  157. #define fstrcmp wcscmp
  158. #define fstrncpy wcsncpy
  159. #define fstrrchr wcsrchr
  160. #define fstrchr wcschr
  161. #define fsnprintf snwprintf
  162. #define fvsnprintf vsnwprintf
  163. #define fstrup _wcsupr
  164. #ifdef __PPU__
  165. #define fstricmp wcscmp // [claforte] TODO: Implement __PPU__ version of wcsicmp
  166. #elif defined(WIN32)
  167. #define fstricmp _wcsicmp
  168. #else
  169. #define fstricmp wcsicmp
  170. #endif // !__PPU__
  171. #ifdef WIN32
  172. #define fstrlower _wcslwr
  173. #else
  174. #define fstrlower wcslwr
  175. #endif // WIN32
  176. #ifdef WIN32
  177. #define fchdir _tchdir
  178. #else // WIN32
  179. #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str())
  180. #endif // !WIN32
  181. #else // UNICODE
  182. typedef char fchar;
  183. #define FC(a) a
  184. #define fstrlen strlen
  185. #define fstrcmp strcmp
  186. #define fstricmp _stricmp
  187. #define fstrncpy strncpy
  188. #define fstrrchr strrchr
  189. #define fstrchr strchr
  190. #define fstrlower strlower
  191. #define fsnprintf snprintf
  192. #define fvsnprintf vsnprintf
  193. #define fstrup _strupr
  194. #define fchdir chdir
  195. #endif // UNICODE
  196. #ifndef WIN32
  197. #define MAX_PATH 1024
  198. #endif // !WIN32
  199. #ifdef WIN32
  200. //#pragma warning(disable:4324) // Don't bother me about forcing the padding of aligned structure.
  201. /** Alignment macro for classes and structures.
  202. Only supported in MSVS 2005 for now.
  203. @param byteCount The number of bytes to align to.*/
  204. //#define ALIGN_STRUCT(byteCount) __declspec(align(byteCount))
  205. #define ALIGN_STRUCT(byteCount)
  206. #else // !WIN32
  207. #define ALIGN_STRUCT(byteCount)
  208. #endif // WIN32
  209. #if defined(WIN32) && _MSC_VER >= 1400
  210. #define DEPRECATED(versionNumber, alternative) __declspec(deprecated("[" #versionNumber "] This function is now deprecated. Please use '" #alternative "' instead."))
  211. #else
  212. /** Deprecated macro for functions.
  213. Only supported in MSVS 2005 for now.
  214. @param versionNumber The version of FCollada that officially deprecated this function.
  215. @param alternative The function or class to use instead. */
  216. #define DEPRECATED(versionNumber, alternative)
  217. #endif // WIN32 && MSVS2005
  218. #endif // _FU_PLATFORMS_H_