billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
640 stars 93 forks source link

Declaring Metaclasses with no template. #57

Closed BlamKiwi closed 7 years ago

BlamKiwi commented 7 years ago

The class builder requires you to specify a concrete C++ type.

ponder::Class::declare<T>("T")

Is there anything architecturally stopping someone from making it so that the template is optional? I want to look at modifying ponder so that it can support interop from late-dynamic languages a bit better.

billyquith commented 7 years ago

Declaration is a compile-time operation, you can't register new types at runtime because there is no type information, the C++ compiler has turned them into code. There are two types of reflection here: compile-time and runtime. Compile-time supplies traits about the types declared (through FunctionTraits and ObjectTraits) and the runtime supplies information via the Function and Property objects.

I am also interested in adding interop (see #42). I'm not sure it can be done with the runtime data, except by using the data to generate a binding offline, i.e. code generation and compilation. It might be possible to do it with the compile-time data by adding another "use". The idea here is that clients of the declared information can use the compile-time trait information to generate the data they require at runtime, each use being different (and example being the evolving Lua bindings).

P.S. What a coincidence! I'm just looking into component caching, like your project. Currently have component pools but want cache coherency.

billyquith commented 7 years ago

Has this question been answered? Can you do what you need to do?

BlamKiwi commented 7 years ago

Decided to take a different approach to solve the problem. One that makes C++ an implementation detail. No need for reflection in C++ taking this approach.