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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdio.h>
6
5 #include "bin/extensions.h" 7 #include "bin/extensions.h"
8 #include "bin/dartutils.h"
6 9
7 #include "include/dart_api.h" 10 #include "include/dart_api.h"
8 #include "platform/assert.h" 11 #include "platform/assert.h"
9 12
10 Dart_Handle Extensions::LoadExtension(const char* extension_url, 13 Dart_Handle Extensions::LoadExtension(const char* extension_url,
11 Dart_Handle parent_library) { 14 Dart_Handle parent_library) {
12 UNIMPLEMENTED(); 15 ASSERT(DartUtils::IsDartExtensionSchemeURL(extension_url));
13 return NULL; 16 fprintf(stderr, "Reached 1\n");
Bill Hesse 2012/03/06 15:04:07 Remove this fprintf.
17 const char* extension_name =
18 extension_url + strlen(DartUtils::kDartExtensionScheme);
19 const int buffer_length = strlen(extension_name) + strlen(".dll") + 1;
20 char* library_path = new char[buffer_length];
21 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
22 printf("%s\n", library_path);
Bill Hesse 2012/03/06 15:04:07 Remove this printf.
23 HMODULE extension_dll = LoadLibrary(library_path);
24 assert(extension_dll != NULL);
25
26 // Reuse library_path buffer for intialization function name.
27 char* library_init_function = library_path;
28 snprintf(library_init_function, buffer_length, "%s_Init", extension_name);
29 typedef Dart_Handle (*InitPtrType)(Dart_Handle);
30 static InitPtrType initPtr =
31 (InitPtrType)GetProcAddress(extension_dll, library_init_function);
Mads Ager (google) 2012/03/06 15:32:50 Please use reinterpret_cast
32 delete[] library_path;
33 assert(initPtr != NULL);
34
35 return (*initPtr)(parent_library);
Søren Gjesse 2012/03/07 06:58:31 reinterpret_cast here as well.
14 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698