damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

flatcc_types.h (3091B)


      1 #ifndef FLATCC_TYPES_H
      2 #define FLATCC_TYPES_H
      3 
      4 #ifdef __cplusplus
      5 extern "C" {
      6 #endif
      7 
      8 #include <stdlib.h>
      9 
     10 #ifndef UINT8_MAX
     11 #include <stdint.h>
     12 #endif
     13 
     14 /*
     15  * This should match generated type declaratios in
     16  * `flatbuffers_common_reader.h` (might have different name prefix).
     17  * Read only generated code does not depend on library code,
     18  * hence the duplication.
     19  */
     20 #ifndef flatbuffers_types_defined
     21 #define flatbuffers_types_defined
     22 
     23 /*
     24  * uoffset_t and soffset_t must be same integer type, except for sign.
     25  * They can be (u)int16_t, (u)int32_t, or (u)int64_t.
     26  * The default is (u)int32_t.
     27  *
     28  * voffset_t is expected to be uint16_t, but can experimentally be
     29  * compiled from uint8_t up to uint32_t.
     30  *
     31  * ID_MAX is the largest value that can index a vtable. The table size
     32  * is given as voffset value. Each id represents a voffset value index
     33  * from 0 to max inclusive. Space is required for two header voffset
     34  * fields and the unaddressible highest index (due to the table size
     35  * representation). For 16-bit voffsets this yields a max of 2^15 - 4,
     36  * or (2^16 - 1) / 2 - 3.
     37  */
     38 
     39 #define flatbuffers_uoffset_t_defined
     40 #define flatbuffers_soffset_t_defined
     41 #define flatbuffers_voffset_t_defined
     42 #define flatbuffers_utype_t_defined
     43 #define flatbuffers_bool_t_defined
     44 #define flatbuffers_thash_t_defined
     45 #define flatbuffers_fid_t_defined
     46 
     47 /* uoffset_t is also used for vector and string headers. */
     48 #define FLATBUFFERS_UOFFSET_MAX UINT32_MAX
     49 #define FLATBUFFERS_SOFFSET_MAX INT32_MAX
     50 #define FLATBUFFERS_SOFFSET_MIN INT32_MIN
     51 #define FLATBUFFERS_VOFFSET_MAX UINT16_MAX
     52 #define FLATBUFFERS_UTYPE_MAX UINT8_MAX
     53 /* Well - the max of the underlying type. */
     54 #define FLATBUFFERS_BOOL_MAX UINT8_MAX
     55 #define FLATBUFFERS_THASH_MAX UINT32_MAX
     56 
     57 #define FLATBUFFERS_ID_MAX (FLATBUFFERS_VOFFSET_MAX / sizeof(flatbuffers_voffset_t) - 3)
     58 /* Vectors of empty structs can yield div by zero, so we must guard against this. */
     59 #define FLATBUFFERS_COUNT_MAX(elem_size) (FLATBUFFERS_UOFFSET_MAX/((elem_size) == 0 ? 1 : (elem_size)))
     60 
     61 #define FLATBUFFERS_UOFFSET_WIDTH 32
     62 #define FLATBUFFERS_COUNT_WIDTH 32
     63 #define FLATBUFFERS_SOFFSET_WIDTH 32
     64 #define FLATBUFFERS_VOFFSET_WIDTH 16
     65 #define FLATBUFFERS_UTYPE_WIDTH 8
     66 #define FLATBUFFERS_BOOL_WIDTH 8
     67 #define FLATBUFFERS_THASH_WIDTH 32
     68 
     69 #define FLATBUFFERS_TRUE 1
     70 #define FLATBUFFERS_FALSE 0
     71 
     72 #define FLATBUFFERS_PROTOCOL_IS_LE 1
     73 #define FLATBUFFERS_PROTOCOL_IS_BE 0
     74 
     75 typedef uint32_t flatbuffers_uoffset_t;
     76 typedef int32_t flatbuffers_soffset_t;
     77 typedef uint16_t flatbuffers_voffset_t;
     78 typedef uint8_t flatbuffers_utype_t;
     79 typedef uint8_t flatbuffers_bool_t;
     80 typedef uint32_t flatbuffers_thash_t;
     81 /* Public facing type operations. */
     82 typedef flatbuffers_utype_t flatbuffers_union_type_t;
     83 
     84 static const flatbuffers_bool_t flatbuffers_true = FLATBUFFERS_TRUE;
     85 static const flatbuffers_bool_t flatbuffers_false = FLATBUFFERS_FALSE;
     86 
     87 #define FLATBUFFERS_IDENTIFIER_SIZE (FLATBUFFERS_THASH_WIDTH / 8)
     88 
     89 typedef char flatbuffers_fid_t[FLATBUFFERS_IDENTIFIER_SIZE];
     90 
     91 #endif /* flatbuffers_types_defined */
     92 
     93 #ifdef __cplusplus
     94 }
     95 #endif
     96 
     97 #endif /* FLATCC_TYPES_H */