summaryrefslogtreecommitdiff
path: root/src/idl_gen_cpp.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-05-17don't emit flatbuffers include in bfbs generated output (#7968)Derek Bailey1-4/+2
2023-05-14feat(C++): Support underlying_type for union (#7954)sssooonnnggg1-4/+10
* feat(C++): support underlying type for union * chore: add conform checks for underlying type changes
2023-05-09fixed bfbs gen to pass extra options (#7949)Derek Bailey1-5/+4
2023-05-09removed extern code generation declarations preferring direct includes (#7948)Derek Bailey1-2/+2
* removed extern code generation definitions, preferring direct includes * add static to functions * remove idl_gen_lua
2023-05-09FlatBuffers 64 for C++ (#7935)Derek Bailey1-86/+212
* First working hack of adding 64-bit. Don't judge :) * Made vector_downward work on 64 bit types * vector_downward uses size_t, added offset64 to reflection * cleaned up adding offset64 in parser * Add C++ testing skeleton for 64-bit * working test for CreateVector64 * working >2 GiB buffers * support for large strings * simplified CreateString<> to just provide the offset type * generalize CreateVector template * update test_64.afb due to upstream format change * Added Vector64 type, which is just an alias for vector ATM * Switch to Offset64 for Vector64 * Update for reflection bfbs output change * Starting to add support for vector64 type in C++ * made a generic CreateVector that can handle different offsets and vector types * Support for 32-vector with 64-addressing * Vector64 basic builder + tests working * basic support for json vector64 support * renamed fields in test_64bit.fbs to better reflect their use * working C++ vector64 builder * Apply --annotate-sparse-vector to 64-bit tests * Enable Vector64 for --annotate-sparse-vectors * Merged from upstream * Add `near_string` field for testing 32-bit offsets alongside * keep track of where the 32-bit and 64-bit regions are for flatbufferbuilder * move template<> outside class body for GCC * update run.sh to build and run tests * basic assertion for adding 64-bit offset at the wrong time * started to separate `FlatBufferBuilder` into two classes, 1 64-bit aware, the other not * add test for nested flatbuffer vector64, fix bug in alignment of big vectors * fixed CreateDirect method by iterating by Offset64 first * internal refactoring of flatbufferbuilder * block not supported languages in the parser from using 64-bit * evolution tests for adding a vector64 field * conformity tests for adding/removing offset64 attributes * ensure test is for a big buffer * add parser error tests for `offset64` and `vector64` attributes * add missing static that GCC only complains about * remove stdint-uintn.h header that gets automatically added * move 64-bit CalculateOffset internal * fixed return size of EndVector * various fixes on windows * add SizeT to vector_downward * minimze range of size changes in vector and builder * reworked how tracking if 64-offsets are added * Add ReturnT to EndVector * small cleanups * remove need for second Array definition * combine IndirectHelpers into one definition * started support for vector of struct * Support for 32/64-vectors of structs + Offset64 * small cleanups * add verification for vector64 * add sized prefix for 64-bit buffers * add fuzzer for 64-bit * add example of adding many vectors using a wrapper table * run the new -bfbs-gen-embed logic on the 64-bit tests * remove run.sh and fix cmakelist issue * fixed bazel rules * fixed some PR comments * add 64-bit tests to cmakelist
2023-05-04Add binary schema reflection (#7932)Derek Bailey1-0/+22
* Add binary schema reflection * remove not-used parameter * move logic from object API to base API * forward declare * remove duplicate code gen that was stompping on the edits * reduce to just typedef generation * fixed bazel rules to not stomp * more bazel fixes to support additional generated files
2023-05-02fix possible null dereference for nested_root accessorDerek Bailey1-20/+24
2023-04-28fixed some windows warnings (#7929)Derek Bailey1-12/+13
2023-02-17Move defined part to idl.h (#7823)Saman1-10/+1
2023-02-05use switch statements for BASE_TYPE_ lookups (#7813)Derek Bailey1-20/+27
2023-01-31Final refactor for bfsb_generator* and text generator (#7806)Khanh Nguyen1-0/+9
* Refactor BfbsGenerator to use CodeGenerator interface * Update * Refactor bfbs generator * Refactor bfbs generator for lua and nim. Remove old code that use Generator interface. * Update import * Update CMakeLists * Update BUILD file * Update BUILD file for src * Remove from Android CMakeLists and add error message * Update * Add generate root file function to Code Generator interface * Update * Update * Minor format fix
2023-01-25Clean up extra white spaces (#7800)Wen Sun1-2/+2
* Clean up extra white spaces * update Co-authored-by: Wen Sun <sunwen@google.com> Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-25Refactor languages to use CodeGenerator interface. (#7797)Khanh Nguyen1-0/+2
* Refactor to use CodeGenerator interface. - Move code to its own header file to be included in flatc_main.cpp - Refactor code to use CodeGenerator interface for all languages * Format all files * remove lua code generator since it doesn't support bfbs generator * Update CMakeLists file with new idl_gen_*.cpp and idl_gen_*.h files * Add idl_gen_swift header file * Add idl_gen_swift header file and update bazel file * Remove CodeGenerator interface for idl_gen_text.*. Remove comments and extern declaration * Reorder header and implementation files in CMakeLists.txt * Add idl_gen_* header files to implementation files * Update CMakeLists and remove unused import Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-24[C++] Enable using struct and array of struct as key (#7741)Wen Sun1-22/+115
* add unit tests for support struct as key * make changes to parser and add helper function to generate comparator for struct * implement * add more unit tests * format * just a test * test done * rerun generator * restore build file * address comment * format * rebase * rebase * add more unit tests * rerun generator * address some comments * address comment * update * format * address comment Co-authored-by: Wen Sun <sunwen@google.com> Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-08Defined CodeGenerator Interface and implement C++ (#7771)Derek Bailey1-0/+47
2023-01-07emit global scoped ::flatbuffers in c++ (#7764)Derek Bailey1-112/+113
2023-01-07[C++] Add Command-Line Flag to Suppress MIN and MAX Enums (#7705)jalitriver1-1/+3
Add the --no-minmax-values flag to prevent flatc from generating C++ enums with MIN and MAX enumerated values that otherwise would be set to the inclusive lower and upper bound respectively of the enum. This command-line flag is needed to avoid collisions when an enum that is being ported to FlatBuffers already has a MIN or MAX enumerated value. It is also needed to work around a long-standing problem with magic_enum that causes magic_enum to not see enumerated values that are not unique. For example, if FlatBuffers sets MIN = FOO and MAX = BAR, MIN and FOO share the same underlying value so they are not unique. The same is true of MAX and BAR. This prevents magic_enum from converting FOO and BAR to and from strings as well as causing magic_enum to return a count of enumerated values that is two fewer than it should be. Co-authored-by: Paul Serice <paul@serice.net>
2023-01-05Fix operator==() generated for field of fixed sized array (#7749)Saman1-1/+2
* Fix operator==() generated for field of fixed sized array * Compare address * noexcept * Grammer Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06[C++] Update to address comparator failure in big endian (#7681)Wen Sun1-8/+11
* update unit test and generated file to test is extra endianswap can help resolve issue * remove EndianScalar wrapper from Get method * remove endianscalar wrapper * update * update * use Array instead * clang format * address error * clang * update * manually generate * Move Nim to completed language * Add swift link * address comments * update unit test * address comment * address comment * regenerate file * use auto instead of size_t * use uint32_t instead * update * format * delete extra whitespace Co-authored-by: Wen Sun <sunwen@google.com> Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-12-06Refactor src/idl_gen_cpp.cpp (#7693)RishabhDeep Singh1-253/+186
* Refactor for loops and simplify code * Refactor for loops and simplify code * Fix for loop and reformat * reformat code
2022-11-18Add support for using array of scalar as key field in Cpp (#7623)Wen Sun1-4/+31
* add support for using array of scalar as key field * update cmakelist and test.cpp to include the tests * update bazel rule * address comments * clang format * delete comment * delete comment * address the rest of the commnets * address comments * update naming in test file * format build file * buildifier * make keycomparelessthan call keycomparewithvalue * update to use flatbuffer array instead of raw pointer * clang * format * revert format * revert format * update * run generate_code.py * run code generator * revert changes by generate_code.py * fist run make flatc and then run generate_code.py Co-authored-by: Wen Sun <sunwen@google.com>
2022-11-11Fixes #7345 to add the option to minify enums (#7566)RishabhDeep Singh1-186/+191
* Added cpp minified enums * Update generated files * remove initializer and fix comma * Fix .gitignore * Fix comma * Add tests for cpp minify enums
2022-11-08Add missing #include <algorithm> for std::min/std::max uses, and #include ↵Even Rouault1-0/+1
<limits> for std::numeric_limits<> (#7624)
2022-09-13UnPackTo disable merge by default (#7527)Derek Bailey1-32/+29
* UnPackTo disable merge by default * avoid double free in test * remove merge parameter * remove shrink to fit
2022-08-29[C++] support native_inline attribute for vector of tables (#7479)sssooonnnggg1-22/+29
2022-08-23Use schema include name for keep-prefix (#7469)Derek Bailey1-26/+13
2022-08-22Reworked keep prefix (#7456)Derek Bailey1-14/+26
* reworked keep prefix * checking in missing schema * fix flatc path for build scripts
2022-08-18disabling unpackto optimization (#7459)Derek Bailey1-0/+16
2022-08-08avoid zero-as-null-pointer warning (#7423)sssooonnnggg1-1/+1
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-08-08[C++] Vector of Tables equality (#7415)Derek Bailey1-3/+25
* Vector of Tables equality * support nullptr and fix for not being able to use auto in lambda * use different std::equal overload * use flatbuffers::unique_ptr * go back to auto and clang-format fix
2022-07-26keep-prefix keeps relative pathing (#7394)Derek Bailey1-2/+9
2022-06-15Only include direct included filed (#7348)Derek Bailey1-17/+18
2022-04-19more google merge fixesDerek Bailey1-1/+2
2022-04-05code gen flexbuffer verifier (#7207)Derek Bailey1-0/+1
* code gen flexbuffer verifier * remove verify nested flexbuffers from flexbuffers * made function static, and placed higher in file * moved function to own header
2022-04-04[C++] generate sorted #include directives (#7213)Stefan F1-1/+8
* [C++] generate sorted #include directives * using stable_sort instead of sort.
2022-04-01Fix for [C++] flatc generates invalid Code in the default constructor for ↵Stefan F1-2/+2
structs, when --cpp-field-case-style is used #7209 (#7211) * Typo in flatc options (warning-as-errors instead of warnings-as-errors) * VerifySizePrefixed (reflection::Schema) and GetAnySizePrefixedRoot added * some review comments * more review comments * Fix for https://github.com/google/flatbuffers/issues/7209 * Fixes [C++] flatc generates invalid Code for union field accessors, when --cpp-field-case-style is used #7210
2022-03-31[C++] Static assert on Flatbuffers Version (#7203)Derek Bailey1-0/+25
* Static assert on Flatbuffers Version * add comment
2022-02-24prevent name clash (#7133)Derek Bailey1-2/+3
2022-02-23Use ConvertCase instead of Make{Upper,Lower,Snake} implementations (#7127)Derek Bailey1-2/+2
* Unified name case conversion to single method * Convert bfbs_gen to use ConvertCase * convert rust to use ConvertCase * Convert idl_parser to use ConvertCase * Convert MakeScreamingCamel to ConvertCase * Replaced MakeCamel with ConvertCase * minor fixes
2022-02-02fixed comparator for native_inline (#7076)Derek Bailey1-1/+1
* fixed comparator for native_inline * added native_inline data * updated more tests for the new field * more fixes
2022-02-02update C++ generator to emit scoped enums in vector of unions (#7075)Derek Bailey1-2/+3
2022-02-01clang format on codebase (#7058)Derek Bailey1-9/+15
2022-01-29[C++] Support C++ object copies and moves (#5988)Jean-François Roy1-8/+168
Augment the C++ generator to emit a C++ copy constructor and a by-value copy assignment operator. This is enabled by default when the C++ standard is C++11 or later. These additional functions are only emitted for objects that need it, typically tables containing other tables. These new functions are declared in the object table type and are defined as inline functions after table declarations. When these new functions are declared, a user-defined explicitly-defaulted default constructor and move constructor are also emitted. The copy assignment operator uses the copy-and-swap idiom to provide strong exception safety, at the expense of keeping 2 full table copies in memory temporarily. fixes #5783
2022-01-28Include a SizePrefixed..HasIdentifier for c++. (#6871)Justin T Conroy1-0/+8
* Include a SizePrefixed..HasIdentifier for c++. * Add updated generated code.
2022-01-25Emit include for bfbs-gen-embed (#7031)Derek Bailey1-0/+3
2022-01-14Added verifier alignment checking to table fields (#7018)Wouter van Oortmerssen1-4/+7
2021-12-13Prevent shadow with _{{FIELD_NAME}} (#6991)Derek Bailey1-5/+5
2021-12-10Verifier for FlexBuffers (#6977)Wouter van Oortmerssen1-0/+3
* Verifier for FlexBuffers * Verifier improvements & fuzzer
2021-11-29Enable verifier on nested_flatbuffersWouter van Oortmerssen1-13/+26
2021-11-19clang-all (#6941)Derek Bailey1-7/+12