diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 4d38125f8..1feeb8839 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -60,8 +60,8 @@ namespace FlaxEngine internal IntPtr name; internal ManagedHandle getterHandle; internal ManagedHandle setterHandle; - internal uint getterFlags; - internal uint setterFlags; + internal uint getterAttributes; + internal uint setterAttributes; } [StructLayout(LayoutKind.Sequential)] @@ -1904,7 +1904,7 @@ namespace FlaxEngine { Type type = Unsafe.As(typeHandle.Target); - List methods = new List(); + var methods = new List(); var staticMethods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly); var instanceMethods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly); foreach (MethodInfo method in staticMethods) @@ -1912,11 +1912,11 @@ namespace FlaxEngine foreach (MethodInfo method in instanceMethods) methods.Add(method); - NativeMethodDefinitions* arr = (NativeMethodDefinitions*)NativeAlloc(methods.Count, Unsafe.SizeOf()); + var arr = (NativeMethodDefinitions*)NativeAlloc(methods.Count, Unsafe.SizeOf()); for (int i = 0; i < methods.Count; i++) { IntPtr ptr = IntPtr.Add(new IntPtr(arr), Unsafe.SizeOf() * i); - NativeMethodDefinitions classMethod = new NativeMethodDefinitions() + var classMethod = new NativeMethodDefinitions { name = NativeAllocStringAnsi(methods[i].Name), numParameters = methods[i].GetParameters().Length, @@ -1977,7 +1977,7 @@ namespace FlaxEngine Type type = Unsafe.As(typeHandle.Target); var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - NativePropertyDefinitions* arr = (NativePropertyDefinitions*)NativeAlloc(properties.Length, Unsafe.SizeOf()); + var arr = (NativePropertyDefinitions*)NativeAlloc(properties.Length, Unsafe.SizeOf()); for (int i = 0; i < properties.Length; i++) { IntPtr ptr = IntPtr.Add(new IntPtr(arr), Unsafe.SizeOf() * i); @@ -1985,19 +1985,19 @@ namespace FlaxEngine var getterMethod = properties[i].GetGetMethod(true); var setterMethod = properties[i].GetSetMethod(true); - NativePropertyDefinitions classProperty = new NativePropertyDefinitions() + var classProperty = new NativePropertyDefinitions { name = NativeAllocStringAnsi(properties[i].Name), }; if (getterMethod != null) { - var getterHandle = GetMethodGCHandle(getterMethod); - classProperty.getterHandle = getterHandle; + classProperty.getterHandle = GetMethodGCHandle(getterMethod); + classProperty.getterAttributes = (uint)getterMethod.Attributes; } if (setterMethod != null) { - var setterHandle = GetMethodGCHandle(setterMethod); - classProperty.setterHandle = setterHandle; + classProperty.setterHandle = GetMethodGCHandle(setterMethod); + classProperty.setterAttributes = (uint)setterMethod.Attributes; } Unsafe.Write(ptr.ToPointer(), classProperty); } diff --git a/Source/Engine/Scripting/DotNet/MonoApi.cpp b/Source/Engine/Scripting/DotNet/MonoApi.cpp index 85747d9cb..307d0585f 100644 --- a/Source/Engine/Scripting/DotNet/MonoApi.cpp +++ b/Source/Engine/Scripting/DotNet/MonoApi.cpp @@ -58,8 +58,8 @@ struct NativePropertyDefinitions const char* name; void* getterHandle; void* setterHandle; - uint32 getterFlags; - uint32 setterFlags; + uint32 getterAttributes; + uint32 setterAttributes; }; struct ClassAttribute @@ -166,8 +166,13 @@ private: int _monoType; public: - CoreCLRClass(void* typeHandle, StringAnsi name, StringAnsi fullname, StringAnsi namespace_, uint32 typeAttributes, CoreCLRAssembly* image) - : _typeHandle(typeHandle), _name(name), _fullname(fullname), _namespace(namespace_), _typeAttributes(typeAttributes), _image(image) + CoreCLRClass(void* typeHandle, StringAnsi&& name, StringAnsi&& fullname, StringAnsi&& namespace_, uint32 typeAttributes, CoreCLRAssembly* image) + : _fullname(MoveTemp(fullname)) + , _name(MoveTemp(name)) + , _namespace(MoveTemp(namespace_)) + , _typeAttributes(typeAttributes) + , _image(image) + , _typeHandle(typeHandle) { _typeToken = TypeTokenPool++; _monoType = 0; @@ -199,10 +204,8 @@ public: { if (_size != 0) return _size; - uint32 align; _size = mono_class_value_size((MonoClass*)this, &align); - return _size; } @@ -289,7 +292,8 @@ public: CoreCLR::CallStaticMethod(GetClassPropertiesPtr, _typeHandle, &foundProperties, &numProperties); for (int i = 0; i < numProperties; i++) { - CoreCLRProperty* prop = New(StringAnsi(foundProperties[i].name), foundProperties[i].getterHandle, foundProperties[i].setterHandle, foundProperties[i].getterFlags, foundProperties[i].setterFlags, this); + const NativePropertyDefinitions& foundProp = foundProperties[i]; + CoreCLRProperty* prop = New(StringAnsi(foundProp.name), foundProp.getterHandle, foundProp.setterHandle, foundProp.getterAttributes, foundProp.setterAttributes, this); _properties.Add(prop); CoreCLR::Free((void*)foundProperties[i].name); @@ -369,8 +373,12 @@ private: uint32 _methodAttributes; public: - CoreCLRMethod(StringAnsi name, int numParams, void* methodHandle, uint32 flags, CoreCLRClass* klass) - :_name(name), _numParams(numParams), _methodHandle(methodHandle), _methodAttributes(flags), _class(klass) + CoreCLRMethod(StringAnsi&& name, int numParams, void* methodHandle, uint32 flags, CoreCLRClass* klass) + : _name(MoveTemp(name)) + , _numParams(numParams) + , _class(klass) + , _methodHandle(methodHandle) + , _methodAttributes(flags) { _returnType = nullptr; } @@ -481,15 +489,16 @@ private: CoreCLRMethod* _setMethod; public: - CoreCLRProperty(StringAnsi name, void* getter, void* setter, uint32 getterFlags, uint32 setterFlags, CoreCLRClass* klass) - :_name(name), _class(klass) + CoreCLRProperty(StringAnsi&& name, void* getter, void* setter, uint32 getterAttributes, uint32 setterAttributes, CoreCLRClass* klass) + : _name(MoveTemp(name)) + , _class(klass) { if (getter != nullptr) - _getMethod = New(StringAnsi(_name + "Get"), 1, getter, getterFlags, klass); + _getMethod = New(StringAnsi(_name + "Get"), 1, getter, getterAttributes, klass); else _getMethod = nullptr; if (setter != nullptr) - _setMethod = New(StringAnsi(_name + "Set"), 1, setter, setterFlags, klass); + _setMethod = New(StringAnsi(_name + "Set"), 1, setter, setterAttributes, klass); else _setMethod = nullptr; } @@ -524,8 +533,11 @@ private: CoreCLRClass* _attributeClass; public: - CoreCLRCustomAttribute(StringAnsi name, void* handle, CoreCLRClass* owningClass, CoreCLRClass* attributeClass) - :_name(name), _handle(handle), _owningClass(owningClass), _attributeClass(attributeClass) + CoreCLRCustomAttribute(StringAnsi&& name, void* handle, CoreCLRClass* owningClass, CoreCLRClass* attributeClass) + : _name(MoveTemp(name)) + , _handle(handle) + , _owningClass(owningClass) + , _attributeClass(attributeClass) { } @@ -550,9 +562,8 @@ CoreCLRAssembly* GetAssembly(void* assemblyHandle) CoreCLRClass* GetClass(void* type) { - CoreCLRClass* klass; - if (classHandles.TryGet(type, klass)) - return klass; + CoreCLRClass* klass = nullptr; + classHandles.TryGet(type, klass); return nullptr; } diff --git a/Source/Engine/Scripting/ManagedCLR/MMethod.cpp b/Source/Engine/Scripting/ManagedCLR/MMethod.cpp index 89c96a27d..e89c100bd 100644 --- a/Source/Engine/Scripting/ManagedCLR/MMethod.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MMethod.cpp @@ -25,7 +25,6 @@ MMethod::MMethod(MonoMethod* monoMethod, const char* name, MClass* parentClass) #endif const uint32_t flags = mono_method_get_flags(monoMethod, nullptr); - _isStatic = (flags & MONO_METHOD_ATTR_STATIC) != 0; switch (flags & MONO_METHOD_ATTR_ACCESS_MASK) {