lua-users home
lua-l archive

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


Hi there,

    I am a fairly new person to lua, the version of lua i am using is
5.0(beta), since i don't have heaps of time to delve over documents etc i
thought i might post this message to the users list in the hope someone
might be able to explain a few things.

    In my current system which is an embedded project i have what i call a
managment system (written in c), along with a number of support modules.
These support modules will be available to the lua scripts. The intended use
of the lua scripts is to be able to give the software new behaviour without
having the need to compile to native code etc. Lua suit my needs perfectly,
well from what i can see.

    Anyway, one of my support modules is responsible for processing a stream
of text input, it breaks it up into fields as it comes in and so forth. When
a particular sequence of character is received an event is generated. This
event in turn causes either one or multiple scripts to execute depending on
the configuration. The problem i am facing, probably due to my infancy of
knowledge with lua is how can i make these string that the module has split
up avaible to lua.

    So far i have thought of having a global table, lets say called
'fields'. on getting a new field to add at the c source level somehow poke
it into the lua environment into that 'fields' table. When the scripts have
finished executing then simply assign nil to the 'fields' value and have the
lua strings GC'd etc. I think i can see how this is done if lua calls a c
function. But i am unsure how to do this when lua does not call a c function
from lua land.

    If anyone can provide me with information on how i can do this, this
would be greatly appreciated. Also i forgot to mention that when c code is
running lua code is not, its is a single threaded system, based on
co-operative multi-tasking. Depending on how long lua takes to execute its
scripts it may or maynot become a pre-emptive multi-threaded system, this is
yet to be determined.

    Also on another note, when lua loads a chunk presumably it stores it in
memory, when the chunk has finished loading and then execution has
subsequantly finished is the memory the chunk occupied free'd up?

Cheers,

    Andrew Stanley Teirney