diff options
author | David Walter Seikel | 2012-02-21 10:09:37 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-21 10:09:37 +1000 |
commit | 0a757ac088212b5aad972a70e050d51e7b7b0a32 (patch) | |
tree | 25049a84f5077279dc67f4a20033cb354fa9a1c5 /LuaSL/src | |
parent | Change over to referring to scripts by SID. (diff) | |
download | SledjHamr-0a757ac088212b5aad972a70e050d51e7b7b0a32.zip SledjHamr-0a757ac088212b5aad972a70e050d51e7b7b0a32.tar.gz SledjHamr-0a757ac088212b5aad972a70e050d51e7b7b0a32.tar.bz2 SledjHamr-0a757ac088212b5aad972a70e050d51e7b7b0a32.tar.xz |
More commentry about how to make constants.lsl go away, and a little bit of code for that.
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LSL.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/LuaSL/src/LSL.lua b/LuaSL/src/LSL.lua index 56cd3ae..d618e65 100644 --- a/LuaSL/src/LSL.lua +++ b/LuaSL/src/LSL.lua | |||
@@ -4,6 +4,16 @@ | |||
4 | -- The compiler compiles that into a LSL_Scripts structure at startup, | 4 | -- The compiler compiles that into a LSL_Scripts structure at startup, |
5 | -- then uses that for function and variable lookups, as well as looking up in the current script. | 5 | -- then uses that for function and variable lookups, as well as looking up in the current script. |
6 | -- I can run this at compiler startup time, then iterate through the LSL table from C to generate that LSL_Script structure. | 6 | -- I can run this at compiler startup time, then iterate through the LSL table from C to generate that LSL_Script structure. |
7 | --[[ | ||
8 | Have an array of functions and argument types. | ||
9 | Compiler startup writes a short script that loads this module as normal, then calls the special "gimme the LSL" function. | ||
10 | The function runs through the array, calling back to C, passing each function definition. | ||
11 | It also runs through the constants, calling back to C, passing each constant type, name, and value. | ||
12 | In both cases, it could just combine them all (variables and functions together) into one big string blob to pass to the lexer+parser. | ||
13 | Hook up the metatable _call method to check if the function is in the array, then pass it to OpenSim. | ||
14 | The array includes any return type, so _call knows if it has to wait for the reply. | ||
15 | So the function array should have some structure, to be able to tell the function name, and the various types. | ||
16 | ]] | ||
7 | 17 | ||
8 | -- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these? | 18 | -- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these? |
9 | -- Does not seem to be slowing it down noticably, but that might change once the stubs are filled out. | 19 | -- Does not seem to be slowing it down noticably, but that might change once the stubs are filled out. |
@@ -60,6 +70,29 @@ function msg(...) | |||
60 | print(SID, ...) -- The comma adds a tab, fancy that. B-) | 70 | print(SID, ...) -- The comma adds a tab, fancy that. B-) |
61 | end | 71 | end |
62 | 72 | ||
73 | -- LSL function and constant creation stuff. | ||
74 | |||
75 | local function newConst(Type, name, value) | ||
76 | LSL[name] = value | ||
77 | return { Type = Type, name = name } | ||
78 | end | ||
79 | |||
80 | local function newFunc(Type, name, ... ) | ||
81 | return { Type = Type, name = name, args = ... } | ||
82 | end | ||
83 | |||
84 | local functions = | ||
85 | { | ||
86 | newFunc("key", "llAvatarOnSitTarget"), | ||
87 | newFunc("list", "llGetAnimationList", "key"), | ||
88 | } | ||
89 | |||
90 | local constants = | ||
91 | { | ||
92 | newConst("float", "PI", 3.14159265358979323846264338327950), | ||
93 | } | ||
94 | |||
95 | |||
63 | -- LSL constants. | 96 | -- LSL constants. |
64 | 97 | ||
65 | LSL.PI = 3.14159265358979323846264338327950; | 98 | LSL.PI = 3.14159265358979323846264338327950; |