|
22 | 22 | - tokenize, newToken, concatTokens, removeUselessTokens, eachToken, isToken, getNextUsefulToken |
23 | 23 | - toLua, serialize |
24 | 24 | Only during processing: |
| 25 | + - getCurrentPathIn, getCurrentPathOut |
25 | 26 | - outputValue, outputLua |
26 | 27 | Search this file for 'EnvironmentTable' for more info. |
27 | 28 |
|
@@ -182,6 +183,8 @@ local isDebug = false |
182 | 183 | local currentErrorHandler = _error |
183 | 184 |
|
184 | 185 | local isRunningMeta = false |
| 186 | +local currentPathIn = "" |
| 187 | +local currentPathOut = "" |
185 | 188 | local metaPathForErrorMessages = "" |
186 | 189 | local outputFromMeta = nil |
187 | 190 |
|
@@ -1049,6 +1052,20 @@ function metaFuncs.outputLua(...) |
1049 | 1052 | end |
1050 | 1053 | end |
1051 | 1054 |
|
| 1055 | +-- getCurrentPathIn() |
| 1056 | +-- Get what file is currently being processed, if any. |
| 1057 | +-- path = getCurrentPathIn( ) |
| 1058 | +function metaFuncs.getCurrentPathIn() |
| 1059 | + return currentPathIn |
| 1060 | +end |
| 1061 | + |
| 1062 | +-- getCurrentPathOut() |
| 1063 | +-- Get what file the currently processed file will be written to, if any. |
| 1064 | +-- path = getCurrentPathOut( ) |
| 1065 | +function metaFuncs.getCurrentPathOut() |
| 1066 | + return currentPathOut |
| 1067 | +end |
| 1068 | + |
1052 | 1069 | -- tokenize() |
1053 | 1070 | -- Convert Lua code to tokens. Returns nil and a message on error. (See newToken() for token types.) |
1054 | 1071 | -- tokens, error = tokenize( luaString [, allowPreprocessorTokens=false ] ) |
@@ -1324,6 +1341,9 @@ local function _processFileOrString(params, isFile) |
1324 | 1341 | errorline("Could not read file: "..err) |
1325 | 1342 | end |
1326 | 1343 |
|
| 1344 | + currentPathIn = params.pathIn |
| 1345 | + currentPathOut = params.pathOut |
| 1346 | + |
1327 | 1347 | else |
1328 | 1348 | pathIn = "<code>" |
1329 | 1349 | luaUnprocessed = params.code |
@@ -1749,6 +1769,9 @@ local function _processFileOrString(params, isFile) |
1749 | 1769 |
|
1750 | 1770 | if params.onDone then params.onDone(info) end |
1751 | 1771 |
|
| 1772 | + currentPathIn = "" |
| 1773 | + currentPathOut = "" |
| 1774 | + |
1752 | 1775 | if isFile then |
1753 | 1776 | return info |
1754 | 1777 | else |
@@ -1786,6 +1809,8 @@ local function processFileOrString(params, isFile) |
1786 | 1809 |
|
1787 | 1810 | -- Cleanup in case an error happened. |
1788 | 1811 | isRunningMeta = false |
| 1812 | + currentPathIn = "" |
| 1813 | + currentPathOut = "" |
1789 | 1814 | metaPathForErrorMessages = "" |
1790 | 1815 | outputFromMeta = nil |
1791 | 1816 |
|
|
0 commit comments