Event.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. end
  15. end
  16. function Event:getEventCode()
  17. local retVal = Polycore.Event_getEventCode(self.__ptr)
  18. return retVal
  19. end
  20. function Event:getDispatcher()
  21. local retVal = Polycore.Event_getDispatcher(self.__ptr)
  22. if Polycore.__ptr_lookup[retVal] ~= nil then
  23. return Polycore.__ptr_lookup[retVal]
  24. else
  25. Polycore.__ptr_lookup[retVal] = EventDispatcher("__skip_ptr__")
  26. Polycore.__ptr_lookup[retVal].__ptr = retVal
  27. return Polycore.__ptr_lookup[retVal]
  28. end
  29. end
  30. function Event:setEventCode(eventCode)
  31. local retVal = Polycore.Event_setEventCode(self.__ptr, eventCode)
  32. end
  33. function Event:setDispatcher(dispatcher)
  34. local retVal = Polycore.Event_setDispatcher(self.__ptr, dispatcher.__ptr)
  35. end
  36. function Event:getEventType()
  37. local retVal = Polycore.Event_getEventType(self.__ptr)
  38. return retVal
  39. end