Skip to content

Commit

Permalink
Lots of cross checking and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Nov 3, 2024
1 parent f335f28 commit 5787b97
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 426 deletions.
6 changes: 2 additions & 4 deletions inc/qcbor/qcbor_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#ifndef qcbor_common_h
#define qcbor_common_h

//#define QCBOR_DISABLE_TAGS

//TODO: get rid of QCBOR_DISABLE_EXP_AND_MANTISSA and uncommon tags

#ifdef __cplusplus
Expand Down Expand Up @@ -125,9 +123,9 @@ extern "C" {
#define CBOR_TAG_DATE_STRING 0
/** See QCBOREncode_AddTDateEpoch(). */
#define CBOR_TAG_DATE_EPOCH 1
/** See QCBOREncode_AddTPositiveBignum(). */
/** See QCBOREncode_AddTBigNumber(). */
#define CBOR_TAG_POS_BIGNUM 2
/** See QCBOREncode_AddTNegativeBignum(). */
/** See QCBOREncode_AddTBigNumber(). */
#define CBOR_TAG_NEG_BIGNUM 3
/** CBOR tag for a two-element array representing a fraction with a
* mantissa and base-10 scaling factor. See
Expand Down
44 changes: 24 additions & 20 deletions inc/qcbor/qcbor_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,52 +312,54 @@ typedef enum {
#define QCBOR_TYPE_UKNOWN_SIMPLE 13

/** A decimal fraction made of decimal exponent and integer mantissa.
* See @ref expAndMantissa and QCBOREncode_AddDecimalFraction(). */
* See @ref expAndMantissa and QCBOREncode_AddTDecimalFraction(). */
#define QCBOR_TYPE_DECIMAL_FRACTION 14

/** A decimal fraction made of decimal exponent and positive big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddDecimalFractionBigNum(). */
* QCBOREncode_AddTDecimalFractionBigMantissa(). */
#define QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM 15

/** A decimal fraction made of decimal exponent and positive
* uint64_t */
#define QCBOR_TYPE_DECIMAL_FRACTION_POS_U64 115

/** A decimal fraction made of decimal exponent and negative big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddDecimalFractionBigNum(). */
* QCBOREncode_AddTDecimalFractionBigMantissa(). */
#define QCBOR_TYPE_DECIMAL_FRACTION_NEG_BIGNUM 16

/** A decimal fraction made of decimal exponent and positive
* uint64_t . See QCBOREncode_AddTDecimalFractionBigMantissa(). */
#define QCBOR_TYPE_DECIMAL_FRACTION_POS_U64 79

/** A decimal fraction made of decimal exponent and negative big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddDecimalFractionBigNum(). */
#define QCBOR_TYPE_DECIMAL_FRACTION_NEG_U64 116 // TODO: is the the number we really want?
* QCBOREncode_AddTDecimalFractionBigMantissa(). */
#define QCBOR_TYPE_DECIMAL_FRACTION_NEG_U64 80

/** A floating-point number made of base-2 exponent and integer
* mantissa. See @ref expAndMantissa and
* QCBOREncode_AddBigFloat(). */
* QCBOREncode_AddTBigFloat(). */
#define QCBOR_TYPE_BIGFLOAT 17

/** A floating-point number made of base-2 exponent and positive big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddBigFloatBigNum(). */
* QCBOREncode_AddTBigFloatBigMantissa(). */
// TODO: rename to BIGMANTISSA?
#define QCBOR_TYPE_BIGFLOAT_POS_BIGNUM 18

/** A floating-point number made of base-2 exponent and negative big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddBigFloatBigNum(). */
* QCBOREncode_AddTBigFloatBigMantissa(). */
#define QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM 19

/** A floating-point number made of base-2 exponent and positive big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddBigFloatBigNum(). */
#define QCBOR_TYPE_BIGFLOAT_POS_U64 118
* QCBOREncode_AddTBigFloatBigMantissa(). */
// TODO: rename to U64MANTISSA
#define QCBOR_TYPE_BIGFLOAT_POS_U64 82

/** A floating-point number made of base-2 exponent and negative big
* number mantissa. See @ref expAndMantissa and
* QCBOREncode_AddBigFloatBigNum(). */
#define QCBOR_TYPE_BIGFLOAT_NEG_U64 119
* QCBOREncode_AddTBigFloatBigMantissa(). */
#define QCBOR_TYPE_BIGFLOAT_NEG_U64 83

/** Type for the simple value false. */
#define QCBOR_TYPE_FALSE 20
Expand Down Expand Up @@ -436,6 +438,8 @@ typedef enum {
* @c val.epochDays */
#define QCBOR_TYPE_DAYS_EPOCH 78

/* 79, 80, 82, 83 is used above for decimal fraction and big float */


#define QCBOR_TYPE_TAG_NUMBER 127 /* Used internally; never returned */

Expand Down Expand Up @@ -575,16 +579,16 @@ typedef struct _QCBORItem {
* be further subtracted from the value returned to get the
* actual value of the mantissa.
*
* See QCBORDecode_GetDecimalFractionBigNumber(),
* and QCBORDecode_GetBigFloatBigNumber() for
* See QCBORDecode_GetTDecimalFractionBigMantissa(),
* and QCBORDecode_GetTBigFloatBigMantissa() for
* methods that fully process negative mantissas.
* Also, QCBORDecode_ProcessBigNumber() which
* can be used on the mantissa returned here.
*
* Also see QCBOREncode_AddTDecimalFraction(),
* QCBOREncode_AddTBigFloat(),
* QCBOREncode_AddTDecimalFractionBigNumber() and
* QCBOREncode_AddTBigFloatBigNumber().
* QCBOREncode_AddTDecimalFractionBigMantissa() and
* QCBOREncode_AddTBigFloatBigMantissa().
*/
struct {
int64_t nExponent;
Expand Down
Loading

0 comments on commit 5787b97

Please sign in to comment.