From 93c41c8936099302458428802b4b6d173870bc76 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Fri, 9 Feb 2024 22:17:49 +0800 Subject: [PATCH 1/5] . --- .mill-version | 2 +- build.sc | 17 +++++--- ujson/src/ujson/package.scala | 80 +++++------------------------------ upickle/src/upickle/Api.scala | 70 +++++------------------------- 4 files changed, 33 insertions(+), 136 deletions(-) diff --git a/.mill-version b/.mill-version index ecd2d5d92..cb9119316 100644 --- a/.mill-version +++ b/.mill-version @@ -1,2 +1,2 @@ -0.11.6 +0.11.7 diff --git a/build.sc b/build.sc index 15f79569e..858cee7f5 100644 --- a/build.sc +++ b/build.sc @@ -15,18 +15,18 @@ import de.tobiasroeser.mill.vcs.version.VcsVersion import com.github.lolgab.mill.mima._ val scala212 = "2.12.18" -val scala213 = "2.13.11" +val scala213 = "2.13.12" val scala3 = "3.3.0" val scalaNative = "0.4.14" -val acyclic = "0.3.8" +val acyclic = "0.3.9" val sourcecode = "0.3.0" val dottyCustomVersion = Option(sys.props("dottyVersion")) val scala2JVMVersions = Seq(scala212, scala213) -val scalaVersions = scala2JVMVersions// ++ Seq(scala3) ++ dottyCustomVersion +val scalaVersions = scala2JVMVersions ++ Seq(scala3) ++ dottyCustomVersion trait CommonPlatformModule extends ScalaModule with PlatformScalaModule{ @@ -58,6 +58,10 @@ trait CommonPublishModule ) ) + def scalacPluginIvyDeps = + super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.3") + + def publishProperties: Target[Map[String, String]] = super.publishProperties() ++ Map( "info.releaseNotesURL" -> "https://com-lihaoyi.github.io/upickle/#VersionHistory" ) @@ -84,7 +88,7 @@ trait CommonPublishModule } def scalacOptions = T { - Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature", "-Xfatal-warnings") ++ + Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature", "-Xfatal-warnings", "-Xplugin-require:unroll") ++ Agg.when(!isScala3(scalaVersion()))("-opt:l:method").toSeq } @@ -219,7 +223,10 @@ object ujson extends Module{ object upickle extends Module{ object core extends Module { trait CommonCoreModule extends CommonPublishModule { - def ivyDeps = Agg(ivy"com.lihaoyi::geny::1.0.0") + def ivyDeps = Agg( + ivy"com.lihaoyi::geny::1.0.0", + ivy"com.lihaoyi::unroll-annotation:0.1.3" + ) } object js extends Cross[CoreJsModule](scalaVersions) diff --git a/ujson/src/ujson/package.scala b/ujson/src/ujson/package.scala index cf1972ac0..19f44aa80 100644 --- a/ujson/src/ujson/package.scala +++ b/ujson/src/ujson/package.scala @@ -1,16 +1,13 @@ import upickle.core.NoOpVisitor import upickle.core.BufferedValue - +import unroll.Unroll package object ujson{ def transform[T](t: Readable, v: upickle.core.Visitor[_, T], - sortKeys: Boolean = false): T = { + @Unroll sortKeys: Boolean = false): T = { BufferedValue.maybeSortKeysTransform(Readable, t, sortKeys, v) } -// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def transform[T](t: Readable, - v: upickle.core.Visitor[_, T]): T = transform(t, v, sortKeys = false) /** * Read the given JSON input as a JSON struct */ @@ -25,19 +22,12 @@ package object ujson{ def write(t: Value.Value, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): String = { + @Unroll sortKeys: Boolean = false): String = { val writer = new java.io.StringWriter writeTo(t, writer, indent, escapeUnicode, sortKeys) writer.toString } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def write(t: Value.Value, - indent: Int, - escapeUnicode: Boolean): String = { - write(t, indent, escapeUnicode, sortKeys = false) - } - /** * Write the given JSON struct as a JSON String to the given Writer */ @@ -45,50 +35,27 @@ package object ujson{ out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { transform(t, Renderer(out, indent, escapeUnicode), sortKeys) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeTo(t: Value.Value, - out: java.io.Writer, - indent: Int, - escapeUnicode: Boolean): Unit = { - writeTo(t, out, indent, escapeUnicode, sortKeys = false) - } - def writeToOutputStream(t: Value.Value, out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { transform(t, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeToOutputStream(t: Value.Value, - out: java.io.OutputStream, - indent: Int, - escapeUnicode: Boolean): Unit = { - writeToOutputStream(t, out, indent, escapeUnicode, sortKeys = false) - } - def writeToByteArray(t: Value.Value, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Array[Byte] = { + @Unroll sortKeys: Boolean = false): Array[Byte] = { val baos = new java.io.ByteArrayOutputStream writeToOutputStream(t, baos, indent, escapeUnicode, sortKeys) baos.toByteArray } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeToByteArray(t: Value.Value, - indent: Int, - escapeUnicode: Boolean): Array[Byte] = { - writeToByteArray(t, indent, escapeUnicode, sortKeys = false) - } - /** * Parse the given JSON input, failing if it is invalid */ @@ -100,18 +67,12 @@ package object ujson{ def reformat(s: Readable, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): String = { + @Unroll sortKeys: Boolean = false): String = { val writer = new java.io.StringWriter() reformatTo(s, writer, indent, escapeUnicode, sortKeys) writer.toString } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def reformat(s: Readable, - indent: Int, - escapeUnicode: Boolean): String = { - reformat(s, indent, escapeUnicode, sortKeys = false) - } /** * Parse the given JSON input and write it to a string with * the configured formatting to the given Writer @@ -120,17 +81,10 @@ package object ujson{ out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { transform(s, Renderer(out, indent, escapeUnicode), sortKeys) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def reformatTo(s: Readable, - out: java.io.Writer, - indent: Int, - escapeUnicode: Boolean): Unit = { - reformatTo(s, out, indent, escapeUnicode, sortKeys = false) - } /** * Parse the given JSON input and write it to a string with * the configured formatting to the given Writer @@ -139,33 +93,19 @@ package object ujson{ out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { transform(s, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def reformatToOutputStream(s: Readable, - out: java.io.OutputStream, - indent: Int, - escapeUnicode: Boolean): Unit = { - reformatToOutputStream(s, out, indent, escapeUnicode, sortKeys = false) - } - def reformatToByteArray(s: Readable, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Array[Byte] = { + @Unroll sortKeys: Boolean = false): Array[Byte] = { val baos = new java.io.ByteArrayOutputStream reformatToOutputStream(s, baos, indent, escapeUnicode, sortKeys) baos.toByteArray } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def reformatToByteArray(s: Readable, - indent: Int, - escapeUnicode: Boolean): Array[Byte] = { - reformatToByteArray(s, indent, escapeUnicode, sortKeys = false) - } // End ujson @deprecated("use ujson.Value") type Js = Value diff --git a/upickle/src/upickle/Api.scala b/upickle/src/upickle/Api.scala index 98773c643..88a5f9e2a 100644 --- a/upickle/src/upickle/Api.scala +++ b/upickle/src/upickle/Api.scala @@ -6,6 +6,7 @@ import language.experimental.macros import language.higherKinds import upickle.core._ import scala.reflect.ClassTag +import unroll.Unroll /** * An instance of the upickle API. There's a default instance at @@ -50,28 +51,18 @@ trait Api def write[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): String = { + @Unroll sortKeys: Boolean = false): String = { maybeSortKeysTransform(t, sortKeys, ujson.StringRenderer(indent, escapeUnicode)).toString } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def write[T: Writer](t: T, - indent: Int, - escapeUnicode: Boolean): String = { - write(t, indent, escapeUnicode, sortKeys = false) - } - /** * Write the given Scala value as a MessagePack binary */ def writeBinary[T: Writer](t: T, - sortKeys: Boolean = false): Array[Byte] = { + @Unroll sortKeys: Boolean = false): Array[Byte] = { maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(new ByteArrayOutputStream())).toByteArray } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeBinary[T: Writer](t: T): Array[Byte] = writeBinary(t, sortKeys = false) - /** * Write the given Scala value as a JSON struct */ @@ -89,105 +80,64 @@ trait Api out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { maybeSortKeysTransform(t, sortKeys, new ujson.Renderer(out, indent = indent, escapeUnicode)) } - - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeTo[T: Writer](t: T, - out: java.io.Writer, - indent: Int, - escapeUnicode: Boolean): Unit = writeTo(t, out, indent, escapeUnicode, sortKeys = false) - def writeToOutputStream[T: Writer](t: T, out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { maybeSortKeysTransform(t, sortKeys, new ujson.BaseByteRenderer(out, indent = indent, escapeUnicode)) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeToOutputStream[T: Writer](t: T, - out: java.io.OutputStream, - indent: Int, - escapeUnicode: Boolean): Unit = { - writeToOutputStream(t, out, indent, escapeUnicode, sortKeys = false) - } - def writeToByteArray[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): Array[Byte] = { + @Unroll sortKeys: Boolean = false): Array[Byte] = { val out = new java.io.ByteArrayOutputStream() writeToOutputStream(t, out, indent, escapeUnicode, sortKeys) out.toByteArray } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeToByteArray[T: Writer](t: T, - indent: Int, - escapeUnicode: Boolean): Array[Byte] = { - writeToByteArray[T](t, indent, escapeUnicode, sortKeys = false) - } /** * Write the given Scala value as a JSON string via a `geny.Writable` */ def stream[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - sortKeys: Boolean = false): geny.Writable = new geny.Writable{ + @Unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ override def httpContentType = Some("application/json") def writeBytesTo(out: java.io.OutputStream) = { maybeSortKeysTransform(t, sortKeys, new ujson.BaseByteRenderer(out, indent = indent, escapeUnicode)) } } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def stream[T: Writer](t: T, - indent: Int, - escapeUnicode: Boolean): geny.Writable = { - stream(t, indent, escapeUnicode, sortKeys = false) - } /** * Write the given Scala value as a MessagePack binary to the given OutputStream */ def writeBinaryTo[T: Writer](t: T, out: java.io.OutputStream, - sortKeys: Boolean = false): Unit = { + @Unroll sortKeys: Boolean = false): Unit = { streamBinary[T](t, sortKeys = sortKeys).writeBytesTo(out) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeBinaryTo[T: Writer](t: T, - out: java.io.OutputStream): Unit = { - writeBinaryTo(t, out, sortKeys = false) - } - def writeBinaryToByteArray[T: Writer](t: T, - sortKeys: Boolean = false): Array[Byte] = { + @Unroll sortKeys: Boolean = false): Array[Byte] = { val out = new java.io.ByteArrayOutputStream() streamBinary[T](t, sortKeys = sortKeys).writeBytesTo(out) out.toByteArray } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def writeBinaryToByteArray[T: Writer](t: T): Array[Byte] = { - writeBinaryToByteArray(t, sortKeys = false) - } /** * Write the given Scala value as a MessagePack binary via a `geny.Writable` */ - def streamBinary[T: Writer](t: T, sortKeys: Boolean = false): geny.Writable = new geny.Writable{ + def streamBinary[T: Writer](t: T, @Unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ override def httpContentType = Some("application/octet-stream") def writeBytesTo(out: java.io.OutputStream) = maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(out)) } - // @deprecated("Binary Compatibility Stub", "upickle after 3.1.4") - def streamBinary[T: Writer](t: T): geny.Writable = { - streamBinary(t, sortKeys = false) - } def writer[T: Writer] = implicitly[Writer[T]] From 7958b0c2a4a0198d11bb0c500d57f3c091e311ff Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 10 Feb 2024 09:46:45 +0800 Subject: [PATCH 2/5] 0.1.7 --- build.sc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sc b/build.sc index 858cee7f5..6eef2de0e 100644 --- a/build.sc +++ b/build.sc @@ -59,7 +59,7 @@ trait CommonPublishModule ) def scalacPluginIvyDeps = - super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.3") + super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.7") def publishProperties: Target[Map[String, String]] = super.publishProperties() ++ Map( @@ -88,7 +88,7 @@ trait CommonPublishModule } def scalacOptions = T { - Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature", "-Xfatal-warnings", "-Xplugin-require:unroll") ++ + Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature", "-Xfatal-warnings") ++ Agg.when(!isScala3(scalaVersion()))("-opt:l:method").toSeq } @@ -225,7 +225,7 @@ object upickle extends Module{ trait CommonCoreModule extends CommonPublishModule { def ivyDeps = Agg( ivy"com.lihaoyi::geny::1.0.0", - ivy"com.lihaoyi::unroll-annotation:0.1.3" + ivy"com.lihaoyi::unroll-annotation:0.1.7" ) } From 54e3c3d053a144a3aff073722f2a7f17b58c6225 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 10 Feb 2024 19:56:51 +0800 Subject: [PATCH 3/5] . --- build.sc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sc b/build.sc index 6eef2de0e..21270e8c1 100644 --- a/build.sc +++ b/build.sc @@ -17,7 +17,7 @@ import com.github.lolgab.mill.mima._ val scala212 = "2.12.18" val scala213 = "2.13.12" -val scala3 = "3.3.0" +val scala3 = "3.3.1" val scalaNative = "0.4.14" val acyclic = "0.3.9" @@ -59,7 +59,7 @@ trait CommonPublishModule ) def scalacPluginIvyDeps = - super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.7") + super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.9") def publishProperties: Target[Map[String, String]] = super.publishProperties() ++ Map( @@ -225,7 +225,7 @@ object upickle extends Module{ trait CommonCoreModule extends CommonPublishModule { def ivyDeps = Agg( ivy"com.lihaoyi::geny::1.0.0", - ivy"com.lihaoyi::unroll-annotation:0.1.7" + ivy"com.lihaoyi::unroll-annotation:0.1.9" ) } From eb6c30d9013a98cfa533ce5bacb5f9d5490b57b6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 10 Feb 2024 21:13:40 +0800 Subject: [PATCH 4/5] . --- build.sc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sc b/build.sc index 21270e8c1..184697b33 100644 --- a/build.sc +++ b/build.sc @@ -59,7 +59,7 @@ trait CommonPublishModule ) def scalacPluginIvyDeps = - super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.9") + super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.10") def publishProperties: Target[Map[String, String]] = super.publishProperties() ++ Map( @@ -225,7 +225,7 @@ object upickle extends Module{ trait CommonCoreModule extends CommonPublishModule { def ivyDeps = Agg( ivy"com.lihaoyi::geny::1.0.0", - ivy"com.lihaoyi::unroll-annotation:0.1.9" + ivy"com.lihaoyi::unroll-annotation:0.1.10" ) } @@ -386,7 +386,7 @@ trait BenchModule extends CommonPlatformModule{ object bench extends Module { object js extends BenchModule with ScalaJSModule { - def scalaJSVersion = "1.13.0" + def scalaJSVersion = "1.13.1" def moduleDeps = Seq(upickle.js(scala213).test) } From d72902ef0807cdc218ff9fe3716f3698cd527f64 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 21 Mar 2024 13:34:11 +0800 Subject: [PATCH 5/5] unroll-0.1.12 --- build.sc | 4 ++-- ujson/src/ujson/package.scala | 20 ++++++++++---------- upickle/src/upickle/Api.scala | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build.sc b/build.sc index 184697b33..557a165b0 100644 --- a/build.sc +++ b/build.sc @@ -59,7 +59,7 @@ trait CommonPublishModule ) def scalacPluginIvyDeps = - super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.10") + super.scalacPluginIvyDeps() ++ Agg(ivy"com.lihaoyi::unroll-plugin:0.1.12") def publishProperties: Target[Map[String, String]] = super.publishProperties() ++ Map( @@ -225,7 +225,7 @@ object upickle extends Module{ trait CommonCoreModule extends CommonPublishModule { def ivyDeps = Agg( ivy"com.lihaoyi::geny::1.0.0", - ivy"com.lihaoyi::unroll-annotation:0.1.10" + ivy"com.lihaoyi::unroll-annotation:0.1.12" ) } diff --git a/ujson/src/ujson/package.scala b/ujson/src/ujson/package.scala index 19f44aa80..4cb9c6468 100644 --- a/ujson/src/ujson/package.scala +++ b/ujson/src/ujson/package.scala @@ -1,10 +1,10 @@ import upickle.core.NoOpVisitor import upickle.core.BufferedValue -import unroll.Unroll +import scala.annotation.unroll package object ujson{ def transform[T](t: Readable, v: upickle.core.Visitor[_, T], - @Unroll sortKeys: Boolean = false): T = { + @unroll sortKeys: Boolean = false): T = { BufferedValue.maybeSortKeysTransform(Readable, t, sortKeys, v) } @@ -22,7 +22,7 @@ package object ujson{ def write(t: Value.Value, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): String = { + @unroll sortKeys: Boolean = false): String = { val writer = new java.io.StringWriter writeTo(t, writer, indent, escapeUnicode, sortKeys) writer.toString @@ -35,7 +35,7 @@ package object ujson{ out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { transform(t, Renderer(out, indent, escapeUnicode), sortKeys) } @@ -43,14 +43,14 @@ package object ujson{ out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { transform(t, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys) } def writeToByteArray(t: Value.Value, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Array[Byte] = { + @unroll sortKeys: Boolean = false): Array[Byte] = { val baos = new java.io.ByteArrayOutputStream writeToOutputStream(t, baos, indent, escapeUnicode, sortKeys) baos.toByteArray @@ -67,7 +67,7 @@ package object ujson{ def reformat(s: Readable, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): String = { + @unroll sortKeys: Boolean = false): String = { val writer = new java.io.StringWriter() reformatTo(s, writer, indent, escapeUnicode, sortKeys) writer.toString @@ -81,7 +81,7 @@ package object ujson{ out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { transform(s, Renderer(out, indent, escapeUnicode), sortKeys) } @@ -93,14 +93,14 @@ package object ujson{ out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { transform(s, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys) } def reformatToByteArray(s: Readable, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Array[Byte] = { + @unroll sortKeys: Boolean = false): Array[Byte] = { val baos = new java.io.ByteArrayOutputStream reformatToOutputStream(s, baos, indent, escapeUnicode, sortKeys) baos.toByteArray diff --git a/upickle/src/upickle/Api.scala b/upickle/src/upickle/Api.scala index 88a5f9e2a..f634d32e1 100644 --- a/upickle/src/upickle/Api.scala +++ b/upickle/src/upickle/Api.scala @@ -6,7 +6,7 @@ import language.experimental.macros import language.higherKinds import upickle.core._ import scala.reflect.ClassTag -import unroll.Unroll +import scala.annotation.unroll /** * An instance of the upickle API. There's a default instance at @@ -51,7 +51,7 @@ trait Api def write[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): String = { + @unroll sortKeys: Boolean = false): String = { maybeSortKeysTransform(t, sortKeys, ujson.StringRenderer(indent, escapeUnicode)).toString } @@ -59,7 +59,7 @@ trait Api * Write the given Scala value as a MessagePack binary */ def writeBinary[T: Writer](t: T, - @Unroll sortKeys: Boolean = false): Array[Byte] = { + @unroll sortKeys: Boolean = false): Array[Byte] = { maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(new ByteArrayOutputStream())).toByteArray } @@ -80,7 +80,7 @@ trait Api out: java.io.Writer, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { maybeSortKeysTransform(t, sortKeys, new ujson.Renderer(out, indent = indent, escapeUnicode)) } @@ -88,14 +88,14 @@ trait Api out: java.io.OutputStream, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { maybeSortKeysTransform(t, sortKeys, new ujson.BaseByteRenderer(out, indent = indent, escapeUnicode)) } def writeToByteArray[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): Array[Byte] = { + @unroll sortKeys: Boolean = false): Array[Byte] = { val out = new java.io.ByteArrayOutputStream() writeToOutputStream(t, out, indent, escapeUnicode, sortKeys) out.toByteArray @@ -107,7 +107,7 @@ trait Api def stream[T: Writer](t: T, indent: Int = -1, escapeUnicode: Boolean = false, - @Unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ + @unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ override def httpContentType = Some("application/json") def writeBytesTo(out: java.io.OutputStream) = { maybeSortKeysTransform(t, sortKeys, new ujson.BaseByteRenderer(out, indent = indent, escapeUnicode)) @@ -119,12 +119,12 @@ trait Api */ def writeBinaryTo[T: Writer](t: T, out: java.io.OutputStream, - @Unroll sortKeys: Boolean = false): Unit = { + @unroll sortKeys: Boolean = false): Unit = { streamBinary[T](t, sortKeys = sortKeys).writeBytesTo(out) } def writeBinaryToByteArray[T: Writer](t: T, - @Unroll sortKeys: Boolean = false): Array[Byte] = { + @unroll sortKeys: Boolean = false): Array[Byte] = { val out = new java.io.ByteArrayOutputStream() streamBinary[T](t, sortKeys = sortKeys).writeBytesTo(out) out.toByteArray @@ -133,7 +133,7 @@ trait Api /** * Write the given Scala value as a MessagePack binary via a `geny.Writable` */ - def streamBinary[T: Writer](t: T, @Unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ + def streamBinary[T: Writer](t: T, @unroll sortKeys: Boolean = false): geny.Writable = new geny.Writable{ override def httpContentType = Some("application/octet-stream") def writeBytesTo(out: java.io.OutputStream) = maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(out)) }