Event.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class "Event"
  2. COMPLETE_EVENT = 0
  3. CHANGE_EVENT = 1
  4. function Event:Event(...)
  5. for k,v in pairs(arg) do
  6. if type(v) == "table" then
  7. if v.__ptr ~= nil then
  8. arg[k] = v.__ptr
  9. end
  10. end
  11. end
  12. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  13. self.__ptr = Polycore.Event(unpack(arg))
  14. Polycore.__ptr_lookup[self.__ptr] = self
  15. end
  16. end
  17. function Event:getEventCode()
  18. local retVal = Polycore.Event_getEventCode(self.__ptr)
  19. return retVal
  20. end
  21. function Event:getDispatcher()
  22. local retVal = Polycore.Event_getDispatcher(self.__ptr)
  23. if retVal == nil then return nil end
  24. if Polycore.__ptr_lookup[retVal] ~= nil then
  25. return Polycore.__ptr_lookup[retVal]
  26. else
  27. Polycore.__ptr_lookup[retVal] = EventDispatcher("__skip_ptr__")
  28. Polycore.__ptr_lookup[retVal].__ptr = retVal
  29. return Polycore.__ptr_lookup[retVal]
  30. end
  31. end
  32. function Event:setEventCode(eventCode)
  33. local retVal = Polycore.Event_setEventCode(self.__ptr, eventCode)
  34. end
  35. function Event:setDispatcher(dispatcher)
  36. local retVal = Polycore.Event_setDispatcher(self.__ptr, dispatcher.__ptr)
  37. end
  38. function Event:getEventType()
  39. local retVal = Polycore.Event_getEventType(self.__ptr)
  40. return retVal
  41. end
  42. function Event:__delete()
  43. Polycore.__ptr_lookup[self.__ptr] = nil
  44. Polycore.delete_Event(self.__ptr)
  45. end