diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-08-05 17:20:00 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-08-05 17:20:00 +0800 |
| commit | 94edfbc8c7d62d700dfb59334a0ed3beedd49493 (patch) | |
| tree | f695cec8b8873d5a6e763ac94bf3c81fb6ba0be9 /spec | |
| parent | f8cd1220147d606b7e96f88c12fd0f163fb4e1c5 (diff) | |
| download | yuescript-0.23.9.tar.gz yuescript-0.23.9.tar.bz2 yuescript-0.23.9.zip | |
add macros generating macros feature.v0.23.9
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/macro.yue | 33 | ||||
| -rw-r--r-- | spec/inputs/macro_export.yue | 18 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc.lua | 2 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 2 | ||||
| -rw-r--r-- | spec/outputs/macro.lua | 11 |
5 files changed, 65 insertions, 1 deletions
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index ae14f53..a2e1046 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue | |||
| @@ -5,6 +5,39 @@ import "macro_export" as { | |||
| 5 | 5 | ||
| 6 | import "macro_todo" as $ | 6 | import "macro_todo" as $ |
| 7 | 7 | ||
| 8 | macro WindowFlag = $enum( | ||
| 9 | NoNav | ||
| 10 | NoDecoration | ||
| 11 | NoTitleBar | ||
| 12 | NoResize | ||
| 13 | NoMove | ||
| 14 | NoScrollbar | ||
| 15 | NoScrollWithMouse | ||
| 16 | NoCollapse | ||
| 17 | AlwaysAutoResize | ||
| 18 | NoSavedSettings | ||
| 19 | NoInputs | ||
| 20 | MenuBar | ||
| 21 | HorizontalScrollbar | ||
| 22 | NoFocusOnAppearing | ||
| 23 | NoBringToFrontOnFocus | ||
| 24 | AlwaysVerticalScrollbar | ||
| 25 | AlwaysHorizontalScrollbar | ||
| 26 | NoNavInputs | ||
| 27 | NoNavFocus | ||
| 28 | UnsavedDocument | ||
| 29 | ) | ||
| 30 | |||
| 31 | print $WindowFlag AlwaysAutoResize | ||
| 32 | print $WindowFlag( | ||
| 33 | NoNav | ||
| 34 | NoDecoration | ||
| 35 | NoTitleBar | ||
| 36 | NoResize | ||
| 37 | NoMove | ||
| 38 | NoScrollbar | ||
| 39 | ) | ||
| 40 | |||
| 8 | $asserts item == nil | 41 | $asserts item == nil |
| 9 | 42 | ||
| 10 | $myconfig false | 43 | $myconfig false |
diff --git a/spec/inputs/macro_export.yue b/spec/inputs/macro_export.yue index eec5848..cc7d459 100644 --- a/spec/inputs/macro_export.yue +++ b/spec/inputs/macro_export.yue | |||
| @@ -44,6 +44,24 @@ do | |||
| 44 | _dst_.#{field} = _src_.#{field} | 44 | _dst_.#{field} = _src_.#{field} |
| 45 | "}" | 45 | "}" |
| 46 | 46 | ||
| 47 | export macro enum = (...) -> | ||
| 48 | items = {...} | ||
| 49 | items = [item\gsub('"', '') for item in *items] | ||
| 50 | itemSet = {item, true for item in *items} | ||
| 51 | (...) -> | ||
| 52 | count = select "#", ... | ||
| 53 | if 1 < count | ||
| 54 | result = "[" | ||
| 55 | for i = 1, count | ||
| 56 | item = select i, ... | ||
| 57 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | ||
| 58 | result ..= "\"#{item}\"," | ||
| 59 | result .. "]" | ||
| 60 | else | ||
| 61 | item = select 1, ... | ||
| 62 | error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] | ||
| 63 | "\"#{item}\"" | ||
| 64 | |||
| 47 | $ -> | 65 | $ -> |
| 48 | global debugMode = true | 66 | global debugMode = true |
| 49 | global debugMacro = true | 67 | global debugMacro = true |
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 6f61569..4073056 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua | |||
| @@ -71,6 +71,7 @@ if cond then | |||
| 71 | end | 71 | end |
| 72 | print("yuescript") | 72 | print("yuescript") |
| 73 | print(3) | 73 | print(3) |
| 74 | print("Valid enum type:", "Static") | ||
| 74 | if tb ~= nil then | 75 | if tb ~= nil then |
| 75 | tb:func() | 76 | tb:func() |
| 76 | end | 77 | end |
| @@ -2068,6 +2069,7 @@ if cond then | |||
| 2068 | end | 2069 | end |
| 2069 | print("yuescript") | 2070 | print("yuescript") |
| 2070 | print(3) | 2071 | print(3) |
| 2072 | print("Valid enum type:", "Static") | ||
| 2071 | if tb ~= nil then | 2073 | if tb ~= nil then |
| 2072 | tb:func() | 2074 | tb:func() |
| 2073 | end | 2075 | end |
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index aa53926..f251450 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua | |||
| @@ -71,6 +71,7 @@ if cond then | |||
| 71 | end | 71 | end |
| 72 | print("yuescript") | 72 | print("yuescript") |
| 73 | print(3) | 73 | print(3) |
| 74 | print("有效的枚举类型:", "Static") | ||
| 74 | if tb ~= nil then | 75 | if tb ~= nil then |
| 75 | tb:func() | 76 | tb:func() |
| 76 | end | 77 | end |
| @@ -2062,6 +2063,7 @@ if cond then | |||
| 2062 | end | 2063 | end |
| 2063 | print("yuescript") | 2064 | print("yuescript") |
| 2064 | print(3) | 2065 | print(3) |
| 2066 | print("有效的枚举类型:", "Static") | ||
| 2065 | if tb ~= nil then | 2067 | if tb ~= nil then |
| 2066 | tb:func() | 2068 | tb:func() |
| 2067 | end | 2069 | end |
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index 2ee3e0a..953c260 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | print("AlwaysAutoResize") | ||
| 2 | print({ | ||
| 3 | "NoNav", | ||
| 4 | "NoDecoration", | ||
| 5 | "NoTitleBar", | ||
| 6 | "NoResize", | ||
| 7 | "NoMove", | ||
| 8 | "NoScrollbar" | ||
| 9 | }) | ||
| 1 | do | 10 | do |
| 2 | assert(item == nil) | 11 | assert(item == nil) |
| 3 | end | 12 | end |
| @@ -285,7 +294,7 @@ print((setmetatable({ | |||
| 285 | return 998 | 294 | return 998 |
| 286 | end | 295 | end |
| 287 | })) | 296 | })) |
| 288 | print("current line: " .. tostring(268)) | 297 | print("current line: " .. tostring(301)) |
| 289 | do | 298 | do |
| 290 | -- TODO | 299 | -- TODO |
| 291 | end | 300 | end |
