Lua 的 .NET 實現:NeoLua

jopen 10年前發布 | 63K 次閱讀 NeoLua Lua開發

NeoLua是Lua 語言的一個.Net實現。可以在 .NET 的應用中調用 Lua 語言或者反過來(當前支持的 Lua 版本是 5.2),其目的是遵循 C-Lua 實現并且合并完整的 .NET 框架支持。你可以很方便在 Lua 程序中調用 .NET 的 functions/classes/interfaces/events ,同時也可以輕松在 .NET 應用中調用 Lua 的變量和函數。

NeoLua 使用 C# 開發并使用 Dynamic Language Runtime. 目前 NeoLua 依賴于 .NET Framework 4,同時也支持當前版本的 Mono 框架。

What NeoLua is useful for

  • Outsource the logic of your application into scripts
  • Structuring of logic
  • Build a dynamic configuration system, with functions and variables
  • As a formula parser
  • ...

Advantages of NeoLua

  • Dynamic access between Lua script and and the host application/.NET framework and vice-versa.
  • NeoLua is based on the DLR. So you get compiled code that is collectable and well-optimized.
  • It is compatible with the .NET world (e.g. C#, VB.NET, IronPython, ...).
  • Full and easy access to the .NET framework or your own libraries (with no stub code).
  • A .NET Framework Garbage Collector that is well-tested and very fast.
  • Pure IL (x86,x64 support)

示例代碼:

using Neo.IronLua;

namespace Test
{
  public static class Program
  {
    public static void Main(string[] args)
    {
      // Create the Lua script engine
      using (Lua l = new Lua())
      {
        // create a Lua script environment (global)
        var g = l.CreateEnvironment();
        // run a chunk, first the code, than the name of the code
        g.DoChunk("print('Hello World!');", "test.lua");
      }
    }
  }
}

Lua 的 .NET 實現:NeoLua

項目主頁:http://www.baiduhome.net/lib/view/home/1408005253192

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!