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

Implement ClassDB::class_get_static_method #91392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RadiantUwU
Copy link
Contributor

No description provided.

@Chaosus Chaosus added this to the 4.x milestone May 1, 2024
@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch from b1319b8 to c20fa27 Compare May 1, 2024 19:04
@Bromeon
Copy link
Contributor

Bromeon commented May 5, 2024

This is a great addition, thanks a lot 👍

The CI is currently encountering an error in the godot-cpp builds. I'm not sure if it's a codegen issue, but it looks like the keyword class is used in expression position, which should probably be escaped/renamed (likely unrelated to this PR)?

In file included from /home/runner/work/godot/godot/godot-cpp/include/godot_cpp/core/class_db.hpp:41,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/ref_counted.hpp:39,
                 from /home/runner/work/godot/godot/godot-cpp/include/godot_cpp/classes/ref.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_from_window.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_with_modifiers.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_mouse.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_mouse_motion.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/src/classes/input_event_mouse_motion.cpp:33:
/home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/class_db_singleton.hpp: In member function 'godot::Variant godot::ClassDBSingleton::class_call_static_method(const godot::StringName&, const godot::StringName&, const Args& ...)':
/home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/class_db_singleton.hpp:71:66: error: expected primary-expression before '(' token
   71 |   std::array<Variant, 2 + sizeof...(Args)> variant_args { Variant(class), Variant(method), Variant(args)... };
      |                                                                  ^

Apart from that, what do you think about naming it class_call_static instead of class_call_static_method?
Simply because that's consistent with Object::call, which isn't named Object::call_method either.

@RadiantUwU
Copy link
Contributor Author

This is a great addition, thanks a lot 👍

The CI is currently encountering an error in the godot-cpp builds. I'm not sure if it's a codegen issue, but it looks like the keyword class is used in expression position, which should probably be escaped/renamed (likely unrelated to this PR)?

In file included from /home/runner/work/godot/godot/godot-cpp/include/godot_cpp/core/class_db.hpp:41,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/ref_counted.hpp:39,
                 from /home/runner/work/godot/godot/godot-cpp/include/godot_cpp/classes/ref.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_from_window.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_with_modifiers.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_mouse.hpp:37,
                 from /home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/input_event_mouse_motion.hpp:36,
                 from /home/runner/work/godot/godot/godot-cpp/gen/src/classes/input_event_mouse_motion.cpp:33:
/home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/class_db_singleton.hpp: In member function 'godot::Variant godot::ClassDBSingleton::class_call_static_method(const godot::StringName&, const godot::StringName&, const Args& ...)':
/home/runner/work/godot/godot/godot-cpp/gen/include/godot_cpp/classes/class_db_singleton.hpp:71:66: error: expected primary-expression before '(' token
   71 |   std::array<Variant, 2 + sizeof...(Args)> variant_args { Variant(class), Variant(method), Variant(args)... };
      |                                                                  ^

Apart from that, what do you think about naming it class_call_static instead of class_call_static_method?
Simply because that's consistent with Object::call, which isn't named Object::call_method either.

Its currently being overhauled to return a static callable directly

@Bromeon
Copy link
Contributor

Bromeon commented Jun 11, 2024

Hey, do you plan to pursue this? 🙂

@RadiantUwU
Copy link
Contributor Author

Hey, do you plan to pursue this? 🙂

I do, and its still sitting on my hard drive, untested.

@dsnopek
Copy link
Contributor

dsnopek commented Jun 12, 2024

I just posted godot-cpp PR godotengine/godot-cpp#1485, which should fix the CI issues here, after it's been merged and cherry-picked to the 4.2 branch.

@RadiantUwU
Copy link
Contributor Author

I just posted godot-cpp PR godotengine/godot-cpp#1485, which should fix the CI issues here, after it's been merged and cherry-picked to the 4.2 branch.

Oh i already changed this to create a custom callable instead to provide more flexibility to the users.

@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch 2 times, most recently from 8be03cc to 24e39bd Compare June 12, 2024 17:23
@RadiantUwU RadiantUwU changed the title Implement ClassDB::class_call_static_method Implement ClassDB::class_get_static_method Jun 12, 2024
@Bromeon
Copy link
Contributor

Bromeon commented Jun 12, 2024

This is a different feature though...
Having the possibility to directly call static functions, as an equivalent to Object::call(), is still valuable.

I would also implement that one first, as it's always possible to add a Callable abstraction on top. However, with only the Callable, one needs to go through extra steps (both ergonomics and performance wise) for static calls.

Maybe the two deserve separate pull requests, so they can be discussed independently?

@dsnopek
Copy link
Contributor

dsnopek commented Jun 12, 2024

This new approach is interesting!

However, it is no longer an analog to Object::call() and makes for a sort of mismatched API. If we go with the Callable approach, we could maybe balance it by adding an Object::get_method() that returns a Callable for non-static methods?

Maybe the two deserve separate pull requests, so they can be discussed independently?

I agree. Even though they are functionally equivalent, the exposed API is very different between the two approaches.

@RadiantUwU
Copy link
Contributor Author

I'll definitely put both methods on this pull request then, had no idea many people wanted it like this.
Also, i'm getting errors from the zstd library just so randomly, even though i never changed it.

@Bromeon
Copy link
Contributor

Bromeon commented Jun 12, 2024

I'll definitely put both methods on this pull request then, had no idea many people wanted it like this.

As dsnopek and I mentioned, it's probably better to have two separate pull requests, first one for ClassDB::class_call_static and later one for Callable.

Then, the discussions can flow independently, people can argue pro/con for each approach, and it's possible to merge one without the other, or at different times.

@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch 3 times, most recently from 6b66185 to e2cc14a Compare June 13, 2024 22:25
@RadiantUwU
Copy link
Contributor Author

#93141

@RadiantUwU RadiantUwU marked this pull request as ready for review June 13, 2024 22:27
@RadiantUwU RadiantUwU requested review from a team as code owners June 13, 2024 22:27
@RadiantUwU
Copy link
Contributor Author

I need help with ZStd "macro redefined" even though i never touched it?

@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch from e2cc14a to bd02839 Compare June 13, 2024 22:30
@RadiantUwU
Copy link
Contributor Author

Found the issue, looks like its an improper merge conflict resolution.

@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch 2 times, most recently from 2c326b1 to 85d5df7 Compare June 13, 2024 22:40
@RadiantUwU RadiantUwU force-pushed the add_static_classdb_callables branch from 85d5df7 to 847a823 Compare June 13, 2024 22:45
core/core_bind.cpp Outdated Show resolved Hide resolved
core/core_bind.cpp Outdated Show resolved Hide resolved
core/core_bind.h Outdated Show resolved Hide resolved
core/core_bind.h Outdated Show resolved Hide resolved
core/core_bind.h Outdated Show resolved Hide resolved
core/core_bind.cpp Outdated Show resolved Hide resolved
Co-authored-by: AThousandShips <AThousandShips@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants