mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-13 22:04:09 +02:00
Merge pull request #782 from xposure/master
Added CreateObject support for Arrays
This commit is contained in:
commit
08f8ccd4d8
2 changed files with 44 additions and 0 deletions
|
@ -1103,6 +1103,28 @@ namespace System.Reflection
|
||||||
strBuffer.Append(',');
|
strBuffer.Append(',');
|
||||||
strBuffer.Append(']');
|
strBuffer.Append(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result<Object> CreateObject(int32 count)
|
||||||
|
{
|
||||||
|
if ([Friend]mTypeClassVData == null)
|
||||||
|
return .Err;
|
||||||
|
|
||||||
|
Object obj;
|
||||||
|
|
||||||
|
let genericType = GetGenericArg(0);
|
||||||
|
let arraySize = [Friend]mInstSize - genericType.Size + genericType.Stride * count;
|
||||||
|
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||||
|
obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, 1);
|
||||||
|
#else
|
||||||
|
void* mem = new [Align(16)] uint8[arraySize]* (?);
|
||||||
|
obj = Internal.UnsafeCastToObject(mem);
|
||||||
|
obj.[Friend]mClassVData = (.)(void*)[Friend]mTypeClassVData;
|
||||||
|
#endif
|
||||||
|
Internal.MemSet((uint8*)Internal.UnsafeCastToPtr(obj) + [Friend]mInstSize, 0, [Friend]arraySize - [Friend]mInstSize);
|
||||||
|
var array = (Array)obj;
|
||||||
|
array.[Friend]mLength = count;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TypeFlags : uint32
|
public enum TypeFlags : uint32
|
||||||
|
|
|
@ -985,6 +985,28 @@ namespace System.Reflection
|
||||||
strBuffer.Append(',');
|
strBuffer.Append(',');
|
||||||
strBuffer.Append(']');
|
strBuffer.Append(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result<Object> CreateObject(int32 count)
|
||||||
|
{
|
||||||
|
if ([Friend]mTypeClassVData == null)
|
||||||
|
return .Err;
|
||||||
|
|
||||||
|
Object obj;
|
||||||
|
|
||||||
|
let genericType = GetGenericArg(0);
|
||||||
|
let arraySize = [Friend]mInstSize - genericType.Size + genericType.Stride * count;
|
||||||
|
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||||
|
obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, 1);
|
||||||
|
#else
|
||||||
|
void* mem = new [Align(16)] uint8[arraySize]* (?);
|
||||||
|
obj = Internal.UnsafeCastToObject(mem);
|
||||||
|
obj.[Friend]mClassVData = (.)(void*)[Friend]mTypeClassVData;
|
||||||
|
#endif
|
||||||
|
Internal.MemSet((uint8*)Internal.UnsafeCastToPtr(obj) + [Friend]mInstSize, 0, [Friend]arraySize - [Friend]mInstSize);
|
||||||
|
var array = (Array)obj;
|
||||||
|
array.[Friend]mLength = count;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TypeFlags : uint32
|
public enum TypeFlags : uint32
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue