lua-users home
lua-l archive

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


Tony Finch <dot@dotat.at> wrote:
> Is there a standard extension for Lua bytecode files? I've been using .luo
> (short for Lua object code).

I don't think there's a standard. FWIW, I use .lbc but .luo sounds
nicer.

> I'm writing a program that embeds Lua and which will have significant
> parts written in Lua. In order to make it easier to deploy I'm embedding
> the bytecodes in the executable, which I am doing by a .lua -> .luo -> .c
> translation. The C file just declares an array and initializes it with
> the contents of the Lua bytecodes so it can be passed to luaL_loadbuffer.
> I guess lots of people do something like this?

This works very well. I have a 'shell' along the lines of lua.c which
loads three or four byte-code libraries either from internal byte arrays
or from external .lbc files.

Just watch out for strlen() and friends ... there's a function in lua.c
that calls this before loading the buffer. That's fine if the string is
text but if it's precompiled byte code strlen() just won't cut the
mustard.

-- 
cheers  thomasl

web : http://thomaslauer.com/start