Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure _get and _set dispatch up the class hierarchy #1539

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

Naros
Copy link
Contributor

@Naros Naros commented Aug 1, 2024

@dsnopek this is in response to my question from chat. It seems a bit odd to me that _get_property_list dispatches up the class hierarchy while calls to _get and _set do not and expect the developer to call the super type internally. I'm not sure whether we want to alter this behavior or leave it as-is and document this nuance for others who may prefer to use these override methods for property management.

This change also seems to align the GDExtension behavior with C++ modules, too.

@Naros Naros requested a review from a team as a code owner August 1, 2024 00:08
@Naros Naros force-pushed the dispatch-get-set-up-hierarchy branch from f3d5629 to 904c2f4 Compare August 1, 2024 00:10
@dsnopek
Copy link
Collaborator

dsnopek commented Aug 1, 2024

Thanks!

This change also seems to align the GDExtension behavior with C++ modules, too.

Yeah, if we can align with in-engine modules, I'm all for it.

However, I think this still doesn't completely match the behavior in modules. Looking in object.h, there's:

		if (m_inherits::_setv(p_name, p_property)) {                                                                                             \
			return true;                                                                                                                         \
		}                                                                                                                                        \
		if (m_class::_get_set() != m_inherits::_get_set()) {                                                                                     \
			return _set(p_name, p_property);                                                                                                     \
		}                                                                                                                                        \
		return false;                                                                                                                            \

Which looks like it tries the parent first, and then if the parent doesn't have that property, it tries the child.

Whereas the changes in this PR have it try the child first, and if it doesn't have that property, it tries the parent.

@dsnopek dsnopek added the bug This has been identified as a bug label Aug 1, 2024
@dsnopek dsnopek added this to the 4.x milestone Aug 1, 2024
@Naros Naros force-pushed the dispatch-get-set-up-hierarchy branch from 904c2f4 to 9d5a5ab Compare August 1, 2024 16:01
@Naros Naros force-pushed the dispatch-get-set-up-hierarchy branch from 9d5a5ab to c77d44f Compare August 1, 2024 16:03
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks good to me :-)

@dsnopek dsnopek merged commit 3f4590f into godotengine:master Aug 7, 2024
12 checks passed
@dsnopek
Copy link
Collaborator

dsnopek commented Sep 3, 2024

Cherry-picked for 4.2 in PR #1570

@dsnopek
Copy link
Collaborator

dsnopek commented Sep 4, 2024

Cherry-picked for 4.1 in PR #1572

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants