Skip to content

Commit

Permalink
Remove deprecations in prep for 4.x, break out Config trait and updat…
Browse files Browse the repository at this point in the history
…e docs (#599)

We disable MIMA checking, because we expect 4.x to be a binary
incompatible change. This gives us the opportunity to clean up a year's
worth of backwards compatibility stubs
  • Loading branch information
lihaoyi authored Jul 11, 2024
1 parent a871efb commit 38ac056
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 489 deletions.
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait CommonPublishModule

def publishVersion = VcsVersion.vcsState().format()
def mimaReportBinaryIssues() =
if (this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) T.command()
if (true || this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) T.command()
else super.mimaReportBinaryIssues()

def mimaPreviousVersions = Seq(
Expand Down
94 changes: 0 additions & 94 deletions ujson/src/ujson/IndexedValue.scala

This file was deleted.

72 changes: 3 additions & 69 deletions ujson/src/ujson/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ package object ujson{
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
*/
Expand All @@ -31,13 +28,6 @@ package object ujson{
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
*/
Expand All @@ -49,14 +39,6 @@ package object ujson{
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,
Expand All @@ -65,14 +47,6 @@ package object ujson{
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,
Expand All @@ -82,13 +56,6 @@ package object ujson{
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
*/
Expand All @@ -105,13 +72,7 @@ package object ujson{
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
Expand All @@ -123,14 +84,7 @@ package object ujson{
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
Expand All @@ -142,15 +96,7 @@ package object ujson{
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,
Expand All @@ -159,16 +105,4 @@ package object ujson{
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
@deprecated("use ujson.Value")
val Js = Value
}
13 changes: 0 additions & 13 deletions upack/src/upack/MsgPackWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,4 @@ class MsgPackWriter[T <: java.io.OutputStream](out: T = new ByteArrayOutputStrea
flushElemBuilder()
out
}


@deprecated("Not used, kept for binary compatibility")
def writeUInt8(i: Int): Unit = writeUInt8(byteBuilder.arr, byteBuilder.length, i)

@deprecated("Not used, kept for binary compatibility")
def writeUInt16(i: Int): Unit = writeUInt16(byteBuilder.arr, byteBuilder.length, i)

@deprecated("Not used, kept for binary compatibility")
def writeUInt32(i: Int): Unit = writeUInt32(byteBuilder.arr, byteBuilder.length, i)

@deprecated("Not used, kept for binary compatibility")
def writeUInt64(i: Long): Unit = writeUInt64(byteBuilder.arr, byteBuilder.length, i)
}
64 changes: 64 additions & 0 deletions upickle/core/src/upickle/core/Config.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package upickle.core

// Common things for derivation
trait Config {
def tagName = Annotator.defaultTagKey
/**
* Whether to use the fully-qualified name of `case class`es and `case object`s which
* are part of `sealed trait` hierarchies when serializing them and writing their `$type`
* key. Defaults to `false`, so `$type` key uses the shortest partially-qualified name.
* Can be set to `true` to use their fully-qualified name.
*/
def objectTypeKeyWriteFullyQualified: Boolean = false

/**
* Whether or not to write `case class` keys which match their default values.
* Defaults to `false`, allowing those keys to be omitted. Can be set to `true`
* to always write field values even if they are equal to the default
*/
def serializeDefaults: Boolean = false

/**
* Transform dictionary keys when writing `case class`es when reading. Can
* be overriden to provide custom mappings between Scala field names and JSON
* field names. Needs to be kept in sync with [[objectAttributeKeyWriteMap]]
*
* This customizes the mapping across all `case class`es fields handled by this
* upickle instance. This can be customized on a field-by-field basis using the
* [[upickle.implicits.key]] annotation on the `case class` field
*/
def objectAttributeKeyReadMap(s: CharSequence): CharSequence = s

/**
* Map the name of JSON object fields to Scala `case class` fields during serialization.
* Must be kept in sync with [[objectAttributeKeyReadMap]]
*/
def objectAttributeKeyWriteMap(s: CharSequence): CharSequence = s

/**
* Transforms the value of the `$type` field when writing `sealed trait`s,
* to allow custom mapping between the `case class` name and the `$type` field
* in the generated JSON. Must be kept in sync with [[objectTypeKeyWriteMap]].
*
* * This customizes the mapping across all `case class`es fields handled by this
* * upickle instance. This can be customized on a per-`sealed trait` basis using the
* * [[upickle.implicits.key]] annotation on the `case class`
*/
def objectTypeKeyReadMap(s: CharSequence): CharSequence = s

/**
* Map the name of Scala `case class` type names to JSON `$type` field value during
* serialization. Must be kept in sync with [[objectTypeKeyReadMap]]
*/
def objectTypeKeyWriteMap(s: CharSequence): CharSequence = s

/**
* Whether top-level `Some(t)`s and `None`s are serialized unboxed as `t` or
* `null`, rather than `[t]` or `[]`. This is generally what people expect,
* although it does cause issues where `Some(null)` when serialized and de-serialized
* can become `None`. Can be disabled to use the boxed serialization format
* as 0-or-1-element-arrays, presering round trip-ability at the expense of
* un-intuitiveness and verbosity
*/
def optionsAsNulls: Boolean = true
}
45 changes: 0 additions & 45 deletions upickle/core/src/upickle/core/RenderUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ object RenderUtils{
if (wrapQuotes) sb.append('"')
}

@deprecated("Not used, kept for binary compatibility")
def escapeSingleByteUnicodeRaw(unicodeCharBuilder: CharBuilder,
sb: ByteBuilder,
s: CharSequence,
escapeUnicode: Boolean,
i0: Int,
len0: Int,
naiveOutLen: Int,
wrapQuotes: Boolean): Unit = escapeSingleByteUnicodeRaw(
unicodeCharBuilder, sb, s, escapeUnicode, i0, len0, wrapQuotes
)

def escapeSingleByteUnicodeRaw(unicodeCharBuilder: CharBuilder,
sb: ByteBuilder,
s: CharSequence,
Expand Down Expand Up @@ -224,37 +212,4 @@ object RenderUtils{
}
19 + d
}

@deprecated("Not used, kept for binary compatibility")
def escapeSingleChar(sb: upickle.core.CharBuilder,
naiveOutLen: Int,
i: Int,
c: Char) = CharUtils.escapeSingleChar(sb, i, c)

@deprecated("Not used, kept for binary compatibility")
def escapeSingleByte(sb: upickle.core.ByteBuilder,
naiveOutLen: Int,
i: Int,
c: Char) = ByteUtils.escapeSingleByte(sb, i, c)

@deprecated("Not used, kept for binary compatibility")
def escapeSingleCharUnicodeEscape(naiveOutLen: Int, sb: CharBuilder, i: Int, c: Char) =
CharUtils.escapeSingleCharUnicodeEscape(sb, i, c)

@deprecated("Not used, kept for binary compatibility")
def escapeSingleByteUnicodeEscape(sb: ByteBuilder, i: Int, naiveOutLen: Int, c: Char) = {
ByteUtils.escapeSingleByteUnicodeEscape(sb, i, c)
}

@deprecated("Not used, kept for binary compatibility")
final def escapeChar0(i0: Int,
naiveOutLen: Int,
len: Int,
sb: upickle.core.CharBuilder,
s: CharSequence,
escapeUnicode: Boolean,
wrapQuotes: Boolean): upickle.core.CharBuilder = {
escapeChar0(i0, len, sb, s, escapeUnicode, wrapQuotes)
}

}
Loading

0 comments on commit 38ac056

Please sign in to comment.