@@ -26,7 +26,7 @@ mixin ComparableMixin {
2626/// Base class for wrapping C++ objects in Dart
2727abstract class NativeObject with ComparableMixin implements ffi.Finalizable {
2828 /// Pointer to the underlying C++ object
29- final ffi.Pointer <ffi.Void > _ptr;
29+ ffi.Pointer <ffi.Void > _ptr;
3030
3131 ffi.NativeFinalizer get finalizer;
3232
@@ -56,6 +56,14 @@ abstract class NativeObject with ComparableMixin implements ffi.Finalizable {
5656 @protected
5757 void release ();
5858
59+ void reattach (ffi.Pointer <ffi.Void > ptr) {
60+ dispose ();
61+ _ptr = ptr;
62+ if (attach) {
63+ finalizer.attach (this , _ptr, detach: this );
64+ }
65+ }
66+
5967 @mustCallSuper
6068 void dispose () {
6169 if (attach) {
@@ -97,13 +105,13 @@ void MnnAssert(bool condition, String message) {
97105 }
98106}
99107
100- typedef u8 = ffi.Uint8 ;
101- typedef u16 = ffi.Uint16 ;
102- typedef u32 = ffi.Uint32 ;
103- typedef u64 = ffi.Uint64 ;
104- typedef i8 = ffi.Int8 ;
105- typedef i16 = ffi.Int16 ;
106- typedef i32 = ffi.Int32 ;
107- typedef i64 = ffi.Int64 ;
108- typedef f32 = ffi.Float ;
109- typedef f64 = ffi.Double ;
108+ typedef uint8 = ffi.Uint8 ;
109+ typedef uint16 = ffi.Uint16 ;
110+ typedef uint32 = ffi.Uint32 ;
111+ typedef uint64 = ffi.Uint64 ;
112+ typedef int8 = ffi.Int8 ;
113+ typedef int16 = ffi.Int16 ;
114+ typedef int32 = ffi.Int32 ;
115+ typedef int64 = ffi.Int64 ;
116+ typedef float32 = ffi.Float ;
117+ typedef float64 = ffi.Double ;
0 commit comments