2121 loadParams
2222 makeDirectory, makeDirectoryRecursive, removeDirectory, removeDirectoryRecursive
2323 NOSPACE
24+ PUSH_CONTEXT, POP_CONTEXT
2425 readFile, writeFile, writeTextFile
2526 templateToLua
2627 templateToString, templateToStringUtf16
2728 toWindowsPath
2829 traverseDirectory
2930 utf16ToUtf8, utf8ToUtf16
30- XPCALL
3131 zipDirectory, zipFiles
3232
3333--============================================================]]
@@ -72,7 +72,7 @@ function _G.loadParams()
7272 if not (line == " " or line :find " ^#" ) then
7373 local k , v = line :match " ^([%w_]+)%s*=%s*(.*)$"
7474 if not k then
75- error ( F ( " local/param.ini:%d: Bad line format: %s" , ln , line ) )
75+ errorf ( " local/param.ini:%d: Bad line format: %s" , ln , line )
7676 end
7777
7878 if k == " pathGpp32" then params .pathGpp32 = v
@@ -135,7 +135,7 @@ function _G.executeRequired(cmd, args)
135135
136136 local exitCode = os.execute (cmd )
137137 if exitCode ~= 0 then
138- error ( F ( " Got code %d from command: %s" , exitCode , cmd ) )
138+ errorf ( " Got code %d from command: %s" , exitCode , cmd )
139139 end
140140end
141141
146146function _G .templateToString (s , values , formatter )
147147 return (s :gsub (" ${(%w+)}" , function (k )
148148 local v = values [k ]
149- if not v then error ( F ( " No value '%s'." , k ) ) end
149+ if not v then errorf ( " No value '%s'." , k ) end
150150 if formatter then v = formatter (v ) end
151151 return v
152152 end ))
@@ -158,7 +158,7 @@ function _G.templateToStringUtf16(params, s, values, formatter)
158158 return (s :gsub (" $%z{%z([%w%z]+)}%z" , function (k )
159159 k = utf16ToUtf8 (params , k )
160160 local v = values [k ]
161- if not v then error ( F ( " No value '%s'." , k ) ) end
161+ if not v then errorf ( " No value '%s'." , k ) end
162162 if formatter then v = formatter (v ) end
163163 return utf8ToUtf16 (params , v )
164164 end ))
@@ -297,7 +297,7 @@ function _G.makeDirectory(dir)
297297
298298 local ok , err = lfs .mkdir (dir )
299299 if not ok then
300- error ( F ( " Could not make directory '%s'. (%s)" , dir , err ) )
300+ errorf ( " Could not make directory '%s'. (%s)" , dir , err )
301301 end
302302end
303303function _G .makeDirectoryRecursive (dir )
@@ -311,7 +311,7 @@ function _G.removeDirectory(dir)
311311
312312 local ok , err = lfs .rmdir (dir )
313313 if not ok then
314- error ( F ( " Could not remove directory '%s'. (%s)" , dir , err ) )
314+ errorf ( " Could not remove directory '%s'. (%s)" , dir , err )
315315 end
316316end
317317function _G .removeDirectoryRecursive (dir )
375375
376376
377377
378- -- ok, err = !XPCALL `lua`
379- function XPCALL (lua )
380- __LUA " xpcall(function() "
381- __LUA (lua )
382- __LUA " end, xpcallErrorHandler)"
383- end
384-
385-
386378do
387379 local function outputArgumentChecks (errLevel , argsStr )
388380 local optionalPos = argsStr :find (" ?" , 1 , true ) or # argsStr
438430
439431
440432
433+ local ctxName
434+
435+ function _G .PUSH_CONTEXT (_ctxName )
436+ ctxName = _ctxName
437+ __LUA " do "
438+ __LUA " local function " __LUA (ctxName )__LUA " Context(ctx)"
439+ end
440+
441+ function _G .POP_CONTEXT ()
442+ __LUA " end "
443+ __LUA " local ctx = pushContext(" __VAL (ctxName )__LUA " , " __LUA (ctxName )__LUA " Context) "
444+ __LUA (ctxName )__LUA " Context(ctx) "
445+ __LUA " end"
446+ end
447+
448+
449+
0 commit comments