@@ -17,6 +17,34 @@ The called functions must not take any parameters.
1717
1818** [ Source on GitHub] ( https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/_wurst/MagicFunctions.wurst ) **
1919
20+ ## Interfaces
21+
22+ ### WurstFieldCallback
23+
24+ ``` wurst
25+ public interface WurstFieldCallback
26+ ```
27+
28+ Tooling signature used by the field-iteration compiler intrinsics.
29+ The compiler specializes ` value ` to the concrete type of each visited field.
30+
31+ ** Members:**
32+
33+ - ` apply(string fieldName, int value) `
34+
35+ ### WurstFieldMapper
36+
37+ ``` wurst
38+ public interface WurstFieldMapper
39+ ```
40+
41+ Tooling signature used by the field-mapping compiler intrinsic.
42+ The compiler specializes both the parameter and result to each concrete field type.
43+
44+ ** Members:**
45+
46+ - ` apply(string fieldName, int value) returns int `
47+
2048## Functions
2149
2250### compileError
@@ -75,6 +103,62 @@ public function compiletime<T:>(T expr) returns T
75103This is a builtin magic function.
76104* It evaluates it's argument at compiletime and replaces the call with the result.
77105
106+ ### wurstForFields
107+
108+ ``` wurst
109+ public function wurstForFields(WurstFieldCallback _callback)
110+ ```
111+
112+ Emits the callback once for every accessible non-static field of the enclosing class.
113+
114+ The callback receives the source field name and its concrete value. This is compile-time code
115+ generation: the generated Jass or Lua contains direct field accesses and no runtime reflection.
116+ Use the explicit-target form ` wurstForFields(target, callback) ` for classes and tuples.
117+
118+ ### wurstForFields
119+
120+ ``` wurst
121+ public function wurstForFields<T:>(T _target, WurstFieldCallback _callback)
122+ ```
123+
124+ Emits the callback once for every accessible non-static field of ` target ` .
125+
126+ This overload supports class instances and tuple values. The target expression is evaluated
127+ once, and the compiler specializes the callback value to each field's concrete type.
128+
129+ ### wurstMapFields
130+
131+ ``` wurst
132+ public function wurstMapFields(WurstFieldMapper _callback)
133+ ```
134+
135+ Maps every accessible mutable non-static field of the enclosing class.
136+
137+ Each callback result is assigned back to its field. Use the explicit-target form
138+ ` wurstMapFields(target, callback) ` for classes and tuple variables.
139+
140+ ### wurstMapFields
141+
142+ ``` wurst
143+ public function wurstMapFields<T:>(T _target, WurstFieldMapper _callback)
144+ ```
145+
146+ Maps every accessible mutable non-static field of ` target ` .
147+
148+ This overload supports class instances and tuple variables. The target expression is evaluated
149+ once, and each specialized callback result is assigned directly back to its field.
150+
151+ ### wurstNewInstance
152+
153+ ``` wurst
154+ public function wurstNewInstance<T:>() returns T
155+ ```
156+
157+ Constructs the concrete class ` T ` through its accessible zero-argument constructor.
158+
159+ This is an intrinsic rather than runtime reflection. Consequently ` T ` must be known concretely
160+ at the call site and normal constructor visibility and abstract-class checks still apply.
161+
78162## Constants
79163
80164### compiletime
0 commit comments