summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Gilleron <marc.gilleron@gmail.com>2023-07-20 21:40:41 +0100
committerMarc Gilleron <marc.gilleron@gmail.com>2023-07-26 20:12:25 +0100
commitbaf0b9e0f73d10dfab07189fc12c4ed0906eedf0 (patch)
tree325e38acb4b3273dee1237da1aebd72c2e3a1d4e /src
parent749b0b9ae03ecac470027b17c6414e7a0e730923 (diff)
downloadredot-cpp-baf0b9e0f73d10dfab07189fc12c4ed0906eedf0.tar.gz
Don't call parent _get_property_list when a class doesn't define it.
Godot is already supposed to call _get_property_list of parent classes, so this binding function must really only return procedural properties of the class it belongs to, and not parent or child classes.
Diffstat (limited to 'src')
-rw-r--r--src/classes/wrapped.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp
index 62088a5..1e9239c 100644
--- a/src/classes/wrapped.cpp
+++ b/src/classes/wrapped.cpp
@@ -60,4 +60,33 @@ void postinitialize_handler(Wrapped *p_wrapped) {
p_wrapped->_postinitialize();
}
+namespace internal {
+
+GDExtensionPropertyInfo *create_c_property_list(const ::godot::List<::godot::PropertyInfo> &plist_cpp, uint32_t *r_size) {
+ GDExtensionPropertyInfo *plist = nullptr;
+ // Linked list size can be expensive to get so we cache it
+ const uint32_t plist_size = plist_cpp.size();
+ if (r_size != nullptr) {
+ *r_size = plist_size;
+ }
+ plist = reinterpret_cast<GDExtensionPropertyInfo *>(memalloc(sizeof(GDExtensionPropertyInfo) * plist_size));
+ unsigned int i = 0;
+ for (const ::godot::PropertyInfo &E : plist_cpp) {
+ plist[i].type = static_cast<GDExtensionVariantType>(E.type);
+ plist[i].name = E.name._native_ptr();
+ plist[i].hint = E.hint;
+ plist[i].hint_string = E.hint_string._native_ptr();
+ plist[i].class_name = E.class_name._native_ptr();
+ plist[i].usage = E.usage;
+ ++i;
+ }
+ return plist;
+}
+
+void free_c_property_list(GDExtensionPropertyInfo *plist) {
+ memfree(plist);
+}
+
+} // namespace internal
+
} // namespace godot