• 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
Encapsulate C struct/toll-free bridging?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Encapsulate C struct/toll-free bridging?


  • Subject: Encapsulate C struct/toll-free bridging?
  • From: David Bainbridge <email@hidden>
  • Date: Mon, 8 Mar 2004 21:52:52 -0600

I am passing a C data structure back and forth between Cocoa framework
and carbon CFM code. Is there an elegant way to encapsulate structs
such that I can integrate it better with Objective-C/Cocoa? Example
struct:

struct C_CList {
SInt32
numItems;
SInt32 slots;
SInt32
blockSize;
Handle hItems;
SInt32
elementSize;
UInt8
lockChanges;
UInt8
usingTemporary;
};


I would like this to actually be data members to an objective-c class
and access the data with methods like -(SInt32)numItems, etc.. I don't
wish to allocate an object and copy each data member over to it and
then turn around and copy it back to the struct when it needs to be
sent back to the CFM code. Currently I am using class methods and
passing the entire C struct to modify/access the data. It sounds like
I am looking for something similar to the toll-free bridging that goes
on between some CF structures and Cocoa objects.. Any suggestions?

Thanks,
D. Bainbridge
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Encapsulate C struct/toll-free bridging?
      • From: Thomas Lachand-Robert <email@hidden>
    • Re: Encapsulate C struct/toll-free bridging?
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: Re: Runloops, Cocoa and Carbon
  • Next by Date: Re: NSMutableArray morphs itself into an NSArray?
  • Previous by thread: requiring methods in a subclass
  • Next by thread: Re: Encapsulate C struct/toll-free bridging?
  • Index(es):
    • Date
    • Thread