diff --git a/Source/Editor/Utilities/EditorUtilities.cpp b/Source/Editor/Utilities/EditorUtilities.cpp index 8e3fc0e4a..4ad415c3d 100644 --- a/Source/Editor/Utilities/EditorUtilities.cpp +++ b/Source/Editor/Utilities/EditorUtilities.cpp @@ -394,8 +394,7 @@ bool EditorUtilities::UpdateExeIcon(const String& path, const TextureData& icon) // - icon/cursor/etc data std::fstream stream; - StringAsANSI<> pathAnsi(path.Get()); - stream.open(pathAnsi.Get(), std::ios::in | std::ios::out | std::ios::binary); + stream.open(path.Get(), std::ios::in | std::ios::out | std::ios::binary); if (!stream.is_open()) { LOG(Warning, "Cannot open file"); diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp index 5b93ab588..1a57c4f10 100644 --- a/Source/Engine/Engine/Engine.cpp +++ b/Source/Engine/Engine/Engine.cpp @@ -596,11 +596,13 @@ void EngineImpl::InitPaths() Globals::ProjectCacheFolder = Globals::ProjectFolder / TEXT("Cache"); #endif +#if USE_MONO // We must ensure that engine is located in folder which path contains only ANSI characters // Why? Mono lib must have etc and lib folders at ANSI path // But project can be located on Unicode path if (!Globals::StartupFolder.IsANSI()) Platform::Fatal(TEXT("Cannot start application in directory which name contains non-ANSI characters.")); +#endif #if !PLATFORM_SWITCH && !FLAX_TESTS // Setup directories diff --git a/Source/Engine/Engine/NativeInterop.Unmanaged.cs b/Source/Engine/Engine/NativeInterop.Unmanaged.cs index 2094a528f..0391974b6 100644 --- a/Source/Engine/Engine/NativeInterop.Unmanaged.cs +++ b/Source/Engine/Engine/NativeInterop.Unmanaged.cs @@ -188,7 +188,7 @@ namespace FlaxEngine.Interop internal static void RegisterNativeLibrary(IntPtr moduleNamePtr, IntPtr modulePathPtr) { string moduleName = Marshal.PtrToStringAnsi(moduleNamePtr); - string modulePath = Marshal.PtrToStringAnsi(modulePathPtr); + string modulePath = Marshal.PtrToStringUni(modulePathPtr); libraryPaths[moduleName] = modulePath; } diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp index a111ae337..3d35983fd 100644 --- a/Source/Engine/Scripting/Runtime/DotNet.cpp +++ b/Source/Engine/Scripting/Runtime/DotNet.cpp @@ -202,10 +202,10 @@ FORCE_INLINE RetType CallStaticMethod(void* methodPtr, Args... args) return ((fun)methodPtr)(args...); } -void RegisterNativeLibrary(const char* moduleName, const char* modulePath) +void RegisterNativeLibrary(const char* moduleName, const Char* modulePath) { static void* RegisterNativeLibraryPtr = GetStaticMethodPointer(TEXT("RegisterNativeLibrary")); - CallStaticMethod(RegisterNativeLibraryPtr, moduleName, modulePath); + CallStaticMethod(RegisterNativeLibraryPtr, moduleName, modulePath); } bool InitHostfxr(); @@ -287,7 +287,7 @@ bool MCore::LoadEngine() flaxLibraryPath = ::String(StringUtils::GetDirectoryName(Platform::GetExecutableFilePath())) / StringUtils::GetFileName(flaxLibraryPath); } #endif - RegisterNativeLibrary("FlaxEngine", StringAnsi(flaxLibraryPath).Get()); + RegisterNativeLibrary("FlaxEngine", flaxLibraryPath.Get()); MRootDomain = New("Root"); MDomains.Add(MRootDomain); @@ -730,7 +730,6 @@ DEFINE_INTERNAL_CALL(void) NativeInterop_CreateClass(NativeClassDefinitions* man StringAnsi assemblyName; StringAnsi assemblyFullName; GetAssemblyName(assemblyHandle, assemblyName, assemblyFullName); - assembly = New(nullptr, assemblyName, assemblyFullName, assemblyHandle); CachedAssemblyHandles.Add(assemblyHandle, assembly); } @@ -797,7 +796,7 @@ bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePa if (nativePath.HasChars()) { StringAnsi nativeName = _name.EndsWith(".CSharp") ? StringAnsi(_name.Get(), _name.Length() - 7) : StringAnsi(_name); - RegisterNativeLibrary(nativeName.Get(), StringAnsi(nativePath).Get()); + RegisterNativeLibrary(nativeName.Get(), nativePath.Get()); } #if USE_EDITOR // Register the editor module location for Assembly resolver @@ -1223,9 +1222,9 @@ MException::~MException() MField::MField(MClass* parentClass, void* handle, const char* name, void* type, int fieldOffset, MFieldAttributes attributes) : _handle(handle) , _type(type) + , _fieldOffset(fieldOffset) , _parentClass(parentClass) , _name(name) - , _fieldOffset(fieldOffset) , _hasCachedAttributes(false) { switch (attributes & MFieldAttributes::FieldAccessMask) @@ -1366,19 +1365,22 @@ MMethod::MMethod(MClass* parentClass, StringAnsi&& name, void* handle, int32 par void MMethod::CacheSignature() const { - _hasCachedSignature = true; + ScopeLock lock(BinaryModule::Locker); + if (_hasCachedSignature) + return; static void* GetMethodReturnTypePtr = GetStaticMethodPointer(TEXT("GetMethodReturnType")); static void* GetMethodParameterTypesPtr = GetStaticMethodPointer(TEXT("GetMethodParameterTypes")); - _returnType = CallStaticMethod(GetMethodReturnTypePtr, _handle); + if (_paramsCount != 0) + { + void** parameterTypeHandles; + CallStaticMethod(GetMethodParameterTypesPtr, _handle, ¶meterTypeHandles); + _parameterTypes.Set(parameterTypeHandles, _paramsCount); + MCore::GC::FreeMemory(parameterTypeHandles); + } - if (_paramsCount == 0) - return; - void** parameterTypeHandles; - CallStaticMethod(GetMethodParameterTypesPtr, _handle, ¶meterTypeHandles); - _parameterTypes.Set(parameterTypeHandles, _paramsCount); - MCore::GC::FreeMemory(parameterTypeHandles); + _hasCachedSignature = true; } MObject* MMethod::Invoke(void* instance, void** params, MObject** exception) const @@ -1434,7 +1436,7 @@ MType* MMethod::GetParameterType(int32 paramIdx) const if (!_hasCachedSignature) CacheSignature(); ASSERT_LOW_LAYER(paramIdx >= 0 && paramIdx < _paramsCount); - return (MType*)_parameterTypes[paramIdx]; + return (MType*)_parameterTypes.Get()[paramIdx]; } bool MMethod::GetParameterIsOut(int32 paramIdx) const