[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C++ enum
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 23 Jun 2003 13:26:04 -0300
Archibald wrote:
>I want to share my identificators by both program and script. It's easy
>when I use #define (I simply delete #define part and copy the rest to the
>script). But how can I do it when I use C++ enum? Is it possible in lua to
>do it other way than manually giving each identificator it's number?
>
>enum enumItem { ITEM_SWORD, ITEM_AXE, ITEM_SHIELD };
Lua traditionally uses strings instead of numbers for enums (after all, enums
and defines were introduced to improve readabiliy too). To map strings to
numbers, use luaL_findstring. See the POSIX library lposix for examples of
this technique. See also f_seek in src/lib/liolib.c.
--lhf