Re: Executing non objective-c code in a loaded bundle
Re: Executing non objective-c code in a loaded bundle
- Subject: Re: Executing non objective-c code in a loaded bundle
- From: Pascal Pochet <email@hidden>
- Date: Wed, 28 Jun 2006 22:23:01 +0200
Using CFBundleRef
define the prototype of your function
typedef FUNCTION_TYPE_RESULT (*FUNCTION_TYPE_PTR)(FUNCTION_PARAMETERS…);
declare a variable to hold the pointer
FUNCTION_TYPE_PTR FUNCTION_VAR ;
make an URL from the POSIX path to your bundle
CFURLRef bundleURL = CFURLCreateWithFileSystemPath
(CFAllocatorGetDefault(),
ABSOLUTE_PATH_TO_YOUR_BUNDLE_AS_CFSTRINGREF,
kCFURLPOSIXPathStyle, NO) ;
create the bundle ref
CFBundleRef bundleRef = CFBundleCreate( CFAllocatorGetDefault(),
bundleURL ) ;
get the pointer on the function using its symbol name
FUNCTION_VAR = CFBundleGetFunctionPointerForName( bundleRef, CFSTR
("FUNCTION_NAME") ) ;
( release the xxxRefs , add you own error checking…)
to call the function:
(*FUNCTION_VAR)( PARAMS );
Pascal Pochet
email@hidden
Le 28-juin-06 à 18:37, Mark Williams a écrit :
OK, But I don't understand then how to just call the functions.
My code is as follows:
NSBundle * myPlugin = [NSBundle bundleWithPath:@"/path/to/my/
bundle.bundle"];
/*There is no init method in this bundle only c routines.*/
BOOL loaded = bundleLoaded(); //Here in the compiler I would get
an undefined symbol error
the bundleLoaded() function is in the bundle I loaded but I don't
know how to call it. I tried declaring the functions I needed as
extern in the header of the main app but of course since they never
are actually defined anywhere in the application I still get the
compiler error.
Thanks,
Mark.
On Jun 27, 2006, at 10:50 PM, Chris Suter wrote:
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden