1. 04 Dec, 2015 3 commits
    • Michael Collins's avatar
      Add Get Bytes Method Generator for C# · e083e466
      Michael Collins authored
      I updated idl_gen_general.cpp to add support for generating a Get Bytes
      method for a vector to the generated C# source code. Given a byte vector
      field named Foo, a method named GetFooBytes() will be generated in the
      C# source code that will return an ArraySegment<byte> value referencing
      the vector data in the underlying ByteBuffer.
      
      I added a method to Table.cs named __vector_as_arraysegment that is used
      by the code generated by the change to the C# generator.
      __vector_as_arraysegment will take the offset of the vector and will
      return the ArraySegment<byte> value corresponding to the bytes that
      store the vector data.
      
      I updated FlatBuffersExampleTests.cs to add tests to validate my
      implementation of Table.__vector_as_arraysegment. I added tests to
      demonstrate that the bytes for the monster's name can be extracted from
      the underlying byte array. I also added tests to show that
      Table.__vector_as_arraysegment returns a null value if the vector is not
      present in the FlatBuffer.
      
      I used the updated flatc.exe program to regenerate the C# source files
      for the MyGame example. The new Monster class includes the GetXXXBytes
      methods to return the byte arrays containing data for vectors.
      e083e466
    • Jason Sanmiya's avatar
      Do not create empty enums. · fe2f8d32
      Jason Sanmiya authored
      Mac build issued a warning for enum{}.
      
      Change-Id: I9cab958538ac3cec61aeae289d1da0118ecac15f
      Tested: Mac build no longer issues warnings.
      fe2f8d32
    • Wouter van Oortmerssen's avatar
      Added --gen-all to generate code for a schema and all its includes. · 45bda6e0
      Wouter van Oortmerssen authored
      Also refactored the way options are stored.
      
      Change-Id: I709ac908cd2aba396c9c282725cf1d42ccce0882
      Tested: on Linux.
      45bda6e0
  2. 02 Dec, 2015 12 commits
  3. 25 Nov, 2015 2 commits
  4. 23 Nov, 2015 1 commit
    • Donnell's avatar
      Fix C# vector of enum code generation · 644bcbde
      Donnell authored
      Fixes a bug where the logic to determine when to use a C# enum flags
      both enums and vectors of enums.  This causes the C# generator to
      generate code that doesn't compile for tables that contain vectors of
      enums.
      
      The fix also consolidates type generation functions a bit and adds
      some additional casting functions for clarity.
      644bcbde
  5. 20 Nov, 2015 3 commits
  6. 19 Nov, 2015 3 commits
  7. 18 Nov, 2015 3 commits
  8. 17 Nov, 2015 3 commits
    • Johan Euphrosine's avatar
      flatbuffers/cmake: move build_flatbuffers to a standalone file · 331d2d83
      Johan Euphrosine authored
      So that it could be included from both flatbuffers CMakeLists.txt and
      FindFlatBuffers.cmake.
      
      Change-Id: Ie16a879beef9367cd6fd9b2d2157044841a7cdbc
      331d2d83
    • Shuhei Taunma's avatar
      (PHP) add experimental support for PHP language. · 5ce86826
      Shuhei Taunma authored
      * codegen for all basic features: WIP (probably implemented all basic feature)
      * JSON parsing: NO
      * Simple mutation: NO
      * Reflection: NO
      * Buffer verifier: NO (will be add later)
      * Testing: basic: Yes
      * Testing: fuzz: Yes
      * Performance: Not bad
      * Platform: Supported Linux, OS X, Windows (has 32bit integer limitation)
      * Engine Unity: No
      
      flatc --php monster_test.fbs
      
        <?php
        //include neccessary files.
        $fbb = new Google\FlatBuffers\FlatBufferBuilder(1);
        $str = $fbb->createString("monster");
        \MyGame\Example\Monster::startMonster($fbb);
        \MyGame\Example\Monster::addHp($fbb, 80);
        \MyGame\Example\Monster::addName($fbb, $str);
        $mon = \MyGame\Example\Monster::endMonster($fbb);
        $fbb->finish($mon);
        echo $fbb->sizedByteArray();
      
      PHP 5.4 higher
      
      Currently, we do not register this library to packagist as still experimental and versioning problem.
      If you intended to use flatbuffers with composer. add repostiories section to composer.json like below.
      
        "repositories": [{
          "type": "vcs",
          "url": "https://github.com/google/flatbuffers"
        }],
      
       and just put google/flatbuffers.
      
        "require": {
          "google/flatbuffers": "*"
        }
      
      * PHP's integer is platform dependant. we strongly recommend use 64bit machine
        and don't use uint, ulong types as prevent overflow issue.
        ref: http://php.net/manual/en/language.types.integer.php
      
      * php don't support float type. floating point numbers are always parsed as double precision internally.
        ref: http://php.net/manual/en/language.types.float.php
      
      * ByteBuffer is little bit slow implemnentation due to many chr/ord function calls. Especially encoding objects.
        This is expected performance as PHP5 has parsing arguments overhead. probably we'll add C-extension.
      
      Basically, PHP implementation respects Java and C# implementation.
      
      Note: ByteBuffer and FlatBuffersBuilder class are not intended to use other purposes.
            we may change internal API foreseeable future.
      
      PSR-2, PSR-4 standards.
      
      Implemented simple assertion class (respect JavaScript testcase implementation) as we prefer small code base.
      this also keeps CI iteration speed.
      
      we'll choose phpunit or something when the test cases grown.
      5ce86826
    • Shuhei Tanuma's avatar
      C# Unity can't cast integer represented enum value. · 37e28d98
      Shuhei Tanuma authored
      ```
      namespace MyGame;
      
      enum CommandType : byte {
      	None = 0,
      }
      
      table Command {
      	id:int;
      	type:CommandType;
      }
      ```
      
      then generate c# files. it'll output compile error like these.
      
      ```
      Assets/MyGame/Command.cs(18,39): error CS1041: Identifier expected
      Assets/MyGame/Command.cs(18,39): error CS1737: Optional parameter cannot precede required parameters
      
      16:   public static Offset<Command> CreateCommand(FlatBufferBuilder builder,
      17:   int id = 0,
      18:   CommandType type = (CommandType)0) {
      ```
      37e28d98
  9. 16 Nov, 2015 3 commits
  10. 15 Nov, 2015 1 commit
  11. 14 Nov, 2015 2 commits
    • Jon Simantov's avatar
      Store the dirs you pass into build_flatbuffers as properties. · 65c9b355
      Jon Simantov authored
      This allows you to query the generated target for those properties
      later, so dependent modules can refer to the directories to, for example,
      add them to the include_directories.
      
      Change-Id: I7a6bd34c5c1d08e2ea69b5ad845223297cad1159
      65c9b355
    • Jon Simantov's avatar
      Added build_flatbuffers function to CMake. · f2949c3f
      Jon Simantov authored
      This function is designed to be called by projects that use FlatBuffers.
      It takes a list of FlatBuffers schemas and a list of schema include
      directories, and generates build rules to create generated headers
      and/or binary schemas for those files, as well as optionally copying
      all of the text schemas into a directory for your use (for example if
      you need to parse text schemas within your app).
      
      See function comments for more details.
      
      Change-Id: I181684b916e91d965e14849d8f83ec2c83e9a4a4
      f2949c3f
  12. 13 Nov, 2015 2 commits
    • Stewart Miles's avatar
      Expand local file path to allow users to fix ndk-build · ef53aebf
      Stewart Miles authored
      local-source-file-path does not expand to correct file paths in
      some circumstances so some users override it.  Therefore
      flatbuffers_header_build_rules has been modified to generate rules
      that expand LOCAL_SRC_FILES values with flatbuffers_header_build_rules.
      
      Also, this overrides local-source-file-path to allow nest projects
      to build when NDK_OUT is set.
      
      Tested:
      Verified a dependent project continues to build.
      
      Bug: 25673744
      Change-Id: Ic90186fe96d6e4533f9f3b7ca9ef78084de08a7e
      ef53aebf
    • Stewart Miles's avatar
      Pass job server arguments (-jX) to make. · 4f96603e
      Stewart Miles authored
      When $(MAKE) is expanded via a macro "make" doesn't know whether
      $(MAKE) refers to an instance of the make app and therefore doesn't
      pass job server arguments down.  This change adds the + prefix to the
      command in the receipe in order to indicate $(MAKE) is another instance of
      make.
      
      Tested:
      Verified flatc builds in parallel from Android builds.
      
      Change-Id: I9f2f4f9680b818fdda7420a75a8bfa995b4644db
      4f96603e
  13. 12 Nov, 2015 2 commits
    • rw's avatar
      Python: Improve Builder user interface. · 3232727a
      rw authored
      + Add state to the Builder object to track if we are inside a table,
        and if we are finished building the buffer.
      + Use this data to check that a buffer is being built correctly.
      + Raise an exception if a buffer is not being built correctly.
      + Test that the exceptions happen as expected.
      
      Based on d236dea1.
      3232727a
    • rw's avatar
      Improve Builder user interface. · 2dfff15a
      rw authored
      + Add state to the Builder object to track if we are inside a table,
        and if we are finished building the buffer.
      + Use this data to check that a buffer is being built correctly.
      + Panic if a buffer is not being built correctly.
      + Test that the panics happen as expected.
      
      Based on d236dea1.
      2dfff15a