summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/classes
diff options
context:
space:
mode:
authorEmmanuel Leblond <emmanuel.leblond@gmail.com>2022-10-22 19:42:48 +0200
committerEmmanuel Leblond <emmanuel.leblond@gmail.com>2022-11-08 21:44:31 +0100
commite24b6b0e517bbebe4ed98d9736c0c7219c418b99 (patch)
treea4336d63d7ce00e6155b80881c4d7348d3ac51c7 /include/godot_cpp/classes
parent0e81f89dd3ea7418573075a716dcdd94b73e8621 (diff)
downloadredot-cpp-e24b6b0e517bbebe4ed98d9736c0c7219c418b99.tar.gz
Use StringName in the whole GDExtension API instead of const char *
Diffstat (limited to 'include/godot_cpp/classes')
-rw-r--r--include/godot_cpp/classes/ref.hpp8
-rw-r--r--include/godot_cpp/classes/wrapped.hpp17
2 files changed, 10 insertions, 15 deletions
diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp
index 16e418d..21171d7 100644
--- a/include/godot_cpp/classes/ref.hpp
+++ b/include/godot_cpp/classes/ref.hpp
@@ -264,8 +264,8 @@ struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>
static const GDNativeVariantType VARIANT_TYPE = GDNATIVE_VARIANT_TYPE_OBJECT;
static const GDNativeExtensionClassMethodArgumentMetadata METADATA = GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE;
- static inline GDNativePropertyInfo get_class_info() {
- return make_property_info(GDNATIVE_VARIANT_TYPE_OBJECT, T::get_class_static());
+ static inline PropertyInfo get_class_info() {
+ return make_property_info(Variant::Type::OBJECT, T::get_class_static());
}
};
@@ -274,8 +274,8 @@ struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>
static const GDNativeVariantType VARIANT_TYPE = GDNATIVE_VARIANT_TYPE_OBJECT;
static const GDNativeExtensionClassMethodArgumentMetadata METADATA = GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE;
- static inline GDNativePropertyInfo get_class_info() {
- return make_property_info(GDNATIVE_VARIANT_TYPE_OBJECT, T::get_class_static());
+ static inline PropertyInfo get_class_info() {
+ return make_property_info(Variant::Type::OBJECT, T::get_class_static());
}
};
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index 128e091..83c4cc3 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -49,7 +49,7 @@ class Wrapped {
friend void postinitialize_handler(Wrapped *);
protected:
- virtual const StringName *_get_extension_class() const; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
+ virtual const StringName *_get_extension_class_name() const; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
virtual const GDNativeInstanceBindingCallbacks *_get_bindings_callbacks() const = 0;
void _notification(int p_what){};
@@ -106,7 +106,7 @@ private:
friend class ::godot::ClassDB; \
\
protected: \
- virtual const StringName *_get_extension_class() const override { \
+ virtual const StringName *_get_extension_class_name() const override { \
static StringName string_name = get_class_static(); \
return &string_name; \
} \
@@ -171,7 +171,7 @@ public:
return string_name; \
} \
\
- static StringName *get_parent_class_static() { \
+ static StringName get_parent_class_static() { \
return m_inherits::get_class_static(); \
} \
\
@@ -223,10 +223,10 @@ public:
cls->plist_size = 0; \
for (const ::godot::PropertyInfo &E : list) { \
cls->plist[cls->plist_size].type = static_cast<GDNativeVariantType>(E.type); \
- cls->plist[cls->plist_size].name = _alloc_and_copy_cstr(E.name.utf8().get_data()); \
+ cls->plist[cls->plist_size].name = E.name._native_ptr(); \
cls->plist[cls->plist_size].hint = E.hint; \
- cls->plist[cls->plist_size].hint_string = _alloc_and_copy_cstr(E.hint_string.utf8().get_data()); \
- cls->plist[cls->plist_size].class_name = _alloc_and_copy_cstr(E.class_name.utf8().get_data()); \
+ cls->plist[cls->plist_size].hint_string = E.hint_string._native_ptr(); \
+ cls->plist[cls->plist_size].class_name = E.class_name._native_ptr(); \
cls->plist[cls->plist_size].usage = E.usage; \
cls->plist_size++; \
} \
@@ -243,11 +243,6 @@ public:
if (p_instance) { \
m_class *cls = reinterpret_cast<m_class *>(p_instance); \
ERR_FAIL_COND_MSG(cls->plist == nullptr, "Internal error, property list double free!"); \
- for (size_t i = 0; i < cls->plist_size; i++) { \
- memfree(const_cast<char *>(cls->plist[i].name)); \
- memfree(const_cast<char *>(cls->plist[i].class_name)); \
- memfree(const_cast<char *>(cls->plist[i].hint_string)); \
- } \
memfree(cls->plist); \
cls->plist = nullptr; \
cls->plist_size = 0; \