summaryrefslogtreecommitdiff
path: root/core/extension
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-09-22 18:33:29 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-09-22 18:33:29 +0200
commitf9ce9a8e103b4b53ad3de032220c3e8799d52409 (patch)
tree0c69f4c5ce2ae3f362cf22adaf2b7bab38d03828 /core/extension
parentf724bd1880ba9633e3f2dd530775dc0535d9cc17 (diff)
[ClassDB] Unify construct/extension retrieval.
Diffstat (limited to 'core/extension')
-rw-r--r--core/extension/gdnative_interface.cpp20
-rw-r--r--core/extension/gdnative_interface.h5
2 files changed, 9 insertions, 16 deletions
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp
index dde8449c3e..ff09b0b86c 100644
--- a/core/extension/gdnative_interface.cpp
+++ b/core/extension/gdnative_interface.cpp
@@ -854,24 +854,19 @@ static GDNativeMethodBindPtr gdnative_classdb_get_method_bind(const char *p_clas
return (GDNativeMethodBindPtr)mb;
}
-static GDNativeClassConstructor gdnative_classdb_get_constructor(const char *p_classname) {
+static GDNativeClassConstructor gdnative_classdb_get_constructor(const char *p_classname, GDNativeExtensionPtr *r_extension) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
if (class_info) {
+ if (r_extension) {
+ *r_extension = class_info->native_extension;
+ }
return (GDNativeClassConstructor)class_info->creation_func;
}
return nullptr;
}
-static GDNativeExtensionPtr gdnative_classdb_get_extension(const char *p_classname) {
- ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
- if (class_info) {
- return (GDNativeExtensionPtr)class_info->native_extension;
- }
- return nullptr;
-}
-
-static GDNativeObjectPtr gdnative_classdb_construct_extended(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension) {
- return (GDNativeObjectPtr)ClassDB::construct_extended((Object * (*)()) p_constructor, (ObjectNativeExtension *)p_extension);
+static GDNativeObjectPtr gdnative_classdb_construct_object(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension) {
+ return (GDNativeObjectPtr)ClassDB::construct_object((Object * (*)()) p_constructor, (ObjectNativeExtension *)p_extension);
}
static void *gdnative_classdb_get_class_tag(const char *p_classname) {
@@ -1022,8 +1017,7 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) {
/* CLASSDB */
gdni.classdb_get_constructor = gdnative_classdb_get_constructor;
- gdni.classdb_get_extension = gdnative_classdb_get_extension;
- gdni.classdb_construct_extended = gdnative_classdb_construct_extended;
+ gdni.classdb_construct_object = gdnative_classdb_construct_object;
gdni.classdb_get_method_bind = gdnative_classdb_get_method_bind;
gdni.classdb_get_class_tag = gdnative_classdb_get_class_tag;
diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h
index 6ab9c8aea3..73f78bde54 100644
--- a/core/extension/gdnative_interface.h
+++ b/core/extension/gdnative_interface.h
@@ -432,9 +432,8 @@ typedef struct {
/* CLASSDB */
- GDNativeClassConstructor (*classdb_get_constructor)(const char *p_classname);
- GDNativeExtensionPtr (*classdb_get_extension)(const char *p_classname);
- GDNativeObjectPtr (*classdb_construct_extended)(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension);
+ GDNativeClassConstructor (*classdb_get_constructor)(const char *p_classname, GDNativeExtensionPtr *r_extension);
+ GDNativeObjectPtr (*classdb_construct_object)(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension);
GDNativeMethodBindPtr (*classdb_get_method_bind)(const char *p_classname, const char *p_methodname, GDNativeInt p_hash);
void *(*classdb_get_class_tag)(const char *p_classname);