File tree 2 files changed +22
-0
lines changed
Generation/Generator/Renderer/Public
Tests/Libs/GirTest-0.1.Tests
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ public partial class {name}
34
34
Initialize();
35
35
}}
36
36
37
+ //TODO: This is a workaround constructor as long as we are
38
+ //not having https://github.com/gircore/gir.core/issues/397
39
+ private { name } (IntPtr ptr, bool ownsHandle) : this(ownsHandle
40
+ ? new { Model . OpaqueTypedRecord . GetFullyQuallifiedOwnedHandle ( record ) } (ptr)
41
+ : new { Model . OpaqueTypedRecord . GetFullyQuallifiedUnownedHandle ( record ) } (ptr).OwnedCopy()){{ }}
42
+
37
43
// Implement this to perform additional steps in the constructor
38
44
partial void Initialize();
39
45
Original file line number Diff line number Diff line change @@ -287,4 +287,20 @@ void Callback(OpaqueTypedRecordTester? obj)
287
287
288
288
called . Should ( ) . BeTrue ( ) ;
289
289
}
290
+
291
+ [ TestMethod ]
292
+ public void SupportsWrapHandle ( )
293
+ {
294
+ var recordTester = OpaqueTypedRecordTester . New ( ) ;
295
+
296
+ var wrapped = ( OpaqueTypedRecordTester ) GObject . Internal . BoxedWrapper . WrapHandle (
297
+ handle : recordTester . Handle . DangerousGetHandle ( ) ,
298
+ ownsHandle : false ,
299
+ gtype : OpaqueTypedRecordTester . GetGType ( )
300
+ ) ;
301
+
302
+ wrapped . Handle . DangerousGetHandle ( ) . Should ( ) . Be ( recordTester . Handle . DangerousGetHandle ( ) ) ;
303
+ recordTester . GetRefCount ( ) . Should ( ) . Be ( 2 ) ;
304
+ wrapped . GetRefCount ( ) . Should ( ) . Be ( 2 ) ;
305
+ }
290
306
}
You can’t perform that action at this time.
0 commit comments