Merge pull request #75955 from mihe/csharp-gdextension
Fix exception when using base types of extension-based types from C#
This commit is contained in:
commit
46321379ba
2 changed files with 12 additions and 2 deletions
|
@ -66,6 +66,10 @@
|
||||||
|
|
||||||
#define CACHED_STRING_NAME(m_var) (CSharpLanguage::get_singleton()->get_string_names().m_var)
|
#define CACHED_STRING_NAME(m_var) (CSharpLanguage::get_singleton()->get_string_names().m_var)
|
||||||
|
|
||||||
|
// Types that will be skipped over (in favor of their base types) when setting up instance bindings.
|
||||||
|
// This must be a superset of `ignored_types` in bindings_generator.cpp.
|
||||||
|
const Vector<String> ignored_types = { "PhysicsServer2DExtension", "PhysicsServer3DExtension" };
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
static bool _create_project_solution_if_needed() {
|
static bool _create_project_solution_if_needed() {
|
||||||
CRASH_COND(CSharpLanguage::get_singleton()->get_godotsharp_editor() == nullptr);
|
CRASH_COND(CSharpLanguage::get_singleton()->get_godotsharp_editor() == nullptr);
|
||||||
|
@ -1245,11 +1249,16 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
|
||||||
|
|
||||||
StringName type_name = p_object->get_class_name();
|
StringName type_name = p_object->get_class_name();
|
||||||
|
|
||||||
// ¯\_(ツ)_/¯
|
|
||||||
const ClassDB::ClassInfo *classinfo = ClassDB::classes.getptr(type_name);
|
const ClassDB::ClassInfo *classinfo = ClassDB::classes.getptr(type_name);
|
||||||
while (classinfo && !classinfo->exposed) {
|
|
||||||
|
// This skipping of GDExtension classes, as well as whatever classes are in this list of ignored types, is a
|
||||||
|
// workaround to allow GDExtension classes to be used from C# so long as they're only used through base classes that
|
||||||
|
// are registered from the engine. This will likely need to be removed whenever proper support for GDExtension
|
||||||
|
// classes is added to C#. See #75955 for more details.
|
||||||
|
while (classinfo && (!classinfo->exposed || classinfo->gdextension || ignored_types.has(classinfo->name))) {
|
||||||
classinfo = classinfo->inherits_ptr;
|
classinfo = classinfo->inherits_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_FAIL_NULL_V(classinfo, false);
|
ERR_FAIL_NULL_V(classinfo, false);
|
||||||
type_name = classinfo->name;
|
type_name = classinfo->name;
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ StringBuilder &operator<<(StringBuilder &r_sb, const char *p_cstring) {
|
||||||
#define C_METHOD_MANAGED_FROM_SIGNAL C_NS_MONOMARSHAL ".ConvertSignalToManaged"
|
#define C_METHOD_MANAGED_FROM_SIGNAL C_NS_MONOMARSHAL ".ConvertSignalToManaged"
|
||||||
|
|
||||||
// Types that will be ignored by the generator and won't be available in C#.
|
// Types that will be ignored by the generator and won't be available in C#.
|
||||||
|
// This must be kept in sync with `ignored_types` in csharp_script.cpp
|
||||||
const Vector<String> ignored_types = { "PhysicsServer2DExtension", "PhysicsServer3DExtension" };
|
const Vector<String> ignored_types = { "PhysicsServer2DExtension", "PhysicsServer3DExtension" };
|
||||||
|
|
||||||
void BindingsGenerator::TypeInterface::postsetup_enum_type(BindingsGenerator::TypeInterface &r_enum_itype) {
|
void BindingsGenerator::TypeInterface::postsetup_enum_type(BindingsGenerator::TypeInterface &r_enum_itype) {
|
||||||
|
|
Loading…
Reference in a new issue