[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Enumerated types
- From: Waldemar Celes <celes@...>
- Date: Wed, 9 Jul 1997 09:26:19 -0400 (EDT)
> I have been looking at the Lua 3.0 manual, and I was wondering how (if
> at all) Lua handles enumerated types. I am curious about this because if
> I want to use Lua as a configuration language, I may want to use Lua to
> map a configuration file to an enumerated type in C or C++.
> Curiously, Jay Godse (email@example.com)
Lua supports "number" type.
You can export the enumerated constants to Lua and
get them back using the type "number".
C code to export constants to Lua:
C code to get values back to C:
value = (MyEnum)lua_getnumber(lo);
Then, in Lua, we can write:
var = FIRST
In fact, we are converting 'enum' to 'float', and then 'float' to 'enum',
but it should work quite well.
I hope this helps.