├── .gitignore
├── ExtTest
├── App.config
├── ExtTest.csproj
├── ExtTest.csproj.vspscc
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── StartEx.cs
├── ISSUE_TEMPLATE.md
├── LICENSE.md
├── LuaDLR.sln
├── NeoCmd
├── App.config
├── NeoCmd.csproj
├── NeoCmd.csproj.vspscc
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── Samples
│ ├── Coroutine.lua
│ ├── Debug.lua
│ ├── FileRead.lua
│ ├── ForEach.lua
│ ├── Forms.lua
│ ├── Forms1.lua
│ ├── Hallo.lua
│ ├── ModTest.lua
│ ├── StringBuilder.lua
│ ├── Table.lua
│ ├── Test.lua
│ ├── file.txt
│ └── getPlus.lua
├── NeoLua.Dbg
├── LuaTraceLineDebugger.cs
├── NeoLua.Dbg.csproj
└── NeoLua.snk
├── NeoLua.MSBuild
├── Init.ps1
├── LuaTask.cs
├── LuaTaskFactory.cs
├── NeoLua.MSBuild.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Sample
│ └── Test.bproj
├── NeoLua.NuGet
├── NeoLua.NuGet.csproj
├── NuGet.config
├── build.ps1
├── common.nupkg.targets
├── common.targets
├── package.targets
└── push.ps1
├── NeoLua.Test
├── CompTests
│ ├── bitwise.lua
│ ├── calls.lua
│ ├── literals.lua
│ ├── math.lua
│ └── strings.lua
├── Complex.cs
├── ControlStructures.cs
├── Examples.cs
├── Exceptions.cs
├── Expressions.cs
├── Functions.cs
├── Lua
│ ├── Control01.lua
│ ├── Control02.lua
│ ├── Control03.lua
│ ├── Control04.lua
│ ├── Control05.lua
│ ├── Control06.lua
│ ├── Control08.lua
│ ├── Control09.lua
│ ├── Control10.lua
│ ├── Control11.lua
│ ├── Control12.lua
│ ├── Control19.lua
│ ├── Control20.lua
│ ├── Coroutines01.lua
│ ├── Echo.bat
│ ├── EnvDynamicCall01.lua
│ ├── Function08.lua
│ ├── Function08a.lua
│ ├── Generics01.lua
│ ├── Runtime11.lua
│ └── Runtime12.lua
├── LuaEmitTests.cs
├── LuaLibs.cs
├── LuaTable.cs
├── LuaType.cs
├── NeoLua.Test.csproj
├── NeoLua.snk
├── Parser.cs
├── RunLuaTests.cs
├── Runtime.cs
└── TestHelper.cs
├── NeoLua
├── Exceptions.cs
├── Extern
│ └── printf.cs
├── GlobalSuppressions.cs
├── Lua.Binder.cs
├── Lua.Runtime.cs
├── Lua.cs
├── LuaChunk.cs
├── LuaDebug.cs
├── LuaEmit.cs
├── LuaFile.cs
├── LuaGlobal.cs
├── LuaLexer.cs
├── LuaLibraries.cs
├── LuaResult.cs
├── LuaStackTraceDebugger.cs
├── LuaTable.cs
├── LuaThread.cs
├── LuaType.cs
├── NeoLua.csproj
├── NeoLua.licenseheader
├── NeoLua.snk
├── Parser.Emit.cs
├── Parser.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.de.resx
│ └── Resources.resx
└── TypeExtensionHelpers.cs
├── NeoSpeed
├── App.config
├── LuaInterface.dll
├── NeoSpeed.csproj
├── NeoSpeed.csproj.vspscc
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Scripts
│ ├── CallStd.lua
│ ├── Delegate.lua
│ ├── Empty.lua
│ ├── String.lua
│ ├── StringBuilder1.lua
│ ├── StringBuilder2.lua
│ ├── String_echo.lua
│ ├── Sum.lua
│ ├── Sum_echo.lua
│ ├── Sum_strict1.lua
│ ├── Sum_strict2.lua
│ ├── TableIntGet.lua
│ ├── TableIntSet.lua
│ ├── TableString.lua
│ ├── TableVsList1.lua
│ └── TableVsList2.lua
└── lua.dll
├── README.md
├── VBtest
├── App.config
├── Module1.vb
├── Module2.vb
├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
└── VBtest.vbproj
└── doc
├── 02_basics.md
├── 03_language.md
├── 04_01_start.md
├── 04_02_engine.md
├── 04_03_chunk.md
├── 04_04_table.md
├── 05_01_clr.md
├── 05_02_extent.md
├── 05_03_debug.md
├── 06_std.md
├── 07_neocmd.md
├── Codeproject.html
├── Implementation.xlsm
└── imgs
├── Image.png
├── done.png
├── noco.png
└── noti.png
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | UpgradeLog*.XML
174 | UpgradeLog*.htm
175 |
176 | # SQL Server files
177 | *.mdf
178 | *.ldf
179 |
180 | # Business Intelligence projects
181 | *.rdl.data
182 | *.bim.layout
183 | *.bim_*.settings
184 |
185 | # Microsoft Fakes
186 | FakesAssemblies/
187 |
188 | # Node.js Tools for Visual Studio
189 | .ntvs_analysis.dat
190 |
191 | # Visual Studio 6 build log
192 | *.plg
193 |
194 | # Visual Studio 6 workspace options file
195 | *.opt
196 | /NeoLua.NuGet/package.apikey.targets
197 | /NeoCmd/Properties/launchSettings.json
198 |
--------------------------------------------------------------------------------
/ExtTest/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ExtTest/ExtTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {AE970FAD-2DDB-4FE5-A1B3-8C5E318823D4}
8 | Exe
9 | Properties
10 | ExtTest
11 | ExtTest
12 | v4.8
13 | 512
14 | SAK
15 | SAK
16 | SAK
17 | SAK
18 |
19 |
20 |
21 | AnyCPU
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | {09aebb35-719e-4e32-9836-f57d7d6f1607}
59 | NeoLua
60 |
61 |
62 |
63 |
70 |
--------------------------------------------------------------------------------
/ExtTest/ExtTest.csproj.vspscc:
--------------------------------------------------------------------------------
1 | ""
2 | {
3 | "FILE_VERSION" = "9237"
4 | "ENLISTMENT_CHOICE" = "NEVER"
5 | "PROJECT_FILE_RELATIVE_PATH" = ""
6 | "NUMBER_OF_EXCLUDED_FILES" = "0"
7 | "ORIGINAL_PROJECT_FILE_PATH" = ""
8 | "NUMBER_OF_NESTED_PROJECTS" = "0"
9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
10 | }
11 |
--------------------------------------------------------------------------------
/ExtTest/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Dynamic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using ExtTest;
7 | using Neo.IronLua;
8 |
9 | namespace NeoTest1
10 | {
11 | //public class Vector3
12 | //{
13 | // public float X;
14 | // public float Y;
15 | // public float Z;
16 |
17 | // public Vector3(float x, float y, float z)
18 | // {
19 | // X = x;
20 | // Y = y;
21 | // Z = z;
22 | // }
23 |
24 | // public override string ToString()
25 | // {
26 | // return string.Format("X = {0}, Y = {1}, Z = {2}", X, Y, Z);
27 | // }
28 | //}
29 |
30 |
31 | public class Folder
32 | {
33 | public int SomeId { get; set; }
34 | }
35 |
36 | public class File
37 | {
38 | public Folder Folder { get; set; }
39 | }
40 |
41 | public class DynData : DynamicObject
42 | {
43 | public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
44 | {
45 | return base.TryGetIndex(binder, indexes, out result);
46 | }
47 |
48 | public override bool TryGetMember(GetMemberBinder binder, out object result)
49 | {
50 | if (binder.Name == "Part")
51 | {
52 | result = "Part returned";
53 | return true;
54 | }
55 | return base.TryGetMember(binder, out result);
56 | }
57 | }
58 |
59 | class Program
60 | {
61 | static async Task TestAsync()
62 | {
63 | await Task.Yield();
64 | return 0;
65 | }
66 |
67 | #region -- Issue 81 --
68 |
69 | static bool NegBla(ref MyStruct my)
70 | => !my.Bla;
71 |
72 | struct MyStruct
73 | {
74 | public bool Bla => true;
75 | public bool Awesome => NegBla(ref this);
76 |
77 | }
78 | static MyStruct getStruct()
79 | => new MyStruct();
80 |
81 | public static void Example()
82 | {
83 | using (var l = new Lua())
84 | {
85 | dynamic g = l.CreateEnvironment();
86 | g.t = new LuaTable();
87 | ((LuaTable)g.t).DefineFunction("getStruct", new Func(getStruct));
88 |
89 | g.dochunk("local o = t.getStruct(); "+Environment.NewLine+"" +
90 | "print(o.Bla); print(o.Awesome); ", "test.lua");
91 | }
92 | }
93 |
94 | #endregion
95 |
96 |
97 | static void Main(string[] args)
98 | {
99 | Example();
100 |
101 | //Console.WriteLine(TestAsync().Result);
102 |
103 | //StartEx.Main1(args);
104 | //TestDynamic();
105 |
106 | //LinqTest2();
107 | Console.ReadKey();
108 | }
109 |
110 | private static void TestDynamic()
111 | {
112 | var lua = new Lua();
113 | var global = new LuaGlobal(lua) { ["workspace"] = new DynData() };
114 |
115 | var r = global.DoChunk("return workspace.Part", "Test.lua");
116 |
117 | Console.WriteLine(r.ToString());
118 | }
119 |
120 | private static void Test()
121 | {
122 | using (Lua l = new Lua())
123 | {
124 | var t = new LuaTable();
125 | var c = l.CompileChunk(
126 | String.Join(Environment.NewLine,
127 | "local v1 = 2;",
128 | "local v2 = 4;",
129 | "function f()",
130 | " return v1 + v2;",
131 | "end;",
132 | "return f();"), "test", null);
133 | var r = c.Run(t);
134 | Console.WriteLine("Test: v1=[{0}], v2=[{1}], r={2}", Lua.RtGetUpValue(t.GetMemberValue("f") as Delegate, 1), Lua.RtGetUpValue(t.GetMemberValue("f") as Delegate, 2), r.ToInt32());
135 | }
136 | }
137 |
138 | // private static void LinqTest2()
139 | // {
140 | // LuaType.RegisterTypeExtension(typeof(Enumerable)); // generic geht nicht
141 | // List lst = new List();
142 | // lst.Add(1);
143 | // lst.Add(2);
144 | // lst.Add(3);
145 | // using (Lua l = new Lua())
146 | // {
147 | // var g = l.CreateEnvironment();
148 |
149 | // LuaResult r = g.DoChunk(String.Join(Environment.NewLine,
150 | // "return a.Select(function (c) return c; end).ToArray();"
151 | // ), new KeyValuePair("a", lst));
152 |
153 | // Console.WriteLine(r[0].ToString());
154 | // }
155 | // }
156 |
157 | // private static void LinqTest()
158 | // {
159 | // LuaTable t = new LuaTable();
160 | // for (int i = 1; i <= 26; i++)
161 | // t[i] = i * i;
162 |
163 | // string[] arr = t.ArrayList.Select(c => c.ToString()).ToArray();
164 |
165 | // foreach (string s in arr)
166 | // Console.Write("{0}, ", s);
167 | // }
168 |
169 | // private static void MasterTest()
170 | // {
171 | // using (Lua l = new Lua())
172 | // {
173 | // dynamic g = l.CreateEnvironment();
174 |
175 | // g.dofile(@"d:\temp\a\m.lua");
176 |
177 | // LuaTable t = (LuaTable)g.array;
178 | // Console.WriteLine("{0}", t[1]);
179 | // }
180 | // }
181 |
182 | // private static void Vector3Test()
183 | // {
184 | // string luaScript = @"
185 | //local Vector3 = clr.NeoTest1.Vector3
186 | //local v1 = Vector3(1, 1, 1)
187 | //print(v1)
188 | //local v2 = Vector3(v1.X, v1.Y, v1.Z)
189 | //print(v2)
190 | //";
191 | // using (Lua lua = new Lua())
192 | // {
193 | // LuaGlobal lg = lua.CreateEnvironment();
194 | // try
195 | // {
196 | // lg.DoChunk(luaScript, "dummy.lua");
197 | // }
198 | // catch (Exception ex)
199 | // {
200 | // Console.WriteLine(ex.Message);
201 | // Console.WriteLine(ex.StackTrace);
202 | // }
203 | // }
204 | // }
205 | }
206 | }
--------------------------------------------------------------------------------
/ExtTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die mit einer Assembly verknüpft sind.
8 | [assembly: AssemblyTitle("ExtTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExtTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("19371e31-6090-47e6-95e8-d782c54f999f")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33 | // übernehmen, indem Sie "*" eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExtTest/StartEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Neo.IronLua;
8 |
9 | namespace ExtTest
10 | {
11 | class StartEx
12 | {
13 | public const string ProgramSource = "local a, b = tonumber(read(\"a\")), tonumber(read(\"b\"));\n" +
14 | "local PrintResult = function(o, op)\n" +
15 | " print(o.. ' = ' .. a..op..b);\n" +
16 | "end;\n" +
17 | "PrintResult(a + b, \" + \");\n" +
18 | "PrintResult(a - b, \" - \");\n" +
19 | "PrintResult(a * b, \" * \");\n" +
20 | "PrintResult(a / b, \" / \");\n" +
21 | "PrintResult(a // b, \" // \");\n";
22 |
23 | public static void Main1(string[] args)
24 | {
25 | // create lua script engine
26 | using (var l = new Lua())
27 | {
28 | // create an environment, that is associated to the lua scripts
29 | dynamic g = l.CreateEnvironment();
30 |
31 | // register new functions
32 | g.print = new Action