@@ -102,12 +102,13 @@ def gen_enum_decl(self, decl):
102
102
self .cur_block = LuaBlock ()
103
103
for i , f in enumerate (decl .fields ):
104
104
self .cur_block .add_stmt (
105
- LuaAssignment ([LuaSelector (LuaIdent (decl .name ), f .name )],
106
- [LuaNumberLit (str (i ))], False )
105
+ LuaAssignment ([LuaIdent (f .name )], [LuaNumberLit (str (i ))])
107
106
)
108
107
self .switch_cur_sym (decl .sym )
109
108
self .gen_decls (decl .decls )
110
- self .export_public_symbols (decl .sym )
109
+ self .export_public_symbols (
110
+ decl .sym , custom_fields = [f .name for f in decl .fields ]
111
+ )
111
112
self .switch_cur_sym ()
112
113
old_block .add_stmt (self .cur_block )
113
114
self .cur_block = old_block
@@ -260,13 +261,22 @@ def gen_expr(self, expr):
260
261
self .cur_block .add_stmt (LuaReturn (ret_expr ))
261
262
return LuaSkip ()
262
263
263
- def export_public_symbols (self , decl_sym , return_table = False ):
264
+ def export_public_symbols (
265
+ self , decl_sym , return_table = False , custom_fields = []
266
+ ):
264
267
exported_fields = []
268
+
269
+ for custom_field in custom_fields :
270
+ exported_fields .append (
271
+ LuaTableField (LuaIdent (custom_field ), LuaIdent (custom_field ))
272
+ )
273
+
265
274
for sym in decl_sym .scope .syms :
266
275
if sym .access_modifier .is_public ():
267
276
exported_fields .append (
268
277
LuaTableField (LuaIdent (sym .name ), LuaIdent (sym .name ))
269
278
)
279
+
270
280
if return_table :
271
281
self .cur_block .add_stmt (LuaReturn (LuaTable (exported_fields )))
272
282
else :
0 commit comments