You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c1a2272
Browse filesBrowse the repository at this point in the historyBrowse files
`__wurst_forFields` invokes the callback once for every non-static instance field. The callback receives the
899
-
field name and current value and must produce a statement. `__wurst_mapFields` invokes a reader callback and
900
-
assigns its result back to each field. Leave the two callback parameter types inferred; overload the reader or
901
-
writer for the field types used by the state class.
926
+
At each concrete call such as `loadState<PlayerState>(reader)`, the compiler specializes the required path and
927
+
lowers `newInstance<PlayerState>()` to its normal zero-argument constructor. `T` must resolve to a concrete,
928
+
non-abstract class with an accessible zero-argument constructor. Interfaces, handles, primitives, tuples,
929
+
unresolved type parameters, and classes without a usable constructor are rejected.
930
+
931
+
Keep a generic loader in the free-function form shown above. On Lua, a method cannot currently combine type
932
+
parameters from its generic owning class with additional type parameters declared by the method itself.
933
+
Likewise, do not call `newInstance<T>()` from a generic class constructor. Construct the state in the loader and
934
+
initialize nested state explicitly afterward.
935
+
936
+
On Lua, do not invoke a generic-construction method directly on a freshly constructed generic receiver. Prefer the
937
+
free loader above, or store the receiver in a typed local first. Multi-parameter generic-interface dispatch is also
938
+
outside this loader contract; use one construction type parameter. `newInstance<T>()` is for runtime Jass/Lua
939
+
construction and is not supported inside `compiletime(...)` expressions. Field mapping also does not support
940
+
nested modules whose sibling submodules declare fields with the same name; use direct fields, inheritance, or
941
+
unique shallow module field names for dedicated state classes.
902
942
903
943
These are compile-time transformations, not runtime reflection, and generate equivalent direct accesses in both
904
-
Jass and Lua. Keep serializable state in a small class with mutable instance fields and keep the persistence
905
-
codec separate from the rest of the game logic. See the [Save and Load tutorial](/tutorials/saveload.html) for
944
+
Jass and Lua. They generate no runtime registry, type-name lookup, or reflection metadata. Keep serializable state
945
+
in small, dedicated classes, avoid unsupported field kinds such as static fields, and keep persistence codecs and
946
+
format migration separate from the state model. See the [Save and Load tutorial](/tutorials/saveload.html) for
906
947
integration with Warcraft III's file API.
907
948
949
+
Identifiers beginning with `__wurst` are reserved for compiler-generated internals and must not be declared by
950
+
user code.
951
+
908
952
### Array Members
909
953
910
954
Wurstscript supports sized arrays as classmembers by translating it to SIZE times arrays and then resolve the array in a get/set function via binary search.
0 commit comments