This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Find more ObjC methods


Markus Hitter wrote:


Am Freitag, 03.10.03 um 04:10 Uhr schrieb Alexander Malmberg:


Ziemowit Laski wrote:
[snip]

in the long run, the compiler should stop distinguishing @interfaces from
@implementations (since the former are merely forward declarations for the latter).


I've always considered this a feature. The @interface is the public interface for an @implementation. Thus, methods that appear only in an implementation are private to that implementation.


It will stay there as a feature unless you get rid of header files at all and #include the whole source when using a library.

That's surely not what Zem meant :-)


When the compiler parses the source, it keeps track of what it sees. Currently it keeps track of methods encountered in @interface declarations seperate from the current @implementation declaration.

Example:
@interface Foo
-(void)somePublicMethod;
@end

@implementation Foo
-(void)somePublicMethod {};
-(void)somePrivatMethod {};
-(void)someOtherPrivateMethod
{
 [self somePrivateMethod];
}
@end

@implementation Foo (aCategory)
-(void)somePrivatCategoryMethod {};
-(void)someOtherCategoryMethod
{
 [self somePrivatCategoryMethod];
 [self somePrivatMethod]; /* <- should not see the prototype and warn! */
}
@end

If the compiler internals didn't distinguish between @implementation and @interface that last line would not warn anymore. Yet I agree with Alex that I see this as a feature.

Cheers,
David



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]