コード例 #1
0
        public static NominalSizeStride FromDylib(DynamicLib lib, string witnessTableName)
        {
            var wit = SwiftValueWitnessTable.FromDylib(lib, witnessTableName);

            if (wit == null)
            {
                throw new SwiftRuntimeException(String.Format("Unable to find witness table entry {0} in library {1}.",
                                                              witnessTableName, lib.FileName));
            }
            return(new NominalSizeStride {
                Size = (int)wit.Size, Stride = (int)wit.Stride
            });
        }
コード例 #2
0
        public static SwiftValueWitnessTable FromMemory(IntPtr p)
        {
            if (p == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(p), "Unable to read SwiftValueWitnessTable");
            }
            int sizeofMachinePointer = IntPtr.Size;

            if (sizeofMachinePointer != 4 && sizeofMachinePointer != 8)
            {
                throw new SwiftRuntimeException("Expected a maching pointer size of either 4 or 8, but got " + sizeofMachinePointer);
            }
            var table = new SwiftValueWitnessTable();

            if (sizeofMachinePointer == 4)
            {
                table.Read32(p);
            }
            else
            {
                table.Read64(p);
            }
            return(table);
        }