[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: ANN: Lua OS 0.6
- From: Stefan Reich <stefan.reich.maker.of.eye@...>
- Date: Wed, 24 Aug 2011 21:02:55 +0200
Hey folks.
A new release! This is really beginning to be fun. You can now write
actual Swing-based GUI apps in (Safe) Lua.
Here goes:
http://luaos.net/luaos-0.6.php (for Windows + Ubuntu as per usual)
As an appetizer, check out this little script:
-- Show the Lua OS example scripts in a list
-- and allow user to run any of them
-- Uses a Java Swing GUI!
gui = safecomm.invoke{'gui', 'getMasterObject' }
frame = gui:showFrame('Lua OS example scripts. This is a Lua app!!')
-- Notice how we seamlessly create Java objects and call Java methods:
list = gui:newList()
vector = gui:newVector()
scripts = gui:getExampleScripts()
size = scripts:size()
for i = 0, size-1 do
vector:add(scripts:getName(i))
end
list:setListData(vector)
btnRun = gui:newButton('Run example')
-- We can even do callbacks (call Lua objects from Java):
actionListener = object()
function actionListener:run()
local idx = list:getSelectedIndex()
if idx >= 0 then
scripts:runScript(idx)
end
end
btnRun:addActionListener(gui:actionListener(actionListener))
buttons = gui:newPanel()
buttons:setLayout(gui:stalactiteLayout())
buttons:add(btnRun)
-- This is a very nice and useful little layout manager I once made
layout = gui:letterLayout('LLB')
layout:setBorder(10)
frame:setLayout(layout)
frame:add('L', gui:newScrollPane(list))
frame:add('B', buttons)
-- Stay alive while user does things
safecomm.daemon()
...and that's all already. :)
I did some timing measurements and we get about 1 ms per roundtrip -
that includes socket transfer to Java, going to the Swing thread,
transferring stuff back to Lua and tunnelling sandbox barriers. Pretty
decent I'd say and certainly quick enough for now.
A note on security: The sandboxes are probably not tight at this point
as the comm infrastructure has not been audited. But the goal now is
to get stuff to actually work - super-security will come at a later
time.
Enjoy!
Stefan