-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Add static method support to ClassDB #59314
Add static method support to ClassDB #59314
Conversation
cbe529a
to
69bfb21
Compare
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index 31af28b783..9acc28f51e 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -666,6 +666,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
Dictionary d2;
d2["name"] = String(method_name);
d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false;
+ d2["is_static"] = (F.flags & METHOD_FLAG_STATIC) ? true : false;
d2["is_vararg"] = false;
d2["is_virtual"] = true;
// virtual functions have no hash since no MethodBind is involved
@@ -708,6 +709,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
d2["is_const"] = method->is_const();
d2["is_vararg"] = method->is_vararg();
+ d2["is_static"] = method->is_static();
d2["is_virtual"] = false;
d2["hash"] = method->get_hash();
A few extra changes required for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs amending as suggested by @bruvzg, otherwise the code seems fine to me. Compiled locally and didn't notice any obvious issue (as mentioned the File.file_exists
static method added in this PR doesn't work in GDScript yet, but it's still usable as non-static).
@bruvzg great catch, thanks! |
* Based on the work done for Variant in the past. * Added `ClassDB::bind_static_method` * Cleaned up ClassDB::bind_method to use variadic templates. This adds support for having static methods in Object derived classes. Note that this does not make it work yet in GDScript or Mono and, while it works for GDExtension, GodotCPP needs to be updated.
69bfb21
to
2f65127
Compare
Thanks! |
ClassDB::bind_static_method
This adds support for having static methods in Object derived classes.
Note that this does not make it work yet in GDScript, Visual Script or Mono and, while it works for GDExtension, GodotCPP needs to be updated.