Commit Graph

2550 Commits

Author SHA1 Message Date
Joe Groff
4f73bd5cb6 ClangImporter: Initializer type for imported ctors
Update the Clang importer to setInitializerType on the ConstructorDecls it creates.

Swift SVN r3863
2013-01-25 17:50:53 +00:00
Jordan Rose
2c86130a8f Remove ScriptingBridge compiler hack, tests, and adapter library.
It wasn't good enough and we're not going to use it.

Swift SVN r3834
2013-01-22 21:29:15 +00:00
Jordan Rose
fa197bff3a The latest OSX 10.9 SDKs have changed name of the ObjC module to ObjectiveC.
Update everywhere in Swift that refers to this module accordingly.

This change is backwards-incompatible and will require rebuilding any
Objective-C-based object files. I recommend a clean of swiftFoundation
and NSStringDemo at the very least. The swiftObjC target is also being
renamed to swiftObjectiveC for consistency.

Swift SVN r3784
2013-01-17 19:46:39 +00:00
Jordan Rose
bfa017d711 For now, don't import properties in protocols at all (for real this time).
Uncomment the commented-out-for-testing lines in r3733.

Swift SVN r3737
2013-01-11 01:50:16 +00:00
Jordan Rose
31cdecb624 For now, don't import properties in protocols at all.
We can't IRGen the getter and setter thunks, and we don't want to import
the getter and setter methods individually because that's not
source-compatible with properties in Swift. Support for importing
protocol properties properly is tracked in <rdar://problem/12993073>.

Swift SVN r3735
2013-01-11 01:46:34 +00:00
Jordan Rose
355dc02dd2 Fix import for SB(Typed)ElementArray.
Its owning module is ScriptingBridge, not Foundation.

Swift SVN r3722
2013-01-10 00:53:56 +00:00
Jordan Rose
f8ddd7c1b5 Add SBTypedElementArray as a typed variant of SBElementArray.
This uses the same hack as NSArray / NSTypedArray.

Swift SVN r3720
2013-01-09 22:53:27 +00:00
Doug Gregor
a6ca4cee66 Rename "objc" module to "ObjC", to match what we're doing in the SDK.
Swift SVN r3652
2013-01-03 00:28:46 +00:00
Doug Gregor
e224c49121 Using numbering of parameters to cope with Objective-C selector identifiers.
This maps methods with selectors that have repeated names, such
as performSelector:withObject:withObject:, to function types for which
one can meaningfully call with named arguments. Once an identifier has
been seen as a parameter name, subsequent parameters will have a
number appended to them, so we'll end up with calls like

  foo.performSelector(sel, withObject=x, withObject2=y)





Swift SVN r3645
2013-01-02 21:39:56 +00:00
Doug Gregor
394172aafe Import Objective-C protocols as Swift [objc] protocols.
When we import an Objective-C protocol, we add the "Proto" suffix to
the name to avoid collisions when a class and protocol have the same
name. Of course, one's "Proto"-suffixed declarations will still
conflict, so this rule isn't great.


Swift SVN r3642
2013-01-02 20:52:25 +00:00
Doug Gregor
2b2b2cfc31 Replace the constructor 'alllocates_this' attribute with an 'allocate-this' expression.
By splitting out the expression used to allocate 'this' (which exists
in the AST but cannot be written in the Swift language proper), we
make it possible to emit non-allocating constructors for imported
Objective-C classes, which are the only classes that have an
allocate-this expression.


Swift SVN r3558
2012-12-20 15:28:37 +00:00
Doug Gregor
aaea6d94cf Import Objective-C properties annotated with 'iboutletcollection' as typed collections.
This commit only covers semantic analysis. We're still not able to
IRgen a downcast from a concrete class to an archetype.


Swift SVN r3535
2012-12-18 23:12:33 +00:00
Doug Gregor
d2c40eeccd Move the ObjCBool type into the 'objc' module.
Swift SVN r3533
2012-12-18 22:06:48 +00:00
Doug Gregor
d4980b67b3 When naming a Swift type from the Clang importer, also provide a module to look in.
No actual functionality change, yet.


Swift SVN r3532
2012-12-18 21:56:14 +00:00
Doug Gregor
03482134f4 Use proper 'this' parameter types for Objective-C getter/setter thunks.
As part of this, also wire up overridden subscript declarations.


Swift SVN r3484
2012-12-13 22:24:03 +00:00
Doug Gregor
675204b5fd Don't map Objective-C methods in the 'new' family to Swift constructors.
Swift SVN r3435
2012-12-11 00:33:13 +00:00
Jordan Rose
8fba78fdba Import [ibaction] and [iboutlet] attributes from Clang.
...although we're not planning to use them for anything. (It's possible they
need to be inherited for ibtool to work correctly, but that's a long ways
off.)

Swift SVN r3433
2012-12-11 00:09:11 +00:00
Doug Gregor
48ac908a8e Map the Objective-C BOOL type to a new ObjCBool Swift type.
The ObjCBool type interoperates with Swift's native Bool type, so one
can use true/false as well as conditionals with Objective-C
functions/methods that involve BOOL.


Swift SVN r3410
2012-12-07 20:02:49 +00:00
Doug Gregor
60aecc415f Provide more bogus source information for synthesized ASTs.
This is just a band-aid to avoid freaking out the diagnostic
system. I'm looking into alternative solutions.



Swift SVN r3409
2012-12-07 19:46:17 +00:00
Doug Gregor
3c7d9d0f62 Don't import inline Clang functions; they won't work.
Eventually, we'll need to teach Swift's IRgen how to call into Clang's
IRgen to cover this case. <rdar://problem/12837078>


Swift SVN r3408
2012-12-07 19:20:12 +00:00
Doug Gregor
aecd8d4432 When accessing a member of a tuple rvalue, materialize the tuple.
Fixes <rdar://problem/12830375>.


Swift SVN r3395
2012-12-07 01:59:27 +00:00
Doug Gregor
4c71d7386a Implement getter/setter thunks for imported Objective-C properties.
With this, we are able to access Objective-C properties from within Swift.


Swift SVN r3393
2012-12-07 01:11:52 +00:00
Doug Gregor
91960e4272 Support keyed subscripting for Objective-C classes as Swift subscripting.
As shown in the updated NSString demo, we can now subscript into
NSDictionary from Swift. No extra magic required.


Swift SVN r3386
2012-12-07 00:13:38 +00:00
Doug Gregor
aabff2b65b Create a getter thunk for Objective-C subscripts.
Swift SVN r3385
2012-12-06 23:52:16 +00:00
Doug Gregor
5bd1e928d1 The subscripting setter thunk is *not* an imported Clang declaration.
Swift SVN r3383
2012-12-06 19:33:04 +00:00
Doug Gregor
aa89f9185b Generate the required AST-level thunk for subscript setters.
An Objective-C subscript setter has a type of the form 

  (this) -> (value, index) -> ()

while a Swift subscript setter has a type of the form

  (this) -> (index) (value) -> ()

Introduce a Swift "thunk" with the latter signature that simply calls
the underlying Objective-C method, and make sure that thunk gets
type-checked and IR-generated appropriately.


Swift SVN r3382
2012-12-06 19:28:11 +00:00
Doug Gregor
e4c2d71632 Import Objective-C indexed subscripting methods as Swift subscript declarations.
This commit covers only the AST-building side of indexed
subscripting, mapping objectAtIndexedSubscript: and
setObject:atIndexedSubscript: to Swift 'subscript' declarations. IR
generation and support for keyed subscripting to follow.


Swift SVN r3377
2012-12-06 02:34:53 +00:00
Doug Gregor
c5c5fa9e35 Be more selective about creating constructors for Objective-C new/init methods.
Only create constructors for class 'new' methods (not instance methods
like
newScriptingObjectOfClass:forValueForKey:withContentsValue:properties:),
and only do so when the class type inherits from NSObject. The latter
occurs because we don't have a notion of a 'top' for Objective-C
classes, and is a temporary measure.


Swift SVN r3374
2012-12-05 23:46:47 +00:00
Doug Gregor
1f45f28837 Emit the constructors synthesized by the Clang importer for ObjC init/new methods.
Note that the constructors we emit don't function yet, since they rely
on the not-yet-implemented class message sends to Objective-C
methods.


Swift SVN r3370
2012-12-05 22:01:38 +00:00
Doug Gregor
9904844727 Move 'external definitions' vector into the Clang module; it only makes sense there.
Swift SVN r3367
2012-12-05 18:35:33 +00:00
Doug Gregor
85f690d086 Type-check the constructors synthesized for Objective-C init/new methods.
Swift SVN r3366
2012-12-05 18:15:48 +00:00
Doug Gregor
519091c30d Synthesize a body for Swift constructors that map down to alloc/init* or new invocations.
At present, the body of these constructors is neither type-checked nor
IR-generated.


Swift SVN r3358
2012-12-05 01:11:11 +00:00
Doug Gregor
a221a6986b Rename the "allocating" attribute to "allocates_this".
Swift SVN r3353
2012-12-04 20:20:58 +00:00
Doug Gregor
d04db691ec Retain the first selector piece when importing init/new methods as constructors.
This is the conservative solution that we can revisit later.


Swift SVN r3352
2012-12-04 20:00:01 +00:00
Doug Gregor
08c9b5c7b2 Allocating constructors are expected to allocate and assign 'this' on their own.
This implementation is very lame, because we don't currently have a
way to detect (in Sema or SIL) where 'this' gets uniquely assigned,
and turn that assignment into initialization.

Also, I'm starting to hate the name 'allocating' constructor, because
it's the opposite of the Itanium C++'s notion of the allocating
constructor. Will think up a better name.




Swift SVN r3347
2012-12-04 01:06:30 +00:00
Doug Gregor
98cc0555a3 Import Objective-C methods in the 'init' and 'new' family as Swift constructors.
This commit only covers the semantic analysis for this operation; IR
generation to follow.


Swift SVN r3341
2012-12-04 00:20:08 +00:00
Doug Gregor
629b06623d Import Objective-C categories and extensions as Swift extensions.
Swift SVN r3262
2012-11-27 22:19:16 +00:00
Doug Gregor
311520a3ec Implement support for calling Objective-C instance methods imported from Clang.
Tweak the import of Objective-C methods to build the proper FuncExpr
and tag the FuncDecl as an Objective-C method, along with a few other
tweaks, so calls to the imported Objective-C methods go through
objc_msgSend().

At this moment, this is aborting in the Objective-C runtime due to an
unrecognized selector. The issue does not appear related to the
importer.


Swift SVN r3255
2012-11-27 07:50:52 +00:00
Doug Gregor
83f2874ba1 Implement support for calling imported C functions from Swift.
There is no protection whatsoever if the Clang-to-Swift type
conversion produces something that Swift doesn't lower in an
ABI-compatible way. That will be dealt with later.


Swift SVN r3249
2012-11-27 00:34:48 +00:00
Doug Gregor
e41a89ab27 Record overridden Objective-C properties in the Swift AST.
Swift SVN r3247
2012-11-26 20:58:20 +00:00
Doug Gregor
8527126264 Import Objective-C properties as Swift variables.
Note that we have to be very careful not to introduce ambiguities
between the name of the getter and the name of the property, so we do
the following:
  - "Informal" properties (where there is no @property) are not
  mapped to Swift variables. The methods are just methods.
  - An @property suppresses name lookup's ability to find
  the getters and setters of that property, so having a "foo" property
  eliminates the "foo" and "setFoo" methods.
  - If an @property is added in a subclass, such that its getter or
  setter come from a superclass, than that property cannot be mapped
  to a Swift variable. Hopefully, this is rare.

As part of this, I had to make sure that Objective-C method overrides
were recorded as overrides in the Swift AST. The same will need to
happen for properties at some point.



Swift SVN r3245
2012-11-26 20:09:55 +00:00
Doug Gregor
f5eae6a60f Import Objective-C class methods into Swift.
Swift SVN r3244
2012-11-26 18:00:37 +00:00
Doug Gregor
9d299f8bec Import Objective-C instance methods into Swift.
Swift SVN r3240
2012-11-26 17:45:07 +00:00
Doug Gregor
c3801abeb4 Import Objective-C classes into Swift.
Only the class name and its superclass are imported at this
time. Properties and methods to follow.



Swift SVN r3239
2012-11-26 16:54:49 +00:00
Doug Gregor
1ed3e7b0d6 Put in stubs for Clang declaration kinds that won't be imported.
Swift SVN r3238
2012-11-26 16:09:36 +00:00
Doug Gregor
037ad8403d Import Clang global variables as Swift global variables.
Swift SVN r3237
2012-11-26 15:59:19 +00:00
Doug Gregor
3fcbfdd42a Import C structs and C++ classes as Swift structs.
Swift SVN r3236
2012-11-26 15:51:46 +00:00
Doug Gregor
1c6c67af5e Implement support for importing Clang enumeration types as Swift oneofs.
Swift SVN r3221
2012-11-17 00:33:37 +00:00
Doug Gregor
5fcca3dc0b Build out the infrastructure for importing declarations.
As part of this, import typedefs (and C++11 type aliases) as Swift
type aliases.


Swift SVN r3215
2012-11-16 23:41:54 +00:00
Doug Gregor
0afad51b4a Factor the declaration-importing code into its own file.
Swift SVN r3214
2012-11-16 23:08:25 +00:00