Skip to content

[+0-args][runtime] Add temporary runtime swift convention macros. #13971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gottesmm
Copy link
Contributor

These are temporary staging macros to ease having a runtime that supports both
+0 and +1 conventions for functions exposed as Swift level functions in the
stdlib (and thus needing to follow the swift convention). The macros values are
toggled by the argument SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS and thus have
values described via the following table:

| SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENT | FALSE                         | TRUE                          |
|-----------------------------------------+-------------------------------+-------------------------------|
| SWIFT_NS_RELEASES_ARGUMENT              | NS_RELEASES_ARGUMENT          | ""                            |
| SWIFT_CC_PLUSONE_GUARD(...)             | do { __VA_ARGS__ ; } while(0) | ""                            |
| SWIFT_CC_PLUSZERO_GUARD(...)            | ""                            | do { __VA_ARGS__ ; } while(0) |

Thus instead of having to write an ugly #ifdef multiple times in each function
(for the arguments, destroys, and retains), we can just use these macros
instead.

In a subsequent commit I am going to cleanup the changes I made in the runtime
already to use these macros. So this is a NFC change.

rdar://34222540

These are temporary staging macros to ease having a runtime that supports both
+0 and +1 conventions for functions exposed as Swift level functions in the
stdlib (and thus needing to follow the swift convention). The macros values are
toggled by the argument SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS and thus have
values described via the following table:

| SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENT | FALSE                         | TRUE                          |
|-----------------------------------------+-------------------------------+-------------------------------|
| SWIFT_NS_RELEASES_ARGUMENT              | NS_RELEASES_ARGUMENT          | ""                            |
| SWIFT_CC_PLUSONE_GUARD(...)             | do { __VA_ARGS__ ; } while(0) | ""                            |
| SWIFT_CC_PLUSZERO_GUARD(...)            | ""                            | do { __VA_ARGS__ ; } while(0) |

Thus instead of having to write an ugly #ifdef multiple times in each function
(for the arguments, destroys, and retains), we can just use these macros
instead.

In a subsequent commit I am going to cleanup the changes I made in the runtime
already to use these macros. So this is a NFC change.

rdar://34222540
@gottesmm
Copy link
Contributor Author

FYI, I already ran this by @gparker42.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 375bdbd into swiftlang:master Jan 16, 2018
@gottesmm gottesmm deleted the pr-72a638e3dd41744f4943fbeafb1e00d8dc0e1ad1 branch January 16, 2018 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants