diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-07-18 11:51:39 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-07-18 11:51:39 +0800 |
| commit | 9d3d8ef2be15dfbf279de71241ff747a568e2c49 (patch) | |
| tree | 53f88fa8a0e64dfa2262898312c9b4d988876fe8 /spec/inputs/macro_export.yue | |
| parent | 51a74726e6f68851bafccba0fe69900274a81d59 (diff) | |
| download | yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.tar.gz yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.tar.bz2 yuescript-9d3d8ef2be15dfbf279de71241ff747a568e2c49.zip | |
Added specs, tests and docs.
Diffstat (limited to 'spec/inputs/macro_export.yue')
| -rw-r--r-- | spec/inputs/macro_export.yue | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/spec/inputs/macro_export.yue b/spec/inputs/macro_export.yue index 75fd813..22905b5 100644 --- a/spec/inputs/macro_export.yue +++ b/spec/inputs/macro_export.yue | |||
| @@ -8,13 +8,12 @@ export macro config = (debugging = true)-> | |||
| 8 | "" | 8 | "" |
| 9 | 9 | ||
| 10 | export macro showMacro = (name, res)-> | 10 | export macro showMacro = (name, res)-> |
| 11 | if debugMacro then " | 11 | if debugMacro then | |
| 12 | do | 12 | do |
| 13 | txt = #{res} | 13 | txt = #{res} |
| 14 | print '[macro ' .. #{name} .. ']' | 14 | print '[macro #{name}]' |
| 15 | print txt | 15 | print txt |
| 16 | txt | 16 | txt |
| 17 | " | ||
| 18 | else | 17 | else |
| 19 | res | 18 | res |
| 20 | 19 | ||
| @@ -35,14 +34,16 @@ export macro copy = (src, dst, ...)-> | |||
| 35 | src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_" | 34 | src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_" |
| 36 | "copy targets can not be _src_ or _dst_" | 35 | "copy targets can not be _src_ or _dst_" |
| 37 | ) | 36 | ) |
| 38 | " | 37 | copyFields = table.concat( |
| 39 | do | 38 | ["_dst_.#{field} = _src_.#{field}" for field in *{...}] |
| 40 | local _src_, _dst_ | 39 | "\n\t\t\t" |
| 41 | with _dst_ := #{dst} | 40 | ) |
| 42 | with _src_ := #{src} | 41 | | |
| 43 | #{table.concat for field in *{...} do " | 42 | do |
| 44 | _dst_.#{field} = _src_.#{field} | 43 | local _src_, _dst_ |
| 45 | "}" | 44 | with _dst_ := #{dst} |
| 45 | with _src_ := #{src} | ||
| 46 | #{copyFields} | ||
| 46 | 47 | ||
| 47 | export macro enum = (...) -> | 48 | export macro enum = (...) -> |
| 48 | items = {...} | 49 | items = {...} |
