Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
- Subject: Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
- From: Thomas Lachand-Robert <email@hidden>
- Date: Wed, 10 Mar 2004 23:35:52 +0100
Le 10 mars 04, ` 22:26, Chris Kane a icrit :
The point I was trying to make is that the compiler produces a '@'
typecode in a method signature through a special case, from pattern
recognition. When you typedef the type of the object separate from
the pointer to that object type, the pattern recognition doesn't seem
to apply.
For example, if you change:
typedef NSObject<NSCopying> Copy;
- (Copy *)test2 {....}
to:
typedef NSObject<NSCopying> * Copy;
- (Copy)test2 {....}
then the compiler does produce '@' again, for the return type of
-test2. Why? Must be some sort of type+pattern recognition.
Remember that 'id' contains the pointer within it; putting the pointer
in the typedef makes your typedef "more like" id. When the pointer is
in the type, things work. They don't work as in your case where
you've typedef'd the base type and left the pointer until the
declaration. Or to look at things another way...
Why does "NSObject *" produce a typecode of '@', instead of
'^NSObject'? Must be some sort of logic where the compiler says, "Is
'NSObject' an ObjC class I've seen declared?" and converts the
NSObject * to '@' in the typecode.
In your specific case, something about the protocol being in there
must be confusing things in the compiler just a bit too much. File a
bug to let the compiler folks at Apple know about the problem, but
you'll have to do something else than What You Want for the forseeable
future.
Ok, this is a bug, then. I already filled a report #3578530, maybe you
could add your own remarks here.
I agree that the compiler is a bit too smart while trying o replace
'^NSObject' by '@' in the typedcode. Anyway protocols confuse it here.
But on the other hand, I don't think the compiler should be converting
everything which happened to look like a 'id' to '@' in the typecodes.
For example, if I have:
typedef struct mystruct {
struct objc_class *aClass;
} mystruct_t;
- (mystruct_t *)test3 {....}
I would not expect to see the typecode for the return value of -test3
show up as '@'. [I haven't tried it.]
Nor would I. This would be MUCH too smart! (I haven't tried either.)
Thanks again,
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
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.