mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Reflection fixes
This commit is contained in:
parent
93facda6b2
commit
64f8e54c05
2 changed files with 96 additions and 1 deletions
|
@ -12,6 +12,14 @@ namespace System.Reflection
|
|||
TypeInstance mTypeInstance;
|
||||
TypeInstance.MethodData* mMethodData;
|
||||
|
||||
public bool IsInitialized
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMethodData != null;
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Name
|
||||
{
|
||||
get
|
||||
|
@ -157,7 +165,7 @@ namespace System.Reflection
|
|||
if ((paramType.IsPrimitive) && (underlyingType.IsTypedPrimitive)) // Boxed primitive?
|
||||
underlyingType = underlyingType.UnderlyingType;
|
||||
|
||||
if (argType.IsBoxedStructPtr)
|
||||
if ((argType.IsBoxedStructPtr) || (argIdx == -1))
|
||||
{
|
||||
dataPtr = *(void**)dataPtr;
|
||||
handled = true;
|
||||
|
|
|
@ -32,6 +32,21 @@ namespace System
|
|||
return .Err(.NoResults);
|
||||
return .Ok(matched);
|
||||
}
|
||||
|
||||
public virtual Result<Object> CreateObject()
|
||||
{
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public virtual Result<void*> CreateValue()
|
||||
{
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public virtual Result<void*> CreateValueDefault()
|
||||
{
|
||||
return .Err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,5 +74,77 @@ namespace System.Reflection
|
|||
{
|
||||
return MethodInfo.Enumerator(this, bindingFlags);
|
||||
}
|
||||
|
||||
public override Result<Object> CreateObject()
|
||||
{
|
||||
if (mTypeClassVData == null)
|
||||
return .Err;
|
||||
|
||||
MethodInfo methodInfo = default;
|
||||
for (int methodId < mMethodDataCount)
|
||||
{
|
||||
let methodData = &mMethodDataPtr[methodId];
|
||||
if (!methodData.mFlags.HasFlag(.Constructor))
|
||||
continue;
|
||||
if (methodData.mParamCount != 0)
|
||||
continue;
|
||||
|
||||
methodInfo = .(this, methodData);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!methodInfo.IsInitialized)
|
||||
return .Err;
|
||||
Object obj = Internal.Dbg_ObjectAlloc(mTypeClassVData, mInstSize, mInstAlign, 1);
|
||||
|
||||
if (methodInfo.Invoke(obj) case .Err)
|
||||
{
|
||||
delete obj;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public override Result<void*> CreateValue()
|
||||
{
|
||||
if (!IsValueType)
|
||||
return .Err;
|
||||
|
||||
MethodInfo methodInfo = default;
|
||||
for (int methodId < mMethodDataCount)
|
||||
{
|
||||
let methodData = &mMethodDataPtr[methodId];
|
||||
if (!methodData.mFlags.HasFlag(.Constructor))
|
||||
continue;
|
||||
if (methodData.mParamCount != 0)
|
||||
continue;
|
||||
|
||||
methodInfo = .(this, methodData);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!methodInfo.IsInitialized)
|
||||
return .Err;
|
||||
|
||||
void* data = new uint8[mInstSize]*;
|
||||
|
||||
if (methodInfo.Invoke(data) case .Err)
|
||||
{
|
||||
delete data;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public override Result<void*> CreateValueDefault()
|
||||
{
|
||||
if (!IsValueType)
|
||||
return .Err;
|
||||
|
||||
void* data = new uint8[mInstSize]*;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue