-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restored groupedText renderer added Ref<T> patch. Need godotengine/godot#69902 to work
- Loading branch information
1 parent
17f22bd
commit 7133097
Showing
15 changed files
with
292 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
diff --git a/godot-headers/godot/gdnative_interface.h b/godot-headers/godot/gdnative_interface.h | ||
index 486f5be..e4fcc9c 100644 | ||
--- a/godot-headers/godot/gdnative_interface.h | ||
+++ b/godot-headers/godot/gdnative_interface.h | ||
@@ -154,6 +154,8 @@ typedef const void *GDNativeMethodBindPtr; | ||
typedef int64_t GDNativeInt; | ||
typedef uint8_t GDNativeBool; | ||
typedef uint64_t GDObjectInstanceID; | ||
+typedef void *GDExtensionRefPtr; | ||
+typedef const void *GDExtensionConstRefPtr; | ||
|
||
/* VARIANT DATA I/O */ | ||
|
||
@@ -551,6 +553,10 @@ typedef struct { | ||
GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); | ||
GDObjectInstanceID (*object_get_instance_id)(GDNativeConstObjectPtr p_object); | ||
|
||
+ /* REFERENCE */ | ||
+ GDNativeObjectPtr (*ref_get_object)(GDExtensionConstRefPtr p_ref); | ||
+ void (*ref_set_object)(GDExtensionRefPtr p_ref, GDNativeObjectPtr p_object); | ||
+ | ||
/* SCRIPT INSTANCE */ | ||
|
||
GDNativeScriptInstancePtr (*script_instance_create)(const GDNativeExtensionScriptInstanceInfo *p_info, GDNativeExtensionScriptInstanceDataPtr p_instance_data); | ||
diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp | ||
index cc7f2d6..470aa83 100644 | ||
--- a/include/godot_cpp/classes/ref.hpp | ||
+++ b/include/godot_cpp/classes/ref.hpp | ||
@@ -240,13 +240,24 @@ public: | ||
template <class T> | ||
struct PtrToArg<Ref<T>> { | ||
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) { | ||
- return Ref<T>(reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast<GDNativeObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks))); | ||
+ GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr; | ||
+ ERR_FAIL_NULL_V(ref, Ref<T>()); | ||
+ | ||
+ T *obj = reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(godot::internal::gdn_interface->ref_get_object(ref), godot::internal::token, &T::___binding_callbacks)); | ||
+ return Ref<T>(obj); | ||
} | ||
|
||
typedef Ref<T> EncodeT; | ||
|
||
_FORCE_INLINE_ static void encode(Ref<T> p_val, void *p_ptr) { | ||
- *reinterpret_cast<const GodotObject **>(p_ptr) = p_val->_owner; | ||
+ GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr; | ||
+ ERR_FAIL_NULL(ref); | ||
+ | ||
+ // This code assumes that p_ptr points to an unset Ref<T> variable on the Godot side | ||
+ // so we only set it if we have an object to set. | ||
+ if (p_val.is_valid()) { | ||
+ godot::internal::gdn_interface->ref_set_object(ref, p_val->_owner); | ||
+ } | ||
} | ||
}; | ||
|
||
-- | ||
2.33.0.windows.2 | ||
|
Oops, something went wrong.