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