diff --git a/LibEvaluator.lua b/LibEvaluator.lua deleted file mode 100644 index 1734e5e..0000000 --- a/LibEvaluator.lua +++ /dev/null @@ -1,85 +0,0 @@ - - -local MAJOR = "StarLibEvaluator-1.0" -local MINOR = 1 -assert(LibStub, MAJOR.." requires LibStub") -local LibEvaluator = LibStub:NewLibrary(MAJOR, MINOR) -if not LibEvaluator then return end - -if not LibEvaluator.__index then - LibEvaluator.__index = LibEvaluator - LibEvaluator.pool = setmetatable({}, {__mode = "k"}) -end - -LibEvaluator.__call = function(...) - self.ExecuteCode(...) -end - -function LibEvaluator:New() - - local obj = next(self.pool) - - if obj then - self.pool[obj] = nil - else - obj = {} - end - - setmetatable(obj, self) - - return obj -end - -function LibEvaluator:Del(ev) - LibEvaluator.pool[ev] = true -end - -do - local pool = setmetatable({},{__mode='v'}) - LibEvaluator.ExecuteCode = function(self, tag, code, dontSandbox, defval) - if not defval and not dontDefault then defval = "" end - - if not self or not tag or not code then return end - - local runnable = pool[code] - local err - - if not runnable then - runnable, err = loadstring(code, tag) - pool[code] = runnable - end - - if not runnable then - StarTip:Print(err) - return nil, err, 0 - end - - - if not dontSandbox then - local table = StarTip.new() - table.self = self - table._G = _G - table.StarTip = StarTip - table.select = select - table.format = format - - setfenv(runnable, table) - - StarTip.del(table) - end - - local ret1, ret2, ret3 = runnable(xpcall, errorhandler) - - defval = loadstring('return ' .. (defval or ""), "defval") or function() StarTip:Print("Error at defval"); return "" end - - if not ret1 then - ret1 = defval - end - - if type(ret1) == "function" then - ret1 = ret1() - end - - return ret1, ret2 - end -end \ No newline at end of file diff --git a/LibProperty.lua b/LibProperty.lua deleted file mode 100644 index e768683..0000000 --- a/LibProperty.lua +++ /dev/null @@ -1,81 +0,0 @@ - -local MAJOR = "StarLibProperty-1.0" -local MINOR = 1 -assert(LibStub, MAJOR.." requires LibStub") -local LibProperty = LibStub:NewLibrary(MAJOR, MINOR) -if not LibStub("StarLibEvaluator-1.0") then return end -local Evaluator = LibStub("StarLibEvaluator-1.0"):New() - -if not LibProperty or not Evaluator then return end - -if not LibProperty.pool then - LibProperty.pool = setmetatable({},{__mode='k'}) - LibProperty.__index = LibProperty -end - -function LibProperty:New(v, expression, name, defval) - if not v or not line or not name then return end - self.visitor = v - self.is_valid = false - self.expression = expression - - if self.expression ~= nil and type(expression) == "string" then - self.result = Evaluator.ExecuteCode(v, self.expression, defval) - if self.result == nil then - StarTip:Print(("Property: %s in \"%s\""):format(self.result, self.expression)) - end - elseif self.expression ~= nil then - StarTip:Print(("Property: <%s> has no expression."):format(name)) - end - - if not frame then - error("No frame specified") - end - - local obj = next(self.pool) - - if obj then - self.pool[obj] = nil - else - obj = {} - end - - setmetatable(obj, self) - - return obj -end - -function LibProperty:Del(prop) - LibProperty.pool[prop] = true -end - -function LibProperty:Eval() - if not self.is_valid then return -1 end - - local update = 1 - - local old = self.result - - self.result = strlen(Evaluator.ExecuteCode(self.visitor, self.expression)) and 1 - - if old == result then - update = 0 - end - - return update -end - -function LibProperty:P2N() - if type(self.result) == "number" then - return self.result - else - return tonumber(self.result) - end -end - -function LibProperty:P2S() - if type(self.result) ~= "number" and type(self.result) ~= "string" then - return "" - end - return ("%s%d"):format(self.result, self.result) -end diff --git a/LibTimer.lua b/LibTimer.lua deleted file mode 100644 index facf0fb..0000000 --- a/LibTimer.lua +++ /dev/null @@ -1,120 +0,0 @@ - -local MAJOR = "StarLibTimer-1.0" -local MINOR = 1 -assert(LibStub, MAJOR.." requires LibStub") -local LibTimer = LibStub:NewLibrary(MAJOR, MINOR) -if not LibTimer then return end - -local objects = {} -local update -local frame = CreateFrame("Frame") - -if not LibTimer.__index then - LibTimer.__index = LibTimer - LibTimer.pool = setmetatable({}, {__mode = "k"}) -end - -function LibTimer:New(duration, repeating, callback, data) - self.duration = duration - self.repeating = repeating - self.callback = callback - self.data = data - - local obj = next(self.pool) - - if obj then - self.pool[obj] = nil - else - obj = {} - end - - setmetatable(obj, self) - - return obj - -end - -function LibTimer:Del(timer) - - if timer and type(timer) == "table" then - pool[timer] = true - else - pool[self] = true - end -end - -function LibTimer:Start() - self.active = true - self.starTime = GetTime() - LibTimer:StarTimers() -end - -function LibTimer:Stop() - self.active = false - LibTimer:StopTimers() -end - -function LibTimer:TimeRemaining() - if type(self.startTime) ~= "number" then return 0 end - - local time = GetTime() - local diff = time - self.startTime - - return time - diff -end - -function LibTimer:StopTimers() - local stop = true - for i, v in ipairs(objects) do - if v.active then - stop = false - end - end - - if stop then - frame:SetScript("OnUpdate", nil) - end -end - -function LibTimer:StartTimers() - local start = false - for i, v in ipairs(objects) do - if v.active then - start = true - end - end - - if start then - frame:SetScript("OnUpdate", update) - end -end - -local function timerUpdate(self) - - if self.timer < 0.1 then - return - end - - local elapsed = self.timer / self.dur - - if self.timer > self.dur then - self:Stop() - if self.callback then self.callback(self.data) end - end -end - -update = function(self, elapsed) - - if #LibFlash.objects == 0 then - LibFlash:StopTimer() - return - end - - for i, o in ipairs(LibFlash.objects) do - if o.active then - o.timer = (o.timer or 0) + elapsed - timerUpdate(o) - end - end -end - diff --git a/Property.lua b/Property.lua deleted file mode 100644 index 5ae911f..0000000 --- a/Property.lua +++ /dev/null @@ -1,73 +0,0 @@ - -local MAJOR = "LibProperty" -local MINOR = 1 -assert(LibStub, MAJOR.." requires LibStub") -local LibProperty = LibStub:NewLibrary(MAJOR, MINOR) -if not LibProperty then return end - -if not LibProperty.pool then - LibProperty.pool = setmetatable({},{__mode='k'}) - LibProperty.__index = LibProperty -end - -function LibProperty:New(v, line, name, defval) - self.visitor = v - self.is_valid = false - self.expression = line.left - - if self.expression ~= nil and type(expression) == "string" then - self.result = StarTip:ExecuteCode(self.expression, defval) - if self.result == nil then - StarTip:Print(("Property: %s in \"%s\""):format(self.result, self.expression)) - end - elseif self.expression ~= nil then - StarTip:Print(("Property: <%s> has no expression."):format(name)) - end - - if not frame then - error("No frame specified") - end - - local obj = next(self.pool) - - if obj then - self.pool[obj] = nil - else - obj = {} - end - - setmetatable(obj, self) - - return obj -end - -function LibProperty:Eval() - if not self.is_valid then return -1 end - - local update = 1 - - local old = self.result - - self.result = strlen(StarTip:ExecuteCode(self.expression)) and 1 - - if old == result then - update = 0 - end - - return update -end - -function LibProperty:P2N() - if type(self.result) == "number" then - return self.result - else - return tonumber(self.result) - end -end - -function LibProperty:P2S() - if type(self.result) ~= "number" and type(self.result) ~= "string" then - return "" - end - return ("%s%d"):format(self.result, self.result) -end