diff --git a/CHANGELOG.md b/CHANGELOG.md index 64c276894..ebf4ca510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ # Change Log -## [0.6.1-pre] +## [0.6.1] - Add `flatcc_builder_alloc` and `flatcc_builder_free` to handle situations - where stanard allocation has been redefined via macros so `free` is no longer + where standard allocation has been redefined via macros so `free` is no longer safe to use. These are similar to the existing `aligned_alloc/free` functions. - Fix a potential, but never seen, low level race condition in the builder when writing a union field because the builder might reallocate between type diff --git a/README.md b/README.md index 6f5f10db5..0b976b5cc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ executable also handle optional json parsing or printing in less than 2 us for a * [Poll on Meson Build](#poll-on-meson-build) * [Reporting Bugs](#reporting-bugs) * [Status](#status) - * [Main features supported as of 0.6.0](#main-features-supported-as-of-060) + * [Main features supported as of 0.6.1](#main-features-supported-as-of-061) * [Supported platforms (CI tested)](#supported-platforms-ci-tested) * [Platforms reported to work by users](#platforms-reported-to-work-by-users) * [Portability](#portability) @@ -292,6 +292,20 @@ fi ## Status +Release 0.6.1 contains primarily bug fixes and numerous contributions +from the community to handle platform edge cases. Additionally, +pendantic GCC warnings are disabled, relying instead on clang, since GCC +is too aggressive, breaks builds frequently and works against +portability. An existing C++ test case ensures that C code also works +with common C++ compilers, but it can break some environments, so there +is now a flag to disable that test without disabling all tests. Support +for Optional Scalar Values in the FlatBuffer format has been added. +There is also improved support for abstracting memory allocation on +various platforms. `_identifier` has been deprecated in favor +`
_file_identifier` in generated code due to `identifier` easily +leading to name conflicts. `file_extension` constant in generated code +is now without prefixed dot (.). + Release 0.6.0 introduces a "primary" attribute to be used together with a key attribute to chose default key for finding and sorting. If primary is absent, the key with the lowest id becomes primary. Tables and @@ -339,7 +353,7 @@ low-level union interface so the terms { type, value } are used consistently over { type, member } and { types, members }. -### Main features supported as of 0.6.0 +### Main features supported as of 0.6.1 - generated FlatBuffers reader and builder headers for C - generated FlatBuffers verifier headers for C @@ -364,6 +378,7 @@ consistently over { type, member } and { types, members }. - base64(url) encoded binary data in JSON. - sort fields by primary key (as of 0.6.0) - char arrays (as of 0.6.0) +- optional scalar values (as of 0.6.1) There are no plans to make frequent updates once the project becomes stable, but input from the community will always be welcome and included diff --git a/include/flatcc/flatcc_version.h b/include/flatcc/flatcc_version.h index 87158986b..0e677d1c1 100644 --- a/include/flatcc/flatcc_version.h +++ b/include/flatcc/flatcc_version.h @@ -2,12 +2,12 @@ extern "C" { #endif -#define FLATCC_VERSION_TEXT "0.6.1-dev" +#define FLATCC_VERSION_TEXT "0.6.1" #define FLATCC_VERSION_MAJOR 0 #define FLATCC_VERSION_MINOR 6 #define FLATCC_VERSION_PATCH 1 /* 1 or 0 */ -#define FLATCC_VERSION_RELEASED 0 +#define FLATCC_VERSION_RELEASED 1 #ifdef __cplusplus } diff --git a/include/flatcc/reflection/flatbuffers_common_builder.h b/include/flatcc/reflection/flatbuffers_common_builder.h index b5ce8a5ce..a4be1ce6e 100644 --- a/include/flatcc/reflection/flatbuffers_common_builder.h +++ b/include/flatcc/reflection/flatbuffers_common_builder.h @@ -1,7 +1,7 @@ #ifndef FLATBUFFERS_COMMON_BUILDER_H #define FLATBUFFERS_COMMON_BUILDER_H -/* Generated by flatcc 0.6.1-dev FlatBuffers schema compiler for C by dvide.com */ +/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */ /* Common FlatBuffers build functionality for C. */ diff --git a/include/flatcc/reflection/flatbuffers_common_reader.h b/include/flatcc/reflection/flatbuffers_common_reader.h index 67971e9af..c57530868 100644 --- a/include/flatcc/reflection/flatbuffers_common_reader.h +++ b/include/flatcc/reflection/flatbuffers_common_reader.h @@ -1,7 +1,7 @@ #ifndef FLATBUFFERS_COMMON_READER_H #define FLATBUFFERS_COMMON_READER_H -/* Generated by flatcc 0.6.1-dev FlatBuffers schema compiler for C by dvide.com */ +/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */ /* Common FlatBuffers read functionality for C. */ diff --git a/include/flatcc/reflection/reflection_builder.h b/include/flatcc/reflection/reflection_builder.h index 4b05199ee..65aef73e5 100644 --- a/include/flatcc/reflection/reflection_builder.h +++ b/include/flatcc/reflection/reflection_builder.h @@ -1,7 +1,7 @@ #ifndef REFLECTION_BUILDER_H #define REFLECTION_BUILDER_H -/* Generated by flatcc 0.6.1-dev FlatBuffers schema compiler for C by dvide.com */ +/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */ #ifndef REFLECTION_READER_H #include "reflection_reader.h" @@ -13,7 +13,7 @@ #undef flatbuffers_identifier #define flatbuffers_identifier "BFBS" #undef flatbuffers_extension -#define flatbuffers_extension ".bfbs" +#define flatbuffers_extension "bfbs" #define __reflection_BaseType_formal_args , reflection_BaseType_enum_t v0 #define __reflection_BaseType_call_args , v0 diff --git a/include/flatcc/reflection/reflection_reader.h b/include/flatcc/reflection/reflection_reader.h index 06b1dfb46..bf6a0e946 100644 --- a/include/flatcc/reflection/reflection_reader.h +++ b/include/flatcc/reflection/reflection_reader.h @@ -1,7 +1,7 @@ #ifndef REFLECTION_READER_H #define REFLECTION_READER_H -/* Generated by flatcc 0.6.1-dev FlatBuffers schema compiler for C by dvide.com */ +/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */ #ifndef FLATBUFFERS_COMMON_READER_H #include "flatbuffers_common_reader.h" @@ -14,7 +14,7 @@ #undef flatbuffers_identifier #define flatbuffers_identifier "BFBS" #undef flatbuffers_extension -#define flatbuffers_extension ".bfbs" +#define flatbuffers_extension "bfbs" typedef const struct reflection_Type_table *reflection_Type_table_t; @@ -54,86 +54,113 @@ typedef struct reflection_Schema_table *reflection_Schema_mutable_table_t; typedef const flatbuffers_uoffset_t *reflection_Schema_vec_t; typedef flatbuffers_uoffset_t *reflection_Schema_mutable_vec_t; #ifndef reflection_Type_file_identifier -#define reflection_Type_file_identifier flatbuffers_identifier +#define reflection_Type_file_identifier "BFBS" #endif /* deprecated, use reflection_Type_file_identifier */ #ifndef reflection_Type_identifier -#define reflection_Type_identifier flatbuffers_identifier +#define reflection_Type_identifier "BFBS" #endif #define reflection_Type_type_hash ((flatbuffers_thash_t)0x44c8fe5e) #define reflection_Type_type_identifier "\x5e\xfe\xc8\x44" +#ifndef reflection_Type_file_extension +#define reflection_Type_file_extension "bfbs" +#endif #ifndef reflection_KeyValue_file_identifier -#define reflection_KeyValue_file_identifier flatbuffers_identifier +#define reflection_KeyValue_file_identifier "BFBS" #endif /* deprecated, use reflection_KeyValue_file_identifier */ #ifndef reflection_KeyValue_identifier -#define reflection_KeyValue_identifier flatbuffers_identifier +#define reflection_KeyValue_identifier "BFBS" #endif #define reflection_KeyValue_type_hash ((flatbuffers_thash_t)0x8c761eaa) #define reflection_KeyValue_type_identifier "\xaa\x1e\x76\x8c" +#ifndef reflection_KeyValue_file_extension +#define reflection_KeyValue_file_extension "bfbs" +#endif #ifndef reflection_EnumVal_file_identifier -#define reflection_EnumVal_file_identifier flatbuffers_identifier +#define reflection_EnumVal_file_identifier "BFBS" #endif /* deprecated, use reflection_EnumVal_file_identifier */ #ifndef reflection_EnumVal_identifier -#define reflection_EnumVal_identifier flatbuffers_identifier +#define reflection_EnumVal_identifier "BFBS" #endif #define reflection_EnumVal_type_hash ((flatbuffers_thash_t)0x9531c946) #define reflection_EnumVal_type_identifier "\x46\xc9\x31\x95" +#ifndef reflection_EnumVal_file_extension +#define reflection_EnumVal_file_extension "bfbs" +#endif #ifndef reflection_Enum_file_identifier -#define reflection_Enum_file_identifier flatbuffers_identifier +#define reflection_Enum_file_identifier "BFBS" #endif /* deprecated, use reflection_Enum_file_identifier */ #ifndef reflection_Enum_identifier -#define reflection_Enum_identifier flatbuffers_identifier +#define reflection_Enum_identifier "BFBS" #endif #define reflection_Enum_type_hash ((flatbuffers_thash_t)0xacffa90f) #define reflection_Enum_type_identifier "\x0f\xa9\xff\xac" +#ifndef reflection_Enum_file_extension +#define reflection_Enum_file_extension "bfbs" +#endif #ifndef reflection_Field_file_identifier -#define reflection_Field_file_identifier flatbuffers_identifier +#define reflection_Field_file_identifier "BFBS" #endif /* deprecated, use reflection_Field_file_identifier */ #ifndef reflection_Field_identifier -#define reflection_Field_identifier flatbuffers_identifier +#define reflection_Field_identifier "BFBS" #endif #define reflection_Field_type_hash ((flatbuffers_thash_t)0x9f7e408a) #define reflection_Field_type_identifier "\x8a\x40\x7e\x9f" +#ifndef reflection_Field_file_extension +#define reflection_Field_file_extension "bfbs" +#endif #ifndef reflection_Object_file_identifier -#define reflection_Object_file_identifier flatbuffers_identifier +#define reflection_Object_file_identifier "BFBS" #endif /* deprecated, use reflection_Object_file_identifier */ #ifndef reflection_Object_identifier -#define reflection_Object_identifier flatbuffers_identifier +#define reflection_Object_identifier "BFBS" #endif #define reflection_Object_type_hash ((flatbuffers_thash_t)0xb09729bd) #define reflection_Object_type_identifier "\xbd\x29\x97\xb0" +#ifndef reflection_Object_file_extension +#define reflection_Object_file_extension "bfbs" +#endif #ifndef reflection_RPCCall_file_identifier -#define reflection_RPCCall_file_identifier flatbuffers_identifier +#define reflection_RPCCall_file_identifier "BFBS" #endif /* deprecated, use reflection_RPCCall_file_identifier */ #ifndef reflection_RPCCall_identifier -#define reflection_RPCCall_identifier flatbuffers_identifier +#define reflection_RPCCall_identifier "BFBS" #endif #define reflection_RPCCall_type_hash ((flatbuffers_thash_t)0xe2d586f1) #define reflection_RPCCall_type_identifier "\xf1\x86\xd5\xe2" +#ifndef reflection_RPCCall_file_extension +#define reflection_RPCCall_file_extension "bfbs" +#endif #ifndef reflection_Service_file_identifier -#define reflection_Service_file_identifier flatbuffers_identifier +#define reflection_Service_file_identifier "BFBS" #endif /* deprecated, use reflection_Service_file_identifier */ #ifndef reflection_Service_identifier -#define reflection_Service_identifier flatbuffers_identifier +#define reflection_Service_identifier "BFBS" #endif #define reflection_Service_type_hash ((flatbuffers_thash_t)0xf31a13b5) #define reflection_Service_type_identifier "\xb5\x13\x1a\xf3" +#ifndef reflection_Service_file_extension +#define reflection_Service_file_extension "bfbs" +#endif #ifndef reflection_Schema_file_identifier -#define reflection_Schema_file_identifier flatbuffers_identifier +#define reflection_Schema_file_identifier "BFBS" #endif /* deprecated, use reflection_Schema_file_identifier */ #ifndef reflection_Schema_identifier -#define reflection_Schema_identifier flatbuffers_identifier +#define reflection_Schema_identifier "BFBS" #endif #define reflection_Schema_type_hash ((flatbuffers_thash_t)0xfaf93779) #define reflection_Schema_type_identifier "\x79\x37\xf9\xfa" +#ifndef reflection_Schema_file_extension +#define reflection_Schema_file_extension "bfbs" +#endif typedef int8_t reflection_BaseType_enum_t; __flatbuffers_define_integer_type(reflection_BaseType, reflection_BaseType_enum_t, 8) diff --git a/include/flatcc/reflection/reflection_verifier.h b/include/flatcc/reflection/reflection_verifier.h index 7d04f34df..5b5bd374a 100644 --- a/include/flatcc/reflection/reflection_verifier.h +++ b/include/flatcc/reflection/reflection_verifier.h @@ -1,7 +1,7 @@ #ifndef REFLECTION_VERIFIER_H #define REFLECTION_VERIFIER_H -/* Generated by flatcc 0.6.1-dev FlatBuffers schema compiler for C by dvide.com */ +/* Generated by flatcc 0.6.1 FlatBuffers schema compiler for C by dvide.com */ #ifndef REFLECTION_READER_H #include "reflection_reader.h" diff --git a/src/compiler/codegen_schema.c b/src/compiler/codegen_schema.c index 0313d9ef8..d0c9fde3c 100644 --- a/src/compiler/codegen_schema.c +++ b/src/compiler/codegen_schema.c @@ -465,17 +465,15 @@ static void sort_objects(void *buffer) static FILE *open_file(fb_options_t *opts, fb_schema_t *S) { FILE *fp = 0; - char *path; + char *path = 0, *ext = 0; const char *prefix = opts->outpath ? opts->outpath : ""; size_t len, prefix_len = strlen(prefix); const char *name; - const char *ext; name = S->basename; len = strlen(name); - ext = flatbuffers_extension; - + ext = fb_create_path_ext(".", flatbuffers_extension); /* We generally should not use cgen options here, but in this case it makes sense. */ if (opts->gen_stdout) { return stdout; @@ -486,6 +484,7 @@ static FILE *open_file(fb_options_t *opts, fb_schema_t *S) fprintf(stderr, "error opening file for writing binary schema: %s\n", path); } free(path); + free(ext); return fp; }