You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2470 lines
126KB

  1. /// ----
  2. /// ---- file : yac.h
  3. /// ----
  4. /// ---- author : (c) 2003 - 2018 by bsp
  5. /// ----
  6. /// ---- date : 21-Nov-2003 / 8-Jun-2003 / 1-Aug-2003 / 24-Dec-2003 / 15-Jan-2004 / 9-Feb-2004 /
  7. /// ---- 17-Feb-2004 / 19-Feb-2004 / 28-Feb-2004 / 26-Mar-2004 / 27-Mar-2004 / 19-Sep-2004 /
  8. /// ---- 05-Nov-2004 / 06-Nov-2004 / 26-Dec-2004 / 9-Jan-2005 / 16-Jan-2005 / 05-Feb-2005 /
  9. /// ---- 14-Feb-2005 / 24-Feb-2005 / 27-Feb-2005 / 12-Mar-2005 / 13-Jun-2005 / 16-Jun-2005
  10. /// ---- 27-Jun-2005 / 22-Aug-2005 / 27-Aug-2005 / 05-Sep-2005 / 11-Sep-2005 / 28-Nov-2005
  11. /// ---- 13-Jan-2006 / 14-Jan-2006 / 04-Feb-2006 / 07-Feb-2006 / 25-Apr-2006 / 13-Mai-2006
  12. /// ---- 19-Jan-2008 / 31-Jan-2008 / 01-Feb-2008 / 04-Feb-2008 / 11-Feb-2008 / 18-Feb-2008
  13. /// ---- 24-Feb-2008 / 25-Feb-2008 / 28-Feb-2008 / 05-Mar-2008 / 22-Mar-2008 / 14-Sep-2008
  14. /// ---- 08-Jan-2009 / 10-Jan-2009 / 31-Jan-2009 / 05-Mar-2009 / 01-Apr-2009 / 03-Apr-2009
  15. /// ---- 17-Apr-2009 / 28-Apr-2009 / 04-May-2009 / 01-Jun-2009 / 22-Apr-2010 / 11-Jul-2010
  16. /// ---- 25-Sep-2010 / 01-Oct-2010 / 21-Apr-2011 / 21-Dec-2012 / 04-Jun-2013 / 13-Aug-2013
  17. /// ---- 24-Aug-2013 / 05-Feb-2014 / 11-Feb-2014 / 03-Mar-2014 / 07-Apr-2018 / 26-Jun-2018
  18. /// ----
  19. /// ---- info : YAC - Yet Another Component object model. YAC is a self contained, binary level
  20. /// ---- C++ component/reflectance model and plugin SDK.
  21. /// ---- YAC is accompanied by YInG- the YAC interface generator.
  22. /// ---- YInG and YAC can be used to e.g. extend the TKScript language by new ADTs.
  23. /// ----
  24. /// ---- The YAC_Object and YAC_Host classes basically define a virtual table
  25. /// ---- setup that has to be used on both host and plugin sides.
  26. /// ----
  27. /// ---- By deriving an extension class from the YAC_Object class, the extension
  28. /// ---- class inherits the YAC_Object virtual table and can now overwrite
  29. /// ---- vtable entries (e.g. by declaring a yacMethodGetAdr() method) so
  30. /// ---- when the plugin host calls this vtable entry the yacMethodGetAdr() method
  31. /// ---- of your extension class is actually called (instead of the 'stub' included
  32. /// ---- in this header file)
  33. /// ----
  34. /// ---- Vice versa, the YAC_Host interface can be used to implement a new application
  35. /// ---- host that handles the registration/instanciation of new YAC_Object classes.
  36. /// ---- Usually, the TKScript engine takes care of this but you are free to implement
  37. /// ---- your own plugin hosts (e.g. for testing/debugging new libraries).
  38. /// ----
  39. /// ---- ack : thanks to Chaos^fr for his s* datatypes, limits,
  40. /// ---- sABS- macros and vector/matrix classes (included with the tkoldmath plugin).
  41. /// ----
  42. /// ---- license: MIT. See LICENSE.txt.
  43. /// ----
  44. /// ----
  45. #ifndef __YAC_H__
  46. #define __YAC_H__
  47. #include <stdio.h>
  48. #include <string.h>
  49. #include <stdarg.h>
  50. /// Define in the project/makefile to disable the use of thread local storage
  51. /* #define YAC_FORCE_NO_TLS defined */
  52. // ----
  53. // ---- Version number
  54. // ----
  55. #define YAC_VERSION_MAJOR 916
  56. #define YAC_VERSION_MINOR 2
  57. // ----
  58. // ---- Configuration
  59. // ----
  60. #ifndef YAC_PRINTF
  61. /// ---- Define if you want a YAC_Host::printf() tool function
  62. #define YAC_PRINTF defined
  63. #endif
  64. /// ---- Define if you want printf(), append(),... methods in the YAC_String class
  65. #ifndef YAC_BIGSTRING
  66. #define YAC_BIGSTRING defined
  67. #endif // YAC_BIGSTRING
  68. /// ---- Adds validation tag to YAC_Object class (yac_host must support this, too!!).
  69. /// ---- This makes it possible to detect double-free'd objects, not only zero-pointers.
  70. #define YAC_OBJECT_TAGS defined
  71. /// ---- Adds static object_counter field to YAC_Object class
  72. #define YAC_OBJECT_COUNTER defined
  73. /// ---- Adds YAC interface to the YAC_Object class
  74. #define YAC_OBJECT_YAC defined
  75. /// ---- Define to enable object pooling
  76. #define YAC_OBJECT_POOL defined
  77. /// ---- Define to use placement new to initialize pooled objects. If not defined, copy vtable* and call constructors.
  78. /// ---- Note: GCC does not allow C::C() so keep this defined if you use GCC!
  79. #define YAC_PLACEMENT_NEW defined
  80. /// ---- Define to use a custom global new/delete replacement
  81. /// ---- This is mainly useful for debugging memory allocations.
  82. /// ---- The global var "yac_global_newdelete_counter" tracks the total number of bytes currently allocated via
  83. /// ---- the global new/delete operators. This also includes the total size of all ObjectPools, regardless of how many
  84. /// ---- pool elements are actually in use. The counter also includes all memory allocated/freed in a plugin via new/delete.
  85. /// ---- Please make sure that your plugin does not call new/delete before YAC_Init() has been called and the
  86. /// ---- yac_host variable has been set.
  87. /// ---- Please re-compile all plugins plus the YAC_Host if you change this setting.
  88. /// ---- There might be issues with new/delete being called before yac_host is set so be careful.
  89. //#define YAC_GLOBAL_NEWDELETE defined
  90. /// ---- Define to define Dflt*_abs and Ddbl*_abs macros, helpful to epsilon compare float/double values
  91. /// ---- Please define this in your plugin sources if you need it
  92. //#define YAC_EPSILONCOMPARE_ABS defined
  93. /// ---- Define to use absolute epsilon float comparisons by default (also requires YAC_EPSILONCOMPARE_ABS)
  94. /// ---- Note: Only one of YAC_EPSILONCOMPARE_ABS_DEFAULT and YAC_EPSILONCOMPARE_REL_DEFAULT may be enabled
  95. //#define YAC_EPSILONCOMPARE_ABS_DEFAULT defined
  96. /// ---- Define to define Dflt*_rel and Ddbl*_rel macros, helpful to epsilon compare float/double values
  97. //#define YAC_EPSILONCOMPARE_REL defined
  98. /// ---- Define to use relative epsilon float comparisons by default (also requires YAC_EPSILONCOMPARE_REL)
  99. //#define YAC_EPSILONCOMPARE_REL_DEFAULT defined
  100. /// ---- Define to give YAC_TypeS, YAC_ValueS a vtable
  101. /// ---- This is used to satisfy the Intel C++ compiler, i.e. to get no warnings
  102. /// ---- when classes with virtual methods are derived from this class/YAC_Value)
  103. /// ---- If you change this define, make sure to recompile the host and all plugins
  104. /// ---- since the member offsets will shift.
  105. //#define YAC_VIRTUAL_VALUE defined
  106. //
  107. //#define YAC_NO_EXPORTS defined
  108. //
  109. /// ---- Define if you want to re-implement the YAC_Object YAC interface (custom YAC_Hosts)
  110. //#define YAC_CUST_OBJECT defined
  111. //#define YAC_CUST_STRING defined // define to skip declaration of the YAC_String and YAC_StringArray class.
  112. //#define YAC_CUST_EVENT defined // define to skip declaration of the YAC_Event class.
  113. //#define YAC_CUST_VALUE defined // define to skip declaration of the YAC_Value,
  114. // YAC_ValueObject and YAC_ValueArray classes.
  115. //#define YAC_CUST_NUMBEROBJECTS defined // define to skip the declaration of the YAC_Integer, YAC_Float, YAC_Byte... classes
  116. //#define YAC_CUST_LISTNODE defined // define to skip declaration of the YAC_ListNode class.
  117. //#define YAC_CUST_TREENODE defined // define to skip declaration of the YAC_TreeNode class.
  118. //#define YAC_CUST_STREAMBASE defined // define to skip declaration of the YAC_StreamBase class.
  119. //#define YAC_CUST_BUFFER defined // define to skip declaration of the YAC_Buffer class.
  120. //#define YAC_CUST_INTARRAY defined // define to skip declaration of the YAC_IntArray class.
  121. //#define YAC_CUST_FLOATARRAY defined // define to skip declaration of the YAC_FloatArray class.
  122. //#define YAC_TRACK_CHARALLOC defined // define to keep track of total amount of allocated string chars
  123. // ----
  124. // ----
  125. // ---- capability flags for an object class ----
  126. // ----
  127. // ----
  128. typedef enum __yac_interfaces {
  129. YAC_INTERFACE_REFLECTION = (1<<0),
  130. YAC_INTERFACE_OPERATOR = (1<<1),
  131. YAC_INTERFACE_STREAM = (1<<2),
  132. YAC_INTERFACE_SERIALIZATION = (1<<3),
  133. YAC_INTERFACE_ITERATOR = (1<<4),
  134. YAC_INTERFACE_ARRAY = (1<<5),
  135. YAC_INTERFACE_METACLASS = (1<<6),
  136. YAC_INTERFACE_SIGNALS = (1<<7),
  137. YAC_INTERFACE_ALL = 0xFF
  138. } e_yac_interfaces;
  139. // ----
  140. // ----
  141. // ---- capability flags for the application host ----
  142. // ----
  143. // ----
  144. typedef enum __yac_host_interfaces {
  145. YAC_HOST_INTERFACE_REFLECTION = (1<<0),
  146. YAC_HOST_INTERFACE_DEBUG = (1<<1),
  147. YAC_HOST_INTERFACE_STRING = (1<<2),
  148. YAC_HOST_INTERFACE_SCRIPTING = (1<<3),
  149. YAC_HOST_INTERFACE_EVENT = (1<<4),
  150. YAC_HOST_INTERFACE_EXCEPTION = (1<<5),
  151. YAC_HOST_INTERFACE_CALLBACK = (1<<6),
  152. YAC_HOST_INTERFACE_MUTEX = (1<<7),
  153. YAC_HOST_INTERFACE_ALL = 0xFF
  154. } e_yac_host_interfaces;
  155. // ----
  156. // ----
  157. // ---- OS detection
  158. // ----
  159. // ----
  160. // ---- Linux ?
  161. #ifdef __linux__
  162. #ifndef YAC_LINUX
  163. #define YAC_LINUX defined
  164. #endif // YAC_LINUX
  165. #define YAC_POSIX defined
  166. #define YAC_OSNAME "linux"
  167. #endif
  168. // ---- Amiga OS ?
  169. #ifdef AMIGA
  170. #ifndef YAC_AMIGA
  171. #define YAC_AMIGA defined
  172. #endif // YAC_AMIGA
  173. #define YAC_OSNAME "c= amiga"
  174. #endif
  175. // ---- QNX ?
  176. #if defined(__QNXNTO__)
  177. #ifndef YAC_QNX
  178. #define YAC_QNX defined
  179. #endif // YAC_QNX
  180. #define YAC_OSNAME "qnx"
  181. #define YAC_POSIX defined
  182. #endif
  183. // ---- OS/2 ?
  184. #ifdef OS2
  185. #ifndef YAC_OS2
  186. #define YAC_OS2 defined
  187. #endif // YAC_OS2
  188. #define YAC_OSNAME "os/2"
  189. #endif
  190. // ---- Win32 ?
  191. #ifdef _WIN32
  192. #ifndef WIN32
  193. #define WIN32
  194. #endif
  195. #endif
  196. #ifdef WIN32
  197. #ifndef YAC_WIN32
  198. #define YAC_WIN32 defined
  199. #endif // YAC_WIN32
  200. #define YAC_OSNAME "win32"
  201. #ifdef _MSC_VER
  202. #define YAC_VC defined
  203. #endif
  204. #endif
  205. // ---- MS/DOS ?
  206. #ifdef MSDOS
  207. #ifndef YAC_MSDOS
  208. #define YAC_MSDOS defined
  209. #endif // YAC_MSDOS
  210. #define YAC_OSNAME "msdos (compatible)"
  211. #endif
  212. // ---- BSD ? (untested)
  213. #ifdef BSD
  214. #ifndef YAC_BSD
  215. #define YAC_BSD defined
  216. #endif // YAC_BSD
  217. #define YAC_POSIX defined
  218. #define YAC_OSNAME "bsd"
  219. #endif
  220. // ---- MacOsX ? (untested)
  221. #ifdef __APPLE__
  222. #ifndef YAC_MACOSX
  223. #define YAC_MACOSX defined
  224. #endif // YAC_MACOSX
  225. #define YAC_POSIX defined
  226. #define YAC_BIG_ENDIAN defined
  227. #define YAC_OSNAME "macosx"
  228. #endif
  229. // ---- NeXT ? (untested)
  230. #ifdef NeXT
  231. #ifndef YAC_NEXT
  232. #define YAC_NEXT defined
  233. #endif // YAC_NEXT
  234. #define YAC_OSNAME "NeXT"
  235. #endif
  236. // ---- Unknown OS.. please report..
  237. #if !defined(YAC_OSNAME)
  238. #ifdef __unix__
  239. #define YAC_UNIX defined
  240. #define YAC_POSIX defined
  241. #define YAC_OSNAME "unix"
  242. #else
  243. #ifdef SYSV
  244. #define YAC_UNIX defined
  245. #define YAC_POSIX defined
  246. #define YAC_OSNAME "sysv"
  247. #else
  248. #define YAC_OSNAME "unknown"
  249. #endif
  250. #endif
  251. #endif
  252. #ifdef __CYGWIN32__
  253. #define YAC_CYGWIN defined
  254. #undef YAC_FORCE_NO_TLS
  255. #define YAC_FORCE_NO_TLS defined
  256. #endif // __CYGWIN32__
  257. // ---- C99 support
  258. #ifdef __STDC_VERSION__
  259. #if (__STDC_VERSION__ >= 199901L)
  260. #define YAC_C99 defined
  261. #endif
  262. #endif
  263. // ---- GCC detection ----
  264. #ifdef __GNUC__
  265. #define YAC_GCC defined
  266. #endif
  267. // ---- endianess ----
  268. #if !defined(YAC_BIG_ENDIAN) && !defined(YAC_LITTLE_ENDIAN)
  269. #ifdef YAC_WIN32
  270. #define YAC_LITTLE_ENDIAN defined
  271. #else
  272. #ifdef YAC_POSIX
  273. #include <endian.h>
  274. #if (__BYTE_ORDER == __BIG_ENDIAN)
  275. #define YAC_BIG_ENDIAN defined
  276. #else
  277. #define YAC_LITTLE_ENDIAN defined
  278. #endif
  279. #else
  280. // !!! "please define YAC_BIG_ENDIAN or YAC_LITTLE_ENDIAN! (falling back to YAC_LITTLE_ENDIAN)" !!!
  281. #define YAC_LITTLE_ENDIAN defined
  282. #endif
  283. #endif
  284. #endif
  285. // ---- check whether we are running on (x86) 64bit ----
  286. #ifdef __x86_64__
  287. #define YAC_64
  288. #else
  289. #ifdef __AMD64__
  290. #define YAC_64
  291. #else
  292. #ifdef __amd64__
  293. #define YAC_64
  294. #else
  295. #ifdef __LP64__
  296. #define YAC_64
  297. #else
  298. #ifdef _M_IA64
  299. #define YAC_64
  300. #else
  301. #ifdef _M_X64
  302. #define YAC_64
  303. #endif
  304. #endif
  305. #endif
  306. #endif
  307. #endif
  308. #endif
  309. // ----
  310. // ---- Calling convention for yac* methods and global functions
  311. // ---- X86/64 uses a custom calling convention; (most?) c++ compilers
  312. // ---- cannot handle __cdecl 64bit methods/functions.
  313. // ----
  314. #ifndef YAC_CALL
  315. #ifdef YAC_64
  316. #define YAC_CALL
  317. #else
  318. #ifdef __GNUC__
  319. #define YAC_CALL
  320. #else
  321. #define YAC_CALL __cdecl
  322. #endif
  323. #endif
  324. #endif
  325. /* // ---- YAC virtual method decorator */
  326. #ifdef YAC_WIN32
  327. //#define YAC_VCALL __cdecl
  328. #define YAC_VCALL
  329. #else
  330. #define YAC_VCALL
  331. #endif
  332. // ----
  333. // ----
  334. // ---- determine way to export symbols
  335. // ----
  336. // ----
  337. #ifndef YAC_NO_EXPORTS
  338. #ifdef YAC_VC
  339. #define YAC_APIC extern "C" __declspec(dllexport)
  340. #define YAC_API __declspec(dllexport)
  341. #else
  342. #define YAC_APIC extern "C"
  343. #define YAC_API
  344. #endif
  345. #else
  346. #define YAC_APIC extern "C"
  347. #define YAC_API
  348. #endif
  349. // ----
  350. // ---- determine thread local storage attribute syntax
  351. // ----
  352. #ifdef YAC_VC
  353. #define YAC_TLS __declspec(thread)
  354. #endif
  355. #ifdef YAC_GCC
  356. #define YAC_TLS __thread
  357. #endif
  358. // Note: using TLS in .dlls is only allowed since Windows Vista.
  359. // However, I noticed that static TLS arrays increase the .dll file size
  360. // by the size of the array (!). e.g.: a 128kb buffer will increase the filesize
  361. // by 128kb. not even UPX crunching can solve that issue (but why?)
  362. // so, to keep the file size small and the .dll compatible with Windows XP and prior versions,
  363. // you should define "YAC_FORCE_NO_TLS" in plugin_msvc.mk
  364. // also see <http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx>
  365. //
  366. #ifdef YAC_FORCE_NO_TLS
  367. #undef YAC_TLS
  368. #define YAC_TLS
  369. #endif // YAC_FORCE_NO_TLS
  370. // ----
  371. // ---- determine how to "restrict" pointer aliasing
  372. // ----
  373. #ifdef YAC_VC
  374. #define YAC_RESTRICT __restrict
  375. #else
  376. #ifdef YAC_GCC
  377. #define YAC_RESTRICT __restrict__
  378. #else
  379. #define YAC_RESTRICT
  380. #endif // YAC_GCC
  381. #endif // YAC_VC
  382. // ----
  383. // ---- determine how to "inline" functions
  384. // ----
  385. #ifdef YAC_VC
  386. #define YAC_INLINE __inline
  387. #else
  388. // GCC
  389. #define YAC_INLINE static inline
  390. #endif
  391. // ----
  392. // ---- Version string
  393. // ----
  394. #define YAC__X(a) # a
  395. #define YAC__Y(a) YAC__X(a)
  396. #define YAC__Z(a,b) a ## . ## b
  397. #define YAC_VERSION_STRING YAC__Y(YAC__Z(YAC_VERSION_MAJOR, YAC_VERSION_MINOR))
  398. #undef YAC__X
  399. #undef YAC__Y
  400. #undef YAC__Z
  401. // ----
  402. // ----
  403. // ---- interface tags for YInG
  404. // ----
  405. // ----
  406. #define YF YAC_APIC
  407. #define YC
  408. #define YCS
  409. #define YCR
  410. #define YCI
  411. #define YCF
  412. #define YG(a)
  413. #define YM
  414. #define YP
  415. // ----
  416. // ---- The only reason to use a macro for "const" is that it
  417. // ---- eases C++ type/name parsing
  418. // ---- (Note: actual parsing would be required to distinguish e.g. "YAC_String *_constName" and "char *const _name",
  419. // ---- hence this workaround)
  420. // ----
  421. #define YAC_CONST const
  422. YG("core");
  423. // ---- s[USF] types originally from Dierk Ohlerich <chaos@vcc.de> <chaos@ohlerich.org> (thanks) ----
  424. // ----
  425. // ----
  426. // ---- type conventions / abbreviations for common C/C++ datatypes
  427. // ----
  428. // ----
  429. typedef char sChar;
  430. typedef unsigned char sU8;
  431. typedef signed char sS8;
  432. typedef unsigned short sU16;
  433. typedef signed short sS16;
  434. typedef unsigned int sU32;
  435. typedef signed int sS32;
  436. #ifdef YAC_VC
  437. typedef unsigned __int64 sU64;
  438. typedef signed __int64 sS64;
  439. #else
  440. typedef unsigned long long sU64;
  441. typedef signed long long sS64;
  442. #endif
  443. typedef float sF32;
  444. typedef double sF64;
  445. typedef unsigned int sBool;
  446. // ---- datatype limits ----
  447. #define sU8_MIN 0x00
  448. #define sU8_MAX 0xff
  449. #define sS8_MIN -0x80
  450. #define sS8_MAX 0x7f
  451. #define sU16_MIN 0x0000
  452. #define sU16_MAX 0xffff
  453. #define sS16_MIN -0x8000
  454. #define sS16_MAX 0x7fff
  455. #define sU32_MIN 0x00000000
  456. #define sU32_MAX 0xffffffff
  457. #define sS32_MIN -0x80000000
  458. #define sS32_MAX 0x7fffffff
  459. #define sU64_MIN 0x0000000000000000
  460. #define sU64_MAX 0xffffffffffffffff
  461. #define sS64_MIN -0x8000000000000000
  462. #define sS64_MAX 0x7fffffffffffffff
  463. #define sINT_MIN -0x80000000
  464. #define sINT_MAX 0x7fffffff
  465. #define sF32_MIN 1.2E-38f
  466. #define sF32_MAX 3.4e+38f
  467. #define SIZEOF_CHAR sizeof(sChar)
  468. #define SIZEOF_BYTE 1
  469. #define SIZEOF_INT 4
  470. #define SIZEOF_FLOAT 4
  471. #define SIZEOF_DOUBLE 8
  472. //#define SIZEOF_RINT sizeof(void*) // # of bytes / CPU register; sizeof(void*)
  473. #define SIZEOF_RINT 4
  474. // ---- void* size, # of bytes per CPU register ----
  475. #if (SIZEOF_RINT) == 4
  476. typedef sU32 sUI;
  477. typedef sS32 sSI;
  478. #define RINT_SIZE_SHIFT 2
  479. #define sUI_MIN sU32_MIN
  480. #define sUI_MAX sU32_MAX
  481. #define sSI_MIN sS32_MIN
  482. #define sSI_MAX sS32_MAX
  483. #else
  484. #if (SIZEOF_RINT) == 8
  485. typedef sU64 sUI;
  486. typedef sS64 sSI;
  487. #define RINT_SIZE_SHIFT 3
  488. #define sUI_MIN sU64_MIN
  489. #define sUI_MAX sU64_MAX
  490. #define sSI_MIN sS64_MIN
  491. #define sSI_MAX sS64_MAX
  492. #else
  493. #error "error: trying to compile with 16-bit ints (128bit?)."
  494. #endif
  495. #endif
  496. // ---- 'sBool' true/false constants ----
  497. #define YAC_TRUE (1)
  498. #define YAC_FALSE (0)
  499. // ---- maximum iterator size, see yacIteratorInit()
  500. #define YAC_MAX_ITERATOR_SIZE (sizeof(void*)*16)
  501. // ---- float constants ----
  502. #define YAC_FLOAT_DEVIATION 0.000001f
  503. #define YAC_DOUBLE_DEVIATION 0.0000000001f
  504. // ---- math constants ----
  505. #define sM_E 2.7182818284590452353602874713526625
  506. #define sM_LOG2E 1.4426950408889634073599246810018922
  507. #define sM_LOG10E 0.4342944819032518276511289189166051
  508. #define sM_LN2 0.6931471805599453094172321214581766
  509. #define sM_LN10 2.3025850929940456840179914546843642
  510. #define sM_PI 3.1415926535897932384626433832795029
  511. #define sM_PI_2 1.5707963267948966192313216916397514
  512. #define sM_PI_4 0.7853981633974483096156608458198757
  513. #define sM_1_PI 0.3183098861837906715377675267450287
  514. #define sM_2_PI 0.6366197723675813430755350534900574
  515. #define sM_2_SQRTP 1.1283791670955125738961589031215452
  516. #define sM_SQRT1_2 0.7071067811865475244008443621048490
  517. #define sM_SQRT2 1.4142135623730950488016887242096981
  518. // ---- math constants for use with 80bit doubles (taken from GNU math.h).
  519. #define sM_El 2.7182818284590452353602874713526625L /* e */
  520. #define sM_LOG2El 1.4426950408889634073599246810018922L /* log_2 e */
  521. #define sM_LOG10El 0.4342944819032518276511289189166051L /* log_10 e */
  522. #define sM_LN2l 0.6931471805599453094172321214581766L /* log_e 2 */
  523. #define sM_LN10l 2.3025850929940456840179914546843642L /* log_e 10 */
  524. #define sM_PIl 3.1415926535897932384626433832795029L /* pi */
  525. #define sM_PI_2l 1.5707963267948966192313216916397514L /* pi/2 */
  526. #define sM_PI_4l 0.7853981633974483096156608458198757L /* pi/4 */
  527. #define sM_1_PIl 0.3183098861837906715377675267450287L /* 1/pi */
  528. #define sM_2_PIl 0.6366197723675813430755350534900574L /* 2/pi */
  529. #define sM_2_SQRTPIl 1.1283791670955125738961589031215452L /* 2/sqrt(pi) */
  530. #define sM_SQRT1_2l 0.7071067811865475244008443621048490L /* 1/sqrt(2) */
  531. #define sM_SQRT2l 1.4142135623730950488016887242096981L /* sqrt(2) */
  532. // ---- floating point endianess helpers ----
  533. typedef union yac_ieee_float_u {
  534. sF32 f32;
  535. #ifdef YAC_LITTLE_ENDIAN
  536. struct {
  537. sUI mantissa : 23;
  538. sUI exponent : 8;
  539. sUI sign : 1;
  540. } le;
  541. struct {
  542. sUI sign : 1;
  543. sUI exponent : 8;
  544. sUI mantissa : 23;
  545. } be;
  546. #else
  547. struct {
  548. sUI sign : 1;
  549. sUI exponent : 8;
  550. sUI mantissa : 23;
  551. } le;
  552. struct {
  553. sUI mantissa : 23;
  554. sUI exponent : 8;
  555. sUI sign : 1;
  556. } be;
  557. #endif // YAC_LITTLE_ENDIAN
  558. sU8 u8[4];
  559. sU64 u32;
  560. } yac_ieee_float_t;
  561. typedef union yac_ieee_double_u {
  562. sF64 f64;
  563. #ifdef YAC_LITTLE_ENDIAN
  564. // (note) C only permits integer types in bitfields => split the mantissa
  565. struct {
  566. sUI mantissa1 : 26;
  567. sUI mantissa2 : 26;
  568. sUI exponent : 11;
  569. sUI sign : 1;
  570. } le;
  571. struct {
  572. sUI sign : 1;
  573. sUI exponent : 11;
  574. sUI mantissa1 : 26;
  575. sUI mantissa2 : 26;
  576. } be;
  577. #else
  578. struct {
  579. sUI sign : 1;
  580. sUI exponent : 11;
  581. sUI mantissa1 : 26;
  582. sUI mantissa2 : 26;
  583. } le;
  584. struct {
  585. sUI mantissa1 : 26;
  586. sUI mantissa2 : 26;
  587. sUI exponent : 11;
  588. sUI sign : 1;
  589. } be;
  590. #endif // YAC_LITTLE_ENDIAN
  591. sU8 u8[8];
  592. sU32 u64;
  593. } yac_ieee_double_t;
  594. // ---- useful macros ----
  595. #define sMIN(a,b) (((a)>(b))?(b):(a))
  596. #define sMAX(a,b) (((a)>(b))?(a):(b))
  597. #define sSIGN(x) (((x)==0)?0:(((x)>0)?1:-1))
  598. #define sABS(x) (((x)>0)?(x):-(x))
  599. #define sRANGE(x,max,min) (((x)<(min))?(min):(((x)>(max))?(max):(x)))
  600. #define sALIGN(x,a) (((x)+(a)-1)&~((a)-1))
  601. #define sMAKE2(b,a) (((a)<<16)+(b)) // special macros to pack multiple numbers in one integer.
  602. #define sMAKE4(d,c,b,a) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) // usefull for if() and switch() statements
  603. #define sMAKEID(d,c,b,a) (((a)<<24)+((b)<<16)+((c)<<8)+(d))
  604. // ---- prefix for printf %p
  605. #ifdef YAC_WIN32
  606. #define YAC_PRINTF_PTRPREFIX "0x"
  607. #else
  608. #define YAC_PRINTF_PTRPREFIX ""
  609. #endif
  610. // ---- handle types ----
  611. typedef void * YAC_ModuleHandle;
  612. typedef void * YAC_FunctionHandle;
  613. typedef void * YAC_VariableHandle;
  614. typedef void * YAC_ContextHandle;
  615. typedef void * YAC_MutexHandle;
  616. // ---- nameid types ----
  617. typedef sUI YAC_ExceptionId;
  618. typedef sSI YAC_CallbackId;
  619. // ---- other anonymous pointer types ----
  620. typedef void * YAC_CFunctionPtr;
  621. typedef struct __YAC_PoolHandle {
  622. sUI pool_id;
  623. sUI object_id;
  624. } YAC_PoolHandle;
  625. // ---- object validation tags ----
  626. #define YAC_VALID_TAG 0x900DF00D
  627. #define YAC_INVALID_TAG 0xD34DBEEF
  628. // ---- base classes and structures ----
  629. class YAC_API YAC_Buffer;
  630. class YAC_API YAC_Event;
  631. class YAC_API YAC_Iterator;
  632. class YAC_API YAC_Object;
  633. class YAC_API YAC_String;
  634. class YAC_API YAC_Value;
  635. // ---- (untyped) memory ----
  636. typedef union _yacmem {
  637. sUI ui;
  638. sSI si;
  639. sF32 f4;
  640. YAC_Object *o ;
  641. YAC_Object **io;
  642. YAC_String *s;
  643. void *any;
  644. } yacmem; //this has size 4byte on 32bit systems and 8byte on 64bit systems
  645. typedef union _yacmem64 {
  646. sUI ui4;
  647. sSI si4;
  648. sU64 ui8;
  649. sS64 si8;
  650. sF32 f4;
  651. sF64 f8;
  652. YAC_Object *o;
  653. YAC_Object **io;
  654. YAC_String *s;
  655. void *any;
  656. } yacmem64; //this is always 8byte (except on bigger than 64bit systems with larger ptr)
  657. // ---- pointer to (untyped) memory ----
  658. typedef union _yacmemptr {
  659. yacmem *mem;
  660. void *any;
  661. sChar *c;
  662. sS8 *s1;
  663. sU8 *u1;
  664. sS16 *s2;
  665. sU16 *u2;
  666. sS32 *s4;
  667. sU32 *u4;
  668. sU64 *u8;
  669. sF32 *f4;
  670. sF64 *f8;
  671. sSI *si;
  672. sUI *ui;
  673. YAC_Object *o;
  674. // ---- pointer to array of pointers ----
  675. void **iany;
  676. sChar **ic;
  677. sS8 **is1;
  678. sU8 **iu1;
  679. sS16 **is2;
  680. sU16 **iu2;
  681. sS32 **is4;
  682. sU32 **iu4;
  683. sF32 **if4;
  684. sSI **isi;
  685. sUI **iui;
  686. YAC_Object **io;
  687. YAC_Object ***iio;
  688. // ---- union with register int (32, 64bit) ----
  689. sUI _ui;
  690. sSI _si;
  691. } yacmemptr;
  692. // ----
  693. // ---- YAC uses a custom RTTI.
  694. // ----
  695. // ---- The following (absolute) class IDs are mapped to a set of core classes.
  696. // ---- (The YAC_Host application host assigns dynamic class IDs to dynamically loaded classes)
  697. // ----
  698. // ----
  699. enum __yac_class_IDs {
  700. YAC_CLID_OBJECT=0, // 0: base class for all API classes; cannot be instanciated
  701. // ---- v a l u e o b j e c t s ----
  702. YAC_CLID_BOOLEAN, // 1: object representation of a boolean (1bit)
  703. YAC_CLID_BYTE, // 2: object representation of a signed byte (8bit)
  704. YAC_CLID_SHORT, // 3: object representation of a signed short (16bit)
  705. YAC_CLID_INTEGER, // 4: object representation of a 32bit integer
  706. YAC_CLID_LONG, // 5: object representation of a signed long long (64bit)
  707. YAC_CLID_UNSIGNEDBYTE, // 6: object representation of an unsigned byte (8bit)
  708. YAC_CLID_UNSIGNEDSHORT, // 7: object representation of an unsigned short (16bit)
  709. YAC_CLID_UNSIGNEDINTEGER, // 8: object representation of an unsigned int (32bit)
  710. YAC_CLID_UNSIGNEDLONG, // 9: object representation of an unsigned long (64bit)
  711. YAC_CLID_FLOAT, // 10: object representation of a 32bit float
  712. YAC_CLID_DOUBLE, // 11: object representation of a 64bit double
  713. YAC_CLID_STRING, // 12: a (buffered) char sequence (has special fastpaths)
  714. YAC_CLID_EVENT, // 13: a time-stamped String
  715. YAC_CLID_VALUE, // 14: an int/float/String or Object value that is wrapped in an object
  716. YAC_CLID_LISTNODE, // 15: a single node of a list (or a list header). derived from Value.
  717. YAC_CLID_TREENODE, // 16: a single node of a tree (or a tree header). derived from Value.
  718. // ---- c o n t a i n e r o b j e c t s ----
  719. YAC_CLID_CLASS, // 17: base class for meta class objects (e.g. script class objects)
  720. YAC_CLID_LIST, // 18: object container for a double linked list, see YAC_ListNode.
  721. YAC_CLID_INTARRAY, // 19: an Array of ints, see yacArray*
  722. YAC_CLID_FLOATARRAY, // 20: an Array of floats, see yacArray*
  723. YAC_CLID_STRINGARRAY, // 21: an Array of YAC_Strings (all read-write)
  724. YAC_CLID_OBJECTARRAY, // 22: an Array of (uniform) YAC_Objects (all read-write)
  725. YAC_CLID_CLASSARRAY, // 23: an Array of meta class objects (all read-write)
  726. YAC_CLID_VALUEARRAY, // 24: an Array of YAC_Values
  727. YAC_CLID_POINTERARRAY, // 25: an Array of (mixed) YAC_Objects wrapped in YAC_Values
  728. YAC_CLID_HASHTABLE, // 26: an associative Array, see yacHash*
  729. // ---- s t r e a m s ----
  730. YAC_CLID_STREAM, // 27: base class for Files und Buffers, see yacStream*, YAC_StreamBase
  731. YAC_CLID_STDINSTREAM, // 28: standard input filestream, derived from YAC_StreamBase
  732. YAC_CLID_STDOUTSTREAM, // 29: standard output filestream, derived from YAC_StreamBase
  733. YAC_CLID_STDERRSTREAM, // 30: standard error filestream, derived from YAC_StreamBase
  734. YAC_CLID_BUFFER, // 31: an Array of bytes, derived from YAC_StreamBase
  735. YAC_CLID_FILE, // 32: used to access local filesystems, derived from YAC_StreamBase
  736. YAC_CLID_PAKFILE, // 33: used to access virtual file systems, derived from YAC_StreamBase
  737. YAC_CLID_PIPE,
  738. // Note: Be careful with the preallocated String/array variants.
  739. // A buffer reallocation will waste the initial buffer memory (not leaked but it cannot be used for anything
  740. // else as long as the object is alive!). This means: Choose the variant wisely!
  741. // The good thing is that in conjunction with object pooling, it is possible to write code that
  742. // works with *zero* malloc() calls. Without these variants, a malloc() would be necessary to allocate
  743. // the actual buffer data even if the object is pooled.
  744. // Finally, keep in mind that if you use static variables, the Object is not re-initialized the next
  745. // time a function is called, i.e. the buffer will still be there and no malloc() will be necessary
  746. // even without these variants.
  747. YAC_CLID_STRING8, // 34: variation of String that comes with preallocated char buffer of 8 chars
  748. YAC_CLID_STRING16, // 35: variation of String that comes with preallocated char buffer of 16 chars
  749. YAC_CLID_STRING32, // 36: variation of String that comes with preallocated char buffer of 32 chars
  750. YAC_CLID_STRING64, // 37: variation of String that comes with preallocated char buffer of 64 chars
  751. YAC_CLID_STRING128, // 38: variation of String that comes with preallocated char buffer of 128 chars
  752. YAC_CLID_INTARRAY8, // 39: variation of IntArray that comes with a preallocated buffer of 8 ints
  753. YAC_CLID_INTARRAY16, // 40: variation of IntArray that comes with a preallocated buffer of 16 ints
  754. YAC_CLID_INTARRAY32, // 41: variation of IntArray that comes with a preallocated buffer of 32 ints
  755. YAC_CLID_INTARRAY64, // 42: variation of IntArray that comes with a preallocated buffer of 64 ints
  756. YAC_CLID_INTARRAY128, // 43: variation of IntArray that comes with a preallocated buffer of 128 ints
  757. YAC_CLID_FLOATARRAY8, // 44: variation of FloatArray that comes with a preallocated buffer of 8 floats
  758. YAC_CLID_FLOATARRAY16, // 45: variation of FloatArray that comes with a preallocated buffer of 16 floats
  759. YAC_CLID_FLOATARRAY32, // 46: variation of FloatArray that comes with a preallocated buffer of 32 floats
  760. YAC_CLID_FLOATARRAY64, // 47: variation of FloatArray that comes with a preallocated buffer of 64 floats
  761. YAC_CLID_FLOATARRAY128, // 48: variation of FloatArray that comes with a preallocated buffer of 128 floats
  762. YAC_NUM_CORE_CLASSES = 128
  763. };
  764. // ---- hard coded limits/"magic" constants ----
  765. #define YAC_MAX_CLASSES 256 // maximum number of C++ classes
  766. #define YAC_MAX_COMMANDS 64 // maximum number of C++ methods per class
  767. #define YAC_LOSTKEY ((sU32)-1) // indicates that YAC_String hashkey needs to be recalc'd
  768. // ---- YAC class types
  769. #define YAC_CLASSTYPE_STATIC 0 // C++ class cannot be instantiated in scripts or native code
  770. #define YAC_CLASSTYPE_NORMAL 1 // regular C++ class
  771. #define YAC_CLASSTYPE_NOINST 2 // C++ class objects can only be instantiated by native code
  772. // ---- basic datatype enumeration
  773. #define YAC_TYPE_VOID 0 // not used
  774. #define YAC_TYPE_VARIANT 0 // not defined (yet)
  775. #define YAC_TYPE_INT 1 // currently 32bit integer (may become 64bit signed long long on 64bit architectures)
  776. #define YAC_TYPE_FLOAT 2 // currently 32bit float (may become 64bit double on 64bit architectures)
  777. #define YAC_TYPE_OBJECT 3 // pointer to Object (YAC_Object *)
  778. #define YAC_TYPE_STRING 4 // only used in YAC_Value::type field, script engine hint
  779. // ---- Hint flags for the YAC_Host to use different pools for different types of object allocations (e.g. short-lived vs. long-term)
  780. // ---- YAC_NEW() should be used for seldomly deleted objects (i.e. to prevent pooling)
  781. #define YAC_POOL_HINT_DEFAULT 0
  782. #define YAC_POOL_HINT_TEMPORARY 1
  783. // ---- Pool priorities
  784. #define YAC_POOL_PRIORITY_LOW 0
  785. #define YAC_POOL_PRIORITY_MEDIUM 1
  786. #define YAC_POOL_PRIORITY_HIGH 2
  787. #define YAC_NUM_POOL_PRIORITIES 3
  788. #ifdef YAC_PLACEMENT_NEW
  789. #include <stdlib.h>
  790. #include <new>
  791. #endif // YAC_PLACEMENT_NEW
  792. #if !defined(RACK_PLUGIN) && !defined(RACK_HOST)
  793. // ---- basic type structure (no con-/destructors) ----
  794. class YAC_API YAC_TypeS {
  795. public:
  796. #ifdef YAC_VIRTUAL_VALUE
  797. inline virtual ~YAC_TypeS() { } // To satisfy the Intel C++ compiler :/ (i.e. to get no warnings when virtual classes are derived from this class/YAC_Value)
  798. #endif // YAC_VIRTUAL_VALUE
  799. public:
  800. sUI type; // YAC_TYPE_xxx
  801. sSI class_type; // if type==YAC_TYPE_OBJECT then this field stores the internal object class type
  802. };
  803. // ---- basic script value structure (no con-/destructors) ----
  804. class YAC_API YAC_ValueS : public YAC_TypeS {
  805. public:
  806. union __my_value {
  807. sF32 float_val;
  808. sSI int_val;
  809. YAC_Object *object_val;
  810. YAC_String *string_val;
  811. void *any;
  812. } value;
  813. sUI deleteme; // ---- this flag is used to decide whether it is safe to delete the object
  814. };
  815. //
  816. // How to allocate string characters
  817. //
  818. #ifdef YAC_TRACK_CHARALLOC
  819. extern sSI yac_string_total_char_size;
  820. extern sU8 *yac_string_alloc_chars(size_t _n);
  821. extern void yac_string_free_chars(sU8 *_chars);
  822. #define Dyacallocchars(n) yac_string_alloc_chars(n)
  823. #define Dyacfreechars(n) yac_string_free_chars(n)
  824. #else
  825. #define Dyacallocchars(n) ((sU8*)::malloc(n))
  826. #define Dyacfreechars(n) ::free(n)
  827. #endif // YAC_TRACK_CHARALLOC
  828. #ifndef YAC_CUST_VALUE
  829. // ----
  830. // ----
  831. // ---- YAC_Value:
  832. // ----
  833. // ---- - stores an int/float or YAC_Object*
  834. // ---- - dynamic type
  835. // ---- - track object pointer ownership
  836. // ---- - used to return values from methods/functions
  837. // ----
  838. // ----
  839. // ----
  840. class YAC_API YAC_Value : public YAC_ValueS {
  841. public:
  842. YAC_Value (void );
  843. ~YAC_Value ( );
  844. void initVoid (void );
  845. void initInt (sSI _i );
  846. void initFloat (sF32 _f );
  847. void initString (YAC_String *_s, sBool _del);
  848. void initNewString (YAC_String *s );
  849. void initObject (YAC_Object *_o, sBool _del);
  850. void initNull (void );
  851. void typecast (sUI _type );
  852. void unsetFast (void ); // delete object if it is volatile (deleteme flag)
  853. void unset (void ); // delete object if it is volatile (deleteme flag), reset members to 0
  854. void operator = (YAC_Value*_v );
  855. void safeInitInt (sSI _i );
  856. void safeInitFloat (sF32 _f );
  857. void safeInitString (YAC_String *_s, sBool _del);
  858. void safeInitObject (YAC_Object *_o, sBool _new);
  859. void initEmptyString (void );
  860. void copyRef (const YAC_Value *_o );
  861. };
  862. #endif // YAC_CUST_VALUE
  863. // ---- macros for the c++ interface ----
  864. #define YAC_RETI(a) _r->initInt((sSI)(a))
  865. // the return value of an API function (to the hostengine) is passed in a YAC_Value *_r argument, e.g. getValue(YAC_Value *_r) { _r->initInt(42); }. lists and arrays can be returned using apprioriate objects (e.g. PointerArray)
  866. #define YAC_RETF(a) _r->initFloat((sF32)(a))
  867. // return a float value, also see YAC_RETI
  868. #define YAC_RETO(a,b) _r->initObject((YAC_Object*)(a),b)
  869. // return an object. new objects have to be allocated with YAC_Host::yacNew(), also see YAC_RETI
  870. #define YAC_RETS(a,b) _r->initString((YAC_String*)(a), b) // return a string. new strings have to be allocated with YAC_Host::yacNew(), also see YAC_RETI
  871. #define YAC_RETSC(a) _r->initNewString((YAC_String*)(a))
  872. #define YAC_H(a) YAC_Object*YAC_VCALL yacNewObject(void);const sChar*YAC_VCALL yacClassName(void)
  873. // ---- start an interface definition, e.g. YAC_H(MyClass);
  874. #define YAC(a) YAC_Object * YAC_VCALL yacNewObject (void);\
  875. const sChar* YAC_VCALL yacClassName (void);\
  876. sUI YAC_VCALL yacMemberGetNum (void);\
  877. const char ** YAC_VCALL yacMemberGetNames (void);\
  878. const sUI * YAC_VCALL yacMemberGetTypes (void);\
  879. const char ** YAC_VCALL yacMemberGetObjectTypes (void);\
  880. const sU8 ** YAC_VCALL yacMemberGetOffsets (void);\
  881. sUI YAC_VCALL yacMethodGetNum (void);\
  882. const char ** YAC_VCALL yacMethodGetNames (void);\
  883. const sUI * YAC_VCALL yacMethodGetNumParameters (void);\
  884. const sUI ** YAC_VCALL yacMethodGetParameterTypes (void);\
  885. const char*** YAC_VCALL yacMethodGetParameterObjectTypes (void);\
  886. const sUI * YAC_VCALL yacMethodGetReturnTypes (void);\
  887. const char ** YAC_VCALL yacMethodGetReturnObjectTypes (void);\
  888. const void ** YAC_VCALL yacMethodGetAdr (void);\
  889. sUI YAC_VCALL yacConstantGetNum (void);\
  890. const char ** YAC_VCALL yacConstantGetNames (void);\
  891. const sUI * YAC_VCALL yacConstantGetTypes (void);\
  892. yacmemptr YAC_VCALL yacConstantGetValues (void)
  893. #define YAC_POOLED_H(a, p) \
  894. void YAC_VCALL yacPoolInit (YAC_Object *_this); \
  895. sUI YAC_VCALL yacPoolGetSize (void); \
  896. sUI YAC_VCALL yacPoolGetPriority (void) { return p; } \
  897. void YAC_VCALL yacFinalizeObject (YAC_ContextHandle)
  898. #define YAC_POOLED(a, p) YAC(a); YAC_POOLED_H(a, p)
  899. #define YAC_C(a, b) YAC_Object *YAC_VCALL a::yacNewObject(void){YAC_Object*r=new a();r->class_ID=class_ID;return r;}const sChar*a::yacClassName(void){return b;}
  900. #define YAC_C_CORE(a, b, c) YAC_Object *YAC_VCALL a::yacNewObject(void){YAC_Object*r=new a();r->class_ID=c;return r;}const sChar*a::yacClassName(void){return b;}
  901. #ifdef YAC_PLACEMENT_NEW
  902. #define YAC_C_POOLED__NEWOBJECT(a) \
  903. void YAC_VCALL a::yacPoolInit(YAC_Object *_this) { new(_this)a(); }
  904. #else
  905. #define YAC_C_POOLED__NEWOBJECT(a) \
  906. void YAC_VCALL a::yacPoolInit(YAC_Object *_this) { *(void**)_this = *(void**)this; ((a*)_this)->a::a(); }
  907. #endif // YAC_PLACEMENT_NEW
  908. #define YAC_C_POOLED(a, b) YAC_C(a, b) YAC_C_POOLED__NEWOBJECT(a) \
  909. void YAC_VCALL a::yacFinalizeObject (YAC_ContextHandle) { this->a::~a(); } \
  910. sUI YAC_VCALL a::yacPoolGetSize (void) { return sizeof(a); }
  911. #define YAC_C_CORE_POOLED(a, b, c) YAC_C_CORE(a, b, c) YAC_C_POOLED__NEWOBJECT(a) \
  912. void YAC_VCALL a::yacFinalizeObject (YAC_ContextHandle) { this->a::~a(); } \
  913. sUI YAC_VCALL a::yacPoolGetSize (void) { return sizeof(a); }
  914. #define YAC_CHK(a,b) ((a)&&((a)->class_ID==b))
  915. // ---- custom RTTI, used to verify Object arguments passed from scripts
  916. #define YAC_BCHK(a,b) ((a)&&(yac_host->cpp_typecast_map[(a)->class_ID][b]))
  917. // ---- custom RTTI, used to verify if Object is baseclass of another Object, also to validate script arguments
  918. // For regular class names (e.g. MyClass)
  919. #define YAC_NEW(a) (a*)yac_host->yacNewByID(clid_##a)
  920. // For mangled class name (e.g. _MyClass)
  921. #define YAC_NEW_(a) (_##a*)yac_host->yacNewByID(clid_##a)
  922. // Note: do not pass stack objects to other yac* methods (object may have different vtable!)
  923. #define YAC_NEW_STACK(t, v) _##t v; v.class_ID = clid_##t
  924. #define YAC_NEW_CORE(c) yac_host->yacNewByID(c)
  925. #define YAC_NEW_POOLED(a) (_##a*)yac_host->yacNewPooledByID(clid_##a, YAC_POOL_HINT_DEFAULT)
  926. #define YAC_NEW_TEMP(a) (_##a*)yac_host->yacNewPooledByID(clid_##a, YAC_POOL_HINT_TEMPORARY)
  927. #define YAC_NEW_CORE_POOLED(c) yac_host->yacNewPooledByID(c, YAC_POOL_HINT_DEFAULT)
  928. #define YAC_NEW_CORE_TEMP(c) yac_host->yacNewPooledByID(c, YAC_POOL_HINT_TEMPORARY)
  929. // ---- Cloning creates a new object and calls yacOperatorInit.
  930. #define YAC_CLONE_POOLED(x, a) (a)->yacNewPooled((YAC_ContextHandle)x, YAC_POOL_HINT_DEFAULT)
  931. #define YAC_CLONE_TEMP(x, a) (a)->yacNewPooled((YAC_ContextHandle)x, YAC_POOL_HINT_TEMPORARY)
  932. #define YAC_DELETE(a) yac_host->yacDelete(a)
  933. #define YAC_DELETE_SAFE(a) if(NULL != a) { YAC_DELETE(a); a = NULL; } else (void)0
  934. // ---- operation codes for YAC_Object::yacOperator() ----
  935. enum __yacoperators {
  936. YAC_OP_ASSIGN=0, // ---- also see YAC_Object::yacOperator()
  937. YAC_OP_ADD,
  938. YAC_OP_SUB,
  939. YAC_OP_MUL,
  940. YAC_OP_DIV,
  941. YAC_OP_MOD,
  942. YAC_OP_SHL,
  943. YAC_OP_SHR,
  944. YAC_OP_CEQ,
  945. YAC_OP_CNE,
  946. YAC_OP_CLE,
  947. YAC_OP_CLT,
  948. YAC_OP_CGE,
  949. YAC_OP_CGT,
  950. YAC_OP_AND,
  951. YAC_OP_OR,
  952. YAC_OP_EOR,
  953. YAC_OP_NOT,
  954. YAC_OP_BITNOT, // iinv
  955. YAC_OP_LAND,
  956. YAC_OP_LOR,
  957. YAC_OP_LEOR,
  958. YAC_OP_NEG,
  959. YAC_OP_INIT, // init class, call constructors (or put on cs list)
  960. YAC_NUMOPERATORS
  961. };
  962. // ---- double arg operator priorities (sUI YAC_Object::yacOperatorPriority(void))
  963. #define YAC_OP_PRIO_BOOLEAN 0x00001000
  964. #define YAC_OP_PRIO_BYTE 0x00002000
  965. #define YAC_OP_PRIO_SHORT 0x00003000
  966. #define YAC_OP_PRIO_INTEGER 0x00004000
  967. #define YAC_OP_PRIO_LONG 0x00005000
  968. #define YAC_OP_PRIO_FLOAT 0x00006000
  969. #define YAC_OP_PRIO_DOUBLE 0x00007000
  970. #define YAC_OP_PRIO_STRING 0x00010000
  971. // ---- Return values for yacTensorRank()
  972. #define YAC_TENSOR_RANK_NONE -2 // Definitely not a math object, e.g. Time
  973. #define YAC_TENSOR_RANK_VAR -1 // Some object's tensor rank can be variant resp. interpreted differently, e.g. String, ListNode, ValueObject
  974. #define YAC_TENSOR_RANK_SCALAR 0 // Integer, Float, Double, ..
  975. #define YAC_TENSOR_RANK_VECTOR 1 // IntArray, FloatArray, ObjectArray, ..
  976. #define YAC_TENSOR_RANK_MATRIX 2 // e.g. tkmath::Matrix3f
  977. // ---- all plugin class(es) have to be derived from this virtual interface class ----
  978. YCR class YAC_API YAC_Object {
  979. public:
  980. sUI class_ID; /// ---- set by YAC_Host::yacRegisterClass()
  981. #ifdef YAC_OBJECT_TAGS
  982. sUI validation_tag; /// ---- YAC_VALID_TAG ord YAC_INVALID_TAG
  983. #endif
  984. #ifdef YAC_OBJECT_POOL
  985. YAC_PoolHandle pool_handle; /// ---- != 0 if the object was allocated from a pool
  986. #endif
  987. #ifdef YAC_OBJECT_COUNTER
  988. static sUI object_counter; /// ---- tracks the total number of objects
  989. #endif
  990. #ifdef YAC_PLACEMENT_NEW
  991. public:
  992. void *operator new (size_t _size) { return ::malloc(_size); }
  993. void operator delete (void *_ptr) {
  994. if(((YAC_Object*)_ptr)->pool_handle.pool_id)
  995. {
  996. ::printf("[---] delete: object is pooled (handle=%08x:%08x)!!\n",
  997. ((YAC_Object*)_ptr)->pool_handle.pool_id,
  998. ((YAC_Object*)_ptr)->pool_handle.object_id
  999. );
  1000. }
  1001. else
  1002. {
  1003. ::free(_ptr);
  1004. }
  1005. }
  1006. void *operator new (size_t, void *_this) { return _this; }
  1007. #endif // YAC_PLACEMENT_NEW
  1008. public:
  1009. // ----
  1010. // ----
  1011. // ---- LEVEL (1<<0) interface
  1012. // ---- ( C++ reflectance support )
  1013. // ----
  1014. // ----
  1015. YAC_Object (void);
  1016. virtual ~YAC_Object ();
  1017. virtual sUI YAC_VCALL yacQueryInterfaces (void);
  1018. virtual const sChar *YAC_VCALL yacClassName (void); // get human readable class name
  1019. virtual YAC_Object *YAC_VCALL yacNewObject (void); // create new instance of object class, also see non-virtual yacNew(). autogenerated by YAC_H(), YAC_C() macros
  1020. virtual sUI YAC_VCALL yacMemberGetNum (void);
  1021. virtual const char **YAC_VCALL yacMemberGetNames (void);
  1022. virtual const sUI *YAC_VCALL yacMemberGetTypes (void);
  1023. virtual const char **YAC_VCALL yacMemberGetObjectTypes (void);
  1024. virtual const sU8 **YAC_VCALL yacMemberGetOffsets (void);
  1025. virtual sUI YAC_VCALL yacMethodGetNum (void);
  1026. virtual const char **YAC_VCALL yacMethodGetNames (void);
  1027. virtual const sUI *YAC_VCALL yacMethodGetNumParameters (void);
  1028. virtual const sUI **YAC_VCALL yacMethodGetParameterTypes (void);
  1029. virtual const char ***YAC_VCALL yacMethodGetParameterObjectTypes(void);
  1030. virtual const sUI *YAC_VCALL yacMethodGetReturnTypes (void);
  1031. virtual const char **YAC_VCALL yacMethodGetReturnObjectTypes (void);
  1032. virtual const void **YAC_VCALL yacMethodGetAdr (void);
  1033. virtual sUI YAC_VCALL yacConstantGetNum (void);
  1034. virtual const char **YAC_VCALL yacConstantGetNames (void);
  1035. virtual const sUI *YAC_VCALL yacConstantGetTypes (void);
  1036. virtual yacmemptr YAC_VCALL yacConstantGetValues (void);
  1037. virtual void YAC_VCALL yacFinalizeObject (YAC_ContextHandle _context);
  1038. virtual void YAC_VCALL yacGetConstantStringList (YAC_String *); // !!WILL BE REMOVED SOON!! write constant list to _retstring. example: "CONST_A:42 CONST_B:77 CONST_C:$7f"
  1039. virtual sBool YAC_VCALL yacIsComposite (void); // return true if object stores references to other objects, used for serialization
  1040. virtual sUI YAC_VCALL yacPoolGetSize (void); // return 0 to prevent pooling for this class type (default)
  1041. virtual void YAC_VCALL yacPoolInit (YAC_Object *_this); // initialize new object (install vtable, call constructors)
  1042. virtual sUI YAC_VCALL yacPoolGetPriority (void); // return pool priority for this class type. see YAC_POOL_PRIORITY_xxx
  1043. virtual void YAC_VCALL vtable_entry_0_25_reserved (void);
  1044. virtual void YAC_VCALL vtable_entry_0_26_reserved (void);
  1045. virtual void YAC_VCALL vtable_entry_0_27_reserved (void);
  1046. virtual void YAC_VCALL vtable_entry_0_28_reserved (void);
  1047. virtual void YAC_VCALL vtable_entry_0_29_reserved (void);
  1048. virtual void YAC_VCALL vtable_entry_0_30_reserved (void);
  1049. virtual void YAC_VCALL vtable_entry_0_31_reserved (void);
  1050. // ----
  1051. // ----
  1052. // ---- LEVEL (1<<1) interface
  1053. // ---- ( operator support )
  1054. // ---- - also see YAC_OP_xxx constants
  1055. // ----
  1056. // ----
  1057. virtual sBool YAC_VCALL yacCopy (YAC_Object *_o); // copy from other object
  1058. virtual sBool YAC_VCALL yacEquals (YAC_Object *_o); // compare objects
  1059. virtual void YAC_VCALL yacOperator (sSI _cmd, YAC_Object *_robj, YAC_Value *_r); // call operator (see YAC_OP_)
  1060. virtual void YAC_VCALL yacOperatorInit (void *_context, YAC_Object *_robj); // used to initialize a class-like YAC_Object by using a template
  1061. virtual void YAC_VCALL yacOperatorAssign (YAC_Object *_robj); // assign YAC_Object _robj (i.e. copy the members)
  1062. virtual void YAC_VCALL yacOperatorAdd (YAC_Object *_robj); // add YAC_Object _robj
  1063. virtual void YAC_VCALL yacOperatorSub (YAC_Object *_robj); // subtract YAC_Object _robj
  1064. virtual void YAC_VCALL yacOperatorMul (YAC_Object *_robj); // multiply with YAC_Object _robj
  1065. virtual void YAC_VCALL yacOperatorDiv (YAC_Object *_robj); // divide by YAC_Object _robj
  1066. virtual void YAC_VCALL yacOperatorClamp (YAC_Object *_min, YAC_Object *_max); // clamp object to boundaries [_min, _max] (e.g. Vector)
  1067. virtual void YAC_VCALL yacOperatorWrap (YAC_Object *_min, YAC_Object *_max); // wrap object around boundaries [_min, _max] (e.g. Vector)
  1068. virtual sBool YAC_VCALL yacScanI (sSI *_ip); // convert object to integer
  1069. virtual sBool YAC_VCALL yacScanF32 (sF32 *_fp); // convert object to 32bit IEEE float
  1070. virtual sBool YAC_VCALL yacScanF64 (sF64 *_dp); // convert object to 64bit IEEE double
  1071. virtual sBool YAC_VCALL yacToString (YAC_String *s) const; // convert object to String object
  1072. virtual sBool YAC_VCALL yacScanI64 (sS64 *_lip); // convert object to long or long long integer (platform dependent)
  1073. virtual void YAC_VCALL yacOperatorI (sSI _cmd, sSI _val, YAC_Value *_r); // operate on object with integer argument
  1074. virtual void YAC_VCALL yacOperatorF32 (sSI _cmd, sF32 _val, YAC_Value *_r); // operate on object with 32bit IEEE float argument
  1075. virtual void YAC_VCALL yacOperatorF64 (sSI _cmd, sF64 _val, YAC_Value *_r); // operato on object with 64bit IEEE double argument
  1076. virtual void YAC_VCALL yacValueOfI (sSI); // set object value by integer argument
  1077. virtual void YAC_VCALL yacValueOfF32 (sF32); // set object value by 32bit IEEE float argument
  1078. virtual void YAC_VCALL yacValueOfF64 (sF64); // set object value by 64bit IEEE double argument
  1079. virtual sUI YAC_VCALL yacOperatorPriority (void); // query priority of object in double-arg expressions (for type conversions)
  1080. virtual void YAC_VCALL yacValueOfI64 (sS64); // set object value by 64bit long long integer
  1081. virtual sSI YAC_VCALL yacTensorRank (void); // query tensor rank of math object, -1=not a math object, 0=scalar, 1=vector, 2=matrix, ..
  1082. virtual sBool YAC_VCALL yacToParsableString (YAC_String *s) const; // convert object to script-parsable String object
  1083. virtual void YAC_VCALL yacOperatorI64 (sSI _cmd, sS64 _val, YAC_Value *_r); // operate on object with 64bit integer argument
  1084. virtual void YAC_VCALL vtable_entry_1_28_reserved (void);
  1085. virtual void YAC_VCALL vtable_entry_1_29_reserved (void);
  1086. virtual void YAC_VCALL vtable_entry_1_30_reserved (void);
  1087. virtual void YAC_VCALL vtable_entry_1_31_reserved (void);
  1088. // ----
  1089. // ----
  1090. // ---- LEVEL (1<<2) interface
  1091. // ---- ( stream support )
  1092. // ----
  1093. // ----
  1094. // ----
  1095. virtual sBool YAC_VCALL yacIsStream (void); // test if the object supports the stream interface
  1096. virtual void YAC_VCALL yacStreamClose (void); // close previously opened stream
  1097. virtual sBool YAC_VCALL yacStreamOpenLocal (sChar *_local_pathname, sSI _access); // open local filestream; _access must be YAC_IOS_IN, YAC_IOS_IN or YAC_IOS_IN. return true (=ok) or false (=error)
  1098. virtual sBool YAC_VCALL yacStreamOpenLogic (sChar *_name_in_pakfile); // open filestream stored in a "pak" file. return true (=ok) or false (=error)
  1099. virtual sUI YAC_VCALL yacStreamGetByteOrder (void); // get byteorder of stream (YAC_LITTLEENDIAN, YAC_BIGENDIAN)
  1100. virtual void YAC_VCALL yacStreamSetByteOrder (sUI); // set byteorder of stream (YAC_LITTLEENDIAN, YAC_BIGENDIAN)
  1101. virtual sBool YAC_VCALL yacStreamEOF (void); // return 1 (true) if the stream end has been reached
  1102. virtual void YAC_VCALL yacStreamSeek (sSI _off, sUI _mode); // seek to a position in the stream. _mode must be one of YAC_BEG (absolute seek), YAC_CUR (add offset to current position), YAC_END (seek relative to stream end, if available)
  1103. virtual sUI YAC_VCALL yacStreamGetOffset (void); // get current stream position (byte offset)
  1104. virtual void YAC_VCALL yacStreamSetOffset (sUI); // set current stream position (byte offset)
  1105. virtual sUI YAC_VCALL yacStreamGetSize (void); // get size of stream (if known)
  1106. virtual sSI YAC_VCALL yacStreamRead (sU8 *, sUI _num); // read _num bytes to buffer, return number of bytes actually read
  1107. virtual sU8 YAC_VCALL yacStreamReadI8 (void); // read a single byte
  1108. virtual sU16 YAC_VCALL yacStreamReadI16 (void); // read a single word, convert endianess from stream to host endianess
  1109. virtual sU32 YAC_VCALL yacStreamReadI32 (void); // read double word, convert endianess from stream to host endianess
  1110. virtual sF32 YAC_VCALL yacStreamReadF32 (void); // read standard IEEE 32bit float
  1111. virtual void YAC_VCALL yacStreamReadObject (YAC_Object *_dest); // deserialize object from stream
  1112. virtual sSI YAC_VCALL yacStreamReadString (YAC_String *_dest, sUI _maxlen); // read up to _maxlen bytes to _dest (until ASCIIZ is found)
  1113. virtual sSI YAC_VCALL yacStreamReadBuffer (YAC_Buffer *_dest, sUI _off, sUI _num, sBool _resize); // read _num bytes into buffer starting at buffer offset _off. resize buffer if necessary and _resize==true. return number of bytes actually read
  1114. virtual sSI YAC_VCALL yacStreamReadLine (YAC_String *_s, sUI _maxlen);
  1115. virtual sSI YAC_VCALL yacStreamWrite (sU8 *, sUI _num); // write _num bytes from _buf into stream. return number of bytes actually written.
  1116. virtual void YAC_VCALL yacStreamWriteI8 (sU8); // write a single byte
  1117. virtual void YAC_VCALL yacStreamWriteI16 (sU16); // write a single word
  1118. virtual void YAC_VCALL yacStreamWriteI32 (sS32); // write a single double word
  1119. virtual void YAC_VCALL yacStreamWriteF32 (sF32); // write a standard IEEE 32bit float
  1120. virtual void YAC_VCALL yacStreamWriteObject (YAC_Object*); // serialize object into stream
  1121. virtual sSI YAC_VCALL yacStreamWriteString (YAC_String *, sUI _off, sUI _num); // write _num chars from string starting at string offset _off into stream. return number of chars (bytes) actually written.
  1122. virtual sSI YAC_VCALL yacStreamWriteBuffer (YAC_Buffer *_buf, sUI _off, sUI _num); // write _num bytes from _buf starting at buffer offset _off into stream. return number of bytes actually written.
  1123. virtual sSI YAC_VCALL yacStreamGetErrorCode (void); // return last error code (or 0==no error)
  1124. virtual void YAC_VCALL yacStreamGetErrorStringByCode (sSI _code, YAC_Value *_r); // convert last error code to human readable string
  1125. virtual sF64 YAC_VCALL yacStreamReadF64 (void); // read standard IEEE 64bit double
  1126. virtual void YAC_VCALL yacStreamWriteF64 (sF64); // write a standard IEEE 64bit double
  1127. virtual sU64 YAC_VCALL yacStreamReadI64 (void); // read 64bit signed long long
  1128. virtual void YAC_VCALL yacStreamWriteI64 (sS64); // write 64bit signed long long
  1129. virtual void YAC_VCALL vtable_entry_2_35_reserved (void);
  1130. virtual void YAC_VCALL vtable_entry_2_36_reserved (void);
  1131. virtual void YAC_VCALL vtable_entry_2_37_reserved (void);
  1132. virtual void YAC_VCALL vtable_entry_2_38_reserved (void);
  1133. virtual void YAC_VCALL vtable_entry_2_39_reserved (void);
  1134. virtual void YAC_VCALL vtable_entry_2_40_reserved (void);
  1135. virtual void YAC_VCALL vtable_entry_2_41_reserved (void);
  1136. virtual void YAC_VCALL vtable_entry_2_42_reserved (void);
  1137. virtual void YAC_VCALL vtable_entry_2_43_reserved (void);
  1138. virtual void YAC_VCALL vtable_entry_2_44_reserved (void);
  1139. virtual void YAC_VCALL vtable_entry_2_45_reserved (void);
  1140. virtual void YAC_VCALL vtable_entry_2_46_reserved (void);
  1141. virtual void YAC_VCALL vtable_entry_2_47_reserved (void);
  1142. // ----
  1143. // ----
  1144. // ---- LEVEL (1<<3) interface
  1145. // ---- ( serialization support )
  1146. // ----
  1147. // ----
  1148. // ----
  1149. virtual void YAC_VCALL yacSerializeClassName (YAC_Object *_ofs); // write pascal style string (sU32 len + string chars) to stream _ofs. may differ from yacClassName()
  1150. virtual void YAC_VCALL yacSerialize (YAC_Object *_ofs, sUI _usetypeinfo); // serialize object into _ofs stream
  1151. virtual sUI YAC_VCALL yacDeserialize (YAC_Object *_ifs, sUI _usetypeinfo); // deserialize object from _ifs stream
  1152. virtual void YAC_VCALL vtable_entry_3_3_reserved (void);
  1153. virtual void YAC_VCALL vtable_entry_3_4_reserved (void);
  1154. virtual void YAC_VCALL vtable_entry_3_5_reserved (void);
  1155. virtual void YAC_VCALL vtable_entry_3_6_reserved (void);
  1156. virtual void YAC_VCALL vtable_entry_3_7_reserved (void);
  1157. virtual void YAC_VCALL vtable_entry_3_8_reserved (void);
  1158. virtual void YAC_VCALL vtable_entry_3_9_reserved (void);
  1159. virtual void YAC_VCALL vtable_entry_3_10_reserved (void);
  1160. virtual void YAC_VCALL vtable_entry_3_11_reserved (void);
  1161. virtual void YAC_VCALL vtable_entry_3_12_reserved (void);
  1162. virtual void YAC_VCALL vtable_entry_3_13_reserved (void);
  1163. virtual void YAC_VCALL vtable_entry_3_14_reserved (void);
  1164. virtual void YAC_VCALL vtable_entry_3_15_reserved (void);
  1165. // ----
  1166. // ----
  1167. // ---- LEVEL (1<<4) interface
  1168. // ---- ( iterator support )
  1169. // ----
  1170. // ----
  1171. // ----
  1172. virtual sBool YAC_VCALL yacIteratorInit (YAC_Iterator *) const; // initialize iterator for a container-like object. The maximum size of an iterator is YAC_MAX_ITERATOR_SIZE bytes.
  1173. virtual void YAC_VCALL vtable_entry_4_1_reserved (void);
  1174. virtual void YAC_VCALL vtable_entry_4_2_reserved (void);
  1175. virtual void YAC_VCALL vtable_entry_4_3_reserved (void);
  1176. virtual void YAC_VCALL vtable_entry_4_4_reserved (void);
  1177. virtual void YAC_VCALL vtable_entry_4_5_reserved (void);
  1178. virtual void YAC_VCALL vtable_entry_4_6_reserved (void);
  1179. virtual void YAC_VCALL vtable_entry_4_7_reserved (void);
  1180. virtual void YAC_VCALL vtable_entry_4_8_reserved (void);
  1181. virtual void YAC_VCALL vtable_entry_4_9_reserved (void);
  1182. virtual void YAC_VCALL vtable_entry_4_10_reserved (void);
  1183. virtual void YAC_VCALL vtable_entry_4_11_reserved (void);
  1184. virtual void YAC_VCALL vtable_entry_4_12_reserved (void);
  1185. virtual void YAC_VCALL vtable_entry_4_13_reserved (void);
  1186. virtual void YAC_VCALL vtable_entry_4_14_reserved (void);
  1187. virtual void YAC_VCALL vtable_entry_4_15_reserved (void);
  1188. // ----
  1189. // ----
  1190. // ---- LEVEL (1<<5) interface
  1191. // ---- ( array and hashtable support )
  1192. // ----
  1193. // ----
  1194. // ----
  1195. virtual YAC_Object *YAC_VCALL yacArrayNew (void); // return array class instance for "scalar" type. e.g. return yac_host->yacNew("MyClassArray");
  1196. virtual sUI YAC_VCALL yacArrayAlloc (sUI _sx, sUI _sy=0, sUI _type=0, sUI _elementbytesize=0); // allocate new array elements
  1197. virtual sUI YAC_VCALL yacArrayRealloc (sUI _sx, sUI _sy=0, sUI _type=0, sUI _elementbytesize=0); // re-allocate new array elements
  1198. virtual sUI YAC_VCALL yacArrayGetNumElements (void); // return number of used elements in array
  1199. virtual sUI YAC_VCALL yacArrayGetMaxElements (void); // return maximum array size (buffer size)
  1200. virtual void YAC_VCALL yacArrayCopySize (YAC_Object *_arrayobject); // copy size of other array object (used to construct arrays from default objects, e.g. a class template)
  1201. virtual void YAC_VCALL yacArraySet (void *_context, sUI _index, YAC_Value *_value); // set an array value
  1202. virtual void YAC_VCALL yacArrayGet (void *_context, sUI _index, YAC_Value *_r); // get an array value (references only)
  1203. virtual sUI YAC_VCALL yacArrayGetWidth (void); // get width of array object (x maxElements)
  1204. virtual sUI YAC_VCALL yacArrayGetHeight (void); // get height of array object (y maxElements)
  1205. virtual sUI YAC_VCALL yacArrayGetElementType (void); // 0=no array,1=int,2=float,3=object,4=string
  1206. virtual sUI YAC_VCALL yacArrayGetElementByteSize (void); // # of bytes per element
  1207. virtual sUI YAC_VCALL yacArrayGetStride (void); // # of bytes to next row
  1208. virtual void *YAC_VCALL yacArrayGetPointer (void); // get pointer to first element of array object
  1209. virtual void YAC_VCALL yacArraySetWidth (sUI); // set # of used elements
  1210. virtual void YAC_VCALL yacArraySetTemplate (YAC_Object *); // set template for yacArrayAlloc(). Used for object and class arrays.
  1211. virtual void YAC_VCALL yacArrayGetDeref (void *_context, sUI _index, YAC_Value *_r); // get/unlink value from array
  1212. virtual void YAC_VCALL vtable_entry_5_17_reserved (void);
  1213. virtual void YAC_VCALL vtable_entry_5_18_reserved (void);
  1214. virtual void YAC_VCALL vtable_entry_5_19_reserved (void);
  1215. virtual void YAC_VCALL vtable_entry_5_20_reserved (void);
  1216. virtual void YAC_VCALL vtable_entry_5_21_reserved (void);
  1217. virtual void YAC_VCALL vtable_entry_5_22_reserved (void);
  1218. virtual void YAC_VCALL vtable_entry_5_23_reserved (void);
  1219. virtual void YAC_VCALL vtable_entry_5_24_reserved (void);
  1220. virtual void YAC_VCALL vtable_entry_5_25_reserved (void);
  1221. virtual void YAC_VCALL vtable_entry_5_26_reserved (void);
  1222. virtual void YAC_VCALL vtable_entry_5_27_reserved (void);
  1223. virtual void YAC_VCALL vtable_entry_5_28_reserved (void);
  1224. virtual void YAC_VCALL vtable_entry_5_29_reserved (void);
  1225. virtual void YAC_VCALL vtable_entry_5_30_reserved (void);
  1226. virtual void YAC_VCALL vtable_entry_5_31_reserved (void);
  1227. virtual void YAC_VCALL yacHashSet (void *_context, YAC_String*_key, YAC_Value *_value); // set value
  1228. virtual void YAC_VCALL yacHashGet (void *_context, YAC_String*_key, YAC_Value *_r); // get value (reference)
  1229. virtual void YAC_VCALL yacHashGetDeref (void *_context, YAC_String*_key, YAC_Value *_r); // get value
  1230. virtual void YAC_VCALL vtable_entry_5_35_reserved (void);
  1231. virtual void YAC_VCALL vtable_entry_5_36_reserved (void);
  1232. virtual void YAC_VCALL vtable_entry_5_37_reserved (void);
  1233. virtual void YAC_VCALL vtable_entry_5_38_reserved (void);
  1234. virtual void YAC_VCALL vtable_entry_5_39_reserved (void);
  1235. // ----
  1236. // ----
  1237. // ---- LEVEL (1<<6) interface
  1238. // ---- ( metaclass support )
  1239. // ----
  1240. // ----
  1241. // ----
  1242. virtual sChar *YAC_VCALL yacMetaClassName (void); // get meta class class name of object (e.g. user defined class name)
  1243. virtual sUI YAC_VCALL yacMetaClassMemberGetNum (void); // get number of members
  1244. virtual sUI YAC_VCALL yacMetaClassMemberGetAccessKeyByIndex (sUI _idx); // get access key to member nr. _idx
  1245. virtual sUI YAC_VCALL yacMetaClassMemberGetAccessKeyByName (const sChar *_name); // get access key to member called _name
  1246. virtual sUI YAC_VCALL yacMetaClassMemberGetType (sUI _accesskey); // get member type (0=void,1=int,2=float,3=object)
  1247. virtual sChar *YAC_VCALL yacMetaClassMemberGetName (sUI _accesskey); // get member name by access key
  1248. virtual void YAC_VCALL yacMetaClassMemberSet (sUI _accesskey, YAC_Value *_value); // set member value
  1249. virtual void YAC_VCALL yacMetaClassMemberGet (sUI _accesskey, YAC_Value *_r); // get member value
  1250. virtual sSI YAC_VCALL yacMetaClassInstanceOf (YAC_Object *_object); // check if this is an instance of _object meta class type
  1251. virtual void YAC_VCALL vtable_entry_6_10_reserved (void);
  1252. virtual void YAC_VCALL vtable_entry_6_11_reserved (void);
  1253. virtual void YAC_VCALL vtable_entry_6_12_reserved (void);
  1254. virtual void YAC_VCALL vtable_entry_6_13_reserved (void);
  1255. virtual void YAC_VCALL vtable_entry_6_14_reserved (void);
  1256. virtual void YAC_VCALL vtable_entry_6_15_reserved (void);
  1257. // ----
  1258. // ----
  1259. // ---- LEVEL (1<<7) interface
  1260. // ---- ( signal/callback support )
  1261. // ----
  1262. // ----
  1263. // ----
  1264. virtual void YAC_VCALL yacRegisterSignal (sUI _id, YAC_FunctionHandle _f); // register script function callback for signal _id (sequential index of signal name in signal list, see below)
  1265. virtual void YAC_VCALL yacGetSignalStringList (YAC_String *_retstring); // write signal name+rtti list to _retstring. example: "onSignal:1 onKeyboard:3 onMouse:85 ". the signals are enumerated (starting with 0) , see yacRegisterSignal()
  1266. // ----
  1267. // ----
  1268. // ---- non-virtual helper methods
  1269. // ----
  1270. // ----
  1271. // ----
  1272. YAC_Object * yacNew (YAC_ContextHandle _context); // call yacNewObject() and yacOperatorInit()
  1273. YAC_Object * yacNewPooled (YAC_ContextHandle _context, sUI _poolHint); // call yacNewObject() and yacOperatorInit()
  1274. sBool yacCanDeserializeClass (YAC_Object *_stream); // read up to 64 chars from stream and compare with class name. implemented below.
  1275. sBool yacInstanceOf (YAC_Object *_object); // check if this is an instance of _object class type
  1276. #ifdef YAC_OBJECT_YAC
  1277. // ---- YAC interface for YAC_Object itself
  1278. YM void _yacClassName (YAC_Value *_r);
  1279. YM void _yacNewObject (YAC_Value *_r);
  1280. // ---- m e m b e r s
  1281. YM sSI _yacMemberGetNum (void);
  1282. YM void _yacMemberGetNames (YAC_Value *_r);
  1283. YM void _yacMemberGetTypes (YAC_Value *_r);
  1284. YM void _yacMemberGetObjectTypes (YAC_Value *_r);
  1285. YM void _yacMemberGetOffsets (YAC_Value *_r);
  1286. // ---- m e t h o d s
  1287. YM sSI _yacMethodGetNum (void);
  1288. YM void _yacMethodGetNames (YAC_Value *_r);
  1289. YM void _yacMethodGetNumParameters (YAC_Value *_r);
  1290. YM void _yacMethodGetParameterTypes (YAC_Value *_r);
  1291. YM void _yacMethodGetParameterObjectTypes (YAC_Value *_r);
  1292. YM void _yacMethodGetReturnTypes (YAC_Value *_r);
  1293. YM void _yacMethodGetReturnObjectTypes (YAC_Value *_r);
  1294. YM void _yacMethodGetAdr (YAC_Value *_r);
  1295. // ---- c o n s t a n t s
  1296. YM sSI _yacConstantGetNum (void);
  1297. YM void _yacConstantGetNames (YAC_Value *_r);
  1298. YM void _yacConstantGetTypes (YAC_Value *_r);
  1299. YM void _yacConstantGetValues (YAC_Value *_r);
  1300. // ---- o p e r a t o r s
  1301. YM sSI _yacCopy (YAC_Object *_os);
  1302. YM sSI _yacEquals (YAC_Object *_ro);
  1303. YM void _yacOperator (sSI _cmd, YAC_Object *_ro, YAC_Value *_r);
  1304. YM void _yacOperatorInit (YAC_Object *_ro);
  1305. YM void _yacOperatorAssign (YAC_Object *_ro);
  1306. YM void _yacOperatorAdd (YAC_Object *_ro);
  1307. YM void _yacOperatorSub (YAC_Object *_ro);
  1308. YM void _yacOperatorMul (YAC_Object *_ro);
  1309. YM void _yacOperatorDiv (YAC_Object *_ro);
  1310. YM void _yacOperatorClamp (YAC_Object *_min, YAC_Object *_max);
  1311. YM void _yacOperatorWrap (YAC_Object *_min, YAC_Object *_max);
  1312. YM sSI _yacScanI32 (YAC_Object *_vo);
  1313. YM sSI _yacScanI64 (YAC_Object *_vo);
  1314. YM sSI _yacScanF32 (YAC_Object *_vo);
  1315. YM sSI _yacScanF64 (YAC_Object *_vo);
  1316. YM sSI _yacToString (YAC_Object *_s) const;
  1317. YM void _yacOperatorI (sSI _cmd, sSI _i, YAC_Value *_r);
  1318. YM void _yacOperatorI64 (sSI _cmd, YAC_Object *_no, YAC_Value *_r);
  1319. YM void _yacOperatorF32 (sSI _cmd, sF32 _f32, YAC_Value *_r);
  1320. YM void _yacOperatorF64 (sSI _cmd, YAC_Object *_no, YAC_Value *_r);
  1321. YM void _yacValueOfI (sSI _i);
  1322. YM void _yacValueOfF32 (sF32 _f32);
  1323. YM void _yacValueOfF64 (YAC_Object *_no);
  1324. YM void _yacValueOfI64 (YAC_Object *_no);
  1325. YM sSI _yacToParsableString (YAC_Object *_s) const;
  1326. // ---- s t r e a m s
  1327. YM sSI _yacIsStream (void);
  1328. YM void _yacStreamClose (void);
  1329. YM sSI _yacStreamOpenLocal (YAC_Object *_name, sSI _access);
  1330. YM sSI _yacStreamOpenLogic (YAC_Object *_name);
  1331. YM sSI _yacStreamGetByteOrder (void);
  1332. YM void _yacStreamSetByteOrder (sSI _order);
  1333. YM sSI _yacStreamEOF (void);
  1334. YM void _yacStreamSeek (sSI _off, sSI _mode);
  1335. YM sSI _yacStreamGetOffset (void);
  1336. YM void _yacStreamSetOffset (sSI _off);
  1337. YM sSI _yacStreamGetSize (void);
  1338. YM sSI _yacStreamRead (YAC_Object *_ret, sSI _num);
  1339. YM sSI _yacStreamReadI8 (void);
  1340. YM sSI _yacStreamReadI16 (void);
  1341. YM sSI _yacStreamReadI32 (void);
  1342. YM void _yacStreamReadI64 (YAC_Value *_r);
  1343. YM sF32 _yacStreamReadF32 (void);
  1344. YM void _yacStreamReadF64 (YAC_Value *_r);
  1345. YM void _yacStreamReadObject (YAC_Object *_p);
  1346. YM sSI _yacStreamReadString (YAC_Object *_s, sSI _maxlen);
  1347. YM sSI _yacStreamReadBuffer (YAC_Object *_buffer, sSI _off, sSI _num, sSI _resize);
  1348. YM sSI _yacStreamReadLine (YAC_Object *_s, sSI _maxlen);
  1349. YM sSI _yacStreamWrite (YAC_Object *_in, sSI _num);
  1350. YM void _yacStreamWriteI8 (sSI _i);
  1351. YM void _yacStreamWriteI16 (sSI _i);
  1352. YM void _yacStreamWriteI32 (sSI _i);
  1353. YM void _yacStreamWriteI64 (YAC_Object *_no);
  1354. YM void _yacStreamWriteF32 (sF32 _f);
  1355. YM void _yacStreamWriteF64 (YAC_Object *_no);
  1356. YM void _yacStreamWriteObject (YAC_Object *_p);
  1357. YM sSI _yacStreamWriteString (YAC_Object *_s, sSI _off, sSI _num);
  1358. YM sSI _yacStreamWriteBuffer (YAC_Object *_b, sSI _off, sSI _num);
  1359. YM sSI _yacStreamGetErrorCode (void);
  1360. YM void _yacStreamGetErrorStringByCode (sSI _code, YAC_Value *_r);
  1361. YM void _yacSerializeClassName (YAC_Object *_ofs);
  1362. YM void _yacSerialize (YAC_Object *_ofs, sSI _usetypeinfo);
  1363. YM sSI _yacDeserialize (YAC_Object *_ifs, sSI _usetypeinfo);
  1364. // ---- i t e r a t o r s
  1365. // ...
  1366. // ---- a r r a y s / h a s h t a b l e s
  1367. YM void _yacArrayNew (YAC_Value *_r);
  1368. YM sSI _yacArrayAlloc (sSI _sx, sSI _sy, sSI _type, sSI _ebytesize);
  1369. YM sSI _yacArrayRealloc (sSI _sx, sSI _sy, sSI _type, sSI _ebytesize);
  1370. YM sSI _yacArrayGetNumElements (void);
  1371. YM sSI _yacArrayGetMaxElements (void);
  1372. YM void _yacArrayCopySize (YAC_Object *_p);
  1373. YM void _yacArraySet (sSI _index, YAC_Object *_value);
  1374. YM void _yacArrayGet (sSI _index, YAC_Value *_r);
  1375. YM sSI _yacArrayGetWidth (void);
  1376. YM sSI _yacArrayGetHeight (void);
  1377. YM sSI _yacArrayGetElementType (void);
  1378. YM sSI _yacArrayGetElementByteSize (void);
  1379. YM sSI _yacArrayGetStride (void);
  1380. YM sSI _yacArrayGetPointer (void);
  1381. YM void _yacArraySetWidth (sSI _width);
  1382. YM void _yacArraySetTemplate (YAC_Object *_template);
  1383. YM void _yacArrayGetDeref (sSI _index, YAC_Value *_r);
  1384. YM void _yacHashSet (YAC_Object *_key, YAC_Object *_value);
  1385. YM void _yacHashGet (YAC_Object *_key, YAC_Value *_r);
  1386. YM void _yacHashGetDeref (YAC_Object *_key, YAC_Value *_r);
  1387. // ---- s i g n a l s
  1388. YM void _yacGetSignalStringList (YAC_Object *_s);
  1389. // ---- m e t a c l a s s e s
  1390. YM void _yacMetaClassName (YAC_Value *_r);
  1391. YM sSI _yacMetaClassMemberGetNum (void);
  1392. YM sSI _yacMetaClassMemberGetAccessKeyByIndex (sSI _index);
  1393. YM sSI _yacMetaClassMemberGetAccessKeyByName (YAC_Object *_s);
  1394. YM sSI _yacMetaClassMemberGetType (sSI _ak);
  1395. YM void _yacMetaClassMemberGetName (sSI _ak, YAC_Value *_r);
  1396. YM void _yacMetaClassMemberSet (sSI _ak, YAC_Object *_value);
  1397. YM void _yacMetaClassMemberGet (sSI _ak, YAC_Value *_r);
  1398. YM sSI _yacMetaClassInstanceOf (YAC_Object *_o);
  1399. // ---- n o n - v i r t u a l
  1400. YM void _yacNew (YAC_Value *_r);
  1401. YM sSI _yacCanDeserializeClass (YAC_Object *_ifs);
  1402. YM sSI _yacInstanceOf (YAC_Object *_o);
  1403. #endif
  1404. };
  1405. YAC_API void YAC_CALL Object__operator(void*,yacmemptr,YAC_Value*);
  1406. #ifdef YAC_OBJECT_YAC
  1407. // ---- forward declarations for external YAC_Object YAC interface implementation ----
  1408. YAC_APIC void YAC_CALL yac_object_yacClassName (YAC_Object *_this, YAC_Value *_r);
  1409. YAC_APIC void YAC_CALL yac_object_yacNewObject (YAC_Object *_this, YAC_Value *_r);
  1410. // ---- m e m b e r s
  1411. YAC_APIC sSI YAC_CALL yac_object_yacMemberGetNum (YAC_Object *_this);
  1412. YAC_APIC void YAC_CALL yac_object_yacMemberGetNames (YAC_Object *_this, YAC_Value *_r);
  1413. YAC_APIC void YAC_CALL yac_object_yacMemberGetTypes (YAC_Object *_this, YAC_Value *_r);
  1414. YAC_APIC void YAC_CALL yac_object_yacMemberGetObjectTypes (YAC_Object *_this, YAC_Value *_r);
  1415. YAC_APIC void YAC_CALL yac_object_yacMemberGetOffsets (YAC_Object *_this, YAC_Value *_r);
  1416. // ---- m e t h o d s
  1417. YAC_APIC sSI YAC_CALL yac_object_yacMethodGetNum (YAC_Object *_this);
  1418. YAC_APIC void YAC_CALL yac_object_yacMethodGetNames (YAC_Object *_this, YAC_Value *_r);
  1419. YAC_APIC void YAC_CALL yac_object_yacMethodGetNumParameters (YAC_Object *_this, YAC_Value *_r);
  1420. YAC_APIC void YAC_CALL yac_object_yacMethodGetParameterTypes (YAC_Object *_this, YAC_Value *_r);
  1421. YAC_APIC void YAC_CALL yac_object_yacMethodGetParameterObjectTypes(YAC_Object *_this, YAC_Value *_r);
  1422. YAC_APIC void YAC_CALL yac_object_yacMethodGetReturnTypes (YAC_Object *_this, YAC_Value *_r);
  1423. YAC_APIC void YAC_CALL yac_object_yacMethodGetReturnObjectTypes (YAC_Object *_this, YAC_Value *_r);
  1424. YAC_APIC void YAC_CALL yac_object_yacMethodGetAdr (YAC_Object *_this, YAC_Value *_r);
  1425. // ---- c o n s t a n t s
  1426. YAC_APIC sSI YAC_CALL yac_object_yacConstantGetNum (YAC_Object *_this);
  1427. YAC_APIC void YAC_CALL yac_object_yacConstantGetNames (YAC_Object *_this, YAC_Value *_r);
  1428. YAC_APIC void YAC_CALL yac_object_yacConstantGetTypes (YAC_Object *_this, YAC_Value *_r);
  1429. YAC_APIC void YAC_CALL yac_object_yacConstantGetValues (YAC_Object *_this, YAC_Value *_r);
  1430. // ---- o p e r a t o r s
  1431. YAC_APIC sSI YAC_CALL yac_object_yacCopy (YAC_Object *_this, YAC_Object *_os);
  1432. YAC_APIC sSI YAC_CALL yac_object_yacEquals (YAC_Object *_this, YAC_Object *_ro);
  1433. YAC_APIC void YAC_CALL yac_object_yacOperator (YAC_Object *_this, sSI _cmd, YAC_Object *_ro, YAC_Value *_r);
  1434. YAC_APIC void YAC_CALL yac_object_yacOperatorInit (YAC_Object *_this, YAC_Object *_ro);
  1435. YAC_APIC void YAC_CALL yac_object_yacOperatorAssign (YAC_Object *_this, YAC_Object *_ro);
  1436. YAC_APIC void YAC_CALL yac_object_yacOperatorAdd (YAC_Object *_this, YAC_Object *_ro);
  1437. YAC_APIC void YAC_CALL yac_object_yacOperatorSub (YAC_Object *_this, YAC_Object *_ro);
  1438. YAC_APIC void YAC_CALL yac_object_yacOperatorMul (YAC_Object *_this, YAC_Object *_ro);
  1439. YAC_APIC void YAC_CALL yac_object_yacOperatorDiv (YAC_Object *_this, YAC_Object *_ro);
  1440. YAC_APIC void YAC_CALL yac_object_yacOperatorClamp (YAC_Object *_this, YAC_Object *_min, YAC_Object *_max);
  1441. YAC_APIC void YAC_CALL yac_object_yacOperatorWrap (YAC_Object *_this, YAC_Object *_min, YAC_Object *_max);
  1442. YAC_APIC sSI YAC_CALL yac_object_yacScanI32 (YAC_Object *_this, YAC_Object *_vo);
  1443. YAC_APIC sSI YAC_CALL yac_object_yacScanI64 (YAC_Object *_this, YAC_Object *_vo);
  1444. YAC_APIC sSI YAC_CALL yac_object_yacScanF32 (YAC_Object *_this, YAC_Object *_vo);
  1445. YAC_APIC sSI YAC_CALL yac_object_yacScanF64 (YAC_Object *_this, YAC_Object *_vo);
  1446. YAC_APIC sSI YAC_CALL yac_object_yacToString (const YAC_Object *_this, YAC_Object *_s);
  1447. YAC_APIC void YAC_CALL yac_object_yacOperatorI (YAC_Object *_this, sSI _cmd, sSI _i, YAC_Value *_r);
  1448. YAC_APIC void YAC_CALL yac_object_yacOperatorI64 (YAC_Object *_this, sSI _cmd, YAC_Object *_no, YAC_Value *_r);
  1449. YAC_APIC void YAC_CALL yac_object_yacOperatorF32 (YAC_Object *_this, sSI _cmd, sF32 _f32, YAC_Value *_r);
  1450. YAC_APIC void YAC_CALL yac_object_yacOperatorF64 (YAC_Object *_this, sSI _cmd, YAC_Object *_no, YAC_Value *_r);
  1451. YAC_APIC void YAC_CALL yac_object_yacValueOfI (YAC_Object *_this, sSI _i);
  1452. YAC_APIC void YAC_CALL yac_object_yacValueOfI64 (YAC_Object *_this, YAC_Object *_no);
  1453. YAC_APIC void YAC_CALL yac_object_yacValueOfF32 (YAC_Object *_this, sF32 _f32);
  1454. YAC_APIC void YAC_CALL yac_object_yacValueOfF64 (YAC_Object *_this, YAC_Object *_no);
  1455. YAC_APIC sSI YAC_CALL yac_object_yacToParsableString (const YAC_Object *_this, YAC_Object *_s);
  1456. // ---- s t r e a m s
  1457. YAC_APIC sSI YAC_CALL yac_object_yacIsStream (YAC_Object *_this);
  1458. YAC_APIC void YAC_CALL yac_object_yacStreamClose (YAC_Object *_this);
  1459. YAC_APIC sSI YAC_CALL yac_object_yacStreamOpenLocal (YAC_Object *_this, YAC_Object *_name, sSI _access);
  1460. YAC_APIC sSI YAC_CALL yac_object_yacStreamOpenLogic (YAC_Object *_this, YAC_Object *_name);
  1461. YAC_APIC sSI YAC_CALL yac_object_yacStreamGetByteOrder (YAC_Object *_this);
  1462. YAC_APIC void YAC_CALL yac_object_yacStreamSetByteOrder (YAC_Object *_this, sSI _order);
  1463. YAC_APIC sSI YAC_CALL yac_object_yacStreamEOF (YAC_Object *_this);
  1464. YAC_APIC void YAC_CALL yac_object_yacStreamSeek (YAC_Object *_this, sSI _off, sSI _mode);
  1465. YAC_APIC sSI YAC_CALL yac_object_yacStreamGetOffset (YAC_Object *_this);
  1466. YAC_APIC void YAC_CALL yac_object_yacStreamSetOffset (YAC_Object *_this, sSI _off);
  1467. YAC_APIC sSI YAC_CALL yac_object_yacStreamGetSize (YAC_Object *_this);
  1468. YAC_APIC sSI YAC_CALL yac_object_yacStreamRead (YAC_Object *_this, YAC_Object *_ret, sSI _num);
  1469. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadI8 (YAC_Object *_this);
  1470. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadI16 (YAC_Object *_this);
  1471. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadI32 (YAC_Object *_this);
  1472. YAC_APIC void YAC_CALL yac_object_yacStreamReadI64 (YAC_Object *_this, YAC_Value *_r);
  1473. YAC_APIC sF32 YAC_CALL yac_object_yacStreamReadF32 (YAC_Object *_this);
  1474. YAC_APIC void YAC_CALL yac_object_yacStreamReadF64 (YAC_Object *_this, YAC_Value *_r);
  1475. YAC_APIC void YAC_CALL yac_object_yacStreamReadObject (YAC_Object *_this, YAC_Object *_p);
  1476. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadString (YAC_Object *_this, YAC_Object *_s, sSI _maxlen);
  1477. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadBuffer (YAC_Object *_this, YAC_Object *_buf, sSI _off, sSI _n, sSI _resize);
  1478. YAC_APIC sSI YAC_CALL yac_object_yacStreamReadLine (YAC_Object *_this, YAC_Object *_s, sSI _maxlen);
  1479. YAC_APIC sSI YAC_CALL yac_object_yacStreamWrite (YAC_Object *_this, YAC_Object *_in, sSI _num);
  1480. YAC_APIC void YAC_CALL yac_object_yacStreamWriteI8 (YAC_Object *_this, sSI _i);
  1481. YAC_APIC void YAC_CALL yac_object_yacStreamWriteI16 (YAC_Object *_this, sSI _i);
  1482. YAC_APIC void YAC_CALL yac_object_yacStreamWriteI32 (YAC_Object *_this, sSI _i);
  1483. YAC_APIC void YAC_CALL yac_object_yacStreamWriteI64 (YAC_Object *_this, YAC_Object *_no);
  1484. YAC_APIC void YAC_CALL yac_object_yacStreamWriteF32 (YAC_Object *_this, sF32 _f);
  1485. YAC_APIC void YAC_CALL yac_object_yacStreamWriteF64 (YAC_Object *_this, YAC_Object *_no);
  1486. YAC_APIC void YAC_CALL yac_object_yacStreamWriteObject (YAC_Object *_this, YAC_Object *_p);
  1487. YAC_APIC sSI YAC_CALL yac_object_yacStreamWriteString (YAC_Object *_this, YAC_Object *_s, sSI _off, sSI _num);
  1488. YAC_APIC sSI YAC_CALL yac_object_yacStreamWriteBuffer (YAC_Object *_this, YAC_Object *_b, sSI _off, sSI _num);
  1489. YAC_APIC sSI YAC_CALL yac_object_yacStreamGetErrorCode (YAC_Object *_this);
  1490. YAC_APIC void YAC_CALL yac_object_yacStreamGetErrorStringByCode (YAC_Object *_this, sSI _code, YAC_Value *_r);
  1491. // ---- s e r i a l i z a t i o n
  1492. YAC_APIC void YAC_CALL yac_object_yacSerializeClassName (YAC_Object *_this, YAC_Object *_ofs);
  1493. YAC_APIC void YAC_CALL yac_object_yacSerialize (YAC_Object *_this, YAC_Object *_ofs, sSI _usetypeinfo);
  1494. YAC_APIC sSI YAC_CALL yac_object_yacDeserialize (YAC_Object *_this, YAC_Object *_ifs, sSI _usetypeinfo);
  1495. // ---- i t e r a t o r s
  1496. // ---- a r r a y s / h a s h t a b l e s
  1497. YAC_APIC void YAC_CALL yac_object_yacArrayNew (YAC_Object *_this, YAC_Value *_r);
  1498. YAC_APIC sSI YAC_CALL yac_object_yacArrayAlloc (YAC_Object *_this, sSI _sx, sSI _sy, sSI _type, sSI _ebytesize);
  1499. YAC_APIC sSI YAC_CALL yac_object_yacArrayRealloc (YAC_Object *_this, sSI _sx, sSI _sy, sSI _type, sSI _ebytesize);
  1500. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetNumElements (YAC_Object *_this);
  1501. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetMaxElements (YAC_Object *_this);
  1502. YAC_APIC void YAC_CALL yac_object_yacArrayCopySize (YAC_Object *_this, YAC_Object *_p);
  1503. YAC_APIC void YAC_CALL yac_object_yacArraySet (YAC_Object *_this, sSI _index, YAC_Object *_value);
  1504. YAC_APIC void YAC_CALL yac_object_yacArrayGet (YAC_Object *_this, sSI _index, YAC_Value *_r);
  1505. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetWidth (YAC_Object *_this);
  1506. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetHeight (YAC_Object *_this);
  1507. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetElementType (YAC_Object *_this);
  1508. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetElementByteSize (YAC_Object *_this);
  1509. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetStride (YAC_Object *_this);
  1510. YAC_APIC sSI YAC_CALL yac_object_yacArrayGetPointer (YAC_Object *_this);
  1511. YAC_APIC void YAC_CALL yac_object_yacArraySetWidth (YAC_Object *_this, sSI _width);
  1512. YAC_APIC void YAC_CALL yac_object_yacArraySetTemplate (YAC_Object *_this, YAC_Object *_template);
  1513. YAC_APIC void YAC_CALL yac_object_yacArrayGetDeref (YAC_Object *_this, sSI _index, YAC_Value *_r);
  1514. YAC_APIC void YAC_CALL yac_object_yacHashSet (YAC_Object *_this, YAC_Object *_key, YAC_Object *_value);
  1515. YAC_APIC void YAC_CALL yac_object_yacHashGet (YAC_Object *_this, YAC_Object *_key, YAC_Value *_r);
  1516. YAC_APIC void YAC_CALL yac_object_yacHashGetDeref (YAC_Object *_this, YAC_Object *_key, YAC_Value *_r);
  1517. // ---- s i g n a l s
  1518. YAC_APIC void YAC_CALL yac_object_yacGetSignalStringList (YAC_Object *_this, YAC_Object *_s);
  1519. // ---- m e t a c l a s s e s
  1520. YAC_APIC void YAC_CALL yac_object_yacMetaClassName (YAC_Object *_this, YAC_Value *_r);
  1521. YAC_APIC sSI YAC_CALL yac_object_yacMetaClassMemberGetNum (YAC_Object *_this);
  1522. YAC_APIC sSI YAC_CALL yac_object_yacMetaClassMemberGetAccessKeyByIndex (YAC_Object *_this, sSI _index);
  1523. YAC_APIC sSI YAC_CALL yac_object_yacMetaClassMemberGetAccessKeyByName (YAC_Object *_this, YAC_Object *_s);
  1524. YAC_APIC sSI YAC_CALL yac_object_yacMetaClassMemberGetType (YAC_Object *_this, sSI _ak);
  1525. YAC_APIC void YAC_CALL yac_object_yacMetaClassMemberGetName (YAC_Object *_this, sSI _ak, YAC_Value *_r);
  1526. YAC_APIC void YAC_CALL yac_object_yacMetaClassMemberSet (YAC_Object *_this, sSI _ak, YAC_Object *_value);
  1527. YAC_APIC void YAC_CALL yac_object_yacMetaClassMemberGet (YAC_Object *_this, sSI _ak, YAC_Value *_r);
  1528. YAC_APIC sSI YAC_CALL yac_object_yacMetaClassInstanceOf (YAC_Object *_this, YAC_Object *_o);
  1529. // ---- n o n - v i r t u a l
  1530. YAC_APIC void YAC_CALL yac_object_yacNew (YAC_Object *_this, YAC_Value *_r);
  1531. YAC_APIC sSI YAC_CALL yac_object_yacCanDeserializeClass (YAC_Object *_this, YAC_Object *_ifs);
  1532. YAC_APIC sSI YAC_CALL yac_object_yacInstanceOf (YAC_Object *_this, YAC_Object *_o);
  1533. #endif // YAC_OBJECT_YAC
  1534. #ifndef YAC_CUST_VALUE
  1535. // ---- YAC_Object representation of a YAC_Value ----
  1536. class YAC_API YAC_ValueObject : public YAC_Object, public YAC_Value {
  1537. };
  1538. // ---- an array of YAC_Values ----
  1539. class YAC_ValueArray : public YAC_Object {
  1540. public:
  1541. sUI max_elements;
  1542. sUI num_elements;
  1543. YAC_Value *elements; // arbitrary int/float/Object values
  1544. YAC_ValueArray(void) {
  1545. max_elements = 0;
  1546. num_elements = 0;
  1547. elements = NULL;
  1548. }
  1549. };
  1550. // ---- an array of YAC_Objects wrapped in YAC_Values ----
  1551. class YAC_PointerArray : public YAC_Object {
  1552. public:
  1553. sUI max_elements;
  1554. sUI num_elements;
  1555. YAC_Value *elements; // only Object values allowed
  1556. YAC_PointerArray(void) {
  1557. max_elements = 0;
  1558. num_elements = 0;
  1559. elements = NULL;
  1560. }
  1561. sBool realloc (sUI _maxElements);
  1562. sBool add (YAC_Object *_o, sBool _bDelete);
  1563. void removeIndex (sUI _idx);
  1564. sSI indexOfPointer(YAC_Object *_o, sUI _off);
  1565. };
  1566. #endif // YAC_CUST_VALUE
  1567. #ifndef YAC_CUST_EVENT
  1568. // ---- event class; a time-stamped String ----
  1569. class YAC_API YAC_Event : public YAC_ValueObject {
  1570. public:
  1571. sSI id;
  1572. sSI sub_id;
  1573. public:
  1574. YAC_Event (void);
  1575. ~YAC_Event();
  1576. };
  1577. #endif // YAC_CUST_EVENT
  1578. // ---- seek modes for streams, see yacStreamSeek() ----
  1579. enum __yac_stream_seekmodes {
  1580. YAC_BEG =0,
  1581. YAC_CUR =1,
  1582. YAC_END =2
  1583. };
  1584. // ---- byte order for streams, see yacStreamGetByteOrder(), yacStreamSetByteOrder()
  1585. enum __yac_stream_byteorder {
  1586. YAC_LITTLEENDIAN =0,
  1587. YAC_BIGENDIAN =1
  1588. };
  1589. // ---- open modes for yacStreamOpenLocal()
  1590. enum __yac_stream_openmodes {
  1591. YAC_IOS_IN =0,
  1592. YAC_IOS_OUTIN =1,
  1593. YAC_IOS_INOUT =2
  1594. };
  1595. // ---- file stream types
  1596. enum __yac_stream_openmodesx {
  1597. YAC_LOGIC =0,
  1598. YAC_LOCAL =1
  1599. };
  1600. // ---- error codes for yacStream*() interface, see yacStreamGetErrorCode()
  1601. enum __streamerrorcodes {
  1602. YAC_NOERROR =0,
  1603. YAC_ERRINVALIDSEEK=1,
  1604. YAC_ERRIO,
  1605. YAC_ERRCREATEFILE,
  1606. YAC_ERROPENFILE,
  1607. YAC_ERRPAD
  1608. };
  1609. // ---- also see Object::serialize(), Object::deserialize() ----
  1610. #define YAC_IS_STREAM(a) ((a)&&((a)->yacIsStream())) // test if class supports the stream interface
  1611. #define YAC_BEG_DESERIALIZE() if((_rtti)&&!yacCanDeserializeClass((_ifs)))return 0 // start object deserialization, read string from stream and compare with class name
  1612. #define YAC_BEG_SERIALIZE() if(_rtti){YAC_String s;char *t=(char*)yacMetaClassName();if(!t)t=(char*)yacClassName();s.visit(t);_ofs->yacStreamWriteString(&s, 0, s.length);} // start object serialization, write (meta) class name string into stream
  1613. #define YAC_SERIALIZE_I8(a) _ofs->yacStreamWriteI8(a) // write a byte (8bit)
  1614. #define YAC_SERIALIZE_I16(a) _ofs->yacStreamWriteI16(a) // write a 16bit word (with transparent byteorder conversion)
  1615. #define YAC_SERIALIZE_I32(a) _ofs->yacStreamWriteI32(a) // write a 32bit double word (with transparent byteorder conversion)
  1616. #define YAC_SERIALIZE_I64(a) _ofs->yacStreamWriteI64(a) // write a 64bit quad word (with transparent byteorder conversion)
  1617. #define YAC_SERIALIZE_F32(a) _ofs->yacStreamWriteF32(a) // write a 32bit IEEE float
  1618. #define YAC_SERIALIZE_F64(a) _ofs->yacStreamWriteF64(a) // write a 64bit IEEE double
  1619. #define YAC_SERIALIZE_OBJ(a) _ofs->yacStreamWriteObject(a) // write an object
  1620. #define YAC_DESERIALIZE_I8() _ifs->yacStreamReadI8() // read a byte (8bit)
  1621. #define YAC_DESERIALIZE_I16() _ifs->yacStreamReadI16() // read a 16bit word (with transparent byteorder conversion)
  1622. #define YAC_DESERIALIZE_I32() _ifs->yacStreamReadI32() // read a 32bit double word (with transparent byteorder conversion)
  1623. #define YAC_DESERIALIZE_I64() _ifs->yacStreamReadI64() // read a 64bit quad word (with transparent byteorder conversion)
  1624. #define YAC_DESERIALIZE_F32() _ifs->yacStreamReadF32() // read a 32bit IEEE float
  1625. #define YAC_DESERIALIZE_F64() _ifs->yacStreamReadF64() // read a 64bit IEEE double
  1626. #define YAC_DESERIALIZE_OBJ(a) _ifs->yacStreamReadObject(a) // read an object
  1627. // ---- base stream class with no methods ----
  1628. #ifndef YAC_CUST_STREAMBASE
  1629. class YAC_API YAC_StreamBase : public YAC_Object {
  1630. public:
  1631. sUI byteOrder;
  1632. };
  1633. #ifndef YAC_CUST_BUFFER
  1634. // ---- a binary buffer that supports the yacStream interface ----
  1635. class YAC_Buffer : public YAC_StreamBase {
  1636. public:
  1637. sUI size;
  1638. sUI io_offset;
  1639. sU8 * buffer;
  1640. sBool deleteme;
  1641. public:
  1642. YAC_Buffer (void); //
  1643. ~YAC_Buffer (); //
  1644. void YAC_VCALL yacArraySet (void *_context, sUI _index, YAC_Value *_value) override; // set a single value
  1645. void YAC_VCALL yacArrayGet (void *_context, sUI _index, YAC_Value *_r) override; // read a single value
  1646. sUI YAC_VCALL yacArrayGetWidth (void) override; // get number of elements/lines
  1647. sUI YAC_VCALL yacArrayGetHeight (void) override; // get number of lines
  1648. sUI YAC_VCALL yacArrayGetElementType (void) override; // get type of element (1=int, 2=float)
  1649. sUI YAC_VCALL yacArrayGetElementByteSize (void) override; // get bytes / element (1,2,4,...)
  1650. sUI YAC_VCALL yacArrayGetStride (void) override; // return byte offset to next line
  1651. void *YAC_VCALL yacArrayGetPointer (void) override; // return pointer to first element in first line
  1652. };
  1653. #endif
  1654. #endif // YAC_CUST_STREAMBASE
  1655. // ---- see YAC_Object::yacGetIterator() ----
  1656. class YAC_API YAC_Iterator {
  1657. public:
  1658. sUI current_index;
  1659. public:
  1660. YAC_Iterator(void); //
  1661. virtual ~YAC_Iterator(); //
  1662. virtual void YAC_VCALL getNext(YAC_Value *); // get next value
  1663. virtual void YAC_VCALL begin(void); // start iteration
  1664. virtual void YAC_VCALL end(void); // finish iteration
  1665. };
  1666. // ---- plugin host interface -----
  1667. class YAC_API YAC_Host {
  1668. public:
  1669. sU8 cpp_typecast_map[YAC_MAX_CLASSES][YAC_MAX_CLASSES]; // used to test whether class b is a base class of class a, i.e. cpp_typecast_map[a_class_id][b_class_id]==1
  1670. public:
  1671. YAC_Host (void);
  1672. virtual ~YAC_Host ();
  1673. // ----
  1674. // ----
  1675. // ----
  1676. // ---- LEVEL (1<<0) interface:
  1677. // ---- ( C/C++ reflection support )
  1678. // ----
  1679. // ----
  1680. virtual sUI YAC_VCALL yacQueryInterfaces (void) = 0;
  1681. virtual sUI YAC_VCALL yacRegisterClass (YAC_Object *_template, sUI _may_instanciate) = 0; // returns class_ID assigned by YAC_Host
  1682. virtual YAC_Object *YAC_VCALL yacNew (const char *_namespaceName, const char *_classname) = 0; // allocate unknown API object (e.g. Texture or a plugin class)
  1683. virtual YAC_Object *YAC_VCALL yacNewByID (sUI _class_ID) = 0;
  1684. virtual void YAC_VCALL yacDelete (YAC_Object *_apiobject) = 0; // delete previously allocated API object
  1685. virtual sUI YAC_VCALL yacGetClassIDByName (sChar *_name) = 0;
  1686. virtual sUI YAC_VCALL yacRegisterFunction (void *_adr, const char *_name, sUI _returntype, const char *_return_otype, sUI _numargs, const sUI *_argtypes, const char **_argtypenames, sUI _callstyle) = 0;
  1687. virtual sSI YAC_VCALL yacEvalMethodByName (YAC_Object *_apiobject, const char *_name, YAC_Value *_args, sUI _numargs, YAC_Value *_r) = 0; // lookup method by name, typecast arguments and evaluate. return true if everything worked OK, false if method _name was not found.
  1688. virtual YAC_Object * YAC_VCALL yacGetClassTemplateByID (sUI _class_ID) = 0;
  1689. virtual YAC_Object * YAC_VCALL yacNewPooledByID (sUI _class_ID, sUI _poolHint) = 0;
  1690. virtual void YAC_VCALL yacNewDeleteModifyCounter (sSI _deltaByteSize) = 0;
  1691. virtual sSI YAC_VCALL yacNewDeleteGetCounter (void) = 0;
  1692. virtual void YAC_VCALL vtable_entry_0_12_reserved (void) = 0;
  1693. virtual void YAC_VCALL vtable_entry_0_13_reserved (void) = 0;
  1694. virtual void YAC_VCALL vtable_entry_0_14_reserved (void) = 0;
  1695. virtual void YAC_VCALL vtable_entry_0_15_reserved (void) = 0;
  1696. // ----
  1697. // ----
  1698. // ----
  1699. // ---- LEVEL (1<<1) interface:
  1700. // ---- ( debug support )
  1701. // ----
  1702. // ----
  1703. virtual sUI YAC_VCALL yacGetDebugLevel (void) = 0;
  1704. virtual void YAC_VCALL yacPrint (const sChar *_s) = 0; // print to default debug console (stdout, stderr, or textfile)
  1705. virtual void YAC_VCALL vtable_entry_1_2_reserved (void) = 0;
  1706. virtual void YAC_VCALL vtable_entry_1_3_reserved (void) = 0;
  1707. virtual void YAC_VCALL vtable_entry_1_4_reserved (void) = 0;
  1708. virtual void YAC_VCALL vtable_entry_1_5_reserved (void) = 0;
  1709. virtual void YAC_VCALL vtable_entry_1_6_reserved (void) = 0;
  1710. virtual void YAC_VCALL vtable_entry_1_7_reserved (void) = 0;
  1711. // ----
  1712. // ----
  1713. // ----
  1714. // ---- LEVEL (1<<2) interface:
  1715. // ---- ( string support )
  1716. // ----
  1717. // ----
  1718. virtual sSI YAC_VCALL yacStringReplace (YAC_String *_d, YAC_String *_a, YAC_String *_b) = 0;
  1719. virtual sSI YAC_VCALL yacStringScan (YAC_String *,sSI*) = 0;
  1720. virtual sSI YAC_VCALL yacStringScan (YAC_String *,sF32*) = 0;
  1721. virtual sUI YAC_VCALL yacScanFlags (YAC_String*) = 0;
  1722. virtual void YAC_VCALL vtable_entry_2_4_reserved (void) = 0;
  1723. virtual void YAC_VCALL vtable_entry_2_5_reserved (void) = 0;
  1724. virtual void YAC_VCALL vtable_entry_2_6_reserved (void) = 0;
  1725. virtual void YAC_VCALL vtable_entry_2_7_reserved (void) = 0;
  1726. virtual void YAC_VCALL vtable_entry_2_8_reserved (void) = 0;
  1727. virtual void YAC_VCALL vtable_entry_2_9_reserved (void) = 0;
  1728. virtual void YAC_VCALL vtable_entry_2_10_reserved (void) = 0;
  1729. virtual void YAC_VCALL vtable_entry_2_11_reserved (void) = 0;
  1730. virtual void YAC_VCALL vtable_entry_2_12_reserved (void) = 0;
  1731. virtual void YAC_VCALL vtable_entry_2_13_reserved (void) = 0;
  1732. virtual void YAC_VCALL vtable_entry_2_14_reserved (void) = 0;
  1733. virtual void YAC_VCALL vtable_entry_2_15_reserved (void) = 0;
  1734. // ----
  1735. // ----
  1736. // ----
  1737. // ---- LEVEL (1<<3) interface:
  1738. // ---- ( scripting support )
  1739. // ----
  1740. // ----
  1741. virtual sUI YAC_VCALL yacRunning (void) = 0;
  1742. virtual YAC_FunctionHandle YAC_VCALL yacFindFunction (sChar *_name) = 0;
  1743. virtual sUI YAC_VCALL yacEvalFunction (YAC_ContextHandle _context, YAC_FunctionHandle _script_function, sUI _numargs, YAC_Value *_args) = 0; // evaluate script function, e.g. used for tks signal callbacks; see YAC_Object::yacRegisterSignal(),yacGetSignalStringList(). return true or false depending on whether the function call succeeded.
  1744. virtual YAC_ModuleHandle YAC_VCALL yacCompileModule (sChar *_source) = 0;
  1745. virtual void YAC_VCALL yacDeleteModule (YAC_ModuleHandle _mod) = 0;
  1746. virtual YAC_FunctionHandle YAC_VCALL yacFindFunctionInModule (YAC_ModuleHandle _mod, sChar *_name) = 0;
  1747. virtual YAC_VariableHandle YAC_VCALL yacFindVariableInModule (YAC_ModuleHandle _mod, sChar *_name) = 0;
  1748. virtual YAC_FunctionHandle YAC_VCALL yacFindVariableInFunction (YAC_FunctionHandle _fn, sChar *_name) = 0;
  1749. virtual void YAC_VCALL yacSetVariable (YAC_VariableHandle _var, YAC_Value *_v) = 0;
  1750. virtual void YAC_VCALL yacGetVariable (YAC_VariableHandle _var, YAC_Value *_r) = 0;
  1751. virtual sUI YAC_VCALL yacEvalFunctionReturn (YAC_ContextHandle _context, YAC_FunctionHandle _script_function, sUI _numargs, YAC_Value *_args, YAC_Value *_r) = 0; // evaluate script function, e.g. used for tks signal callbacks; see YAC_Object::yacRegisterSignal(),yacGetSignalStringList(). return true or false depending on whether the function call succeeded.
  1752. virtual YAC_ContextHandle YAC_VCALL yacContextCreate (void) = 0; // Create script execution context
  1753. virtual void YAC_VCALL yacContextDestroy (YAC_ContextHandle _context) = 0; // Destroy script execution context
  1754. virtual YAC_ContextHandle YAC_VCALL yacContextGetDefault (void) = 0;
  1755. virtual void YAC_VCALL yacContextSetDefault (YAC_ContextHandle _context) = 0; // Set default script context (for use in threads created by plugins / not by a Thread object)
  1756. virtual void YAC_VCALL vtable_entry_3_15_reserved (void) = 0;
  1757. virtual void YAC_VCALL vtable_entry_3_16_reserved (void) = 0;
  1758. virtual void YAC_VCALL vtable_entry_3_17_reserved (void) = 0;
  1759. virtual void YAC_VCALL vtable_entry_3_18_reserved (void) = 0;
  1760. virtual void YAC_VCALL vtable_entry_3_19_reserved (void) = 0;
  1761. virtual void YAC_VCALL vtable_entry_3_20_reserved (void) = 0;
  1762. virtual void YAC_VCALL vtable_entry_3_21_reserved (void) = 0;
  1763. virtual void YAC_VCALL vtable_entry_3_22_reserved (void) = 0;
  1764. virtual void YAC_VCALL vtable_entry_3_23_reserved (void) = 0;
  1765. virtual void YAC_VCALL vtable_entry_3_24_reserved (void) = 0;
  1766. virtual void YAC_VCALL vtable_entry_3_25_reserved (void) = 0;
  1767. virtual void YAC_VCALL vtable_entry_3_26_reserved (void) = 0;
  1768. virtual void YAC_VCALL vtable_entry_3_27_reserved (void) = 0;
  1769. virtual void YAC_VCALL vtable_entry_3_28_reserved (void) = 0;
  1770. virtual void YAC_VCALL vtable_entry_3_29_reserved (void) = 0;
  1771. virtual void YAC_VCALL vtable_entry_3_30_reserved (void) = 0;
  1772. virtual void YAC_VCALL vtable_entry_3_31_reserved (void) = 0;
  1773. // ----
  1774. // ----
  1775. // ----
  1776. // ---- LEVEL (1<<4) interface:
  1777. // ---- ( event support )
  1778. // ----
  1779. // ----
  1780. virtual void YAC_VCALL yacSendUserEvent (YAC_Object *_event_or_string) = 0; // send user event to running application
  1781. virtual sUI YAC_VCALL yacMilliSeconds (void) = 0; // Query milliseconds since startup
  1782. virtual void YAC_VCALL vtable_entry_4_2_reserved (void) = 0;
  1783. virtual void YAC_VCALL vtable_entry_4_3_reserved (void) = 0;
  1784. virtual void YAC_VCALL vtable_entry_4_4_reserved (void) = 0;
  1785. virtual void YAC_VCALL vtable_entry_4_5_reserved (void) = 0;
  1786. virtual void YAC_VCALL vtable_entry_4_6_reserved (void) = 0;
  1787. virtual void YAC_VCALL vtable_entry_4_7_reserved (void) = 0;
  1788. // ----
  1789. // ----
  1790. // ---- LEVEL (1<<5) interface
  1791. // ---- ( exception support )
  1792. // ----
  1793. // ----
  1794. // ----
  1795. virtual YAC_ExceptionId YAC_VCALL yacExceptionRegister (const char *_name, sUI _baseException) = 0; // register new exception type. Return exception id or 0==registration failed
  1796. virtual YAC_ExceptionId YAC_VCALL yacExceptionGetIdByName (const char *_name) = 0; // Look up ID for exception called _name
  1797. virtual void YAC_VCALL yacExceptionRaise (YAC_ContextHandle _context, sUI _id, const char *_message=NULL, const char *_file=NULL, sSI _line=0) = 0; // raise new Exception with type _id.
  1798. virtual void YAC_VCALL vtable_entry_5_3_reserved (void) = 0;
  1799. virtual void YAC_VCALL vtable_entry_5_4_reserved (void) = 0;
  1800. virtual void YAC_VCALL vtable_entry_5_5_reserved (void) = 0;
  1801. virtual void YAC_VCALL vtable_entry_5_6_reserved (void) = 0;
  1802. virtual void YAC_VCALL vtable_entry_5_7_reserved (void) = 0;
  1803. virtual void YAC_VCALL vtable_entry_5_8_reserved (void) = 0;
  1804. virtual void YAC_VCALL vtable_entry_5_9_reserved (void) = 0;
  1805. // ----
  1806. // ----
  1807. // ---- LEVEL (1<<6) interface
  1808. // ---- ( callback support )
  1809. // ----
  1810. // ----
  1811. // ----
  1812. virtual YAC_CallbackId YAC_VCALL yacCallbackCreate (const char *_name) = 0; // create named callback slot and returns callback id, -1=unable to create
  1813. virtual YAC_CallbackId YAC_VCALL yacCallbackGetIdByName (const char *_name) = 0; // map callback name to slot id, -1=not found
  1814. virtual sBool YAC_VCALL yacCallbackSetFunById (YAC_CallbackId _id, YAC_CFunctionPtr _fun) = 0; // register callback function for given slot, _fun=NULL => unregister
  1815. virtual sSI YAC_VCALL yacCallbackSetFunByName (const char *_name, YAC_CFunctionPtr _fun) = 0; // register callback function for given slot, _fun=NULL => unregister
  1816. // this implicitely creates a callback slot in order to make the plugin
  1817. // loading order irrelevant
  1818. virtual YAC_CFunctionPtr YAC_VCALL yacCallbackGetFunById (YAC_CallbackId _callbackId) = 0; // query current C function (cdecl) binding for the given callback slot
  1819. virtual void YAC_VCALL vtable_entry_6_6_reserved (void) = 0;
  1820. virtual void YAC_VCALL vtable_entry_6_7_reserved (void) = 0;
  1821. virtual void YAC_VCALL vtable_entry_6_8_reserved (void) = 0;
  1822. virtual void YAC_VCALL vtable_entry_6_9_reserved (void) = 0;
  1823. // ----
  1824. // ----
  1825. // ---- LEVEL (1<<7) interface
  1826. // ---- ( mutual exclusive semaphore support )
  1827. // ----
  1828. // ----
  1829. // ----
  1830. virtual YAC_MutexHandle YAC_VCALL yacMutexCreate (void) = 0; // Create new mutex, NULL=create failed
  1831. virtual void YAC_VCALL yacMutexDestroy (YAC_MutexHandle _mutexHandle) = 0; // Destroy mutex that was created with yacMutexCreate()
  1832. virtual YAC_MutexHandle YAC_VCALL yacMutexFindByName (const char *_name) = 0; // Find named sync point
  1833. virtual void YAC_VCALL yacMutexLock (YAC_MutexHandle _mutexHandle) = 0; // Lock mutex, beware of dead locks!
  1834. virtual void YAC_VCALL yacMutexUnlock (YAC_MutexHandle _mutexHandle) = 0; // Unlock mutex
  1835. virtual void YAC_VCALL vtable_entry_7_5_reserved (void) = 0;
  1836. virtual void YAC_VCALL vtable_entry_7_6_reserved (void) = 0;
  1837. virtual void YAC_VCALL vtable_entry_7_7_reserved (void) = 0;
  1838. virtual void YAC_VCALL vtable_entry_7_8_reserved (void) = 0;
  1839. virtual void YAC_VCALL vtable_entry_7_9_reserved (void) = 0;
  1840. #ifdef YAC_PRINTF
  1841. void printf(const char *_fmt, ...);
  1842. #endif
  1843. };
  1844. #ifndef YAC_CUST_STRING
  1845. // ---- simple String class
  1846. // ---- Import notes: * Never delete[]chars in Strings obtained from YAC_New_String()!
  1847. // ---- * Never pass Strings NOT allocated with YAC_New_String() to the YAC_Host !
  1848. class YAC_API YAC_String : public YAC_Object {
  1849. public:
  1850. enum __stringflags {
  1851. QUOT = (1<<24),
  1852. UTAG1 = (1<<25),
  1853. DEL = (1<<31)
  1854. };
  1855. public:
  1856. sUI buflen; // ---- total buffer size
  1857. sUI bflags; // ---- stringflags (e.g. deleteme flag)
  1858. sUI length; // ---- number of used chars in buffer
  1859. sUI key; // ---- hashkey that is used for fast object comparison
  1860. sU8 *chars; // ---- pointer to first char in buffer
  1861. void *clones; // ---- internal StaticList::Node*, see tks-list.h if you need this member (used for split() string lists)
  1862. public:
  1863. YAC_String (void);
  1864. ~YAC_String ();
  1865. void free (void ); // Note: Never delete Strings obtained from the YAC_Host!
  1866. void visit (const sChar *_cstring ); // set read-only reference to (const) char array
  1867. sBool compare (const sChar *e ); // compare with "C" string (slow)
  1868. sSI lastIndexOf (sChar _c, sUI _start=0 );
  1869. sSI indexOf (sChar _c, sUI _start=0 );
  1870. #ifdef YAC_BIGSTRING // ---- use with care; don't mix YAC_Host/plugin *chars
  1871. sUI sum (void ); //
  1872. void genKey (void ); //
  1873. sUI getKey (void ); //
  1874. sBool compare (YAC_String *s ); // compare with YAC_String object (fast)
  1875. void fixLength (void ); // counter number of chars (including ASCIIZ)
  1876. sBool alloc (sU32 len );
  1877. sBool copy (const sChar *e ); // copy c-string,
  1878. sBool copy (YAC_String *_s ); // copy YAC_String object
  1879. sBool realloc (sU32 len ); // resize string buffer
  1880. sBool createEmpty (void );
  1881. sBool append (YAC_String * ); // append YAC_String
  1882. sBool append (const char * ); // append "C" string
  1883. sBool substring (YAC_String *s, sUI start, sUI len); // extract substring
  1884. sBool empty (void );
  1885. void printf (const char *_fmt, ... );
  1886. #endif // YAC_BIGSTRING
  1887. };
  1888. #ifdef YAC_BIGSTRING
  1889. sUI YAC_strlen(const char *_s);
  1890. #endif
  1891. // ---- an array of YAC_Strings ----
  1892. class YAC_StringArray : public YAC_Object {
  1893. public:
  1894. sUI max_elements;
  1895. sUI num_elements;
  1896. YAC_String *elements;
  1897. YAC_StringArray(void) {
  1898. max_elements = 0;
  1899. num_elements = 0;
  1900. elements = NULL;
  1901. }
  1902. };
  1903. #endif // YAC_CUST_STRING
  1904. #ifndef YAC_CUST_FLOATARRAY
  1905. // ----
  1906. class YAC_FloatArray : public YAC_Object {
  1907. public:
  1908. sBool own_data;
  1909. sUI max_elements;
  1910. sUI num_elements;
  1911. sF32 *elements;
  1912. YAC_FloatArray(void) {
  1913. own_data = 0;
  1914. max_elements = 0u;
  1915. num_elements = 0u;
  1916. elements = NULL;
  1917. }
  1918. };
  1919. #endif // YAC_CUST_FLOATARRAY
  1920. #ifndef YAC_CUST_INTARRAY
  1921. // ----
  1922. class YAC_IntArray : public YAC_Object {
  1923. public:
  1924. sSI own_data;
  1925. sUI max_elements;
  1926. sUI num_elements;
  1927. sSI *elements;
  1928. YAC_IntArray(void) {
  1929. own_data = 0;
  1930. max_elements = 0u;
  1931. num_elements = 0u;
  1932. elements = NULL;
  1933. }
  1934. };
  1935. #endif // YAC_CUST_INTARRAY
  1936. #ifndef YAC_CUST_LISTNODE
  1937. // ---- a list of value objects ----
  1938. class YAC_API YAC_ListNode : public YAC_ValueObject {
  1939. public:
  1940. YAC_ListNode *next;
  1941. YAC_ListNode *prev;
  1942. YAC_ListNode(void);
  1943. ~YAC_ListNode();
  1944. };
  1945. // ---- object wrapper for a YAC_ListNode list ----
  1946. class YAC_API YAC_List : public YAC_Object {
  1947. YAC_ListNode *head;
  1948. YAC_ListNode *tail;
  1949. YAC_List(void) {
  1950. head = NULL;
  1951. tail = NULL;
  1952. }
  1953. };
  1954. #endif // YAC_CUST_LISTNODE
  1955. #ifndef YAC_CUST_TREENODE
  1956. // ---- a tree of values ----
  1957. class YAC_API YAC_TreeNode : public YAC_ValueObject {
  1958. public:
  1959. YAC_TreeNode *left;
  1960. YAC_TreeNode *right;
  1961. YAC_TreeNode *parent;
  1962. YAC_String name;
  1963. YAC_String id;
  1964. YAC_TreeNode(void);
  1965. ~YAC_TreeNode();
  1966. };
  1967. #endif // YAC_CUST_LISTNODE
  1968. #ifndef YAC_CUST_NUMBEROBJECTS
  1969. // ---- Object shells/wrappers for 8-64 bit integer resp. floating point values
  1970. // ---- YAC_Number is part of the YAC_Object interface thus there is no "Number" class
  1971. class YAC_API YAC_UnsignedByte : public YAC_Object { public: sU8 value; };
  1972. class YAC_API YAC_Byte : public YAC_Object { public: sS8 value; };
  1973. class YAC_API YAC_Boolean : public YAC_Object { public: sBool value;};
  1974. class YAC_API YAC_UnsignedShort : public YAC_Object { public: sU16 value; };
  1975. class YAC_API YAC_Short : public YAC_Object { public: sS16 value; };
  1976. class YAC_API YAC_UnsignedInteger : public YAC_Object { public: sU32 value; };
  1977. class YAC_API YAC_Integer : public YAC_Object { public: sS32 value; };
  1978. class YAC_API YAC_Long : public YAC_Object { public: sS64 value; };
  1979. class YAC_API YAC_Float : public YAC_Object { public: sF32 value; };
  1980. class YAC_API YAC_Double : public YAC_Object { public: sF64 value; };
  1981. #endif // YAC_CUST_NUMBEROBJECTS
  1982. // ---- magic loader symbols ----
  1983. YAC_APIC void YAC_Init (YAC_Host *); // ---- called when a plugin is (un-)loaded
  1984. YAC_APIC void YAC_Exit (YAC_Host *); // ---- your plugin needs to define at least these
  1985. YAC_APIC sUI YAC_Version(void ); // ---- query plugin version information. 0xaabbccdd, e.g. 0x00050203.
  1986. // ---- helper macros to instanciate new YAC_Objects ----
  1987. #define YAC_New_Boolean() (YAC_Boolean*) yac_host->yacNewByID (YAC_CLID_BOOLEAN )
  1988. #define YAC_New_Byte() (YAC_Byte*) yac_host->yacNewByID (YAC_CLID_BYTE )
  1989. #define YAC_New_Short() (YAC_Short*) yac_host->yacNewByID (YAC_CLID_SHORT )
  1990. #define YAC_New_Integer() (YAC_Integer*) yac_host->yacNewByID (YAC_CLID_INTEGER )
  1991. #define YAC_New_Long() (YAC_Long*) yac_host->yacNewByID (YAC_CLID_LONG )
  1992. #define YAC_New_UnsignedByte() (YAC_UnsignedByte*) yac_host->yacNewByID (YAC_CLID_UNSIGNEDBYTE )
  1993. #define YAC_New_UnsignedShort() (YAC_UnsignedShort*) yac_host->yacNewByID (YAC_CLID_UNSIGNEDSHORT )
  1994. #define YAC_New_UnsignedInteger() (YAC_UnsignedInteger*) yac_host->yacNewByID (YAC_CLID_UNSIGNEDINTEGER)
  1995. #define YAC_New_Float() (YAC_Float*) yac_host->yacNewByID (YAC_CLID_FLOAT )
  1996. #define YAC_New_Double() (YAC_Double*) yac_host->yacNewByID (YAC_CLID_DOUBLE )
  1997. #define YAC_New_String() (YAC_String*) yac_host->yacNewByID (YAC_CLID_STRING )
  1998. #define YAC_New_Event() (YAC_Event*) yac_host->yacNewByID (YAC_CLID_EVENT )
  1999. #define YAC_New_Value() (YAC_ValueObject*) yac_host->yacNewByID (YAC_CLID_VALUE )
  2000. #define YAC_New_ListNode() (YAC_ListNode*) yac_host->yacNewByID (YAC_CLID_LISTNODE )
  2001. #define YAC_New_TreeNode() (YAC_TreeNode*) yac_host->yacNewByID (YAC_CLID_TREENODE )
  2002. #define YAC_New_IntArray() (YAC_IntArray*) yac_host->yacNewByID (YAC_CLID_INTARRAY )
  2003. #define YAC_New_FloatArray() (YAC_FloatArray*) yac_host->yacNewByID (YAC_CLID_FLOATARRAY )
  2004. #define YAC_New_StringArray() (YAC_StringArray*) yac_host->yacNewByID (YAC_CLID_STRINGARRAY )
  2005. #define YAC_New_ObjectArray( ) (YAC_ObjectArray*) yac_host->yacNewByID (YAC_CLID_OBJECTARRAY )
  2006. #define YAC_New_ClassArray() (YAC_ClassArray*) yac_host->yacNewByID (YAC_CLID_CLASSARRAY )
  2007. #define YAC_New_ValueArray() (YAC_ValueArray*) yac_host->yacNewByID (YAC_CLID_VALUEARRAY )
  2008. #define YAC_New_PointerArray() yac_host->yacNewByID (YAC_CLID_POINTERARRAY )
  2009. #define YAC_New_HashTable() yac_host->yacNewByID (YAC_CLID_HASHTABLE )
  2010. #define YAC_New_Buffer() (YAC_Buffer*) yac_host->yacNewByID (YAC_CLID_BUFFER )
  2011. #define YAC_New_File() yac_host->yacNewByID (YAC_CLID_FILE )
  2012. #define YAC_New_PakFile() yac_host->yacNewByID (YAC_CLID_PAKFILE )
  2013. #define YAC_New_Pipe() yac_host->yacNewByID (YAC_CLID_PIPE )
  2014. // ---- helper macros to check whether a YAC_Object is safe to cast to the respective type
  2015. #define YAC_Is_String(a) YAC_BCHK(a, YAC_CLID_STRING)
  2016. #define YAC_Is_Buffer(a) YAC_BCHK(a, YAC_CLID_BUFFER)
  2017. #define YAC_Is_IntArray(a) YAC_BCHK(a, YAC_CLID_INTARRAY)
  2018. #define YAC_Is_FloatArray(a) YAC_BCHK(a, YAC_CLID_FLOATARRAY)
  2019. #define YAC_Is_StringArray(a) YAC_BCHK(a, YAC_CLID_STRINGARRAY)
  2020. #define YAC_Is_HashTable(a) YAC_BCHK(a, YAC_CLID_HASHTABLE)
  2021. #define YAC_Is_Value(a) YAC_BCHK(a, YAC_CLID_VALUE)
  2022. #define YAC_Is_ListNode(a) YAC_BCHK(a, YAC_CLID_LISTNODE)
  2023. #define YAC_Is_TreeNode(a) YAC_BCHK(a, YAC_CLID_TREENODE)
  2024. #define YAC_Is_PointerArray(a) YAC_BCHK(a, YAC_CLID_POINTERARRAY)
  2025. #define YAC_Is_File(a) YAC_BCHK(a, YAC_CLID_FILE)
  2026. #define YAC_Is_Boolean(a) YAC_BCHK(a, YAC_CLID_BOOLEAN)
  2027. #define YAC_Is_UnsignedByte(a ) YAC_BCHK(a, YAC_CLID_UNSIGNEDBYTE)
  2028. #define YAC_Is_UnsignedShort(a) YAC_BCHK(a, YAC_CLID_UNSIGNEDSHORT)
  2029. #define YAC_Is_UnsignedInteger(a) YAC_BCHK(a, YAC_CLID_UNSIGNEDINTEGER)
  2030. #define YAC_Is_Byte(a) YAC_BCHK(a, YAC_CLID_BYTE)
  2031. #define YAC_Is_Short(a) YAC_BCHK(a, YAC_CLID_SHORT)
  2032. #define YAC_Is_Integer(a) YAC_BCHK(a, YAC_CLID_INTEGER)
  2033. #define YAC_Is_Long(a) YAC_BCHK(a, YAC_CLID_LONG)
  2034. #define YAC_Is_Float(a) YAC_BCHK(a, YAC_CLID_FLOAT)
  2035. #define YAC_Is_Double(a) YAC_BCHK(a, YAC_CLID_DOUBLE)
  2036. // ---- used for e.g. scriptclasses (YAC_Object type=Class, metaclasstype=MyClass ..) ----
  2037. #define YAC_IS_METACLASS(a) ((a)->yacMetaClassName()!=0)
  2038. // ---- object class template macros ----
  2039. // -------- regular template ----
  2040. /* template <class T> class YAC_Template {public:T *ctemplate; public: YAC_Template (YAC_Host *_host) { ctemplate=new T(); _host->yacRegisterClass(ctemplate, YAC_CLASSTYPE_NORMAL); } ~YAC_Template() { delete ctemplate; } }; */
  2041. /* // -------- singleton type template, may not be instanciated ---- */
  2042. /* template <class T> class YAC_STemplate {public:T *ctemplate; public: YAC_STemplate (YAC_Host *_host) { ctemplate=new T(); _host->yacRegisterClass(ctemplate, YAC_CLASSTYPE_STATIC); } ~YAC_STemplate() { delete ctemplate; } }; */
  2043. /* // -------- interface template, objects are only created by plugins, may not be instanciated but pointer variables may be declared ---- */
  2044. /* template <class T> class YAC_RTemplate {public:T *ctemplate; public: YAC_RTemplate (YAC_Host *_host) { ctemplate=new T(); _host->yacRegisterClass(ctemplate, YAC_CLASSTYPE_NOINST); } ~YAC_RTemplate() { delete ctemplate; } }; */
  2045. // Note: the template objects are declared static so that operator new is never called.
  2046. template <class T> class YAC_Template {public: T ctemplate; YAC_Template(YAC_Host *_host) { _host->yacRegisterClass(&ctemplate, YAC_CLASSTYPE_NORMAL); } ~YAC_Template() { } };
  2047. // -------- singleton type template, may not be instanciated ----
  2048. template <class T> class YAC_STemplate {public: T ctemplate; YAC_STemplate(YAC_Host *_host) { _host->yacRegisterClass(&ctemplate, YAC_CLASSTYPE_STATIC); } ~YAC_STemplate() { } };
  2049. // -------- interface template, objects are only created by plugins, may not be instanciated but pointer variables may be declared ----
  2050. template <class T> class YAC_RTemplate {public: T ctemplate; YAC_RTemplate(YAC_Host *_host) { _host->yacRegisterClass(&ctemplate, YAC_CLASSTYPE_NOINST); } ~YAC_RTemplate() { } };
  2051. #ifndef YAC_NO_EXPORTS
  2052. extern YAC_Host *yac_host;
  2053. #endif
  2054. #ifdef YAC_OBJECT_TAGS
  2055. #define YAC_VALID(a) ((a)&&((a)->validation_tag==YAC_VALID_TAG))
  2056. //#define YAC_ILL(a) ((a)?((a)->validation_tag!=YAC_VALID_TAG):0)
  2057. #else
  2058. #define YAC_VALID(a) a
  2059. //#define YAC_ILL(a) 0
  2060. #endif // YAC_OBJECT_TAGS
  2061. // ---- "C" function handling (0..8 args, YAC_Value *_r return) ----
  2062. // YAC_APIC const sChar*YAC_GetFunctionStringList(void); // called to get list of "c" functions
  2063. // ----
  2064. // ----
  2065. // ---- Epsilon float comparisons
  2066. // ----
  2067. // ----
  2068. #define YAC_FLT_EPSILON 0.000001f
  2069. #define YAC_DBL_EPSILON 0.000000000001
  2070. #ifdef YAC_EPSILONCOMPARE_ABS
  2071. //
  2072. // absolute epsilon floating point value comparisons (taken from tks-source/tks.h)
  2073. //
  2074. #define Dfltnonzero_abs(a) ( ((a)>YAC_FLT_EPSILON) || ((a)<-YAC_FLT_EPSILON) )
  2075. #define Dfltequal_abs(a,b) ( (((a)-YAC_FLT_EPSILON) <= (b)) && (((a)+YAC_FLT_EPSILON) >= (b)) )
  2076. #define Dfltnotequal_abs(a,b) ( (((a)-YAC_FLT_EPSILON) > (b)) || (((a)+YAC_FLT_EPSILON) < (b)) )
  2077. #define Dfltzero_abs(a) Dfltequal(a, 0.0f)
  2078. #define Ddblnonzero_abs(a) ( ((a)>YAC_DBL_EPSILON) || ((a)<-YAC_DBL_EPSILON) )
  2079. #define Ddblequal_abs(a,b) ( (((a)-YAC_DBL_EPSILON) <= (b)) && (((a)+YAC_DBL_EPSILON) >= (b)) )
  2080. #define Ddblnotequal_abs(a,b) ( (((a)-YAC_DBL_EPSILON) > (b)) || (((a)+YAC_DBL_EPSILON) < (b)) )
  2081. #define Ddblzero_abs(a) Ddblequal(a, 0.0)
  2082. #endif // YAC_EPISLONCOMPARE_ABS
  2083. #ifdef YAC_EPSILONCOMPARE_REL
  2084. //
  2085. // alternative floating point value comparisons that shift epsilon
  2086. // with the exponent.
  2087. // test against zero are special cases
  2088. //
  2089. // contributed by Carsten Busse <carsten.busse@gmail.com>
  2090. //
  2091. extern sSI yac_epsilon_flt_units;
  2092. extern sS64 yac_epsilon_dbl_units;
  2093. extern sF32 yac_epsilon_flt;
  2094. extern sF64 yac_epsilon_dbl;
  2095. //fast version
  2096. YAC_APIC sSI YAC_CALL yac_fltcmp_rel_fast(sF32, sF32);
  2097. YAC_APIC sSI YAC_CALL yac_dblcmp_rel_fast(sF64, sF64);
  2098. //"real" tolerance version
  2099. YAC_APIC sSI YAC_CALL yac_fltcmp_rel(sF32, sF32, sF32);
  2100. YAC_APIC sSI YAC_CALL yac_dblcmp_rel(sF64, sF64, sF64);
  2101. #define Dfltnonzero_rel(a) ( ((a)>YAC_FLT_EPSILON) || ((a)<-YAC_FLT_EPSILON) )
  2102. #define Dfltzero_rel(a) ( ((a)<=YAC_FLT_EPSILON) && ((a)>=-YAC_FLT_EPSILON) )
  2103. #define Dfltequal_rel(a,b) ( yac_fltcmp_rel_fast((sF32)a,(sF32)(b)) == 0 )
  2104. #define Dfltnotequal_rel(a,b) ( yac_fltcmp_rel_fast((sF32)(a), (sF32)(b)) != 0 )
  2105. #define Ddblnonzero_rel(a) ( ((a)>YAC_DBL_EPSILON) || ((a)<-YAC_DBL_EPSILON) )
  2106. #define Ddblzero_rel(a) ( ((a)<=YAC_DBL_EPSILON) && ((a)>=-YAC_DBL_EPSILON) )
  2107. #define Ddblequal_rel(a,b) ( yac_dblcmp_rel_fast((sF64)(a), (sF64)(b) ) == 0 )
  2108. #define Ddblnotequal_rel(a,b) ( yac_dblcmp_rel_fast((sF64)(a), (sF64)(b) ) != 0 )
  2109. #endif // YAC_EPSILONCOMPARE_REL
  2110. // ----
  2111. // ---- Default float comparison, either abs or rel
  2112. // ----
  2113. #ifdef YAC_EPSILONCOMPARE_ABS_DEFAULT
  2114. // ---- Use absolute epsilon comparison macros by default
  2115. #define Dfltnonzero(a) Dfltnonzero_abs (a)
  2116. #define Dfltequal(a, b) Dfltequal_abs (a, b)
  2117. #define Dfltnotequal(a, b) Dfltnotequal_abs (a, b)
  2118. #define Dfltzero(a) Dfltzero_abs (a)
  2119. #define Ddblnonzero(a) Ddblnonzero_abs (a)
  2120. #define Ddblequal(a,b) Ddblequal_abs (a, b)
  2121. #define Ddblnotequal(a, b) Ddblnotequal_abs (a, b)
  2122. #define Ddblzero(a) Ddblzero_abs (a)
  2123. #elif defined(YAC_EPSILONCOMPARE_REL_DEFAULT)
  2124. // ---- Use relative epsilon comparison macros by default
  2125. #define Dfltnonzero(a) Dfltnonzero_rel (a)
  2126. #define Dfltequal(a, b) Dfltequal_rel (a, b)
  2127. #define Dfltnotequal(a, b) Dfltnotequal_rel (a, b)
  2128. #define Dfltzero(a) Dfltzero_rel (a)
  2129. #define Ddblnonzero(a) Ddblnonzero_rel (a)
  2130. #define Ddblequal(a,b) Ddblequal_rel (a, b)
  2131. #define Ddblnotequal(a, b) Ddblnotequal_rel (a, b)
  2132. #define Ddblzero(a) Ddblzero_rel (a)
  2133. #endif // YAC_EPSILONCOMPARE_REL_DEFAULT
  2134. // ---- ----
  2135. // ---- exception helpers ----
  2136. // ---- ----
  2137. // Raise runtime exception "a" with message text "b" in context _ctx
  2138. #define Dyac_throw(a, b) yac_host->yacExceptionRaise(_ctx, exid_##a, b, __FILE__, __LINE__)
  2139. // Raise runtime exception "a" with message text "b" in default context (**only use if context is not available!**)
  2140. #define Dyac_throw_def(a, b) yac_host->yacExceptionRaise(yac_host->yacContextGetDefault(), exid_##a, b, __FILE__, __LINE__)
  2141. // Forward declarate an exception id
  2142. #define Dyac_exid_decl(a) extern YAC_ExceptionId exid_##a
  2143. // Implement exception id variable
  2144. #define Dyac_exid_impl(a) YAC_ExceptionId exid_##a
  2145. // Resolve exception id
  2146. #define Dyac_exid_resolve(a) exid_##a = yac_host->yacExceptionGetIdByName(#a)
  2147. // Register custom exception id (e=exception name, b=base class exception name)
  2148. #define Dyac_exid_register(e, b) exid_##e = yac_host->yacExceptionRegister(#e, exid_##b)
  2149. // Forward declarate all "standard" YAC/TkScript exceptions
  2150. #define Dyac_std_exid_decl \
  2151. Dyac_exid_decl(CriticalError);\
  2152. Dyac_exid_decl(UncriticalError);\
  2153. Dyac_exid_decl(InvalidPointer);\
  2154. Dyac_exid_decl(Death);\
  2155. Dyac_exid_decl(TypeMismatch);\
  2156. Dyac_exid_decl(ClassTypeMismatch);\
  2157. Dyac_exid_decl(NativeClassTypeMismatch);\
  2158. Dyac_exid_decl(ScriptClassTypeMismatch);\
  2159. Dyac_exid_decl(ClassMemberNotFound);\
  2160. Dyac_exid_decl(NativeClassMemberNotFound);\
  2161. Dyac_exid_decl(ScriptClassMemberNotFound);\
  2162. Dyac_exid_decl(ModuleNotFound);\
  2163. Dyac_exid_decl(ModuleMemberNotFound);\
  2164. Dyac_exid_decl(ArrayOutOfBounds);\
  2165. Dyac_exid_decl(ReadArrayOutOfBounds);\
  2166. Dyac_exid_decl(WriteArrayOutOfBounds);\
  2167. Dyac_exid_decl(ConstraintViolation);\
  2168. Dyac_exid_decl(NotNullConstraintViolation)
  2169. // Implement all "standard" YAC/TkScript exception id variables
  2170. #define Dyac_std_exid_impl \
  2171. Dyac_exid_impl(CriticalError);\
  2172. Dyac_exid_impl(UncriticalError);\
  2173. Dyac_exid_impl(InvalidPointer);\
  2174. Dyac_exid_impl(Death);\
  2175. Dyac_exid_impl(TypeMismatch);\
  2176. Dyac_exid_impl(ClassTypeMismatch);\
  2177. Dyac_exid_impl(NativeClassTypeMismatch);\
  2178. Dyac_exid_impl(ScriptClassTypeMismatch);\
  2179. Dyac_exid_impl(ClassMemberNotFound);\
  2180. Dyac_exid_impl(NativeClassMemberNotFound);\
  2181. Dyac_exid_impl(ScriptClassMemberNotFound);\
  2182. Dyac_exid_impl(ModuleNotFound);\
  2183. Dyac_exid_impl(ModuleMemberNotFound);\
  2184. Dyac_exid_impl(ArrayOutOfBounds);\
  2185. Dyac_exid_impl(ReadArrayOutOfBounds);\
  2186. Dyac_exid_impl(WriteArrayOutOfBounds);\
  2187. Dyac_exid_impl(ConstraintViolation);\
  2188. Dyac_exid_impl(NotNullConstraintViolation)
  2189. // Resolve all "standard" YAC/TkScript exception ids
  2190. #define Dyac_std_exid_resolve \
  2191. Dyac_exid_resolve(CriticalError);\
  2192. Dyac_exid_resolve(UncriticalError);\
  2193. Dyac_exid_resolve(InvalidPointer);\
  2194. Dyac_exid_resolve(Death);\
  2195. Dyac_exid_resolve(TypeMismatch);\
  2196. Dyac_exid_resolve(ClassTypeMismatch);\
  2197. Dyac_exid_resolve(NativeClassTypeMismatch);\
  2198. Dyac_exid_resolve(ScriptClassTypeMismatch);\
  2199. Dyac_exid_resolve(ClassMemberNotFound);\
  2200. Dyac_exid_resolve(NativeClassMemberNotFound);\
  2201. Dyac_exid_resolve(ScriptClassMemberNotFound);\
  2202. Dyac_exid_resolve(ModuleNotFound);\
  2203. Dyac_exid_resolve(ModuleMemberNotFound);\
  2204. Dyac_exid_resolve(ArrayOutOfBounds);\
  2205. Dyac_exid_resolve(ReadArrayOutOfBounds);\
  2206. Dyac_exid_resolve(WriteArrayOutOfBounds);\
  2207. Dyac_exid_resolve(ConstraintViolation);\
  2208. Dyac_exid_resolve(NotNullConstraintViolation)
  2209. #ifdef YAC_GLOBAL_NEWDELETE
  2210. extern sSI yac_global_newdelete_counter; // Tracks currently allocated # of bytes
  2211. extern sSI yac_global_newdelete_numallocs; // Tracks total number of calls to "new"
  2212. extern sSI yac_global_newdelete_numfrees; // Tracks total number of calls to "delete"
  2213. #endif // YAC_GLOBAL_NEWDELETE
  2214. #endif // RACK_PLUGIN
  2215. // Local var/typecast from arg helper
  2216. #define YAC_CAST_ARG(t,l,a) t *l = (t *) a
  2217. // Local var/typecast/unlink from ValueObject arg helper
  2218. #define YAC_DEREF_ARG(t,l,a) t*l=NULL; sBool l##_deleteme=0; if(YAC_Is_Value(a)){ YAC_ValueObject*l##vo=(YAC_ValueObject*)a; if(l##vo->type >= YAC_TYPE_OBJECT) { l = (t*) l##vo->value.object_val; l##_deleteme = l##vo->deleteme; l##vo->deleteme = 0; } } else { l = (t*) a; }
  2219. // Check if 32bit float is denormalized (can cause severe slowdowns on Intel processors (faktor 5-8)
  2220. // a float is denormalized if the exponent part is 0 and the fractional part is not
  2221. #define Dyac_chkdenorm_32(a) ((0==((*(sUI*)&(a)) & 0x7f800000u)) && (0 != ((*(sUI*)&(a)) & 0x007FFFFFu)))
  2222. // Correct denormalized 32bit float
  2223. //#define Dyac_denorm_32(a) (Dyac_chkdenorm_32(a) ? 0.0f : (a))
  2224. #define Dyac_denorm_32(a) ( ((a)+10.0f) - 10.0f ) // kb's denormalize trick!
  2225. // Check if 32bit float is (plus or minus) infinity
  2226. #define Dyac_chkinf_32(a) (0x7f800000u == ((*(sUI*)&(a)) & 0x7f800000u))
  2227. // Check if 32bit float is NaN
  2228. #define Dyac_chknan_32(a) ( ((*(sUI*)&(a)) == 0x7F820000u) || ((*(sUI*)&(a)) == 0xFF9112AAu) )
  2229. // Check if 32bit float is -0
  2230. #define Dyac_chkm0_32(a) ( ((*(sUI*)&(a)) == 0x80000000u) )
  2231. // Debug: print warning if float is denormalized, infinity, or NaN
  2232. #define Dyac_dbgflt_32(a) if(1) { \
  2233. if(Dyac_chkdenorm_32(a)) printf(#a " denorm\n"); \
  2234. if(Dyac_chkinf_32(a)) printf(#a " inf\n"); \
  2235. if(Dyac_chknan_32(a)) printf(#a " NaN\n"); \
  2236. if(Dyac_chkm0_32(a)) printf(#a " m0\n"); \
  2237. } else (void)0
  2238. #endif // ifndef __YAC_H__