aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2023-12-16 23:44:40 +0100
committerLaytan Laats <laytanlaats@hotmail.com>2024-03-04 17:26:19 +0100
commit7283b5e75ccecf7dbf28072456a137b29ff983af (patch)
tree9400eba0dec59cb9bcd5d25d47c6a79f3c455c4f /core/encoding
parent21e6e28a3a5609bc4db19dd2b1bc00ff7b1ac5e5 (diff)
encoding/cbor: minor things
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/cbor/cbor.odin6
-rw-r--r--core/encoding/cbor/tags.odin2
-rw-r--r--core/encoding/cbor/unmarshal.odin2
3 files changed, 6 insertions, 4 deletions
diff --git a/core/encoding/cbor/cbor.odin b/core/encoding/cbor/cbor.odin
index 9c4bb0e4e..ddbd53c8d 100644
--- a/core/encoding/cbor/cbor.odin
+++ b/core/encoding/cbor/cbor.odin
@@ -1,3 +1,7 @@
+// Package cbor encodes, decodes, marshals and unmarshals types from/into RCF 8949 compatible CBOR binary.
+// Also provided are conversion to and from JSON and the CBOR diagnostic format.
+//
+// You can additionally provide custom CBOR tag implementations for your use cases.
package cbor
import "core:encoding/json"
@@ -163,7 +167,7 @@ Decode_Data_Error :: enum {
Nested_Tag, // When a tag's value is another tag, this is not allowed.
Length_Too_Big, // When the length of a container (map, array, bytes, string) is more than `max(int)`.
Disallowed_Streaming, // When the `.Disallow_Streaming` flag is set and a streaming header is encountered.
- Break,
+ Break, // When the `break` header was found without any stream to break off.
}
Encode_Data_Error :: enum {
diff --git a/core/encoding/cbor/tags.odin b/core/encoding/cbor/tags.odin
index d2867e7be..cdb7227ef 100644
--- a/core/encoding/cbor/tags.odin
+++ b/core/encoding/cbor/tags.odin
@@ -89,7 +89,7 @@ tag_register_number :: proc(impl: Tag_Implementation, nr: Tag_Number, id: string
// Controls initialization of default tag implementations.
// JS and WASI default to a panic allocator so we don't want to do it on those.
-INITIALIZE_DEFAULT_TAGS :: #config(CBOR_INITIALIZE_DEFAULT_TAGS, ODIN_OS != .JS && ODIN_OS != .WASI)
+INITIALIZE_DEFAULT_TAGS :: #config(CBOR_INITIALIZE_DEFAULT_TAGS, !ODIN_DEFAULT_TO_NIL_ALLOCATOR && ODIN_OS != .JS && ODIN_OS != .WASI)
@(private, init, disabled=!INITIALIZE_DEFAULT_TAGS)
tags_initialize_defaults :: proc() {
diff --git a/core/encoding/cbor/unmarshal.odin b/core/encoding/cbor/unmarshal.odin
index 2df99ca71..dea4b749c 100644
--- a/core/encoding/cbor/unmarshal.odin
+++ b/core/encoding/cbor/unmarshal.odin
@@ -686,8 +686,6 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header,
return _unsupported(v, hdr)
}
- // TODO: shrink excess.
-
raw_map := (^mem.Raw_Map)(v.data)
if raw_map.allocator.procedure == nil {
raw_map.allocator = context.allocator