{"id":18582288,"url":"https://github.com/ubpa/uluapp","last_synced_at":"2025-04-10T11:36:06.434Z","repository":{"id":51293027,"uuid":"281792191","full_name":"Ubpa/ULuaPP","owner":"Ubpa","description":"Ubpa Lua++ (Lua \u0026 C++)","archived":false,"fork":false,"pushed_at":"2020-11-23T13:29:51.000Z","size":53,"stargazers_count":33,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T20:38:11.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Ubpa.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}},"created_at":"2020-07-22T22:04:57.000Z","updated_at":"2024-11-09T17:08:23.000Z","dependencies_parsed_at":"2022-09-24T12:44:43.398Z","dependency_job_id":null,"html_url":"https://github.com/Ubpa/ULuaPP","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FULuaPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FULuaPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FULuaPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FULuaPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ubpa","download_url":"https://codeload.github.com/Ubpa/ULuaPP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208688,"owners_count":21065205,"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":[],"created_at":"2024-11-07T00:10:25.473Z","updated_at":"2025-04-10T11:36:01.418Z","avatar_url":"https://github.com/Ubpa.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n _   _ _                ____________ \n| | | | |               | ___ \\ ___ \\\n| | | | |    _   _  __ _| |_/ / |_/ /\n| | | | |   | | | |/ _` |  __/|  __/ \n| |_| | |___| |_| | (_| | |   | |    \n \\___/\\_____/\\__,_|\\__,_\\_|   \\_|    \n                                     \n```\n\n[![repo-size](https://img.shields.io/github/languages/code-size/Ubpa/ULuaPP?style=flat)](https://github.com/Ubpa/ULuaPP/archive/master.zip) [![tag](https://img.shields.io/github/v/tag/Ubpa/ULuaPP)](https://github.com/Ubpa/ULuaPP/tags) [![license](https://img.shields.io/github/license/Ubpa/ULuaPP)](LICENSE) \n\n⭐ Star us on GitHub — it helps!\n\n# ULuaPP\n\nUbpa Lua++ (Lua \u0026amp; C++)\n\nAuto register C++ class to Lua with [sol2](https://github.com/ThePhD/sol2) and [USRefl](https://github.com/Ubpa/USRefl) \n\n## Example\n\nSuppose you have a class `Vec`, what you need to do are\n\n- write `TypeInfo\u003cVec\u003e` (you can use `USRefl::AutoRefl` to generate)\n- register : `Ubpa::ULuaPP::Register\u003cVec\u003e(lua_State*)` \n\nThat's all.\n\n```c++\n#include \u003cULuaPP/ULuaPP.h\u003e\n#include \u003ciostream\u003e\n\nstruct Vec {\n  Vec(float x, float y) : x{ x }, y{ y } {}\n  float x;\n  float y;\n  void Add(float dx = 1.f, float dy = 1.f) {\n    x += dx;\n    y += dy;\n  }\n};\n\ntemplate\u003c\u003e\nstruct Ubpa::USRefl::TypeInfo\u003cVec\u003e :\n  TypeInfoBase\u003cVec\u003e\n{\n#ifdef UBPA_USREFL_NOT_USE_NAMEOF\n  static constexpr char name[4] = \"Vec\";\n#endif\n  static constexpr AttrList attrs = {};\n  static constexpr FieldList fields = {\n    Field {TSTR(UMeta::constructor), WrapConstructor\u003cType(float, float)\u003e()},\n    Field {TSTR(\"x\"), \u0026Type::x},\n    Field {TSTR(\"y\"), \u0026Type::y},\n    Field {TSTR(\"Add\"), \u0026Type::Add, AttrList {\n      Attr {TSTR(UMeta::default_functions), std::tuple {\n        [](Type* __this, float dx) { return __this-\u003eAdd(std::forward\u003cfloat\u003e(dx)); },\n        [](Type* __this) { return __this-\u003eAdd(); }\n      }},\n    }},\n  };\n};\n\nint main() {\n  lua_State* L = luaL_newstate(); /* opens Lua */\n  luaL_openlibs(L); /* opens the standard libraries */\n\n  // you just need to write a line of code\n  Ubpa::ULuaPP::Register\u003cVec\u003e(L);\n\t\n  {\n    sol::state_view lua(L);\n    const char code[] = R\"(\nv = Vec.new(1, 2)\nprint(v.x, v.y)\nv.x = 3\nv.y = 4\nprint(v.x, v.y)\nv:Add(1, 2)\nv:Add(3)\nv:Add()\nprint(v.x, v.y)\n)\";\n    lua.script(code);\n  }\n  lua_close(L);\n  return 0;\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubpa%2Fuluapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubpa%2Fuluapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubpa%2Fuluapp/lists"}