Index: sky/engine/tonic/dart_wrappable.cc |
diff --git a/sky/engine/tonic/dart_wrappable.cc b/sky/engine/tonic/dart_wrappable.cc |
index c52a27ac80bf49282a8f5fb447d7e9e41869d901..c04bc1ea2f0a4ab9a73eeff54cb0a208240dea93 100644 |
--- a/sky/engine/tonic/dart_wrappable.cc |
+++ b/sky/engine/tonic/dart_wrappable.cc |
@@ -41,6 +41,29 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) { |
return wrapper; |
} |
+void DartWrappable::AssociateWithDartWrapper(Dart_NativeArguments args) { |
+ DCHECK(!dart_wrapper_); |
+ |
+ Dart_Handle wrapper = Dart_GetNativeArgument(args, 0); |
+ CHECK(!LogIfError(wrapper)); |
+ |
+ intptr_t native_fields[kNumberOfNativeFields]; |
+ CHECK(!LogIfError(Dart_GetNativeFieldsOfArgument( |
+ args, 0, kNumberOfNativeFields, native_fields))); |
esprehn
2015/02/20 06:56:10
So all things have the same number of native field
abarth-chromium
2015/02/20 07:00:34
Yes. Always two there are.
|
+ CHECK(!native_fields[kPeerIndex]); |
+ CHECK(!native_fields[kWrapperInfoIndex]); |
+ |
+ const DartWrapperInfo& info = GetDartWrapperInfo(); |
+ CHECK(!LogIfError(Dart_SetNativeInstanceField( |
+ wrapper, kPeerIndex, reinterpret_cast<intptr_t>(this)))); |
+ CHECK(!LogIfError(Dart_SetNativeInstanceField( |
+ wrapper, kWrapperInfoIndex, reinterpret_cast<intptr_t>(&info)))); |
+ |
+ info.ref_object(this); // Balanced in FinalizeDartWrapper. |
+ dart_wrapper_ = Dart_NewPrologueWeakPersistentHandle( |
+ wrapper, this, info.size_in_bytes, &FinalizeDartWrapper); |
+} |
+ |
void DartWrappable::FinalizeDartWrapper(void* isolate_callback_data, |
Dart_WeakPersistentHandle wrapper, |
void* peer) { |