Commits

Amin67v  committed 2229256

  • Participants
  • Parent commits a863890

Comments (0)

Files changed (4)

File SharpHammer/Core/Allocator.cs

-using System;
-using System.Runtime.InteropServices;
-
-namespace Hmr.Core
-{
-	/// <summary>
-	/// callback function for aligned allocation.
-	/// </summary>
-	/// <param name="size"></param>
-	/// <param name="alignment"></param>
-	/// <param name="source"></param>
-	/// <param name="line"></param>
-	/// <param name="id"></param>
-	/// <param name="param"></param>
-	/// <returns></returns>
-	internal delegate IntPtr pfn_alignedalloc(IntPtr size, byte alignment,
-		[In] [MarshalAs(UnmanagedType.LPStr)] string source,
-		int line, int id, IntPtr param);
-
-	/// <summary>
-	/// callback function for aligned free.
-	/// </summary>
-	/// <param name="ptr"></param>
-	/// <param name="param"></param>
-	internal delegate void pfn_alignedfree(IntPtr ptr, IntPtr param);
-
-	/// <summary>
-	/// Callback function for custom allocation.
-	/// </summary>
-	/// <param name="size"></param>
-	/// <param name="source"></param>
-	/// <param name="line"></param>
-	/// <param name="id"></param>
-	/// <param name="param"></param>
-	/// <returns></returns>
-	internal delegate IntPtr pfn_alloc(IntPtr size,
-		[In] [MarshalAs(UnmanagedType.LPStr)] string source,
-		int line, int id, IntPtr param);
-
-	/// <summary>
-	/// callback function for custom free.
-	/// </summary>
-	/// <param name="ptr"></param>
-	/// <param name="param"></param>
-	internal delegate void pfn_free(IntPtr ptr, IntPtr param);
-
-	/// <summary>
-	/// allocator structure that holds all callback functions , each custom allocator,
-	/// has a function for binding allocator structure to it's routines
-	/// </summary>
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct Allocator
-	{
-		public pfn_alloc alloc_fn;
-		public pfn_free free_fn;
-		public pfn_alignedalloc alignedalloc_fn;
-		public pfn_alignedfree alignedfree_fn;
-		public IntPtr param;
-	}
-}

File SharpHammer/Core/Array.cs

-using System;
-using System.Runtime.InteropServices;
-
-namespace Hmr.Core
-{
-	[StructLayout(LayoutKind.Sequential)]
-	internal struct Array
-	{
-		private IntPtr alloc;
-		private IntPtr buffer;
-		private uint item_cnt;
-		private uint max_cnt;
-		private uint item_sz;
-		private uint mem_id;
-		private uint expand_sz;
-	}
-}

File SharpHammer/Core/Core.cs

-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace Hmr.Core
-{
-	internal class core
-	{
-		public const string NativeDll = "core.dll";
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, EntryPoint = "core_init", CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		public static extern bool Init([MarshalAs(UnmanagedType.Bool)] bool trace_mem);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, EntryPoint = "core_release", CallingConvention = CallingConvention.Cdecl)]
-		public static extern void Release([MarshalAs(UnmanagedType.Bool)] bool report_leaks);
-	}
-}

File SharpHammer/Core/Log.cs

-using System;
-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace Hmr.Core
-{
-	public enum LogType
-	{
-		Text = 0,
-		Error = 1,
-		Warning = 2,
-		Info = 3,
-		Load = 4
-	}
-
-	[StructLayout(LayoutKind.Sequential)]
-	public struct LogStat
-	{
-		private UInt32 MessagesCount;
-		private UInt32 ErrorsCount;
-		private UInt32 WarningsCount;
-	}
-
-	internal class Log
-	{
-		/// <summary>
-		/// Gets or sets console output for the logger.
-		/// </summary>
-		public static bool OutputConsole
-		{
-			get
-			{
-				return log_isconsole();
-			}
-			set
-			{
-				log_outputconsole(value);
-			}
-		}
-
-		/// <summary>
-		/// Gets or sets debugger output for the logger.
-		/// </summary>
-		public static bool OutputDebugger
-		{
-			get
-			{
-				return log_isdebugger();
-			}
-			set
-			{
-				log_outputdebugger(value);
-			}
-		}
-
-		/// <summary>
-		/// Gets file output for the logger.
-		/// </summary>
-		public static bool OutputFile
-		{
-			get
-			{
-				return log_isfile();
-			}
-		}
-
-		/// <summary>
-		/// Gets log statistics, count number of errors/warnings/...
-		/// </summary>
-		public static LogStat Stat
-		{
-			get
-			{
-				LogStat stat = new LogStat();
-				log_getstats(ref stat);
-				return stat;
-			}
-		}
-
-		/// <summary>
-		/// Print Error to logger
-		/// </summary>
-		/// <param name="text"></param>
-		//[MethodImpl(MethodImplOptions.AggressiveInlining)]
-		public static void Error(string text)
-		{
-			Print(LogType.Error, text);
-		}
-
-		/// <summary>
-		/// Print Info to logger
-		/// </summary>
-		/// <param name="text"></param>
-		//[MethodImpl(MethodImplOptions.AggressiveInlining)]
-		public static void Info(string text)
-		{
-			Print(LogType.Info, text);
-		}
-
-		/// <summary>
-		/// Init log
-		/// </summary>
-		/// <returns></returns>
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, EntryPoint = "log_init", CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		public static extern bool Init();
-
-		/// <summary>
-		/// Print text to the logger
-		/// </summary>
-		/// <param name="type"></param>
-		/// <param name="text"></param>
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, EntryPoint = "log_print", CallingConvention = CallingConvention.Cdecl)]
-		public static extern void Print(LogType type, [In] [MarshalAs(UnmanagedType.LPStr)] string text);
-
-		/// <summary>
-		/// Release Log
-		/// </summary>
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, EntryPoint = "log_init", CallingConvention = CallingConvention.Cdecl)]
-		public static extern void Release();
-
-		/// <summary>
-		/// Sets file output for the logger.
-		/// </summary>
-		/// <param name="enable"></param>
-		/// <param name="path"></param>
-		/// <returns></returns>
-		public static bool SetOutputFile(bool enable, string path)
-		{
-			return log_outputfile(enable, path);
-		}
-
-		/// <summary>
-		/// Print Warning to logger
-		/// </summary>
-		/// <param name="text"></param>
-		//[MethodImpl(MethodImplOptions.AggressiveInlining)]
-		public static void Warning(string text)
-		{
-			Print(LogType.Warning, text);
-		}
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		private static extern void log_getstats(ref LogStat stats);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_isconsole();
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_isdebugger();
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_isfile();
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_outputconsole([MarshalAs(UnmanagedType.Bool)]bool enable);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_outputdebugger([MarshalAs(UnmanagedType.Bool)]bool enable);
-
-		[SuppressUnmanagedCodeSecurity()]
-		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		[return: MarshalAs(UnmanagedType.Bool)]
-		private static extern bool log_outputfile([MarshalAs(UnmanagedType.Bool)]bool enable,
-			[In] [MarshalAs(UnmanagedType.LPStr)] string log_filepath);
-	}
-}