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); }
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())); }
internal void ToNative(Native *native) { native->Binding = Binding; native->DescriptorType = DescriptorType; native->DescriptorCount = DescriptorCount; native->StageFlags = StageFlags; native->ImmutableSamplers = Interop.Struct.AllocToPointer(ImmutableSamplers); }
protected virtual void Dispose(bool disposing) { if (NativeStream != null) { Native.Free(NativeStream); NativeStream = null; } available = false; }
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; }
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); }
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); }
public Error Open(Native *stream) { if (open) { return(Error.OkError); } BeginRead(); return(Error.Ok); }
public Error Close(Native *stream) { if (!open) { return(Error.OkError); } open = false; cancellationToken.Cancel(); return(Error.Ok); }
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; }
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); }
/// <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 } }
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(); }
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}]"); } }
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); }
internal KeyButton(Native *nativeMemory) { Data = nativeMemory; }
public static void Free(Native *stream) { Marshal.FreeHGlobal((IntPtr)stream); }
private unsafe void ReleaseNative() { Marshal.FreeHGlobal(new IntPtr(DataPointer)); DataPointer = null; MaxCount = 0; }
internal ClientEntity(Native *nativeMemory) { Data = nativeMemory; }
public EntityState(Native *nativeMemory) { Data = nativeMemory; }
internal StudioEvent(Native *nativeMemory) { Data = nativeMemory; }
internal TempEntity(Native *nativeMemory) { Data = nativeMemory; }
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; }
internal Resource(Native *nativeMemory) { Data = nativeMemory; }
internal RefParams(Native *nativeMemory) { Data = nativeMemory; }
public ClientData(Native *nativeMemory) { Data = nativeMemory; }
internal EntVars(Native *nativeMemory) { Data = nativeMemory; }
internal NetAddress(Native *nativeMemory) { Data = nativeMemory; }
internal Delta(Native *nativeMemory) { Data = nativeMemory; }
private unsafe void ReleaseNative() { Marshal.FreeHGlobal(new IntPtr(DataPointer)); DataPointer = null; MaxCount = 0; }
internal Customization(Native *nativeMemory) { Data = nativeMemory; }