@@ -19,18 +19,15 @@ #import "OFExceptions.h" @implementation OFPlugin + pluginFromFile: (const char*)path { - return [[[OFPlugin alloc] initFromFile: path] autorelease]; -} - -- initFromFile: (const char*)path -{ char *file; size_t pathlen, suffixlen; - id (*init_plugin)(); + void *handle; + OFPlugin *(*init_plugin)(); + OFPlugin *plugin; Class c; if ((self = [super init])) { pathlen = strlen(path); suffixlen = strlen(PLUGIN_SUFFIX); @@ -61,38 +58,20 @@ c = [self class]; [super free]; @throw [OFInitializationFailedException newWithClass: c]; } + + plugin->handle = handle; + return plugin; } return self; } - free { - [plugin free]; dlclose(handle); return [super free]; } - -#ifdef __objc_INCLUDE_GNU -- (retval_t)forward: (SEL)selector - : (arglist_t)args -#else -- (id)forward: (SEL)selector - : (marg_list)args -#endif -{ - return [plugin performv: selector - : args]; -} - -- (IMP)methodFor: (SEL)selector -{ - if ([self respondsTo: selector]) - return [self methodFor: selector]; - else - return [plugin methodFor: selector]; -} @end