Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Improve templates for the Swift standard library #35

Open
vinivendra opened this issue May 20, 2020 · 5 comments
Open

Improve templates for the Swift standard library #35

vinivendra opened this issue May 20, 2020 · 5 comments
Labels
gryphon library Affects the Gryphon Swift or Kotlin libraries

Comments

@vinivendra
Copy link
Owner

The templates file currently covers a few parts of the Swift standard library, mainly Strings and Arrays. This issue will be used to keep track of expanding the standard library support to other types and methods.

@vinivendra vinivendra added the gryphon library Affects the Gryphon Swift or Kotlin libraries label May 20, 2020
@sgade
Copy link
Contributor

sgade commented Jul 7, 2020

Do you have a list of types you'd like to be covered? Otherwise, there could be multiple PRs, each covering one to a few classes at a time.

@vinivendra
Copy link
Owner Author

Yeah, multiple PRs would definitely be best.

I don't have a list yet. I thought about maybe using something like the documentation to create a list, at least so we can be sure we considered everything (even though we won't be able to translate everything).

@sgade
Copy link
Contributor

sgade commented Jul 7, 2020

Alright, when I find the time I'll go over it and look at possible classes and methods that need translating.
Might be only in a couple of weeks, though.

@sgade
Copy link
Contributor

sgade commented Sep 20, 2020

So I dug through the documentation link you provided and came up with a list of types and functions that should be looked at in how they are translated. Most are covered already.

I will dump this list here as you are currently working on the SourceKit AST version of gryphon if I am not mistaken.
Once that is done, we could look at how the following types are translated and if any need special templates.

What do you think?

Bool
Int
Double
Float
Range
ClosedRange
Error
Result
Optional
String
Character
Unicode
StaticString
Array
Dictionary
Set
OptionSet
Equatable
Comparable
Identifiable
Hashable
Hasher
CustomStringConvertible
LosslessStringConvertible
CustomDebugStringConvertible
CaseIterable
RawRepresentable
Encodable
Decodable
CodingKey
CodingUserInfoKey
Encoder
Decoder
ExpressibleByArrayLiteral
ExpressibleByDictionaryLiteral
ExpressibleByIntegerLiteral
ExpressibleByFloatLiteral
ExpressibleByBooleanLiteral
ExpressibleByNilLiteral
ExpressibleByStringLiteral
ExpressibleByExtendedGraphemeClusterLiteral
ExpressibleByUnicodeScalarLiteral
ExpressibleByStringInterpolation
CommandLine
TextOutputStream
TextOutputStreamable
CustomReflectable
CustomLeafReflectable
CustomPlaygroundDisplayConvertible
KeyPath
PartialKeyPath
AnyKeyPath
WritableKeyPath
ReferenceWritableKeyPath
func print(Any, separator: String, terminator: String)
func print<Target>(Any, separator: String, terminator: String, to: inout Target)
func readLine(strippingNewLine: Bool) -> String?
func debugPrint(Any, separator: String, terminator: String)
func debugPrint<Target>(Any, separator: String, terminator: String, to: inout Target)
func dump<T>(_ value: T, name: String? = nil, indent: Int = 0, maxDepth: Int = .max, maxItems: Int = .max) -> T
func dump<T, TargetStream>(_ value: T, to target: inout TargetStream, name: String? = nil, indent: Int = 0, maxDepth: Int = .max, maxItems: Int = .max) -> T where TargetStream : TextOutputStream
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)
func assertionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)
func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)
func preconditionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) -> Never
func fatalError(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) -> Never
´´´

@vinivendra
Copy link
Owner Author

Looks great!

Yeah, I'm working on SourceKit right now, but this could be done in parallel if you want to.

Based on your list, I created a new Status.md file we can use to track development. I'm not sure I like how it turned out though, so suggestions for improving it are welcome.

If you want to begin implementing the new templates, I'd probably start with the easier "concrete" types (Bools, Ints, basically anything that isn't a protocol) and do something like this:

  • Create the template in a test file so you can tinker and make sure it works OK.
  • Add your template to the gryphonTemplatesLibraryFileContents string (around here)
  • Add some tests in Test cases/standardLibrary.swift (also Test cases/standardLibrary.kt and Test cases/standardLibrary.output).

In any case, let me know if you need help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
gryphon library Affects the Gryphon Swift or Kotlin libraries
Projects
None yet
Development

No branches or pull requests

2 participants