changeset 707:9890d8dbac1f

val: switch CBOR packing to pack-val op As a side effect, all nvlist are now encoded as definite length maps. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 18 Mar 2019 21:32:39 -0400
parents fe60b160f306
children 9a1c3e578c26
files tests/nvl-pack/cmd-clear.cbor tests/nvl-pack/cmd-empty.cbor tests/nvl-pack/multi-bb.cbor tests/nvl-pack/multi-ib.cbor tests/nvl-pack/multi-in.cbor tests/nvl-pack/single-bool-false.cbor tests/nvl-pack/single-bool-true.cbor tests/nvl-pack/single-null.cbor tests/nvl-pack/single-str.cbor tests/nvl-pack/single-u16.cbor tests/nvl-pack/single-u32.cbor tests/nvl-pack/single-u64.cbor tests/nvl-pack/single-u8-medium.cbor tests/nvl-pack/single-u8-tiny.cbor tests/nvl-pack/uint-limits-0.cbor tests/nvl-pack/uint-limits-1.cbor tests/nvl-pack/uint-limits-1311768467463790320.cbor tests/nvl-pack/uint-limits-18446744073709551615.cbor tests/nvl-pack/uint-limits-23.cbor tests/nvl-pack/uint-limits-24.cbor tests/nvl-pack/uint-limits-255.cbor tests/nvl-pack/uint-limits-256.cbor tests/nvl-pack/uint-limits-4294967295.cbor tests/nvl-pack/uint-limits-4294967296.cbor tests/nvl-pack/uint-limits-65535.cbor tests/nvl-pack/uint-limits-65536.cbor val_fmt_cbor.c
diffstat 27 files changed, 22 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/tests/nvl-pack/cmd-clear.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/cmd-clear.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿ÿ
\ No newline at end of file

\ No newline at end of file
--- a/tests/nvl-pack/cmd-empty.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/cmd-empty.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿ÿ
\ No newline at end of file

\ No newline at end of file
--- a/tests/nvl-pack/multi-bb.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/multi-bb.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcõcdefôÿ
\ No newline at end of file
+¢cabcõcdefô
\ No newline at end of file
--- a/tests/nvl-pack/multi-ib.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/multi-ib.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabccdefõÿ
\ No newline at end of file
+¢cabccdefõ
\ No newline at end of file
--- a/tests/nvl-pack/multi-in.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/multi-in.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabccdeföÿ
\ No newline at end of file
+¢cabccdefö
\ No newline at end of file
--- a/tests/nvl-pack/single-bool-false.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-bool-false.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCôÿ
\ No newline at end of file
+¡cABCô
\ No newline at end of file
--- a/tests/nvl-pack/single-bool-true.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-bool-true.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCõÿ
\ No newline at end of file
+¡cABCõ
\ No newline at end of file
--- a/tests/nvl-pack/single-null.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-null.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCöÿ
\ No newline at end of file
+¡cABCö
\ No newline at end of file
--- a/tests/nvl-pack/single-str.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-str.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCcDEFÿ
\ No newline at end of file
+¡cABCcDEF
\ No newline at end of file
--- a/tests/nvl-pack/single-u16.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-u16.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCîÿ
\ No newline at end of file
+¡cABCî
\ No newline at end of file
Binary file tests/nvl-pack/single-u32.cbor has changed
Binary file tests/nvl-pack/single-u64.cbor has changed
--- a/tests/nvl-pack/single-u8-medium.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-u8-medium.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCdÿ
\ No newline at end of file
+¡cABCd
\ No newline at end of file
--- a/tests/nvl-pack/single-u8-tiny.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/single-u8-tiny.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cABCÿ
\ No newline at end of file
+¡cABC
\ No newline at end of file
Binary file tests/nvl-pack/uint-limits-0.cbor has changed
--- a/tests/nvl-pack/uint-limits-1.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-1.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿ
\ No newline at end of file
+¡cabc
\ No newline at end of file
--- a/tests/nvl-pack/uint-limits-1311768467463790320.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-1311768467463790320.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabc4Vxš¼Þðÿ
\ No newline at end of file
+¡cabc4Vxš¼Þð
\ No newline at end of file
--- a/tests/nvl-pack/uint-limits-18446744073709551615.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-18446744073709551615.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿÿÿÿÿÿÿÿÿ
\ No newline at end of file
+¡cabcÿÿÿÿÿÿÿÿ
\ No newline at end of file
--- a/tests/nvl-pack/uint-limits-23.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-23.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿ
\ No newline at end of file
+¡cabc
\ No newline at end of file
--- a/tests/nvl-pack/uint-limits-24.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-24.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿ
\ No newline at end of file
+¡cabc
\ No newline at end of file
--- a/tests/nvl-pack/uint-limits-255.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-255.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿÿ
\ No newline at end of file
+¡cabcÿ
\ No newline at end of file
Binary file tests/nvl-pack/uint-limits-256.cbor has changed
--- a/tests/nvl-pack/uint-limits-4294967295.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-4294967295.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿÿÿÿÿ
\ No newline at end of file
+¡cabcÿÿÿÿ
\ No newline at end of file
Binary file tests/nvl-pack/uint-limits-4294967296.cbor has changed
--- a/tests/nvl-pack/uint-limits-65535.cbor	Mon Mar 18 21:31:12 2019 -0400
+++ b/tests/nvl-pack/uint-limits-65535.cbor	Mon Mar 18 21:32:39 2019 -0400
@@ -1,1 +1,1 @@
-¿cabcÿÿÿ
\ No newline at end of file
+¡cabcÿÿ
\ No newline at end of file
Binary file tests/nvl-pack/uint-limits-65536.cbor has changed
--- a/val_fmt_cbor.c	Mon Mar 18 21:31:12 2019 -0400
+++ b/val_fmt_cbor.c	Mon Mar 18 21:32:39 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2017-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -29,40 +29,6 @@
  * nvl packing interface
  */
 
-static int cbor_nvl_prologue(struct buffer *buffer, struct nvlist *nvl)
-{
-	return cbor_pack_map_start(buffer, CBOR_UNKNOWN_NELEM);
-}
-
-static int cbor_nvl_epilogue(struct buffer *buffer, struct nvlist *nvl)
-{
-	return cbor_pack_map_end(buffer, CBOR_UNKNOWN_NELEM);
-}
-
-static int cbor_array_prologue(struct buffer *buffer, struct val *const *vals,
-			       size_t nelem)
-{
-	return cbor_pack_array_start(buffer, nelem);
-}
-
-static int cbor_array_epilogue(struct buffer *buffer, struct val *const *vals,
-			       size_t nelem)
-{
-	return cbor_pack_array_end(buffer, nelem);
-}
-
 const struct valops valops_cbor = {
-	.pack = {
-		.nvl_prologue = cbor_nvl_prologue,
-		.nvl_epilogue = cbor_nvl_epilogue,
-
-		.array_prologue = cbor_array_prologue,
-		.array_epilogue = cbor_array_epilogue,
-
-		.val_blob = cbor_pack_blob,
-		.val_bool = cbor_pack_bool,
-		.val_int = cbor_pack_uint,
-		.val_null = cbor_pack_null,
-		.val_str = cbor_pack_cstr,
-	}
+	.pack_val = cbor_pack_val,
 };