Skip to main content

Marshal Spec (spec/marshal/)

Normative: C# ↔ Lua value shapes on the stack and conversion rules. Implementation:../../impl/marshal/.

This directory

FileContents
01-OVERVIEW.mdDefault marshal matrix, integer/number, array summary, reference façade summary
02-MARSHAL-AS.md[LuaMarshalAs], LuaMarshalType, legal sets, Table/Unpacked/Params/Bytes/UserData/Opaque, XML external config
03-BYREF.mdref / in / out (C#→Lua Opaque; Lua→C#: Opaque/ByVal pass address; otherwise temp slots)
04-OPAQUE.mdOpaqueValue, get_opaquevalue / set_opaquevalue, lifetime, pass-back split
05-STRUCT.mdstruct ByVal / ByObj / Handle, box/unbox
06-CLASS.mdclass / interface / declared-type façade
07-ARRAY.mdszarray / mdarray / Bytes
08-ENUM.mdDefault integer + zlua.box
09-FUNCTION.mdDelegate ↔ Lua function
10-POINTER.mdT*, function pointers, unsupported types

Reading order

  1. 01-OVERVIEW.md — default behavior overview
  2. 02-MARSHAL-AS.md — when to override defaults; how to configure Table/Unpacked/Params
  3. By type: 05-STRUCT / 06-CLASS / 07-ARRAY / 08-ENUM / 09-FUNCTION
  4. Bidirectional byref fork: Lua→C# → 03-BYREF.md; C#→Lua → 04-OPAQUE.md

Cross-references

TopicOther specs
CSharp type tables, construction entry../02-TYPE-SYSTEM.md
Overloads and argument matching../04-METHOD-OVERLOAD.md
zlua.box / unbox / cast / get_opaquevalue / set_opaquevalue../05-LIB.md
Metatables and member indexing (not Marshal)../metatable/

Platform principles

  • Mono (Editor) and Il2Cpp (Player) share the same Lua-visible Marshal semantics; differences exist only in impl/.
  • No Event-specific support; use ordinary add_* / remove_* methods (see ../../README.md).