Ensure that PtrToArg specializations for native structs are used
(cherry picked from commit 3cd3f24150
)
pull/1244/head
parent
354ed1e79d
commit
dcd7a69512
|
@ -1142,6 +1142,12 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||||
else:
|
else:
|
||||||
fully_used_classes.add("Wrapped")
|
fully_used_classes.add("Wrapped")
|
||||||
|
|
||||||
|
# In order to ensure that PtrToArg specializations for native structs are
|
||||||
|
# always used, let's move any of them into 'fully_used_classes'.
|
||||||
|
for type_name in used_classes:
|
||||||
|
if is_struct_type(type_name) and not is_included_struct_type(type_name):
|
||||||
|
fully_used_classes.add(type_name)
|
||||||
|
|
||||||
for type_name in fully_used_classes:
|
for type_name in fully_used_classes:
|
||||||
if type_name in used_classes:
|
if type_name in used_classes:
|
||||||
used_classes.remove(type_name)
|
used_classes.remove(type_name)
|
||||||
|
|
|
@ -168,6 +168,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct PtrToArg<T *> {
|
struct PtrToArg<T *> {
|
||||||
|
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
||||||
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
||||||
return reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
|
return reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
|
||||||
}
|
}
|
||||||
|
@ -179,6 +180,7 @@ struct PtrToArg<T *> {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct PtrToArg<const T *> {
|
struct PtrToArg<const T *> {
|
||||||
|
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
|
||||||
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
||||||
return reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
|
return reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr))));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue