On Sep 5, 2009, at 21:15, Adam R. Maxwell wrote: > > On Sep 5, 2009, at 11:27 AM, Christiaan Hofman wrote: > >> >> On Sep 5, 2009, at 19:59, Adam R. Maxwell wrote: >> >>> >>> On Sep 5, 2009, at 10:43 AM, Christiaan Hofman wrote: >>> >>>> And now I know why PDFKit doesn't work on 64 bits. They are really >>>> messing up writing to ivars. Remember they use weird private >>>> classes >>>> to hide the ivars. This means they must be using runtime >>>> functions to >>>> read/write to these ivars, because these private classes don't have >>>> accessors. >>> >>> Is it really using runtime functions? I've done this by >>> >>> @class PublicClassIvars; >>> >>> @interface PublicClass : NSObject >>> { >>> @private >>> PublicClassIvars *_ivars; >>> } >>> @end >>> >>> /// In the implementation of PublicClass, declare the ivars >>> >>> @interface PublicClassIvars : NSObject >>> { >>> @public >>> id _representedObject; >>> NSInteger _type; >>> } >>> @end >>> >>> and you can access it in PublicClass by >>> >>> NSInteger t = _ivars->_type; >>> id obj = _ivars->_representedObject; >>> >>> Basically this is the Pimpl idiom, using an object instead of an >>> opaque pointer, and it's pretty easy unless you have object types >>> and need to manage memory. It would be interesting to set a >>> breakpoint on the objc runtime functions and see if PDF Kit is >>> calling them. If so, that's really the hard way of doing it; you >>> might as well use indexed ivars! >>> >> >> That sounds very dangerous, especially in view of Objective-C 2.0 and >> 64 bits. Moreover, the compiler complains very hard, and the docs say >> not to use @defs in 64-bits. Remember they're making objects more and >> more opaque. Anyway, PDFKit for sure does it the hard way by adding >> all those private ivar wrapping objects. > > No, this works fine in 64 bit (I use it in FileView); the important > part is @public in the declaration of PublicClassIvars, which > obviates the need for @defs since you already have access to _ivars > from PublicClass. For true opaque objects, you'd use @dynamic, but > then I think you have to use @property accessors...which would > eliminate the private ivar object also. >
But PDFKit does not use @public, and the docs say not to use @defs. Christiaan > > #import <Foundation/Foundation.h> > > @class PublicClassIvars; > > @interface PublicClass : NSObject > { > @private > PublicClassIvars *_ivars; > } > @end > > @interface PublicClassIvars : NSObject > { > @public > id _representedObject; > NSInteger _type; > } > @end > > @implementation PublicClassIvars > @end > > @implementation PublicClass > > - (id)init > { > self = [super init]; > if (self) { > _ivars = [PublicClassIvars new]; > _ivars->_representedObject = [NSObject new]; > _ivars->_type = 1; > } > return self; > } > > - (NSString *)description > { > return [NSString stringWithFormat:@"%@:\n\trepresented object = %@ > \n\ttype = %d", [super description], _ivars->_representedObject, > _ivars->_type]; > } > > @end > > int main (int argc, char const *argv[]) > { > NSAutoreleasePool *pool = [NSAutoreleasePool new]; > > PublicClass *x = [PublicClass new]; > NSLog(@"%@", [x description]); > > > return 0; > } > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. > http://p.sf.net/sfu/bobj-july_______________________________________________ > Bibdesk-develop mailing list > Bibdesk-develop@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bibdesk-develop ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Bibdesk-develop mailing list Bibdesk-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-develop