Skip to content

Commit

Permalink
Update Scala Native to 0.5.1 (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski authored Apr 24, 2024
1 parent 8e1f5f9 commit ec4f331
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ val commonSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq(
)

val commonJvmSettings = commonSettings ++ Seq(
scalacOptions ++= Seq("-target:jvm-1.8"),
ideSkipProject := (scalaVersion.value != scala2_13),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % scalaTestVersion % Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package sttp.model.internal.idn

import scala.scalanative.libc.stdlib.{malloc, free}
import scala.scalanative.unsafe.{CString, Ptr, Zone, fromCString, sizeof, toCString}

private[model] object IdnApi {
def toAscii(input: String): String =
Zone { implicit z =>
val output: Ptr[CString] = malloc(sizeof[CString]).asInstanceOf[Ptr[CString]]
val rc = CIdn.toAscii(toCString(input), output, 0)
if (rc != 0) {
val errMsg = CIdn.errorMsg(rc)
throw new RuntimeException(fromCString(errMsg))
} else {
val out = fromCString(!output)
CIdn.free(!output)
free(output.asInstanceOf[Ptr[Byte]])
out
}
}
}
21 changes: 21 additions & 0 deletions core/src/main/scalanative-3/sttp/model/internal/idn/IdnApi.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package sttp.model.internal.idn

import scala.scalanative.libc.stdlib.{malloc, free}
import scala.scalanative.unsafe.{CString, Ptr, Zone, fromCString, sizeof, toCString}

private[model] object IdnApi {
def toAscii(input: String): String =
Zone {
val output: Ptr[CString] = malloc(sizeof[CString]).asInstanceOf[Ptr[CString]]
val rc = CIdn.toAscii(toCString(input), output, 0)
if (rc != 0) {
val errMsg = CIdn.errorMsg(rc)
throw new RuntimeException(fromCString(errMsg))
} else {
val out = fromCString(!output)
CIdn.free(!output)
free(output.asInstanceOf[Ptr[Byte]])
out
}
}
}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.0")

val sbtSoftwareMillVersion = "2.0.20"
Expand Down

0 comments on commit ec4f331

Please sign in to comment.