mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-11 04:52:21 +02:00
Use Variant
in CustomAttributeEnumerator
This commit is contained in:
parent
9eecf83c22
commit
d52ebfa1db
1 changed files with 10 additions and 12 deletions
|
@ -114,12 +114,12 @@ namespace System.Reflection
|
||||||
return .Err;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct CustomAttributeEnumerator : IEnumerator<Object>, IDisposable
|
public struct CustomAttributeEnumerator : IEnumerator<Variant>, IDisposable
|
||||||
{
|
{
|
||||||
void* data;
|
void* data;
|
||||||
int32 attrIdx;
|
int32 attrIdx;
|
||||||
uint8 count;
|
uint8 count;
|
||||||
Object targetAttr;
|
Variant targetAttr;
|
||||||
|
|
||||||
public this(void* inAttrData)
|
public this(void* inAttrData)
|
||||||
{
|
{
|
||||||
|
@ -127,10 +127,10 @@ namespace System.Reflection
|
||||||
data++;
|
data++;
|
||||||
attrIdx = 0;
|
attrIdx = 0;
|
||||||
count = data != null ? AttributeInfo.Decode!<uint8>(data) : 0;
|
count = data != null ? AttributeInfo.Decode!<uint8>(data) : 0;
|
||||||
targetAttr = null;
|
targetAttr = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object Current
|
public Variant Current
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -200,24 +200,22 @@ namespace System.Reflection
|
||||||
argIdx++;
|
argIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type boxedAttrType = attrType.BoxedType;
|
targetAttr.Dispose();
|
||||||
|
void* data = Variant.Alloc(attrType, out targetAttr);
|
||||||
|
|
||||||
delete targetAttr;
|
if (methodInfo.Invoke(data, params args) case .Ok(var val))
|
||||||
targetAttr = boxedAttrType.CreateObject().Get();
|
|
||||||
|
|
||||||
if (methodInfo.Invoke((uint8*)Internal.UnsafeCastToPtr(targetAttr) + boxedAttrType.[Friend]mMemberDataOffset, params args) case .Ok(var val))
|
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
|
||||||
attrIdx++;
|
attrIdx++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose() mut
|
||||||
{
|
{
|
||||||
delete targetAttr;
|
targetAttr.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<Object> GetNext() mut
|
public Result<Variant> GetNext() mut
|
||||||
{
|
{
|
||||||
if (!MoveNext())
|
if (!MoveNext())
|
||||||
return .Err;
|
return .Err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue