Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > Re: Extract fun...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 912 of 1039
Post > Topic >>

Re: Extract function pointers from function table

by Michael Ash <mike@[EMAIL PROTECTED] > Sep 27, 2007 at 08:24 AM

kebabklubben.emp@[EMAIL PROTECTED]
 wrote:
> Hi!
> 
> I'm quite new to Objective-C, and now I'm trying to get it to interact
> with older C-code compiled to a Win32 dll. (All work is on PC with
> GNUStep.)
> 
> One of my old C-functions requests a function pointer of type
> Do_SFXP_Buffer_Allocate_t as input, and the function pointer type is
> declared as:
> 
> typedef BufferHeader_t*(* Do_Buffer_Allocate_t)(const uint16
> NoOfChannels);
> 
> I have now written a method in Objective C whos interface looks like
> the expected C-interface. (Is the function the same with first input
> argument and output in register 0?)
> 
> How can I extract the function pointer to my Obj-C function and use it
> as input to my C-function? (I'm using the NS-cl*****...)
> 
> -(BufferHeader_t*)AllocateBufferWithChannels:(const
> uint16)nNoOfChannels
> {
> ...
> }
> 
> -(Do_Buffer_Allocate_t*)getAlloccateBufferFunctionPointer
> {
>  return ??? /In pure C: &AllocateBufferWithChannels;
> }

This cannot work. The reason is because your Objective-C method has two 
implicit parameters, self and _cmd. The full signature of an equivalent C 
function would be:

BufferHeader_t *AllocateBufferWithChannels(id self, SEL _cmd, const uint16

nNoOfChannels);

Since your C library does not provide this kind of signature, you'll have 
to write a C function which then calls through to your Objective-C method.

-- 
Michael Ash
Rogue Amoeba Software
 




 3 Posts in Topic:
Extract function pointers from function table
kebabklubben.emp@[EMAIL P  2007-09-27 05:34:12 
Re: Extract function pointers from function table
Michael Ash <mike@[EMA  2007-09-27 08:24:23 
Re: Extract function pointers from function table
kebabklubben.emp@[EMAIL P  2007-09-28 00:11:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 7:19:23 CDT 2008.