mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Added CallingConvention support, mangle specifying
This commit is contained in:
parent
904f907f1d
commit
61d9edea83
26 changed files with 413 additions and 96 deletions
|
@ -158,9 +158,36 @@ namespace System
|
|||
[AttributeUsage(.Method /*2*/ | .StaticField)]
|
||||
public struct LinkNameAttribute : Attribute
|
||||
{
|
||||
public enum MangleKind
|
||||
{
|
||||
Beef,
|
||||
C,
|
||||
CPP
|
||||
}
|
||||
|
||||
public this(String linkName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public this(MangleKind mangleKind)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(.Method | .Delegate | .Function)]
|
||||
public struct CallingConventionAttribute : Attribute
|
||||
{
|
||||
public enum Kind
|
||||
{
|
||||
Unspecified,
|
||||
Cdecl,
|
||||
Stdcall,
|
||||
Fastcall,
|
||||
}
|
||||
|
||||
public this(Kind callingConvention)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace System.Diagnostics
|
|||
#endif
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
static extern void Write(char8* str, int strLen);
|
||||
|
||||
public static void Write(String line)
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace System
|
|||
return true;
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern static void ReportTLSMember(int moduleTLSIndex, void* addr, void* markFunc);
|
||||
static void ReportTLSMember(void* addr, void* markFunc)
|
||||
{
|
||||
|
@ -91,8 +92,11 @@ namespace System
|
|||
}
|
||||
|
||||
#if BF_ENABLE_REALTIME_LEAK_CHECK || BF_DEBUG_ALLOC
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void Report();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void Shutdown();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void SetMaxRawDeferredObjectFreePercentage(int maxPercentage);
|
||||
#else
|
||||
public static void Report() {}
|
||||
|
@ -101,19 +105,31 @@ namespace System
|
|||
#endif
|
||||
|
||||
#if BF_ENABLE_REALTIME_LEAK_CHECK
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern static void Init();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void Collect(bool async = true);
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern static void StopCollecting();
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern static void AddStackMarkableObject(Object obj);
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern static void RemoveStackMarkableObject(Object obj);
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
private extern static void MarkAllStaticMembers();
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern static void FindAllTLSMembers();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void DebugDumpLeaks();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void Mark(Object obj);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void Mark(void* ptr, int size);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void SetAutoCollectPeriod(int periodMS); // <= -1 to disable, 0 to constantly run. Defaults to -1
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void SetCollectFreeThreshold(int freeBytes); // -1 to disable, 0 to trigger collection after every single free. Defaults to 64MB
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern static void SetMaxPausePercentage(int maxPausePercentage); // 0 = disabled. Defaults to 20.
|
||||
#else
|
||||
public static void Collect(bool async = true) {}
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace System
|
|||
static class Internal
|
||||
{
|
||||
[Intrinsic("cast")]
|
||||
public static extern Object UnsafeCastToObject(void* ptr);
|
||||
public static extern Object UnsafeCastToObject(void* ptr);
|
||||
[Intrinsic("cast")]
|
||||
public static extern void* UnsafeCastToPtr(Object obj);
|
||||
[NoReturn]
|
||||
[CallingConvention(.Cdecl), NoReturn]
|
||||
public static extern void ThrowIndexOutOfRange(int stackOffset = 0);
|
||||
[NoReturn]
|
||||
[CallingConvention(.Cdecl), NoReturn]
|
||||
public static extern void FatalError(String error, int stackOffset = 0);
|
||||
[Intrinsic("memcpy")]
|
||||
public static extern void MemCpy(void* dest, void* src, int length, int32 align = 1, bool isVolatile = false);
|
||||
|
@ -46,43 +46,70 @@ namespace System
|
|||
public static extern void* StdMalloc(int size);
|
||||
[LinkName("free")]
|
||||
public static extern void StdFree(void* ptr);
|
||||
public static extern void* VirtualAlloc(int size, bool canExecute, bool canWrite);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void* VirtualAlloc(int size, bool canExecute, bool canWrite);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern int32 CStrLen(char8* charPtr);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern int64 GetTickCountMicro();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void BfDelegateTargetCheck(void* target);
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
public static extern void* LoadSharedLibrary(char8* filePath);
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
public static extern void LoadSharedLibraryInto(char8* filePath, void** libDest);
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
public static extern void* GetSharedProcAddress(void* libHandle, char8* procName);
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
public static extern void GetSharedProcAddressInto(void* libHandle, char8* procName, void** procDest);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern char8* GetCommandLineArgs();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void ProfilerCmd(char8* str);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void ReportMemory();
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void ObjectDynCheck(Object obj, int32 typeId, bool allowNull);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void ObjectDynCheckFailed(Object obj, int32 typeId);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectCreated(Object obj, int size, ClassVData* classVData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectCreatedEx(Object obj, int size, ClassVData* classVData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectAllocated(Object obj, int size, ClassVData* classVData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectAllocatedEx(Object obj, int size, ClassVData* classVData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern int Dbg_PrepareStackTrace(int baseAllocSize, int maxStackTraceDepth);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectStackInit(Object object, ClassVData* classVData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern Object Dbg_ObjectAlloc(TypeInstance typeInst, int size);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern Object Dbg_ObjectAlloc(ClassVData* classVData, int size, int align, int maxStackTraceDepth);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectPreDelete(Object obj);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_ObjectPreCustomDelete(Object obj);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_MarkObjectDeleted(Object obj);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void* Dbg_RawAlloc(int size);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void* Dbg_RawObjectAlloc(int size);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void* Dbg_RawAlloc(int size, DbgRawAllocData* rawAllocData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
public static extern void Dbg_RawFree(void* ptr);
|
||||
|
||||
[AlwaysInclude]
|
||||
[CallingConvention(.Cdecl), AlwaysInclude]
|
||||
static extern void Shutdown();
|
||||
[CallingConvention(.Cdecl)]
|
||||
static extern void Test_Init(char8* testData);
|
||||
[CallingConvention(.Cdecl)]
|
||||
static extern int32 Test_Query();
|
||||
[CallingConvention(.Cdecl)]
|
||||
static extern void Test_Finish();
|
||||
|
||||
static void* sModuleHandle;
|
||||
|
|
|
@ -204,12 +204,15 @@ namespace System.Threading
|
|||
}
|
||||
|
||||
public void Suspend() { SuspendInternal(); }
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void SuspendInternal();
|
||||
|
||||
public void Resume() { ResumeInternal(); }
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void ResumeInternal();
|
||||
|
||||
public void Interrupt() { InterruptInternal(); }
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void InterruptInternal();
|
||||
|
||||
public ThreadPriority Priority
|
||||
|
@ -217,7 +220,9 @@ namespace System.Threading
|
|||
get { return (ThreadPriority)GetPriorityNative(); }
|
||||
set { SetPriorityNative((int32)value); }
|
||||
}
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern int32 GetPriorityNative();
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void SetPriorityNative(int32 priority);
|
||||
|
||||
extern bool GetIsAlive();
|
||||
|
@ -229,6 +234,7 @@ namespace System.Threading
|
|||
}
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern bool GetIsThreadPoolThread();
|
||||
public bool IsThreadPoolThread
|
||||
{
|
||||
|
@ -305,6 +311,7 @@ namespace System.Threading
|
|||
}
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
private static extern Thread GetCurrentThreadNative();
|
||||
|
||||
void SetStart(Delegate start, int32 maxStackSize)
|
||||
|
@ -323,7 +330,8 @@ namespace System.Threading
|
|||
// Thread owns delegate
|
||||
delete mDelegate;
|
||||
}
|
||||
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void InternalFinalize();
|
||||
|
||||
public bool IsBackground
|
||||
|
@ -331,16 +339,18 @@ namespace System.Threading
|
|||
get { return IsBackgroundNative(); }
|
||||
set { SetBackgroundNative(value); }
|
||||
}
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern bool IsBackgroundNative();
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void SetBackgroundNative(bool isBackground);
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
public extern void SetJoinOnDelete(bool joinOnDelete);
|
||||
|
||||
public ThreadState ThreadState
|
||||
{
|
||||
get { return (ThreadState)GetThreadStateNative(); }
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern int32 GetThreadStateNative();
|
||||
|
||||
public void SetName(String name)
|
||||
|
@ -363,7 +373,7 @@ namespace System.Threading
|
|||
if (mName != null)
|
||||
outName.Append(mName);
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
private extern void InformThreadNameChange(String name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace System
|
|||
public class Type
|
||||
{
|
||||
extern const Type* sTypes;
|
||||
extern static int32 sTypeCount;
|
||||
|
||||
protected const BindingFlags cDefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
|
||||
|
||||
|
@ -25,7 +26,15 @@ namespace System
|
|||
protected int32 mMemberDataOffset;
|
||||
protected TypeCode mTypeCode;
|
||||
protected uint8 mAlign;
|
||||
|
||||
|
||||
public static TypeId TypeIdEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return (.)sTypeCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int32 Size
|
||||
{
|
||||
get
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue