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

Unified Diff: runtime/bin/builtin.dart

Issue 180783008: Change handling of dart-ext: URIs for native extensions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « no previous file | runtime/bin/dartutils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 99e80ca7705c104284157ab1b9e541df052a18b5..bbefd9ea553a7f55bd4a5494a2ef0c9f69a0b65b 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -207,37 +207,24 @@ String _resolveScriptUri(String scriptName) {
String _resolveUri(String base, String userString) {
- var baseUri = Uri.parse(base);
_logResolution('# Resolving: $userString from $base');
-
- var uri = Uri.parse(userString);
- var resolved;
- if ('dart-ext' == uri.scheme) {
- // Relative URIs with scheme dart-ext should be resolved as if with no
- // scheme.
- resolved = baseUri.resolve(uri.path);
- if (resolved.scheme == 'package') {
- // If we are resolving relative to a package URI we go directly to the
- // file path and keep the dart-ext scheme. Otherwise, we will lose the
- // package URI path part.
- var path = _filePathFromPackageUri(resolved);
- if (path.startsWith('http:')) {
- throw "Native extensions not supported in "
- "packages loaded over http: %path";
- }
- resolved = new Uri.file(path);
- }
- resolved = new Uri(scheme: 'dart-ext', path: resolved.path);
+ const DART_EXT = 'dart-ext:';
+ var baseUri = Uri.parse(base);
+ if (userString.startsWith(DART_EXT)) {
+ var uri = userString.substring(DART_EXT.length);
+ return '$DART_EXT${baseUri.resolve(uri)}';
} else {
- resolved = baseUri.resolve(userString);
+ return '${baseUri.resolve(userString)}';
}
- _logResolution('# Resolved to: $resolved');
- return resolved.toString();
}
// Returns either a file path or a URI starting with http:, as a String.
String _filePathFromUri(String userUri) {
+ const DART_EXT = 'dart-ext:';
Ivan Posva 2014/03/03 08:26:37 This constant should only be defined once. How abo
Bill Hesse 2014/03/04 09:27:14 Done. Committed with a typo in r33216, fixed in r
+ if (userUri.startsWith(DART_EXT)) {
+ userUri = userUri.substring(DART_EXT.length);
+ }
var uri = Uri.parse(userUri);
_logResolution('# Getting file path from: $uri');
@@ -247,20 +234,13 @@ String _filePathFromUri(String userUri) {
case 'file':
return uri.toFilePath();
break;
- case 'dart-ext':
- // Relative file URIs don't start with file:///.
- var scheme = (uri.path.startsWith('/') ? 'file' : '');
- return new Uri(scheme: scheme,
- host: uri.host,
- path: uri.path).toFilePath();
- break;
case 'package':
return _filePathFromPackageUri(uri);
break;
case 'http':
return uri.toString();
default:
- // Only handling file, dart-ext, http, and package URIs
+ // Only handling file, http, and package URIs
// in standalone binary.
_logResolution('# Unknown scheme (${uri.scheme}) in $uri.');
throw 'Not a known scheme: $uri';
@@ -270,7 +250,7 @@ String _filePathFromUri(String userUri) {
String _filePathFromPackageUri(Uri uri) {
if (!uri.host.isEmpty) {
- var path = (uri.path != '') ? '${uri.host}${uri.path}' : uri.host;
+ var path = '${uri.host}${uri.path}';
var right = 'package:$path';
var wrong = 'package://$path';
« no previous file with comments | « no previous file | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698