public void Setup() { lua = new Lua(); luaEnv = lua.CreateEnvironment(); options = new LuaCompileOptions(); options.DebugEngine = new LuaStackTraceDebugger(); }
private void menuitem_testlua_Click(object sender, EventArgs e) { FileInfo fi = new FileInfo(this.nowFile); string fn = fi.Name; if (!fn.ToUpper().EndsWith(".LUA")) { return; } string cCode = fn.Substring(0, fn.Length - 4); bool error = false; try { Directory.SetCurrentDirectory(fi.DirectoryName); Lua lua = new Lua(); var env = lua.CreateEnvironment(); string pre = "Duel={} Effect={} Card={} aux={} Auxiliary={} " + cCode + "={} Duel.LoadScript=function(str) end "; env.DoChunk(pre + this.fctb.Text, "test.lua"); } catch (LuaException ex) { MessageBox.Show($"LINE{ex.Line} - {ex.Message}"); error = true; } if (!error) { MyMsg.Show(LMSG.syntaxCheckPassed); } }
public LazynetLua() { using (Lua l = new Lua()) { this.G = l.CreateEnvironment(); } }
public void EnvDynamicCall01() { using (Lua l = new Lua()) { l.PrintExpressionTree = true; dynamic g = l.CreateEnvironment(); g.dochunk(GetLines("Lua.EnvDynamicCall01.lua"), "test.lua"); TestResult(new LuaResult(g.test(2)), 4); TestResult(((LuaTable)g).CallMember("test", 2), 4); // test of c# binders Debug.Print("C# Binders:"); TestResult(g.b.a(5), 20); TestResult(g.b.b(5), 115); TestResult(g.b.c(g.b, 5), 110); TestResult(g.test(5), 10); // test of lua binders Debug.Print("Lua Binders:"); TestResult(g.dochunk("return b.a(5)", "test.lua"), 20); TestResult(g.dochunk("return b:b(5)", "test.lua"), 115); TestResult(g.dochunk("return b.b(b, 5)", "test.lua"), 115); TestResult(g.dochunk("return b:c(5)", "test.lua"), 110); TestResult(g.dochunk("return b.c(b, 5)", "test.lua"), 110); TestResult(g.dochunk("return test(5)", "test.lua"), 10); } } // prop EnvDynamicCall01
public void MainThread(ResourceManager resources, InstanceHelper instanceHelper) { resourceManager = resources; config = resources.GetConfig(Name); if (EnsureConfigCorrect() == false) { resourceManager.SaveConfig(Name); resourceManager.SaveConfig("ArkDesktop.LayeredWindowManager"); return; } ; manager = new LayeredWindowManager(resources); instanceHelper.AddControl("", manager); if (loadPosition == LoadPosition.InConfig) { if (config.Element("Script") == null) { MessageBox.Show("似乎没有加载到脚本,请联系配置包制作者"); return; } luaScript = config.Element("Script").Value; } else { using (var sr = new System.IO.StreamReader(resourceManager.OpenRead("script.lua"))) luaScript = sr.ReadToEnd(); if (luaScript == "") { MessageBox.Show("似乎没有加载到脚本,请联系配置包制作者", "QAQ"); return; } } using (Lua lua = new Lua()) { dynamic env = lua.CreateEnvironment(); LuaApi api = new LuaApi(this, lua, env); var chunk = lua.CompileChunk(luaScript, "script.lua", new LuaCompileOptions { DebugEngine = LuaStackTraceDebugger.Default }); manager.window.Click += (sender, e) => api.OnClick(); var luaThread = new Thread(new ThreadStart(() => { if (launchType == LaunchType.Positive) { while (true) { try { env.dochunk(chunk); } catch (ThreadAbortException) { break; } } catch (Exception e) { MessageBox.Show("发生异常:" + e.Message + "\n" + e.StackTrace); } }
public IrcScriptEngine() { Engine = new Lua ( integerType: LuaIntegerType.Int32, floatType: LuaFloatType.Float ); LuaEnvironment = Engine.CreateEnvironment<LuaGlobal> (); }
public void TestParserIssue55() { using (var l = new Lua()) { var g = l.CreateEnvironment(); var r = g.DoChunk("repeat break if true then end until true return 23", "TestParserIssue55"); Assert.AreEqual(23, r[0]); } }
private T CreateWpfType <T>(string snippet) where T : class { using (var lua = new Lua()) { var g = lua.CreateEnvironment(); return((T)g.DoChunk(snippet, "wpf.lua", new KeyValuePair <string, object>("UI", new LuaUI()))[0]); } } // func CreateWpfType
public void TestFunctions58() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); TestResult(g.dochunk("return p:ParamOut(1, 2);", "dummy", "p", new TestParam()), 1, 1, 2); } }
public void TestFunctions59() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); TestResult(g.dochunk("local b = p:GetValue(); return b;", "dummy", "p", new TestParam()), 4); } }
static void Main(string[] args) { //Minitouch.connect("localhost", 1111); //Minitouch.setPos(1, 100, 100); //Minitouch.press(1); using var lua = new Lua(); var env = lua.CreateEnvironment(); env.RegisterPackage("autopcr", typeof(Autopcr)); env.RegisterPackage("minitouch", typeof(Minitouch)); var chunk = lua.CompileChunk(File.ReadAllText("timeline.lua"), "timeline.lua", new LuaCompileOptions()); Console.Write("pid>"); var pid = int.Parse(Console.ReadLine()); //var pid = 11892; hwnd = NativeFunctions.OpenProcess(NativeFunctions.PROCESS_ALL_ACCESS, false, pid); var tuple = AobscanHelper.Aobscan(hwnd, idcode, addr => { var frame = TryGetInfo(hwnd, addr); if (frame.Item1 >= 0 && frame.Item1 < 1000 && frame.Item2 > 80 && frame.Item2 < 100) { Console.WriteLine($"data found, frameCount = {frame.Item1}, limitTime = {frame.Item2}"); return(true); } return(false); }); addr = tuple.Item1; Console.WriteLine($"addr = {addr:x}"); Console.WriteLine(); if (addr == -1) { Console.WriteLine("aobscan failed."); return; } seed_addr = AobscanHelper.Aobscan(hwnd, seed_code, addr => { Console.WriteLine($"seed found."); return(true); }).Item1 - 0x90; chunk.Run(env); Console.WriteLine("script finished."); Minitouch.exit(); Console.ReadLine(); }
public void TestGlobalProperty01() { using (Lua l = new Lua()) { var g = l.CreateEnvironment <LuaGlobalNew>(); g.DoChunk("BoolProperty = true", "test1.lua"); TestResult(g.DoChunk("return BoolProperty", "test2.lua"), true); } }
/// <summary> /// 初始化Lua运行环境 /// </summary> public void InitLuaEnv() { gEnv = lua.CreateEnvironment(); // 每100秒对其中一个字典进行检测 timerCheckDict = new Timer(100 * 1000); timerCheckDict.Elapsed += new ElapsedEventHandler(CheckDictLuaInfo); timerCheckDict.Interval = 100 * 1000; timerCheckDict.Enabled = true; }
public void TestGlobalProperty01() { using (Lua l = new Lua()) { var g = l.CreateEnvironment<LuaGlobalNew>(); g.DoChunk("BoolProperty = true", "test1.lua"); TestResult(g.DoChunk("return BoolProperty", "test2.lua"), true); } }
public void AbstractCall01() { var c = new TestImpl(); using (var l = new Lua()) { var g = l.CreateEnvironment(); TestResult(g.DoChunk("return cast(LuaDLR.Test.LuaTypeTests.ITestIntf, a):Foo()", "test.lua", new KeyValuePair <string, object>("a", c)), 42); } }
public void TestRuntimeLua14() { using (var l = new Lua()) { var g = l.CreateEnvironment(); l.PrintExpressionTree = Console.Out; g.RegisterPackage("debug", typeof(System.Diagnostics.Debug)); g.DoChunk("debug:Print('Hallo World!');", "test.lua"); } } // proc TestRuntimeLua13
public LuaEngine() { this._script = ""; _lua = new Lua(); _luaEnvironment = _lua.CreateEnvironment(); this.AddVariable("TCAdminFolder", Path.GetFullPath(Path.Combine(Path.Combine(Utility.GetSharedPath(), ".."), ".."))); this.AddVariable("Script", this); }
public void CodePlexExample0() { using (Lua l = new Lua()) // create the lua script engine { dynamic g = l.CreateEnvironment(); // create a environment g.dochunk("a = 'Hallo World!';", "test.lua"); // create a variable in lua Console.WriteLine(g.a); // access a variable in c# g.dochunk("function add(b) return b + 3; end;", "test.lua"); // create a function in lua Console.WriteLine("Add(3) = {0}", g.add(3)); // call the function in c# } }
public void CodePlexExample8c() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); g.c = new ClrClass(); Console.WriteLine((int)g.dochunk("return c + 2;")); } }
public void Setup() { IOC.Reset(); lua = new Lua(); luaEnv = lua.CreateEnvironment(); apiBridge = Mock.Interface <IApiBridge>(); IOC.Register <IApiBridge>(() => apiBridge); IOC.Register <ApiAdapter>(() => new ApiAdapter()); api = IOC.Resolve <ApiAdapter>(); api.LuaEnv = luaEnv; }
public void TestFunctions10() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); var p = new TestParam(); g.DoChunk("p.Test = 3;", "dummy", new KeyValuePair <string, object>("p", p)); Assert.AreEqual(3, p.Test); } }
public void TestFunctions61() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); TestResult(g.dochunk("function test(a) if a ~= nil then return a; end; end;", "test.lua")); TestResult(g.test()); TestResult(g.test(1), 1); } }
private static void MasterTest() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); g.dofile(@"d:\temp\a\m.lua"); LuaTable t = (LuaTable)g.array; Console.WriteLine("{0}", t[1]); } }
public static void Example() { using (var l = new Lua()) { dynamic g = l.CreateEnvironment(); g.t = new LuaTable(); ((LuaTable)g.t).DefineFunction("getStruct", new Func <MyStruct>(getStruct)); g.dochunk("local o = t.getStruct(); " + Environment.NewLine + "" + "print(o.Bla); print(o.Awesome); ", "test.lua"); } }
public void CodePlexExample2a() { using (Lua l = new Lua()) { dynamic dg = l.CreateEnvironment(); dg.t = new LuaTable(); dg.t.a = 2; dg.t.b = 4; dg.dochunk("t.c = t.a + t.b", "test.lua"); Console.WriteLine(dg.t.c); } }
public void CodePlexExample2b() { using (Lua l = new Lua()) { dynamic dg = l.CreateEnvironment(); dg.t = new LuaTable(); dg.t[0] = 2; dg.t[1] = 4; dg.dochunk("t[2] = t[0] + t[1]", "test.lua"); Console.WriteLine(dg.t[2]); } }
public void TestConvert01() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); var r = g.DoChunk("return cast(System.Diagnostics.ProcessStartInfo, { FileName = 'Test.exe', Arguments = 'aaa' });", "dummy"); ProcessStartInfo psi = (ProcessStartInfo)r[0]; Assert.IsTrue(psi.FileName == "Test.exe"); Assert.IsTrue(psi.Arguments == "aaa"); } } // func TestConvert01
public void TestConst01() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); TestResult(g.DoChunk("const a = 20; return a;", "dummy"), 20); TestResult(g.DoChunk("const a = cast(ushort, 20); return a;", "dummy"), (ushort)20); TestResult(g.DoChunk("const a = cast(int, '20'); return a;", "dummy"), 20); } }
public void TestArithmetic05() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); var c = l.CompileChunk("return 1 + a;", "test.lua", null, new KeyValuePair <string, Type>("a", typeof(string))); TestResult(g.DoChunk(c, "2"), 3); TestResult(g.DoChunk(c, "2.0"), 3.0); } }
public void TestIndex04() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); TestResult( g.DoChunk("test[1] = 42; return test[0], test[1], test[2];", "dummy", new KeyValuePair <string, object>("test", new int[] { 1, 2, 3 }) ), 1, 42, 3); } }
public void TestIndex03() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); TestResult( g.DoChunk("return test[0], test[1];", "dummy", new KeyValuePair <string, object>("test", new IndexAccess()) ), 0, 1); } }
public void TestFunctions62() { using (var l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); var c = l.CompileChunk("print(a)", "dummy", null, new KeyValuePair <string, Type>("a", typeof(object))); g.dochunk(c, 1); g.dochunk(c, "a"); } }
public void CodePlexExample2() { using (Lua l = new Lua()) { var g = l.CreateEnvironment(); dynamic dg = g; dg.a = 2; // dynamic way to set a variable g["b"] = 4; // second way to access variable dg.dochunk("c = a + b", "test.lua"); Console.WriteLine(dg.c); Console.WriteLine(g["c"]); } }
public void Exception01() { using (Lua l = new Lua()) { var g = l.CreateEnvironment(); try { g.DoChunk(l.CompileChunk("\nNull(a, a);", "test.lua", LuaDeskop.StackTraceCompileOptions, new KeyValuePair<string, Type>("a", typeof(int))), 1); } catch (Exception e) { LuaExceptionData d = LuaExceptionData.GetData(e); Assert.IsTrue(d[2].LineNumber == 2); } } } // proc Exception01
} // func GetLines public void TestCode(string sCode, params object[] expectedResult) { using (Lua l = new Lua()) { l.PrintExpressionTree = PrintExpressionTree ? Console.Out : null; var g = l.CreateEnvironment<LuaGlobal>(); Console.WriteLine("Test: {0}", sCode); Console.WriteLine(new string('=', 66)); Stopwatch sw = new Stopwatch(); sw.Start(); TestResult(g.DoChunk(sCode, "test.lua"), expectedResult); Console.WriteLine(" Dauer: {0}ms", sw.ElapsedMilliseconds); Console.WriteLine(); Console.WriteLine(); } } // proc TestCode
public void CodePlexExample1() { using (Lua l = new Lua()) { var g = l.CreateEnvironment(); dynamic dg = g; LuaResult r = g.DoChunk("return a + b", "test.lua", new KeyValuePair<string, object>("a", 2), new KeyValuePair<string, object>("b", 4)); Console.WriteLine(r[0]); dynamic dr = dg.dochunk("return a + b", "test.lua", "a", 2, "b", 4); Console.WriteLine((int)dr); } }
public ArchiveCache(string unitsyncWritableFolder) { Archives = new List<ResourceInfo>(); var fi = GetCacheFile(unitsyncWritableFolder); if (fi != null) { var lua = new Lua(); var luaEnv = lua.CreateEnvironment(); using (var file = fi.OpenText()) { dynamic result = luaEnv.DoChunk(file, "dummy.lua"); foreach (var archive in result.archives) { var v = archive.Value; if (v.archivedata != null) { var newEntry = new ResourceInfo() { ArchiveName = v.name, ArchivePath = v.path, Name = v.archivedata.name, Author = v.archivedata.author, Description = v.archivedata.description, Mutator = v.mutator, ShortGame = v.shortgame, Game = v.game, ShortName = v.shortname, PrimaryModVersion = v.version, }; if (v.archivedata.modtype != null) newEntry.ModType = v.archivedata.modtype; if (v.checksum != null) { uint temp; if (uint.TryParse(v.checksum, out temp)) newEntry.CheckSum = temp; } if (v.archivedata.depend != null) foreach (var dep in v.archivedata.depend) newEntry.Dependencies.Add(dep.Value); Archives.Add(newEntry); } } } } }
public void Exception02() { using (Lua l = new Lua()) { var g = l.CreateEnvironment(); try { g.DoChunk(l.CompileChunk("math.abs(-1 / a).A();", "test.lua", LuaDeskop.StackTraceCompileOptions, new KeyValuePair<string, Type>("a", typeof(int))), 1); } catch (Exception e) { LuaExceptionData d = LuaExceptionData.GetData(e); Debug.Print("Error: {0}", e.Message); Debug.Print("Error at:\n{0}", d.StackTrace); Assert.IsTrue(d[2].LineNumber == 1); // && d[2].ColumnNumber == 18 in release this is one } } } // proc Exception01
public void RunTest() { using (Lua l = new Lua()) { var g = l.CreateEnvironment<LuaGlobal>(); dynamic dg = g; dg.math.randomseed(0); dg.assert = new Func<object, string, object>(TestAssert); DoScript(l, g, "calls.lua"); DoScript(l, g, "strings.lua"); //DoScript(l, g, "literals.lua"); DoScript(l, g, "math.lua"); DoScript(l, g, "bitwise.lua"); } }
public void TestDateTime01() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment<LuaGlobal>(); g.dochunk("print(os.date('Today is %A, in %B'))"); TestResult(g.dochunk("return os.date('%x', 906000490)"), new DateTime(1998, 09, 17).ToString("d")); TestResult(g.dochunk("return os.date('%d.%m.%Y')"), DateTime.Today.ToString("d")); g.dochunk("t = os.date('*t');"); DateTime dt = DateTime.Now; TestResult(g.dochunk("return t.year"), dt.Year); TestResult(g.dochunk("return t.month"), dt.Month); TestResult(g.dochunk("return t.day"), dt.Day); TestResult(g.dochunk("return t.hour"), dt.Hour); TestResult(g.dochunk("return t.min"), dt.Minute); TestResult(g.dochunk("return t.sec"), dt.Second); TestResult(g.dochunk("return t.wday"), (int)dt.DayOfWeek); TestResult(g.dochunk("return t.yday"), dt.DayOfYear); TestResult(g.dochunk("return t.isdst"), true); g.dochunk("t = os.date('!*t');"); dt = DateTime.UtcNow; TestResult(g.dochunk("return t.year"), dt.Year); TestResult(g.dochunk("return t.month"), dt.Month); TestResult(g.dochunk("return t.day"), dt.Day); TestResult(g.dochunk("return t.hour"), dt.Hour); TestResult(g.dochunk("return t.min"), dt.Minute); TestResult(g.dochunk("return t.sec"), dt.Second); TestResult(g.dochunk("return t.wday"), (int)dt.DayOfWeek); TestResult(g.dochunk("return t.yday"), dt.DayOfYear); TestResult(g.dochunk("return t.isdst"), false); TestResult(g.dochunk("return os.date()"), DateTime.Now.ToString("G")); g.dochunk("t={};t.year = 2001; print(os.time(t))"); } }
public LuaInstance() { lua = new Lua(); packages = new HashSet<string>(); try { global = lua.CreateEnvironment(); global["package.path"] = LuaConfig.PackagePath; LuaAerospike.LoadLibrary(this); LuaStream.LoadLibrary(this); Assembly assembly = Assembly.GetExecutingAssembly(); LoadSystemPackage(assembly, "aslib"); LoadSystemPackage(assembly, "stream_ops"); LoadSystemPackage(assembly, "aerospike"); } catch (Exception) { lua.Dispose(); throw; } }
public void MethodTest05() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); dynamic r = g.dochunk(Lines( new string[] { "local c = clr.LuaDLR.Test.LuaTypeTests.SubClass()", "c.Test('Test');", "return c.Test;" })); foreach (var c in r[0]) Console.WriteLine(c.GetType().Name); } }
public void MethodTest02() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); g.console = LuaType.GetType(typeof(Console)); g.dochunk("console.WriteLine('Hallo!');", "test"); dynamic wl = g.console.WriteLine; Delegate dlg1 = wl[LuaType.GetType(typeof(string))]; Delegate dlg2 = g.dochunk("return console.WriteLine[clr.System.String]"); Delegate dlg3 = g.dochunk("return console.WriteLine[]"); Assert.IsTrue(dlg1 == dlg2); Assert.IsTrue(dlg3 != null); } }
public void TestFunctions62() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); var c = l.CompileChunk("print(a)", "dummy", null, new KeyValuePair<string, Type>("a", typeof(object))); g.dochunk(c, 1); g.dochunk(c, "a"); } }
public void TestFunctions60() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); g.dochunk(Lines( "function add(a : int, b : int) : int", " return a + b;", "end;"), "add.lua"); Func<int, int, int> a = g.add; Assert.IsTrue(a(1, 3) == 4); Assert.IsTrue(g.add(1, 2) == 3); } }
public void TypeTest03() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); g.dochunk("return cast(System.IO.Stream, null);"); g.dochunk("return cast(LuaDLR.Test.LuaTypeTests.SubClass, null);"); g.dochunk("return cast(System.Collections.Generic.List[string[]], null);"); g.dochunk("return cast(System.String[], null);"); g.dochunk("return cast(string[], null);"); } }
public void MethodTest01() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); g.console = LuaType.GetType(typeof(Console)); g.dochunk("console.WriteLine('Hallo!');", "test"); dynamic wl = g.console.WriteLine; Assert.IsTrue(wl.GetType() == typeof(LuaOverloadedMethod)); int iCount = wl.Count; Assert.IsTrue(iCount == 19); for (int i = 0; i < wl.Count; i++) { if (i == 17) Console.WriteLine("VarArgs NotImplemented."); else Console.WriteLine("{0}: {1}", i, wl[i].GetType().Name); } } }
public void EventTest05() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); var c = l.CompileChunk(Lines( "local a : System.EventHandler = function(a, b) : void", " print('Hallo');", "end;", "a();"), "dummy", null); g.DoChunk(c); } }
public void MethodTest04() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); dynamic m = g.DoChunk("return clr.LuaDLR.Test.LuaTypeTests.Test", "dummy"); MethodInfo mi = m; Action action = m; Delegate dlg = m; m(); Assert.IsTrue(mi != null); Assert.IsTrue(action != null); Assert.IsTrue(dlg != null); } }
public void TestFunctions10() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; var g = l.CreateEnvironment(); var p = new TestParam(); g.DoChunk("p.Test = 3;", "dummy", new KeyValuePair<string, object>("p", p)); Assert.AreEqual(3, p.Test); } }
public void EnvDynamicCall01() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); g.dochunk(GetLines("Lua.EnvDynamicCall01.lua"), "test.lua"); TestResult(new LuaResult(g.test(2)), 4); TestResult(((LuaTable)g).CallMember("test", 2), 4); // test of c# binders Debug.Print("C# Binders:"); TestResult(g.b.a(5), 20); TestResult(g.b.b(5), 115); TestResult(g.b.c(g.b, 5), 110); TestResult(g.test(5), 10); // test of lua binders Debug.Print("Lua Binders:"); TestResult(g.dochunk("return b.a(5)", "test.lua"), 20); TestResult(g.dochunk("return b:b(5)", "test.lua"), 115); TestResult(g.dochunk("return b.b(b, 5)", "test.lua"), 115); TestResult(g.dochunk("return b:c(5)", "test.lua"), 110); TestResult(g.dochunk("return b.c(b, 5)", "test.lua"), 110); TestResult(g.dochunk("return test(5)", "test.lua"), 10); } } // prop EnvDynamicCall01
public void TypeTest02() { using (Lua l = new Lua()) { dynamic g = l.CreateEnvironment(); Type t = typeof(SubClass); LuaType tl = LuaType.GetType(t); TestResult(g.dochunk("return clr.LuaDLR.Test.LuaTypeTests.SubClass"), tl); TestResult(g.dochunk("return clr.LuaDLR.Test.LuaTypeTests.SubClass:GetType()"), t); TestResult(g.dochunk("return clr.System.IO.Stream"), LuaType.GetType(typeof(Stream))); LuaType tNull = g.dochunk("return clr.System.Test.Test"); Assert.IsTrue(tNull.Type == null); tl = g.dochunk("return clr.System.Collections.Generic.List[clr.System.String]", "test"); TestResult(new LuaResult(tl.Type), typeof(List<string>)); tl = g.dochunk("return clr.System.String[]", "test"); TestResult(new LuaResult(tl.Type), typeof(string[])); } }
public void MethodTest03() { using (Lua l = new Lua()) { l.PrintExpressionTree = Console.Out; dynamic g = l.CreateEnvironment(); g.console = LuaType.GetType(typeof(Console)); g.dochunk("console.WriteLine('Hallo!');", "test"); g.dochunk("c = console.WriteLine[clr.System.String];"); //g.c = g.console.WriteLine[typeof(string)]; g.c("Hallo"); g.dochunk("c('Hallo!')"); } }