Skip to content

Commit 4e15cc2

Browse files
committed
more AI slop
1 parent 255f250 commit 4e15cc2

File tree

5 files changed

+119
-202
lines changed

5 files changed

+119
-202
lines changed

formats/cbor/commonMain/src/kotlinx/serialization/cbor/Cbor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public sealed class Cbor(
9090
}
9191

9292
public fun <T> decodeFromCbor(deserializer: DeserializationStrategy<T>, element: CborElement): T {
93-
val reader = StructuredCborReader(this, StructuredCborParser(element, configuration.verifyObjectTags))
93+
val reader = CborReader(this, StructuredCborParser(element, configuration.verifyObjectTags))
9494
return reader.decodeSerializableValue(deserializer)
9595
}
9696

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2017-2025 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
@file:OptIn(ExperimentalSerializationApi::class, ExperimentalUnsignedTypes::class)
5+
6+
package kotlinx.serialization.cbor.internal
7+
8+
import kotlinx.serialization.*
9+
10+
/**
11+
* Common interface for CBOR parsers that can read CBOR data from different sources.
12+
*/
13+
internal interface CborParserInterface {
14+
// Basic state checks
15+
fun isNull(): Boolean
16+
fun isEnd(): Boolean
17+
fun end()
18+
19+
// Collection operations
20+
fun startArray(tags: ULongArray? = null): Int
21+
fun startMap(tags: ULongArray? = null): Int
22+
23+
// Value reading operations
24+
fun nextNull(tags: ULongArray? = null): Nothing?
25+
fun nextBoolean(tags: ULongArray? = null): Boolean
26+
fun nextNumber(tags: ULongArray? = null): Long
27+
fun nextString(tags: ULongArray? = null): String
28+
fun nextByteString(tags: ULongArray? = null): ByteArray
29+
fun nextDouble(tags: ULongArray? = null): Double
30+
fun nextFloat(tags: ULongArray? = null): Float
31+
32+
// Map key operations
33+
fun nextTaggedStringOrNumber(): Triple<String?, Long?, ULongArray?>
34+
35+
// Skip operations
36+
fun skipElement(tags: ULongArray?)
37+
38+
// Tag verification
39+
fun verifyTagsAndThrow(expected: ULongArray, actual: ULongArray?)
40+
41+
// Additional methods needed for CborTreeReader
42+
fun nextTag(): ULong
43+
fun readByte(): Int
44+
45+
// Properties needed for CborTreeReader
46+
val curByte: Int
47+
}

formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/CborTreeReader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal class CborTreeReader(
1616
//we cannot validate tags, or disregard nulls, can we?!
1717
//still, this needs to go here, in case it evolves to a point where we need to respect certain config values
1818
private val configuration: CborConfiguration,
19-
private val parser: CborParser
19+
private val parser: CborParserInterface
2020
) {
2121
/**
2222
* Reads the next CBOR element from the parser.

0 commit comments

Comments
 (0)