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

Fixed dynamic boxability of wrappable types (such as pointers)

This commit is contained in:
Brian Fiete 2020-09-26 09:25:38 -07:00
parent befcbf3ddc
commit ee71c8c97b
2 changed files with 3 additions and 13 deletions

View file

@ -313,24 +313,14 @@ namespace System
if (IsObject) if (IsObject)
return .Err; return .Err;
var self = this;
var type = VariantType; var type = VariantType;
void* dataPtr = self.DataPtr;
if (type.IsPointer)
{
type = type.UnderlyingType;
var boxedType = type.BoxedType;
if (boxedType == null)
return .Err;
dataPtr = (void*)mData;
}
var boxedType = type.BoxedType; var boxedType = type.BoxedType;
if (boxedType == null) if (boxedType == null)
return .Err; return .Err;
var self = this;
var object = Try!(boxedType.CreateObject()); var object = Try!(boxedType.CreateObject());
Internal.MemCpy((uint8*)Internal.UnsafeCastToPtr(object) + boxedType.[Friend]mMemberDataOffset, dataPtr, type.Size); Internal.MemCpy((uint8*)Internal.UnsafeCastToPtr(object) + boxedType.[Friend]mMemberDataOffset, self.DataPtr, type.Size);
return object; return object;
} }

View file

@ -4934,7 +4934,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
} }
int boxedTypeId = 0; int boxedTypeId = 0;
if (type->IsValueType()) if ((type->IsValueType()) || (type->IsWrappableType()))
{ {
auto boxedType = CreateBoxedType(type, false); auto boxedType = CreateBoxedType(type, false);
if ((boxedType != NULL) && (boxedType->mIsReified)) if ((boxedType != NULL) && (boxedType->mIsReified))