{"id":13730457,"url":"https://github.com/Leandros/metareflect","last_synced_at":"2025-05-08T03:30:40.251Z","repository":{"id":41407114,"uuid":"131321041","full_name":"Leandros/metareflect","owner":"Leandros","description":" Metareflect is a lightweight reflection system for C++, based on LLVM and Clangs libtooling.","archived":false,"fork":false,"pushed_at":"2019-10-25T08:15:54.000Z","size":39,"stargazers_count":229,"open_issues_count":7,"forks_count":33,"subscribers_count":9,"default_branch":"dev","last_synced_at":"2024-08-04T02:09:34.736Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","clang","llvm","reflection"],"latest_commit_sha":null,"homepage":"https://arvid.io","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/Leandros.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":"2018-04-27T16:32:10.000Z","updated_at":"2024-07-12T22:14:46.000Z","dependencies_parsed_at":"2022-08-25T06:00:27.456Z","dependency_job_id":null,"html_url":"https://github.com/Leandros/metareflect","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/Leandros%2Fmetareflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leandros%2Fmetareflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leandros%2Fmetareflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leandros%2Fmetareflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leandros","download_url":"https://codeload.github.com/Leandros/metareflect/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224695513,"owners_count":17354424,"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":["c-plus-plus","c-plus-plus-11","clang","llvm","reflection"],"created_at":"2024-08-03T02:01:15.138Z","updated_at":"2024-11-14T21:31:01.289Z","avatar_url":"https://github.com/Leandros.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# MetaReflect\n\nMetareflect is a lightweight reflection system for C++, based on LLVM and Clangs\nlibtooling.\n\n- **Lookup members of reflected classes:** Once reflection data has been generated,\nyou can query the members of the class, inspect their types, size and where they're\nlocated in the class, as well as qualifiers and storage class.\n- **Control over which classes are reflected:** By annotating your class with\n`CLASS`, and each member which you want to be reflected with `PROPERTY`, you\nhave fine-grained control over what you want to reflect, and what you want to\nkeep completely private.\n- **Extensible:** It's easy to add new flags, which can be queried at runtime.\nThis allows for easily adding any feature you like. Currently used to provide\nserialization from and to a byte stream for annotated classes.\n\n\n# Getting Started\n\n**To get started [download the latest release here](https://github.com/Leandros/metareflect/releases).**\n\n## Setting Up The Runtime\n\nMetareflect requires the runtime, it's consisting of the interface and a couple\nhelper macros for annotating your classes. To include it into your project,\nsimply copy over the [`/metareflect`](/metareflect) folder into your project.\nUnfortunately, the runtime is not fully header-only and requires you to compile\nthe files ending in `.cxx`.\n\n\n## Annotating Your Classes\n\nEvery class which you want to be reflected needs to be annotated.\n\n**point.hxx:**\n\n    #include \u003cmetareflect/metareflect.hxx\u003e\n\n    CLASS() Point\n    {\n    public:\n        PROPERTY()\n        int x;\n\n        PROPERTY()\n        int y;\n\n        PROPERTY()\n        int z;\n\n        FUNCTION()\n        size_t Hash() const\n        {\n            return x ^ y ^ z;\n        }\n    };\n\n**point.cxx:**\n\n    #include \"point.hxx\"\n    #include \"point.generated.hxx\"\n\n    /* rest of the code */\n\n\nFor a full example take a look at our [`/example`](/example).\n\n## Run The Metareflect Tool\n\nTo provide the reflection data, the metareflect tool generates a header-file\nwhich contains the reflection data in a format consumable by the runtime.\nThe generated file needs to be in your include path and included into the\nimplementation file of the reflected class.\n\nSince metareflect is based on libtooling, all the flags common to libtooling\ntools apply to it to. That means if you have a build system which can generate\na `compile_commands.json` (for example: ninja or CMake) you can simply provide\nit the path to your compilation database and metareflect will pick the correct\nflags automatically.\nFor further information, consult the [LLVM documentation for libtooling](https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html).\n\nTo generate a compilation database using CMake, pass it\n`-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` while generating your build files.\n\n\n# Contributing\n\nAny contribution is welcome. Take a look at the [open tickets](https://github.com/Leandros/metareflect/issues) to get\nstarted with the development of metareflect.\n\n## Requirements\n\n- A clone of the LLVM 6.0.0 source code, including clang and clang-extra-tools.\n  See [LLVM_SETUP](/LLVM_SETUP.md) how to setup LLVM for development.\n- A clone of the metareflect repository\n- A beefy computer, otherwise compiling LLVM will take some time\n\n## Structure\n\nMetareflect consists of two parts, the runtime and the libtooling tool.\n\nThe runtime lives in the `metareflect/` folder, while the `tooling/` folder\ncontains the source code for the tool.\n\n## Getting Started\n\nOnce you've cloned the LLVM repo (by following the guide at [LLVM_SETUP](/LLVM_SETUP.md)),\nnavigate to `path/to/llvm/tools/clang/tools/extra/metareflect/metareflect`.\nThe directory contains the source code for metareflect and anything you need\nto get started developing metareflect.\n\nThe following resources give an insight into how to develop an libtooling application:\n\n- [Clang Documentation on LibTooling](https://clang.llvm.org/docs/LibTooling.html)\n- [Using ASTMatchers in LibTooling](https://clang.llvm.org/docs/LibASTMatchersTutorial.html)\n\nTo contribute your changes back, please open a pull request! We welcome any contribution.\n\n# Inspiration\n\nParts of the design and how the tool works has been based upon prior research\ndone in Unreal Engine 4s UHT (Unreal Header Tool) and Qts `moc`.\nIf you've used either of the two, you might spot the similarities.\n\n# License\n\n[MIT License](/LICENSE)\n\nCopyright (c) 2018 Arvid Gerstmann.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeandros%2Fmetareflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLeandros%2Fmetareflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLeandros%2Fmetareflect/lists"}