diff --git a/modules/mono/SCsub b/modules/mono/SCsub index 0e5dd9b4cf3..e1f5e2ef28b 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -103,6 +103,16 @@ import os def find_nuget_unix(): + import os + + if 'NUGET_PATH' in os.environ: + hint_path = os.environ['NUGET_PATH'] + if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): + return hint_path + hint_path = os.path.join(hint_path, 'nuget') + if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): + return hint_path + import os.path import sys @@ -129,6 +139,16 @@ def find_nuget_unix(): def find_nuget_windows(): + import os + + if 'NUGET_PATH' in os.environ: + hint_path = os.environ['NUGET_PATH'] + if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): + return hint_path + hint_path = os.path.join(hint_path, 'nuget.exe') + if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): + return hint_path + import mono_reg_utils as monoreg mono_root = '' @@ -160,14 +180,6 @@ def find_nuget_windows(): if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - if 'NUGET_PATH' in os.environ: - hint_path = os.environ['NUGET_PATH'] - if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): - return hint_path - hint_path = os.path.join(hint_path, 'nuget.exe') - if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): - return hint_path - return None diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 0a54ed5fbd5..8bc459c4fdd 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -50,6 +50,7 @@ #include "mono_gd/gd_mono_marshal.h" #include "signal_awaiter_utils.h" #include "utils/macros.h" +#include "utils/mutex_utils.h" #include "utils/string_utils.h" #include "utils/thread_local.h" @@ -378,60 +379,72 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { return "object"; if (!ClassDB::class_exists(p_var_type_name)) { - Variant::Type var_types[] = { - Variant::BOOL, - Variant::INT, - Variant::REAL, - Variant::STRING, - Variant::VECTOR2, - Variant::RECT2, - Variant::VECTOR3, - Variant::TRANSFORM2D, - Variant::PLANE, - Variant::QUAT, - Variant::AABB, - Variant::BASIS, - Variant::TRANSFORM, - Variant::COLOR, - Variant::NODE_PATH, - Variant::_RID - }; - - for (int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) { - if (p_var_type_name == Variant::get_type_name(var_types[i])) - return p_var_type_name; - } - - if (p_var_type_name == "String") - return "string"; // I prefer this one >:[ - - // TODO these will be rewritten later into custom containers - - if (p_var_type_name == "Array") - return "object[]"; - - if (p_var_type_name == "Dictionary") - return "Dictionary"; - - if (p_var_type_name == "PoolByteArray") - return "byte[]"; - if (p_var_type_name == "PoolIntArray") - return "int[]"; - if (p_var_type_name == "PoolRealArray") - return "float[]"; - if (p_var_type_name == "PoolStringArray") - return "string[]"; - if (p_var_type_name == "PoolVector2Array") - return "Vector2[]"; - if (p_var_type_name == "PoolVector3Array") - return "Vector3[]"; - if (p_var_type_name == "PoolColorArray") - return "Color[]"; - - return "object"; + return p_var_type_name; } - return p_var_type_name; + if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) + return "Godot.Object"; + + if (p_var_type_name == Variant::get_type_name(Variant::REAL)) { +#ifdef REAL_T_IS_DOUBLE + return "double"; +#else + return "float"; +#endif + } + + if (p_var_type_name == Variant::get_type_name(Variant::STRING)) + return "string"; // I prefer this one >:[ + + if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY)) + return "Collections.Dictionary"; + + if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) + return "Collections.Array"; + + if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY)) + return "byte[]"; + if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY)) + return "int[]"; + if (p_var_type_name == Variant::get_type_name(Variant::POOL_REAL_ARRAY)) { +#ifdef REAL_T_IS_DOUBLE + return "double[]"; +#else + return "float[]"; +#endif + } + if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY)) + return "string[]"; + if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY)) + return "Vector2[]"; + if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY)) + return "Vector3[]"; + if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY)) + return "Color[]"; + + Variant::Type var_types[] = { + Variant::BOOL, + Variant::INT, + Variant::VECTOR2, + Variant::RECT2, + Variant::VECTOR3, + Variant::TRANSFORM2D, + Variant::PLANE, + Variant::QUAT, + Variant::AABB, + Variant::BASIS, + Variant::TRANSFORM, + Variant::COLOR, + Variant::NODE_PATH, + Variant::_RID + }; + + for (int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) { + if (p_var_type_name == Variant::get_type_name(var_types[i])) + return p_var_type_name; + } + + return "object"; } String CSharpLanguage::make_function(const String &, const String &p_name, const PoolStringArray &p_args) const { @@ -507,8 +520,7 @@ Vector CSharpLanguage::stack_trace_get_info(MonoObjec MonoException *exc = NULL; - GDMonoUtils::StackTrace_GetFrames st_get_frames = CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames); - MonoArray *frames = st_get_frames(p_stack_trace, (MonoObject **)&exc); + MonoArray *frames = invoke_method_thunk(CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames), p_stack_trace, (MonoObject **)&exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); @@ -532,7 +544,7 @@ Vector CSharpLanguage::stack_trace_get_info(MonoObjec MonoString *file_name; int file_line_num; MonoString *method_decl; - get_sf_info(frame, &file_name, &file_line_num, &method_decl, (MonoObject **)&exc); + invoke_method_thunk(get_sf_info, frame, &file_name, &file_line_num, &method_decl, (MonoObject **)&exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); @@ -561,10 +573,8 @@ void CSharpLanguage::frame() { MonoObject *task_scheduler = task_scheduler_handle->get_target(); if (task_scheduler) { - GDMonoUtils::GodotTaskScheduler_Activate thunk = CACHED_METHOD_THUNK(GodotTaskScheduler, Activate); - MonoException *exc = NULL; - thunk(task_scheduler, (MonoObject **)&exc); + invoke_method_thunk(CACHED_METHOD_THUNK(GodotTaskScheduler, Activate), task_scheduler, (MonoObject **)&exc); if (exc) { GDMonoUtils::debug_unhandled_exception(exc); @@ -599,23 +609,19 @@ void CSharpLanguage::reload_all_scripts() { #ifdef DEBUG_ENABLED -#ifndef NO_THREADS - lock->lock(); -#endif - List > scripts; - SelfList *elem = script_list.first(); - while (elem) { - if (elem->self()->get_path().is_resource_file()) { - scripts.push_back(Ref(elem->self())); //cast to gdscript to avoid being erased by accident - } - elem = elem->next(); - } + { + SCOPED_MUTEX_LOCK(script_instances_mutex); -#ifndef NO_THREADS - lock->unlock(); -#endif + SelfList *elem = script_list.first(); + while (elem) { + if (elem->self()->get_path().is_resource_file()) { + scripts.push_back(Ref(elem->self())); //cast to gdscript to avoid being erased by accident + } + elem = elem->next(); + } + } //as scripts are going to be reloaded, must proceed without locking here @@ -625,6 +631,7 @@ void CSharpLanguage::reload_all_scripts() { E->get()->load_source_code(E->get()->get_path()); E->get()->reload(true); } + #endif } @@ -634,15 +641,17 @@ void CSharpLanguage::reload_tool_script(const Ref