script.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __SCRIPT_H
  2. #define __SCRIPT_H
  3. #include <bfc/ptrlist.h>
  4. #include <api/script/vcputypes.h>
  5. class String;
  6. #define GURU_POPEMPTYSTACK 0
  7. #define GURU_INVALIDHEADER 1
  8. #define GURU_INVALIDFUNCINDLF 2
  9. #define GURU_INVALIDFUNCBT 3
  10. #define GURU_INVALIDVARBT 4
  11. #define GURU_INVALIDEVENTDLF 5
  12. #define GURU_INVALIDEVENTADDR 6
  13. #define GURU_INVALIDEVENTVAR 7
  14. #define GURU_INVALIDSCRIPTID 8
  15. #define GURU_DLFSETUPFAILED 9
  16. #define GURU_SETNONINTERNAL 10
  17. #define GURU_INCSNONNUM 11
  18. #define GURU_DECSNONNUM 12
  19. #define GURU_INCPNONNUM 13
  20. #define GURU_DECPNONNUM 14
  21. #define GURU_OBJECTADD 15
  22. #define GURU_SUBNONNUM 16
  23. #define GURU_MULNONNUM 17
  24. #define GURU_DIVNONNUM 18
  25. #define GURU_DIVBYZERO 19
  26. #define GURU_MODNONNUM 20
  27. #define GURU_NEGNONNUM 21
  28. #define GURU_BNOTNONNUM 22
  29. #define GURU_SHLNONNUM 23
  30. #define GURU_SHRNONNUM 24
  31. #define GURU_XORNONNUM 25
  32. #define GURU_ANDNONNUM 26
  33. #define GURU_NEWFAILED 27
  34. #define GURU_NULLCALLED 28
  35. #define GURU_OLDFORMAT 29
  36. #define GURU_INVALIDPEEKSTACK 30
  37. #define GURU_INVALIDOLDID 31
  38. #define GURU_INCOMPATIBLEOBJECT 32
  39. #define GURU_EXCEPTION 33
  40. #define GURU_FUTUREFORMAT 34
  41. // This is our virtual machine basic type. Reducing of expression will use this
  42. // type. We will not malloc or new it, but we'll pass it on the stack for speed
  43. // and stability. 8 bytes should be ok for our stack. This way we won't have to
  44. // maintain lists on dynamically allocated computation values, and we won't have
  45. // to cleanup if some error (divide by zero ?) occurs in the middle of a
  46. // statement. String values are an exception since sdata will point to dynamic
  47. // data, but since every step of the virtual machine reducing strings will free
  48. // that data, cleanup will be automatic
  49. typedef struct {
  50. void *scriptBlock;
  51. int vcpuId; // id of script in virtual CPU. will be used later for unloading
  52. } scriptEntry;
  53. class Group;
  54. class SystemObject;
  55. class Script
  56. {
  57. public:
  58. static int addScript(const wchar_t *path, const wchar_t *filename, const wchar_t *id);
  59. static void unloadScript(int id);
  60. static void unloadAllScripts();
  61. static void guruMeditation(SystemObject *script, int code, const wchar_t *pub=NULL, int intinfo=0);
  62. static void setScriptParam(int id, const wchar_t *p);
  63. static int varIdToGlobal(int id, int script);
  64. static int getNumEventsLinked();
  65. static int getLinkedEventParams(int num, int *dlfid, int *scriptid, int *varid);
  66. static int getCacheCount();
  67. static int getUserAncestor(int varid, int scriptid);
  68. static int isValidScriptId(int id);
  69. static void setParentGroup(int id, Group *g);
  70. static void setSkinPartId(int id, int skinpartid);
  71. static int getNumScripts() { return scriptslist.getNumItems(); }
  72. static PtrList <scriptEntry> scriptslist;
  73. private:
  74. static int codeToSeverity(int code, wchar_t *t, int len);
  75. };
  76. #endif