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

Should classes with an alias name be retrievable both by name and by type? #61

Closed Weeena closed 7 years ago

Weeena commented 7 years ago

If I have declared a class to ponder with an alias name like this

PONDER_TYPE(MyType)

ponder::Class::declare<MyType>("SomeAliasName")
    ...

should then both methods work to retrieve the class:

class1 = ponder::classByType<MyType>();
class2 = ponder::classByName("SomeAliasName");

Currently, only the retrieval by name works. The first call with classByType<MyType>() leads to a runtime error because the class with name "MyType" is not found (which was established as static name for type MyType with the PONDER_TYPE macro).

So my question is: Should this work as expected or are my expectations wrong?

(Side note: It is not an urgent issue for me since up to now all my classed are declared without an alias name, and in that case everything works fine.)

billyquith commented 7 years ago

I'd see the name as an override, and if you declare it you have to use it. I've found it best to just use the type and not declare a meta-class name unless necessary.

Weeena commented 7 years ago

Ok, then the optional name is an override name rather than an alias name. And I will definitely stick to the type name and not declare a meta-class name unnecessary.