diff --git a/Changelog.txt b/Changelog.txt index 9d3432b..14c5a74 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,15 @@ Changelog LuaPreprocess +v1.17 (2021-11-22) +Library: +- Added predefined macros @@ASSERT() and @@LOG(). +- Added params.release and params.logLevel for controlling aspects of the predefined macros. +- Added params.macroPrefix and params.macroSuffix (e.g. make @@FOO() call the function MACRO_FOO()). +Command line program: +- Added support for using stdin/stdout as input/output. (Specify "-" as the file path.) +- Added --release and --loglevel options. + v1.16 (2021-11-16) Library: - Added preprocessor symbols (in the form of '$name'). diff --git a/preprocess.lua b/preprocess.lua index 151e52b..98c9918 100644 --- a/preprocess.lua +++ b/preprocess.lua @@ -27,10 +27,10 @@ - getOutputSoFar, getOutputSizeSoFar, getCurrentLineNumberInOutput - outputValue, outputLua, outputLuaTemplate - startInterceptingOutput, stopInterceptingOutput - Macros (search for 'PredefinedMacros'): + Macros: - ASSERT - LOG - Search this file for 'EnvironmentTable' for more info. + Search this file for 'EnvironmentTable' and 'PredefinedMacros' for more info. Exported stuff from the library: - (all the functions above) @@ -127,7 +127,7 @@ -local PP_VERSION = "1.16.0-dev" +local PP_VERSION = "1.17.0" local MAX_DUPLICATE_FILE_INSERTS = 1000 -- @Incomplete: Make this a parameter for processFile()/processString(). @@ -1873,8 +1873,8 @@ end -- ASSERT() -- @@ASSERT( condition [, message=auto ] ) --- Macro. Does nothing if params.release is set, otherwise calls error() if --- the condition fails. The message is only evaluated if the condition fails. +-- Macro. Does nothing if params.release is set, otherwise calls error() if the +-- condition fails. The message argument is only evaluated if the condition fails. function metaFuncs.ASSERT(conditionCode, messageCode) errorIfNotRunningMeta(2) if not conditionCode then error("missing argument #1 to 'ASSERT'", 2) end @@ -1903,8 +1903,8 @@ end -- Macro. Does nothing if logLevel is lower than params.logLevel, -- otherwise prints a value[1] or a formatted message[2]. -- --- logLevel can be "error" (level 1), "warning" (level 2), --- "info" (level 3), "debug" (level 4) or "trace" (level 5). +-- logLevel can be "error", "warning", "info", "debug" or "trace" +-- (from highest to lowest priority). -- function metaFuncs.LOG(logLevelCode, valueOrFormatCode, ...) errorIfNotRunningMeta(2) diff --git a/tests/suite.lua b/tests/suite.lua index b9aaa7a..0c05111 100644 --- a/tests/suite.lua +++ b/tests/suite.lua @@ -388,9 +388,9 @@ doTest("Predefined macros", function() assertCodeOutput(luaOut, [[if not (foo) then error("Assertion failed: foo") end]]) local luaOut = assert(pp.processString{ code=[[ - @@ASSERT(foo ~= "bad", "Bad foo: "..foo) + @@ASSERT(foo ~= "good", "Bad foo: "..foo) ]]}) - assertCodeOutput(luaOut, [[if not (foo ~= "bad") then error(("Bad foo: "..foo)) end]]) + assertCodeOutput(luaOut, [[if not (foo ~= "good") then error(("Bad foo: "..foo)) end]]) -- @@LOG() local luaOut = assert(pp.processString{ logLevel="error", code=[[