[src] Make a few P/Invokes stragglers have blittable signatures. (#20675)

Contributes towards #15684.
This commit is contained in:
Rolf Bjarne Kvinge 2024-06-04 14:51:51 +02:00 коммит произвёл GitHub
Родитель aa25b1e191
Коммит 05a9b0872f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 29 добавлений и 10 удалений

Просмотреть файл

@ -88,7 +88,11 @@ namespace AudioUnit {
static IntPtr Create ()
{
int err = NewAUGraph (out var handle);
IntPtr handle;
int err;
unsafe {
err = NewAUGraph (&handle);
}
if (err != 0)
throw new InvalidOperationException (String.Format ("Cannot create new AUGraph. Error code: {0}", err));
return handle;
@ -101,7 +105,10 @@ namespace AudioUnit {
public static AUGraph? Create (out int errorCode)
{
errorCode = NewAUGraph (out var handle);
IntPtr handle;
unsafe {
errorCode = NewAUGraph (&handle);
}
if (errorCode != 0)
return null;
@ -483,7 +490,7 @@ namespace AudioUnit {
}
[DllImport (Constants.AudioToolboxLibrary, EntryPoint = "NewAUGraph")]
static extern int /* OSStatus */ NewAUGraph (out IntPtr outGraph);
unsafe static extern int /* OSStatus */ NewAUGraph (IntPtr* outGraph);
[DllImport (Constants.AudioToolboxLibrary, EntryPoint = "AUGraphOpen")]
static extern int /* OSStatus */ AUGraphOpen (IntPtr inGraph);

Просмотреть файл

@ -138,10 +138,21 @@ namespace ObjCRuntime {
[DllImport (Messaging.LIBOBJC_DYLIB)]
extern static /* const char* */ IntPtr sel_getName (/* SEL */ IntPtr sel);
// objc/runtime.h
[DllImport (Messaging.LIBOBJC_DYLIB)]
extern static /* SEL */ IntPtr sel_registerName (/* const char* */ IntPtr name);
// objc/runtime.h
// Selector.GetHandle is optimized by the AOT compiler, and the current implementation only supports IntPtr, so we can't switch to NativeHandle quite yet (the AOT compiler crashes).
[DllImport (Messaging.LIBOBJC_DYLIB, EntryPoint = "sel_registerName")]
public extern static /* SEL */ IntPtr GetHandle (/* const char* */ string name);
public static IntPtr GetHandle (string name)
{
var ptr = Marshal.StringToHGlobalAnsi (name);
try {
return sel_registerName (ptr);
} finally {
Marshal.FreeHGlobal (ptr);
}
}
// objc/objc.h
[DllImport (Messaging.LIBOBJC_DYLIB)]

Просмотреть файл

@ -1206,7 +1206,7 @@ namespace Security {
[SupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.SecurityLibrary)]
static extern /* CFDataRef _Nullable */ IntPtr SecKeyCreateEncryptedData (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr plaintext, /* CFErrorRef* */ out IntPtr error);
unsafe static extern /* CFDataRef _Nullable */ IntPtr SecKeyCreateEncryptedData (/* SecKeyRef */ IntPtr key, /* SecKeyAlgorithm */ IntPtr algorithm, /* CFDataRef */ IntPtr plaintext, /* CFErrorRef* */ IntPtr* error);
#if NET
[SupportedOSPlatform ("tvos")]
@ -1219,7 +1219,11 @@ namespace Security {
if (plaintext is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (plaintext));
var data = SecKeyCreateEncryptedData (Handle, algorithm.GetConstant ().GetHandle (), plaintext.Handle, out var err);
IntPtr data;
IntPtr err;
unsafe {
data = SecKeyCreateEncryptedData (Handle, algorithm.GetConstant ().GetHandle (), plaintext.Handle, &err);
}
error = Runtime.GetNSObject<NSError> (err);
return Runtime.GetNSObject<NSData> (data, true);
}

Просмотреть файл

@ -27,9 +27,6 @@ namespace Cecil.Tests {
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)",
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
"System.Int32 AudioUnit.AUGraph::NewAUGraph(System.IntPtr&)",
"System.IntPtr ObjCRuntime.Selector::GetHandle(System.String)",
"System.IntPtr Security.SecKey::SecKeyCreateEncryptedData(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
"System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",
"System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalResistiveStrengths(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalResistiveStrengths)",
"System.Void ObjCRuntime.Messaging::void_objc_msgSendSuper_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",