Skip to content
Snippets Groups Projects
  1. Feb 08, 2017
  2. Feb 01, 2017
  3. Jan 30, 2017
  4. Jan 27, 2017
  5. Jan 25, 2017
  6. Jan 24, 2017
  7. Jan 23, 2017
  8. Jan 22, 2017
  9. Jan 19, 2017
    • Wouter van Oortmerssen's avatar
      More native code gen functionality. · 3f936c56
      Wouter van Oortmerssen authored
      Allow tables to be mapped to native types directly.  For example, a table
      representing a vector3 (eg. table Vec3 { x:float; y:float; z:float; }) can
      be mapped to a "mathfu::vec3" native type in NativeTables.  This requires
      users to provide Pack and UnPack functions that convert between the
      Table and native types.  This is done by adding the "native_type" attribute
      to the table definition.
      
      To support user-defined flatbuffers::Pack and flatbuffers::UnPack functions,
      support a "native_include" markup that will generate a corresponding
      
      Also add an UnPackTo function which allows users to pass in a pointer to
      a NativeTable object into which to UnPack the Table.  The existing UnPack
      function is now simply:
      
        NativeTable* UnPack() {
          NativeTable* obj = new NativeTable();
          Table::UnPackTo(obj);
          return obj;
        }
      
      Finally, allow native types to be given a default value as well which are
      set in the NativeTable constructor.  This is done by providing a
      "native_default" attribute to the member of a table.
      
      Change-Id: Ic45cb48b0e6d7cfa5734b24819e54aa96d847cfd
      3f936c56
    • Wouter van Oortmerssen's avatar
      Add no-op for padding variables to prevent clang compiler warning. · 42a265b4
      Wouter van Oortmerssen authored
      Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11
      42a265b4
    • Wouter van Oortmerssen's avatar
      Fix compiler warning on Visual Studio. · 4bc4979a
      Wouter van Oortmerssen authored
      Change-Id: Ifda5f2c32c6484508d5e12a463d6373798f1f523
      4bc4979a
  10. Jan 18, 2017
  11. Jan 14, 2017
    • 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
  12. Jan 11, 2017
  13. Jan 10, 2017
  14. Jan 09, 2017
  15. Jan 04, 2017
    • 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
  16. Jan 03, 2017
  17. Dec 28, 2016
  18. Dec 22, 2016
    • Wouter van Oortmerssen's avatar
    • Wouter van Oortmerssen's avatar
      Fixed empty structs generating illegal constructor in C++. · 5fd0fefa
      Wouter van Oortmerssen authored
      Change-Id: I60418d597b497c3cfa655ad76b3128351e9139f2
      5fd0fefa
    • Ankur Dave's avatar
      Fix call to Verifier::VerifyBuffer from BufferRef (#4124) · f8a964d2
      Ankur Dave authored
      3a1f7761 added a required identifier parameter
      to Verifier::VerifyBuffer but did not update the templated call site in
      BufferRef. This causes errors like the following when trying to instantiate the
      call site by calling BufferRef::Verify():
      
          include/flatbuffers/flatbuffers.h: In instantiation of ‘bool flatbuffers::BufferRef<T>::Verify() [with T = MyType]’:
          MyApp.cpp:16:3:   required from here
          include/flatbuffers/flatbuffers.h:1421:37: error: no matching function for call to ‘flatbuffers::Verifier::VerifyBuffer()’
               return verifier.VerifyBuffer<T>();
                                               ^
          include/flatbuffers/flatbuffers.h:1421:37: note: candidate is:
          include/flatbuffers/flatbuffers.h:1352:29: note: template<class T> bool flatbuffers::Verifier::VerifyBuffer(const char*)
             template<typename T> bool VerifyBuffer(const char *identifier) {
                                       ^
          include/flatbuffers/flatbuffers.h:1352:29: note:   template argument deduction/substitution failed:
          include/flatbuffers/flatbuffers.h:1421:37: note:   candidate expects 1 argument, 0 provided
               return verifier.VerifyBuffer<T>();
                                               ^
      
      This commit fixes the BufferRef call site by adding a nullptr argument.
      f8a964d2
    • Zarian Waheed's avatar
      Added helper methods to access struct through reflection. (#4120) · 84033ae0
      Zarian Waheed authored
      * Added helper methods to access struct through reflection. Also added unit test for it.
      
      * Added a TODO comment to check for the is_struct flag.
      84033ae0
Loading