Re: Building a C library Objective-C wrapper framework
Re: Building a C library Objective-C wrapper framework
- Subject: Re: Building a C library Objective-C wrapper framework
- From: Brian Stern <email@hidden>
- Date: Tue, 15 Jul 2008 11:38:35 -0400
On Jul 15, 2008, at 8:12 AM, Sebastian wrote:
-------------- Original message ----------------------
From: Sebastian Nowicki <email@hidden>
> I also can't think of a way to use the typedef'd C structs and
> enums from the library in the header file without including the
> library header file. This is tricky indeed. If only I could see how
> Apple did it with OpenGL, etc :P.
There are very few places where I actually return an enum from the C
library. As previously mentioned, I simple don't know how to handle
this, and it would be returning an enum either way (I'd just need an
"alias"). I mostly use the structs from the library internally, ie.,
as instance variables. It would otherwise be impossible for me to do
anything in the class :P. For instance if there's a struct apple_t,
I make a class Apple, and internally the class must store the
apple_t struct somewhere. In order to define this variable I have to
import the header from the library. e.g:
struct*s are easy.
struct apple_t *apple;
will compile without a definition of apple_t available to the
compiler. You need to #include the definition in order to use it
though. This strategy is used in Apple's headers to hide private
info. See OpaqueAudioFileID for instance.
For the enums you could make your own that have the same values as the
one from the C library.
enum { mySome_enum = whatever some_enum is from the library }
Obviously you need to be very certain that all of your new enums have
the same values as the library values.
--
Brian Stern
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden