Exemplo n.º 1
0
        public static unsafe void WriteArray <T>(IntPtr destination, T[] buffer, int index, int count)
            where T : struct
        {
            uint elementSize = (uint)SizeOf <T>();

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (buffer.Length - index < count)
            {
                throw new ArgumentException("Invalid offset into array specified by index and count");
            }

            void *ptr = destination.ToPointer();
            byte *p   = (byte *)FastStructure.GetPtr <T>(ref buffer[0]);

            Buffer.MemoryCopy(p + (index * elementSize), ptr, elementSize * count, elementSize * count);
        }
Exemplo n.º 2
0
 internal unsafe T GetResultFast <T>()
     where T : struct
 {
     fixed(byte *functionData = m_context.functionData)
     {
         return(FastStructure <T> .PtrToStructure(new IntPtr(functionData)));
     }
 }
Exemplo n.º 3
0
        internal static unsafe void PushFast <T>(ContextType *cxt, T arg)
            where T : struct
        {
            var size = FastStructure <T> .Size;

            var numArgs = (size / 8);

            if ((size % 8) != 0)
            {
                *(long *)(&cxt->functionData[8 * cxt->numArguments]) = 0;
                numArgs++;
            }

            FastStructure <T> .StructureToPtr(ref arg, new IntPtr(&cxt->functionData[8 * cxt->numArguments]));

            cxt->numArguments += numArgs;
        }
Exemplo n.º 4
0
        internal unsafe void PushFast <T>(T arg)
            where T : struct
        {
            var size = FastStructure <T> .Size;

            var numArgs = (size / 8);

            fixed(byte *functionData = m_context.functionData)
            {
                if ((size % 8) != 0)
                {
                    *(long *)(&functionData[8 * m_context.numArguments]) = 0;
                    numArgs++;
                }

                FastStructure <T> .StructureToPtr(ref arg, new IntPtr(&functionData[8 * m_context.numArguments]));
            }

            m_context.numArguments += numArgs;
        }
Exemplo n.º 5
0
 internal static unsafe T GetResultFast <T>(ContextType *cxt)
     where T : struct
 {
     return(FastStructure <T> .PtrToStructure(new IntPtr(&cxt->functionData)));
 }
Exemplo n.º 6
0
 public static unsafe void StructureToPtr <T>(ref T structure, IntPtr pointer)
     where T : struct
 {
     FastStructure <T> .StructureToPtr(ref structure, pointer);
 }
Exemplo n.º 7
0
 public static unsafe T PtrToStructure <T>(IntPtr pointer)
     where T : struct
 {
     return(FastStructure <T> .PtrToStructure(pointer));
 }
Exemplo n.º 8
0
 public static unsafe void *GetPtr <T>(ref T structure)
     where T : struct
 {
     return(FastStructure <T> .GetPtr(ref structure));
 }