OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/native_library.h" |
| 6 |
| 7 #import <Carbon/Carbon.h> |
| 8 |
| 9 #include "base/file_path.h" |
| 10 #include "base/scoped_cftyperef.h" |
| 11 |
| 12 namespace base { |
| 13 |
| 14 // static |
| 15 NativeLibrary LoadNativeLibrary(const FilePath& library_path) { |
| 16 scoped_cftyperef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation( |
| 17 kCFAllocatorDefault, |
| 18 (const UInt8*)library_path.value().c_str(), |
| 19 library_path.value().length(), |
| 20 true)); |
| 21 if (!url) |
| 22 return NULL; |
| 23 |
| 24 return CFBundleCreate(kCFAllocatorDefault, url.get()); |
| 25 } |
| 26 |
| 27 // static |
| 28 void UnloadNativeLibrary(NativeLibrary library) { |
| 29 CFRelease(library); |
| 30 } |
| 31 |
| 32 // static |
| 33 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| 34 NativeLibraryFunctionNameType name) { |
| 35 return CFBundleGetFunctionPointerForName(library, name); |
| 36 } |
| 37 |
| 38 } // namespace base |
OLD | NEW |