Chromium Code Reviews| 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.
|
| } |