mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 07:14:09 +02:00
Added GetFieldReference, ability to explicitly reference in Variant
This commit is contained in:
parent
5cfe9e6196
commit
78dd56d6c5
11 changed files with 279 additions and 54 deletions
|
@ -216,6 +216,30 @@ namespace System.Reflection
|
|||
return value;
|
||||
}
|
||||
|
||||
public Result<Variant> GetValueReference(Object target)
|
||||
{
|
||||
Variant value = Variant();
|
||||
|
||||
Type tTarget;
|
||||
void* targetDataAddr = GetDataPtrAndType(target, out tTarget);
|
||||
|
||||
if (!tTarget.IsSubtypeOf(mTypeInstance))
|
||||
Runtime.FatalError("Invalid type");
|
||||
|
||||
targetDataAddr = (uint8*)targetDataAddr + mFieldData.mDataOffset;
|
||||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
|
||||
TypeCode typeCode = fieldType.[Friend]mTypeCode;
|
||||
if (typeCode == TypeCode.Enum)
|
||||
typeCode = fieldType.UnderlyingType.[Friend]mTypeCode;
|
||||
|
||||
value = Variant.CreateReference(fieldType, targetDataAddr);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public Result<Variant> GetValue()
|
||||
{
|
||||
Variant value = Variant();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue