summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-18 17:40:39 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-18 17:40:39 +0200
commit57c868483a3f2c9da7764e694a03eee9bcc50f2a (patch)
treee612709444a9bf3c02442caab554493f2adef890
parent84dcdde9088d512efebb0033fb881d8f7fd9c107 (diff)
parent949d24b38838109e5a6385bbe193a1d252f6ef7e (diff)
downloadredot-engine-57c868483a3f2c9da7764e694a03eee9bcc50f2a.tar.gz
Merge pull request #90703 from ZerxZ/core/classdb_get_api_type
Expose `ClassDB.class_get_api_type()` method
-rw-r--r--core/core_bind.cpp15
-rw-r--r--core/core_bind.h11
-rw-r--r--doc/classes/ClassDB.xml24
3 files changed, 49 insertions, 1 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index b27981d56b..bbfbb6e3cd 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -1419,6 +1419,11 @@ Variant ClassDB::instantiate(const StringName &p_class) const {
}
}
+ClassDB::APIType ClassDB::class_get_api_type(const StringName &p_class) const {
+ ::ClassDB::APIType api_type = ::ClassDB::get_api_type(p_class);
+ return (APIType)api_type;
+}
+
bool ClassDB::class_has_signal(const StringName &p_class, const StringName &p_signal) const {
return ::ClassDB::has_signal(p_class, p_signal);
}
@@ -1615,7 +1620,7 @@ void ClassDB::get_argument_options(const StringName &p_function, int p_idx, List
pf == "class_has_method" || pf == "class_get_method_list" ||
pf == "class_get_integer_constant_list" || pf == "class_has_integer_constant" || pf == "class_get_integer_constant" ||
pf == "class_has_enum" || pf == "class_get_enum_list" || pf == "class_get_enum_constants" || pf == "class_get_integer_constant_enum" ||
- pf == "is_class_enabled" || pf == "is_class_enum_bitfield");
+ pf == "is_class_enabled" || pf == "is_class_enum_bitfield" || pf == "class_get_api_type");
}
if (first_argument_is_class || pf == "is_parent_class") {
for (const String &E : get_class_list()) {
@@ -1636,6 +1641,8 @@ void ClassDB::_bind_methods() {
::ClassDB::bind_method(D_METHOD("can_instantiate", "class"), &ClassDB::can_instantiate);
::ClassDB::bind_method(D_METHOD("instantiate", "class"), &ClassDB::instantiate);
+ ::ClassDB::bind_method(D_METHOD("class_get_api_type", "class"), &ClassDB::class_get_api_type);
+
::ClassDB::bind_method(D_METHOD("class_has_signal", "class", "signal"), &ClassDB::class_has_signal);
::ClassDB::bind_method(D_METHOD("class_get_signal", "class", "signal"), &ClassDB::class_get_signal);
::ClassDB::bind_method(D_METHOD("class_get_signal_list", "class", "no_inheritance"), &ClassDB::class_get_signal_list, DEFVAL(false));
@@ -1669,6 +1676,12 @@ void ClassDB::_bind_methods() {
::ClassDB::bind_method(D_METHOD("is_class_enum_bitfield", "class", "enum", "no_inheritance"), &ClassDB::is_class_enum_bitfield, DEFVAL(false));
::ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &ClassDB::is_class_enabled);
+
+ BIND_ENUM_CONSTANT(API_CORE);
+ BIND_ENUM_CONSTANT(API_EDITOR);
+ BIND_ENUM_CONSTANT(API_EXTENSION);
+ BIND_ENUM_CONSTANT(API_EDITOR_EXTENSION);
+ BIND_ENUM_CONSTANT(API_NONE);
}
} // namespace special
diff --git a/core/core_bind.h b/core/core_bind.h
index 7e2686c848..2a31e64425 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -447,6 +447,14 @@ protected:
static void _bind_methods();
public:
+ enum APIType {
+ API_CORE,
+ API_EDITOR,
+ API_EXTENSION,
+ API_EDITOR_EXTENSION,
+ API_NONE,
+ };
+
PackedStringArray get_class_list() const;
PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
StringName get_parent_class(const StringName &p_class) const;
@@ -455,6 +463,7 @@ public:
bool can_instantiate(const StringName &p_class) const;
Variant instantiate(const StringName &p_class) const;
+ APIType class_get_api_type(const StringName &p_class) const;
bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
@@ -634,4 +643,6 @@ VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyEndType);
VARIANT_ENUM_CAST(core_bind::Thread::Priority);
+VARIANT_ENUM_CAST(core_bind::special::ClassDB::APIType);
+
#endif // CORE_BIND_H
diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml
index 99d0c9be84..d1b666097c 100644
--- a/doc/classes/ClassDB.xml
+++ b/doc/classes/ClassDB.xml
@@ -31,6 +31,13 @@
Returns whether the specified [param class] is available or not.
</description>
</method>
+ <method name="class_get_api_type" qualifiers="const">
+ <return type="int" enum="ClassDB.APIType" />
+ <param index="0" name="class" type="StringName" />
+ <description>
+ Returns the API type of [param class]. See [enum APIType].
+ </description>
+ </method>
<method name="class_get_enum_constants" qualifiers="const">
<return type="PackedStringArray" />
<param index="0" name="class" type="StringName" />
@@ -242,4 +249,21 @@
</description>
</method>
</methods>
+ <constants>
+ <constant name="API_CORE" value="0" enum="APIType">
+ Native Core class type.
+ </constant>
+ <constant name="API_EDITOR" value="1" enum="APIType">
+ Native Editor class type.
+ </constant>
+ <constant name="API_EXTENSION" value="2" enum="APIType">
+ GDExtension class type.
+ </constant>
+ <constant name="API_EDITOR_EXTENSION" value="3" enum="APIType">
+ GDExtension Editor class type.
+ </constant>
+ <constant name="API_NONE" value="4" enum="APIType">
+ Unknown class type.
+ </constant>
+ </constants>
</class>