14#include "deconz/declspec.h"
73typedef unsigned long long nb_word;
75#define NB_SHIFT_TYPE 48LLU
76#define NB_SHIFT_Q 51LLU
77#define NB_S_TO_Q_MASK 0x1fffLLU
80#define NB_ATOM_SHIFT_LENGTH 24ULL
81#define NB_ATOM_LENGTH_MASK 0xFFFF
82#define NB_ATOM_PTR_MASK 0xFFFFFFUL
85#define NB_VALUE_NAN ((NB_S_TO_Q_MASK << NB_SHIFT_Q) | ((nb_word)NB_TYPE_NAN << NB_SHIFT_TYPE))
87#define NB_VALUE_NULL ((NB_S_TO_Q_MASK << NB_SHIFT_Q) | ((nb_word)NB_TYPE_NULL << NB_SHIFT_TYPE))
89#define NB_VALUE_TRUE ((NB_S_TO_Q_MASK << NB_SHIFT_Q) | ((nb_word)NB_TYPE_BOOL << NB_SHIFT_TYPE) | 3)
91#define NB_VALUE_FALSE ((NB_S_TO_Q_MASK << NB_SHIFT_Q) | ((nb_word)NB_TYPE_BOOL << NB_SHIFT_TYPE) | 2)
94#define NB_VALUE_ATOM_PTR(idx, len) ((NB_S_TO_Q_MASK << NB_SHIFT_Q) | ((nb_word)NB_TYPE_ATOM_PTR << NB_SHIFT_TYPE) | ((len) << NB_ATOM_SHIFT_LENGTH) | (idx))
DECONZ_DLLSPEC int NB_IsBox(struct NB_NanBox)
Returns 1 if the value is NaN boxed, that is the expontent bits are 1 and TTT type is known.
Definition nanbox.c:18
NB_BoxType
3-bit enumeration refering to TTT type bits.
Definition nanbox.h:60
DECONZ_DLLSPEC NB_BoxType NB_Type(struct NB_NanBox)
Returns the type of a NaN boxed value.
Definition nanbox.c:23
@ NB_TYPE_TIMESTAMP
48-bit Unix timestamp with millisecond precision
Definition nanbox.h:65
@ NB_TYPE_NULL
null
Definition nanbox.h:62
@ NB_TYPE_DOUBLE
Not a NaN boxed value but a valid double.
Definition nanbox.h:68
@ NB_TYPE_UNKNOWN
Type can't be determined.
Definition nanbox.h:70
@ NB_TYPE_BOOL
Bool type for true and false.
Definition nanbox.h:66
@ NB_TYPE_USTRING_PTR
Used internally by UString for heap allocated strings.
Definition nanbox.h:63
@ NB_TYPE_NAN
NaN (not a number)
Definition nanbox.h:61
@ NB_TYPE_ATOM_PTR
Atom index and length.
Definition nanbox.h:64
nb_word u64
unsigned value for bit operations
Definition nanbox.h:103
double f64
double value for NB_TYPE_DOUBLE
Definition nanbox.h:104