No response received the first time.
Can't anybody help?
TIA
Mike
Hi folks,
You have been a great help in the past, so I wonder if I can bounce
something off of you.
I'm working on an embedded Lua library for LuaNIOS, a project I'm
starting to kick off.
I have 2 problems:
1) I'm trying to get bit operations working in Lua.  I stole the 
library
from http://rrt.sc3d.org/Lua.
2) I think an error is getting generated, but my error routine is not
getting called.
My bit library is crashing, and I'm not familiar enough with the issues
of adding a C library to Lua yet.
Don't spend much time, please.
Compiling for 5.1w5, and here's the line I'm testing with.
--
-- Test Lua
--
print("Hello from Lua!")
LED_MATRIX_WIDTH = 21
LED_MATRIX_HEIGHT = 8
LED_ON      = 0
LED_OFF     = 1
adders = { 512,1024,2048,4096,8192,16384,32768,65536 }
levels = { 0,1,3,7,15,31,63,127 }
current = 1
data = {}
for i=1,LED_MATRIX_WIDTH do
   data[i] = LED_OFF
end
math.randomseed(5599)
*build = bit.bor(adders[current],data[i])*
print(build)
print("Goodby from Lua!")
--
If I comment out the build=bit.bor line, program runs fine.
Note:  This code doesn't do anything, but is a subset of a test program
I'm writing for LuaNIOS.
I'm initializing the library with:
   (functions omitted)
   static const struct luaL_reg bitlib[] = {
     {"bnot",    bit_bnot},
     {"band",    bit_band},
     {"bor",     bit_bor},
     {"bxor",    bit_bxor},
     {"lshift",  bit_lshift},
     {"rshift",  bit_rshift},
     {"arshift", bit_arshift},
     {"mod",     bit_mod},
     {NULL, NULL}
   };
   LUALIB_API int luaopen_bit (lua_State *L) {
     luaL_openlib(L, "bit", bitlib, 0);
     return 1;
   }
I'm initializing the library in my main routine with:
       lua_State *L=lua_open();
     luaopen_base(L);
     luaopen_string(L);           // opens the string lib.
     luaopen_table(L);
     luaopen_math(L);
     luaopen_io(L);
     luaopen_avalon_pio(L);
     luaopen_bit(L);
     luapush_globals(L);
     if ( lua_loadmylua(L) || lua_pcall(L,0,0,0))
         fprintf(stderr,"%s\n",lua_tostring(L,-1));
I can files if needed.