feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -148,7 +148,7 @@ void CSharpLanguage::finalize() {
finalizing = true;
// Make sure all script binding gchandles are released before finalizing GDMono
// Make sure all script binding gchandles are released before finalizing GDMono.
for (KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) {
CSharpScriptBinding &script_binding = E.value;
@ -156,6 +156,10 @@ void CSharpLanguage::finalize() {
script_binding.gchandle.release();
script_binding.inited = false;
}
// Make sure we clear all the instance binding callbacks so they don't get called
// after finalizing the C# language.
script_binding.owner->free_instance_binding(this);
}
if (gdmono) {
@ -441,9 +445,9 @@ bool CSharpLanguage::handles_global_class_type(const String &p_type) const {
return p_type == get_type();
}
String CSharpLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
String CSharpLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path, bool *r_is_abstract, bool *r_is_tool) const {
String class_name;
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetGlobalClassName(&p_path, r_base_type, r_icon_path, &class_name);
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetGlobalClassName(&p_path, r_base_type, r_icon_path, r_is_abstract, r_is_tool, &class_name);
return class_name;
}
@ -496,8 +500,8 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info()
}
_recursion_flag_ = true;
SCOPE_EXIT {
_recursion_flag_ = false;
};
_recursion_flag_ = false; // clang-format off
}; // clang-format on
if (!gdmono || !gdmono->is_runtime_initialized()) {
return Vector<StackInfo>();
@ -1227,6 +1231,11 @@ void CSharpLanguage::_instance_binding_free_callback(void *, void *, void *p_bin
}
GDExtensionBool CSharpLanguage::_instance_binding_reference_callback(void *p_token, void *p_binding, GDExtensionBool p_reference) {
// Instance bindings callbacks can only be called if the C# language is available.
// Failing this assert usually means that we didn't clear the instance binding in some Object
// and the C# language has already been finalized.
DEV_ASSERT(CSharpLanguage::get_singleton() != nullptr);
CRASH_COND(!p_binding);
CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)p_binding)->get();
@ -1464,14 +1473,14 @@ Object *CSharpInstance::get_owner() {
}
bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(!script.is_valid(), false);
ERR_FAIL_COND_V(script.is_null(), false);
return GDMonoCache::managed_callbacks.CSharpInstanceBridge_Set(
gchandle.get_intptr(), &p_name, &p_value);
}
bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
ERR_FAIL_COND_V(!script.is_valid(), false);
ERR_FAIL_COND_V(script.is_null(), false);
Variant ret_value;
@ -1488,12 +1497,24 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
List<PropertyInfo> props;
script->get_script_property_list(&props);
ERR_FAIL_COND(script.is_null());
#ifdef TOOLS_ENABLED
for (const PropertyInfo &prop : script->exported_members_cache) {
props.push_back(prop);
}
#else
for (const KeyValue<StringName, PropertyInfo> &E : script->member_info) {
props.push_front(E.value);
}
#endif
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_back(prop);
}
// Call _get_property_list
ERR_FAIL_COND(!script.is_valid());
StringName method = SNAME("_get_property_list");
Variant ret;
@ -1515,9 +1536,25 @@ void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
}
}
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_back(prop);
CSharpScript *top = script.ptr()->base_script.ptr();
while (top != nullptr) {
props.clear();
#ifdef TOOLS_ENABLED
for (const PropertyInfo &prop : top->exported_members_cache) {
props.push_back(prop);
}
#else
for (const KeyValue<StringName, PropertyInfo> &E : top->member_info) {
props.push_front(E.value);
}
#endif
for (PropertyInfo &prop : props) {
validate_property(prop);
p_properties->push_back(prop);
}
top = top->base_script.ptr();
}
}
@ -1537,7 +1574,7 @@ Variant::Type CSharpInstance::get_property_type(const StringName &p_name, bool *
}
bool CSharpInstance::property_can_revert(const StringName &p_name) const {
ERR_FAIL_COND_V(!script.is_valid(), false);
ERR_FAIL_COND_V(script.is_null(), false);
Variant name_arg = p_name;
const Variant *args[1] = { &name_arg };
@ -1555,7 +1592,7 @@ bool CSharpInstance::property_can_revert(const StringName &p_name) const {
}
void CSharpInstance::validate_property(PropertyInfo &p_property) const {
ERR_FAIL_COND(!script.is_valid());
ERR_FAIL_COND(script.is_null());
Variant property_arg = (Dictionary)p_property;
const Variant *args[1] = { &property_arg };
@ -1573,7 +1610,7 @@ void CSharpInstance::validate_property(PropertyInfo &p_property) const {
}
bool CSharpInstance::property_get_revert(const StringName &p_name, Variant &r_ret) const {
ERR_FAIL_COND_V(!script.is_valid(), false);
ERR_FAIL_COND_V(script.is_null(), false);
Variant name_arg = p_name;
const Variant *args[1] = { &name_arg };
@ -1600,7 +1637,7 @@ void CSharpInstance::get_method_list(List<MethodInfo> *p_list) const {
}
bool CSharpInstance::has_method(const StringName &p_method) const {
if (!script.is_valid()) {
if (script.is_null()) {
return false;
}
@ -1641,7 +1678,7 @@ int CSharpInstance::get_method_argument_count(const StringName &p_method, bool *
}
Variant CSharpInstance::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
ERR_FAIL_COND_V(!script.is_valid(), Variant());
ERR_FAIL_COND_V(script.is_null(), Variant());
Variant ret;
GDMonoCache::managed_callbacks.CSharpInstanceBridge_Call(
@ -1662,7 +1699,7 @@ bool CSharpInstance::_reference_owner_unsafe() {
// but the managed instance is alive, the refcount will be 1 instead of 0.
// See: _unreference_owner_unsafe()
// May not me referenced yet, so we must use init_ref() instead of reference()
// May not be referenced yet, so we must use init_ref() instead of reference()
if (static_cast<RefCounted *>(owner)->init_ref()) {
CSharpLanguage::get_singleton()->post_unsafe_reference(owner);
unsafe_referenced = true;
@ -2291,7 +2328,7 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
bool CSharpScript::can_instantiate() const {
#ifdef TOOLS_ENABLED
bool extra_cond = type_info.is_tool || ScriptServer::is_scripting_enabled();
bool extra_cond = (type_info.is_tool || ScriptServer::is_scripting_enabled()) && !Engine::get_singleton()->is_recovery_mode_hint();
#else
bool extra_cond = true;
#endif
@ -2307,9 +2344,7 @@ bool CSharpScript::can_instantiate() const {
}
StringName CSharpScript::get_instance_base_type() const {
StringName native_name;
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetScriptNativeName(this, &native_name);
return native_name;
return type_info.native_base_name;
}
CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error) {
@ -2351,8 +2386,8 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
if (!ok) {
// Important to clear this before destroying the script instance here
instance->script = Ref<CSharpScript>();
instance->owner = nullptr;
p_owner->set_script_instance(nullptr);
instance->owner = nullptr;
return nullptr;
}
@ -2707,7 +2742,7 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
return -1;
}
const Variant CSharpScript::get_rpc_config() const {
Variant CSharpScript::get_rpc_config() const {
return rpc_config;
}
@ -2780,16 +2815,16 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
if (p_path.begins_with("csharp://")) {
// This is a virtual path used by generic types, extract the real path.
real_path = "res://" + p_path.trim_prefix("csharp://");
real_path = real_path.substr(0, real_path.rfind(":"));
real_path = real_path.substr(0, real_path.rfind_char(':'));
}
Ref<CSharpScript> scr;
if (GDMonoCache::godot_api_cache_updated) {
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetOrCreateScriptBridgeForPath(&p_path, &scr);
ERR_FAIL_NULL_V_MSG(scr, Ref<Resource>(), "Could not create C# script '" + real_path + "'.");
ERR_FAIL_COND_V_MSG(scr.is_null(), Ref<Resource>(), "Could not create C# script '" + real_path + "'.");
} else {
scr = Ref<CSharpScript>(memnew(CSharpScript));
scr.instantiate();
}
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)