{"id":16699424,"url":"https://github.com/ousttrue/perilune","last_synced_at":"2025-03-14T04:33:54.804Z","repository":{"id":136460688,"uuid":"199254310","full_name":"ousttrue/perilune","owner":"ousttrue","description":"header only lua binding  💫","archived":false,"fork":false,"pushed_at":"2020-06-03T04:49:46.000Z","size":356,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T23:29:22.637Z","etag":null,"topics":["cpp","lua-binding"],"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/ousttrue.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":"2019-07-28T07:04:15.000Z","updated_at":"2020-06-03T04:49:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4a657fd-a676-4331-b3af-699e8d8c2dd9","html_url":"https://github.com/ousttrue/perilune","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Fperilune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Fperilune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Fperilune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Fperilune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ousttrue","download_url":"https://codeload.github.com/ousttrue/perilune/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526945,"owners_count":20305112,"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":["cpp","lua-binding"],"created_at":"2024-10-12T18:06:56.777Z","updated_at":"2025-03-14T04:33:54.796Z","avatar_url":"https://github.com/ousttrue.png","language":"C++","readme":"# perilune\n\nheader only lua binding\n\n## features\n\n* [x] reference argument\n* [x] this pointer by upvalue\n* [x] getter\n* [ ] setter\n* [x] operator\n* [x] indexer\n* [x] pointer type\n* [x] std::shared_ptr\n* [x] metatable use hash\n* [x] return unknown pointer type to lightuesrdata\n* [x] return unknown value type to error\n* [x] placement new\n* [ ] generic typed array\n\n## usage\n\n### value type\n\nfor the type that copy side effect is safe.\n\n```c++\nstruct Vector3\n{\n    float x;\n    float y;\n    float z;\n\n    Vector3()\n        : x(0), y(0), z(0)\n    {\n    }\n\n    Vector3::Vector3(float x_, float y_, float z_)\n        : x(x_), y(y_), z(z_)\n    {\n    }\n\n    float SqNorm() const\n    {\n        return x * x + y * y + z * z;\n    }\n};\n```\n\n```c++\n    static perilune::ValueType\u003cVector3\u003e vector3Type;\n    vector3Type\n        // lambda\n        .StaticMethod(\"Zero\", []() { return Vector3(); })\n        .StaticMethod(\"Vector3\", [](float x, float y, float z) { return Vector3(x, y, z); })\n        .MetaIndexDispatcher([](auto d) {\n            d-\u003eGetter(\"x\", [](const Vector3 \u0026value) {\n                return value.x;\n            });\n            // member pointer\n            d-\u003eGetter(\"y\", \u0026Vector3::y);\n            d-\u003eGetter(\"z\", \u0026Vector3::z);\n            d-\u003eMethod(\"sqnorm\", \u0026Vector3::SqNorm);\n        })\n        // create and push lua stack\n        .LuaNewType(lua.L);\n    lua_setglobal(lua.L, \"Vector3\");\n```\n\n```lua\nlocal zero = Vector3.Zero()\nprint(zero)\nprint(zero.x)\n\nlocal v = Vector3.Vector3(1, 2, 3)\nprint(v)\nprint(v.x)\nprint(v.y)\nprint(v.z)\nlocal n = v.sqnorm()\nprint(n)\n```\n\n### pointer type\n\nfor the type that cannot copy or copy side effect is not safe.\ntemplate specialized.\n\n```cpp\n    static perilune::UserType\u003cWin32Window *\u003e windowType;\n    windowType\n        .StaticMethod(\"new\", []() {\n            return new Win32Window;\n        })\n        .MetaMethod(perilune::MetaKey::__gc, [](Win32Window *p) {\n            std::cerr \u003c\u003c \"destruct: \" \u003c\u003c p \u003c\u003c std::endl;\n            delete p;\n        })\n        .MetaIndexDispatcher([](auto d) {\n            d-\u003eMethod(\"create\", \u0026Win32Window::Create);\n            d-\u003eMethod(\"is_running\", \u0026Win32Window::IsRunning);\n            d-\u003eMethod(\"get_state\", \u0026Win32Window::GetState);\n        })\n        .LuaNewType(lua.L);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fousttrue%2Fperilune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fousttrue%2Fperilune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fousttrue%2Fperilune/lists"}