7
7
8
8
namespace SwiftRuntimeLibrary {
9
9
public sealed class SwiftAnyObject : SwiftNativeObject {
10
- SwiftAnyObject ( IntPtr ptr )
10
+ SwiftAnyObject ( IntPtr ptr )
11
11
: base ( ptr , GetSwiftMetatype ( ) , SwiftObjectRegistry . Registry )
12
12
{
13
+ SwiftCore . Retain ( ptr ) ;
13
14
}
14
15
15
16
~ SwiftAnyObject ( )
@@ -22,7 +23,7 @@ public static SwiftAnyObject XamarinFactory (IntPtr p)
22
23
return new SwiftAnyObject ( p ) ;
23
24
}
24
25
25
- public static SwiftAnyObject FromISwiftObject ( ISwiftObject obj )
26
+ public static SwiftAnyObject FromISwiftObject ( ISwiftObject obj )
26
27
{
27
28
if ( obj == null )
28
29
throw new ArgumentNullException ( nameof ( obj ) ) ;
@@ -37,7 +38,7 @@ public static SwiftMetatype GetSwiftMetatype ()
37
38
public T CastAs < T > ( ) where T : class , ISwiftObject
38
39
{
39
40
var metaType = StructMarshal . Marshaler . Metatypeof ( typeof ( T ) ) ;
40
- using ( var optional = SwiftOptional < T > . None ( ) ) {
41
+ using ( var optional = SwiftOptional < T > . None ( ) ) {
41
42
unsafe {
42
43
fixed ( byte * dataPtr = StructMarshal . Marshaler . PrepareNominal ( optional ) ) {
43
44
NativeMethodsForSwiftAnyObject . CastAs ( new IntPtr ( dataPtr ) , SwiftObject , metaType ) ;
@@ -51,8 +52,7 @@ public T CastAs<T> () where T : class, ISwiftObject
51
52
}
52
53
53
54
internal static class NativeMethodsForSwiftAnyObject {
54
- [ DllImport ( SwiftCore . kXamGlue , EntryPoint = XamGlueConstants . SwiftAnyObject_CastAs ) ]
55
+ [ DllImport ( SwiftCore . kXamGlue , EntryPoint = XamGlueConstants . SwiftAnyObject_CastAs ) ]
55
56
public static extern void CastAs ( IntPtr retval , IntPtr obj , SwiftMetatype meta ) ;
56
57
}
57
- }
58
-
58
+ }
0 commit comments