Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2065)

Unified Diff: sky/engine/tonic/dart_wrappable.cc

Issue 936193005: Make it possible to inherit from any constructable host object (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove extra comment Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/tonic/dart_wrappable.h ('k') | sky/tests/dom/inherit-from-text.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « sky/engine/tonic/dart_wrappable.h ('k') | sky/tests/dom/inherit-from-text.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698