diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Plugins/iOS/CoreBluetoothForUnity.framework/CoreBluetoothForUnity b/Packages/com.teach310.core-bluetooth-for-unity/Plugins/iOS/CoreBluetoothForUnity.framework/CoreBluetoothForUnity index 09dccd7..4d89332 100755 Binary files a/Packages/com.teach310.core-bluetooth-for-unity/Plugins/iOS/CoreBluetoothForUnity.framework/CoreBluetoothForUnity and b/Packages/com.teach310.core-bluetooth-for-unity/Plugins/iOS/CoreBluetoothForUnity.framework/CoreBluetoothForUnity differ diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Plugins/macOS/libCoreBluetoothForUnity.dylib b/Packages/com.teach310.core-bluetooth-for-unity/Plugins/macOS/libCoreBluetoothForUnity.dylib index 48e8a9d..aacb7ce 100755 Binary files a/Packages/com.teach310.core-bluetooth-for-unity/Plugins/macOS/libCoreBluetoothForUnity.dylib and b/Packages/com.teach310.core-bluetooth-for-unity/Plugins/macOS/libCoreBluetoothForUnity.dylib differ diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs new file mode 100644 index 0000000..66921d9 --- /dev/null +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs @@ -0,0 +1,15 @@ +using System; + +namespace CoreBluetooth.Foundation +{ + internal static class AnyObject + { + public static void Release(IntPtr handle) + { + if (handle != IntPtr.Zero) + { + NativeMethods.any_object_release(handle); + } + } + } +} diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs.meta b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs.meta new file mode 100644 index 0000000..85fda1b --- /dev/null +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/AnyObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d08359fda0701497991b4c454cd8791f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/NativeMethods.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/NativeMethods.cs index b8b4f33..3751f03 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/NativeMethods.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/NativeMethods.cs @@ -12,7 +12,7 @@ internal static class NativeMethods #endif [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void ns_object_release(IntPtr handle); + internal static extern void any_object_release(IntPtr handle); [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern SafeNSNumberHandle ns_number_new_bool([MarshalAs(UnmanagedType.I1)] bool value); diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/SafeNSObjectHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/SafeNSObjectHandle.cs index 4a0473c..b88ac48 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/SafeNSObjectHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/Foundation/SafeNSObjectHandle.cs @@ -13,7 +13,7 @@ protected SafeNSObjectHandle(IntPtr handle) : base(true) protected override bool ReleaseHandle() { - NativeMethods.ns_object_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/NativeMethods.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/NativeMethods.cs index 76f8178..89477d5 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/NativeMethods.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/NativeMethods.cs @@ -12,9 +12,6 @@ internal static class NativeMethods #else const string DLL_NAME = "libCoreBluetoothForUnity"; #endif - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_central_release(IntPtr handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr cb4u_central_identifier( SafeNativeCentralHandle handle, @@ -74,9 +71,6 @@ int serviceUUIDsCount [return: MarshalAs(UnmanagedType.I1)] internal static extern bool cb4u_central_manager_is_scanning(SafeNativeCentralManagerHandle handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_peripheral_release(IntPtr handle); - // NOTE: using comma-separated service UUIDs instead of an array of service UUIDs to avoid marshalling issues internal delegate void CB4UPeripheralDidDiscoverServicesHandler(IntPtr peripheralPtr, IntPtr commaSeparatedServiceUUIDsPtr, int errorCode); internal delegate void CB4UPeripheralDidDiscoverCharacteristicsHandler(IntPtr peripheralPtr, IntPtr serviceUUIDPtr, IntPtr commaSeparatedCharacteristicUUIDsPtr, int errorCode); @@ -179,9 +173,6 @@ internal static extern int cb4u_peripheral_characteristic_properties( [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern SafeNativePeripheralManagerHandle cb4u_peripheral_manager_new(IntPtr options); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_peripheral_manager_release(IntPtr handle); - internal delegate void CB4UPeripheralManagerDidUpdateStateHandler(IntPtr peripheralManagerPtr, CBManagerState state); internal delegate void CB4UPeripheralManagerDidAddServiceHandler(IntPtr peripheralManagerPtr, IntPtr serviceUUIDPtr, int errorCode); internal delegate void CB4UPeripheralManagerDidStartAdvertisingHandler(IntPtr peripheralManagerPtr, int errorCode); @@ -251,9 +242,6 @@ int subscribedCentralsCount [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern SafeNativeMutableServiceHandle cb4u_mutable_service_new([MarshalAs(UnmanagedType.LPStr), In] string uuid, [MarshalAs(UnmanagedType.I1)] bool primary); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_mutable_service_release(IntPtr handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern int cb4u_mutable_service_set_characteristics(SafeNativeMutableServiceHandle handle, IntPtr[] characteristics, int characteristicsCount); @@ -266,9 +254,6 @@ internal static extern SafeNativeMutableCharacteristicHandle cb4u_mutable_charac int permissions ); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_mutable_characteristic_release(IntPtr handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern int cb4u_mutable_characteristic_value_length(SafeNativeMutableCharacteristicHandle handle); @@ -290,9 +275,6 @@ int permissions [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern void cb4u_mutable_characteristic_set_permissions(SafeNativeMutableCharacteristicHandle handle, int permissions); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern void cb4u_att_request_release(IntPtr handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr cb4u_att_request_central(SafeNativeATTRequestHandle handle); @@ -317,9 +299,6 @@ int characteristicUUIDSize [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern int cb4u_att_request_offset(SafeNativeATTRequestHandle handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr cb4u_att_requests_release(IntPtr handle); - [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)] internal static extern int cb4u_att_requests_count(SafeNativeATTRequestsHandle handle); diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestHandle.cs index fb147db..d548a54 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestHandle.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using CoreBluetooth.Foundation; namespace CoreBluetooth { @@ -11,7 +12,7 @@ internal SafeNativeATTRequestHandle(IntPtr handle) : base(handle, true) { } protected override bool ReleaseHandle() { - NativeMethods.cb4u_att_request_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestsHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestsHandle.cs index f756558..e913841 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestsHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeATTRequestsHandle.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using CoreBluetooth.Foundation; namespace CoreBluetooth { @@ -11,7 +12,7 @@ internal SafeNativeATTRequestsHandle(IntPtr handle) : base(handle, true) { } protected override bool ReleaseHandle() { - NativeMethods.cb4u_att_requests_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralHandle.cs index c58f8e9..92c04f8 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralHandle.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using CoreBluetooth.Foundation; namespace CoreBluetooth { @@ -11,7 +12,7 @@ internal SafeNativeCentralHandle(IntPtr handle) : base(handle, true) { } protected override bool ReleaseHandle() { - NativeMethods.cb4u_central_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralManagerHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralManagerHandle.cs index 14911f2..5742ea4 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralManagerHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeCentralManagerHandle.cs @@ -1,4 +1,5 @@ using System; +using CoreBluetooth.Foundation; using Microsoft.Win32.SafeHandles; namespace CoreBluetooth @@ -24,7 +25,7 @@ public static SafeNativeCentralManagerHandle Create() protected override bool ReleaseHandle() { - NativeMethods.cb4u_central_manager_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableCharacteristicHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableCharacteristicHandle.cs index 5eaf019..6fca81a 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableCharacteristicHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableCharacteristicHandle.cs @@ -1,3 +1,4 @@ +using CoreBluetooth.Foundation; using Microsoft.Win32.SafeHandles; namespace CoreBluetooth @@ -23,7 +24,7 @@ CBAttributePermissions permissions protected override bool ReleaseHandle() { - NativeMethods.cb4u_mutable_characteristic_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableServiceHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableServiceHandle.cs index 80fd0a7..50c3895 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableServiceHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativeMutableServiceHandle.cs @@ -1,3 +1,4 @@ +using CoreBluetooth.Foundation; using Microsoft.Win32.SafeHandles; namespace CoreBluetooth @@ -13,7 +14,7 @@ internal static SafeNativeMutableServiceHandle Create(string uuid, bool isPrimar protected override bool ReleaseHandle() { - NativeMethods.cb4u_mutable_service_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs index ca05f39..2d95122 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralHandle.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using CoreBluetooth.Foundation; namespace CoreBluetooth { @@ -13,7 +14,7 @@ internal SafeNativePeripheralHandle(IntPtr handle) : base(handle, true) protected override bool ReleaseHandle() { - NativeMethods.cb4u_peripheral_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralManagerHandle.cs b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralManagerHandle.cs index b3737dd..93b1c52 100644 --- a/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralManagerHandle.cs +++ b/Packages/com.teach310.core-bluetooth-for-unity/Runtime/SafeNativePeripheralManagerHandle.cs @@ -1,4 +1,5 @@ using System; +using CoreBluetooth.Foundation; using Microsoft.Win32.SafeHandles; namespace CoreBluetooth @@ -24,7 +25,7 @@ internal static SafeNativePeripheralManagerHandle Create() protected override bool ReleaseHandle() { - NativeMethods.cb4u_peripheral_manager_release(handle); + AnyObject.Release(handle); return true; } } diff --git a/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/CoreBluetoothForUnity.swift b/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/CoreBluetoothForUnity.swift index 94d30a6..d5cfa69 100644 --- a/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/CoreBluetoothForUnity.swift +++ b/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/CoreBluetoothForUnity.swift @@ -1,10 +1,5 @@ import CoreBluetooth -@_cdecl("cb4u_central_release") -public func cb4u_central_release(_ centralPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(centralPtr).release() -} - @_cdecl("cb4u_central_identifier") public func cb4u_central_identifier(_ centralPtr: UnsafeRawPointer, _ identifier: UnsafeMutablePointer, _ identifierSize: Int32) { let instance = Unmanaged.fromOpaque(centralPtr).takeUnretainedValue() @@ -38,11 +33,6 @@ public func cb4u_central_manager_new(_ optionsPtr: UnsafeRawPointer?) -> UnsafeM return Unmanaged.passRetained(CB4UCentralManager(options)).toOpaque() } -@_cdecl("cb4u_central_manager_release") -public func cb4u_central_manager_release(_ centralManagerPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(centralManagerPtr).release() -} - public typealias CB4UCentralManagerDidConnectHandler = @convention(c) (UnsafeRawPointer, UnsafePointer) -> Void public typealias CB4UCentralManagerDidDisconnectPeripheralHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, Int32) -> Void public typealias CB4UCentralManagerDidFailToConnectHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, Int32) -> Void @@ -133,11 +123,6 @@ public func cb4u_central_manager_is_scanning(_ centralPtr: UnsafeRawPointer) -> return instance.isScanning } -@_cdecl("cb4u_peripheral_release") -public func cb4u_peripheral_release(_ peripheralPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(peripheralPtr).release() -} - public typealias CB4UPeripheralDidDiscoverServicesHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, Int32) -> Void public typealias CB4UPeripheralDidDiscoverCharacteristicsHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, UnsafePointer, Int32) -> Void public typealias CB4UPeripheralDidUpdateValueForCharacteristicHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, UnsafePointer, UnsafePointer, Int32, Int32) -> Void @@ -328,15 +313,10 @@ public func cb4u_peripheral_manager_new(_ optionsPtr: UnsafeRawPointer?) -> Unsa let nsMutableDictionary = Unmanaged.fromOpaque(optionsPtr).takeUnretainedValue() options = nsMutableDictionary as? [String: Any] } - + return Unmanaged.passRetained(CB4UPeripheralManager(options)).toOpaque() } -@_cdecl("cb4u_peripheral_manager_release") -public func cb4u_peripheral_manager_release(_ peripheralManagerPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(peripheralManagerPtr).release() -} - public typealias CB4UPeripheralManagerDidUpdateStateHandler = @convention(c) (UnsafeRawPointer, Int32) -> Void public typealias CB4UPeripheralManagerDidAddServiceHandler = @convention(c) (UnsafeRawPointer, UnsafePointer, Int32) -> Void public typealias CB4UPeripheralManagerDidStartAdvertisingHandler = @convention(c) (UnsafeRawPointer, Int32) -> Void @@ -457,11 +437,6 @@ public func cb4u_mutable_service_new(_ serviceUUID: UnsafePointer, _ prim return Unmanaged.passRetained(CB4UMutableService(service: service)).toOpaque() } -@_cdecl("cb4u_mutable_service_release") -public func cb4u_mutable_service_release(_ servicePtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(servicePtr).release() -} - @_cdecl("cb4u_mutable_service_set_characteristics") public func cb4u_mutable_service_set_characteristics(_ servicePtr: UnsafeRawPointer, _ characteristicsPtr: UnsafePointer?, _ characteristicsCount: Int32) { let service = Unmanaged.fromOpaque(servicePtr).takeUnretainedValue() @@ -495,11 +470,6 @@ public func cb4u_mutable_characteristic_new( return Unmanaged.passRetained(CB4UMutableCharacteristic(characteristic: characteristic)).toOpaque() } -@_cdecl("cb4u_mutable_characteristic_release") -public func cb4u_mutable_characteristic_release(_ characteristicPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(characteristicPtr).release() -} - @_cdecl("cb4u_mutable_characteristic_value_length") public func cb4u_mutable_characteristic_value_length(_ characteristicPtr: UnsafeRawPointer) -> Int32 { let instance = Unmanaged.fromOpaque(characteristicPtr).takeUnretainedValue() @@ -561,11 +531,6 @@ public func cb4u_mutable_characteristic_set_permissions(_ characteristicPtr: Uns instance.permissions = CBAttributePermissions(rawValue: UInt(permissions)) } -@_cdecl("cb4u_att_request_release") -public func cb4u_att_request_release(_ requestPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(requestPtr).release() -} - @_cdecl("cb4u_att_request_central") public func cb4u_att_request_central(_ requestPtr: UnsafeRawPointer) -> UnsafeMutableRawPointer { let instance = Unmanaged.fromOpaque(requestPtr).takeUnretainedValue() @@ -646,11 +611,6 @@ public func cb4u_att_request_offset(_ requestPtr: UnsafeRawPointer) -> Int32 { return Int32(instance.offset) } -@_cdecl("cb4u_att_requests_release") -public func cb4u_att_requests_release(_ requestsPtr: UnsafeRawPointer) { - Unmanaged.fromOpaque(requestsPtr).release() -} - @_cdecl("cb4u_att_requests_count") public func cb4u_att_requests_count(_ requestsPtr: UnsafeRawPointer) -> Int32 { let instance = Unmanaged.fromOpaque(requestsPtr).takeUnretainedValue() diff --git a/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/FoundationForUnity/FoundationForUnity.swift b/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/FoundationForUnity/FoundationForUnity.swift index 3d6da2f..8ed0c31 100644 --- a/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/FoundationForUnity/FoundationForUnity.swift +++ b/Plugins/CoreBluetoothForUnity/Sources/CoreBluetoothForUnity/FoundationForUnity/FoundationForUnity.swift @@ -1,8 +1,8 @@ import Foundation -@_cdecl("ns_object_release") -public func ns_object_release(_ handle: UnsafeRawPointer) { - Unmanaged.fromOpaque(handle).release() +@_cdecl("any_object_release") +public func any_object_release(_ handle: UnsafeRawPointer) { + Unmanaged.fromOpaque(handle).release() } @_cdecl("ns_number_new_bool") @@ -85,19 +85,19 @@ public func ns_mutable_dictionary_new() -> UnsafeMutableRawPointer { @_cdecl("ns_mutable_dictionary_get_value") public func ns_mutable_dictionary_get_value(_ handle: UnsafeRawPointer, _ keyPtr: UnsafeRawPointer) -> UnsafeMutableRawPointer? { let instance = Unmanaged.fromOpaque(handle).takeUnretainedValue() - + let key = Unmanaged.fromOpaque(keyPtr).takeUnretainedValue() if let value = instance[key] as? NSObject { return Unmanaged.passRetained(value).toOpaque() } - + return nil } @_cdecl("ns_mutable_dictionary_set_value") public func ns_mutable_dictionary_set_value(_ handle: UnsafeRawPointer, _ keyPtr: UnsafeRawPointer, _ valuePtr: UnsafeRawPointer?) { let instance = Unmanaged.fromOpaque(handle).takeUnretainedValue() - + let key = Unmanaged.fromOpaque(keyPtr).takeUnretainedValue() if let valuePtr = valuePtr { let value = Unmanaged.fromOpaque(valuePtr).takeUnretainedValue()