| OLD | NEW |
| 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 "platform/assert.h" | |
| 6 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 7 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 8 | 7 |
| 9 #include "bin/extensions.h" | 8 #include "bin/extensions.h" |
| 10 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 11 #include "bin/utils_win.h" | 10 #include "bin/utils_win.h" |
| 12 | 11 |
| 13 | 12 |
| 14 namespace dart { | 13 namespace dart { |
| 15 namespace bin { | 14 namespace bin { |
| 16 | 15 |
| 17 const char* kPrecompiledLibraryName = "precompiled.dll"; | 16 const char* kPrecompiledLibraryName = "precompiled.dll"; |
| 18 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot"; | 17 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot"; |
| 19 | 18 |
| 20 Dart_Handle Extensions::LoadExtensionLibrary(const char* library_file, | 19 void* Extensions::LoadExtensionLibrary(const char* library_file) { |
| 21 void** library_handle) { | 20 SetLastError(0); |
| 22 ASSERT(library_handle != NULL); | 21 return LoadLibraryW(StringUtilsWin::Utf8ToWide(library_file)); |
| 23 *library_handle = LoadLibraryW(StringUtilsWin::Utf8ToWide(library_file)); | 22 } |
| 24 if (*library_handle == NULL) { | 23 |
| 24 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
| 25 SetLastError(0); |
| 26 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol); |
| 27 } |
| 28 |
| 29 Dart_Handle Extensions::GetError() { |
| 30 int last_error = GetLastError(); |
| 31 if (last_error != 0) { |
| 25 OSError err; | 32 OSError err; |
| 26 return Dart_NewApiError(err.message()); | 33 return Dart_NewApiError(err.message()); |
| 27 } | 34 } |
| 28 return Dart_Null(); | 35 return Dart_Null(); |
| 29 } | 36 } |
| 30 | 37 |
| 31 void* Extensions::LoadExtensionLibrary(const char* library_file) { | |
| 32 return LoadLibraryW(StringUtilsWin::Utf8ToWide(library_file)); | |
| 33 } | |
| 34 | |
| 35 Dart_Handle Extensions::ResolveSymbol(void* lib_handle, | |
| 36 const char* symbol, | |
| 37 void** init_function) { | |
| 38 ASSERT(init_function != NULL); | |
| 39 *init_function = GetProcAddress( | |
| 40 reinterpret_cast<HMODULE>(lib_handle), symbol); | |
| 41 if (*init_function == NULL) { | |
| 42 OSError err; | |
| 43 return Dart_NewApiError(err.message()); | |
| 44 } | |
| 45 return Dart_Null(); | |
| 46 } | |
| 47 | |
| 48 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | |
| 49 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol); | |
| 50 } | |
| 51 | |
| 52 } // namespace bin | 38 } // namespace bin |
| 53 } // namespace dart | 39 } // namespace dart |
| 54 | 40 |
| 55 #endif // defined(TARGET_OS_WINDOWS) | 41 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |