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.

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