{"id":13419655,"url":"https://github.com/vapourismo/luwra","last_synced_at":"2026-03-05T07:35:48.634Z","repository":{"id":73455113,"uuid":"37752239","full_name":"vapourismo/luwra","owner":"vapourismo","description":"Minimal-overhead C++ wrapper for Lua","archived":false,"fork":false,"pushed_at":"2023-07-17T19:25:39.000Z","size":7662,"stargazers_count":176,"open_issues_count":1,"forks_count":17,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-08-21T04:45:57.632Z","etag":null,"topics":["cpp","cpp11","lua","wrapper"],"latest_commit_sha":null,"homepage":"https://ole.lol/luwra/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vapourismo.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}},"created_at":"2015-06-20T00:33:34.000Z","updated_at":"2025-05-28T01:19:31.000Z","dependencies_parsed_at":"2024-10-26T16:53:12.137Z","dependency_job_id":"965401e7-e219-4f99-9c5d-ab5e4f8b83d3","html_url":"https://github.com/vapourismo/luwra","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/vapourismo/luwra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapourismo%2Fluwra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapourismo%2Fluwra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapourismo%2Fluwra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapourismo%2Fluwra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vapourismo","download_url":"https://codeload.github.com/vapourismo/luwra/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapourismo%2Fluwra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30114316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cpp","cpp11","lua","wrapper"],"created_at":"2024-07-30T22:01:19.003Z","updated_at":"2026-03-05T07:35:48.615Z","avatar_url":"https://github.com/vapourismo.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"[![Integration](https://github.com/vapourismo/luwra/workflows/Integration/badge.svg)](https://github.com/vapourismo/luwra/actions?query=workflow%3AIntegration)\n\n# Luwra\nA header-only C++ library which provides a Lua wrapper with minimal overhead.\n\n## Usage\nRefer to the [documentation](https://ole.lol/luwra/). In order to use the library you must clone\nthis repository and include `lib/luwra.hpp`.\n\nHave a question? Simply send me a an email or open an issue.\n\n## Examples\nIn the following examples `lua` refers to an instance of `lua_State*`.\n\nEasily push values onto the stack:\n\n```c++\n// Push an integer\nluwra::push(lua, 1338);\n\n// Push a number\nluwra::push(lua, 13.37);\n\n// Push a boolean\nluwra::push(lua, false);\n\n// Push a string\nluwra::push(lua, \"Hello World\");\n```\n\nOr retrieve them:\n\n```c++\n// Your function\nint my_fun(int a, int b) {\n    return a + b;\n}\n\n// Prepare stack\nluwra::push(lua, 13);\nluwra::push(lua, 37);\n\n// Read manually\nint a = luwra::read\u003cint\u003e(lua, 1);\n\n// Read with deduced type\nint b = luwra::read(lua, -1);\n\n// Apply your function\nint result = luwra::apply(lua, my_fun);\n\n// which is equivalent to\nint result = luwra::apply(lua, 1, my_fun);\n\n// and equivalent to\nint result = luwra::apply(lua, -2, my_fun);\n\n// All of this is essentially syntactic sugar for\nint result = my_fun(luwra::read(lua, 1), luwra::read(lua, 2));\n\n// You can also return the result to the stack\nluwra::map(lua, 1, my_fun);\nint result = luwra::read(state, -1);\n```\n\nGenerate a C function which can be used by Lua:\n\n```c++\n// Assuming your function looks something like this\nint my_function(const char* a, int b) {\n    // ...\n}\n\n// Convert to lua_CFunction\nlua_CFunction cfun = LUWRA_WRAP(my_function);\n\n// Do something with it, for example set it as a Lua global function\nluwra::setGlobal(lua, \"my_function\", cfun);\n```\n\n```lua\n-- Invoke the registered function\nlocal my_result = my_function(\"Hello World\", 1337)\nprint(my_result)\n```\n\nOr register your own class:\n\n```c++\nstruct Point {\n    double x, y;\n\n    Point(double x, double y):\n        x(x), y(y)\n    {\n        std::cout \u003c\u003c \"Construct Point(\" \u003c\u003c x \u003c\u003c \", \" \u003c\u003c y \u003c\u003c \")\" \u003c\u003c std::endl;\n    }\n\n    ~Point() {\n        std::cout \u003c\u003c \"Destruct Point(\" \u003c\u003c x \u003c\u003c \", \" \u003c\u003c y \u003c\u003c \")\" \u003c\u003c std::endl;\n    }\n\n    void scale(double f) {\n        x *= f;\n        y *= f;\n    }\n\n    std::string __tostring() {\n        return \"\u003cPoint(\" + std::to_string(x) + \", \" + std::to_string(y) + \")\u003e\";\n    }\n};\n\n// Register the metatable and constructor\nluwra::registerUserType\u003cPoint(double, double)\u003e(\n    lua,\n\n    // Constructor name\n    \"Point\",\n\n    // Methods need to be declared here\n    {\n        LUWRA_MEMBER(Point, scale),\n        LUWRA_MEMBER(Point, x),\n        LUWRA_MEMBER(Point, y)\n    },\n\n    // Meta methods may be registered aswell\n    {\n        LUWRA_MEMBER(Point, __tostring)\n    }\n);\n```\n\n```lua\n-- Instantiate 'Point'\nlocal point = Point(13, 37)\n\n-- Invoke 'scale' method\npoint:scale(1.5)\n\n-- Convert to string via '__tostring' meta method\nprint(point)\n\n-- Read properties 'x' and 'y'\nprint(point:x(), point:y())\n\n-- Set property 'x'\npoint:x(4.2)\n```\n\n## Requirements\nYou need a C++11-compliant compiler and at least Lua 5.1 to get this library to work. I recommend\nusing Lua 5.3 or later, to avoid the messy `lua_Integer` situation. LuaJIT 2.0 seems to work aswell.\n\n## Tests\nThe attached GNU `Makefile` allows you to run both examples and tests using `make examples` and\n`make test` respectively. You might need to adjust `LUA_*` variables, so Luwra finds the\nLua headers and library.\n\nAssuming all headers are located in `/usr/include/lua5.3` and the shared object name is\n`liblua5.3.so`, you need to invoke this:\n\n```\nmake LUA_INCDIR=/usr/include/lua5.3 LUA_LIBNAME=lua5.3 test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapourismo%2Fluwra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvapourismo%2Fluwra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapourismo%2Fluwra/lists"}