From 0a757ac088212b5aad972a70e050d51e7b7b0a32 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 21 Feb 2012 10:09:37 +1000 Subject: More commentry about how to make constants.lsl go away, and a little bit of code for that. --- LuaSL/src/LSL.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'LuaSL/src/LSL.lua') 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 @@ -- The compiler compiles that into a LSL_Scripts structure at startup, -- then uses that for function and variable lookups, as well as looking up in the current script. -- I can run this at compiler startup time, then iterate through the LSL table from C to generate that LSL_Script structure. +--[[ +Have an array of functions and argument types. +Compiler startup writes a short script that loads this module as normal, then calls the special "gimme the LSL" function. + The function runs through the array, calling back to C, passing each function definition. + It also runs through the constants, calling back to C, passing each constant type, name, and value. + In both cases, it could just combine them all (variables and functions together) into one big string blob to pass to the lexer+parser. +Hook up the metatable _call method to check if the function is in the array, then pass it to OpenSim. + The array includes any return type, so _call knows if it has to wait for the reply. + So the function array should have some structure, to be able to tell the function name, and the various types. +]] -- Using a module means it gets compiled each time? Maybe not if I can use bytecode files. Perhaps LuaJIT caches these? -- 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(...) print(SID, ...) -- The comma adds a tab, fancy that. B-) end +-- LSL function and constant creation stuff. + +local function newConst(Type, name, value) + LSL[name] = value + return { Type = Type, name = name } +end + +local function newFunc(Type, name, ... ) + return { Type = Type, name = name, args = ... } +end + +local functions = +{ + newFunc("key", "llAvatarOnSitTarget"), + newFunc("list", "llGetAnimationList", "key"), +} + +local constants = +{ + newConst("float", "PI", 3.14159265358979323846264338327950), +} + + -- LSL constants. LSL.PI = 3.14159265358979323846264338327950; -- cgit v1.1