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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 10867032: Beginning support for library prefixes in the dart API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Dart_Null in builtin.cc Created 8 years, 4 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 | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index edb2a6aa027d66089178c3989588b8b9de152f5b..a8e6194f70e24e7fdf19b499567664bd0839e262 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -2634,7 +2634,7 @@ DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
func = lib.LookupFunctionAllowPrivate(tmp_name);
}
- // Case 3. Lookup the funciton with the getter prefix prepended.
+ // Case 3. Lookup the function with the getter prefix prepended.
if (func.IsNull()) {
tmp_name = Field::GetterName(func_name);
func = lib.LookupFunctionAllowPrivate(tmp_name);
@@ -4037,7 +4037,8 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
- Dart_Handle import) {
+ Dart_Handle import,
+ Dart_Handle prefix) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Library& library_vm = Api::UnwrapLibraryHandle(isolate, library);
@@ -4048,7 +4049,26 @@ DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
if (import_vm.IsNull()) {
RETURN_TYPE_ERROR(isolate, import, Library);
}
- library_vm.AddImport(import_vm);
+ const String& prefix_vm = Dart_IsNull(prefix)
+ ? String::Handle(isolate, Symbols::New(""))
+ : Api::UnwrapStringHandle(isolate, prefix);
+ if (prefix_vm.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, prefix, String);
+ }
+ const String& prefix_symbol =
+ String::Handle(isolate, Symbols::New(prefix_vm));
+ if (prefix_vm.Length() == 0) {
+ library_vm.AddImport(import_vm);
+ } else {
+ LibraryPrefix& library_prefix = LibraryPrefix::Handle();
+ library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol);
+ if (!library_prefix.IsNull()) {
+ library_prefix.AddLibrary(import_vm);
+ } else {
+ library_prefix = LibraryPrefix::New(prefix_symbol, import_vm);
+ library_vm.AddObject(library_prefix, prefix_symbol);
+ }
+ }
return Api::Success(isolate);
}
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698