OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_NATIVE_LIBRARY_H_ | 5 #ifndef BASE_NATIVE_LIBRARY_H_ |
6 #define BASE_NATIVE_LIBRARY_H_ | 6 #define BASE_NATIVE_LIBRARY_H_ |
7 | 7 |
8 // This file defines a cross-platform "NativeLibrary" type which represents | 8 // This file defines a cross-platform "NativeLibrary" type which represents |
9 // a loadable module. | 9 // a loadable module. |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 union { | 43 union { |
44 CFBundleRef bundle; | 44 CFBundleRef bundle; |
45 void* dylib; | 45 void* dylib; |
46 }; | 46 }; |
47 }; | 47 }; |
48 typedef NativeLibraryStruct* NativeLibrary; | 48 typedef NativeLibraryStruct* NativeLibrary; |
49 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
50 typedef void* NativeLibrary; | 50 typedef void* NativeLibrary; |
51 #endif // OS_* | 51 #endif // OS_* |
52 | 52 |
53 #if defined(OS_WIN) | |
54 typedef DWORD NativeLibraryLoadError; | |
ddorwin
2014/03/21 20:06:32
While more explicit about what to expect, this for
xhwang
2014/03/21 22:33:28
I fixed the initialization issue with a struct. Mo
| |
55 #else | |
56 typedef std::string NativeLibraryLoadError; | |
57 #endif // OS_WIN | |
58 | |
53 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 59 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
54 // you're done. Returns NULL on failure. | 60 // you're done. Returns NULL on failure. |
55 // If |error| is not NULL, it may be filled in with an error message on error. | 61 // If |error| is not NULL, it may be filled in on load error if the platform |
ddorwin
2014/03/21 20:06:32
I think we can drop the "if the platform..." part.
xhwang
2014/03/21 22:33:28
Done.
| |
62 // supports it. | |
56 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 63 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
57 std::string* error); | 64 NativeLibraryLoadError* error); |
58 | 65 |
59 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
60 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 67 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
61 // you're done. | 68 // you're done. |
62 // This function retrieves the LoadLibrary function exported from kernel32.dll | 69 // This function retrieves the LoadLibrary function exported from kernel32.dll |
63 // and calls it instead of directly calling the LoadLibrary function via the | 70 // and calls it instead of directly calling the LoadLibrary function via the |
64 // import table. | 71 // import table. |
65 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( | 72 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
66 const FilePath& library_path); | 73 const FilePath& library_path); |
67 #endif // OS_WIN | 74 #endif // OS_WIN |
68 | 75 |
69 // Unloads a native library. | 76 // Unloads a native library. |
70 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); | 77 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
71 | 78 |
72 // Gets a function pointer from a native library. | 79 // Gets a function pointer from a native library. |
73 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 80 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
74 const char* name); | 81 const char* name); |
75 | 82 |
76 // Returns the full platform specific name for a native library. | 83 // Returns the full platform specific name for a native library. |
77 // For example: | 84 // For example: |
78 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 85 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
79 // "mylib.dylib" on Mac. | 86 // "mylib.dylib" on Mac. |
80 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); | 87 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); |
81 | 88 |
82 } // namespace base | 89 } // namespace base |
83 | 90 |
84 #endif // BASE_NATIVE_LIBRARY_H_ | 91 #endif // BASE_NATIVE_LIBRARY_H_ |
OLD | NEW |