aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-10 16:45:22 +1000
committerDavid Walter Seikel2012-02-10 16:45:22 +1000
commit79d87a9bf9cec73add710cc9983fc7aa16a8912b (patch)
treed464f18bf473ae2d9d02a3c9138dcbf6acd9bb7d /LuaSL
parentMove sound functions to media. (diff)
downloadSledjHamr-79d87a9bf9cec73add710cc9983fc7aa16a8912b.zip
SledjHamr-79d87a9bf9cec73add710cc9983fc7aa16a8912b.tar.gz
SledjHamr-79d87a9bf9cec73add710cc9983fc7aa16a8912b.tar.bz2
SledjHamr-79d87a9bf9cec73add710cc9983fc7aa16a8912b.tar.xz
More design notes.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/README18
-rw-r--r--LuaSL/src/LuaSL_compile.c4
-rw-r--r--LuaSL/src/LuaSL_runner.c93
3 files changed, 108 insertions, 7 deletions
diff --git a/LuaSL/README b/LuaSL/README
index 7eb9ce0..cf5f9ae 100644
--- a/LuaSL/README
+++ b/LuaSL/README
@@ -19,7 +19,8 @@ The basic design will be made up as I go along, but so far I have this -
19 19
20An object is a file system directory, full of LSL scripts as text files, 20An object is a file system directory, full of LSL scripts as text files,
21notecards as text files, animations as BVH (or later BVJ) files, etc. 21notecards as text files, animations as BVH (or later BVJ) files, etc.
22There will be some sort of metadata in place. 22There will be some sort of metadata in place. This could be created by
23our own OpenSim compatible cache module.
23 24
24A parser parses an LSL script, validating it and reporting errors. 25A parser parses an LSL script, validating it and reporting errors.
25 26
@@ -34,8 +35,9 @@ The Lua source is compiled by the Lua compiler.
34 35
35LuaJIT is used as the Lua compiler, library, and runtime. 36LuaJIT is used as the Lua compiler, library, and runtime.
36 37
37Luaproc is used to start up operating system threads and hand Lua 38Luaproc is used to start up operating system threads and hand Lua states
38states between them. 39between them. Luaproc messaging is also being used, but might need to
40change to edje messaging.
39 41
40Nails is used to pump commands in and out of the LuaSL system. Incoming 42Nails is used to pump commands in and out of the LuaSL system. Incoming
41commands invoke LSL events via the LuaSL state metatable. LL and OS 43commands invoke LSL events via the LuaSL state metatable. LL and OS
@@ -45,7 +47,7 @@ to the command pump.
45Initialy, since this is the first thing being written, a nails command 47Initialy, since this is the first thing being written, a nails command
46pump client needs to be installed into OpenSim's C# stuff. Though it 48pump client needs to be installed into OpenSim's C# stuff. Though it
47might be possible to talk directly to ROBUST instead. Think I'll try 49might be possible to talk directly to ROBUST instead. Think I'll try
48the ROBUST route, see hov far I can get. That's the general principle 50the ROBUST route, see how far I can get. That's the general principle
49applying in all of this - try to avoid C# and see how for we can get. 51applying in all of this - try to avoid C# and see how for we can get.
50lol 52lol
51 53
@@ -56,6 +58,14 @@ Some form of serialization will need to be created for saving script
56state during shutdowns, passing script state to other threads / 58state during shutdowns, passing script state to other threads /
57processes / computers. 59processes / computers.
58 60
61There will have to be a MySQL (and maybe SQLite) client in the system,
62so we can talk directly to the local sim database. Esskyuehl may be
63suitable, though it's still in the prototype stage.
64
65Email, HTTP, and XML-RPC might need to be dealt with by us. A ROBUST
66client will be needed to. Azy might be suitable, but it's also in
67prototype.
68
59 69
60Test harness. 70Test harness.
61------------- 71-------------
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 29ea47c..a65b84b 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -2276,9 +2276,7 @@ boolean compileLSL(gameGlobals *game, char *script, boolean doConstants)
2276 fprintf(out, "--// Generated code goes here.\n\n"); 2276 fprintf(out, "--// Generated code goes here.\n\n");
2277 fprintf(out, "local _bit = require(\"bit\")\n"); 2277 fprintf(out, "local _bit = require(\"bit\")\n");
2278 fprintf(out, "local _LSL = require(\"LSL\")\n\n"); 2278 fprintf(out, "local _LSL = require(\"LSL\")\n\n");
2279 // TODO - Use the scripts UUID instead of the file name here. 2279 // TODO - Use the scripts UUID instead of the file name here, or something.
2280 // Hmm, copies of the same script in the same prim would have the same UUID, but different name, though they would run independently.
2281 // Copies of the same script in different prims could have the same UUID AND the same name.
2282 fprintf(out, "local _SID = [=[%s.lua.out]=]\n\n", compiler.fileName); 2280 fprintf(out, "local _SID = [=[%s.lua.out]=]\n\n", compiler.fileName);
2283 outputLeaf(out, OM_LUA, compiler.ast); 2281 outputLeaf(out, OM_LUA, compiler.ast);
2284 fprintf(out, "\n\n_LSL.mainLoop(_SID, _defaultState)\n"); // This actually starts the script running. 2282 fprintf(out, "\n\n_LSL.mainLoop(_SID, _defaultState)\n"); // This actually starts the script running.
diff --git a/LuaSL/src/LuaSL_runner.c b/LuaSL/src/LuaSL_runner.c
index a59855d..5bb5e7a 100644
--- a/LuaSL/src/LuaSL_runner.c
+++ b/LuaSL/src/LuaSL_runner.c
@@ -159,3 +159,96 @@ void runnerTearDown(gameGlobals *game)
159// TODO - this is what hangs the system. 159// TODO - this is what hangs the system.
160 sched_join_workerthreads(); 160 sched_join_workerthreads();
161} 161}
162
163
164/* What we need to do, and how we might do it.
165 *
166 * Get configuration info.
167 *
168 * Some of the configuration info we need is tucked away in OpenSim .ini files. So we have to read that.
169 * Eet is probably not so useful here, as we would have to write a UI tool, and there's no UI otherwise.
170 *
171 * Multi task!
172 *
173 * Luaproc starts up X worker threads. Each one takes the next ready Lua state and runs it until it blocks waiting for a channel message, or yields.
174 * The current mainloop waits for events and commands from the message channel, executes them, then goes back to waiting.
175 * So that is fine in general, so long as the LSL event handlers actually return in a reasonable time.
176 * We need to be able to yield at suitable places, or be able to force a yield. Both without slowing things down too much.
177 *
178 * Watchdog thread.
179 *
180 * It's easy enough to have a watchdog thread wake up every now and then to check if any given Lua state has been hogging it's CPU for too long.
181 * The hard part is forcing Lua states to yield cleanly, without slowing performance too much.
182 *
183 * Identifying scripts.
184 *
185 * We need to be able to identify scripts so that messages can get to the right ones. Also the objects they are in.
186 * And do it all in a way that OpenSim is happy with.
187 * Copies of the same script in the same prim would have the same UUID, but different name, though they would run independently.
188 * Copies of the same script in different prims could have the same UUID AND the same name.
189 *
190 * Script start, stop, reset.
191 *
192 * Scripts and users have to be able to start, stop, and reset scripts.
193 * Users have to be able to see the start / stopped status of scripts from the viewer.
194 * Which means if the script does it, we have to tell OpenSim.
195 * Naturally, if OpenSim does it, it has to tell us.
196 * Should be able to do both by passing textual Lua function calls between OpenSim and LuaSL.
197 *
198 * Event handling, llDetect*() functions.
199 *
200 * OpenSim will generate events at random times and send us relevant information for llDetect*() functions and the handler calls.
201 * These should come through the scripts main loop eventually.
202 *
203 * Send messages from / to OpenSim and ROBUST.
204 *
205 * ROBUST uses HTTP for the communications, and some sort of XML, probably XML-RPC.
206 * OpenSim has some sort of generic mechanism for talking to script engines in C#. I want to turn that into a socket based, pass textual Lua function calls, type system.
207 * That assumes C# has some sort of semi decent introspection or reflection system.
208 * The scripts main loop can already deal with incoming commands as a string with a Lua function call in it.
209 *
210 * Send messages from / to Lua or C, and wait or not wait.
211 *
212 * Luaproc channels are distinct from Lua states, but some Lua state has to create them before they can be used.
213 * On the other hand, looks like broadcasting messages is not really catered for, it's first come first served.
214 * luaproc.send() can send multiple messages to a single channel. It blocks if no one is listening.
215 * This was done to simplify things for the luaproc programmers, who suggest creating more Lua states to deal with asynchronous message sending.
216 * luaprog.receive() gets a channel message. It can block waiting, or not block.
217 * I already hacked up C code to send and not block. I might have broken the luaproc.send() ability to send multiple messages.
218 * Before I hacked it up, actual message sending was done by copying the contents of the sending Lua states stack to the receiver states stack.
219 * This is the simple method for the luaproc programmers, as both states are in the context of a luaproc call, so both stacks are available.
220 * My hacked up version either takes one message from the sender, or is passed one from C. The C call just returns if there is no one waiting on that channel.
221 * luaproc.send() cals that C function after taking a single message from the stack, and block waits as usual if the C call cannot deliver.
222 * Don't think there is C to receive messages, luaproc seems to be lacking entirely in C side API.
223 * Edje messages might have to be used instead, or some hybrid.
224 *
225 * Time and timers, plus deal with time dilation.
226 *
227 * Various LSL functions deal with time, that's no problem.
228 * Some might deal with time dilation, which means dealing with that info through OpenSim.
229 * There is a timer event, which should be done through ecore timers and whatever message system we end up with.
230 * Finally, a sleep call, which can be done with ecore timer and messages to.
231 *
232 * Deal directly with MySQL and SQLite databases.
233 *
234 * The script engine can run on the same computer as the sim server, that's how OpenSim does stuff. So we can directly access the database the sim server has, which gives us access to sim object metadata.
235 * Changing that metadata might require us to inform OpenSim about the changes. It's entirely possible that different changes do or do not need that.
236 * Esskyuehl may be suitable, though it's still in the prototype stage.
237 *
238 * Serialise the script state, send it somewhere.
239 *
240 * Lua can generally serialise itself as as a string of code to be executed at the destination. There might be some C side state that needs to be take care of as well. We shall see.
241 *
242 * Email, HTTP, XML-RPC?
243 *
244 * LSL has functions for using these as communications methods. We should implement them ourselves eventually, but use the existing OpenSim methods for now.
245 * Note that doing it ourselves may cause issues with OpenSim doing it for some other script engine.
246 * Azy might be suitable, but it's also in prototype.
247 *
248 * Object inventory "cache".
249 *
250 * This code currently pretends that there is a local file based sim object store available.
251 * I think it would be a good idea to abuse the OpenSim cache system to produce that file based object store.
252 * It will help with the "damn OpenSim's asset database has to be a bottomless pit" monster design flaw.
253 *
254*/