Commit Graph

164 Commits

Author SHA1 Message Date
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Doug Gregor
4f9f945d62 Teach the Clang importer to add @objc(selector) attributes for imported methods and initializers.
With this in place, remove the hacks that peeked at the imported Clang
node to determine the selector for a method. We're all
attribute-driven now. Part of <rdar://problem/16019773>.


Swift SVN r15663
2014-03-31 04:26:32 +00:00
Jordan Rose
f6426f27ed [PrintAsObjC] Use the selectors provided by the AST.
...instead of building our own from the argument patterns. This is all likely
to change soon, so let's not keep a separate implementation in PrintAsObjC.

In that vein, print subscript accessors the same way as any other methods.

No functionality change, except that subscript setter arguments are not all
called "value" any more.

Swift SVN r15532
2014-03-26 22:15:19 +00:00
Dmitri Hrybenko
7d697d7a89 @objc inference / PrintAsObjC: don't map non-@objc classes to id (and metatypes
of those to Class)

I would not call this a regression because the fix is very simple -- just mark
the class @objc, but in return the user will get concrete types on the
Objective-C side, which is a significant benefit.


Swift SVN r15234
2014-03-19 11:04:22 +00:00
Jordan Rose
12964f2e27 [ClangImporter] Resolve generated header protocols to native decls as well.
This is the same as the previous commit, but for protocols. To do this I
had to modify the ObjC printer to include a SWIFT_PROTOCOL annotation like
the SWIFT_CLASS annotation already in use. This is probably a good thing
anyway.

Second half of <rdar://problem/16296027>

Swift SVN r14985
2014-03-13 00:19:12 +00:00
Jordan Rose
480c1bac08 [PrintAsObjC] Push the prologue back into the generated headers.
This means more duplication, but it's also more future-proof: the set of
features used is based on the compiler that generates the header, not the
compiler that eventually consumes the header. To allow for forward-
compatibility, all the macros used by the header can be overridden by the
consuming environment, and the header <swift/objc-prologue.h> will be
included if it exists.

Swift SVN r14893
2014-03-10 23:47:22 +00:00
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Doug Gregor
25c5692fe6 PrintAsObjC: Swift subobject initializers are ObjC designated initializers.
Swift SVN r14610
2014-03-03 21:38:28 +00:00
Jordan Rose
4e72db0a94 [PrintAsObjC] Only @import frameworks that are used by the header.
Anything used only in an implementation should be omitted.

<rdar://problem/16140047>

Swift SVN r14485
2014-02-27 23:32:58 +00:00
Jordan Rose
b9cd3c1163 [Sema] Allow Optional and UncheckedOptional in @objc methods and properties.
...when the optional object type is a class or Objective-C protocol type.
This is currently hidden behind -enable-objc-optional because I didn't test
if the generated code is actually correct.

Also add PrintAsObjC support for these.

Known missing pieces: blocks, and Swift structs bridged to Objective-C classes
(right now, just String).

Swift SVN r14416
2014-02-26 22:15:55 +00:00
Jordan Rose
ffd104e3b0 [PrintAsObjC] Add objc_complete_definition attribute to generated @interfaces.
This is using the compatibility macro SWIFT_CLASS, so older Clangs can still
parse a generated header on its own. This will only be interesting in a
mixed-source target, where we may need to merge a forward declaration with
a Swift-generated @interface. (See <rdar://problem/16076729>.)

Swift SVN r14411
2014-02-26 22:15:48 +00:00
Jordan Rose
02892a0412 [PrintAsObjC] Handle UInt by printing it as NSUInteger.
This is a bit ironic considering we're importing NSUInteger as Int rather
than UInt, but Swift should never be using the headers it prints anyway.

Swift SVN r14088
2014-02-19 18:29:42 +00:00
Jordan Rose
7995dde448 Module::getImportedModules can now get public, private, or all imports.
...whereas before the only options were "public" and "all".

No functionality change.

Swift SVN r13849
2014-02-12 23:57:43 +00:00
Jordan Rose
95461797aa Move -print-as-objc feature into a library.
No functionality change.

Swift SVN r13798
2014-02-12 01:19:09 +00:00