libcoral/coral — Issue #22: Low-level reflection API in C
Author: tbastos
Created: 2011-11-26 03:59:25+00:00
State: open

The reflection subsystem should be revamped as follows:

1. __Low-level reflection in C++__
- Unsafe, assumes the provided input is always correct.
- Based on vararg and pointers?
- May raise C++ exceptions.
2. __Low-level reflection in C__
- Wraps the low-level C++ API into plain C functions.
- Catches exceptions and translates into C.
- Should be easy to use with LuaJIT-FFI.
3. __High-level Reflectors in CSL/C++__
- Adapts the low-level C++ API to match the current API.
- Adds type safety and conversions from/to co::Any.
- Could this layer itself be implemented using reflection instead of code generation?

This revamp provides the following advantages over the current solution:

- We could refactor the code for loading annotations to use the low-level reflection API, as this would allow annotations to be applied to core types (currently this is not possible because the reflection API requires all core types to be previously loaded).
- We can get maximum speed by using the low-level APIs where its safe (i.e. language bindings), and use the high-level API where safety is more important (i.e. general code).
- Other languages can interface with Coral through FFI (via the C reflection API).
- This would allow for a JIT'ed Lua/Coral integration with near-zero overhead (using LuaJIT-FFI).