1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Add AllocOwned to Variant

This commit is contained in:
disarray2077 2022-03-04 13:50:34 -03:00 committed by GitHub
parent 1223395a01
commit 9f441ed8f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -265,6 +265,23 @@ namespace System
}
}
public static void* AllocOwned(Type type, out Variant variant)
{
variant = .();
if (type.IsObject)
{
return &variant.mData;
}
else
{
variant.mStructType = (int)Internal.UnsafeCastToPtr(type) | 1;
void* data = new uint8[type.[Friend]mSize]*;
variant.mData = (int)data;
return data;
}
}
public T Get<T>() where T : class
{
Debug.Assert(IsObject);