aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-21 10:09:37 +1000
committerDavid Walter Seikel2012-02-21 10:09:37 +1000
commit0a757ac088212b5aad972a70e050d51e7b7b0a32 (patch)
tree25049a84f5077279dc67f4a20033cb354fa9a1c5 /LuaSL
parentChange over to referring to scripts by SID. (diff)
downloadSledjHamr-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')
-rw-r--r--LuaSL/src/LSL.lua33
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--[[
8Have an array of functions and argument types.
9Compiler 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.
13Hook 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-)
61end 71end
62 72
73-- LSL function and constant creation stuff.
74
75local function newConst(Type, name, value)
76 LSL[name] = value
77 return { Type = Type, name = name }
78end
79
80local function newFunc(Type, name, ... )
81 return { Type = Type, name = name, args = ... }
82end
83
84local functions =
85{
86 newFunc("key", "llAvatarOnSitTarget"),
87 newFunc("list", "llGetAnimationList", "key"),
88}
89
90local constants =
91{
92 newConst("float", "PI", 3.14159265358979323846264338327950),
93}
94
95
63-- LSL constants. 96-- LSL constants.
64 97
65LSL.PI = 3.14159265358979323846264338327950; 98LSL.PI = 3.14159265358979323846264338327950;