mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Changed FFI API to handle user case where BF_CRT_DISABLE is defined
This commit is contained in:
parent
95a9c7aa8e
commit
96c13e095f
1 changed files with 12 additions and 1 deletions
|
@ -131,7 +131,8 @@ namespace System.FFI
|
|||
{
|
||||
OK,
|
||||
BadTypeDef,
|
||||
BadABI
|
||||
BadABI,
|
||||
NoBeefCRT,
|
||||
}
|
||||
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
|
@ -199,9 +200,11 @@ namespace System.FFI
|
|||
uint32 mFlags;
|
||||
}
|
||||
|
||||
#if !BF_CRT_DISABLE
|
||||
public static extern void* ClosureAlloc(int size, void** outFunc);
|
||||
public static extern FFIResult PrepCif(FFICIF* cif, FFIABI abi, int32 nargs, FFIType* rtype, FFIType** argTypes);
|
||||
public static extern void Call(FFICIF* cif, void* funcPtr, void* rvalue, void** args);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct FFICaller
|
||||
|
@ -210,15 +213,23 @@ namespace System.FFI
|
|||
|
||||
public Result<void, FFIResult> Prep(FFIABI abi, int32 nargs, FFIType* rtype, FFIType** argTypes) mut
|
||||
{
|
||||
#if !BF_CRT_DISABLE
|
||||
let res = FFILIB.PrepCif(&mCIF, abi, nargs, rtype, argTypes);
|
||||
if (res == .OK)
|
||||
return .Ok;
|
||||
return .Err(res);
|
||||
#else
|
||||
return .Err(.NoBeefCRT);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Call(void* funcPtr, void* rvalue, void** args) mut
|
||||
{
|
||||
#if !BF_CRT_DISABLE
|
||||
FFILIB.Call(&mCIF, funcPtr, rvalue, args);
|
||||
#else
|
||||
Internal.FatalError("FFI requires Beef runtime.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue