ObjFW  Diff

Differences From Artifact [260b8dfd9b]:

To Artifact [27e1ed9410]:


27
28
29
30
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
#import "OFString.h"

#import "OFInitializationFailedException.h"

#import "autorelease.h"

#ifdef _WIN32
# define dlopen(file, mode) LoadLibrary(file)
# define dlsym(handle, symbol) GetProcAddress(handle, symbol)
# define dlclose(handle) FreeLibrary(handle)
#endif

@implementation OFPlugin
+ (id)pluginFromFile: (OFString*)path
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableString *file;
	of_plugin_handle_t handle;
	OFPlugin *(*initPlugin)(void);
	OFPlugin *plugin;

	file = [OFMutableString stringWithString: path];
	[file appendString: @PLUGIN_SUFFIX];


	if ((handle = dlopen([file cStringUsingEncoding:
	    OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL)



		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	objc_autoreleasePoolPop(pool);

	initPlugin = (OFPlugin*(*)(void))dlsym(handle, "init_plugin");
	if (initPlugin == NULL || (plugin = initPlugin()) == nil) {







<








<




<
|

>
|

>
>
>







27
28
29
30
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
#import "OFString.h"

#import "OFInitializationFailedException.h"

#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;
	OFPlugin *(*initPlugin)(void);
	OFPlugin *plugin;


	path = [path stringByAppendingString: @PLUGIN_SUFFIX];

#ifndef _WIN32
	if ((handle = dlopen([path cStringUsingEncoding:
	    OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL)
#else
	if ((handle = LoadLibraryW([path UTF16String])) == NULL)
#endif
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	objc_autoreleasePoolPop(pool);

	initPlugin = (OFPlugin*(*)(void))dlsym(handle, "init_plugin");
	if (initPlugin == NULL || (plugin = initPlugin()) == nil) {