Skip to content

Commit 51d59d0

Browse files
authored
Merge pull request #4977 from myk002/myk_unionize
[Lua] add _union=true field to union types
2 parents 20389f3 + 94354ab commit 51d59d0

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

docs/dev/Lua API.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ All types and the global object have the following features:
315315

316316
All compound types (structs, classes, unions, and the global object) support:
317317

318+
* ``type._union``
319+
320+
``true`` if the type represents a union, otherwise ``nil``.
321+
318322
* ``type._fields``
319323

320324
Contains a table mapping field names to descriptions of the type's fields,

library/LuaWrapper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,11 @@ static void RenderType(lua_State *state, const compound_identity *node)
16381638

16391639
switch (node->type())
16401640
{
1641-
case IDTYPE_STRUCT:
16421641
case IDTYPE_UNION: // TODO: change this to union-type? what relies on this?
1642+
lua_pushboolean(state, true);
1643+
lua_setfield(state, ftable, "_union");
1644+
// fall through
1645+
case IDTYPE_STRUCT:
16431646
lua_pushstring(state, "struct-type");
16441647
lua_setfield(state, ftable, "_kind");
16451648
IndexStatics(state, ix_meta, ftable, (struct_identity*)node);

0 commit comments

Comments
 (0)