[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Basic questions about Gorm
From: |
David Chisnall |
Subject: |
Re: Basic questions about Gorm |
Date: |
Sat, 9 Apr 2011 11:08:18 +0100 |
On 9 Apr 2011, at 10:43, Nicola Pero wrote:
>> - Unique protocols (two protocols returned by @protocol()
>> may give different sets of methods - this requires a little
>> bit of help from the compiler, not sure if GCC 4.6 does it)
>
> Do you have an example/testcase of what you mean by this ?
The runtime only sees protocols that are attached to classes. If you declare a
protocol in a compilation unit and then reference it with @protocol(), the
compiler will generate a reference to it, but the runtime won't see it. If you
DON'T declare the protocol, but still reference it with @protocol(), then the
runtime still won't see it, and the compiler will generate a stub protocol that
only has the name filled in.
If the runtime sees the protocol, then it can add it to a table and update all
other references to the protocol to use the same metadata (required / optional
methods / properties). The GNUstep runtime does this, and I think the GCC 4.6
runtime does too.
To ensure that the runtime sees all protocols, I added a really ugly hack,
where every protocol that is referenced but not attached to a class or category
is implicitly added as a category on a class called
__ObjC_Protocol_Holder_Ugly_Hack. This ensures that the runtime sees all
protocols. The Apple solution to this is to make every protocol a public
symbol with link-once ODR linkage (in definitions, external linkage in
references) so you get a linker error if you reference a protocol that is
declared, or declare it in two different ways. I'll probably do that at some
point with the new ABI, but the ugly hack needs to stay for a bit for
compatibility.
This is documented in README in libobjc2 svn.
David
-- Sent from my IBM 1620
- Basic questions about Gorm, Omar Campos, 2011/04/08
- Re: Basic questions about Gorm, Ivan Vučica, 2011/04/08
- Re: Basic questions about Gorm, Omar Campos, 2011/04/08
- Re: Basic questions about Gorm, David Chisnall, 2011/04/09
- Re: Basic questions about Gorm, Ivan Vučica, 2011/04/09
- Re: Basic questions about Gorm, Nicola Pero, 2011/04/09
- Re: Basic questions about Gorm, David Chisnall, 2011/04/09
Re: Basic questions about Gorm, Riccardo Mottola, 2011/04/08