Skip to content

jextract: support Swift custom operators#829

Draft
AbdAlRahmanGad wants to merge 3 commits into
swiftlang:mainfrom
AbdAlRahmanGad:operators
Draft

jextract: support Swift custom operators#829
AbdAlRahmanGad wants to merge 3 commits into
swiftlang:mainfrom
AbdAlRahmanGad:operators

Conversation

@AbdAlRahmanGad

Copy link
Copy Markdown
Member

Comment thread Sources/SwiftExtract/SwiftAnalysisVisitor.swift
return index == 0 ? name : name.firstCharacterUppercased
}
.joined()
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be great to have a test for this, because e.g. we could have an operator ++++ which we'd like to then turn into plusPlusPlusPlus perhaps, so this is a "consume one operator, get the name, continue" operation.

Picking the known ones is good! but notice that knownOperatorNames[String(character)] wouldn't work for "==": "isEqual", or other known ones that have more characters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, I didn’t know custom operators could have more than three characters, like ===========.

Thanks for noticing!

}
private var deferredConstrainedExtensions: [DeferredConstrainedExtension] = []

private static func isOperatorFunction(_ node: FunctionDeclSyntax) -> Bool {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This may be worth changing into operatorKind: SwiftOperatorKind?`

and make a new SwiftOperatorKind that is enum SwiftOperatorKind { case prefixOperator; case binaryOperator; case postfixOperator }

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