MagicFunctions

Core Language View source
MagicFunctions

builtin magic function. Calls all functions with the given annotation, for example callFunctionsWithAnnotation("@initializeObject"). The called functions must not take any parameters.

Types

Functions and constants

public function compileError(string msg)

Stops compilation with the provided error message

public function getMapName() returns string

Returns the map name from wurst.build file

public function getBuildDate() returns string

Returns the build date in uuuu-MM-dd’T’HH:mm format

public function isProductionBuild() returns boolean

Returns true if the map is being built using the ‘buildmap’ command, false otherwise.

public function getStackTraceString() returns string

builtin function which returns a stack trace. If stack traces are disabled, this function returns the empty string.

public function callFunctionsWithAnnotation(string _annotation)
public function preserveName()

Prevents -opt name minification for a top-level function whose name is used externally.

public constant compiletime = false

this is a magic constant. It is always false at runtime and true during compiletime.

public constant isLua = false

This is a magic constant. It is always false when compiling to Jass and true when compiling to Lua. Use it to write backend-specific code paths.

public function compiletime<T:>(T expr) returns T

This is a builtin magic function.

  • It evaluates its argument at compiletime and replaces the call with the result.
public function wurstForFields(WurstFieldCallback _callback)

Emits the callback once for every accessible non-static field of the enclosing class.

The callback receives the source field name and its concrete value. This is compile-time code generation: the generated Jass or Lua contains direct field accesses and no runtime reflection. Use the explicit-target form wurstForFields(target, callback) for classes and tuples.

public function wurstForFields<T:>(T _target, WurstFieldCallback _callback)

Emits the callback once for every accessible non-static field of target.

This overload supports class instances and tuple values. The target expression is evaluated once, and the compiler specializes the callback value to each field’s concrete type.

public function wurstMapFields(WurstFieldMapper _callback)

Maps every accessible mutable non-static field of the enclosing class.

Each callback result is assigned back to its field. Use the explicit-target form wurstMapFields(target, callback) for classes and tuple variables.

public function wurstMapFields<T:>(T _target, WurstFieldMapper _callback)

Maps every accessible mutable non-static field of target.

This overload supports class instances and tuple variables. The target expression is evaluated once, and each specialized callback result is assigned directly back to its field.

public function wurstNewInstance<T:>() returns T

Constructs the concrete class T through its accessible zero-argument constructor.

This is an intrinsic rather than runtime reflection. Consequently T must be known concretely at the call site and normal constructor visibility and abstract-class checks still apply.