Windows: bridge BOOL to Bool

This allows the conversion of the Windows `BOOL` type to be converted to
`Bool` implicitly.  The implicit bridging allows for a more ergonomic
use of the native Windows APIs in Swift.

Due to the ambiguity between the Objective C `BOOL` and the Windows
`BOOL`, we must manually map the `BOOL` type to the appropriate type.
This required lifting the mapping entry for `ObjCBool` from the mapped
types XMACRO definition into the inline definition in the importer.

Take the opportunity to simplify the mapping code.

Adjust the standard library usage of the `BOOL` type which is now
eclipsed by the new `WindowsBool` type, preferring to use `Bool`
whenever possible.

Thanks to Jordan Rose for the suggestion to do this and a couple of
hints along the way.
This commit is contained in:
Saleem Abdulrasool
2019-04-23 18:03:33 -07:00
parent 2022b5c566
commit 83b290438c
19 changed files with 220 additions and 39 deletions

View File

@@ -350,9 +350,9 @@ public protocol _ExpressibleByBuiltinBooleanLiteral {
/// A type that can be initialized with the Boolean literals `true` and
/// `false`.
///
/// Only three types provided by Swift---`Bool`, `DarwinBoolean`, and
/// `ObjCBool`---are treated as Boolean values. Expanding this set to include
/// types that represent more than simple Boolean values is discouraged.
/// `Bool`, `DarwinBoolean`, `ObjCBool`, and `WindowsBool` are treated as
/// Boolean values. Expanding this set to include types that represent more than
/// simple Boolean values is discouraged.
///
/// To add `ExpressibleByBooleanLiteral` conformance to your custom type,
/// implement the `init(booleanLiteral:)` initializer that creates an instance