Commit Graph

36 Commits

Author SHA1 Message Date
Saleem Abdulrasool
714eaefc78 Importer: remove ImportAsMember support
This functionality is not actively in use and the last usage of this has
been removed.  Remove the infrastructure that is no longer in need.
2021-03-22 08:53:56 -07:00
Doug Gregor
1e5d30f5ca [Concurrency] Import Objective-C methods with completion handlers as async
When a given Objective-C method has a completion handler parameter
with an appropriate signature, import that Objective-C method as
async. For example, consider the following CloudKit API:

    - (void)fetchShareParticipantWithUserRecordID:(CKRecordID
*)userRecordID
            completionHandler:(void (^)(CKShareParticipant * _Nullable shareParticipant, NSError * _Nullable error))completionHandler;

With the experimental concurrency model, this would import as:

    func fetchShareParticipant(withUserRecordID userRecordID: CKRecord.ID) async throws -> CKShare.Participant?

The compiler will be responsible for turning the caller's continuation
into a block to pass along to the completion handler. When the error
parameter of the completion handler is non-null, the async call
will result in that error being thrown. Otherwise, the other arguments
passed to that completion handler will be returned as the result of
the async call.

async versions of methods are imported alongside their
completion-handler versions, to maintain source compatibility with
existing code that provides a completion handler.

Note that this only covers the Clang importer portion of this task.
2020-08-27 21:30:13 -07:00
tbkka
868425be8a More Python3 lint fixes (#32967)
* More Python3 lint fixes

Some of the issues addressed include:
* Don't use `l` as a variable name (confusable with `1` or `I`)
* `print` statement does not exist in Py3, use `print` function instead
* Implicit tuple deconstruction in function args is no longer supported,
  use explicit splat `*` at the call site instead
* `xrange` does not exist in Py3, use `range` instead

* Better name per review feedback
2020-07-19 21:44:13 -07:00
Doug Gregor
8082d391bd [swift-api-dump] Support arbitrary version strings, e.g., "4.2"
Fixes rdar://problem/41141987.
2018-06-26 13:39:42 -07:00
Doug Gregor
7fae6bb4b8 [swift-api-dump] Add options to tweak output.
Introduce a few new options to tweak the output of this script:

  -show-overlay         Show overlay API in addition to Objective-C module API
  -show-doc-comments    Show documentation comments
  -show-unavailable     Show declarations that are unavailable in Swift

As requested by rdar://problem/39384089.
2018-04-16 13:55:32 -07:00
Hugh Bellamy
c6fcbf0510 Python lint a bunch of files not currently python linted 2017-03-17 14:11:00 +07:00
Doug Gregor
17d5022fde Teach swift-api-dump.py to work with SDK variants.
Fixes <rdar://problem/30584462>.
2017-03-10 16:16:11 -08:00
Hugh Bellamy
fa3543d3c5 Fix some pylint errors for double whitespace after class/function 2017-02-17 15:37:19 +07:00
practicalswift
1d7d2e1bb7 [gardening] Fix PEP-8 violations. 2016-10-16 12:41:36 +02:00
Doug Gregor
23549296ed [swift-ide-test / swift-api-dump.py] Add -iframework support. 2016-10-13 14:43:39 -07:00
Doug Gregor
69d6709f17 [swift-api-dump.py] Add support for -swift-version N.
Teach swift-api-dump to pass through a Swift version flag, so it's
easy to see the effects of Swift 3 compatibility mode vs. Swift 4.

While I'm here, drop the "-always-argument-labels" flag (which we
don't need now that we've settled the argument-label rules) and
replace 'OSX' with 'macOS'.
2016-10-13 14:02:14 -07:00
Alex Chan
5bf26ca309 Minor Python tidies in swift-api-dump.py
* Don't override the name of the builtin `str`
* Use raw strings for regex matches
* Replace a couple of unused variables by `_`
* Remove an unused argument from `create_dump_module_api_args` (the arg
  is never used in the body of the function, and it's only called from
  this file).
2016-06-18 14:41:07 +01:00
practicalswift
2c25cbb0fd [gardening] Fix PEP 8 violation. 2016-04-19 21:48:03 +02:00
Doug Gregor
4d5dfffbaa [swift-api-dump] Improve failure diagnostics slightly 2016-04-18 17:08:06 -07:00
practicalswift
711da003a1 [gardening] Fix PEP 8 regression. 2016-03-28 00:48:14 +02:00
Michael Ilseman
47e73ad4f1 Merge branch 'master' of github.com:apple/swift into import-as-member 2016-03-23 17:01:47 -07:00
Michael Ilseman
d7581d1b36 Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member 2016-03-23 13:05:57 -07:00
Doug Gregor
593932741c Remove historical flags -enable-omit-needless-words/-enable-infer-default-arguments/-enable-swift-name-lookup-tables.
NFC; all of these options are always-on now and we no longer have a
way to turn them off.
2016-03-22 17:04:19 -07:00
practicalswift
1edb62dc38 [Python] Make flake8 linting pass without errors/warning (w/ default rules) 2016-03-13 20:19:51 +01:00
practicalswift
0796eaad1f [Python] Fix 80-column violations 2016-03-09 23:52:11 +01:00
Brian Gesiak
c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
Michael Ilseman
24417848ec [Import as member] add inference support to swift-api-dump script 2016-03-08 16:55:24 -08:00
practicalswift
265835fdfc [Python] Use consistent import ordering for Python code
Ordering used:
1.) standard library imports
2.) third party imports
3.) local package imports

Each group is individually alphabetized.
2016-03-07 23:25:16 +01:00
practicalswift
183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00
practicalswift
f6d6585ee0 [Python] Improve Python consistency: Use function_name(…) throughout (PEP8) 2016-02-29 22:49:19 +01:00
Doug Gregor
1c2ce6f22f [Omit needless words] Add a flag to let us skip overrides and witnesses.
When performing Swift API dumps, it's helpful to avoid putting
redundant APIs into the results. Therefore, filter out any APIs that
are overrides of another API or are witnesses for a protocol
requirement, since the original definition (that doesn't override any
other or is a protocol requirement) is what determines the APIs name.
2016-02-24 17:47:31 -08:00
Erik Eckstein
dcb458676b Revert "Revert "[Omit needless words] Always dump both argument label and parameter name.""
This reverts commit 836cf9ea71.

Sorry, I reverted the wrong commit
2016-02-23 07:41:50 -08:00
Erik Eckstein
836cf9ea71 Revert "[Omit needless words] Always dump both argument label and parameter name."
This reverts commit c0b432d7eb.

There is a crash in StdlibUnittests on i386.
2016-02-22 21:30:41 -08:00
Doug Gregor
c0b432d7eb [Omit needless words] Always dump both argument label and parameter name.
The default first argument label rules are confusing reviewers looking
at API dumps. Even though it's more verbose, always put in argument
labels explicitly.
2016-02-22 15:11:16 -08:00
Doug Gregor
78cb038cbb [Omit needless words] Don't prefix-strip when dumping APIs.
We're going to delay NS prefix stripping for a bit. Change the API
dump script accordingly, and bump the Swift name lookup table format
version number so this doesn't break everyone who has already run
swift-api-dump.py.
2016-02-22 14:24:20 -08:00
Brian Gesiak
9980b5b062 [swift-api-dump] Omit 'python' in usage (NFC)
- Since this file has a Python shebang (`#!/usr/bin/env python`) at the top, it can be invoked directly, without specifying which Python interpreter to use on the command line.
- Use the `%(prog)s` substitution instead of writing the program name again explicitly.
2016-02-15 14:48:05 -05:00
Doug Gregor
fc43acd501 [swift-api-dump] Add support for -F/-I arguments. 2016-02-15 11:38:00 -08:00
Doug Gregor
9832468dac Install swift-api-dump.py script to make it easier to use 2016-02-15 11:38:00 -08:00
Doug Gregor
7d26349c9c Rename omit-needless-words.py to swift-api-dump.py.
This script is more general than its name implies. NFC
2016-02-15 11:38:00 -08:00
Chris Lattner
c66fdac034 Revert "Generalize omit-needless-words script to swift-api-dump."
This reverts commit a4e4af0c40.
2016-02-09 22:33:52 -08:00
Doug Gregor
a4e4af0c40 Generalize omit-needless-words script to swift-api-dump.
The omit-needless-words script has grown into a more general "API
dumping" script. Make it a bit more useful by installing it alongside
swift-ide-test, symlinking it in the build directory next to
swift-ide-test (for Swift developers), and defaulting to using the
swift-ide-test in the same directory as the script. Now it's fairly
easy to dump the API for a given SDK with, e.g.,

  swift-api-dump.py -s iphoneos
2016-02-09 16:41:24 -08:00