From 7bd0c23ee91589421a0456d010611d422309d246 Mon Sep 17 00:00:00 2001 From: Jane Roxanne Date: Tue, 12 May 2020 01:16:36 -0500 Subject: [PATCH] wew --- .gitignore | 4 + build.lua | 30 +++- ksrc/bios/zoryalegacy/docs.lua | 12 +- ksrc/bios/zoryaneo/docs.lua | 6 +- ksrc/biosfixes.lua | 2 +- ksrc/lupi2.lua | 0 ksrc/security.lua | 8 +- ksrc/stdlib/init.lua | 5 +- ksrc/stdlib/string.lua | 11 ++ ksrc/stdlib/table.lua | 9 ++ tkrnl.velx | Bin 2436 -> 3407 bytes utils/gendocs.lua | 248 +++++++++++++++++++++++++++++++++ 12 files changed, 316 insertions(+), 19 deletions(-) create mode 100644 .gitignore create mode 100644 ksrc/lupi2.lua create mode 100644 ksrc/stdlib/string.lua create mode 100644 ksrc/stdlib/table.lua create mode 100644 utils/gendocs.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b973370 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.velx +/.doc +.ktmp +debug.lua diff --git a/build.lua b/build.lua index fc25987..9fabb5c 100644 --- a/build.lua +++ b/build.lua @@ -159,9 +159,23 @@ local velx_spec = struct { -- This builds Tsuki into a VELX executable. print("Compiling kernel...") -local h = io.popen("luacomp ksrc/init.lua") +local h = io.popen("luacomp ksrc/init.lua", "r") +os.execute("luacomp ksrc/init.lua -O debug.lua") +local krnl = h:read("*a") +h:close() +print("Generating docs and stripping comments...") +os.execute("mkdir .docs") +h = io.popen("lua utils/gendocs.lua .docs 2>.ktmp", "w") +h:write(krnl) +h:close() +h = io.popen("find .docs -depth | tsar -o", "r") +local arc = h:read("*a") +h:close() +h = io.open(".ktmp", "rb") +local data = h:read("*a") +h:close() print("Compressing kernel...") -local data = M.compress(h:read("*a")) +data = M.compress(data) print("Writing out tkrnl.velx...") local h = io.open("tkrnl.velx", "wb") local header = velx_spec({ @@ -169,13 +183,17 @@ local header = velx_spec({ compression = 1, lver = 0x53, fver = 1, - os = 0xFF, + os = 0x7F, psize = #data, lsize=0, ssize=0, - rsize=0 + rsize=#arc }) - h:write(header) h:write(data) -h:close() \ No newline at end of file +h:write(arc) +h:close() +print("Cleaning up...") +os.execute("rm -rf .docs") +os.execute("rm -rf .ktmp") +print("Build complete.") \ No newline at end of file diff --git a/ksrc/bios/zoryalegacy/docs.lua b/ksrc/bios/zoryalegacy/docs.lua index 6d84874..b4a4fc9 100644 --- a/ksrc/bios/zoryalegacy/docs.lua +++ b/ksrc/bios/zoryalegacy/docs.lua @@ -1,6 +1,6 @@ ----@method "Zorya 1.x (Zorya Legacy)" ---[[-- - Zorya 1.x puts a few things in the global space that need to be removed. These include: - - The OEFI library - - The Zorya library -]] \ No newline at end of file +---@page zorya_legacy "Zorya 1.x (Zorya Legacy)" +---@doc "Zorya 1.x puts a few things in the global space that need to be removed. These include:" +---@doc "- The OEFI library" +---@doc "- The Zorya library" +---@doc "" +---@doc "Note: This *should* also apply to any forks of Zorya Legacy." \ No newline at end of file diff --git a/ksrc/bios/zoryaneo/docs.lua b/ksrc/bios/zoryaneo/docs.lua index f79adc7..2a310d5 100644 --- a/ksrc/bios/zoryaneo/docs.lua +++ b/ksrc/bios/zoryaneo/docs.lua @@ -1,4 +1,2 @@ ----@method "Zorya NEO (Zorya 2.0)" ---[[-- - There's not much to be done for Zorya NEO as the included Zorya module starts Tsuki with a nice enviroment. -]] \ No newline at end of file +---@page zorya_neo "Zorya NEO (Zorya 2.0)" +---@doc "There's not much to be done for Zorya NEO as the included Zorya module starts Tsuki with a nice enviroment." \ No newline at end of file diff --git a/ksrc/biosfixes.lua b/ksrc/biosfixes.lua index fe6ebe8..ec6db52 100644 --- a/ksrc/biosfixes.lua +++ b/ksrc/biosfixes.lua @@ -1,4 +1,4 @@ ----@module "BIOS fixes" +---@section biosfixes "BIOS fixes" local _biossupport = {} @[[function biosfix(bios)]] diff --git a/ksrc/lupi2.lua b/ksrc/lupi2.lua new file mode 100644 index 0000000..e69de29 diff --git a/ksrc/security.lua b/ksrc/security.lua index 6604fb2..838d91c 100644 --- a/ksrc/security.lua +++ b/ksrc/security.lua @@ -1,9 +1,15 @@ +---@module security Security local security = {} +---@func checkacl +---@arg permission string "The permission to check." +---@return boolean "True if the current process has this permission." function security.checkacl(permission) local perms = acl.get("group", thread.info().egid, {}) end +---@func getmode +---@return string "The current security mode." function security.getmode() end @@ -11,4 +17,4 @@ end function security.init() klog("security", 1, "Security init started.") -end \ No newline at end of file +end diff --git a/ksrc/stdlib/init.lua b/ksrc/stdlib/init.lua index 26a77bc..c5cb84b 100644 --- a/ksrc/stdlib/init.lua +++ b/ksrc/stdlib/init.lua @@ -2,4 +2,7 @@ function _P.load(...) if (security.checkacl("unsigned_code")) then end -end \ No newline at end of file +end + +--#include "ksrc/stdlib/string.lua" +--#include "ksrc/stdlib/thread.lua" \ No newline at end of file diff --git a/ksrc/stdlib/string.lua b/ksrc/stdlib/string.lua new file mode 100644 index 0000000..850e02c --- /dev/null +++ b/ksrc/stdlib/string.lua @@ -0,0 +1,11 @@ +_P.string = {} +@[[function copylib(method)]] +_P.string.@[{method}] = string.@[{method}] +@[[end]] + +@[[for k, v in pairs(string) do + copylib(k) +end]] +@[[copylib("trim")]] +@[[copylib("explode")]] +@[[copylib = nil]] \ No newline at end of file diff --git a/ksrc/stdlib/table.lua b/ksrc/stdlib/table.lua new file mode 100644 index 0000000..081bbdd --- /dev/null +++ b/ksrc/stdlib/table.lua @@ -0,0 +1,9 @@ +_P.table = {} +@[[function copylib(method)]] +_P.table.@[{method}] = table.@[{method}] +@[[end]] + +@[[for k, v in pairs(table) do + copylib(k) +end]] +@[[copylib = nil]] \ No newline at end of file diff --git a/tkrnl.velx b/tkrnl.velx index 57c815a6fc939eeb80758323b689e8e801309daf..42f087efb4571f747ace6df2cdc5e66dadec1e8b 100644 GIT binary patch literal 3407 zcmb_edvp_38lP#>LI&F=DUU9=+uLai6Vgu7v=A&!U$m}xJT`q$q#(&;<|Y|4nMr3R zebB9>fU8y%s0y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6tbMu!X>6ao;7QYg?M1HR^T0e$nvA}8v#8;27G84YTF8p;%QJ7TJE?Jc9g#1A+D;8t`L>9G@-i13^3^@O zSeMp5^xfBWWllfw{1>rA`qrlEkaTTX;?_w7^Yz=2o6)ydIwp_osvQDC1E8WW+&Q;7 zz(Pijj2fa_SDo9VhHpU4sEhHzWyObPlpEcjbn7pTH#Xr<-(93YgSrHZl-nRE$mTL?sgJWnM7^g-GXV!hS8BzKvtmZ%Pwx#V*w72ixuh&$SmftZL3`U7#1O71= z5O9f$7x8G+rY-Ul66uZMSe72oqH>nCn07$ztSKv5sz@r8*WDS^>oNTeOs|jHOhFE~ zr)X0h%*TlIo|3XX=~XL^%*6nyS5t2e>DqsH+mIG=KDn=Ccd;yVJAWze)>re_OarqE zO~g7DaB~l5JUe&g9+y?<)1~|7y8g%6xu7SWpBsLB&+G*USyBF*DHFW4*IBawPnVX@ x7e}0*t8IJs1s(I|+k 0) then + for k=1, #docs[i].methods[j].args do + fun = fun .. docs[i].methods[j].args[k].name..":"..docs[i].methods[j].args[k].type .. ", " + argtext = argtext .. docs[i].methods[j].args[k].name .. " - " .. docs[i].methods[j].args[k].doc .. "\n" + end + if (docs[i].methods[j].vararg) then + fun = fun .. "..." + else + fun = fun:sub(1, #fun-2) + end + else + argtext = "No arguments" + end + fun = fun .. ")" + + local rettext = "" + if (#docs[i].methods[j].ret > 0) then + fun = fun .. ":" + for k=1, #docs[i].methods[j].ret do + fun = fun .. docs[i].methods[j].ret[k].type .. ", " + rettext = rettext .. docs[i].methods[j].ret[k].type .. " - " .. docs[i].methods[j].ret[k].doc .. "\n" + end + if (docs[i].methods[j].varret) then + fun = fun .. "..." + else + fun = fun:sub(1, #fun-2) + end + else + rettext = "No return." + end + docc = docc .. fun .. "\n\nArguments:\n"..argtext.."\n\nReturns:\n"..rettext + else + docc = docc .. docs[i].methods[j].print_name .. "\n\n" + end + for k=1, #docs[i].methods[j].doc do + docc = docc..docs[i].methods[j].doc[k].doc .. "\n" + end + f:write(docc) + f:close() + end +end \ No newline at end of file