From 7cb145374bae1ec58619f26e8500511fa91ae76c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 22 Sep 2020 16:10:46 +0300 Subject: [PATCH] refactor(classes): Move SILE.baseClass to SILE.classes.base --- classes/base.lua | 4 ++-- classes/plain.lua | 2 +- core/classes.lua | 4 +++- core/sile.lua | 2 +- documentation/c12-tricks.sil | 6 +++--- packages/parallel.lua | 2 +- packages/rules.lua | 4 ++-- spec/complex_frame_spec.lua | 2 +- tests/letter.sil | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/classes/base.lua b/classes/base.lua index 76a9807264..9520bff88c 100644 --- a/classes/base.lua +++ b/classes/base.lua @@ -99,7 +99,7 @@ return std.object { if type(pack) == "table" then if pack.exports then self:mapfields(pack.exports) end if pack.init then - table.insert(SILE.baseClass.deferredInit, function () pack.init(self, args) end) + table.insert(SILE.classes.base.deferredInit, function () pack.init(self, args) end) end end end, @@ -114,7 +114,7 @@ return std.object { SILE.outputter:init(self) self:registerCommands() -- Call all stored package init routines - for i = 1, #(SILE.baseClass.deferredInit) do (SILE.baseClass.deferredInit[i])() end + for i = 1, #(SILE.classes.base.deferredInit) do (SILE.classes.base.deferredInit[i])() end SILE.typesetter:registerPageEndHook(function () if SU.debugging("frames") then for _, v in pairs(SILE.frames) do SILE.outputter:debugFrame(v) end diff --git a/classes/plain.lua b/classes/plain.lua index 4d2a894652..58cb3c7c51 100644 --- a/classes/plain.lua +++ b/classes/plain.lua @@ -1,4 +1,4 @@ -local base = SILE.baseClass +local base = SILE.classes.base local plain = base { id = "plain" } local classopts = {} diff --git a/core/classes.lua b/core/classes.lua index c8dae32760..2c97abab7c 100644 --- a/core/classes.lua +++ b/core/classes.lua @@ -93,4 +93,6 @@ SILE.registerCommand("process", function () SU.error("Encountered unsubstituted \\process.") end, "Within a macro definition, processes the contents of the macro body.") -return require("classes/base") +return { + base = require("classes/base") +} diff --git a/core/sile.lua b/core/sile.lua index db90694a89..7f637975a3 100644 --- a/core/sile.lua +++ b/core/sile.lua @@ -39,7 +39,7 @@ SILE.units = require("core/units") SILE.measurement = require("core/measurement") SILE.length = require("core/length") SILE.papersize = require("core/papersize") -SILE.baseClass = require("core/classes") +SILE.classes = require("core/classes") SILE.nodefactory = require("core/nodefactory") require("core/settings") require("core/inputs-texlike") diff --git a/documentation/c12-tricks.sil b/documentation/c12-tricks.sil index af110e4209..cef4a51334 100644 --- a/documentation/c12-tricks.sil +++ b/documentation/c12-tricks.sil @@ -128,7 +128,7 @@ that each typesetter is linked to the appropriate frame: diglot.init = function(self) diglot.leftTypesetter:init(SILE.getFrame("a")) diglot.rightTypesetter:init(SILE.getFrame("b")) - return SILE.baseClass.init(self) + return SILE.classes.base.init(self) end \end{verbatim} @@ -291,7 +291,7 @@ discovery.init = function() SILE.getFrame("rGutter") or SILE.getFrame("lGutter") discovery.innerTypesetter:init(gutter) ... - return SILE.baseClass:init() + return SILE.classes.base:init() end discovery.newPage = function () @@ -301,7 +301,7 @@ discovery.newPage = function () SILE.getFrame("rGutter") or SILE.getFrame("lGutter") discovery.innerTypesetter:init(gutter) ... - return SILE.baseClass.newPage(discovery); + return SILE.classes.base.newPage(discovery); end \line \end{verbatim} diff --git a/packages/parallel.lua b/packages/parallel.lua index 4a5b62bdc8..c8795c532b 100644 --- a/packages/parallel.lua +++ b/packages/parallel.lua @@ -74,7 +74,7 @@ local setupParallel = function (klass, options) allTypesetters(function (frame, _) calculations[frame] = { mark = 0 } end) - SILE.baseClass:newPage() + SILE.classes.base:newPage() SILE.call("sync") end allTypesetters(function (frame, _) calculations[frame] = { mark = 0 } end) diff --git a/packages/rules.lua b/packages/rules.lua index 65f7c4b485..8a4280749f 100644 --- a/packages/rules.lua +++ b/packages/rules.lua @@ -1,5 +1,5 @@ -SILE.baseClass:loadPackage("raiselower") -SILE.baseClass:loadPackage("rebox") +SILE.classes.base:loadPackage("raiselower") +SILE.classes.base:loadPackage("rebox") SILE.registerCommand("hrule", function (options, _) local width = SU.cast("length", options.width) diff --git a/spec/complex_frame_spec.lua b/spec/complex_frame_spec.lua index df678ce549..07f1fca010 100644 --- a/spec/complex_frame_spec.lua +++ b/spec/complex_frame_spec.lua @@ -1,6 +1,6 @@ SILE = require("core/sile") -local tClass = SILE.baseClass {} +local tClass = SILE.classes.base {} tClass:declareFrame("a", { left = "1pt", right = "12pt", top = "1pt", bottom = "top(b)" }) tClass:declareFrame("b", { left = "1pt", right = "12pt", bottom = "12pt", height="4pt" }) diff --git a/tests/letter.sil b/tests/letter.sil index fa86250999..beddf31bf3 100644 --- a/tests/letter.sil +++ b/tests/letter.sil @@ -6,4 +6,4 @@ Anytown} \begin{letter} Hello. \end{letter} -\end{document} \ No newline at end of file +\end{document}