Skip to content

Commit

Permalink
better internal structure?
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilly Schramm committed Sep 28, 2024
1 parent 1de60e5 commit d59cad7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 36 deletions.
36 changes: 19 additions & 17 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
std = {
globals = {
prismaDebugLuacheckGenerator = {
fields = {
luaCheckGlobalsTable = {},
customEncode = {},
cleanUp = {}
}
},
prismaDebugLog = {
fields = {
tableTree = {},
detailedTableTree = {},
tableList = {},
info = {},
warn = {},
error = {}
}
},
thirdpartyenabled = {},
tech = {},
sl = {
Expand Down Expand Up @@ -292,23 +309,8 @@ std = {
},
debug = {
fields = {
log = {
fields = {
tableTree = {},
detailedTableTree = {},
tableList = {},
info = {},
warn = {},
error = {}
}
},
luacheckgenerator = {
fields = {
luaCheckGlobalsTable = {},
customEncode = {},
cleanUp = {}
}
},
log = {},
luacheckgenerator = {},
enabled = {}
}
}
Expand Down
10 changes: 5 additions & 5 deletions Prisma/prisma/core/generic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function update(...)
localAnimator = string.prisma.localAnimator;
elseif firstSuccessUpdate then

string.prisma.debug.log.info("Got the LocalAnimator!");
prismaDebugLog.info("Got the LocalAnimator!");

firstSuccessUpdate = false;

string.prisma.debug.log.detailedTableTree(_ENV, "");
-- prismaDebugLog.detailedTableTree(_ENV, "");

local resultTable = string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(_ENV)
local resultString = string.prisma.debug.luacheckgenerator.customEncode(resultTable)
resultString = string.prisma.debug.luacheckgenerator.cleanUp(resultString)
local resultTable = prismaDebugLuacheckGenerator.luaCheckGlobalsTable(_ENV)
local resultString = prismaDebugLuacheckGenerator.customEncode(resultTable)
resultString = prismaDebugLuacheckGenerator.cleanUp(resultString)
if resultString then
sb.logInfo("%s", resultString)
end
Expand Down
23 changes: 14 additions & 9 deletions Prisma/prisma/debug/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ string.prisma = string.prisma or {};
string.prisma.debug = string.prisma.debug or {};
string.prisma.debug.log = {};

function string.prisma.debug.log.tableList(node, displayString)
prismaDebugLog = {}

function prismaDebugLog.tableList(node, displayString)
if not string.prisma.debug.enabled then
return;
end
if type(node) == "table" then
for nodeName, nodeType in pairs(node) do
sb.logInfo("%s%s : %s", displayString, nodeName, type(nodeType));
string.prisma.debug.log.tableList(nodeType, displayString .. nodeName .. ".");
prismaDebugLog.tableList(nodeType, displayString .. nodeName .. ".");
end
end
end

function string.prisma.debug.log.tableTree(node, displayString)
function prismaDebugLog.tableTree(node, displayString)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -25,12 +27,12 @@ function string.prisma.debug.log.tableTree(node, displayString)
arrow = "└>";
end
sb.logInfo("%s%s %s : %s", displayString, arrow, nodeName, type(nodeType));
string.prisma.debug.log.tableTree(nodeType, displayString .. " ");
prismaDebugLog.tableTree(nodeType, displayString .. " ");
end
end
end

function string.prisma.debug.log.detailedTableTree(node, displayString)
function prismaDebugLog.detailedTableTree(node, displayString)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -44,12 +46,12 @@ function string.prisma.debug.log.detailedTableTree(node, displayString)
if type(nodeType) ~= "table" and type(nodeType) ~= "function" then
sb.logInfo("%s %s", displayString, nodeType);
end
string.prisma.debug.log.detailedTableTree(nodeType, displayString .. " ");
prismaDebugLog.detailedTableTree(nodeType, displayString .. " ");
end
end
end

function string.prisma.debug.log.info(message, title)
function prismaDebugLog.info(message, title)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -58,7 +60,7 @@ function string.prisma.debug.log.info(message, title)
sb.logInfo("\n[%s] %s", title, message);
end

function string.prisma.debug.log.warn(message, title)
function prismaDebugLog.warn(message, title)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -67,7 +69,7 @@ function string.prisma.debug.log.warn(message, title)
sb.logWarn("\n[%s] %s", title, message);
end

function string.prisma.debug.log.error(message, title)
function prismaDebugLog.error(message, title)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -76,3 +78,6 @@ function string.prisma.debug.log.error(message, title)
sb.logError("\n[%s] %s", title, message);
end


--- Export the functions for 3rd parties to use without the possibility of changing the original code
string.prisma.debug.log = prismaDebugLog;
16 changes: 11 additions & 5 deletions Prisma/prisma/debug/luacheckgenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ string.prisma = string.prisma or {};
string.prisma.debug = string.prisma.debug or {};
string.prisma.debug.luacheckgenerator = {};

function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node)
prismaDebugLuacheckGenerator = {};

function prismaDebugLuacheckGenerator.luaCheckGlobalsTable(node)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -12,7 +14,7 @@ function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node)
if type(node) == "table" then
for nodeName, nodeValue in pairs(node) do
if type(nodeValue) == "table" then
resultTable[nodeName] = string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(nodeValue)
resultTable[nodeName] = prismaDebugLuacheckGenerator.luaCheckGlobalsTable(nodeValue)
elseif type(nodeValue) == "function" then
resultTable[nodeName] = {} -- Replace functions with an empty table
else
Expand All @@ -24,7 +26,7 @@ function string.prisma.debug.luacheckgenerator.luaCheckGlobalsTable(node)
return resultTable
end

function string.prisma.debug.luacheckgenerator.customEncode(value)
function prismaDebugLuacheckGenerator.customEncode(value)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -33,7 +35,7 @@ function string.prisma.debug.luacheckgenerator.customEncode(value)
local elements = {}
for k, v in pairs(value) do
local key = type(k) == "string" and string.format('"%s": ', k) or ""
table.insert(elements, key .. string.prisma.debug.luacheckgenerator.customEncode(v))
table.insert(elements, key .. prismaDebugLuacheckGenerator.customEncode(v))
end
return "{ fields: {" .. table.concat(elements, ", ") .. "}}"
elseif type(value) == "string" then
Expand All @@ -45,7 +47,7 @@ function string.prisma.debug.luacheckgenerator.customEncode(value)
end
end

function string.prisma.debug.luacheckgenerator.cleanUp(input)
function prismaDebugLuacheckGenerator.cleanUp(input)
if not string.prisma.debug.enabled then
return;
end
Expand All @@ -57,3 +59,7 @@ function string.prisma.debug.luacheckgenerator.cleanUp(input)
output = output:gsub('" =', ' =')
return output
end


--- Export the functions for 3rd parties to use without the possibility of changing the original code
string.prisma.debug.luacheckgenerator = prismaDebugLuacheckGenerator;

0 comments on commit d59cad7

Please sign in to comment.