Transitioning to GC-supported
Transitioning to GC-supported
- Subject: Transitioning to GC-supported
- From: Dave Keck <email@hidden>
- Date: Mon, 26 Oct 2009 03:45:59 -1000
Hey list,
Until recently, I didn't realize that System Preferences on 10.6 required
preferences panes to be GC-supported. As such, I wrote my preference pane
RC-only, and now I've got a fun few weeks ahead of me. :)
I'm planning on systematically going through each of my source files and
updating them to be GC-supported. I've been compiling a list of things to do
and to look out for. So far, this is what I've got:
1. Apply workaround for interior pointers by '[containingObject self];' at
the end of the method, to keep the containing object alive. It would be
great if I had a list of every accessor method that returned an interior
pointer - I figure I'll just make a fancy regex to search through the
framework headers for anything returning a void *, char *, etc., but of
course this won't catch everything. I fear the bugs caused by using interior
pointers will be subtle and intermittent which is why I'd like to exert the
effort to patch every instance in one fell swoop, ideally without having to
re-read every line that I've written for this (somewhat large) project.
2. Go through every -dealloc and implement an -invalidate or equivalent for
cases where non-memory-related cleanup is needed, or -finalize if absolutely
necessary.
3. Wrap all CF*Create(), CG*Create(), CF*Copy(), CG*Copy(), etc. with
CFMakeCollectable(), and replace corresponding CFRelease()s with a custom
macro - CFReleaseIfRC(). (This way, if I ever choose to go GC-only, I can
simply remove all calls to CFReleaseIfRC().)
4. Search for every call to -retain, -alloc, -init pairs, and -copy. Verify
that the object being retained is strongly referenced, and if not, it must
be CFRetain()ed or -disableCollectorForPointer: must be called for it.
5. Search for every call to -release and -autorelease. If the object being
released is a CFType, then it must be CFReleaseIfRC() instead.
6. Search for every use of '&', and use objc_assign_global() and
objc_assign_ivar() as necessary.
7. Search for all opaque pointer types (void *, uintptr_t) and scold them.
8. Test and maintain sanity.
This is my first trip to GC-land, so it's sure to be a learning experience.
Any tips or pitfalls to look out for would be greatly appreciated!
David
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden