public Block *FirstBlock() { if (BuildPlatformUtil.is32Bit()) { // 32bit return(m_Data32Bit[0]); } else { // 64bit return(m_Data64Bit[0]); } }
public byte *Start() { if (BuildPlatformUtil.is32Bit()) { // 32bit fixed(byte *d = m_DataStart32Bit) { return(d); } } else { // 64bit fixed(byte *d = m_DataStart64Bit) { return(d); } } }
// There's more fields of in-place array here, but we don't care about them #pragma warning restore CS0649, CS0169 // Fills the specified array (given as pointer and length) with offsets of this struct's fields that need to be in sync with plugin struct fields. public unsafe static int FillFieldOffsetsArray(int startFrom, int *fieldOffsets, int fieldOffsetsLength) { // List of (field name, isPublic) pairs List <KeyValuePair <string, bool> > fieldNamesAndAccess = new List <KeyValuePair <string, bool> >() { new KeyValuePair <string, bool>("m_Allocator", false), new KeyValuePair <string, bool>("m_NumTotalElements", false), new KeyValuePair <string, bool>("m_PartiallyFreed", false), new KeyValuePair <string, bool>("m_IsLocked", false) }; // We need to account for m_Data* separately int myFieldCount = fieldNamesAndAccess.Count + 1; if (startFrom + myFieldCount > fieldOffsetsLength) { throw new ArgumentException($"{nameof(fieldOffsets)} (length {fieldOffsetsLength}) is not big enough for all {myFieldCount} fields of this struct (starting from {startFrom})!"); } int fieldIndex = startFrom; UnsafeEx.FillFieldOffsetsArray(typeof(HpBlockStream), fieldNamesAndAccess, fieldOffsets, ref fieldIndex); if (BuildPlatformUtil.is32Bit()) { // 32bit fieldOffsets[fieldIndex] = UnsafeUtility.GetFieldOffset(typeof(HpBlockStream).GetField("m_Data32Bit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)); } else { // 64bit fieldOffsets[fieldIndex] = UnsafeUtility.GetFieldOffset(typeof(HpBlockStream).GetField("m_Data64Bit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)); } fieldIndex++; Assert.AreEqual(myFieldCount, fieldIndex - startFrom); return(fieldIndex); }