LCOV - code coverage report
Current view: top level - include/flatcc/reflection - flatbuffers_common_builder.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 6 83.3 %
Date: 2016-11-30 13:12:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : #ifndef FLATBUFFERS_COMMON_BUILDER_H
       2                 :            : #define FLATBUFFERS_COMMON_BUILDER_H
       3                 :            : 
       4                 :            : /* Generated by flatcc 0.4.0 FlatBuffers schema compiler for C by dvide.com */
       5                 :            : 
       6                 :            : /* Common FlatBuffers build functionality for C. */
       7                 :            : 
       8                 :            : #define PDIAGNOSTIC_IGNORE_UNUSED
       9                 :            : #include "flatcc/portable/pdiagnostic_push.h"
      10                 :            : #ifndef FLATBUILDER_H
      11                 :            : #include "flatcc/flatcc_builder.h"
      12                 :            : #endif
      13                 :            : typedef flatcc_builder_t flatbuffers_builder_t;
      14                 :            : typedef flatcc_builder_ref_t flatbuffers_ref_t;
      15                 :            : typedef flatcc_builder_ref_t flatbuffers_vec_ref_t;
      16                 :            : /* integer return code (ref and ptr always fail on 0) */
      17                 :            : #define flatbuffers_failed(x) ((x) < 0)
      18                 :            : typedef flatbuffers_ref_t flatbuffers_root_t;
      19                 :            : #define flatbuffers_root(ref) ((flatbuffers_root_t)(ref))
      20                 :            : 
      21                 :            : #define __flatbuffers_build_buffer(NS)\
      22                 :            : typedef NS ## ref_t NS ## buffer_ref_t;\
      23                 :            : static inline int NS ## buffer_start(NS ## builder_t *B, NS ##fid_t fid)\
      24                 :            : { return flatcc_builder_start_buffer(B, fid, 0, 0); }\
      25                 :            : static inline int NS ## buffer_start_with_size(NS ## builder_t *B, NS ##fid_t fid)\
      26                 :            : { return flatcc_builder_start_buffer(B, fid, 0, flatcc_builder_with_size); }\
      27                 :            : static inline int NS ## buffer_start_aligned(NS ## builder_t *B, NS ##fid_t fid, uint16_t block_align)\
      28                 :            : { return flatcc_builder_start_buffer(B, fid, block_align, 0); }\
      29                 :            : static inline int NS ## buffer_start_aligned_with_size(NS ## builder_t *B, NS ##fid_t fid, uint16_t block_align)\
      30                 :            : { return flatcc_builder_start_buffer(B, fid, block_align, flatcc_builder_with_size); }\
      31                 :            : static inline NS ## buffer_ref_t NS ## buffer_end(NS ## builder_t *B, NS ## ref_t root)\
      32                 :            : { return flatcc_builder_end_buffer(B, root); }
      33                 :            : 
      34                 :            : #define __flatbuffers_build_table_root(NS, N, FID, TFID)\
      35                 :            : static inline int N ## _start_as_root(NS ## builder_t *B)\
      36                 :            : { return NS ## buffer_start(B, FID) ? -1 : N ## _start(B); }\
      37                 :            : static inline int N ## _start_as_root_with_size(NS ## builder_t *B)\
      38                 :            : { return NS ## buffer_start_with_size(B, FID) ? -1 : N ## _start(B); }\
      39                 :            : static inline int N ## _start_as_typed_root(NS ## builder_t *B)\
      40                 :            : { return NS ## buffer_start(B, TFID) ? -1 : N ## _start(B); }\
      41                 :            : static inline int N ## _start_as_typed_root_with_size(NS ## builder_t *B)\
      42                 :            : { return NS ## buffer_start_with_size(B, TFID) ? -1 : N ## _start(B); }\
      43                 :            : static inline NS ## buffer_ref_t N ## _end_as_root(NS ## builder_t *B)\
      44                 :            : { return NS ## buffer_end(B, N ## _end(B)); }\
      45                 :            : static inline NS ## buffer_ref_t N ## _end_as_typed_root(NS ## builder_t *B)\
      46                 :            : { return NS ## buffer_end(B, N ## _end(B)); }\
      47                 :            : static inline NS ## buffer_ref_t N ## _create_as_root(NS ## builder_t *B __ ## N ## _formal_args)\
      48                 :            : { if (NS ## buffer_start(B, FID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\
      49                 :            : static inline NS ## buffer_ref_t N ## _create_as_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\
      50                 :            : { if (NS ## buffer_start_with_size(B, FID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\
      51                 :            : static inline NS ## buffer_ref_t N ## _create_as_typed_root(NS ## builder_t *B __ ## N ## _formal_args)\
      52                 :            : { if (NS ## buffer_start(B, TFID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }\
      53                 :            : static inline NS ## buffer_ref_t N ## _create_as_typed_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\
      54                 :            : { if (NS ## buffer_start_with_size(B, TFID)) return 0; return NS ## buffer_end(B, N ## _create(B __ ## N ## _call_args)); }
      55                 :            : 
      56                 :            : #define __flatbuffers_build_table_prolog(NS, N, FID, TFID)\
      57                 :            : __flatbuffers_build_table_vector_ops(NS, N ## _vec, N)\
      58                 :            : __flatbuffers_build_table_root(NS, N, FID, TFID)
      59                 :            : 
      60                 :            : #define __flatbuffers_build_struct_root(NS, N, A, FID, TFID)\
      61                 :            : static inline N ## _t *N ## _start_as_root(NS ## builder_t *B)\
      62                 :            : { return NS ## buffer_start(B, FID) ? 0 : N ## _start(B); }\
      63                 :            : static inline N ## _t *N ## _start_as_root_with_size(NS ## builder_t *B)\
      64                 :            : { return NS ## buffer_start_with_size(B, FID) ? 0 : N ## _start(B); }\
      65                 :            : static inline N ## _t *N ## _start_as_typed_root(NS ## builder_t *B)\
      66                 :            : { return NS ## buffer_start(B, TFID) ? 0 : N ## _start(B); }\
      67                 :            : static inline N ## _t *N ## _start_as_typed_root_with_size(NS ## builder_t *B)\
      68                 :            : { return NS ## buffer_start_with_size(B, TFID) ? 0 : N ## _start(B); }\
      69                 :            : static inline NS ## buffer_ref_t N ## _end_as_root(NS ## builder_t *B)\
      70                 :            : { return NS ## buffer_end(B, N ## _end(B)); }\
      71                 :            : static inline NS ## buffer_ref_t N ## _end_as_typed_root(NS ## builder_t *B)\
      72                 :            : { return NS ## buffer_end(B, N ## _end(B)); }\
      73                 :            : static inline NS ## buffer_ref_t N ## _end_pe_as_root(NS ## builder_t *B)\
      74                 :            : { return NS ## buffer_end(B, N ## _end_pe(B)); }\
      75                 :            : static inline NS ## buffer_ref_t N ## _end_pe_as_typed_root(NS ## builder_t *B)\
      76                 :            : { return NS ## buffer_end(B, N ## _end_pe(B)); }\
      77                 :            : static inline NS ## buffer_ref_t N ## _create_as_root(NS ## builder_t *B __ ## N ## _formal_args)\
      78                 :            : { return flatcc_builder_create_buffer(B, FID, 0,\
      79                 :            :   N ## _create(B __ ## N ## _call_args), A, 0); }\
      80                 :            : static inline NS ## buffer_ref_t N ## _create_as_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\
      81                 :            : { return flatcc_builder_create_buffer(B, FID, 0,\
      82                 :            :   N ## _create(B __ ## N ## _call_args), A, flatcc_builder_with_size); }\
      83                 :            : static inline NS ## buffer_ref_t N ## _create_as_typed_root(NS ## builder_t *B __ ## N ## _formal_args)\
      84                 :            : { return flatcc_builder_create_buffer(B, TFID, 0,\
      85                 :            :   N ## _create(B __ ## N ## _call_args), A, 0); }\
      86                 :            : static inline NS ## buffer_ref_t N ## _create_as_typed_root_with_size(NS ## builder_t *B __ ## N ## _formal_args)\
      87                 :            : { return flatcc_builder_create_buffer(B, TFID, 0,\
      88                 :            :   N ## _create(B __ ## N ## _call_args), A, flatcc_builder_with_size); }
      89                 :            : 
      90                 :            : #define __flatbuffers_build_nested_table_root(NS, N, TN, FID, TFID)\
      91                 :            : static inline int N ## _start_as_root(NS ## builder_t *B)\
      92                 :            : { return NS ## buffer_start(B, FID) ? -1 : TN ## _start(B); }\
      93                 :            : static inline int N ## _start_as_typed_root(NS ## builder_t *B)\
      94                 :            : { return NS ## buffer_start(B, TFID) ? -1 : TN ## _start(B); }\
      95                 :            : static inline int N ## _end_as_root(NS ## builder_t *B)\
      96                 :            : { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\
      97                 :            : static inline int N ## _end_as_typed_root(NS ## builder_t *B)\
      98                 :            : { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\
      99                 :            : static inline int N ## _nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\
     100                 :            : { if (NS ## buffer_start(B, FID)) return -1;\
     101                 :            :   return N ## _add(B, NS ## buffer_end(B, flatcc_builder_create_vector(B, data, size, 1,\
     102                 :            :   align ? align : 8, FLATBUFFERS_COUNT_MAX(1)))); }\
     103                 :            : static inline int N ## _typed_nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\
     104                 :            : { if (NS ## buffer_start(B, TFID)) return -1;\
     105                 :            :   return N ## _add(B, NS ## buffer_end(B, flatcc_builder_create_vector(B, data, size, 1,\
     106                 :            :   align ? align : 8, FLATBUFFERS_COUNT_MAX(1)))); }
     107                 :            : 
     108                 :            : #define __flatbuffers_build_nested_struct_root(NS, N, TN, A, FID, TFID)\
     109                 :            : static inline TN ## _t *N ## _start_as_root(NS ## builder_t *B)\
     110                 :            : { return NS ## buffer_start(B, FID) ? 0 : TN ## _start(B); }\
     111                 :            : static inline TN ## _t *N ## _start_as_typed_root(NS ## builder_t *B)\
     112                 :            : { return NS ## buffer_start(B, FID) ? 0 : TN ## _start(B); }\
     113                 :            : static inline int N ## _end_as_root(NS ## builder_t *B)\
     114                 :            : { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\
     115                 :            : static inline int N ## _end_as_typed_root(NS ## builder_t *B)\
     116                 :            : { return N ## _add(B, NS ## buffer_end(B, TN ## _end(B))); }\
     117                 :            : static inline int N ## _end_pe_as_root(NS ## builder_t *B)\
     118                 :            : { return N ## _add(B, NS ## buffer_end(B, TN ## _end_pe(B))); }\
     119                 :            : static inline int N ## _create_as_root(NS ## builder_t *B __ ## TN ## _formal_args)\
     120                 :            : { return N ## _add(B, flatcc_builder_create_buffer(B, FID, 0,\
     121                 :            :   TN ## _create(B __ ## TN ## _call_args), A, flatcc_builder_is_nested)); }\
     122                 :            : static inline int N ## _create_as_typed_root(NS ## builder_t *B __ ## TN ## _formal_args)\
     123                 :            : { return N ## _add(B, flatcc_builder_create_buffer(B, TFID, 0,\
     124                 :            :   TN ## _create(B __ ## TN ## _call_args), A, flatcc_builder_is_nested)); }\
     125                 :            : static inline int N ## _nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\
     126                 :            : { if (NS ## buffer_start(B, FID)) return -1;\
     127                 :            :   return N ## _add(B, NS ## buffer_end(B, flatcc_builder_create_vector(B, data, size, 1,\
     128                 :            :   align < A ? A : align, FLATBUFFERS_COUNT_MAX(1)))); }\
     129                 :            : static inline int N ## _typed_nest(NS ## builder_t *B, void *data, size_t size, uint16_t align)\
     130                 :            : { if (NS ## buffer_start(B, TFID)) return -1;\
     131                 :            :   return N ## _add(B, NS ## buffer_end(B, flatcc_builder_create_vector(B, data, size, 1,\
     132                 :            :   align < A ? A : align, FLATBUFFERS_COUNT_MAX(1)))); }
     133                 :            : 
     134                 :            : #define __flatbuffers_build_vector_ops(NS, V, N, TN, T)\
     135                 :            : static inline T *V ## _extend(NS ## builder_t *B, size_t len)\
     136                 :            : { return flatcc_builder_extend_vector(B, len); }\
     137                 :            : static inline T *V ## _append(NS ## builder_t *B, const T *data, size_t len)\
     138                 :            : { return flatcc_builder_append_vector(B, data, len); }\
     139                 :            : static inline int V ## _truncate(NS ## builder_t *B, size_t len)\
     140                 :            : { return flatcc_builder_truncate_vector(B, len); }\
     141                 :            : static inline T *V ## _edit(NS ## builder_t *B)\
     142                 :            : { return flatcc_builder_vector_edit(B); }\
     143                 :            : static inline size_t V ## _reserved_len(NS ## builder_t *B)\
     144                 :            : { return flatcc_builder_vector_count(B); }\
     145                 :            : static inline T *V ## _push(NS ## builder_t *B, const T *p)\
     146                 :            : { T *_p; return (_p = flatcc_builder_extend_vector(B, 1)) ? (memcpy(_p, p, TN ## __size()), _p) : 0; }\
     147                 :            : static inline T *V ## _push_copy(NS ## builder_t *B, const T *p)\
     148                 :            : { T *_p; return (_p = flatcc_builder_extend_vector(B, 1)) ? TN ## _copy(_p, p) : 0; }\
     149                 :            : static inline T *V ## _push_create(NS ## builder_t *B __ ## TN ## _formal_args)\
     150                 :            : { T *_p; return (_p = flatcc_builder_extend_vector(B, 1)) ? TN ## _assign(_p __ ## TN ## _call_args) : 0; }
     151                 :            : 
     152                 :            : #define __flatbuffers_build_vector(NS, N, T, S, A)\
     153                 :            : typedef NS ## ref_t N ## _vec_ref_t;\
     154                 :            : static inline int N ## _vec_start(NS ## builder_t *B)\
     155                 :            : { return flatcc_builder_start_vector(B, S, A, FLATBUFFERS_COUNT_MAX(S)); }\
     156                 :            : static inline N ## _vec_ref_t N ## _vec_end_pe(NS ## builder_t *B)\
     157                 :            : { return flatcc_builder_end_vector(B); }\
     158                 :            : static inline N ## _vec_ref_t N ## _vec_end(NS ## builder_t *B)\
     159                 :            : { if (!NS ## is_native_pe()) { size_t i, n; T *p = flatcc_builder_vector_edit(B);\
     160                 :            :     for (i = 0, n = flatcc_builder_vector_count(B); i < n; ++i)\
     161                 :            :     { N ## _to_pe(N ## __ptr_add(p, i)); }} return flatcc_builder_end_vector(B); }\
     162                 :            : static inline N ## _vec_ref_t N ## _vec_create_pe(NS ## builder_t *B, const T *data, size_t len)\
     163                 :            : { return flatcc_builder_create_vector(B, data, len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\
     164                 :            : static inline N ## _vec_ref_t N ## _vec_create(NS ## builder_t *B, const T *data, size_t len)\
     165                 :            : { if (!NS ## is_native_pe()) { size_t i; T *p; int ret = flatcc_builder_start_vector(B, S, A, FLATBUFFERS_COUNT_MAX(S)); if (ret) { return ret; }\
     166                 :            :   p = flatcc_builder_extend_vector(B, len); if (!p) return 0;\
     167                 :            :   for (i = 0; i < len; ++i) { N ## _copy_to_pe(N ## __ptr_add(p, i), N ## __const_ptr_add(data, i)); }\
     168                 :            :   return flatcc_builder_end_vector(B); } else return flatcc_builder_create_vector(B, data, len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\
     169                 :            : static inline N ## _vec_ref_t N ## _vec_clone(NS ## builder_t *B, N ##_vec_t vec)\
     170                 :            : { return flatcc_builder_create_vector(B, vec, N ## _vec_len(vec), S, A, FLATBUFFERS_COUNT_MAX(S)); }\
     171                 :            : static inline N ## _vec_ref_t N ## _vec_slice(NS ## builder_t *B, N ##_vec_t vec, size_t index, size_t len)\
     172                 :            : { size_t n = N ## _vec_len(vec); if (index >= n) index = n; n -= index; if (len > n) len = n;\
     173                 :            :   return flatcc_builder_create_vector(B, N ## __const_ptr_add(vec, index), len, S, A, FLATBUFFERS_COUNT_MAX(S)); }\
     174                 :            : __flatbuffers_build_vector_ops(NS, N ## _vec, N, N, T)
     175                 :            : 
     176                 :            : #define __flatbuffers_build_string_vector_ops(NS, N)\
     177                 :            : static inline int N ## _push_start(NS ## builder_t *B)\
     178                 :            : { return NS ## string_start(B); }\
     179                 :            : static inline NS ## string_ref_t *N ## _push_end(NS ## builder_t *B)\
     180                 :            : { return NS ## string_vec_push(B, NS ## string_end(B)); }\
     181                 :            : static inline NS ## string_ref_t *N ## _push_create(NS ## builder_t *B, const char *s, size_t len)\
     182                 :            : { return NS ## string_vec_push(B, NS ## string_create(B, s, len)); }\
     183                 :            : static inline NS ## string_ref_t *N ## _push_create_str(NS ## builder_t *B, const char *s)\
     184                 :            : { return NS ## string_vec_push(B, NS ## string_create_str(B, s)); }\
     185                 :            : static inline NS ## string_ref_t *N ## _push_create_strn(NS ## builder_t *B, const char *s, size_t max_len)\
     186                 :            : { return NS ## string_vec_push(B, NS ## string_create_strn(B, s, max_len)); }\
     187                 :            : static inline NS ## string_ref_t *N ## _push_clone(NS ## builder_t *B, NS ## string_t string)\
     188                 :            : { return NS ## string_vec_push(B, NS ## string_clone(B, string)); }\
     189                 :            : static inline NS ## string_ref_t *N ## _push_slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\
     190                 :            : { return NS ## string_vec_push(B, NS ## string_slice(B, string, index, len)); }
     191                 :            : 
     192                 :            : #define __flatbuffers_build_table_vector_ops(NS, N, TN)\
     193                 :            : static inline int N ## _push_start(NS ## builder_t *B)\
     194                 :            : { return TN ## _start(B); }\
     195                 :            : static inline TN ## _ref_t *N ## _push_end(NS ## builder_t *B)\
     196                 :            : { return N ## _push(B, TN ## _end(B)); }\
     197                 :            : static inline TN ## _ref_t *N ## _push_create(NS ## builder_t *B __ ## TN ##_formal_args)\
     198                 :            : { return N ## _push(B, TN ## _create(B __ ## TN ## _call_args)); }
     199                 :            : 
     200                 :            : #define __flatbuffers_build_offset_vector_ops(NS, V, N, TN)\
     201                 :            : static inline TN ## _ref_t *V ## _extend(NS ## builder_t *B, size_t len)\
     202                 :            : { return flatcc_builder_extend_offset_vector(B, len); }\
     203                 :            : static inline TN ## _ref_t *V ## _append(NS ## builder_t *B, const TN ## _ref_t *data, size_t len)\
     204                 :            : { return flatcc_builder_append_offset_vector(B, data, len); }\
     205                 :            : static inline int V ## _truncate(NS ## builder_t *B, size_t len)\
     206                 :            : { return flatcc_builder_truncate_offset_vector(B, len); }\
     207                 :            : static inline TN ## _ref_t *V ## _edit(NS ## builder_t *B)\
     208                 :            : { return flatcc_builder_offset_vector_edit(B); }\
     209                 :            : static inline size_t V ## _reserved_len(NS ## builder_t *B)\
     210                 :            : { return flatcc_builder_offset_vector_count(B); }\
     211                 :            : static inline TN ## _ref_t *V ## _push(NS ## builder_t *B, const TN ## _ref_t ref)\
     212                 :            : { return ref ? flatcc_builder_offset_vector_push(B, ref) : 0; }
     213                 :            : 
     214                 :            : #define __flatbuffers_build_offset_vector(NS, N)\
     215                 :            : typedef NS ## ref_t N ## _vec_ref_t;\
     216                 :            : static inline int N ## _vec_start(NS ## builder_t *B)\
     217                 :            : { return flatcc_builder_start_offset_vector(B); }\
     218                 :            : static inline N ## _vec_ref_t N ## _vec_end(NS ## builder_t *B)\
     219                 :            : { return flatcc_builder_end_offset_vector(B); }\
     220                 :            : static inline N ## _vec_ref_t N ## _vec_create(NS ## builder_t *B, const N ## _ref_t *data, size_t len)\
     221                 :            : { return flatcc_builder_create_offset_vector(B, data, len); }\
     222                 :            : __flatbuffers_build_offset_vector_ops(NS, N ## _vec, N, N)
     223                 :            : 
     224                 :            : #define __flatbuffers_build_string_ops(NS, N)\
     225                 :            : static inline char *N ## _append(NS ## builder_t *B, const char *s, size_t len)\
     226                 :            : { return flatcc_builder_append_string(B, s, len); }\
     227                 :            : static inline char *N ## _append_str(NS ## builder_t *B, const char *s)\
     228                 :            : { return flatcc_builder_append_string_str(B, s); }\
     229                 :            : static inline char *N ## _append_strn(NS ## builder_t *B, const char *s, size_t len)\
     230                 :            : { return flatcc_builder_append_string_strn(B, s, len); }\
     231                 :            : static inline size_t N ## _reserved_len(NS ## builder_t *B)\
     232                 :            : { return flatcc_builder_string_len(B); }\
     233                 :            : static inline char *N ## _extend(NS ## builder_t *B, size_t len)\
     234                 :            : { return flatcc_builder_extend_string(B, len); }\
     235                 :            : static inline char *N ## _edit(NS ## builder_t *B)\
     236                 :            : { return flatcc_builder_string_edit(B); }\
     237                 :            : static inline int N ## _truncate(NS ## builder_t *B, size_t len)\
     238                 :            : { return flatcc_builder_truncate_string(B, len); }
     239                 :            : 
     240                 :            : #define __flatbuffers_build_string(NS)\
     241                 :            : typedef NS ## ref_t NS ## string_ref_t;\
     242                 :            : static inline int NS ## string_start(NS ## builder_t *B)\
     243                 :            : { return flatcc_builder_start_string(B); }\
     244                 :            : static inline NS ## string_ref_t NS ## string_end(NS ## builder_t *B)\
     245                 :            : { return flatcc_builder_end_string(B); }\
     246                 :            : static inline NS ## ref_t NS ## string_create(NS ## builder_t *B, const char *s, size_t len)\
     247                 :            : { return flatcc_builder_create_string(B, s, len); }\
     248                 :            : static inline NS ## ref_t NS ## string_create_str(NS ## builder_t *B, const char *s)\
     249                 :            : { return flatcc_builder_create_string_str(B, s); }\
     250                 :            : static inline NS ## ref_t NS ## string_create_strn(NS ## builder_t *B, const char *s, size_t len)\
     251                 :            : { return flatcc_builder_create_string_strn(B, s, len); }\
     252                 :            : static inline NS ## string_ref_t NS ## string_clone(NS ## builder_t *B, NS ## string_t string)\
     253                 :            : { return flatcc_builder_create_string(B, string, NS ## string_len(string)); }\
     254                 :            : static inline NS ## string_ref_t NS ## string_slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\
     255                 :            : { size_t n = NS ## string_len(string); if (index >= n) index = n; n -= index; if (len > n) len = n;\
     256                 :            :   return flatcc_builder_create_string(B, string + index, len); }\
     257                 :            : __flatbuffers_build_string_ops(NS, NS ## string)\
     258                 :            : __flatbuffers_build_offset_vector(NS, NS ## string)
     259                 :            : 
     260                 :            : #define __flatbuffers_copy_from_pe(P, P2, N) (*(P) = N ## _cast_from_pe(*P2), (P))
     261                 :            : #define __flatbuffers_from_pe(P, N) (*(P) = N ## _cast_from_pe(*P), (P))
     262                 :            : #define __flatbuffers_copy_to_pe(P, P2, N) (*(P) = N ## _cast_to_pe(*P2), (P))
     263                 :            : #define __flatbuffers_to_pe(P, N) (*(P) = N ## _cast_to_pe(*P), (P))
     264                 :            : #define __flatbuffers_define_scalar_primitives(NS, N, T)\
     265                 :            : static inline T *N ## _from_pe(T *p) { return __ ## NS ## from_pe(p, N); }\
     266                 :            : static inline T *N ## _to_pe(T *p) { return __ ## NS ## to_pe(p, N); }\
     267                 :            : static inline T *N ## _copy(T *p, const T *p2) { *p = *p2; return p; }\
     268                 :            : static inline T *N ## _copy_from_pe(T *p, const T *p2)\
     269                 :            : { return __ ## NS ## copy_from_pe(p, p2, N); }\
     270                 :            : static inline T *N ## _copy_to_pe(T *p, const T *p2) \
     271                 :            : { return __ ## NS ## copy_to_pe(p, p2, N); }\
     272                 :            : static inline T *N ## _assign(T *p, const T v0) { *p = v0; return p; }\
     273                 :            : static inline T *N ## _assign_from_pe(T *p, T v0)\
     274                 :            : { *p = N ## _cast_from_pe(v0); return p; }\
     275                 :            : static inline T *N ## _assign_to_pe(T *p, T v0)\
     276                 :            : { *p = N ## _cast_to_pe(v0); return p; }
     277                 :            : #define __flatbuffers_build_scalar(NS, N, T)\
     278                 :            : __ ## NS ## define_scalar_primitives(NS, N, T)\
     279                 :            : __ ## NS ## build_vector(NS, N, T, sizeof(T), sizeof(T))
     280                 :            : /* Depends on generated copy_to/from_pe functions, and the type. */
     281                 :            : #define __flatbuffers_define_struct_primitives(NS, N)\
     282                 :            : static inline N ## _t *N ##_to_pe(N ## _t *p)\
     283                 :            : { if (!NS ## is_native_pe()) { N ## _copy_to_pe(p, p); }; return p; }\
     284                 :            : static inline N ## _t *N ##_from_pe(N ## _t *p)\
     285                 :            : { if (!NS ## is_native_pe()) { N ## _copy_from_pe(p, p); }; return p; }\
     286                 :            : static inline N ## _t *N ## _clear(N ## _t *p) { return memset(p, 0, N ## __size()); }
     287                 :            : 
     288                 :            : /* Depends on generated copy/assign_to/from_pe functions, and the type. */
     289                 :            : #define __flatbuffers_build_struct(NS, N, S, A, FID, TFID)\
     290                 :            : __ ## NS ## define_struct_primitives(NS, N)\
     291                 :            : typedef NS ## ref_t N ## _ref_t;\
     292                 :            : static inline N ## _t *N ## _start(NS ## builder_t *B)\
     293                 :            : { return flatcc_builder_start_struct(B, S, A); }\
     294                 :            : static inline N ## _ref_t N ## _end(NS ## builder_t *B)\
     295                 :            : { if (!NS ## is_native_pe()) { N ## _to_pe(flatcc_builder_struct_edit(B)); }\
     296                 :            :   return flatcc_builder_end_struct(B); }\
     297                 :            : static inline N ## _ref_t N ## _end_pe(NS ## builder_t *B)\
     298                 :            : { return flatcc_builder_end_struct(B); }\
     299                 :            : static inline N ## _ref_t N ## _create(NS ## builder_t *B __ ## N ## _formal_args)\
     300                 :            : { N ## _t *_p = N ## _start(B); if (!_p) return 0; N ##_assign_to_pe(_p __ ## N ## _call_args);\
     301                 :            :   return N ## _end_pe(B); }\
     302                 :            : __flatbuffers_build_vector(NS, N, N ## _t, S, A)\
     303                 :            : __flatbuffers_build_struct_root(NS, N, A, FID, TFID)
     304                 :            : 
     305                 :            : #define __flatbuffers_build_table(NS, N, K)\
     306                 :            : typedef NS ## ref_t N ## _ref_t;\
     307                 :            : static inline int N ## _start(NS ## builder_t *B)\
     308                 :            : { return flatcc_builder_start_table(B, K); }\
     309                 :            : static inline N ## _ref_t N ## _end(NS ## builder_t *B)\
     310                 :            : { assert(flatcc_builder_check_required(B, __ ## N ## _required,\
     311                 :            :   sizeof(__ ## N ## _required) / sizeof(__ ## N ## _required[0]) - 1));\
     312                 :            :   return flatcc_builder_end_table(B); }\
     313                 :            : __flatbuffers_build_offset_vector(NS, N)
     314                 :            : 
     315                 :            : #define __flatbuffers_build_table_field(ID, NS, N, TN)\
     316                 :            : static inline int N ## _add(NS ## builder_t *B, TN ## _ref_t ref)\
     317                 :            : { TN ## _ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ?\
     318                 :            :   ((*_p = ref), 0) : -1; }\
     319                 :            : static inline int N ## _start(NS ## builder_t *B)\
     320                 :            : { return TN ## _start(B); }\
     321                 :            : static inline int N ## _end(NS ## builder_t *B)\
     322                 :            : { return N ## _add(B, TN ## _end(B)); }\
     323                 :            : static inline TN ## _ref_t N ## _create(NS ## builder_t *B __ ## TN ##_formal_args)\
     324                 :            : { return N ## _add(B, TN ## _create(B __ ## TN ## _call_args)); }
     325                 :            : 
     326                 :            : #define __flatbuffers_build_union_field(ID, NS, N, TN)\
     327                 :            : static inline int N ## _add(NS ## builder_t *B, TN ## _union_ref_t uref)\
     328                 :            : { NS ## ref_t *_p; TN ## _union_type_t *_pt; if (uref.type == TN ## _NONE) return 0; if (uref._member == 0) return -1;\
     329                 :            :   if (!(_pt = flatcc_builder_table_add(B, ID - 1, sizeof(*_pt), sizeof(_pt))) ||\
     330                 :            :   !(_p = flatcc_builder_table_add_offset(B, ID))) return -1; *_pt = uref.type; *_p = uref._member; return 0; }\
     331                 :            : static inline int N ## _add_type(NS ## builder_t *B, TN ## _union_type_t type)\
     332                 :            : { TN ## _union_type_t *_pt; if (type == TN ## _NONE) return 0; return (_pt = flatcc_builder_table_add(B, ID - 1,\
     333                 :            :   sizeof(*_pt), sizeof(*_pt))) ? ((*_pt = type), 0) : -1; }\
     334                 :            : static inline int N ## _add_member(NS ## builder_t *B, TN ## _union_ref_t uref)\
     335                 :            : { NS ## ref_t *p; if (uref.type == TN ## _NONE) return 0; return (p = flatcc_builder_table_add_offset(B, ID)) ?\
     336                 :            :   ((*p = uref._member), 0) : -1; }
     337                 :            : 
     338                 :            : /* M is the union member name and T is its type, i.e. the qualified name. */
     339                 :            : #define __flatbuffers_build_union_member_field(NS, N, NU, M, T)\
     340                 :            : static inline int N ## _ ## M ## _add(NS ## builder_t *B, T ## _ref_t ref)\
     341                 :            : { return N ## _add(B, NU ## _as_ ## M (ref)); }\
     342                 :            : static inline int N ## _ ## M ## _start(NS ## builder_t *B)\
     343                 :            : { return T ## _start(B); }\
     344                 :            : static inline int N ## _ ## M ## _end(NS ## builder_t *B)\
     345                 :            : { return N ## _ ## M ## _add(B, T ## _end(B)); }
     346                 :            : 
     347                 :            : /* NS: common namespace, ID: table field id (not offset), TN: name of type T,
     348                 :            :  * S: sizeof of scalar type, A: alignment of type T, default value V of type T. */
     349                 :            : #define __flatbuffers_build_scalar_field(ID, NS, N, TN, T, S, A, V)\
     350                 :            : static inline int N ## _add(NS ## builder_t *B, const T v)\
     351                 :            : { T *_p; if (v == V) return 0; if (!(_p = flatcc_builder_table_add(B, ID, S, A))) return -1;\
     352                 :            :   TN ## _assign_to_pe(_p, v); return 0; }\
     353                 :            : static inline int N ## _force_add(NS ## builder_t *B, const T v)\
     354                 :            : { T *_p; if (!(_p = flatcc_builder_table_add(B, ID, S, A))) return -1;\
     355                 :            :   TN ## _assign_to_pe(_p, v); return 0; }\
     356                 :            : 
     357                 :            : #define __flatbuffers_build_struct_field(ID, NS, N, TN, S, A)\
     358                 :            : static inline TN ## _t *N ## _start(NS ## builder_t *B)\
     359                 :            : { return flatcc_builder_table_add(B, ID, S, A); }\
     360                 :            : static inline int N ## _end(NS ## builder_t *B)\
     361                 :            : { if (!NS ## is_native_pe()) { TN ## _to_pe(flatcc_builder_table_edit(B, S)); } return 0; }\
     362                 :            : static inline int N ## _end_pe(NS ## builder_t *B) { return 0; }\
     363                 :            : static inline int N ## _create(NS ## builder_t *B __ ## TN ## _formal_args)\
     364                 :            : { TN ## _t *_p = N ## _start(B); if (!_p) return 0; TN ##_assign_to_pe(_p __ ## TN ## _call_args);\
     365                 :            :  return 0; }\
     366                 :            : static inline int N ## _add(NS ## builder_t *B, const TN ## _t *p)\
     367                 :            : { TN ## _t *_p = N ## _start(B); if (!_p) return -1; TN ##_copy_to_pe(_p, p); return 0; }\
     368                 :            : static inline int N ## _clone(NS ## builder_t *B, TN ## _struct_t p)\
     369                 :            : { return 0 == flatcc_builder_table_add_copy(B, ID, p, S, A) ? -1 : 0; }
     370                 :            : 
     371                 :            : #define __flatbuffers_build_vector_field(ID, NS, N, TN, T)\
     372                 :            : static inline int N ## _add(NS ## builder_t *B, TN ## _vec_ref_t ref)\
     373                 :            : { TN ## _vec_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\
     374                 :            : static inline int N ## _start(NS ## builder_t *B)\
     375                 :            : { return TN ## _vec_start(B); }\
     376                 :            : static inline int N ## _end_pe(NS ## builder_t *B)\
     377                 :            : { return N ## _add(B, TN ## _vec_end_pe(B)); }\
     378                 :            : static inline int N ## _end(NS ## builder_t *B)\
     379                 :            : { return N ## _add(B, TN ## _vec_end(B)); }\
     380                 :            : static inline int N ## _create_pe(NS ## builder_t *B, T *data, size_t len)\
     381                 :            : { return N ## _add(B, TN ## _vec_create_pe(B, data, len)); }\
     382                 :            : static inline int N ## _create(NS ## builder_t *B, T *data, size_t len)\
     383                 :            : { return N ## _add(B, TN ## _vec_create(B, data, len)); }\
     384                 :            : static inline int N ## _clone(NS ## builder_t *B, TN ## _vec_t vec)\
     385                 :            : { return N ## _add(B, TN ## _vec_clone(B, vec)); }\
     386                 :            : static inline int N ## _slice(NS ## builder_t *B, TN ## _vec_t vec, size_t index, size_t len)\
     387                 :            : { return N ## _add(B, TN ## _vec_slice(B, vec, index, len)); }\
     388                 :            : __flatbuffers_build_vector_ops(NS, N, N, TN, T)
     389                 :            : 
     390                 :            : #define __flatbuffers_build_offset_vector_field(ID, NS, N, TN)\
     391                 :            : static inline int N ## _add(NS ## builder_t *B, TN ## _vec_ref_t ref)\
     392                 :            : { TN ## _vec_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\
     393                 :            : static inline int N ## _start(NS ## builder_t *B)\
     394                 :            : { return flatcc_builder_start_offset_vector(B); }\
     395                 :            : static inline int N ## _end(NS ## builder_t *B)\
     396                 :            : { return N ## _add(B, flatcc_builder_end_offset_vector(B)); }\
     397                 :            : static inline int N ## _create(NS ## builder_t *B, const TN ## _ref_t *data, size_t len)\
     398                 :            : { return N ## _add(B, flatcc_builder_create_offset_vector(B, data, len)); }\
     399                 :            : __flatbuffers_build_offset_vector_ops(NS, N, N, TN)
     400                 :            : 
     401                 :            : #define __flatbuffers_build_string_field(ID, NS, N)\
     402                 :            : static inline int N ## _add(NS ## builder_t *B, NS ## string_ref_t ref)\
     403                 :            : { NS ## string_ref_t *_p; return (ref && (_p = flatcc_builder_table_add_offset(B, ID))) ? ((*_p = ref), 0) : -1; }\
     404                 :            : static inline int N ## _start(NS ## builder_t *B)\
     405                 :            : { return flatcc_builder_start_string(B); }\
     406                 :            : static inline int N ## _end(NS ## builder_t *B)\
     407                 :            : { return N ## _add(B, flatcc_builder_end_string(B)); }\
     408                 :            : static inline int N ## _create(NS ## builder_t *B, const char *s, size_t len)\
     409                 :            : { return N ## _add(B, flatcc_builder_create_string(B, s, len)); }\
     410                 :            : static inline int N ## _create_str(NS ## builder_t *B, const char *s)\
     411                 :            : { return N ## _add(B, flatcc_builder_create_string_str(B, s)); }\
     412                 :            : static inline int N ## _create_strn(NS ## builder_t *B, const char *s, size_t max_len)\
     413                 :            : { return N ## _add(B, flatcc_builder_create_string_strn(B, s, max_len)); }\
     414                 :            : static inline int N ## _clone(NS ## builder_t *B, NS ## string_t string)\
     415                 :            : { return N ## _add(B, NS ## string_clone(B, string)); }\
     416                 :            : static inline int N ## _slice(NS ## builder_t *B, NS ## string_t string, size_t index, size_t len)\
     417                 :            : { return N ## _add(B, NS ## string_slice(B, string, index, len)); }\
     418                 :            : __flatbuffers_build_string_ops(NS, N)
     419                 :            : 
     420                 :            : #define __flatbuffers_build_table_vector_field(ID, NS, N, TN)\
     421                 :            : __flatbuffers_build_offset_vector_field(ID, NS, N, TN)\
     422                 :            : __flatbuffers_build_table_vector_ops(NS, N, TN)
     423                 :            : 
     424                 :            : #define __flatbuffers_build_string_vector_field(ID, NS, N)\
     425                 :            : __flatbuffers_build_offset_vector_field(ID, NS, N, NS ## string)\
     426                 :            : __flatbuffers_build_string_vector_ops(NS, N)
     427                 :            : 
     428                 :            : #define __flatbuffers_uint8_formal_args , uint8_t v0
     429                 :            : #define __flatbuffers_uint8_call_args , v0
     430                 :            : #define __flatbuffers_int8_formal_args , int8_t v0
     431                 :            : #define __flatbuffers_int8_call_args , v0
     432                 :            : #define __flatbuffers_bool_formal_args , flatbuffers_bool_t v0
     433                 :            : #define __flatbuffers_bool_call_args , v0
     434                 :            : #define __flatbuffers_uint16_formal_args , uint16_t v0
     435                 :            : #define __flatbuffers_uint16_call_args , v0
     436                 :            : #define __flatbuffers_uint32_formal_args , uint32_t v0
     437                 :            : #define __flatbuffers_uint32_call_args , v0
     438                 :            : #define __flatbuffers_uint64_formal_args , uint64_t v0
     439                 :            : #define __flatbuffers_uint64_call_args , v0
     440                 :            : #define __flatbuffers_int16_formal_args , int16_t v0
     441                 :            : #define __flatbuffers_int16_call_args , v0
     442                 :            : #define __flatbuffers_int32_formal_args , int32_t v0
     443                 :            : #define __flatbuffers_int32_call_args , v0
     444                 :            : #define __flatbuffers_int64_formal_args , int64_t v0
     445                 :            : #define __flatbuffers_int64_call_args , v0
     446                 :            : #define __flatbuffers_float_formal_args , float v0
     447                 :            : #define __flatbuffers_float_call_args , v0
     448                 :            : #define __flatbuffers_double_formal_args , double v0
     449                 :            : #define __flatbuffers_double_call_args , v0
     450                 :            : 
     451                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint8, uint8_t)
     452                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int8, int8_t)
     453                 :         12 : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_bool, flatbuffers_bool_t)
     454                 :        108 : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint16, uint16_t)
     455                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint32, uint32_t)
     456                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_uint64, uint64_t)
     457                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int16, int16_t)
     458                 :         21 : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int32, int32_t)
     459                 :         20 : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_int64, int64_t)
     460                 :            : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_float, float)
     461                 :          0 : __flatbuffers_build_scalar(flatbuffers_, flatbuffers_double, double)
     462                 :            : 
     463                 :            : __flatbuffers_build_string(flatbuffers_)
     464                 :            : 
     465                 :          4 : __flatbuffers_build_buffer(flatbuffers_)
     466                 :            : #include "flatcc/portable/pdiagnostic_pop.h"
     467                 :            : #endif /* FLATBUFFERS_COMMON_BUILDER_H */

Generated by: LCOV version 1.12