ProgramAttribute.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. class "ProgramAttribute"
  2. function ProgramAttribute:__getvar(name)
  3. if name == "size" then
  4. return Polycode.ProgramAttribute_get_size(self.__ptr)
  5. elseif name == "name" then
  6. return Polycode.ProgramAttribute_get_name(self.__ptr)
  7. elseif name == "platformData" then
  8. local retVal = Polycode.ProgramAttribute_get_platformData(self.__ptr)
  9. if retVal == nil then return nil end
  10. local __c = _G["void"]("__skip_ptr__")
  11. __c.__ptr = retVal
  12. return __c
  13. end
  14. end
  15. function ProgramAttribute:__setvar(name,value)
  16. if name == "size" then
  17. Polycode.ProgramAttribute_set_size(self.__ptr, value)
  18. return true
  19. elseif name == "name" then
  20. Polycode.ProgramAttribute_set_name(self.__ptr, value)
  21. return true
  22. elseif name == "platformData" then
  23. Polycode.ProgramAttribute_set_platformData(self.__ptr, value.__ptr)
  24. return true
  25. end
  26. return false
  27. end
  28. function ProgramAttribute:ProgramAttribute(...)
  29. local arg = {...}
  30. for k,v in pairs(arg) do
  31. if type(v) == "table" then
  32. if v.__ptr ~= nil then
  33. arg[k] = v.__ptr
  34. end
  35. end
  36. end
  37. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  38. self.__ptr = Polycode.ProgramAttribute(unpack(arg))
  39. end
  40. end
  41. function ProgramAttribute:__delete()
  42. if self then Polycode.delete_ProgramAttribute(self.__ptr) end
  43. end