mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 23:34:10 +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
|
@ -156,12 +156,41 @@ 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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[AttributeUsage(.Method | .Delegate | .Function)]
|
||||
public struct StdCallAttribute : Attribute
|
||||
{
|
||||
|
|
|
@ -23,8 +23,9 @@ namespace System.Diagnostics
|
|||
}
|
||||
|
||||
#if !DEBUG
|
||||
[SkipCall]
|
||||
[CallingConvention(.Cdecl), SkipCall]
|
||||
#endif
|
||||
[CallingConvention(.Cdecl)]
|
||||
static extern void Write(char8* str, int strLen);
|
||||
|
||||
public static void WriteLine(StringView 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) {}
|
||||
|
|
|
@ -17,9 +17,9 @@ namespace System
|
|||
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);
|
||||
|
@ -35,43 +35,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;
|
||||
|
|
|
@ -152,8 +152,11 @@ namespace System.Threading
|
|||
}
|
||||
}
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern void ManualThreadInit();
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern void StartInternal();
|
||||
[CallingConvention(.Cdecl)]
|
||||
extern void SetStackStart(void* ptr);
|
||||
|
||||
public void Start(bool autoDelete = true)
|
||||
|
@ -266,7 +269,8 @@ namespace System.Threading
|
|||
{
|
||||
SpinWaitInternal((int32)iterations);
|
||||
}
|
||||
|
||||
|
||||
[CallingConvention(.Cdecl)]
|
||||
private static extern bool YieldInternal();
|
||||
|
||||
public static bool Yield()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue