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

Unified Diff: runtime/vm/object.cc

Issue 349643003: Add a function Dart_AllocateWithNativeFields which allocates an object and sets the native fields i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
« runtime/include/dart_api.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 37560)
+++ runtime/vm/object.cc (working copy)
@@ -13092,6 +13092,23 @@
}
+void Instance::SetNativeFields(uint16_t num_native_fields,
+ const intptr_t* field_values) const {
+ ASSERT(num_native_fields == NumNativeFields());
+ ASSERT(field_values != NULL);
+ Object& native_fields = Object::Handle(*NativeFieldsAddr());
+ if (native_fields.IsNull()) {
+ // Allocate backing storage for the native fields.
+ native_fields = TypedData::New(kIntPtrCid, NumNativeFields());
+ StorePointer(NativeFieldsAddr(), native_fields.raw());
+ }
+ for (uint16_t i = 0; i < num_native_fields; i++) {
+ intptr_t byte_offset = i * sizeof(intptr_t);
+ TypedData::Cast(native_fields).SetIntPtr(byte_offset, field_values[i]);
+ }
+}
+
+
bool Instance::IsClosure() const {
const Class& cls = Class::Handle(clazz());
return cls.IsSignatureClass();
« runtime/include/dart_api.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698