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

Unified Diff: runtime/bin/extensions.cc

Issue 9694045: Change lookup path for Dart native extensions shared libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix isAbsolutePath, remove trailing whitespace. Created 8 years, 9 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
Index: runtime/bin/extensions.cc
diff --git a/runtime/bin/extensions.cc b/runtime/bin/extensions.cc
index afcb29fdc52a10ba9222e1c0c63e68becdcad562..73a9a54f429ca4d4197fc9c7cf661521aa372481 100644
--- a/runtime/bin/extensions.cc
+++ b/runtime/bin/extensions.cc
@@ -10,27 +10,42 @@
#include "platform/assert.h"
#include "platform/globals.h"
#include "bin/dartutils.h"
+#include "bin/file.h"
Dart_Handle Extensions::LoadExtension(const char* extension_url,
Dart_Handle parent_library) {
ASSERT(DartUtils::IsDartExtensionSchemeURL(extension_url));
- const char* library_name =
+ // Make a mutable copy of the extension url, without the "dart:" scheme.
+ const char* path_component =
extension_url + strlen(DartUtils::kDartExtensionScheme);
- if (strchr(library_name, '/') != NULL ||
- strchr(library_name, '\\') != NULL) {
- return Dart_Error("path components not allowed in extension library name");
+#ifdef TARGET_OS_WINDOWS
Ivan Posva 2012/03/15 16:18:20 Please no ifdefs, they are generally a sign of bad
Bill Hesse 2012/04/17 14:46:31 Done.
+ // Remove initial '/' from a uri formatted absolute path "/C:/path/to/dll"
+ ASSERT(path_component[0] == '/');
+ path_component++;
+#endif
+ char* library_path = strdup(path_component);
+ if (!library_path || !File::IsAbsolutePath(library_path)) {
+ free(library_path);
+ return Dart_Error("unexpected error in library path");
}
- void* library_handle = LoadExtensionLibrary(library_name);
+ // Extract the path and the extension name from the url.
+ char* last_path_separator = strrchr(library_path, '/');
+ char* extension_name = last_path_separator + 1;
+ *last_path_separator = '\0'; // Terminate library_path at last separator.
+
+ void* library_handle = LoadExtensionLibrary(library_path, extension_name);
if (!library_handle) {
+ free(library_path);
return Dart_Error("cannot find extension library");
}
- const char* strings[3] = { library_name, "_Init", NULL };
+ const char* strings[3] = { extension_name, "_Init", NULL };
char* init_function_name = Concatenate(strings);
typedef Dart_Handle (*InitFunctionType)(Dart_Handle import_map);
InitFunctionType fn = reinterpret_cast<InitFunctionType>(
ResolveSymbol(library_handle, init_function_name));
free(init_function_name);
+ free(library_path);
if (fn == NULL) {
return Dart_Error("cannot find initialization function in extension");

Powered by Google App Engine
This is Rietveld 408576698