From 96352955e810e2e518449920dc2236ddea79ebca Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Mon, 23 Jan 2017 14:09:32 +0300 Subject: [PATCH] aefaf --- .DS_Store | Bin 18436 -> 18436 bytes Applications.txt | 4 +- Applications/.DS_Store | Bin 79876 -> 79876 bytes Applications/Stargate/Stargate.lua | 2 +- lib/advancedLua.lua | 82 ++++++++++++++++++----------- 5 files changed, 54 insertions(+), 34 deletions(-) diff --git a/.DS_Store b/.DS_Store index cb3164ff7c687a5e7ba488e20a4e04ea8a5fb61c..94723fd2636bcce4fc4a6c744952c3e723f410b2 100644 GIT binary patch delta 683 zcmaLTPe{{Y9LMqRr!;;~Puret&dsgbM7ODl&Spc6=5iM5q^u@Ef0UULqcx?0V4+5N zkgO1%{z*m9AtIv!Q&6l!heA3;HiDuKUA&ctpd^rb*lrPhZ{N@R_8J+-$T*%17BjB1 zH#N7IBdro{vuq1g$c5q>IVZRb=a{XGP3o;13*BXv)wRKJ+8~T3a~|jNV|khEbZ-Wi zLvG(*?zNXP5!0fn`01XsNf-^hoL4ZBV$l=vWOrt9Ajs|HcX;*~Et2^%TI=O(D)>ztBV0UcsI-O#Tre&T=pK5EBZ?;u$<4%#Q zD6_S;j&qTttg|&(uj)Fbs-+zTb{lWxyO|MRnINqw^cU)XNf&65z9`OL^c%T~(xez& z@Sq$41Q9|Qjo5`fXv2OSKvW@iB8ILEWHJLefHN4xkm4N01zf}>T*h@wxNsA2OWm^W51II$uK)l5 delta 372 zcmZpfz}PZ@aYL;NCl9Zbho_eUkI!UB7U#*wRV*fRNeNG0&B7zPnonFtQB_Od#L~|B z3crA$kgy03&*WP=T9e~cI0U>o!^={OiZk=`AcEFBlmDnXGftlDpeA9# zsqA3D00A5fvJ6HHE(|^l2@FLH)eOB1GZ}xUS+(;_?+6yWhj^C<7+nZjR$r6r{#c$|4$ zIRzQtatbhTC_8|ip+LwPlh2D3@^59_!MKxgH{%}0qm1VmuW#O?DImaMVrr?QU}S1G N`JkfXW>Ks6ya3DUVyXZD diff --git a/Applications.txt b/Applications.txt index c3da0f5b..567c85e3 100644 --- a/Applications.txt +++ b/Applications.txt @@ -260,7 +260,7 @@ url="IgorTimofeev/OpenComputers/master/lib/advancedLua.lua", type="Library", preLoadFile=true, - version=1.06, + version=1.07, }, { name="MineOS/System/OS/EFI.lua", @@ -870,7 +870,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/Stargate/Icon.pic", createShortcut="desktop", - version=1.03, + version=1.04, resources={ { name="Gate.pic", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index e97ca239665efb64700521f79ddea9d68f2ffe0f..18e9fa77ac74660e9aff736ae40734e1ebe5f8d5 100644 GIT binary patch delta 71 zcmZqqz|!)8rC|%>C)vqwR<%sGRAcm<{y~mWY4Wry(%b*=G4eBR=T=~R&Wl}^n{hk4 I0pnkG07RP{IRF3v delta 49 tcmZqqz|!)8rC|%>C)vq!O4m)kc`ac2emO>^?LzX55BSi8^cg>K002tW74-lB diff --git a/Applications/Stargate/Stargate.lua b/Applications/Stargate/Stargate.lua index 6d0344c4..224f1be3 100755 --- a/Applications/Stargate/Stargate.lua +++ b/Applications/Stargate/Stargate.lua @@ -19,7 +19,7 @@ end local toolbarWidth = 32 local sg = image.load("MineOS/Applications/Stargate.app/Resources/Gate.pic") local sgCore = image.load("MineOS/Applications/Stargate.app/Resources/GateCore.pic") -local pathToContacts = "MineOS/System/Stargate/Contacts.cfg" +local pathToContacts = "MineOS/System/Stargate/Contacts2.cfg" local buttons = {} local contacts = {addresses = {}} local chevrons = { diff --git a/lib/advancedLua.lua b/lib/advancedLua.lua index 5357fedb..437582e6 100755 --- a/lib/advancedLua.lua +++ b/lib/advancedLua.lua @@ -116,15 +116,15 @@ end -------------------------------------------------- Table extensions -------------------------------------------------- -local function doSerialize(array, text, prettyLook, indentationSymbol, oldIndentationSymbol, equalsSymbol, currentRecusrionStack, recursionStackLimit) - text = {"{"} +local function doSerialize(array, prettyLook, indentationSymbol, indentationSymbolAdder, equalsSymbol, currentRecusrionStack, recursionStackLimit) + local text, keyType, valueType, stringValue = {"{"} table.insert(text, (prettyLook and "\n" or nil)) for key, value in pairs(array) do - local keyType, valueType, stringValue = type(key), type(value), tostring(value) + keyType, valueType, stringValue = type(key), type(value), tostring(value) if keyType == "number" or keyType == "string" then - table.insert(text, (prettyLook and indentationSymbol or nil)) + table.insert(text, (prettyLook and table.concat({indentationSymbol, indentationSymbolAdder}) or nil)) table.insert(text, "[") table.insert(text, (keyType == "string" and table.concat({"\"", key, "\""}) or key)) table.insert(text, "]") @@ -139,33 +139,48 @@ local function doSerialize(array, text, prettyLook, indentationSymbol, oldIndent elseif valueType == "table" then -- Ограничение стека рекурсии if currentRecusrionStack < recursionStackLimit then - table.insert(text, table.concat(doSerialize(value, text, prettyLook, table.concat({indentationSymbol, indentationSymbol}), table.concat({oldIndentationSymbol, indentationSymbol}), equalsSymbol, currentRecusrionStack + 1, recursionStackLimit))) + table.insert(text, table.concat(doSerialize(value, prettyLook, table.concat({indentationSymbol, indentationSymbolAdder}), indentationSymbolAdder, equalsSymbol, currentRecusrionStack + 1, recursionStackLimit))) else table.insert(text, "...") end - else - -- error("Unsupported table value type: " .. valueType) end table.insert(text, ",") table.insert(text, (prettyLook and "\n" or nil)) - else - -- error("Unsupported table key type: " .. keyType) end end - table.remove(text, (prettyLook and #text - 1 or #text)) - table.insert(text, (prettyLook and oldIndentationSymbol or nil)) + -- Удаляем запятую + if prettyLook then + if #text > 2 then + table.remove(text, #text - 1) + end + -- Вставляем заодно уж символ индентации, благо чек на притти лук идет + table.insert(text, indentationSymbol) + else + if #text > 1 then + table.remove(text, #text) + end + end + table.insert(text, "}") + return text end function table.serialize(array, prettyLook, indentationWidth, indentUsingTabs, recursionStackLimit) checkArg(1, array, "table") - indentationWidth = indentationWidth or 2 - local indentationSymbol = indentUsingTabs and " " or " " - indentationSymbol, indentationSymbolHalf = string.rep(indentationSymbol, indentationWidth) - return table.concat(doSerialize(array, {}, prettyLook, indentationSymbol, "", prettyLook and " = " or "=", 1, recursionStackLimit or math.huge)) + return table.concat( + doSerialize( + array, + prettyLook, + "", + string.rep(indentUsingTabs and " " or " ", indentationWidth or 2), + prettyLook and " = " or "=", + 1, + recursionStackLimit or math.huge + ) + ) end function table.unserialize(serializedString) @@ -174,13 +189,8 @@ function table.unserialize(serializedString) if success then return result else return nil, result end end -function table.toString(...) - return table.serialize(...) -end - -function table.fromString(...) - return table.unserialize(...) -end +table.toString = table.serialize +table.fromString = table.unserialize function table.toFile(path, array, prettyLook, indentationWidth, indentUsingTabs, recursionStackLimit, appendToFile) checkArg(1, path, "string") @@ -365,16 +375,26 @@ end -------------------------------------------------- Playground -------------------------------------------------- --- local function safeCall(method, ...) --- local arguments = {...} --- return xpcall(function() return method(table.unpack(arguments)) end, debug.traceback) --- end +-- local t = { +-- abc = 123, +-- def = { +-- cyka = "pidor", +-- vagina = { +-- chlen = 555, +-- devil = 666, +-- god = 777, +-- serost = { +-- tripleTable = "aefaef", +-- aaa = "bbb", +-- ccc = 123, +-- } +-- } +-- }, +-- ghi = "HEHE", +-- emptyTable = {}, +-- } --- local function safeCallString(str) --- return safeCall(load(str)) --- end - --- print(safeCallString("return 123")) +-- print(table.toString(t, true)) ------------------------------------------------------------------------------------------------------------------