scriptobji.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __SCRIPTOBJI_H
  2. #define __SCRIPTOBJI_H
  3. #include <api/script/vcputypes.h>
  4. #include <bfc/dispatch.h>
  5. #include <bfc/tlist.h>
  6. #include <bfc/ptrlist.h>
  7. #include <bfc/pair.h>
  8. //<?<autoheader/>
  9. #include "scriptobj.h"
  10. #include "scriptobjx.h"
  11. class ScriptHook;
  12. class ScriptObject;
  13. class ScriptObjectController;
  14. //?>
  15. class ScriptObjectController;
  16. class ScriptHook;
  17. /*[interface.header.h]
  18. enum {
  19. INTERFACE_GENERICVOIDPTR=0,
  20. INTERFACE_SCRIPTOBJECT,
  21. };
  22. */
  23. // ----------------------------------------------------------------------------------------------------------
  24. /*class MemberVarCompare {
  25. public:
  26. static int compareItem(void *p1, void *p2);
  27. static int compareAttrib(const wchar_t *attrib, void *p);
  28. };*/
  29. // ----------------------------------------------------------------------------------------------------------
  30. // ----------------------------------------------------------------------------------------------------------
  31. class ScriptObjectI : public ScriptObjectX
  32. {
  33. private:
  34. /* These three classes are here to ensure they don't get used anywhere else */
  35. struct assvar
  36. {
  37. int scriptid;
  38. int varid;
  39. TList<int> dlfs;
  40. };
  41. class InterfaceEntry
  42. {
  43. public:
  44. InterfaceEntry(GUID _guid, void *_ptr, int _type = INTERFACE_GENERICVOIDPTR) : guid(_guid), ptr(_ptr), type(_type) {}
  45. virtual ~InterfaceEntry() {}
  46. virtual GUID getGuid() { return guid; }
  47. virtual void *getInterface() { return ptr; }
  48. virtual int getType() { return type; }
  49. private:
  50. GUID guid;
  51. void *ptr;
  52. int type;
  53. };
  54. class MemberVar
  55. {
  56. public:
  57. MemberVar(const wchar_t *name, int scriptid, int rettype);
  58. virtual ~MemberVar();
  59. const wchar_t *getName() { return name; }
  60. int getScriptId() { return scriptid; }
  61. int getReturnType() { return rettype; }
  62. int getGlobalId() { return globalid; }
  63. private:
  64. StringW name;
  65. int scriptid;
  66. int rettype;
  67. int globalid;
  68. };
  69. public:
  70. ScriptObjectI(const wchar_t *class_name = NULL, ScriptObjectController *object_controller = NULL);
  71. virtual ~ScriptObjectI();
  72. DISPATCH(50) virtual void *vcpu_getInterface(GUID g, int *interfacetype = NULL);
  73. DISPATCH(60) virtual void *vcpu_getInterfaceObject(GUID g, ScriptObject **o);
  74. DISPATCH(100) int vcpu_getAssignedVariable(int start, int scriptid, int functionId, int *next, int *globalevententry, int *inheritedevent);
  75. DISPATCH(200) void vcpu_removeAssignedVariable(int var, int id);
  76. DISPATCH(300) void vcpu_addAssignedVariable(int var, int scriptid);
  77. DISPATCH(400) virtual const wchar_t *vcpu_getClassName();
  78. DISPATCH(500) virtual ScriptObjectController *vcpu_getController();
  79. // DISPATCH(600) virtual void vcpu_addClassHook(ScriptHook *h);
  80. // DISPATCH(700) virtual void vcpu_addObjectHook(ScriptHook *h);
  81. DISPATCH(800) int vcpu_getScriptId();
  82. DISPATCH(900) void vcpu_setScriptId(int i);
  83. DISPATCH(1000) int vcpu_getMember(const wchar_t *id, int scriptid, int rettype);
  84. DISPATCH(1100) void vcpu_delMembers(int scriptid);
  85. DISPATCH(1200) virtual void vcpu_setInterface(GUID g, void *v, int interfacetype = INTERFACE_SCRIPTOBJECT);
  86. DISPATCH(1300) virtual void vcpu_setClassName(const wchar_t *name);
  87. DISPATCH(1400) virtual void vcpu_setController(ScriptObjectController *c);
  88. DISPATCH(1500) virtual void vcpu_init();
  89. protected:
  90. NODISPATCH int getEventForVar(assvar *var, int funcid, int *inheritedevent);
  91. NODISPATCH void computeEventList(assvar *a);
  92. PtrList < assvar > assignedVariables;
  93. PtrList < MemberVar > memberVariables;
  94. int cache_count;
  95. int id;
  96. StringW membercacheid;
  97. int membercachesid;
  98. int membercachegid;
  99. PtrList < InterfaceEntry > interfaceslist;
  100. const wchar_t *classname;
  101. ScriptObjectController * controller;
  102. int ingetinterface;
  103. };
  104. #endif