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/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(HOST_OS_WINDOWS) | 6 #if defined(HOST_OS_WINDOWS) |
7 | 7 |
8 #include "bin/extensions.h" | 8 #include "bin/extensions.h" |
9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
10 #include "bin/utils_win.h" | 10 #include "bin/utils_win.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 int name_len = MultiByteToWideChar(CP_UTF8, 0, library_file, -1, NULL, 0); | 26 int name_len = MultiByteToWideChar(CP_UTF8, 0, library_file, -1, NULL, 0); |
27 wchar_t* name; | 27 wchar_t* name; |
28 name = new wchar_t[name_len]; | 28 name = new wchar_t[name_len]; |
29 MultiByteToWideChar(CP_UTF8, 0, library_file, -1, name, name_len); | 29 MultiByteToWideChar(CP_UTF8, 0, library_file, -1, name, name_len); |
30 | 30 |
31 void* ext = LoadLibraryW(name); | 31 void* ext = LoadLibraryW(name); |
32 delete[] name; | 32 delete[] name; |
33 return ext; | 33 return ext; |
34 } | 34 } |
35 | 35 |
36 | |
37 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 36 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
38 SetLastError(0); | 37 SetLastError(0); |
39 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol); | 38 return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol); |
40 } | 39 } |
41 | 40 |
42 | |
43 void Extensions::UnloadLibrary(void* lib_handle) { | 41 void Extensions::UnloadLibrary(void* lib_handle) { |
44 SetLastError(0); | 42 SetLastError(0); |
45 BOOL result = FreeLibrary(reinterpret_cast<HMODULE>(lib_handle)); | 43 BOOL result = FreeLibrary(reinterpret_cast<HMODULE>(lib_handle)); |
46 ASSERT(result); | 44 ASSERT(result); |
47 } | 45 } |
48 | 46 |
49 | |
50 Dart_Handle Extensions::GetError() { | 47 Dart_Handle Extensions::GetError() { |
51 int last_error = GetLastError(); | 48 int last_error = GetLastError(); |
52 if (last_error != 0) { | 49 if (last_error != 0) { |
53 OSError err; | 50 OSError err; |
54 return Dart_NewApiError(err.message()); | 51 return Dart_NewApiError(err.message()); |
55 } | 52 } |
56 return Dart_Null(); | 53 return Dart_Null(); |
57 } | 54 } |
58 | 55 |
59 } // namespace bin | 56 } // namespace bin |
60 } // namespace dart | 57 } // namespace dart |
61 | 58 |
62 #endif // defined(HOST_OS_WINDOWS) | 59 #endif // defined(HOST_OS_WINDOWS) |
OLD | NEW |