diff options
Diffstat (limited to 'spec/inputs/macro_export.yue')
-rw-r--r-- | spec/inputs/macro_export.yue | 18 |
1 files changed, 18 insertions, 0 deletions
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 |