123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #region MIT License
- #endregion
- using System;
- using System.Runtime.InteropServices;
- using SharpFont.Internal;
- namespace SharpFont
- {
-
-
-
-
-
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate IntPtr AllocFunc([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MemoryMarshaler))] Memory memory, IntPtr size);
-
-
-
-
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate void FreeFunc([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MemoryMarshaler))] Memory memory, IntPtr block);
-
-
-
-
-
-
-
-
-
-
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate IntPtr ReallocFunc([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MemoryMarshaler))] Memory memory, IntPtr currentSize, IntPtr newSize, IntPtr block);
-
-
-
- public class Memory
- {
- #region Fields
- private IntPtr reference;
- private MemoryRec rec;
- #endregion
- #region Constructors
- internal Memory(IntPtr reference)
- {
- Reference = reference;
- }
- internal Memory(IntPtr reference, IntPtr offset)
- : this(new IntPtr(reference.ToInt64() + offset.ToInt64()))
- {
- }
- #endregion
- #region Properties
-
-
-
- public IntPtr User
- {
- get
- {
- return rec.user;
- }
- }
-
-
-
- public AllocFunc Allocate
- {
- get
- {
- return rec.alloc;
- }
- }
-
-
-
- public FreeFunc Free
- {
- get
- {
- return rec.free;
- }
- }
-
-
-
- public ReallocFunc Reallocate
- {
- get
- {
- return rec.realloc;
- }
- }
- internal IntPtr Reference
- {
- get
- {
- return reference;
- }
- set
- {
- reference = value;
- rec = PInvokeHelper.PtrToStructure<MemoryRec>(reference);
- }
- }
- #endregion
- }
- }
|