Commit Graph

386 Commits

Author SHA1 Message Date
Jordan Rose
6afb4df544 [PrintAsObjC] Handle properties with weak/unowned storage.
We don't do this quite as well as we could (we don't list the storage
type in the @property), but previously we just failed on these types.

<rdar://problem/16992990>

Swift SVN r18528
2014-05-21 22:38:04 +00:00
Joe Groff
e8f71c12a2 Rename ObjCMutablePointer to AutoreleasingUnsafePointer.
This relates its interface and behavior to that of UnsafePointer, and draws an analogy to '__autoreleasing *' in ARC.

Swift SVN r18236
2014-05-17 04:44:44 +00:00
Jordan Rose
fed3b6d636 [PrintAsObjC] Remove references to the objc_complete_definition attribute.
This is part of @partial_interface, which we decided not to ship.
Follow-on to r18168.

Swift SVN r18208
2014-05-16 19:57:51 +00:00
Jordan Rose
d4a493e871 [PrintAsObjC] Don't include the ObjC header module in the generated header.
Importing a header with -import-objc-header causes the Clang importer to
provide an extra module to represent the header's content, and this was
showing up as "@import __ObjC;" in the /generated/ header for the target.
We should just not print anything there and let users import what's
necessary.

<rdar://problem/16917113>

Swift SVN r18081
2014-05-14 21:42:31 +00:00
Jordan Rose
74bc750c43 [PrintAsObjC] Use #import for the underlying module (instead of @import).
When generating a header for the Swift half of a mixed-source framework,
we can't import the framework using @import, because that means a submodule
is trying to import a parent module before the module is done being built.
This currently isn't supported in Clang, though it only recently became an
error instead of being ignored.

Instead, we now assume that the framework will have an umbrella header with
the same name as the framework module, which is the same assumption Xcode
makes when you don't provide your own module map. I'm not too concerned about
people trying to build mixed-source frameworks who /don't/ have umbrella
headers.

This doesn't affect app targets at all, which use -import-objc-header instead
of a standalone underlying module.

<rdar://problem/16879704>

Swift SVN r17984
2014-05-13 00:38:49 +00:00
Doug Gregor
c61b347169 Make Dictionary conditionally bridged to Objective-C.
This is the runtime support we need to be able to bridge
dictionaries. I believe this is the last part of
<rdar://problem/16870606>.

Swift SVN r17843
2014-05-10 20:41:15 +00:00
Doug Gregor
4de43af267 PrintAsObjC: Print Dictionary<K, V> as "NSDictionary *"
Swift SVN r17839
2014-05-10 20:07:57 +00:00
Jordan Rose
9ba37a07a3 [PrintAsObjC] Print imported CF types using their typedefs.
Swift SVN r17577
2014-05-06 22:50:37 +00:00
Jordan Rose
07936a7328 [PrintAsObjC] Handle briding *Pointer types.
Also add NSZone, which we special-case in the importer but forgot to do in
Sema and PrintAsObjC. (Sorry for the combined commit.)

<rdar://problem/16505708>

Swift SVN r17576
2014-05-06 22:50:36 +00:00
Jordan Rose
ad386cf85c [PrintAsObjC] Print Array<T> as NSArray *.
There aren't any tests for anything but AnyObject[] because we can't actually
generate code for other arrays yet.

Swift SVN r17575
2014-05-06 22:50:35 +00:00
Jordan Rose
16f96f1139 [PrintAsObjC] Guard @import lines with __has_feature(modules).
Also, use "#include <objc/NSObject.h>" instead of "@import ObjectiveC;"
to get access to BOOL, SEL, NSObject, and NSString.

This allows generated headers to be used in Objective-C++ contexts, where
modules don't yet work. The dependencies will unfortunately need to be
imported separately (because there's not a direct mapping from module name
back to header file), but that's still better than just being incompatible.

<rdar://problem/16796627>

Swift SVN r17272
2014-05-02 21:36:55 +00:00
Jordan Rose
efc8b0d3ec [PrintAsObjC] Add objc_subclassing_restricted to Swift classes.
This will cause new enough Clangs to warn when someone tries to subclass a
Swift class from Objective-C.

<rdar://problem/15800366>

Swift SVN r16897
2014-04-26 23:32:04 +00:00
Dmitri Hrybenko
00722d4c2e Comment parsing: extract parameter name from the text in :param: field
Swift SVN r16750
2014-04-24 09:13:42 +00:00
Doug Gregor
36889a2b1a Introduce DeclIterator and DeclRange for iterating over decl members.
NFC. DeclRange is a range over DeclIterators, and is used rather than
ArrayRef<Decl*> to retrieve the members of a nominal type declaration
or extension thereof. The intent is to change the representation of
DeclRange next.


Swift SVN r16571
2014-04-19 18:53:20 +00:00
Doug Gregor
8bc2ea4ea1 Use designated/convenience initializer terminology throughout. NFC
Introduce CtorInitializerKind to describe the kind of an enum, rather
than a bool, to make way for more initializer kinds in the future.

Swift SVN r16525
2014-04-18 15:10:13 +00:00
Dmitri Hrybenko
0dac54ab1d PrintAsObjC: attach comments to protocols in the generated header
Swift SVN r16513
2014-04-18 09:16:19 +00:00
Dmitri Hrybenko
68e8fee5fc Comment parsing: put more information into the generated XML documents
This commit adds infrastructure for conversion and testing it.

The conversion is still incomplete, pending discussion about which tags should
we use in the XML documents.  I copied the RelaxNG schema from Clang, and will
edit it accordingly.


Swift SVN r16451
2014-04-17 15:42:51 +00:00
Doug Gregor
53b84c121e Switch ValueDecl::getObjCSelector() and friends over to ObjCSelector.
Formatting names into strings repeatedly, and using those for semantic
analysis, is generally considered poor form. Additionally, use the
camelCase utilities to perform the string manipulation we need, and
cache results on the ObjCAttr so we don't repeatedly do string
manipulation.

Swift SVN r16334
2014-04-14 22:02:51 +00:00
Ted Kremenek
35c2b6e469 PrintAsObjC: use protocol remapping in the importer to remap to the original protocol name.
Along the way, don't print out the same module import more than once.

Fixes <rdar://problem/16602327>.

Swift SVN r16308
2014-04-14 08:27:11 +00:00
Joe Groff
8adaab0233 Fold ExtInfo::isThin and ::isBlock into a "Representation" enum.
These bits are orthogonal to each other, so combine them into one, and diagnose attempts to produce a type that's both. Spot-fix a bunch of places this revealed by inspection that we would have crashed in SILGen or IRGen if blocks were be handled.

Swift SVN r16088
2014-04-09 00:37:26 +00:00
Doug Gregor
6baa7eb35c PrintAsObjC: Emit objc_runtime_name attributes for Swift classes.
This makes sure that Clang uses the mangled class names for
Swift-defined classes. Should be last compiler-side piece of
<rdar://problem/15506580>.


Swift SVN r15977
2014-04-05 04:45:21 +00:00
Dmitri Hrybenko
c68fe1a5d7 Comment parsing / PrintAsObjC: translate Swift comments to Doxygen syntax when
printing a header file


Swift SVN r15871
2014-04-03 16:06:01 +00:00
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