Skip to content
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

[stdlib] Replacing M_PI with .pi #6802

Merged
merged 3 commits into from
Jan 17, 2017
Merged

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Jan 14, 2017

M_PI has recently been deprecated. Replacing it's usages to avoid compilation warnings.

@moiseev moiseev changed the title Replacing M_PI with .pi [stdlib] Replacing M_PI with .pi Jan 14, 2017
@moiseev
Copy link
Contributor Author

moiseev commented Jan 14, 2017

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 764fc0a
Test requested by - @moiseev

@moiseev
Copy link
Contributor Author

moiseev commented Jan 14, 2017

@swift-ci Please smoke test and merge

Copy link
Contributor

@stephentyrone stephentyrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few simplifications are possible because CGFloat also has .pi, whereas M_PI was Double. Those may be outside the scope of this change, however.

@@ -124,7 +124,7 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
[ 0 0 1 ]
*/
public init(rotationByDegrees angle: CGFloat) {
let α = Double(angle) * M_PI / 180.0
let α = Double(angle) * .pi / 180.0
self.init(rotationByRadians: CGFloat(α))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be cleaned up further, I think; there's no long any need for the conversions.

self.init(rotationByRadians: angle * .pi / 180)

Possibly outside the scope of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. right! CGFloat conforms to the same protocol. Makes perfect sense. Thanks!

@@ -169,19 +169,19 @@ class TestAffineTransform : TestAffineTransformSuper {
checkPointTransformation(noop, point: point, expectedPoint: point)

var tenEighty = AffineTransform.identity
tenEighty.rotate(byRadians: CGFloat(6 * M_PI))
tenEighty.rotate(byRadians: CGFloat(6 * Double.pi))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, these could just be tenEighty.rotate(byRadians: 6 * .pi).

@moiseev
Copy link
Contributor Author

moiseev commented Jan 17, 2017

@swift-ci Please test and merge

@swift-ci swift-ci merged commit 1b75481 into swiftlang:master Jan 17, 2017
@moiseev moiseev deleted the no-pi-warning branch January 17, 2017 22:44
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.

3 participants