Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
* upstream/develop: (41 commits)
  Version update
  Minor changes
  Added other members to enums
  Added other members to enum body
  Added extra tests for missing properties and functions
  Moved code into utils and added extra inheritance tokens
  Changed enum code to allow simple value types, and a rawValue constructor
  angelolloqui#68 Fixed list/map initialization
  Updated contributions
  angelolloqui#91 Fixed force cast conversion
  PR changes
  added  Assets/Tests/KotlinTokenizer/overrideargs.swift
  added funtion and code to remove default arguments from override function in class. With tests.
  add colors to token for dark mode cases
  Updated travis file and cleanup
  Updated readme file
  Removed autogenerated project file
  Removed local references
  Version update
  Updated swift transform to v0.18.10
  ...

# Conflicts:
#	Sources/SwiftKotlinApp/ViewController.swift
#	Sources/SwiftKotlinCommandLine/main.swift
#	Sources/SwiftKotlinFramework/KotlinTokenizer.swift
#	SwiftKotlin.xcodeproj/project.pbxproj
  • Loading branch information
TamirTwina committed Aug 10, 2019
2 parents 92f5f43 + e993ad5 commit c36a3ea
Show file tree
Hide file tree
Showing 84 changed files with 1,603 additions and 863 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ SwiftKotlin.xcodeproj/project.xcworkspace/xcshareddata/
*.xcscmblueprint
test.swiftdoc
test.swiftmodule

## Generated project file
SwiftKotlinFramework.xcodeproj
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: objective-c
osx_image: xcode9
osx_image: xcode10
install:
- swift package resolve
- swift package update
- swift package generate-xcodeproj --enable-code-coverage
script:
- xcodebuild test -scheme SwiftKotlin-Package
- xcodebuild test -workspace SwiftKotlin.xcworkspace -scheme SwiftKotlinFramework-Package
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,42 @@ public sealed class SDKException : Error {
object unauthorized : SDKException()
data class network(val v1: HttpResponse, val v2: Error?) : SDKException()
}
public enum class PaymentMethodType (val rawValue: String) : Equatable {
direct("DIRECT"), creditCard("CREDIT_CARD");

companion object {
operator fun invoke(rawValue: String) = PaymentMethodType.values().firstOrNull { it.rawValue == rawValue }
}
}
enum class AnimationLength {
shot,
long

val duration: Double
get() {
when (this) {
.shot -> return 2
.long -> return 5.0
}
}

fun getDuration() : Double =
this.duration
}
sealed class AnimationLengthAdvanced {
object shot : AnimationLengthAdvanced()
object long : AnimationLengthAdvanced()
data class custom(val v1: Double) : AnimationLengthAdvanced()

val duration: Double
get() {
when (this) {
.shot -> return 2
.long -> return 5.0
.custom -> return duration
}
}

fun getDuration() : Double =
this.duration
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,45 @@ public enum SDKException: Error {
case unauthorized
case network(HttpResponse, Error?)
}

public enum PaymentMethodType: String, Equatable {
case direct = "DIRECT", creditCard = "CREDIT_CARD"
}

enum AnimationLength {
case shot
case long
var duration: Double {
switch self {
case .shot:
return 2
case .long:
return 5.0
}
}

func getDuration() -> Double {
return self.duration
}
}

enum AnimationLengthAdvanced {
case shot
case long
case custom(Double)

var duration: Double {
switch self {
case .shot:
return 2
case .long:
return 5.0
case .custom(let duration):
return duration
}
}

func getDuration() -> Double {
return self.duration
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ val text = label ?: "default"
service.deleteObject()
this.service.fetchData()?.user?.name?.size
this.data.filter { it.item?.value == 1 }.map { it.key }.firstOrNull()?.name?.size
this.object = data as ObjectType
this.object = data as? ObjectType
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ _ = service.deleteObject()
// Optional chaning
self.service.fetchData()?.user.name?.count
self.data.filter { $0.item?.value == 1 }.map { $0.key }.first?.name.count

// Type casting
self.object = data as! ObjectType
self.object = data as? ObjectType
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ var any: Any? = null
var array: List<String>? = null
var array: Promise<List<String>>? = null
var array: List<Promise<List<String>>>
var array = listOf("1", "2")
var strings1 = listOf<String>()
var strings2 = listOf("value1", "value2")
var strings3: List<Any> = listOf("value3", "value4")
var map: Map<Int, String>? = null
var map: Promise<Map<Int, String>>? = null
var map: Map<Int, Promise<Map<String, String>>>
var map = mapOf(1 to "a", 2 to "b")
var map = mapOf<String , String>()
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ var any: Any? = nil
var array: [String]?
var array: Promise<[String]>?
var array: [Promise<[String]>]
var array = ["1", "2"]
var strings1 = [String]()
var strings2 = ["value1", "value2"]
var strings3: [Any] = ["value3", "value4"]
var map: [Int: String]?
var map: Promise<[Int: String]>?
var map: [Int: Promise<[String: String]>]
var map = [1: "a", 2: "b"]
var map = [String: String]()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions Assets/Tests/KotlinTokenizer/overrideargs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

class Test {

override fun dostuff(x: Int) {}

fun otherMethod(x: Int = 5) {}
}
8 changes: 8 additions & 0 deletions Assets/Tests/KotlinTokenizer/overrideargs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test {
override func dostuff(x: Int = 5) {
}

func otherMethod(x: Int = 5) {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class A {
}
lateinit var subject: TestSubject
val players: List<String> by lazy {
var temporaryPlayers = listOf(String)()
var temporaryPlayers = listOf<String>()
temporaryPlayers.append("John Doe")
temporaryPlayers
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions Assets/Tests/plugins/CommentsAdditionTransformPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Header comments
// Multiple lines together
//
// Created by Angel Garcia on 14/10/2017.
//
class MyClass {
//Public properties
var a: Int? = null
var b: String? = null

//Public method
fun aMethod() {
// A comment inside aMethod
b = "method run"
b = b + "more"
}

/*
Multiline comments
are also supported
*/
fun anotherMethod() {
val a = this.a
if (a != null) {
// Inside if
this.a = a + 1
} else {
// Inside else
this.a = 1
}
}
}

// Other comments before structs
data class MyStruct {}

38 changes: 38 additions & 0 deletions Assets/Tests/plugins/CommentsAdditionTransformPlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Header comments
// Multiple lines together
//
// Created by Angel Garcia on 14/10/2017.
//

class MyClass {

//Public properties
var a: Int?
var b: String?

//Public method
func aMethod() {
// A comment inside aMethod
b = "method run"
b = b + "more"
}

/*
Multiline comments
are also supported
*/
func anotherMethod() {
if let a = self.a {
// Inside if
self.a = a + 1
} else {
// Inside else
self.a = 1
}
}
}

// Other comments before structs
struct MyStruct {}

10 changes: 10 additions & 0 deletions Dummy/AST.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// AST.swift
// Dummy
//
// Created by Tomohiro Matsuzawa on 9/14/18.
//

import Foundation

// AST.framework build fails because it doesn't import Foundation, so import it here
10 changes: 10 additions & 0 deletions Dummy/Sema.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Sema.swift
// Dummy
//
// Created by Tomohiro Matsuzawa on 9/14/18.
//

import Foundation

// Sema.framework build fails because it doesn't import Foundation, so import it here
14 changes: 7 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
"repositoryURL": "https://github.com/yanagiba/bocho",
"state": {
"branch": null,
"revision": "411fb57fe99824ebe8f107c69cf61fc8bc68853d",
"version": "0.1.1"
"revision": "11a60ae8509658ea38bbe166d9c4e9af4d411700",
"version": "0.18.10"
}
},
{
"package": "swift-ast",
"repositoryURL": "https://github.com/yanagiba/swift-ast",
"state": {
"branch": null,
"revision": "e9657500e90aebc5220401d222a4664f6241f3d7",
"version": null
"revision": "295998ce223da98cab6b7189db22f0be3dfc0eb7",
"version": "0.18.10"
}
},
{
"package": "swift-transform",
"repositoryURL": "https://github.com/angelolloqui/swift-transform",
"repositoryURL": "https://github.com/yanagiba/swift-transform",
"state": {
"branch": null,
"revision": "3fc221cc73d30034bf1d32a21a42ba1474f21abf",
"version": null
"revision": "45464c7747d97f320ca153b713affede11ce3bf4",
"version": "0.18.10"
}
}
]
Expand Down
Loading

0 comments on commit c36a3ea

Please sign in to comment.