1
0

rootobjcontroller.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "precomp.h"
  2. //<?#include "<class data="implementationheader"/>"
  3. #include "rootobjcontroller.h"
  4. //?>
  5. #include <api/script/objects/rootobj.h>
  6. #include <api/script/objects/rootobjecti.h>
  7. RootScriptObjectController _rootScriptObjectController;
  8. RootScriptObjectController *rootScriptObjectController = &_rootScriptObjectController;
  9. // -- Functions table -------------------------------------
  10. function_descriptor_struct RootScriptObjectController::exportedFunction[] = {
  11. {L"getClassName", 0, (void*)RootObject_ScriptMethods::getClassName },
  12. {L"notify", 4, (void*)RootObject_ScriptMethods::notify },
  13. {L"onNotify", 4, (void*)RootObject_ScriptMethods::onNotify },
  14. };
  15. const wchar_t *RootScriptObjectController::getClassName() {
  16. return L"Object";
  17. }
  18. const wchar_t *RootScriptObjectController::getAncestorClassName() {
  19. return NULL;
  20. }
  21. int RootScriptObjectController::getNumFunctions() {
  22. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  23. }
  24. const function_descriptor_struct *RootScriptObjectController::getExportedFunctions() {
  25. return exportedFunction;
  26. }
  27. GUID RootScriptObjectController::getClassGuid() {
  28. return rootObjectGuid;
  29. }
  30. ScriptObject *RootScriptObjectController::instantiate() {
  31. RootObjectInstance *o = new RootObjectInstance;
  32. ASSERT(o != NULL);
  33. return o->getScriptObject();
  34. }
  35. void RootScriptObjectController::destroy(ScriptObject *o) {
  36. RootObjectInstance *obj = static_cast<RootObjectInstance *>(o->vcpu_getInterface(rootObjectGuid));
  37. ASSERT(obj != NULL);
  38. delete obj;
  39. }
  40. void RootScriptObjectController::deencapsulate(void *o) {
  41. RootObjectI *obj = static_cast<RootObjectI *>(o);
  42. delete obj;
  43. }
  44. void *RootScriptObjectController::encapsulate(ScriptObject *o) {
  45. return new RootObjectI(o);
  46. }
  47. // -------------------------------------------------------------------------------------------------------------------------------------
  48. // Script Methods and Events for RootObject (Object)
  49. // -------------------------------------------------------------------------------------------------------------------------------------
  50. scriptVar RootObject_ScriptMethods::getClassName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  51. SCRIPT_FUNCTION_INIT;
  52. return MAKE_SCRIPT_STRING(o->vcpu_getClassName());
  53. }
  54. scriptVar RootObject_ScriptMethods::onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) {
  55. SCRIPT_FUNCTION_INIT
  56. PROCESS_HOOKS4(o, rootScriptObjectController, s, s2, i1, i2);
  57. SCRIPT_FUNCTION_CHECKABORTEVENT;
  58. SCRIPT_EXEC_EVENT4(o, s, s2, i1, i2);
  59. }
  60. scriptVar RootObject_ScriptMethods::notify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) {
  61. SCRIPT_FUNCTION_INIT
  62. RootObject *ro = static_cast<RootObject*>(o->vcpu_getInterface(rootObjectGuid));
  63. if (ro) ro->rootobject_notify(GET_SCRIPT_STRING(s), GET_SCRIPT_STRING(s2), GET_SCRIPT_INT(i1), GET_SCRIPT_INT(i2));
  64. RETURN_SCRIPT_VOID;
  65. }