[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple Lua for scripts - Sumary
- From: Alain <alainm@...>
- Date: Thu, 25 Aug 2005 18:48:01 -0300
I made this nice summary in a wild hope that I will get some comments
from someone... This will serve as the basis of a big and long term
project so I would really be very thankfull if someone take me out of a
wrong path ;-)
Was it too perfect to need any comment (just impossible) or too stupid
and so equivalent? (just joking)
forguive me for repeating the message, but maybe it did not go to the
thanks for your collective patience
thanks to all the feedback I got from this thread. I am making here a
sumary where I will try to put it all toghether and see if it is
reasonable. I started with a question about a small aspect (2) and got
1) Link Lua static into my program. (this also helps Win/Lin portability
stability and install)
2) I can edit llex.c and make a syntaticaly simpler Lua language. I will
check if this can do what I want.
3) Remove from Lua all possibilty of loading modules and even functions
from Lua code. This will probably require altering the code to remove
"loadstring" , "loadlib" and "require" (maybe some others...)
4) Use one Lua state for each window. A window in the system is one
entity where all objects colectively execute one single task. This will
keep things independant and problems easier to track.
4) All general libs and functions will be pre-loaded by the C program.
Then a new environment is created to protect all globals with setfenv().
Then all object functions are loaded, they can only access selected
functions and variables declared as locals (last sniplet of
http://www.lua.org/pil/15.4.html) I could even have a GLOB local to
access the global environment only in debug mode.
5) All object scripts share the same environment. They comunicate with
the outside world though C functions that access the Window properties
and databases. A single return string sets the object's value if
apprepriate. (I believe this is a kind os community sandboxing)
6) In the editing window for object scripts, I test the code with
loadstring() to turn the user's code into a function (to catch any
syntax errors). A few more filtering can be done (eg: GLOB access) only
then I accept and store the code.
MISSING: all user data should be UTF8 :() how much far from Lua is
LuaPlus? do you recomend it?
TODO: limit execution time. Mark Hamburg sent some info that I could not
understand. FWIK it should be done inside the VM ... (?)