Skip to main content
Version: Next

type system

Luban has a complete type system, especially bean supports type inheritance and polymorphism, so that Luban can easily express any complex data structure.

basic type

TypeDescription
boolBool type, true, false, 0, 1 can all be recognized, case insensitive, such as True, TRUE are also valid values
bytecorresponding to the byte of c# (uint8_t)
shortcorresponding to c# short (int16_t)
intcorresponding to c# int (int32_t)
longcorresponding to c#'s long (int64_t)
floatcorresponds to the float of c#
doublecorresponds to the double of c#
stringstring corresponding to c#
texttext is a syntactic sugar type, not an independent type. Equivalent to string#text=1, that is, the string type containing tag text=1. Luban will verify the validity of the localization key for this type of data
datetimeThe type is long in c#, and the value is the number of seconds since UTC 1970-01-01 00:00:00

Custom Type

See schema logical structure for detailed design of custom structures.

TypeDescription
enumEnumeration class, corresponding to enum of c#
beanComposite type, corresponding to class or struct of c#. beans support type inheritance and polymorphism

container type

TypeDescription
arrayCorresponding to the array of c#, the definition method is array,<eleType>, and eleType cannot be a nullable type
listCorresponding to the List of c#, the definition method is list,<eleType>, and eleType cannot be a nullable type
setCorresponding to the HashSet of c#, the definition method is set,<eleType>, and eleType cannot be a nullable type
mapCorresponds to the Dictionary of c#, defined as map,<keyType>,<valueType>. keyType can only be basic type or enum type, neither keyType nor valueType can be nullable

Nullable types

Both basic types and custom types support nullable types, container types do not support nullable types, and container key or value types do not support nullable types. The definition method is <type>? (such as int?, Color?, which is the same syntax as c#.

type mapping

Supports mapping custom types to external ready-made types, such as mapping MyAccessMode enumeration class to System.IO.AccessMode type; mapping MyVec3 type to UnityEngine.Vector3 type. All custom types in the generated code will be mapped to external types, which is more convenient to use.

special type table

When generating code for most languages, a class will be generated for each table to manage all the data in this table.

special type tables

When generating code for most languages, a management class for all tables will be included. The class name is defined in the targets[xxx].manager field in luban.conf and is generally named Tables.