-
Notifications
You must be signed in to change notification settings - Fork 9
Add StaticString implementation
#31
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
Sources/Core/UInt8.swift
Outdated
| } | ||
|
|
||
| @_transparent | ||
| public static func &= (lhs: inout UInt8, rhs: UInt8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These operators are required for StaticString flag checks. I'll move them to a corresponding numeric protocol conformance in a future PR.
|
Build failure due to
I wonder if there's some way to specialize |
|
Tried to monomorphize that call to |
|
Ok, I removed |
|
I tend to prefer that the changes are focused rather than a grab bag of changes. That makes it too difficult to focus on one thing. Please split this up accordingly. Additionally, I'm not sure I want to add CMake toolchain configurations, especially the way that you have setup the cache file. It encodes much about the build environment. For example, I wish to build on Windows with MSVC 2022 to target ARM but that cache file doesn't work :) (or perhaps I want to build on exherbo Linux). |
Sure, I can move out the What about new metadata requirements, would you like |
|
I think that we can split out the pointer changes, assertion changes, and static string changes. As to the build failures, I don't think its the end of the world if we cannot support 5.4, but it would be nice to retain support for 5.5 - stable, development would be nice. If we cannot manage to do that, I'd be willing to settle for 5.6 + main. |
Sources/Core/CompilerProtocols.swift
Outdated
| } | ||
|
|
||
| public protocol _ExpressibleByBuiltinStringLiteral { | ||
| init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't break immediately after the (, prefer to bin-pack the arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What column limit would you like to set? Would something like 100 or 120 work?
Sources/Core/StaticString.swift
Outdated
| ) { | ||
| _startPtrOrData = Builtin.ptrtoint_Word(_start) | ||
| _utf8CodeUnitCount = utf8CodeUnitCount | ||
| _flags = Bool(isASCII) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This took me a second to understand. Can you add a comment to the _flags ivar to indicate what the bit flags are and what is reserved?
Sources/Core/StaticString.swift
Outdated
|
|
||
| @_transparent | ||
| public var isASCII: Bool { | ||
| (UInt8(_flags) & 0x2) != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use explicit returns.
StaticString and required pointer typesStaticString implementation
| @usableFromInline | ||
| internal var _utf8CodeUnitCount: Builtin.Word | ||
|
|
||
| /// Flags indicating how `StaticString` storage is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having additional documentation of reserved and in use fields would be desirable.
Sources/Core/StaticString.swift
Outdated
| extension StaticString: _ExpressibleByBuiltinStringLiteral { | ||
| @_effects(readonly) | ||
| @_transparent | ||
| public init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont break after (
compnerd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please stick to 80-column and bin-packing arguments (and not breaking after ().
This implementation excludes a few properties that rely on
precondition, which will be submitted as a separate PR.