aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-02-06 10:41:30 +0800
committerLi Jin <dragon-fly@qq.com>2021-02-06 10:41:30 +0800
commit32651cccb380bf4682fa8f6d3e70d74952171f7b (patch)
tree498a5d77886a0ff56b54eabed1177759bac9eba9 /spec/inputs
parent90bdaec058948f00d11ccfe955ce252ace045929 (diff)
downloadyuescript-32651cccb380bf4682fa8f6d3e70d74952171f7b.tar.gz
yuescript-32651cccb380bf4682fa8f6d3e70d74952171f7b.tar.bz2
yuescript-32651cccb380bf4682fa8f6d3e70d74952171f7b.zip
fix #38
Diffstat (limited to 'spec/inputs')
-rw-r--r--spec/inputs/macro.mp42
1 files changed, 33 insertions, 9 deletions
diff --git a/spec/inputs/macro.mp b/spec/inputs/macro.mp
index be88a3f..da696bd 100644
--- a/spec/inputs/macro.mp
+++ b/spec/inputs/macro.mp
@@ -154,16 +154,38 @@ $insertComment "a comment here"
154 154
155import 'underscore' as _ 155import 'underscore' as _
156 156
157macro expr chain = (...)-> $showMacro "chain",table.concat {...}, "\\" 157macro expr chain = (...)->
158 callable = nil
159 for item in *{...}
160 callable = callable? and "(#{callable})\\#{item}" or item
161 $showMacro "chain", callable
158 162
159a = $chain( 163a = $chain(
160 _({1, 2, 3, 4, -2, 3}) 164 _{1, 2, 3, 4, -2, 3}
161 chain! 165 chain!
162 map(=> @ * 2) 166 map => @ * 2
163 filter(=> @ > 3) 167 filter => @ > 3
164 value! 168 value!
165) 169)
166 170
171$chain(
172 _{1, 2, 3, 4, -2, 3}
173 chain!
174 map => @ * 2
175 filter => @ > 3
176 each => print @
177)
178
179result = $chain(
180 origin.transform.root.gameObject\Parents!
181 Descendants!
182 SelectEnable!
183 SelectVisible!
184 TagEqual "fx"
185 Where (x) -> x.name\EndsWith "(Clone)"
186 Destroy!
187)
188
167macro block chainB = (...)-> 189macro block chainB = (...)->
168 switch select "#", ... 190 switch select "#", ...
169 when 0 then return "" 191 when 0 then return ""
@@ -185,11 +207,13 @@ macro block chainB = (...)->
185 $showMacro "chainB", res 207 $showMacro "chainB", res
186 208
187$chainB( 209$chainB(
188 _{1, 2, 3, 4, -2, 3} 210 origin.transform.root.gameObject\Parents!
189 chain! 211 Descendants!
190 map => @ * 2 212 SelectEnable!
191 filter => @ > 3 213 SelectVisible!
192 each => print @ 214 TagEqual "fx"
215 Where (x) -> x.name\EndsWith "(Clone)"
216 Destroy!
193) 217)
194 218
195macro block implicitReturnblockMacroIsAllowed = -> "123" 219macro block implicitReturnblockMacroIsAllowed = -> "123"