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

Unified Diff: runtime/bin/extensions_win.cc

Issue 9465004: Add native extensions for the Dart shell to mac and windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos 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_win.cc
diff --git a/runtime/bin/extensions_win.cc b/runtime/bin/extensions_win.cc
index d81e670eef10218fe7bc68228faa4d0d88a9083c..40b05923e22746324af076f113e63bc86a27c535 100644
--- a/runtime/bin/extensions_win.cc
+++ b/runtime/bin/extensions_win.cc
@@ -2,13 +2,35 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#include <stdio.h>
+
#include "bin/extensions.h"
+#include "bin/dartutils.h"
#include "include/dart_api.h"
#include "platform/assert.h"
Dart_Handle Extensions::LoadExtension(const char* extension_url,
Dart_Handle parent_library) {
- UNIMPLEMENTED();
- return NULL;
+ ASSERT(DartUtils::IsDartExtensionSchemeURL(extension_url));
+ fprintf(stderr, "Reached 1\n");
Bill Hesse 2012/03/06 15:04:07 Remove this fprintf.
+ const char* extension_name =
+ extension_url + strlen(DartUtils::kDartExtensionScheme);
+ const int buffer_length = strlen(extension_name) + strlen(".dll") + 1;
+ char* library_path = new char[buffer_length];
+ snprintf(library_path, buffer_length, "%s.dll", extension_name);
Mads Ager (google) 2012/03/06 15:32:50 On the other platforms the dll has to be called li
+ printf("%s\n", library_path);
Bill Hesse 2012/03/06 15:04:07 Remove this printf.
+ HMODULE extension_dll = LoadLibrary(library_path);
+ assert(extension_dll != NULL);
+
+ // Reuse library_path buffer for intialization function name.
+ char* library_init_function = library_path;
+ snprintf(library_init_function, buffer_length, "%s_Init", extension_name);
+ typedef Dart_Handle (*InitPtrType)(Dart_Handle);
+ static InitPtrType initPtr =
+ (InitPtrType)GetProcAddress(extension_dll, library_init_function);
Mads Ager (google) 2012/03/06 15:32:50 Please use reinterpret_cast
+ delete[] library_path;
+ assert(initPtr != NULL);
+
+ return (*initPtr)(parent_library);
Søren Gjesse 2012/03/07 06:58:31 reinterpret_cast here as well.
}

Powered by Google App Engine
This is Rietveld 408576698