Commit Graph

22 Commits

Author SHA1 Message Date
Doug Gregor
c593d49b08 Rework the _ObjectiveCBridgeable to use inout parameters rather than returns.
The _forceBridgeFromObjectiveC and _conditionallyBridgeFromObjectiveC
requirements of the _ObjectiveCBridgeable protocol previously returned
Self and Self?, respectively, where 'Self' is the value type that is
bridged. This use of returns is fairly hostile to the idea of calling
the witnesses for these requirements from the C++ part of the runtime,
leading to "interesting" tricks with OpaqueExistentialContainer that
made it hard to use these witnesses within the dynamic casting
infrastructure.

Replace the returns with inout Self? parameters, which are far easier
to deal with in the C++ part of the runtime. Despite the churn because
we're changing the _ObjectiveCBridgeable protocol, this is NFC.

Swift SVN r20934
2014-08-02 01:03:41 +00:00
Doug Gregor
fd3fa7228f Dynamic casting from Objective-C bridged value types to class types.
First part of <rdar://problem/17637959>.

Swift SVN r20906
2014-08-01 18:44:05 +00:00
Dmitri Hrybenko
c7a5b1daca stdlib/runtime: fix leaks in swift_bridgeNonVerbatimToObjectiveC
Swift SVN r20827
2014-07-31 15:49:17 +00:00
John McCall
934527a029 Eliminate all uses of the typeof value witness.
Swift SVN r20734
2014-07-30 04:40:58 +00:00
Dave Abrahams
9a13a7148b [stdlib] Consolidate bridging protocols
Squash _[Conditionally]BridgedToObjectiveC into one protocol.  This
change results in simpler bridging code with fewer dynamic protocol
conformance checks, and solves the nasty naming/semantics problem that
resulted from having _ConditionallyBridgedToObjectiveC refining
_BridgedToObjectiveC.

Also, rename things so they're more symmetrical and less confusing.

Swift SVN r20664
2014-07-29 01:30:27 +00:00
Dmitri Hrybenko
4c4f83fb52 stdlib: underscore-prefix requirements of _BridgedToObjectiveCType and
_ConditionallyBridgedToObjectiveCType protocols

rdar://17283639


Swift SVN r20079
2014-07-17 09:42:19 +00:00
Dmitri Hrybenko
d125ac1e24 stdlib/runtime: stdlib casts to existentials: correctly project the buffer as
required

rdar://17628745


Swift SVN r20024
2014-07-16 15:17:46 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Doug Gregor
c7adb497ba Blocks "are" classes, from the runtime perspective.
This allows arrays of blocks to be bridged at runtime
<rdar://problem/17035548>.

Swift SVN r19765
2014-07-10 00:12:14 +00:00
Doug Gregor
0598b6db5e Casting runtime: Use the runtime's constant for reserved bits in an ObjC pointer.
Previously, we had a predicate that only worked properly for 64-bit
architectures; the 32-bit platforms don't have tagged pointers, and
have an annoying tendency to allocate objects with the high bit of the
address set. Fixes <rdar://problem/17544277>.

Swift SVN r19523
2014-07-03 17:55:38 +00:00
Doug Gregor
2618061168 Eliminate a pointless and wrong initialization from swift_bridgeNonVerbatimFromObjectiveCConditional.
Fixes part of <rdar://problem/17411843>.

Swift SVN r19485
2014-07-02 22:15:47 +00:00
John McCall
d0dc196e8b Fix a metatype casting bug in the new casting runtime.
Swift SVN r19078
2014-06-22 09:53:34 +00:00
Doug Gregor
e47b0c220f Address Dmitri's review comments
Swift SVN r19047
2014-06-20 13:57:00 +00:00
Doug Gregor
22dc55058e Make bridgeFromObjectiveC return non-optional.
Now that we use bridgeFromObjectiveCConditional to perform conditional
bridging, make bridgeFromObjectiveC handle forced bridging. For the
latter, deferred checking is acceptable.

Almost all of <rdar://problem/17319154>.


Swift SVN r19046
2014-06-20 13:15:41 +00:00
John McCall
47427ccc5a Ensure that we deallocate opaque existential containers
if we dynamic-cast out of them as a take.

Swift SVN r19043
2014-06-20 07:47:01 +00:00
Doug Gregor
2e3863b211 Introduce _ConditionallyBridgedToObjectiveC.bridgeFromObjectiveCConditional.
This entry point is used in conditional downcasts (as?) to attempt to
bridge from an Objective-C class down to a specific native type (e.g.,
array, dictionary), bridging all elements eagerly so that it can
produce nil if the bridging would fail.

This is the scaffolding for <rdar://problem/17319154>, and makes the
example there work, but there is much more cleanup and optimization to
do.



Swift SVN r18999
2014-06-19 14:48:00 +00:00
John McCall
9890d8bca0 Add swift_dynamicCast.
This is the most general dynamic cast operation, permitting
arbitary source and destination types and handling arbitrary
changes in representation.  A value of the destination type
is constructed in an address provided by the caller; flags
control the behavior w.r.t. the source value.

Not yet used; probably buggy in various particulars.

Swift SVN r18815
2014-06-12 00:13:13 +00:00
John McCall
0f0874bb4b Add variants of the checked-cast instructions that
put the result in a different place.

WIP: no IRGen support yet.

This will eventually be the required form when casting
to an address-only type; the existing instructions will
have only scalar outputs.

Swift SVN r18780
2014-06-10 07:43:22 +00:00
John McCall
5e1c15df93 Rationalize the class-instance dynamicCast runtime functions.
dynamicCastClass assumes that the destination type is a
Swift class type.

dynamicCastObjCClass assumes that the destination type is
an ObjC class type (represented as ObjC metadata, not type
metadata).

dynamicCastUnknownClass assumes only that the destination
type is some kind of class.

Swift SVN r18776
2014-06-10 02:11:24 +00:00
Joe Groff
cf20524271 Fix typo.
Swift SVN r18761
2014-06-09 22:19:12 +00:00
John McCall
1f5fa04724 Move the rest of the dynamic-cast code over to Casting.cpp.
Swift SVN r18759
2014-06-09 21:42:30 +00:00
John McCall
fd9778165b Split the dynamic-cast code out into its own file.
Swift SVN r18756
2014-06-09 21:16:09 +00:00