{"id":26822262,"url":"https://github.com/wh1teduke/cslua","last_synced_at":"2025-07-21T04:34:32.096Z","repository":{"id":285141825,"uuid":"957184987","full_name":"Wh1teDuke/CSLua","owner":"Wh1teDuke","description":"C# implementation of Lua 5.2","archived":false,"fork":false,"pushed_at":"2025-04-19T12:44:24.000Z","size":1053,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T17:03:57.999Z","etag":null,"topics":["csharp","interpreter","lua"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wh1teDuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-29T18:52:46.000Z","updated_at":"2025-04-19T12:44:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"90c9ca08-f07a-4779-9b56-7df6fdc3f5a1","html_url":"https://github.com/Wh1teDuke/CSLua","commit_stats":null,"previous_names":["wh1teduke/cslua"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Wh1teDuke/CSLua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wh1teDuke%2FCSLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wh1teDuke%2FCSLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wh1teDuke%2FCSLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wh1teDuke%2FCSLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wh1teDuke","download_url":"https://codeload.github.com/Wh1teDuke/CSLua/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wh1teDuke%2FCSLua/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266241105,"owners_count":23898065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","interpreter","lua"],"created_at":"2025-03-30T08:18:22.557Z","updated_at":"2025-07-21T04:34:32.084Z","avatar_url":"https://github.com/Wh1teDuke.png","language":"C#","readme":"# CSLua\n\n## Example\n\n```cs\npublic void Test()\n{\n    var L = new LuaState();\n    L.OpenLibs(); // or L.OpenSafeLibs();\n    \n    L.PushCsDelegate(FromCS);\n    L.SetGlobal(\"FromCS\");\n    \n    L.DoString(\n        \"\"\"\n        assert(_CSLUA)\n        local a, b = 1, 2\n        return FromCS(a, b);\n        \"\"\");\n\n    var b = L.PopInteger();\n    var a = L.PopInteger();\n    Assert.Equal(2, a);\n    Assert.Equal(1, b);\n}\n\nprivate static int FromCS(ILuaState L)\n{\n    var a = L.ToInteger(1);\n    var b = L.ToInteger(2);\n    L.PushInteger(a + 1);\n    L.PushInteger(b - 1);\n    return 2;\n}\n```\n\nLua 5.2 implemented in pure C#. For more examples, check out the [`Test` folder](Test/).\n\n---\n\n## About CSLua\n\n**CSLua** is fork of [UniLua](https://github.com/xebecnan/UniLua). I needed a Lua interpreter compatible with [AoT C#](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/) and as efficient as possible. Unfortunately most libraries don't make the cut due to being focused on unity or allocating too much garbage.\nThis project is a big refactoring of the original code. [@Xebecnan](https://github.com/xebecnan)'s UniLua targets version 5.2 but it also includes some 5.3 features such as utf8 support and integers.\n\nIn specific, the differences between my fork and the original are:\n\n* **Code refactoring**: Remove references to unity, create new folders.\n* **Performance improvements**: Converted code to use structs and spans where it makes sense. For example, `StkId` is no longer a class but a ref to `TValue`.\n* **Added Tests**: Including some of the basic [Lua 5.2 test suite](https://www.lua.org/tests/).\n* **Implement some functions of the standard library that were missing**: This is still incomplete.\n* **Added some [power patches](Test/TestPatches.cs)**: Compound assignments (`+=`, `-=`, `..=` and friends), `continue`, `!=` alias for `~=`, digit separators (`1_000`), implicit pairs (`for i, v in {1, 2, 3} do ...`).\n* **First class citizen support for [lists](Test/TestList.cs)**: \n```lua\nlocal list = require 'list'\nlocal list1 = list.new(1, 2, 3)\nlist1[0] = 2\nassert(list1[0] == 2)\nassert(#list1 == 3)\nlist.add(list1, 4)\nassert(#list1 == 4)\n```\n\n\u003e [!WARNING]\n\u003e While this library is functional, expect some bugs. Some of lua's tests were disabled due to differences in the implementation or incomplete standard library. You can find them by grepping **CSLUA_FAIL** in the [test/suite folder](Test/suite). Don't expect a stable API.\n\n\nContributions are welcome.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwh1teduke%2Fcslua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwh1teduke%2Fcslua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwh1teduke%2Fcslua/lists"}