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

SR-1464: NSNumber.description is not compatible between OS X and linux #1724

Merged
merged 3 commits into from Dec 1, 2018

Conversation

spevans
Copy link
Collaborator

@spevans spevans commented Oct 14, 2018

  • Use Swift's stringification of numbers for .description and .stringValue

  • Use String(format:locale:...) with the correct format for the
    NSNumber type if locale is not nil.

  • Enable use of __CFStringFormatLocalizedNumber() on
    DEPLOYMENT_TARGET_LINUX.

@spevans
Copy link
Collaborator Author

spevans commented Oct 14, 2018

@swift-ci test

1 similar comment
@spevans
Copy link
Collaborator Author

spevans commented Oct 14, 2018

@swift-ci test

@@ -6013,7 +6013,7 @@ enum {
CFFormatDummyPointerType = 42 /* special case for %n */
};

#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
Copy link
Contributor

Choose a reason for hiding this comment

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

This applies to all patches, but: going forward, we need to start using TARGET_OS_* instead of DEPLOYMENT_*. I’m going to be pinging patches when they make changes to an if line that contains the old constants.

Can this be made to read TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, thats no problem. Should the EMBEDDED be added as well ?

Copy link
Contributor

Choose a reason for hiding this comment

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

TARGET_OS_MAC includes all Mac OS X-derived software, including what 'embedded' used to target. (You can replace 'embedded' with TARGET_OS_IPHONE.)

Copy link
Contributor

Choose a reason for hiding this comment

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

_MAC includes _IPHONE and _OSX; _IPHONE includes _IOS, _WATCH etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't that make more sense if TARGET_OS_MAC becomes TARGET_OS_DARWIN? Technically Darwin is the operating system.

Copy link
Member

Choose a reason for hiding this comment

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

The macros come from TargetConditionals.h in the macOS/iOS SDK. We're trying to maintain cross-platform standardization for their names.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarification.

@@ -7109,7 +7109,7 @@ static Boolean __CFStringAppendFormatCore(CFMutableStringRef outputString, CFStr
switch (specs[curSpec].type) {
case CFFormatLongType:
case CFFormatDoubleType:
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -832,19 +832,17 @@ class TestNSString: LoopbackServerTest {
XCTAssertEqual(string, "Default value is 1000 (42.0)")
}

#if false // these two tests expose bugs in icu4c's localization on some linux builds (disable until we can get a uniform fix for this)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this no longer applicable after this patch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think enabling the __CFStringFormatLocalizedNumber makes it work on Linux now. I tested it on 14.04 and it seemed ok

@spevans
Copy link
Collaborator Author

spevans commented Oct 14, 2018

@swift-ci test

1 similar comment
@spevans
Copy link
Collaborator Author

spevans commented Oct 15, 2018

@swift-ci test

@spevans
Copy link
Collaborator Author

spevans commented Oct 24, 2018

@millenomi Do these changes look ok now?

@spevans
Copy link
Collaborator Author

spevans commented Nov 8, 2018

@swift-ci test linux

6 similar comments
@spevans
Copy link
Collaborator Author

spevans commented Nov 9, 2018

@swift-ci test linux

@spevans
Copy link
Collaborator Author

spevans commented Nov 10, 2018

@swift-ci test linux

@spevans
Copy link
Collaborator Author

spevans commented Nov 10, 2018

@swift-ci test linux

@spevans
Copy link
Collaborator Author

spevans commented Nov 12, 2018

@swift-ci test linux

@spevans
Copy link
Collaborator Author

spevans commented Nov 13, 2018

@swift-ci test linux

@spevans
Copy link
Collaborator Author

spevans commented Nov 13, 2018

@swift-ci test linux

- Use Swift's stringification of numbers for .description and .stringValue

- Use String(format:locale:...) with the correct format for the
  NSNumber type if locale is not nil.

- Enable use of __CFStringFormatLocalizedNumber() on
  DEPLOYMENT_TARGET_LINUX.
@spevans
Copy link
Collaborator Author

spevans commented Nov 13, 2018

@swift-ci test

1 similar comment
@spevans
Copy link
Collaborator Author

spevans commented Nov 13, 2018

@swift-ci test

@spevans
Copy link
Collaborator Author

spevans commented Nov 30, 2018

@millenomi I think all your comments have been addressed now, do you see any other issues?

@millenomi
Copy link
Contributor

@swift-ci please test and merge

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.

None yet

5 participants