isApiLevel1 = not platform.withGC ------------------------------ -- Extend the window object -- ------------------------------ do local window = getmetatable(platform.window) -- Add invalidate all function window:invalidateAll() -- self:setFocus(false) -- self:setFocus(true) self:invalidate() end end ----------- -- withGC - ----------- if isApiLevel1 then platform.withGC = function(func, ...) local gc = platform.gc() local args = {...} table.insert(args, gc) gc:begin() local result = {func(unpack(args))} gc:finish() return unpack(result) end end --------------- -- Extend GC -- --------------- function AddToGC(key, func) local gcMetatable = platform.withGC(getmetatable) gcMetatable[key] = func end ----------------------------- -- setColorRGB fix for 3.1 -- ----------------------------- if isApiLevel1 then do local _setColorRGB = platform.gc().setColorRGB local function setColorRGB(gc, r, g, b) if b then _setColorRGB(gc, r, g, b) else r, g = math.modf(r / 65536) g, b = math.modf(g * 256) _setColorRGB(gc, r, g, b * 256) end end AddToGC("setColorRGB", setColorRGB) end end -------------------------- -- Tuple implementation -- -------------------------- local function tuple(...) return {n=select('#', ...), ...} end