• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Executing non objective-c code in a loaded bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Executing non objective-c code in a loaded bundle
      • From: Uli Kusterer <email@hidden>
References: 
 >Re: Executing non objective-c code in a loaded bundle (From: Damien Sorresso <email@hidden>)
 >Re: Executing non objective-c code in a loaded bundle (From: Chris Suter <email@hidden>)
 >Re: Executing non objective-c code in a loaded bundle (From: Mark Williams <email@hidden>)

  • Prev by Date: Re: Binding beginner question
  • Next by Date: Re: Getting the parent process name
  • Previous by thread: Re: Executing non objective-c code in a loaded bundle
  • Next by thread: Re: Executing non objective-c code in a loaded bundle
  • Index(es):
    • Date
    • Thread