lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



I've been developing a suggestion to the enum/bitwise operations issue, discussed extensively on the List lately. Seems like the best way to cut that thread?

Now, I'm in a dead end position with 2 places in the code causing headaches. Would like to pleed for help, anyone with under the hood Lua core understanding, would you please do the rest? :)

How-to:

  svn co svn://slugak.dyndns.org/public/rocks/bitwise
  cd bitwise
  make test

Mod top level Makefile if you're not running OS X (one liner).

What the patch does:

- enum.new( value_int [,family_str] ) provides a means for Lua code to create 'enums', which belong to a family. If you leave the family part out, they are "anonymous" (which in a way is just a family itself, too)

- existing operators offer bitwise manipulation to the enums, _within_ their family. See test.lua for samples. New operators can also be used, but I don't personally see that vital.

- inter-family operations are not allowed (that's the whole purpose!)

- C API has means to generate enums from C modules

typedef struct _lua_enum_tag *lua_EnumTag;
LUA_API lua_EnumTag lua_newenumtag (lua_State *L, const char *family);
LUA_API lua_EnumTag lua_enumtag (lua_State *L, int idx);
LUA_API lua_Enum lua_toenum (lua_State *L, int idx, lua_EnumTag tag); LUA_API void lua_pushenum (lua_State *L, lua_Enum v, lua_EnumTag tag); LUA_API const char *lua_enumtagname (lua_State *L, lua_EnumTag tag);


Warning: I may be moving the folder to another URL soon, since it's not a 'rock' after all. bitwise.[lua|c] files are not needed; they're leftovers of when I thought this could be done as a pure module. There's limitations, if it's done that way.

thanks,
-asko

ps. thanks to the recent 4x listing in top-smileys, I'm currently cutting my emotions back heavily. I am... ;)