2
0

as_config.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2011 Andreas Jonsson
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any
  6. damages arising from the use of this software.
  7. Permission is granted to anyone to use this software for any
  8. purpose, including commercial applications, and to alter it and
  9. redistribute it freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you
  11. must not claim that you wrote the original software. If you use
  12. this software in a product, an acknowledgment in the product
  13. documentation would be appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and
  15. must not be misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. The original version of this library can be located at:
  19. http://www.angelcode.com/angelscript/
  20. Andreas Jonsson
  21. [email protected]
  22. */
  23. // Modified by Lasse Öörni for Urho3D
  24. //
  25. // as_config.h
  26. //
  27. // this file is used for configuring the compilation of the library
  28. //
  29. #ifndef AS_CONFIG_H
  30. #define AS_CONFIG_H
  31. //
  32. // Features
  33. //-----------------------------------------
  34. // AS_NO_THREADS
  35. // Turns off support for multithreading. By turning off
  36. // this when it's not needed a bit of performance is gained.
  37. // AS_WINDOWS_THREADS
  38. // If the library should be compiled using windows threads.
  39. // AS_POSIX_THREADS
  40. // If the library should be compiled using posix threads.
  41. // AS_NO_ATOMIC
  42. // If the compiler/platform doesn't support atomic instructions
  43. // then this should be defined to use critical sections instead.
  44. // AS_DEBUG
  45. // This flag can be defined to make the library write some extra output when
  46. // compiling and executing scripts.
  47. // AS_DEPRECATED
  48. // If this flag is defined then some backwards compatibility is maintained.
  49. // There is no guarantee for how well deprecated functionality will work though
  50. // so it is best to exchange it for the new functionality as soon as possible.
  51. // AS_NO_CLASS_METHODS
  52. // Disables the possibility to add class methods. Can increase the
  53. // portability of the library.
  54. // AS_MAX_PORTABILITY
  55. // Disables all platform specific code. Only the asCALL_GENERIC calling
  56. // convention will be available in with this flag set.
  57. // AS_DOUBLEBYTE_CHARSET
  58. // When this flag is defined, the parser will treat all characters in strings
  59. // that are greater than 127 as lead characters and automatically include the
  60. // next character in the script without checking its value. This should be
  61. // compatible with common encoding schemes, e.g. Big5. Shift-JIS is not compatible
  62. // though as it encodes some single byte characters above 127.
  63. //
  64. // If support for international text is desired, it is recommended that UTF-8
  65. // is used as this is supported natively by the compiler without the use for this
  66. // preprocessor flag.
  67. //
  68. // Library usage
  69. //------------------------------------------
  70. // ANGELSCRIPT_EXPORT
  71. // This flag should be defined when compiling the library as a lib or dll.
  72. // ANGELSCRIPT_DLL_LIBRARY_IMPORT
  73. // This flag should be defined when using AngelScript as a dll with automatic
  74. // library import.
  75. // ANGELSCRIPT_DLL_MANUAL_IMPORT
  76. // This flag should be defined when using AngelScript as a dll with manual
  77. // loading of the library.
  78. //
  79. // Compiler differences
  80. //-----------------------------------------
  81. // asVSNPRINTF(a,b,c,d)
  82. // Some compilers use different names for this function. You must
  83. // define this macro to map to the proper function.
  84. // ASM_AT_N_T or ASM_INTEL
  85. // You should choose what inline assembly syntax to use when compiling.
  86. // VALUE_OF_BOOLEAN_TRUE
  87. // This flag allows to customize the exact value of boolean true.
  88. // AS_SIZEOF_BOOL
  89. // On some target platforms the sizeof(bool) is 4, but on most it is 1.
  90. // STDCALL
  91. // This is used to declare a function to use the stdcall calling convention.
  92. // AS_USE_NAMESPACE
  93. // Adds the AngelScript namespace on the declarations.
  94. // AS_NO_MEMORY_H
  95. // Some compilers don't come with the memory.h header file.
  96. //
  97. // How to identify different compilers
  98. //-----------------------------------------
  99. // MS Visual C++
  100. // _MSC_VER is defined
  101. // __MWERKS__ is not defined
  102. // Metrowerks
  103. // _MSC_VER is defined
  104. // __MWERKS__ is defined
  105. // GNU C based compilers
  106. // __GNUC__ is defined
  107. // Embarcadero C++Builder
  108. // __BORLANDC__ is defined
  109. //
  110. // CPU differences
  111. //---------------------------------------
  112. // AS_ALIGN
  113. // Some CPUs require that data words are aligned in some way. This macro
  114. // should be defined if the words should be aligned to boundaries of the same
  115. // size as the word, i.e.
  116. // 1 byte on 1 byte boundaries
  117. // 2 bytes on 2 byte boundaries
  118. // 4 bytes on 4 byte boundaries
  119. // 8 bytes on 4 byte boundaries (no it's not a typo)
  120. // AS_USE_DOUBLE_AS_FLOAT
  121. // If there is no 64 bit floating point type, then this constant can be defined
  122. // to treat double like normal floats.
  123. // AS_X86
  124. // Use assembler code for the x86 CPU family
  125. // AS_SH4
  126. // Use assembler code for the SH4 CPU family
  127. // AS_MIPS
  128. // Use assembler code for the MIPS CPU family
  129. // AS_PPC
  130. // Use assembler code for the 32bit PowerPC CPU family
  131. // AS_PPC_64
  132. // Use assembler code for the 64bit PowerPC CPU family
  133. // AS_XENON
  134. // Use assembler code for the Xenon (XBOX360) CPU family
  135. // AS_ARM
  136. // Use assembler code for the ARM CPU family
  137. // AS_X64_GCC
  138. // Use GCC assembler code for the X64 AMD/Intel CPU family
  139. // AS_X64_MSVC
  140. // Use MSVC assembler code for the X64 AMD/Intel CPU family
  141. // AS_64BIT_PTR
  142. // Define this to make the engine store all pointers in 64bit words.
  143. // AS_BIG_ENDIAN
  144. // Define this for CPUs that use big endian memory layout, e.g. PPC
  145. //
  146. // Target systems
  147. //--------------------------------
  148. // This group shows a few of the flags used to identify different target systems.
  149. // Sometimes there are differences on different target systems, while both CPU and
  150. // compiler is the same for both, when this is so these flags are used to produce the
  151. // right code.
  152. // AS_WIN - Microsoft Windows
  153. // AS_LINUX - Linux
  154. // AS_MAC - Apple Macintosh
  155. // AS_BSD - BSD based OS (FreeBSD, DragonFly, OpenBSD, etc)
  156. // AS_XBOX - Microsoft XBox
  157. // AS_XBOX360 - Microsoft XBox 360
  158. // AS_PSP - Sony Playstation Portable
  159. // AS_PS2 - Sony Playstation 2
  160. // AS_PS3 - Sony Playstation 3
  161. // AS_DC - Sega Dreamcast
  162. // AS_GC - Nintendo GameCube
  163. // AS_WII - Nintendo Wii
  164. // AS_IPHONE - Apple IPhone
  165. // AS_ANDROID - Android
  166. // AS_HAIKU - Haiku
  167. // AS_ILLUMOS - Illumos like (OpenSolaris, OpenIndiana, NCP, etc)
  168. //
  169. // Calling conventions
  170. //-----------------------------------------
  171. // GNU_STYLE_VIRTUAL_METHOD
  172. // This constant should be defined if method pointers store index for virtual
  173. // functions in the same location as the function pointer. In such cases the method
  174. // is identified as virtual if the least significant bit is set.
  175. // MULTI_BASE_OFFSET(x)
  176. // This macro is used to retrieve the offset added to the object pointer in order to
  177. // implicitly cast the object to the base object. x is the method pointer received by
  178. // the register function.
  179. // HAVE_VIRTUAL_BASE_OFFSET
  180. // Define this constant if the compiler stores the virtual base offset in the method
  181. // pointers. If it is not stored in the pointers then AngelScript have no way of
  182. // identifying a method as coming from a class with virtual inheritance.
  183. // VIRTUAL_BASE_OFFSET(x)
  184. // This macro is used to retrieve the offset added to the object pointer in order to
  185. // find the virtual base object. x is the method pointer received by the register
  186. // function;
  187. // COMPLEX_RETURN_MASK
  188. // This constant shows what attributes determine if an object is returned in memory
  189. // or in the registers as normal structures
  190. // COMPLEX_MASK
  191. // This constant shows what attributes determine if an object is implicitly passed
  192. // by reference or not, even if the argument is declared by value
  193. // THISCALL_RETURN_SIMPLE_IN_MEMORY
  194. // CDECL_RETURN_SIMPLE_IN_MEMORY
  195. // STDCALL_RETURN_SIMPLE_IN_MEMORY
  196. // When these constants are defined then the corresponding calling convention always
  197. // return classes/structs in memory regardless of size or complexity.
  198. // THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  199. // STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  200. // CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  201. // Specifies the minimum size in dwords a class/struct needs to be to be passed in memory
  202. // CALLEE_POPS_HIDDEN_RETURN_POINTER
  203. // This constant should be defined if the callee pops the hidden return pointer,
  204. // used when returning an object in memory.
  205. // THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  206. // This constant should be defined if the callee pops the hidden return pointer
  207. // for thiscall functions; used when returning an object in memory.
  208. // THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  209. // With this constant defined AngelScript will pass the object pointer on the stack
  210. // THISCALL_CALLEE_POPS_ARGUMENTS
  211. // If the callee pops arguments for class methods then define this constant
  212. // COMPLEX_OBJS_PASSED_BY_REF
  213. // Some compilers always pass certain objects by reference. GNUC for example does
  214. // this if the the class has a defined destructor.
  215. // AS_LARGE_OBJS_PASSED_BY_REF
  216. // If this is defined large objects are passed by reference, whether they are complex or not
  217. // AS_LARGE_OBJ_MIN_SIZE
  218. // This is the size of objects determined as large ones
  219. // AS_CALLEE_DESTROY_OBJ_BY_VAL
  220. // When an object is passed by value the called function is the one responsible
  221. // for calling the destructor before returning.
  222. // HAS_128_BIT_PRIMITIVES
  223. // 64bit processors often support 128bit primitives. These may require special
  224. // treatment when passed in function arguments or returned by functions.
  225. // SPLIT_OBJS_BY_MEMBER_TYPES
  226. // On some platforms objects with primitive members are split over different
  227. // register types when passed by value to functions.
  228. //
  229. // Detect compiler
  230. //------------------------------------------------
  231. #define VALUE_OF_BOOLEAN_TRUE 1
  232. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  233. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  234. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  235. #define THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  236. // Embarcadero C++Builder
  237. #if defined(__BORLANDC__)
  238. #ifndef _Windows
  239. #error "Configuration doesn't yet support BCC for Linux or Mac OS."
  240. #endif
  241. #if defined(_M_X64)
  242. #error "Configuration doesn't yet support BCC for AMD64."
  243. #endif
  244. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  245. #define HAVE_VIRTUAL_BASE_OFFSET
  246. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  247. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  248. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  249. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  250. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  251. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  252. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  253. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  254. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  255. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  256. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  257. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  258. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  259. #define STDCALL __stdcall
  260. #define AS_SIZEOF_BOOL 1
  261. #define AS_WINDOWS_THREADS
  262. #undef THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  263. #define AS_WIN
  264. #define AS_X86
  265. #define ASM_INTEL
  266. #define I64(x) x##ll
  267. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  268. #define fmodf(a,b) fmod(a,b)
  269. #define UNREACHABLE_RETURN
  270. #endif
  271. // Microsoft Visual C++
  272. #if defined(_MSC_VER) && !defined(__MWERKS__)
  273. #ifdef _M_X64
  274. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  275. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+4))
  276. #else
  277. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  278. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  279. #endif
  280. #define HAVE_VIRTUAL_BASE_OFFSET
  281. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  282. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  283. #if _MSC_VER < 1500 // MSVC++ 9 (aka MSVC++ .NET 2008)
  284. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  285. #else
  286. #define asVSNPRINTF(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
  287. #endif
  288. #define THISCALL_CALLEE_POPS_ARGUMENTS
  289. #define STDCALL __stdcall
  290. #define AS_SIZEOF_BOOL 1
  291. #define AS_WINDOWS_THREADS
  292. #define ASM_INTEL // Intel style for inline assembly on microsoft compilers
  293. #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
  294. #define AS_WIN
  295. #endif
  296. #if _XBOX_VER >= 200
  297. // 360 uses a Xenon processor (which is a modified 64bit PPC)
  298. #define AS_XBOX360
  299. #define AS_XENON
  300. #define AS_BIG_ENDIAN
  301. #else
  302. #if defined(_XBOX) || (defined(_M_IX86) && !defined(__LP64__))
  303. #define AS_X86
  304. #elif defined(_M_X64)
  305. #define AS_X64_MSVC
  306. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  307. #define AS_LARGE_OBJS_PASSED_BY_REF
  308. #define AS_LARGE_OBJ_MIN_SIZE 3
  309. #define COMPLEX_OBJS_PASSED_BY_REF
  310. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  311. #define COMPLEX_MASK (asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  312. #endif
  313. #endif
  314. #if _MSC_VER <= 1300 // MSVC++ 7.0 and lower
  315. #define I64(x) x##l
  316. #else // MSVC++ 7.1 and higher
  317. #define I64(x) x##ll
  318. #endif
  319. #ifdef _ARM_
  320. #define AS_ALIGN
  321. #define AS_ARM
  322. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  323. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  324. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  325. #define COMPLEX_OBJS_PASSED_BY_REF
  326. #define COMPLEX_MASK asOBJ_APP_CLASS_ASSIGNMENT
  327. #define COMPLEX_RETURN_MASK asOBJ_APP_CLASS_ASSIGNMENT
  328. #endif
  329. #ifndef COMPLEX_MASK
  330. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  331. #endif
  332. #ifndef COMPLEX_RETURN_MASK
  333. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  334. #endif
  335. #define UNREACHABLE_RETURN
  336. #endif
  337. // Metrowerks CodeWarrior (experimental, let me know if something isn't working)
  338. #if defined(__MWERKS__) && !defined(EPPC) // JWC -- If Wii DO NOT use this even when using Metrowerks Compiler. Even though they are called Freescale...
  339. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  340. #define HAVE_VIRTUAL_BASE_OFFSET
  341. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  342. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  343. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  344. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  345. #define THISCALL_CALLEE_POPS_ARGUMENTS
  346. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  347. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  348. #define AS_SIZEOF_BOOL 1
  349. #define AS_WINDOWS_THREADS
  350. #define STDCALL __stdcall
  351. // Support native calling conventions on x86, but not 64bit yet
  352. #if defined(_M_IX86) && !defined(__LP64__)
  353. #define AS_X86
  354. #define ASM_INTEL // Intel style for inline assembly
  355. #endif
  356. #if _MSC_VER <= 1300 // MSVC++ 7.0 and lower
  357. #define I64(x) x##l
  358. #else // MSVC++ 7.1 and higher
  359. #define I64(x) x##ll
  360. #endif
  361. #define UNREACHABLE_RETURN
  362. #endif
  363. // SN Systems ProDG (also experimental, let me know if something isn't working)
  364. #if defined(__SNC__) || defined(SNSYS)
  365. #define GNU_STYLE_VIRTUAL_METHOD
  366. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  367. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  368. #define COMPLEX_OBJS_PASSED_BY_REF
  369. #define ASM_AT_N_T // AT&T style inline assembly
  370. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  371. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  372. #define AS_SIZEOF_BOOL 1
  373. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  374. // SN doesnt seem to like STDCALL.
  375. // Maybe it can work with some fiddling, but I can't imagine linking to
  376. // any STDCALL functions with a console anyway...
  377. #define STDCALL
  378. // Linux specific
  379. #ifdef __linux__
  380. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  381. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  382. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  383. #endif
  384. // Support native calling conventions on x86, but not 64bit yet
  385. #if defined(i386) && !defined(__LP64__)
  386. #define AS_X86
  387. // PS3
  388. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  389. // Support native calling conventions on PS3
  390. #define AS_PS3
  391. #define AS_PPC_64
  392. #endif
  393. #define I64(x) x##ll
  394. #define UNREACHABLE_RETURN
  395. #endif
  396. // GNU C (and MinGW or Cygwin on Windows)
  397. #if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
  398. #define GNU_STYLE_VIRTUAL_METHOD
  399. #if !defined( __amd64__ )
  400. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  401. #else
  402. #define MULTI_BASE_OFFSET(x) (*((asQWORD*)(&x)+1))
  403. #endif
  404. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  405. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  406. #define COMPLEX_OBJS_PASSED_BY_REF
  407. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  408. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  409. #define AS_NO_MEMORY_H
  410. #define AS_SIZEOF_BOOL 1
  411. #define STDCALL __attribute__((stdcall))
  412. #define ASM_AT_N_T
  413. // MacOSX and IPhone
  414. #ifdef __APPLE__
  415. // Is this a Mac or an IPhone?
  416. #ifdef TARGET_OS_IPHONE
  417. #define AS_IPHONE
  418. #else
  419. #define AS_MAC
  420. #endif
  421. // The sizeof bool is different depending on the target CPU
  422. #undef AS_SIZEOF_BOOL
  423. #if defined(__ppc__)
  424. #define AS_SIZEOF_BOOL 4
  425. // STDCALL is not available on PPC
  426. #undef STDCALL
  427. #define STDCALL
  428. #else
  429. #define AS_SIZEOF_BOOL 1
  430. #endif
  431. #if defined(i386) && !defined(__LP64__)
  432. // Support native calling conventions on Mac OS X + Intel 32bit CPU
  433. #define AS_X86
  434. #undef COMPLEX_MASK
  435. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  436. #undef COMPLEX_RETURN_MASK
  437. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  438. #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__)
  439. // http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/LowLevelABI/140-x86-64_Function_Calling_Conventions/x86_64.html#//apple_ref/doc/uid/TP40005035-SW1
  440. #define AS_NO_THREADS
  441. #define AS_X64_GCC
  442. #define HAS_128_BIT_PRIMITIVES
  443. #define SPLIT_OBJS_BY_MEMBER_TYPES
  444. #undef COMPLEX_MASK
  445. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  446. #undef COMPLEX_RETURN_MASK
  447. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  448. // STDCALL is not available on 64bit Mac
  449. #undef STDCALL
  450. #define STDCALL
  451. #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
  452. // Support native calling conventions on Mac OS X + PPC 32bit CPU
  453. #define AS_PPC
  454. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  455. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  456. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  457. #undef COMPLEX_MASK
  458. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  459. #undef COMPLEX_RETURN_MASK
  460. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  461. #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
  462. #define AS_PPC_64
  463. #elif (defined(_ARM_) || defined(__arm__))
  464. // The IPhone use an ARM processor
  465. #define AS_ARM
  466. #define AS_IPHONE
  467. #define AS_ALIGN
  468. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  469. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  470. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  471. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  472. #undef GNU_STYLE_VIRTUAL_METHOD
  473. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  474. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  475. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  476. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  477. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  478. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  479. #define COMPLEX_OBJS_PASSED_BY_REF
  480. #undef COMPLEX_MASK
  481. #define COMPLEX_MASK asOBJ_APP_CLASS_DESTRUCTOR
  482. #undef COMPLEX_RETURN_MASK
  483. #define COMPLEX_RETURN_MASK asOBJ_APP_CLASS_DESTRUCTOR
  484. #else
  485. // Unknown CPU type
  486. #define AS_MAX_PORTABILITY
  487. #endif
  488. #define AS_POSIX_THREADS
  489. // Windows
  490. #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
  491. // On Windows the simple classes are returned in the EAX:EDX registers
  492. //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
  493. //#define CDECL_RETURN_SIMPLE_IN_MEMORY
  494. //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
  495. #undef COMPLEX_MASK
  496. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  497. #undef COMPLEX_RETURN_MASK
  498. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  499. #if defined(i386) && !defined(__LP64__)
  500. // Support native calling conventions on Intel 32bit CPU
  501. #define AS_X86
  502. #elif defined(__x86_64__)
  503. #define AS_X64_MINGW
  504. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  505. #define AS_LARGE_OBJS_PASSED_BY_REF
  506. #define AS_LARGE_OBJ_MIN_SIZE 3
  507. #define COMPLEX_OBJS_PASSED_BY_REF
  508. #else
  509. #define AS_MAX_PORTABILITY
  510. #endif
  511. #define AS_WIN
  512. #define AS_WINDOWS_THREADS
  513. // Linux
  514. #elif defined(__linux__)
  515. #if defined(i386) && !defined(__LP64__)
  516. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  517. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  518. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  519. #undef COMPLEX_MASK
  520. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  521. #undef COMPLEX_RETURN_MASK
  522. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  523. // Support native calling conventions on Intel 32bit CPU
  524. #define AS_X86
  525. #elif defined(__LP64__)
  526. #define AS_X64_GCC
  527. #define HAS_128_BIT_PRIMITIVES
  528. #define SPLIT_OBJS_BY_MEMBER_TYPES
  529. #undef COMPLEX_MASK
  530. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  531. #undef COMPLEX_RETURN_MASK
  532. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  533. // STDCALL is not available on 64bit Linux
  534. #undef STDCALL
  535. #define STDCALL
  536. #elif defined(__ARMEL__) || defined(__arm__)
  537. #define AS_ARM
  538. #define AS_ALIGN
  539. #define AS_NO_ATOMIC
  540. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  541. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  542. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  543. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  544. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  545. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  546. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  547. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  548. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  549. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  550. #else
  551. #define AS_MAX_PORTABILITY
  552. #endif
  553. #define AS_LINUX
  554. #define AS_POSIX_THREADS
  555. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  556. // Only with GCC 4.1 was the atomic instructions available
  557. #define AS_NO_ATOMIC
  558. #endif
  559. // Free BSD
  560. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  561. #define AS_BSD
  562. #if defined(i386) && !defined(__LP64__)
  563. #undef COMPLEX_MASK
  564. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  565. #undef COMPLEX_RETURN_MASK
  566. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  567. #define AS_X86
  568. #elif defined(__LP64__)
  569. #define AS_X64_GCC
  570. #define HAS_128_BIT_PRIMITIVES
  571. #define SPLIT_OBJS_BY_MEMBER_TYPES
  572. #undef COMPLEX_MASK
  573. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  574. #undef COMPLEX_RETURN_MASK
  575. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  576. #undef STDCALL
  577. #define STDCALL
  578. #else
  579. #define AS_MAX_PORTABILITY
  580. #endif
  581. #define AS_POSIX_THREADS
  582. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  583. // Only with GCC 4.1 was the atomic instructions available
  584. #define AS_NO_ATOMIC
  585. #endif
  586. // PSP and PS2
  587. #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  588. // Support native calling conventions on MIPS architecture
  589. #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
  590. #define AS_MIPS
  591. #else
  592. #define AS_MAX_PORTABILITY
  593. #endif
  594. // PS3
  595. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  596. // Support native calling conventions on PS3
  597. #define AS_PS3
  598. #define AS_PPC_64
  599. #define SPLIT_OBJS_BY_MEMBER_TYPES
  600. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  601. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  602. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  603. // PS3 doesn't have STDCALL
  604. #undef STDCALL
  605. #define STDCALL
  606. // Dreamcast
  607. #elif __SH4_SINGLE_ONLY__
  608. // Support native calling conventions on Dreamcast
  609. #define AS_DC
  610. #define AS_SH4
  611. // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
  612. #elif defined(EPPC)
  613. #define AS_WII
  614. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  615. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  616. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  617. #undef STDCALL
  618. #define STDCALL
  619. // Android
  620. #elif defined(ANDROID)
  621. #define AS_ANDROID
  622. #define AS_NO_ATOMIC
  623. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  624. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  625. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  626. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  627. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  628. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  629. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  630. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  631. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  632. #if (defined(_ARM_) || defined(__arm__))
  633. #define AS_ARM
  634. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  635. #define AS_ALIGN
  636. #endif
  637. // Haiku OS
  638. #elif __HAIKU__
  639. #define AS_HAIKU
  640. // Only x86-32 is currently supported by Haiku, but they do plan to support
  641. // x86-64 and PowerPC in the future, so should go ahead and check the platform
  642. // for future compatibility
  643. #if defined(i386) && !defined(__LP64__)
  644. #define AS_X86
  645. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  646. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  647. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  648. #else
  649. #define AS_MAX_PORTABILITY
  650. #endif
  651. #define AS_POSIX_THREADS
  652. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  653. // Only with GCC 4.1 was the atomic instructions available
  654. #define AS_NO_ATOMIC
  655. #endif
  656. // Illumos
  657. #elif defined(__sun)
  658. #if defined(__i386__) && !defined(__LP64__)
  659. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  660. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  661. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  662. // Support native calling conventions on Intel 32bit CPU
  663. #define AS_X86
  664. #elif defined(__LP64__)
  665. #define AS_X64_GCC
  666. #define HAS_128_BIT_PRIMITIVES
  667. #define SPLIT_OBJS_BY_MEMBER_TYPES
  668. // STDCALL is not available on 64bit Linux
  669. #undef STDCALL
  670. #define STDCALL
  671. #else
  672. #define AS_MAX_PORTABILITY
  673. #endif
  674. #define AS_ILLUMOS
  675. #define AS_POSIX_THREADS
  676. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  677. // Only with GCC 4.1 was the atomic instructions available
  678. #define AS_NO_ATOMIC
  679. #endif
  680. #endif
  681. #define I64(x) x##ll
  682. #define UNREACHABLE_RETURN
  683. #endif
  684. //
  685. // Detect target hardware
  686. //------------------------------------------------
  687. // X86, Intel, AMD, etc, i.e. most PCs
  688. #if defined(__i386__) || defined(_M_IX86)
  689. // Nothing special here
  690. #endif
  691. // MIPS architecture (generally PS2 and PSP consoles, potentially supports N64 as well)
  692. #if defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__) || defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  693. #define AS_ALIGN // align datastructures
  694. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  695. #endif
  696. // PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
  697. #if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
  698. #define AS_BIG_ENDIAN
  699. // Gamecube
  700. #if defined(_GC)
  701. #define AS_ALIGN
  702. #define AS_USE_DOUBLE_AS_FLOAT
  703. #endif
  704. // XBox 360
  705. #if (_XBOX_VER >= 200 )
  706. #define AS_ALIGN
  707. #endif
  708. // PS3
  709. #if defined(__PPU__)
  710. #define AS_ALIGN
  711. #endif
  712. // Wii
  713. #if defined(EPPC)
  714. #define AS_ALIGN
  715. #endif
  716. #endif
  717. // Dreamcast console
  718. #ifdef __SH4_SINGLE_ONLY__
  719. #define AS_ALIGN // align datastructures
  720. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  721. #endif
  722. // Is the target a 64bit system?
  723. #if defined(__LP64__) || defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
  724. #ifndef AS_64BIT_PTR
  725. #define AS_64BIT_PTR
  726. #endif
  727. #endif
  728. // If there are no current support for native calling
  729. // conventions, then compile with AS_MAX_PORTABILITY
  730. #if (!defined(AS_X86) && !defined(AS_SH4) && !defined(AS_MIPS) && !defined(AS_PPC) && !defined(AS_PPC_64) && !defined(AS_XENON) && !defined(AS_X64_GCC) && !defined(AS_X64_MSVC) && !defined(AS_ARM) && !defined(AS_X64_MINGW))
  731. #ifndef AS_MAX_PORTABILITY
  732. #define AS_MAX_PORTABILITY
  733. #endif
  734. #endif
  735. // If the form of threads to use hasn't been chosen
  736. // then the library will be compiled without support
  737. // for multithreading
  738. #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
  739. #define AS_NO_THREADS
  740. #endif
  741. // Urho3D: always use float type, use EMMS to clear FPU stack
  742. #define AS_USE_DOUBLE_AS_FLOAT
  743. #define CLEAR_FPU_STACK emms
  744. // The assert macro
  745. #if defined(ANDROID)
  746. #if defined(AS_DEBUG)
  747. #include <android/log.h>
  748. #include <stdlib.h>
  749. #define asASSERT(x) \
  750. do { \
  751. if (!(x)) { \
  752. __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
  753. exit(1); \
  754. } \
  755. } while (0)
  756. #else
  757. #define asASSERT(x)
  758. #endif
  759. #else
  760. #include <assert.h>
  761. #define asASSERT(x) assert(x)
  762. #endif
  763. //
  764. // Internal defines (do not change these)
  765. //----------------------------------------------------------------
  766. #ifdef AS_ALIGN
  767. #define ALIGN(b) (((b)+3)&(~3))
  768. #else
  769. #define ALIGN(b) (b)
  770. #endif
  771. #define ARG_W(b) ((asWORD*)&b)
  772. #define ARG_DW(b) ((asDWORD*)&b)
  773. #define ARG_QW(b) ((asQWORD*)&b)
  774. #define BCARG_W(b) ((asWORD*)&(b)[1])
  775. #define BCARG_DW(b) ((asDWORD*)&(b)[1])
  776. #define BCARG_QW(b) ((asQWORD*)&(b)[1])
  777. #ifdef AS_64BIT_PTR
  778. #define AS_PTR_SIZE 2
  779. #define asPTRWORD asQWORD
  780. #define asBC_RDSPTR asBC_RDS8
  781. #else
  782. #define AS_PTR_SIZE 1
  783. #define asPTRWORD asDWORD
  784. #define asBC_RDSPTR asBC_RDS4
  785. #endif
  786. #define ARG_PTR(b) ((asPTRWORD*)&b)
  787. #define BCARG_PTR(b) ((asPTRWORD*)&(b)[1])
  788. // This macro is used to avoid warnings about unused variables.
  789. // Usually where the variables are only used in debug mode.
  790. #define UNUSED_VAR(x) (x)=(x)
  791. #include "../include/angelscript.h"
  792. #include "as_memory.h"
  793. #ifdef AS_USE_NAMESPACE
  794. using namespace AngelScript;
  795. #endif
  796. #endif