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


|