66
77namespace SwiftRuntimeLibrary {
88 [ SwiftNativeObject ( ) ]
9- public class BaseAssociatedTypeProxy : ISwiftObject {
10- IntPtr handle ;
11- SwiftMetatype class_handle ;
12- SwiftObjectFlags object_flags = SwiftObjectFlags . IsSwift ;
13-
9+ public class BaseAssociatedTypeProxy : SwiftNativeObject {
1410 protected BaseAssociatedTypeProxy ( IntPtr handle , SwiftMetatype classHandle , SwiftObjectRegistry registry )
11+ : base ( handle , classHandle , registry )
1512 {
16- if ( SwiftNativeObjectAttribute . IsSwiftNativeObject ( this ) ) {
17- object_flags |= SwiftObjectFlags . IsDirectBinding ;
18- }
19- class_handle = classHandle ;
20- SwiftObject = handle ;
2113 if ( IsCSObjectProxy )
2214 registry . Add ( this ) ;
2315 }
2416
2517 protected BaseAssociatedTypeProxy ( byte [ ] swiftTypeData , SwiftMetatype mt )
18+ : base ( IntPtr . Zero , mt , SwiftObjectRegistry . Registry )
2619 {
2720 if ( swiftTypeData == null )
2821 throw new ArgumentNullException ( nameof ( swiftTypeData ) ) ;
@@ -33,33 +26,11 @@ protected BaseAssociatedTypeProxy (byte [] swiftTypeData, SwiftMetatype mt)
3326 ProxiedMetatype = mt ;
3427 }
3528
36- public void Dispose ( )
37- {
38- Dispose ( true ) ;
39- GC . SuppressFinalize ( this ) ;
40- }
41-
42- protected virtual void Dispose ( bool disposing )
29+ protected override void DisposeUnmanagedResources ( )
4330 {
44- if ( ( object_flags & SwiftObjectFlags . Disposed ) != SwiftObjectFlags . Disposed ) {
45- if ( disposing ) {
46- DisposeManagedResources ( ) ;
47- }
48- if ( IsCSObjectProxy )
49- SwiftObjectRegistry . Registry . RemoveAndWeakRelease ( this ) ;
50- DisposeUnmanagedResources ( ) ;
51- object_flags |= SwiftObjectFlags . Disposed ;
52- }
53- }
5431
55- protected virtual void DisposeManagedResources ( )
56- {
57- }
58-
59- protected virtual void DisposeUnmanagedResources ( )
60- {
6132 if ( IsCSObjectProxy ) {
62- SwiftCore . Release ( SwiftObject ) ;
33+ base . DisposeUnmanagedResources ( ) ;
6334 } else {
6435 StructMarshal . Marshaler . NominalDestroy ( ProxiedMetatype , SwiftData ) ;
6536 }
@@ -70,16 +41,7 @@ protected virtual void DisposeUnmanagedResources ()
7041 Dispose ( false ) ;
7142 }
7243
73- protected bool IsCSObjectProxy => handle != IntPtr . Zero ;
74-
75- public IntPtr SwiftObject {
76- get {
77- return handle ;
78- }
79- private set {
80- handle = value ;
81- }
82- }
44+ protected bool IsCSObjectProxy => SwiftObject != IntPtr . Zero ;
8345
8446 protected byte [ ] SwiftData { get ; set ; }
8547
0 commit comments