Core Types

MXHX defines a number of core language data types. The names of these types should look very familiar to Haxe developers, as they are meant to represent the Haxe language's core classes.

These core types are defined by the MXHX language namespaces. Add a language namespace to the root tag to make these types available. The example below uses the basic namespace:

xmlns:mx="https://ns.mxhx.dev/2024/basic"

Array

Creates a Haxe Array object.

Use the type attribute to specify an explicit type of objects stored in the array. The following array is of type Array<String>:

<mx:Array type="String">
  <mx:String>One</mx:String>
  <mx:String>Two</mx:String>
  <mx:String>Three</mx:String>
</mx:Array>

If the type attribute is omitted, it may be inferred automatically.

  • If the array is assigned to a field, the field's type will be used.
  • If the array is a standalone declaration, it will infer from the types of the array's items.

The following array is inferred as Array<Float>:

<mx:Array>
  <mx:Float>1.0</mx:Float>
  <mx:Float>2.0</mx:Float>
  <mx:Float>3.0</mx:Float>
</mx:Array>

Like in Haxe, if the array contains mixed types that are not compatible, the array's type must be declared explicitly as Any or Dynamic or a compiler error will be reported.

<mx:Array type="Any">
  <mx:Bool>true</mx:Bool>
  <mx:Float>2.0</mx:Float>
  <mx:String>Three</mx:String>
</mx:Array>

See also:

Bool

Creates a Haxe Bool value. It may be set to either true or false.

<mx:Bool>true</mx:Bool>
<mx:Bool>false</mx:Bool>

See also:

Class

References a Haxe Class object.

<mx:Class>haxe.io.Bytes</mx:Class>

See also:

Date

References a Haxe Date object.

<mx:Date fullYear="1999" month="11" date="31" hours="11" minutes="59" seconds="0"/>

See also:

EReg

Creates a Haxe EReg regular expression object.

<mx:EReg>~/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z][A-Z][A-Z]*/i</mx:EReg>

See also:

Float

Creates a Haxe Float value.

<mx:Float>123.4</mx:Float>
<mx:Float>-56</mx:Float>
<mx:Float>789e-5</mx:Float>
<mx:Float>0xfe3c12</mx:Float>

Use the string NaN to set the value to Math.NaN.

<mx:Float>NaN</mx:Float>

See also:

Int

Creates a Haxe Int value.

<mx:Int>1234</mx:Float>
<mx:Int>-56</mx:Int>
<mx:Int>0xfe3c12</mx:Int>

See also:

String

Creates a Haxe String value.

<mx:String>hello world</mx:String>

Certain characters must be escaped when included in XML, such as &.

<mx:String>I love MXHX &amp; Haxe</mx:String>

Or you may use a <![CDATA[]]> block to include unescaped text.

<mx:String><![CDATA[I love MXHX & Haxe]]></mx:String>

See also:

Struct

Creates a Haxe anonymous structure.

<mx:Struct/>
<mx:Struct>
</mx:Struct>

See also:

UInt

Creates a Haxe UInt value.

<mx:UInt>12345</mx:UInt>

See also:

Xml

Creates a Haxe Xml object from the markup inside this tag.

<mx:Xml>
  <items>
    <item text="One"/>
    <item text="Two"/>
    <item text="Three"/>
  </items>
</mx:Xml>

See also: