The World of Warcraft API is constructed in lua, with an accompanying XML definition, in which everything is either a basic type, function or table. Tables are flexible objects that the API uses to define rather distinct WoW-specific "complex" types.
Lua variables are not formally assigned a type, but rather dynamically become a type when a value is assigned. World of Warcraft uses seven basic types from Lua.
|Type||Description||Implicit casting||Explicit casting||Special Functions|
|absence of any value|
|true or false, historically represented as 1 or nil†||nil → false; any other value → true||
|integer or floating-point||"1" → 1; "1.23" → 1.23||tonumber(x) returns a number or nil||Math, Bitlib|
|array of UTF-8 characters||1.23 → "1.23"; true → "true"||tostring(x) returns "nil", "function: x", etc.||String|
|reference to executable code|
|reference to an association of key/value pairs||Table|
|reference to an object implemented in C‡|
Although XML has 19 primitive data types, FrameXML only uses five corresponding to Lua types:
|xs:nil||missing or empty attribute||varies by the default value of each attribute|
|xs:boolean||"true" or "false"||usually becomes boolean|
|xs:int||"1"||usually becomes number|
|xs:float||"1.23"||usually becomes number|
|xs:string||"abc"||usually becomes a string or a globally accessible reference (ie. _G["name"])|
Complex World of Warcraft API Data Types
- For the complete list of complex types, see Category:API types.
The API encodes several complex information using tables and strings. Although these objects are merely instances of the basic types, their utility comes from how the information is encoded. Wowpedia's API documentation treates these as complex types even though there is no such official term. These may be further categorized as below:
|Numeric ID||Whole number enumerating each kind of something, usually ascending from 1 as each expansion adds to the list. |
(Differs from the enumeration type which is a table with string/number pairs)
|Encoded String||Colon-delimited description of an in-game object, usually beginning with its category and ID.
|Hyperlink||H and |
|Globally Unique Identifier (GUID)||Hyphen-delimited string for every distinguishable object, possibly containing a numeric ID or encoded string in one of the fields.|
|Constant||Global variable (commonly uppercase and underscores) intended to be written in code for legibility and compatibility. |
The value is fixed (constant) during runtime but could differ between classic/retail or languages.
|Enumeration||Keys are strings and values are integers used for quick identification. This approach has increasing usage to replace constants. They can be accessed with e.g. |
|Struct||Return values as a consolidated table with several key/value pairs. This approach has increasing usage in the modern API.|
|Mixin||FrameXML tables whose members are copied into another table using CreateFromMixins(mixin) and often (not always) incorporated into XML virtual templates.
- ^ R. Ierusalimschy, L. H. de Figueiredo, W. Celes. "2.2 – Values and Types", Lua 5.1 Reference Manual. ISBN 85-903798-3-3.
- ^ XML Schema Working Group 2014-10-28. XML Schema Part 2: Datatypes Second Edition. World Wide Web Consortium.
- ^ For example, compare GetMapInfo() until Legion with C_Map.GetMapInfo after Patch 8.0.1