diff options
| author | David Snopek <dsnopek@gmail.com> | 2024-01-30 11:25:25 -0600 |
|---|---|---|
| committer | David Snopek <dsnopek@gmail.com> | 2024-02-12 13:30:07 -0600 |
| commit | 8fbb7cf79535a2b382d57ce2a094d4cbee316fd1 (patch) | |
| tree | 3b3ea3c4c80911752073ba50920600a348ab81de /include/godot_cpp/core | |
| parent | 36847f6af0be548bae96429fa84d59f407b51582 (diff) | |
| download | redot-cpp-8fbb7cf79535a2b382d57ce2a094d4cbee316fd1.tar.gz | |
Allow GDExtensions to register virtual methods and call them on scripts
Diffstat (limited to 'include/godot_cpp/core')
| -rw-r--r-- | include/godot_cpp/core/class_db.hpp | 3 | ||||
| -rw-r--r-- | include/godot_cpp/core/object.hpp | 2 | ||||
| -rw-r--r-- | include/godot_cpp/core/property_info.hpp | 11 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index af394f0..e5bccf3 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -165,7 +165,10 @@ public: static void add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); static void add_signal(const StringName &p_class, const MethodInfo &p_signal); static void bind_integer_constant(const StringName &p_class_name, const StringName &p_enum_name, const StringName &p_constant_name, GDExtensionInt p_constant_value, bool p_is_bitfield = false); + // Binds an implementation of a virtual method defined in Godot. static void bind_virtual_method(const StringName &p_class, const StringName &p_method, GDExtensionClassCallVirtual p_call); + // Add a new virtual method that can be implemented by scripts. + static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, const Vector<StringName> &p_arg_names = Vector<StringName>()); static MethodBind *get_method(const StringName &p_class, const StringName &p_method); diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index 79f8fbf..c1f1069 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -68,6 +68,8 @@ struct MethodInfo { int id = 0; std::vector<PropertyInfo> arguments; std::vector<Variant> default_arguments; + GDExtensionClassMethodArgumentMetadata return_val_metadata; + std::vector<GDExtensionClassMethodArgumentMetadata> arguments_metadata; inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; } inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); } diff --git a/include/godot_cpp/core/property_info.hpp b/include/godot_cpp/core/property_info.hpp index 0ecfa32..f610f3f 100644 --- a/include/godot_cpp/core/property_info.hpp +++ b/include/godot_cpp/core/property_info.hpp @@ -80,6 +80,17 @@ struct PropertyInfo { p_info->usage = usage; *(reinterpret_cast<StringName *>(p_info->class_name)) = class_name; } + + GDExtensionPropertyInfo _to_gdextension() const { + return { + (GDExtensionVariantType)type, + name._native_ptr(), + class_name._native_ptr(), + hint, + hint_string._native_ptr(), + usage, + }; + } }; } // namespace godot |
