Esempio n. 1
0
 public void MarshalTo(Native *pNative)
 {
     this.Header.MarshalTo(&pNative->Header);
     this.Mouse?.MarshalTo(&pNative->Data.Mouse);
     this.Keyboard?.MarshalTo(&pNative->Data.Keyboard);
     this.Hid?.MarshalTo(&pNative->Data.Hid);
 }
Esempio n. 2
0
        internal StudioSequence(byte *buffer, Native *nativeMemory)
        {
            Data = nativeMemory;

            Label = Marshal.PtrToStringUTF8(new IntPtr(Data->label));

            Events = APIUtils.AllocateListWrapper(buffer, Data->numevents, Data->eventindex, n => new StudioEvent((StudioEvent.Native *)n.ToPointer()));
        }
Esempio n. 3
0
 internal void ToNative(Native *native)
 {
     native->Binding           = Binding;
     native->DescriptorType    = DescriptorType;
     native->DescriptorCount   = DescriptorCount;
     native->StageFlags        = StageFlags;
     native->ImmutableSamplers = Interop.Struct.AllocToPointer(ImmutableSamplers);
 }
Esempio n. 4
0
        protected virtual void Dispose(bool disposing)
        {
            if (NativeStream != null)
            {
                Native.Free(NativeStream);
                NativeStream = null;
            }

            available = false;
        }
Esempio n. 5
0
 internal void ToNative(Native *val)
 {
     val->Type               = StructureType.ApplicationInfo;
     val->Next               = IntPtr.Zero;
     val->ApplicationName    = Interop.String.AllocToPointer(ApplicationName);
     val->ApplicationVersion = ApplicationVersion;
     val->EngineName         = Interop.String.AllocToPointer(EngineName);
     val->EngineVersion      = EngineVersion;
     val->ApiVersion         = ApiVersion;
 }
Esempio n. 6
0
        public Error Write(Native *stream, IntPtr data, int len)
        {
            var buffer = new byte[len];

            Marshal.Copy(data, buffer, 0, len);

            BaseStream.Write(buffer, 0, buffer.Length);

            return(Error.Ok);
        }
Esempio n. 7
0
 internal void ToNative(Native *native)
 {
     native->Type            = StructureType.WriteDescriptorSet;
     native->DstSet          = DstSet;
     native->DstBinding      = DstBinding;
     native->DescriptorCount = DescriptorCount;
     native->DescriptorType  = DescriptorType;
     native->ImageInfo       = Interop.Struct.AllocToPointer(ImageInfo);
     native->BufferInfo      = Interop.Struct.AllocToPointer(BufferInfo);
     native->TexelBufferView = Interop.Struct.AllocToPointer(TexelBufferView);
 }
Esempio n. 8
0
        public Error Open(Native *stream)
        {
            if (open)
            {
                return(Error.OkError);
            }

            BeginRead();

            return(Error.Ok);
        }
Esempio n. 9
0
        public Error Close(Native *stream)
        {
            if (!open)
            {
                return(Error.OkError);
            }

            open = false;
            cancellationToken.Cancel();

            return(Error.Ok);
        }
Esempio n. 10
0
        internal KeyValueData(Native *nativeMemory)
        {
            Data = nativeMemory;

            //Cache off the strings to avoid expensive conversions executing multiple times
            KeyName = Marshal.PtrToStringUTF8(new IntPtr(Data->szKeyName));
            Value   = Marshal.PtrToStringUTF8(new IntPtr(Data->szValue));

            //If this keyvalue is "classname", then this field is null
            //To avoid having to handle this logic in game code, just use the same string
            ClassName = Data->szClassName != null?Marshal.PtrToStringUTF8(new IntPtr(Data->szClassName)) : Value;
        }
Esempio n. 11
0
 internal void ToNative(Native *native)
 {
     native->UserData           = UserData;
     native->Allocation         = Interop.GetFunctionPointerForDelegate(Allocation);
     native->Reallocation       = Interop.GetFunctionPointerForDelegate(Reallocation);
     native->Free               = Interop.GetFunctionPointerForDelegate(Free);
     native->InternalAllocation = InternalAllocation == null
         ? IntPtr.Zero
         : Interop.GetFunctionPointerForDelegate(InternalAllocation);
     native->InternalFree = InternalFree == null
         ? IntPtr.Zero
         : Interop.GetFunctionPointerForDelegate(InternalFree);
 }
Esempio n. 12
0
        /// <summary>
        /// Create a page with the size of an item.
        /// </summary>
        /// <param name="aItemSize">Item size.</param>
        /// <exception cref="Exception">Thrown if:
        /// <list type="bullet">
        /// <item>aItemSize is 0.</item>
        /// <item>aItemSize is not word aligned.</item>
        /// <item>SMT is not initialized.</item>
        /// <item>The item size is bigger then a small heap size.</item>
        /// </list>
        /// </exception>
        static void CreatePage(Native aItemSize)
        {
            if (aItemSize == 0)
            {
                throw new Exception("aItemSize cannot be 0.");
            }
            else if (aItemSize % sizeof(Native) != 0)
            {
                throw new Exception("aItemSize must be word aligned.");
            }
            else if (mMaxItemSize == 0)
            {
                throw new Exception("SMT is not initialized.");
            }
            else if (aItemSize > mMaxItemSize)
            {
                throw new Exception("Cannot allocate more than MaxItemSize in SmallHeap.");
            }

            // Limit to one page so they are allocated low and easy to move around.
            // In future may put some up top and be larger as well.
            Native xPages = 1;
            var    xPtr   = (Native *)RAT.AllocPages(RAT.PageType.HeapSmall, xPages);

            // Ptr to next page of same size
            xPtr[0] = 0;
            //
            // # of slots. Necessary for future use when more than one page, but used currently as well.
            Native xSlotSize  = aItemSize + PrefixItemBytes;
            Native xItemCount = RAT.PageSize * xPages / xSlotSize;

            xPtr[1] = xItemCount;
            //
            // # of free slots
            xPtr[2] = xItemCount;
            //
            xPtr = xPtr + 3;

            for (Native i = 0; i < xItemCount; i++)
            {
                byte *  xSlotPtr     = (byte *)xPtr + i * xSlotSize;
                Native *xMetaDataPtr = (Native *)xSlotPtr;
                xMetaDataPtr[0] = 0; // Actual data size. 0 is empty.
                xMetaDataPtr[1] = 0; // Ref count
                xMetaDataPtr[2] = 0; // Ptr to first
            }
        }
Esempio n. 13
0
        public StudioHeader(Native *nativeMemory)
        {
            Data = nativeMemory;

            Name = Marshal.PtrToStringUTF8(new IntPtr(Data->name));

            var buffer = (byte *)Data;

            Bones           = APIUtils.AllocateListWrapper(buffer, Data->numbones, Data->boneindex, n => new StudioBone((StudioBone.Native *)n.ToPointer()));
            BoneControllers = APIUtils.AllocateListWrapper(buffer, Data->numbones, Data->boneindex, n => new StudioBoneController((StudioBoneController.Native *)n.ToPointer()));
            Sequences       = APIUtils.AllocateListWrapper(buffer, Data->numseq, Data->seqindex, n => new StudioSequence(buffer, (StudioSequence.Native *)n.ToPointer()));
            BodyParts       = APIUtils.AllocateListWrapper(buffer, Data->numbodyparts, Data->bodypartindex, n => new StudioBodyPart((StudioBodyPart.Native *)n.ToPointer()));

            var transitions = new byte[Data->numtransitions];

            Marshal.Copy(new IntPtr(buffer + Data->transitionindex), transitions, 0, Data->numtransitions);

            Transitions = transitions.ToList();
        }
Esempio n. 14
0
            public void RestoreFrom(Native *pNative)
            {
                this.Header = new RawInputHeader(pNative->Header);
                switch (this.Header.Type)
                {
                case DeviceType.Mouse:
                    this.Mouse = new RawMouse(pNative->Data.Mouse);
                    break;

                case DeviceType.Keyboard:
                    this.Keyboard = new RawKeyboard(pNative->Data.Keyboard);
                    break;

                case DeviceType.HumanInputDevice:
                    this.Hid = new RawHid(pNative->Data.Hid);
                    break;

                default:
                    throw new ArgumentException($"未知のDeviceTypeです。[{this.Header.Type}]");
                }
            }
Esempio n. 15
0
        public PlayerMove(Native *nativeMemory, bool isServer)
        {
            Data = nativeMemory;

            Data->server = isServer ? QBoolean.True : QBoolean.False;

            PhysEnts = WrapPhysEnts(&Data->physents, MaxPhysEnts);
            MoveEnts = WrapPhysEnts(&Data->moveents, MaxMoveEnts);
            VisEnts  = WrapPhysEnts(&Data->visents, MaxPhysEnts);

            Cmd = new UserCmd(&nativeMemory->cmd);

            var touchIndex = new List <PMTrace>(MaxPhysEnts);

            for (var i = 0; i < MaxPhysEnts; ++i)
            {
                touchIndex.Add(new PMTrace(&Data->touchindex + i));
            }

            TouchIndex = touchIndex;

            MoveVars = new MoveVars(Data->movevars);
        }
 internal void ToNative(Native *native)
 {
     native->Image     = Image;
     native->BindCount = Binds?.Length ?? 0;
     native->Binds     = Interop.Struct.AllocToPointer(Binds);
 }
Esempio n. 17
0
 internal KeyButton(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 18
0
 public static void Free(Native *stream)
 {
     Marshal.FreeHGlobal((IntPtr)stream);
 }
Esempio n. 19
0
 private unsafe void ReleaseNative()
 {
     Marshal.FreeHGlobal(new IntPtr(DataPointer));
     DataPointer = null;
     MaxCount    = 0;
 }
Esempio n. 20
0
 internal ClientEntity(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 21
0
 public EntityState(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 22
0
 internal StudioEvent(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 23
0
 internal TempEntity(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 24
0
 private unsafe void CreateNative(int pointCount)
 {
     DataPointer = (Native*)(void*)Marshal.AllocHGlobal(Utilities.SizeOf<Native>() + Utilities.SizeOf<CurvePoint>() * pointCount);
     DataPointer->PointsPointer = new IntPtr(DataPointer + 1);
     MaxCount = pointCount;
 }
Esempio n. 25
0
 internal Resource(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 26
0
 internal RefParams(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 27
0
 public ClientData(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 28
0
 internal EntVars(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 29
0
 internal NetAddress(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 30
0
 internal Delta(Native *nativeMemory)
 {
     Data = nativeMemory;
 }
Esempio n. 31
0
 private unsafe void ReleaseNative()
 {
     Marshal.FreeHGlobal(new IntPtr(DataPointer));
     DataPointer = null;
     MaxCount = 0;
 }
Esempio n. 32
0
 internal Customization(Native *nativeMemory)
 {
     Data = nativeMemory;
 }