Skip to content

feature(hlua): #[derive(Push, LuaRead)] for structs & enums

Alexey Protsenko requested to merge feature/struct-to-lua-table into master

requires !68 (merged) closes #34 (closed)

Structs with named fields correspond to tables (struct S { x: i32, y: f32 } <-> return { x = number, y = number })

Struct with unnamed fields:

  1. As an enum variant: is equivalent to tuples and correspond to multiple values on the stack (struct S(i32, f32) <-> return number, number;).
  2. Standalone structs with unnamed fields are not supported because they are unintuitive and aren't used very often.

Enums represent a one of the alternative values (enum E { Num: i32, Table { x: i32, f: f32 } } <-> return number; or return { x = number, y = number };)

Unit structs are not supported yet, so are enums variants without associated data. (enum E { X, Y }, struct S; <- not supported by derive macros)

Edited by Alexey Protsenko

Merge request reports