Sun, 23 May 2010 02:29:04 +0100
New LValueFromValue() to convert from any Javascript value (almost) to a LValue
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Sat May 22 20:14:33 2010 +0100 +++ b/lvm.js Sun May 23 02:29:04 2010 +0100 @@ -60,6 +60,25 @@ return new LValue("function", func); } +function LValueFromValue(value) +{ + switch(typeof(value)) + { + case "string": + return new LValueFromString(value); + case "function": + return new LValueFromFunction(value); + case "object": + if(value == null) + return new LValue("nil", value); + default: + sys.puts( "Not able to convert type " + + typeof(value)+" from Javascript to Lua: "+sys.inspect(value)); + throw "Not able to convert type " + + typeof(value)+" from Javascript to Lua"; + } +} + function LBinaryChunk(chunk, start) { this.chunk = chunk;