1. 14 Jan, 2017 2 commits
    • Wouter van Oortmerssen's avatar
      Fix unused field warning in clang. · 19101826
      Wouter van Oortmerssen authored
      Change-Id: I71d590a1e5b2709f0e2dcf97faaebda5cb918fc7
      Tested: on Linux.
      19101826
    • Wouter van Oortmerssen's avatar
      Add CodeWriter utility class. · 7b94eab2
      Wouter van Oortmerssen authored
      Helps simplify code generation code.  Instead of this:
        code += "inline const " + cpp_qualified_name + " *Get";
        code += name;
        code += "(const void *buf) {\n  return flatbuffers::GetRoot<";
        code += cpp_qualified_name + ">(buf);\n}\n\n";
      
      You do this:
        code.SetValue("NAME", struct_def.name);
        code.SetValue("CPP_NAME", cpp_qualified_name);
        code += "inline const {{CPP_NAME}} *Get{{NAME}}(const void *buf) {";
        code += "  return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);";
        code += "}";
        code += "";
      
      Updated the CPP code generator to use the CodeWriter class.  Most of the
      changes in the generated code are white-space changes, esp. around new
      lines (since the code generator class automatically appends new lines
      when appending a string).  Actual code changes include:
      
      * Renamed "rehasher" to "_rehasher" for consistency with other args in
        Pack function.
      
      * Renamed "union_obj" to "obj: in UnPack function.
      
      * Always do "(void)_o;" to prevent unused variable warning in Create
        function (instead of only doing it if there are no fields) in order
        to avoid two-passes.
      
      * Renamed padding variables from __paddingX to paddingX__.
        "Each name that contains a double underscore (_ _) [...] is reserved
         to the implementation for any use."  C++ standards 17.4.3.1.2.
      
      * Add braces around switch cases.
      
      * Calculate index as a separate statement in EnumName function, eg.
          const size_t index = ...;
          return EnumNamesX()[index];
        vs.
          return EnumNamesX()[...];
      
      * Stored end table offset in variable in Finish() functions, eg.
          const auto end = fbb_.EndTable(start_, ...);
          auto o = flatbuffers::Offset<T>(end);
        vs.
          auto o = flatbuffers::Offset<T>(fbb_.EndTable(start, ...));
      
      * Separate reinterpret_cast calls from function calls in Union
        functions, eg.
          auto ptr = reinterpret_cast<const T *>(obj);
          return ptr->UnPack(resolver);
        vs.
          return reinterpret_cast<const T *>(obj)->UnPack(resolver);
      
      * Removed unecessary (void)(padding__X) no-ops from constructors, eg.
          Test(int16_t a, int8_t b) : ... {
            (void)__padding0;  // <-- Removed this line.
          }
      
      In the idl_gen_cpp.cpp file itself, I refactored some code generation into
      new functions: GenParam, GenNativeTable, GenVerifyCall, GenBuilders,
      GenUnpackFieldStatement, and GenCreateParam.
      
      Change-Id: I727b1bd8719d05b7ce33cbce00eb58fda817b25d
      7b94eab2
  2. 11 Jan, 2017 1 commit
  3. 10 Jan, 2017 1 commit
  4. 09 Jan, 2017 3 commits
  5. 04 Jan, 2017 2 commits
    • Wouter van Oortmerssen's avatar
      Re-applied reverted fix, adding missing codegen files. · 2c4dce5b
      Wouter van Oortmerssen authored
      Change-Id: I301d29835fb0baffd859950eb0fb3056e4f4d66b
      2c4dce5b
    • Wouter van Oortmerssen's avatar
      Misc idl_gen_cpp cleanup · cc842400
      Wouter van Oortmerssen authored
      - Update to be const-correct where possible.
      - Consistently pass |code| as pointer instead of non-const-ref.
      - No newlines (\n) characters in the middle of code strings.
      - Use if-else if-else statements instead of nested ternary operators.
      - Ensure all lines end at 80 chars.
      - Make utility functions static.
      
      From cl/143505731.
      
      Change-Id: If0fab9ee75de5af963367a948dddf53af93f73b4
      cc842400
  6. 03 Jan, 2017 2 commits
  7. 28 Dec, 2016 1 commit
  8. 22 Dec, 2016 6 commits
  9. 21 Dec, 2016 1 commit
  10. 20 Dec, 2016 5 commits
  11. 19 Dec, 2016 2 commits
    • Wouter van Oortmerssen's avatar
      Add default values (if they exist) to native tables. · e6fa14a0
      Wouter van Oortmerssen authored
      From cl/142307012.
      
      Change-Id: I54d550573f6506b92ad18e7cc90bcd8589259e52
      e6fa14a0
    • Wouter van Oortmerssen's avatar
      Add ::Set function to Unions to make memory ownership clear. · c66683f2
      Wouter van Oortmerssen authored
      Unions own the NativeTable* value member because they need to destroy them
      when the Union goes out of scope.  Currently, the data is destroyed by calling
      delete, which means that the member needs to be allocated with new.  However,
      making the allocation the responsibility of the client and the destruction
      the responsibility of the Union can lead to potential errors.  Adding a
      Set function will ensure that the memory is allocated correctly so that it
      can be deleted later.
      
      From cl/142161569.
      
      Change-Id: I4605f26d2749164819bfae0140e5fae08442b50a
      c66683f2
  12. 16 Dec, 2016 2 commits
    • Zarian Waheed's avatar
      Changes for verifying a buffer dynamically using reflection. (#4102) · 6d6271db
      Zarian Waheed authored
      * Changes for verifying a buffer dynamically using reflection.
      
      * Fixing build issues on linux and applied code reformatting.
      
      * Fixing the file order in cmake file that was messing up the macro based code inclusion.
      
      Added tests for reflection based verification.
      
      * Changes for verifying a buffer dynamically using reflection.
      
      Fixing build issues on linux and applied code reformatting.
      
      Fixing the file order in cmake file that was messing up the macro based code inclusion.
      
      Added tests for reflection based verification.
      
      * Incorporated the code review changes that were requested:
      
      1. Changed the Verify function signature.
      2. Changed the variable names to use snake_case.
      3. Added better comments.
      4. Refactored duplicate code.
      5. Changed the verifier class so that it has the same size when compiled with or without FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE macro.
      
      * Setting FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE and FLATBUFFERS_DEBUG_VERIFICATION_FAILURE through cmake for flattests so that it gets propagted to all translation units of flattests.
      
      * Making the Verifier struct fields the same in all cases. Also reverting the target_compile_definitions change in cmake file because build machine on travis does not have cmake version 3.0 or higher which was the version when target_compile_definitions was added in cmake.
      
      * Defining macros through cmake in a portable way using functions that are available in cmake 2.8.
      6d6271db
    • krupnov's avatar
      random access iterator for vector added (#4119) · ab76c57e
      krupnov authored
      * random access iterator for vector added
      
      * Style changes
      ab76c57e
  13. 14 Dec, 2016 2 commits
  14. 13 Dec, 2016 1 commit
  15. 12 Dec, 2016 1 commit
  16. 09 Dec, 2016 2 commits
  17. 07 Dec, 2016 3 commits
  18. 05 Dec, 2016 1 commit
    • Ronak Jain's avatar
      Support for Golang GRPC (Experimental) (#4082) · a31ddd2b
      Ronak Jain authored
      * support for grpc golang
      
      * refactored grpc go generator
      
      * added grpc-go test and refactored
      
      * refactored idl_gen_grpc.cpp
      
      * fixed grpc generate method name
      
      * refactored flatc and fixed line length issue
      
      * added codec to go lib and fixed formatting issues
      
      * fixed spacing issues
      a31ddd2b
  19. 02 Dec, 2016 2 commits
    • Wouter van Oortmerssen's avatar
      Adds typedefs and functions to help write generic code. · bc2ec711
      Wouter van Oortmerssen authored
      The following changes have been made to the C++ codegen to enable writing generic code
      that uses the Table and NativeTable types.
      
      - Adds TableType and NativeTableType typedefs to NativeTable and Table structs.
      - Adds GetFullyQualifiedName() to NativeTables if --gen-name-strings is set.
      - Adds a static Pack function to Tables that simply calls the global CreateX functions.
      
      See cr/140391505 as an example of improved usage.
      
      From cl/140529288.
      
      Change-Id: Idec137c16129e15c1783f94fabdcea24aeeaaef6
      bc2ec711
    • Wouter van Oortmerssen's avatar
      Allows structs to be stored directly as member variables. · 641b397f
      Wouter van Oortmerssen authored
      Introduce a "native_inline" attribute that can be applied on fields that are structs.
      This results in NativeTable code generation that sets the struct "inline" rather than
      storing it in a pointer.
      
      From cl/140527470.
      
      Change-Id: I208724f552b8b921b20923e0bf82f42cb3582416
      641b397f