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

How to get UserObject from UserProperty ? #74

Closed AntAgna closed 7 years ago

AntAgna commented 7 years ago

In order to enumerate recursively trough properties of objects, I was using the constructor UserObject(const UserObject& parent, const UserProperty& member) to get a UserObject from a UserProperty. But this constructor has been removed in commit 915bb384dd0c7.

After a quick glance trough the code and the documentation, I could not find another way to get a UserObject from a UserProperty.

I added the simple method UserObject UserProperty::getObject(const UserObject& parentInstance) const, which provides this functionality without requiring parent-child information in UserObject.

billyquith commented 7 years ago

Ok, I think I removed too much. 🔪

Just trying to get the naming right for this:

UserObject UserProperty::getObject(const UserObject& parentInstance)

Is it the parentInstance? Or just the objectInstance? The properties belong to the metaclass. So the relationship is more member than parent-child.

billyquith commented 7 years ago

Clarified in docs: https://billyquith.github.io/ponder/docs/classponder_1_1_user_property.html#aaab97d0bcfeacdae2291e1fc61b103a4

AntAgna commented 7 years ago

Yes, I wasn't sure how to name the parameter. objectInstance is a better choice.