Skip to content

Commit c24a951

Browse files
authored
Merge pull request #93 from ReflectCxx/develop
added sponser badge.
2 parents cc86d32 + 43b2ec3 commit c24a951

File tree

2 files changed

+46
-57
lines changed

2 files changed

+46
-57
lines changed

.github/workflows/FUNDING.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
github: ReflectCxx
1+
# These are supported funding model platforms
2+
github: neeraj31285

README.md

Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
[![Codecov](https://codecov.io/gh/ReflectCxx/ReflectionTemplateLibrary-CPP/branch/release/graph/badge.svg)](https://codecov.io/gh/ReflectCxx/ReflectionTemplateLibrary-CPP)
1212
 
1313
[![Try RTL Online](https://img.shields.io/badge/Try-RTL%20Online-f48024?logo=github&logoColor=white)](https://github.com/codespaces/new?repo=ReflectCxx/RTL-Demo&quickstart=1)
14+
 
15+
[![Sponsor](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?logo=github)](https://github.com/sponsors/ReflectCxx)
1416

1517
**RTL** provides type-safe run-time reflection for modern C++ – combining compile-time guarantees with controlled run-time flexibility.
1618

@@ -61,13 +63,13 @@ First, create an instance of `CxxMirror` –
6163
auto cxx_mirror = rtl::CxxMirror({ /* ...register all types here... */ });
6264
```
6365
The `cxx_mirror` object provides access to the runtime reflection system. It enables querying, introspection, and instantiation of registered types without requiring compile-time type knowledge at the call site.
64-
It can reside in any translation unit and is initialized on first use. To make it globally accessible in a controlled manner, a singleton interface can be used –
66+
It can reside in any translation unit. To make it globally accessible in a controlled manner and ensure it is initialized only when needed, a singleton interface can be used –
6567
```c++
6668
// MyReflection.h
6769
namespace rtl { class CxxMirror; } // Forward declaration, no includes here!
6870
struct cxx { static rtl::CxxMirror& mirror(); }; // The Singleton.
6971
```
70-
define and register everything in an isolated translation unit,
72+
define and register everything in an isolated translation unit
7173
```c++
7274
// MyReflection.cpp
7375
#include <rtl_builder.h> // Reflection builder interface.
@@ -90,7 +92,7 @@ rtl::CxxMirror& cxx::mirror() {
9092

9193
**[Explore the demo code](https://github.com/ReflectCxx/RTL-Demo)**
9294

93-
Lookup class `Person` by name (given at registration time).
95+
Lookup the `Person` class by its registered name –
9496
```c++
9597
std::optional<rtl::Record> classPerson = cxx::mirror().getRecord("Person");
9698
if (!classPerson) { /* Class not registered. */ }
@@ -100,28 +102,28 @@ if (!classPerson) { /* Class not registered. */ }
100102
From `rtl::Record`, registered member functions can be queried as `rtl::Method`. These are metadata descriptors (not callables) and are returned as `std::optional`, which will be empty if the requested entity is not found.
101103
102104
Callables are materialized by explicitly providing the argument types we intend to pass. If the signature is valid, the resulting callable can be invoked safely.
103-
For example, the overloaded constructor `Person(std::string, int)` -
105+
For example, the overloaded constructor `Person(std::string, int)`
104106
```c++
105107
rtl::constructor<std::string, int> personCtor = classPerson->ctor<std::string, int>();
106108
if (!personCtor) { /* Constructor with expected signature not found. */ }
107109
```
108-
Or the default constructor -
110+
Or the default constructor
109111
```c++
110112
rtl::constructor<> personCtor = classPerson->ctor();
111113
```
112-
Instances can be created on the `Heap` or `Stack` with automatic lifetime management:
114+
Instances can be created on the `Heap` or `Stack` with automatic lifetime management
113115
```c++
114116
auto [err, robj] = personCtor(rtl::alloc::Stack, "John", 42);
115117
if (err != rtl::error::None) { std::cerr << rtl::to_string(err); } // Construction failed.
116118
```
117119
The constructed object is returned wrapped in `rtl::RObject`. Heap-allocated objects are internally managed via `std::unique_ptr`, while stack-allocated objects are stored directly in `std::any`.
118120
119-
Now, Lookup a member-function by name -
121+
Now, Lookup a member-function by name
120122
```c++
121123
std::optional<rtl::Method> oGetName = classPerson->getMethod("getName");
122124
if (!oGetName) { /* Member function not registered */ }
123125
```
124-
And materialize a complete type-aware caller -
126+
And materialize a complete type-aware caller
125127
```c++
126128
rtl::method<Person, std::string()> getName = oGetName->targetT<Person>()
127129
.argsT().returnT<std::string>();
@@ -135,7 +137,7 @@ else {
135137
```
136138
The above `getName` invocation is effectively a native function-pointer hop, since all types are known at compile time.
137139

138-
If the concrete type `Person` is not accessible at the call site, its member functions can still be invoked by erasing the target type and using `rtl::RObject` instead. The previously constructed instance (`robj`) is passed as the target.
140+
If the concrete type `Person` is not accessible at the call site, its member functions can still be invoked by erasing the target type and using `rtl::RObject` instead. The previously constructed instance (`robj`) is passed as the target
139141
```c++
140142
rtl::method<rtl::RObject, std::string()> getName = oGetName->targetT()
141143
.argsT().returnT<std::string>();
@@ -144,7 +146,7 @@ if (err == rtl::error::None && ret.has_value()) {
144146
std::cout << ret.value();
145147
}
146148
```
147-
If the return type is also not known at compile time,`rtl::Return` can be used:
149+
If the return type is also not known at compile time,`rtl::Return` can be used
148150
```c++
149151
rtl::method<rtl::RObject, rtl::Return()> getName = oGetName->targetT()
150152
.argsT().returnT();
@@ -160,31 +162,51 @@ At a high level, every registered C++ type is encapsulated as an `rtl::Record`.
160162

161163
RTL provides the following callable wrappers, designed to be as lightweight and performant as `std::function` (and in many micro-benchmarks, faster when fully type-aware):
162164

163-
`rtl::function<...>` – Free (non-member) functions
165+
`rtl::function<>` – Free (non-member) functions
164166

165-
`rtl::constructor<...>` – Constructors
167+
`rtl::constructor<>` – Constructors
166168

167-
`rtl::method<...>` – Non-const member functions
169+
`rtl::method<>` – Non-const member functions
168170

169-
`rtl::const_method<...>` – Const-qualified member functions
171+
`rtl::const_method<>` – Const-qualified member functions
170172

171-
`rtl::static_method<...>` – Static member functions
173+
`rtl::static_method<>` – Static member functions
172174

173175
These callable types are regular value types: they can be copied, moved, stored in standard containers, and passed around like any other lightweight object.
174176

175177
When invoked, only type-erased callables return an `rtl::error`, with results provided as `rtl::RObject` when both the return and target types are erased or as `std::optional<T>` when only the target type is erased, while fully type-aware callables return `T` directly with no error wrapper.
176178

177-
### Allocation and Lifetime Management
179+
### How to Build (Windows / Linux)
180+
```sh
181+
mkdir build && cd build
182+
cmake -G "<Generator>" # Use a C++20-compatible compiler
183+
cmake --build .
184+
```
185+
Run the generated binaries from `bin/`:
186+
187+
* `RTLTestRunApp` – Reflection tests and examples
188+
* `RTLBenchmarkApp` – Performance benchmarks
189+
190+
Additional resources:
178191

179-
* Heap (`alloc::Heap`) – objects are owned by an internal `std::unique_ptr` and destroyed when their `rtl::RObject` wrapper goes out of scope.
192+
* `CxxTestRegistration/src/MyReflectionTests/` – Tutorial examples
193+
* `RTLTestRunApp/src` – Detailed test cases
194+
* `RTLBenchmarkApp/src` – Benchmark implementations
195+
* `run_benchmarks.sh` – Automated benchmark runs
180196

181-
* Stack (`alloc::Stack`) – independent copies behave like normal stack values and clean up at scope exit.
197+
## 💚 Support RTL’s Development
182198

183-
* Move semantics – `Heap` objects follow `std::unique_ptr` rules (move transfers ownership, copy/assign disabled). `Stack` objects move like regular values.
199+
Reflection Template Library (RTL) is an actively maintained, production-oriented C++ runtime reflection system focused on performance, type safety, and real-world usability.
184200

185-
* Return values – All returns are propagated back wrapped in `rtl::RObject`, cleaned up automatically at scope exit.
201+
Sponsorship supports continued improvement of RTL’s core reflection capabilities, along with:
186202

187-
RTL doesn’t invent a new paradigm – it extends C++ itself. You create objects, call methods, and work with types as usual, but now safely at run-time.
203+
* Production-ready examples
204+
* Tooling and documentation
205+
* Cross-platform CI and testing
206+
207+
If you’re interested in advancing practical runtime reflection in C++ and supporting the continued evolution of RTL’s core capabilities, consider sponsoring the project.
208+
209+
[![Sponsor RTL](https://img.shields.io/badge/Sponsor-RTL_Development-ea4aaa?logo=github)](https://github.com/sponsors/ReflectCxx)
188210

189211
## Reflection Features
190212

@@ -218,40 +240,6 @@ RTL doesn’t invent a new paradigm – it extends C++ itself. You create object
218240
***Composite Type Reflection**: Planned.
219241
***Inheritance Support**: Planned.
220242

221-
## How To build (Windows/Linux)
222-
223-
Create a build directory in the project root folder:
224-
225-
```sh
226-
mkdir build && cd build
227-
```
228-
229-
Generate a build system using **Unix Makefiles** or **Visual Studio** in CMake (use a compiler with C++20):
230-
231-
```sh
232-
cmake -G "<Generator>"
233-
```
234-
235-
To build, use any IDE applicable to the generator, or build straight from CMake:
236-
237-
```sh
238-
cmake --build .
239-
```
240-
241-
Run the `RTLTestRunApp` or `RTLBenchmarkApp` binaries generated in the `bin/` directory. (Tested with MSVC 19, GCC 14, and Clang 19)
242-
* See `CxxTestRegistration/src/MyReflectionTests/` for introductory examples of type registration and reflective programming.
243-
* See `RTLTestRunApp/src` for detailed test cases.
244-
* See `RTLBenchmarkApp/src` for benchmarking implementations.
245-
* Run `run_benchmarks.sh` to perform automated benchmarking, from micro-level tests to scaled workloads.
246-
247-
## Contributions
248-
249-
Contributions welcome! Report bugs, request features, or submit PRs on GitHub.
250-
251-
## Contact
252-
253-
GitHub issues or email at `reflectcxx@outlook.com`.
254-
255243
##
256244

257-
***C++ joins the reflection party! why should Java & .NET have all the fun?***
245+
***C++ joins the reflection party! why should Java have all the fun?***

0 commit comments

Comments
 (0)