Differences From Artifact [28a68da273]:
- File
src/OFPlugin.m
— part of check-in
[e54c8c0368]
at
2014-01-16 23:38:42
on branch trunk
— Add +[OFString nativeOSEncoding].
This replaces OF_STRING_ENCODING_NATIVE, as a define was not flexible
enough (determining the native OS encoding at startup was not possible). (user: js, size: 2028) [annotate] [blame] [check-ins using]
To Artifact [a5b4d66f4b]:
- File
src/OFPlugin.m
— part of check-in
[4a2f61814f]
at
2014-05-15 15:32:42
on branch trunk
— Work around dlsym() API not being valid C
This only silences the compiler. Storing function pointers in void* is
illegal, yet POSIX requires it. (user: js, size: 2084) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 | #import "autorelease.h" #ifdef _WIN32 # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif @implementation OFPlugin + (id)pluginFromFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); of_plugin_handle_t handle; | > > | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #import "autorelease.h" #ifdef _WIN32 # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif typedef OFPlugin* (*init_plugin_t)(void); @implementation OFPlugin + (id)pluginFromFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); of_plugin_handle_t handle; init_plugin_t initPlugin; OFPlugin *plugin; path = [path stringByAppendingString: @PLUGIN_SUFFIX]; #ifndef _WIN32 if ((handle = dlopen([path cStringWithEncoding: [OFString nativeOSEncoding]], RTLD_LAZY)) == NULL) #else if ((handle = LoadLibraryW([path UTF16String])) == NULL) #endif @throw [OFInitializationFailedException exceptionWithClass: self]; objc_autoreleasePoolPop(pool); initPlugin = (init_plugin_t)(uintptr_t)dlsym(handle, "init_plugin"); if (initPlugin == (init_plugin_t)0 || (plugin = initPlugin()) == nil) { dlclose(handle); @throw [OFInitializationFailedException exceptionWithClass: self]; } plugin->_handle = handle; return plugin; |
︙ | ︙ |