1
0
mirror of git://jb55.com/damus synced 2024-09-05 21:03:51 +00:00

flatbuffers: update bindings, add verifier

This commit is contained in:
William Casarin 2023-08-28 08:17:25 -07:00
parent 984c7b6932
commit ba6792640d
24 changed files with 434 additions and 77 deletions

View File

@ -5,9 +5,9 @@
/* Common FlatBuffers build functionality for C. */
#include "flatcc/flatcc_prologue.h"
#include "flatcc_prologue.h"
#ifndef FLATBUILDER_H
#include "flatcc/flatcc_builder.h"
#include "flatcc_builder.h"
#endif
typedef flatcc_builder_t flatbuffers_builder_t;
typedef flatcc_builder_ref_t flatbuffers_ref_t;
@ -681,5 +681,5 @@ __flatbuffers_build_scalar(flatbuffers_, flatbuffers_double, double)
__flatbuffers_build_string(flatbuffers_)
__flatbuffers_build_buffer(flatbuffers_)
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* FLATBUFFERS_COMMON_BUILDER_H */

View File

@ -9,7 +9,7 @@
#ifndef FLATBUFFERS_COMMON_BUILDER_H
#include "flatbuffers_common_builder.h"
#endif
#include "flatcc/flatcc_prologue.h"
#include "flatcc_prologue.h"
#ifndef flatbuffers_identifier
#define flatbuffers_identifier 0
#endif
@ -48,5 +48,5 @@ static NdbEventMeta_ref_t NdbEventMeta_clone(flatbuffers_builder_t *B, NdbEventM
__flatbuffers_memoize_end(B, t, NdbEventMeta_end(B));
}
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* META_BUILDER_H */

View File

@ -3,8 +3,8 @@
/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */
#include "flatcc/flatcc_json_parser.h"
#include "flatcc/flatcc_prologue.h"
#include "flatcc_json_parser.h"
#include "flatcc_prologue.h"
/*
* Parses the default root table or struct of the schema and constructs a FlatBuffer.
@ -112,5 +112,5 @@ static int meta_parse_json(flatcc_builder_t *B, flatcc_json_parser_t *ctx,
return 0;
}
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* META_JSON_PARSER_H */

View File

@ -6,11 +6,11 @@
#ifndef FLATBUFFERS_COMMON_READER_H
#include "flatbuffers_common_reader.h"
#endif
#include "flatcc/flatcc_flatbuffers.h"
#include "flatcc_flatbuffers.h"
#ifndef __alignas_is_defined
#include <stdalign.h>
#endif
#include "flatcc/flatcc_prologue.h"
#include "flatcc_prologue.h"
#ifndef flatbuffers_identifier
#define flatbuffers_identifier 0
#endif
@ -49,5 +49,5 @@ __flatbuffers_table_as_root(NdbEventMeta)
__flatbuffers_define_scalar_field(0, NdbEventMeta, received_at, flatbuffers_int32, int32_t, INT32_C(0))
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* META_READER_H */

View File

@ -6,8 +6,8 @@
#ifndef META_READER_H
#include "meta_reader.h"
#endif
#include "flatcc/flatcc_verifier.h"
#include "flatcc/flatcc_prologue.h"
#include "flatcc_verifier.h"
#include "flatcc_prologue.h"
static int NdbEventMeta_verify_table(flatcc_table_verifier_descriptor_t *td);
@ -38,5 +38,5 @@ static inline int NdbEventMeta_verify_as_root_with_type_hash(const void *buf, si
return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &NdbEventMeta_verify_table);
}
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* META_VERIFIER_H */

View File

@ -9,7 +9,7 @@
#ifndef FLATBUFFERS_COMMON_BUILDER_H
#include "flatbuffers_common_builder.h"
#endif
#include "flatcc/flatcc_prologue.h"
#include "flatcc_prologue.h"
#ifndef flatbuffers_identifier
#define flatbuffers_identifier 0
#endif
@ -20,19 +20,29 @@
static const flatbuffers_voffset_t __NdbProfile_required[] = { 0 };
typedef flatbuffers_ref_t NdbProfile_ref_t;
static NdbProfile_ref_t NdbProfile_clone(flatbuffers_builder_t *B, NdbProfile_table_t t);
__flatbuffers_build_table(flatbuffers_, NdbProfile, 11)
__flatbuffers_build_table(flatbuffers_, NdbProfile, 12)
static const flatbuffers_voffset_t __NdbProfileRecord_required[] = { 0 };
typedef flatbuffers_ref_t NdbProfileRecord_ref_t;
static NdbProfileRecord_ref_t NdbProfileRecord_clone(flatbuffers_builder_t *B, NdbProfileRecord_table_t t);
__flatbuffers_build_table(flatbuffers_, NdbProfileRecord, 4)
#define __NdbProfile_formal_args ,\
flatbuffers_string_ref_t v0, flatbuffers_string_ref_t v1, flatbuffers_string_ref_t v2, flatbuffers_string_ref_t v3,\
flatbuffers_string_ref_t v4, flatbuffers_string_ref_t v5, flatbuffers_bool_t v6, flatbuffers_string_ref_t v7,\
flatbuffers_string_ref_t v8, int32_t v9, int32_t v10
flatbuffers_string_ref_t v8, int32_t v9, int32_t v10, flatbuffers_string_ref_t v11
#define __NdbProfile_call_args ,\
v0, v1, v2, v3,\
v4, v5, v6, v7,\
v8, v9, v10
v8, v9, v10, v11
static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbProfile_formal_args);
__flatbuffers_build_table_prolog(flatbuffers_, NdbProfile, NdbProfile_file_identifier, NdbProfile_type_identifier)
#define __NdbProfileRecord_formal_args , NdbProfile_ref_t v0, uint64_t v1, uint64_t v2, flatbuffers_string_ref_t v3
#define __NdbProfileRecord_call_args , v0, v1, v2, v3
static inline NdbProfileRecord_ref_t NdbProfileRecord_create(flatbuffers_builder_t *B __NdbProfileRecord_formal_args);
__flatbuffers_build_table_prolog(flatbuffers_, NdbProfileRecord, NdbProfileRecord_file_identifier, NdbProfileRecord_type_identifier)
__flatbuffers_build_string_field(0, flatbuffers_, NdbProfile_name, NdbProfile)
__flatbuffers_build_string_field(1, flatbuffers_, NdbProfile_website, NdbProfile)
__flatbuffers_build_string_field(2, flatbuffers_, NdbProfile_about, NdbProfile)
@ -44,6 +54,7 @@ __flatbuffers_build_string_field(7, flatbuffers_, NdbProfile_picture, NdbProfile
__flatbuffers_build_string_field(8, flatbuffers_, NdbProfile_nip05, NdbProfile)
__flatbuffers_build_scalar_field(9, flatbuffers_, NdbProfile_damus_donation, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile)
__flatbuffers_build_scalar_field(10, flatbuffers_, NdbProfile_damus_donation_v2, flatbuffers_int32, int32_t, 4, 4, INT32_C(0), NdbProfile)
__flatbuffers_build_string_field(11, flatbuffers_, NdbProfile_lud06, NdbProfile)
static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbProfile_formal_args)
{
@ -58,6 +69,7 @@ static inline NdbProfile_ref_t NdbProfile_create(flatbuffers_builder_t *B __NdbP
|| NdbProfile_nip05_add(B, v8)
|| NdbProfile_damus_donation_add(B, v9)
|| NdbProfile_damus_donation_v2_add(B, v10)
|| NdbProfile_lud06_add(B, v11)
|| NdbProfile_reactions_add(B, v6)) {
return 0;
}
@ -78,11 +90,42 @@ static NdbProfile_ref_t NdbProfile_clone(flatbuffers_builder_t *B, NdbProfile_ta
|| NdbProfile_nip05_pick(B, t)
|| NdbProfile_damus_donation_pick(B, t)
|| NdbProfile_damus_donation_v2_pick(B, t)
|| NdbProfile_lud06_pick(B, t)
|| NdbProfile_reactions_pick(B, t)) {
return 0;
}
__flatbuffers_memoize_end(B, t, NdbProfile_end(B));
}
#include "flatcc/flatcc_epilogue.h"
__flatbuffers_build_table_field(0, flatbuffers_, NdbProfileRecord_profile, NdbProfile, NdbProfileRecord)
__flatbuffers_build_scalar_field(1, flatbuffers_, NdbProfileRecord_received_at, flatbuffers_uint64, uint64_t, 8, 8, UINT64_C(0), NdbProfileRecord)
__flatbuffers_build_scalar_field(2, flatbuffers_, NdbProfileRecord_note_key, flatbuffers_uint64, uint64_t, 8, 8, UINT64_C(0), NdbProfileRecord)
__flatbuffers_build_string_field(3, flatbuffers_, NdbProfileRecord_lnurl, NdbProfileRecord)
static inline NdbProfileRecord_ref_t NdbProfileRecord_create(flatbuffers_builder_t *B __NdbProfileRecord_formal_args)
{
if (NdbProfileRecord_start(B)
|| NdbProfileRecord_received_at_add(B, v1)
|| NdbProfileRecord_note_key_add(B, v2)
|| NdbProfileRecord_profile_add(B, v0)
|| NdbProfileRecord_lnurl_add(B, v3)) {
return 0;
}
return NdbProfileRecord_end(B);
}
static NdbProfileRecord_ref_t NdbProfileRecord_clone(flatbuffers_builder_t *B, NdbProfileRecord_table_t t)
{
__flatbuffers_memoize_begin(B, t);
if (NdbProfileRecord_start(B)
|| NdbProfileRecord_received_at_pick(B, t)
|| NdbProfileRecord_note_key_pick(B, t)
|| NdbProfileRecord_profile_pick(B, t)
|| NdbProfileRecord_lnurl_pick(B, t)) {
return 0;
}
__flatbuffers_memoize_end(B, t, NdbProfileRecord_end(B));
}
#include "flatcc_epilogue.h"
#endif /* PROFILE_BUILDER_H */

View File

@ -19,6 +19,7 @@ static int profile_parse_json(flatcc_builder_t *B, flatcc_json_parser_t *ctx,
const char *buf, size_t bufsiz, int flags);
static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const char *buf, const char *end, flatcc_builder_ref_t *result);
static const char *NdbProfileRecord_parse_json_table(flatcc_json_parser_t *ctx, const char *buf, const char *end, flatcc_builder_ref_t *result);
static const char *profile_local_json_parser_enum(flatcc_json_parser_t *ctx, const char *buf, const char *end,
int *value_type, uint64_t *value, int *aggregate);
static const char *profile_global_json_parser_enum(flatcc_json_parser_t *ctx, const char *buf, const char *end,
@ -33,12 +34,12 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const
uint64_t w;
*result = 0;
if (flatcc_builder_start_table(ctx->ctx, 11)) goto failed;
if (flatcc_builder_start_table(ctx->ctx, 12)) goto failed;
buf = flatcc_json_parser_object_start(ctx, buf, end, &more);
while (more) {
buf = flatcc_json_parser_symbol_start(ctx, buf, end);
w = flatcc_json_parser_symbol_part(buf, end);
if (w < 0x6c75643136000000) { /* branch "lud16" */
if (w < 0x6c75643036000000) { /* branch "lud06" */
if (w < 0x64616d75735f646f) { /* branch "damus_do" */
if ((w & 0xffffffffffff0000) == 0x62616e6e65720000) { /* "banner" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 6);
@ -137,31 +138,46 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const
} /* descend "display_" */
} /* descend "damus_do" */
} /* branch "damus_do" */
} else { /* branch "lud16" */
} else { /* branch "lud06" */
if (w < 0x6e69703035000000) { /* branch "nip05" */
if ((w & 0xffffffff00000000) == 0x6e616d6500000000) { /* "name" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 4);
if (mark != buf) {
buf = flatcc_json_parser_build_string(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 0))) goto failed;
*pref = ref;
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "name" */
if ((w & 0xffffffffff000000) == 0x6c75643136000000) { /* "lud16" */
if (w < 0x6c75643136000000) { /* branch "lud16" */
if ((w & 0xffffffffff000000) == 0x6c75643036000000) { /* "lud06" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 5);
if (mark != buf) {
buf = flatcc_json_parser_build_string(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 3))) goto failed;
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 11))) goto failed;
*pref = ref;
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "lud16" */
} else { /* "lud06" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* "lud16" */
} /* "name" */
} /* "lud06" */
} else { /* branch "lud16" */
if ((w & 0xffffffff00000000) == 0x6e616d6500000000) { /* "name" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 4);
if (mark != buf) {
buf = flatcc_json_parser_build_string(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 0))) goto failed;
*pref = ref;
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "name" */
if ((w & 0xffffffffff000000) == 0x6c75643136000000) { /* "lud16" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 5);
if (mark != buf) {
buf = flatcc_json_parser_build_string(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 3))) goto failed;
*pref = ref;
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "lud16" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* "lud16" */
} /* "name" */
} /* branch "lud16" */
} else { /* branch "nip05" */
if (w < 0x7069637475726500) { /* branch "picture" */
if ((w & 0xffffffffff000000) == 0x6e69703035000000) { /* "nip05" */
@ -233,7 +249,7 @@ static const char *NdbProfile_parse_json_table(flatcc_json_parser_t *ctx, const
} /* branch "reaction" */
} /* branch "picture" */
} /* branch "nip05" */
} /* branch "lud16" */
} /* branch "lud06" */
buf = flatcc_json_parser_object_end(ctx, buf, end, &more);
}
if (ctx->error) goto failed;
@ -248,6 +264,118 @@ static inline int NdbProfile_parse_json_as_root(flatcc_builder_t *B, flatcc_json
return flatcc_json_parser_table_as_root(B, ctx, buf, bufsiz, flags, fid, NdbProfile_parse_json_table);
}
static const char *NdbProfileRecord_parse_json_table(flatcc_json_parser_t *ctx, const char *buf, const char *end, flatcc_builder_ref_t *result)
{
int more;
void *pval;
flatcc_builder_ref_t ref, *pref;
const char *mark;
uint64_t w;
*result = 0;
if (flatcc_builder_start_table(ctx->ctx, 4)) goto failed;
buf = flatcc_json_parser_object_start(ctx, buf, end, &more);
while (more) {
buf = flatcc_json_parser_symbol_start(ctx, buf, end);
w = flatcc_json_parser_symbol_part(buf, end);
if (w < 0x6e6f74655f6b6579) { /* branch "note_key" */
if ((w & 0xffffffffff000000) == 0x6c6e75726c000000) { /* "lnurl" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 5);
if (mark != buf) {
buf = flatcc_json_parser_build_string(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 3))) goto failed;
*pref = ref;
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "lnurl" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* "lnurl" */
} else { /* branch "note_key" */
if (w < 0x70726f66696c6500) { /* branch "profile" */
if (w == 0x6e6f74655f6b6579) { /* "note_key" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 8);
if (mark != buf) {
uint64_t val = 0;
static flatcc_json_parser_integral_symbol_f *symbolic_parsers[] = {
profile_local_json_parser_enum,
profile_global_json_parser_enum, 0 };
buf = flatcc_json_parser_uint64(ctx, (mark = buf), end, &val);
if (mark == buf) {
buf = flatcc_json_parser_symbolic_uint64(ctx, (mark = buf), end, symbolic_parsers, &val);
if (buf == mark || buf == end) goto failed;
}
if (val != UINT64_C(0) || (ctx->flags & flatcc_json_parser_f_force_add)) {
if (!(pval = flatcc_builder_table_add(ctx->ctx, 2, 8, 8))) goto failed;
flatbuffers_uint64_write_to_pe(pval, val);
}
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "note_key" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* "note_key" */
} else { /* branch "profile" */
if ((w & 0xffffffffffffff00) == 0x70726f66696c6500) { /* "profile" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 7);
if (mark != buf) {
buf = NdbProfile_parse_json_table(ctx, buf, end, &ref);
if (!ref || !(pref = flatcc_builder_table_add_offset(ctx->ctx, 0))) goto failed;
*pref = ref;
} else {
goto pfguard1;
}
} else { /* "profile" */
goto pfguard1;
} /* "profile" */
goto endpfguard1;
pfguard1:
if (w == 0x7265636569766564) { /* descend "received" */
buf += 8;
w = flatcc_json_parser_symbol_part(buf, end);
if ((w & 0xffffff0000000000) == 0x5f61740000000000) { /* "_at" */
buf = flatcc_json_parser_match_symbol(ctx, (mark = buf), end, 3);
if (mark != buf) {
uint64_t val = 0;
static flatcc_json_parser_integral_symbol_f *symbolic_parsers[] = {
profile_local_json_parser_enum,
profile_global_json_parser_enum, 0 };
buf = flatcc_json_parser_uint64(ctx, (mark = buf), end, &val);
if (mark == buf) {
buf = flatcc_json_parser_symbolic_uint64(ctx, (mark = buf), end, symbolic_parsers, &val);
if (buf == mark || buf == end) goto failed;
}
if (val != UINT64_C(0) || (ctx->flags & flatcc_json_parser_f_force_add)) {
if (!(pval = flatcc_builder_table_add(ctx->ctx, 1, 8, 8))) goto failed;
flatbuffers_uint64_write_to_pe(pval, val);
}
} else {
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
}
} else { /* "_at" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* "_at" */
} else { /* descend "received" */
buf = flatcc_json_parser_unmatched_symbol(ctx, buf, end);
} /* descend "received" */
endpfguard1:
(void)0;
} /* branch "profile" */
} /* branch "note_key" */
buf = flatcc_json_parser_object_end(ctx, buf, end, &more);
}
if (ctx->error) goto failed;
if (!(*result = flatcc_builder_end_table(ctx->ctx))) goto failed;
return buf;
failed:
return flatcc_json_parser_set_error(ctx, buf, end, flatcc_json_parser_error_runtime);
}
static inline int NdbProfileRecord_parse_json_as_root(flatcc_builder_t *B, flatcc_json_parser_t *ctx, const char *buf, size_t bufsiz, int flags, const char *fid)
{
return flatcc_json_parser_table_as_root(B, ctx, buf, bufsiz, flags, fid, NdbProfileRecord_parse_json_table);
}
static const char *profile_local_json_parser_enum(flatcc_json_parser_t *ctx, const char *buf, const char *end,
int *value_type, uint64_t *value, int *aggregate)
{
@ -271,7 +399,7 @@ static int profile_parse_json(flatcc_builder_t *B, flatcc_json_parser_t *ctx,
ctx = ctx ? ctx : &parser;
flatcc_json_parser_init(ctx, B, buf, buf + bufsiz, flags);
if (flatcc_builder_start_buffer(B, 0, 0, 0)) return -1;
NdbProfile_parse_json_table(ctx, buf, buf + bufsiz, &root);
NdbProfileRecord_parse_json_table(ctx, buf, buf + bufsiz, &root);
if (ctx->error) {
return ctx->error;
}

View File

@ -6,11 +6,11 @@
#ifndef FLATBUFFERS_COMMON_READER_H
#include "flatbuffers_common_reader.h"
#endif
#include "flatcc/flatcc_flatbuffers.h"
#include "flatcc_flatbuffers.h"
#ifndef __alignas_is_defined
#include <stdalign.h>
#endif
#include "flatcc/flatcc_prologue.h"
#include "flatcc_prologue.h"
#ifndef flatbuffers_identifier
#define flatbuffers_identifier 0
#endif
@ -23,6 +23,10 @@ typedef const struct NdbProfile_table *NdbProfile_table_t;
typedef struct NdbProfile_table *NdbProfile_mutable_table_t;
typedef const flatbuffers_uoffset_t *NdbProfile_vec_t;
typedef flatbuffers_uoffset_t *NdbProfile_mutable_vec_t;
typedef const struct NdbProfileRecord_table *NdbProfileRecord_table_t;
typedef struct NdbProfileRecord_table *NdbProfileRecord_mutable_table_t;
typedef const flatbuffers_uoffset_t *NdbProfileRecord_vec_t;
typedef flatbuffers_uoffset_t *NdbProfileRecord_mutable_vec_t;
#ifndef NdbProfile_file_identifier
#define NdbProfile_file_identifier 0
#endif
@ -35,6 +39,18 @@ typedef flatbuffers_uoffset_t *NdbProfile_mutable_vec_t;
#ifndef NdbProfile_file_extension
#define NdbProfile_file_extension "bin"
#endif
#ifndef NdbProfileRecord_file_identifier
#define NdbProfileRecord_file_identifier 0
#endif
/* deprecated, use NdbProfileRecord_file_identifier */
#ifndef NdbProfileRecord_identifier
#define NdbProfileRecord_identifier 0
#endif
#define NdbProfileRecord_type_hash ((flatbuffers_thash_t)0xa1a8569d)
#define NdbProfileRecord_type_identifier "\x9d\x56\xa8\xa1"
#ifndef NdbProfileRecord_file_extension
#define NdbProfileRecord_file_extension "bin"
#endif
@ -57,7 +73,21 @@ __flatbuffers_define_string_field(7, NdbProfile, picture, 0)
__flatbuffers_define_string_field(8, NdbProfile, nip05, 0)
__flatbuffers_define_scalar_field(9, NdbProfile, damus_donation, flatbuffers_int32, int32_t, INT32_C(0))
__flatbuffers_define_scalar_field(10, NdbProfile, damus_donation_v2, flatbuffers_int32, int32_t, INT32_C(0))
__flatbuffers_define_string_field(11, NdbProfile, lud06, 0)
struct NdbProfileRecord_table { uint8_t unused__; };
static inline size_t NdbProfileRecord_vec_len(NdbProfileRecord_vec_t vec)
__flatbuffers_vec_len(vec)
static inline NdbProfileRecord_table_t NdbProfileRecord_vec_at(NdbProfileRecord_vec_t vec, size_t i)
__flatbuffers_offset_vec_at(NdbProfileRecord_table_t, vec, i, 0)
__flatbuffers_table_as_root(NdbProfileRecord)
__flatbuffers_define_table_field(0, NdbProfileRecord, profile, NdbProfile_table_t, 0)
__flatbuffers_define_scalar_field(1, NdbProfileRecord, received_at, flatbuffers_uint64, uint64_t, UINT64_C(0))
__flatbuffers_define_scalar_field(2, NdbProfileRecord, note_key, flatbuffers_uint64, uint64_t, UINT64_C(0))
__flatbuffers_define_string_field(3, NdbProfileRecord, lnurl, 0)
#include "flatcc/flatcc_epilogue.h"
#include "flatcc_epilogue.h"
#endif /* PROFILE_READER_H */

View File

@ -6,10 +6,11 @@
#ifndef PROFILE_READER_H
#include "profile_reader.h"
#endif
#include "flatcc/flatcc_verifier.h"
#include "flatcc/flatcc_prologue.h"
#include "flatcc_verifier.h"
#include "flatcc_prologue.h"
static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td);
static int NdbProfileRecord_verify_table(flatcc_table_verifier_descriptor_t *td);
static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td)
{
@ -25,6 +26,7 @@ static int NdbProfile_verify_table(flatcc_table_verifier_descriptor_t *td)
if ((ret = flatcc_verify_string_field(td, 8, 0) /* nip05 */)) return ret;
if ((ret = flatcc_verify_field(td, 9, 4, 4) /* damus_donation */)) return ret;
if ((ret = flatcc_verify_field(td, 10, 4, 4) /* damus_donation_v2 */)) return ret;
if ((ret = flatcc_verify_string_field(td, 11, 0) /* lud06 */)) return ret;
return flatcc_verify_ok;
}
@ -48,5 +50,35 @@ static inline int NdbProfile_verify_as_root_with_type_hash(const void *buf, size
return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &NdbProfile_verify_table);
}
#include "flatcc/flatcc_epilogue.h"
static int NdbProfileRecord_verify_table(flatcc_table_verifier_descriptor_t *td)
{
int ret;
if ((ret = flatcc_verify_table_field(td, 0, 0, &NdbProfile_verify_table) /* profile */)) return ret;
if ((ret = flatcc_verify_field(td, 1, 8, 8) /* received_at */)) return ret;
if ((ret = flatcc_verify_field(td, 2, 8, 8) /* note_key */)) return ret;
if ((ret = flatcc_verify_string_field(td, 3, 0) /* lnurl */)) return ret;
return flatcc_verify_ok;
}
static inline int NdbProfileRecord_verify_as_root(const void *buf, size_t bufsiz)
{
return flatcc_verify_table_as_root(buf, bufsiz, NdbProfileRecord_identifier, &NdbProfileRecord_verify_table);
}
static inline int NdbProfileRecord_verify_as_typed_root(const void *buf, size_t bufsiz)
{
return flatcc_verify_table_as_root(buf, bufsiz, NdbProfileRecord_type_identifier, &NdbProfileRecord_verify_table);
}
static inline int NdbProfileRecord_verify_as_root_with_identifier(const void *buf, size_t bufsiz, const char *fid)
{
return flatcc_verify_table_as_root(buf, bufsiz, fid, &NdbProfileRecord_verify_table);
}
static inline int NdbProfileRecord_verify_as_root_with_type_hash(const void *buf, size_t bufsiz, flatbuffers_thash_t thash)
{
return flatcc_verify_table_as_typed_root(buf, bufsiz, thash, &NdbProfileRecord_verify_table);
}
#include "flatcc_epilogue.h"
#endif /* PROFILE_VERIFIER_H */

View File

@ -2,6 +2,8 @@
// swiftlint:disable all
// swiftformat:disable all
public struct NdbProfile: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_26() }
@ -23,6 +25,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
case nip05 = 20
case damusDonation = 22
case damusDonationV2 = 24
case lud06 = 26
var v: Int32 { Int32(self.rawValue) }
var p: VOffset { self.rawValue }
}
@ -46,7 +49,9 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
public var nip05SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.nip05.v) }
public var damusDonation: Int32 { let o = _accessor.offset(VTOFFSET.damusDonation.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
public var damusDonationV2: Int32 { let o = _accessor.offset(VTOFFSET.damusDonationV2.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
public var lud06: String? { let o = _accessor.offset(VTOFFSET.lud06.v); return o == 0 ? nil : _accessor.string(at: o) }
public var lud06SegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lud06.v) }
public static func startNdbProfile(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 12) }
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
public static func add(website: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: website, at: VTOFFSET.website.p) }
public static func add(about: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: about, at: VTOFFSET.about.p) }
@ -59,6 +64,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
public static func add(nip05: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: nip05, at: VTOFFSET.nip05.p) }
public static func add(damusDonation: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonation, def: 0, at: VTOFFSET.damusDonation.p) }
public static func add(damusDonationV2: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damusDonationV2, def: 0, at: VTOFFSET.damusDonationV2.p) }
public static func add(lud06: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lud06, at: VTOFFSET.lud06.p) }
public static func endNdbProfile(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
public static func createNdbProfile(
_ fbb: inout FlatBufferBuilder,
@ -72,7 +78,8 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
pictureOffset picture: Offset = Offset(),
nip05Offset nip05: Offset = Offset(),
damusDonation: Int32 = 0,
damusDonationV2: Int32 = 0
damusDonationV2: Int32 = 0,
lud06Offset lud06: Offset = Offset()
) -> Offset {
let __start = NdbProfile.startNdbProfile(&fbb)
NdbProfile.add(name: name, &fbb)
@ -86,6 +93,7 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
NdbProfile.add(nip05: nip05, &fbb)
NdbProfile.add(damusDonation: damusDonation, &fbb)
NdbProfile.add(damusDonationV2: damusDonationV2, &fbb)
NdbProfile.add(lud06: lud06, &fbb)
return NdbProfile.endNdbProfile(&fbb, start: __start)
}
@ -102,7 +110,122 @@ public struct NdbProfile: FlatBufferObject, Verifiable {
try _v.visit(field: VTOFFSET.nip05.p, fieldName: "nip05", required: false, type: ForwardOffset<String>.self)
try _v.visit(field: VTOFFSET.damusDonation.p, fieldName: "damusDonation", required: false, type: Int32.self)
try _v.visit(field: VTOFFSET.damusDonationV2.p, fieldName: "damusDonationV2", required: false, type: Int32.self)
try _v.visit(field: VTOFFSET.lud06.p, fieldName: "lud06", required: false, type: ForwardOffset<String>.self)
_v.finish()
}
}
extension NdbProfile: Encodable {
enum CodingKeys: String, CodingKey {
case name = "name"
case website = "website"
case about = "about"
case lud16 = "lud16"
case banner = "banner"
case displayName = "display_name"
case reactions = "reactions"
case picture = "picture"
case nip05 = "nip05"
case damusDonation = "damus_donation"
case damusDonationV2 = "damus_donation_v2"
case lud06 = "lud06"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(name, forKey: .name)
try container.encodeIfPresent(website, forKey: .website)
try container.encodeIfPresent(about, forKey: .about)
try container.encodeIfPresent(lud16, forKey: .lud16)
try container.encodeIfPresent(banner, forKey: .banner)
try container.encodeIfPresent(displayName, forKey: .displayName)
if reactions != true {
try container.encodeIfPresent(reactions, forKey: .reactions)
}
try container.encodeIfPresent(picture, forKey: .picture)
try container.encodeIfPresent(nip05, forKey: .nip05)
if damusDonation != 0 {
try container.encodeIfPresent(damusDonation, forKey: .damusDonation)
}
if damusDonationV2 != 0 {
try container.encodeIfPresent(damusDonationV2, forKey: .damusDonationV2)
}
try container.encodeIfPresent(lud06, forKey: .lud06)
}
}
public struct NdbProfileRecord: FlatBufferObject, Verifiable {
static func validateVersion() { FlatBuffersVersion_23_5_26() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
private init(_ t: Table) { _accessor = t }
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
private enum VTOFFSET: VOffset {
case profile = 4
case receivedAt = 6
case noteKey = 8
case lnurl = 10
var v: Int32 { Int32(self.rawValue) }
var p: VOffset { self.rawValue }
}
public var profile: NdbProfile? { let o = _accessor.offset(VTOFFSET.profile.v); return o == 0 ? nil : NdbProfile(_accessor.bb, o: _accessor.indirect(o + _accessor.postion)) }
public var receivedAt: UInt64 { let o = _accessor.offset(VTOFFSET.receivedAt.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
public var noteKey: UInt64 { let o = _accessor.offset(VTOFFSET.noteKey.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
public var lnurl: String? { let o = _accessor.offset(VTOFFSET.lnurl.v); return o == 0 ? nil : _accessor.string(at: o) }
public var lnurlSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.lnurl.v) }
public static func startNdbProfileRecord(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
public static func add(profile: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: profile, at: VTOFFSET.profile.p) }
public static func add(receivedAt: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: receivedAt, def: 0, at: VTOFFSET.receivedAt.p) }
public static func add(noteKey: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: noteKey, def: 0, at: VTOFFSET.noteKey.p) }
public static func add(lnurl: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: lnurl, at: VTOFFSET.lnurl.p) }
public static func endNdbProfileRecord(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
public static func createNdbProfileRecord(
_ fbb: inout FlatBufferBuilder,
profileOffset profile: Offset = Offset(),
receivedAt: UInt64 = 0,
noteKey: UInt64 = 0,
lnurlOffset lnurl: Offset = Offset()
) -> Offset {
let __start = NdbProfileRecord.startNdbProfileRecord(&fbb)
NdbProfileRecord.add(profile: profile, &fbb)
NdbProfileRecord.add(receivedAt: receivedAt, &fbb)
NdbProfileRecord.add(noteKey: noteKey, &fbb)
NdbProfileRecord.add(lnurl: lnurl, &fbb)
return NdbProfileRecord.endNdbProfileRecord(&fbb, start: __start)
}
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
try _v.visit(field: VTOFFSET.profile.p, fieldName: "profile", required: false, type: ForwardOffset<NdbProfile>.self)
try _v.visit(field: VTOFFSET.receivedAt.p, fieldName: "receivedAt", required: false, type: UInt64.self)
try _v.visit(field: VTOFFSET.noteKey.p, fieldName: "noteKey", required: false, type: UInt64.self)
try _v.visit(field: VTOFFSET.lnurl.p, fieldName: "lnurl", required: false, type: ForwardOffset<String>.self)
_v.finish()
}
}
extension NdbProfileRecord: Encodable {
enum CodingKeys: String, CodingKey {
case profile = "profile"
case receivedAt = "received_at"
case noteKey = "note_key"
case lnurl = "lnurl"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(profile, forKey: .profile)
if receivedAt != 0 {
try container.encodeIfPresent(receivedAt, forKey: .receivedAt)
}
if noteKey != 0 {
try container.encodeIfPresent(noteKey, forKey: .noteKey)
}
try container.encodeIfPresent(lnurl, forKey: .lnurl)
}
}

View File

@ -69,7 +69,7 @@ extern "C" {
#ifndef FLATCC_USE_GENERIC_ALIGNED_ALLOC
#ifndef FLATCC_NO_PALIGNED_ALLOC
#include "paligned_alloc.h"
#include "portable/paligned_alloc.h"
#else
#if !defined(__aligned_free_is_defined) || !__aligned_free_is_defined
#define aligned_free free

View File

@ -4,5 +4,5 @@
}
#endif
#include "pdiagnostic_pop.h"
#include "portable/pdiagnostic_pop.h"

View File

@ -4,7 +4,7 @@
*
* Outside include guard to handle scope counter.
*/
#include "pstatic_assert.h"
#include "portable/pstatic_assert.h"
#ifndef FLATCC_FLATBUFFERS_H
#define FLATCC_FLATBUFFERS_H
@ -17,14 +17,14 @@ extern "C" {
#define flatcc_flatbuffers_defined
#ifdef FLATCC_PORTABLE
#include "flatcc/flatcc_portable.h"
#include "flatcc_portable.h"
#endif
#include "pwarnings.h"
#include "portable/pwarnings.h"
/* Needed by C99 compilers without FLATCC_PORTABLE. */
#include "pstdalign.h"
#include "portable/pstdalign.h"
/* Handle fallthrough attribute in switch statements. */
#include "pattributes.h"
#include "portable/pattributes.h"
#include "flatcc_alloc.h"
#include "flatcc_assert.h"
@ -37,7 +37,7 @@ extern "C" {
* "flatcc_endian.h" requires the preceeding include files,
* or compatible definitions.
*/
#include "pendian.h"
#include "portable/pendian.h"
#include "flatcc_types.h"
#include "flatcc_endian.h"
#include "flatcc_identifier.h"

View File

@ -20,7 +20,7 @@ extern "C" {
#include "flatcc_unaligned.h"
#define PDIAGNOSTIC_IGNORE_UNUSED
#include "pdiagnostic_push.h"
#include "portable/pdiagnostic_push.h"
enum flatcc_json_parser_flags {
flatcc_json_parser_f_skip_unknown = 1,
@ -886,7 +886,7 @@ int flatcc_json_parser_struct_as_root(flatcc_builder_t *B, flatcc_json_parser_t
const char *buf, size_t bufsiz, int flags, const char *fid,
flatcc_json_parser_struct_f *parser);
#include "pdiagnostic_pop.h"
#include "portable/pdiagnostic_pop.h"
#ifdef __cplusplus
}

View File

@ -32,8 +32,8 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
#include "flatcc/flatcc_rtconfig.h"
#include "flatcc/flatcc_flatbuffers.h"
#include "flatcc_rtconfig.h"
#include "flatcc_flatbuffers.h"
/* -DFLATCC_PORTABLE may help if inttypes.h is missing. */
#ifndef PRId64

View File

@ -5,7 +5,7 @@
extern "C" {
#endif
#include "flatcc/portable/portable_basic.h"
#include "portable/portable_basic.h"
#ifdef __cplusplus
}

View File

@ -1,7 +1,7 @@
/* Include guard intentionally left out. */
#define PDIAGNOSTIC_IGNORE_UNUSED
#include "pdiagnostic_push.h"
#include "portable/pdiagnostic_push.h"
#ifdef __cplusplus
extern "C" {

View File

@ -8,7 +8,7 @@ extern "C" {
/* Include portability layer here since all other files depend on it. */
#ifdef FLATCC_PORTABLE
#include "flatcc/portable/portable.h"
#include "portable/portable.h"
#endif
/*

View File

@ -5,7 +5,7 @@
extern "C" {
#endif
#include "punaligned.h"
#include "portable/punaligned.h"
#define FLATCC_ALLOW_UNALIGNED_ACCESS PORTABLE_UNALIGNED_ACCESS

View File

@ -51,7 +51,7 @@ extern "C" {
*
*/
#include "flatcc/flatcc_types.h"
#include "flatcc_types.h"
#define FLATCC_VERIFY_ERROR_MAP(XX)\
XX(ok, "ok")\

View File

@ -6,8 +6,8 @@
#include <string.h>
#include <stdlib.h>
#include "flatcc/flatcc_rtconfig.h"
#include "flatcc/flatcc_assert.h"
#include "flatcc_rtconfig.h"
#include "flatcc_assert.h"
/*
* Grisu significantly improves printing speed of floating point values
@ -18,13 +18,13 @@
#define PORTABLE_USE_GRISU3 1
#endif
#include "flatcc/flatcc_flatbuffers.h"
#include "flatcc/flatcc_json_printer.h"
#include "flatcc/flatcc_identifier.h"
#include "flatcc_flatbuffers.h"
#include "flatcc_json_printer.h"
#include "flatcc_identifier.h"
#include "flatcc/portable/pprintint.h"
#include "flatcc/portable/pprintfp.h"
#include "flatcc/portable/pbase64.h"
#include "portable/pprintint.h"
#include "portable/pprintfp.h"
#include "portable/pbase64.h"
#define RAISE_ERROR(err) flatcc_json_printer_set_error(ctx, flatcc_json_printer_error_##err)

View File

@ -64,6 +64,7 @@ static inline TK ## _option_t N ## _ ## NK ## _option(N ## _table_t t__tmp)\
#define __flatbuffers_offset_field(T, ID, t, r, adjust)\
{\
flatbuffers_uoffset_t *elem__tmp;\
printf("got here\n");
__flatbuffers_read_vt(ID, offset__tmp, t)\
if (offset__tmp) {\
elem__tmp = (flatbuffers_uoffset_t *)((uint8_t *)(t) + offset__tmp);\

View File

@ -179,7 +179,7 @@ flatcc_refmap_ref_t flatcc_refmap_find(flatcc_refmap_t *refmap, const void *src)
#include <stdio.h>
#ifndef FLATCC_REFMAP_H
#include "flatcc/flatcc_refmap.h"
#include "flatcc_refmap.h"
#endif
#define test(x) do { if (!(x)) { fprintf(stderr, "%02d: refmap test failed\n", __LINE__); exit(-1); } } while (0)

View File

@ -6,10 +6,10 @@
*/
#include <string.h>
#include "flatcc/flatcc_rtconfig.h"
#include "flatcc/flatcc_flatbuffers.h"
#include "flatcc/flatcc_verifier.h"
#include "flatcc/flatcc_identifier.h"
#include "flatcc_rtconfig.h"
#include "flatcc_flatbuffers.h"
#include "flatcc_verifier.h"
#include "flatcc_identifier.h"
/* Customization for testing. */
#if FLATCC_DEBUG_VERIFY