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

Unified Diff: vm/object.cc

Issue 8537023: Implement automatic loading of dart:core_native_fields library (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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
Index: vm/object.cc
===================================================================
--- vm/object.cc (revision 1545)
+++ vm/object.cc (working copy)
@@ -566,6 +566,11 @@
bool_value = Bool::New(false);
object_store->set_false_value(bool_value);
+ // Setup some default native field classes which can be extended for
+ // specifying native fields in dart classes.
+ Library::InitNativeFieldsLibrary(isolate);
+ ASSERT(isolate->object_store()->native_fields_library() != Library::null());
+
// Finish the initialization by compiling the bootstrap scripts containing the
// base interfaces and the implementation of the internal classes.
Bootstrap::Compile(core_lib, script);
@@ -4102,6 +4107,27 @@
}
+void Library::InitNativeFieldsLibrary(Isolate* isolate) {
+ static const int kNumNativeFieldClasses = 4;
+ ASSERT(kNumNativeFieldClasses > 0 && kNumNativeFieldClasses < 10);
+ const String& native_flds_lib_url = String::Handle(
+ String::NewSymbol("dart:core-native-fields"));
+ Library& native_flds_lib = Library::Handle(
+ Library::NewLibraryHelper(native_flds_lib_url, false));
+ native_flds_lib.Register();
+ isolate->object_store()->set_native_fields_library(native_flds_lib);
+ static const char* const kNativeFieldClass = "NativeFieldWrapperClass";
+ static const int kNameLength = strlen(kNativeFieldClass) + 1 + 1;
+ char name_buffer[kNameLength];
+ String& cls_name = String::Handle();
+ for (int fld_cnt = 1; fld_cnt <= kNumNativeFieldClasses; fld_cnt++) {
+ OS::SNPrint(name_buffer, kNameLength, "%s%d", kNativeFieldClass, fld_cnt);
+ cls_name = String::NewSymbol(name_buffer);
+ Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt);
+ }
+}
+
+
RawLibrary* Library::LookupLibrary(const String &url) {
Library& lib = Library::Handle();
String& lib_url = String::Handle();
@@ -4172,6 +4198,11 @@
}
+RawLibrary* Library::NativeFieldsLibrary() {
+ return Isolate::Current()->object_store()->native_fields_library();
+}
+
+
const char* Library::ToCString() const {
const char* kFormat = "Library:'%s'";
const String& name = String::Handle(url());

Powered by Google App Engine
This is Rietveld 408576698