icerockdev / moko-kswift

Swift-friendly api generator for Kotlin/Native frameworks
https://moko.icerock.dev
Apache License 2.0
351 stars 21 forks source link

Generate Swift enum class for Kotlin enum class #7

Open Alex009 opened 3 years ago

Alex009 commented 3 years ago

to support exhaustive whens/switches for Kotlin enums (either via a generated extension with blocks for every case, or maybe something like this)

cl3m commented 2 years ago

I've made a generator to avoid default on enum. You can check it here. It produce extension like below

public extension shared.SpaceState.Status {
  var `enum`: SpaceState.Status.Enum {
    if self == shared.SpaceState.Status.idle {
      return .idle
    } else if self == shared.SpaceState.Status.pending {
      return .pending
    } else {
      fatalError("SpaceState.Status not synchronized")
    }
  }
  enum Enum {

    case idle
    case pending

  }
}

Is it what you had in mind ? Do you want a PR ?

Alex009 commented 2 years ago

yes, it is. please create PR 👍

ivan-magda commented 1 year ago

@cl3m please submit a PR 👍