Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Marcel Weiher <email@hidden>
- Date: Wed, 21 May 2003 22:21:49 +0200
On Wednesday, May 21, 2003, at 09:00 Uhr, Quentin Mathi wrote:
Le mercredi, 21 mai 2003, ` 10:02 Europe/Paris, Marcel Weiher a icrit :
Hmm...I don't find it error prone. If you use convenience factor
methods for temporary objects, then the only place you need to deal
with reference counting is the accessor. If you use accessor-macros,
the accessors, and especially the refcounting that goes on inside
them essentially disappears, and the whole thing is automatic (apart
from dealloc, but that is so straightforward/boiler-plate that it
just disappears in the other syntactic noise of creating a class).
You are talking about accessors-macros I'm curious to see an example.
This sounds like it might be a cocoa-dev FAQ...
idAccessor( var, setVar )
generates both the get and the set accessor for (object) instance
variable 'var'. The get-accessor has the same name as the instance
variable, the set accessor is called -setVar:, and does all the
retain/release correctly and efficiently. So you never have to deal
with it again. Corresponding accessors also exist for scalar
variables, these don't do any retain/release, but just assign.
So a header(-extract) looks like this:
@interface MPWTextFragment : MPWGraphicContainer {
id string;
NSPoint position;
float _width;
}
scalarAccessor_h( NSPoint, position, setPosition )
floatAccessor_h( width, setWidth )
idAccessor_h( string, setString )
with the .m file starting like this:
#import "MPWTextFragment.h"
#import <MPWScript/MPWPSFontDict.h>
#import <MPWGraphRep/MPWPSGstate.h>
#import <MPWGraphRep/MPWPSMatrix.h>
#import "MPWTextLine.h"
@implementation MPWTextFragment
scalarAccessor( NSPoint, position, setPosition )
floatAccessor( _width, setWidth )
idAccessor( string, _setString )
...
Notice that some of the declarations don't match the implementations.
In these cases, there are specialized routines that refer back to the
accessors.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.