diff --git a/CMake/BuildFlatBuffers.cmake b/CMake/BuildFlatBuffers.cmake
index 2c28899a7..42f78de77 100644
--- a/CMake/BuildFlatBuffers.cmake
+++ b/CMake/BuildFlatBuffers.cmake
@@ -63,6 +63,13 @@ function(build_flatbuffers flatbuffers_schemas
set(FLATC_TARGET flatc)
set(FLATC flatc)
endif()
+ set(FLATC_SCHEMA_ARGS --gen-mutable)
+ if(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS)
+ set(FLATC_SCHEMA_ARGS
+ ${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}
+ ${FLATC_SCHEMA_ARGS}
+ )
+ endif()
set(schema_glob "*.fbs")
# Generate the include files parameters.
@@ -86,7 +93,7 @@ function(build_flatbuffers flatbuffers_schemas
set(generated_include ${generated_includes_dir}/${filename}_generated.h)
add_custom_command(
OUTPUT ${generated_include}
- COMMAND ${FLATC} --gen-mutable
+ COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS}
-o ${generated_includes_dir}
${include_params}
-c ${schema}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b1e56d6b0..c2dd95085 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library" ON)
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON)
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
+option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
message(WARNING
@@ -39,7 +40,10 @@ set(FlatBuffers_Compiler_SRCS
src/idl_gen_php.cpp
src/idl_gen_python.cpp
src/idl_gen_fbs.cpp
+ src/idl_gen_grpc.cpp
src/flatc.cpp
+ grpc/src/compiler/cpp_generator.h
+ grpc/src/compiler/cpp_generator.cc
)
set(FlatHash_SRCS
@@ -76,6 +80,16 @@ set(FlatBuffers_Sample_Text_SRCS
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
)
+set(FlatBuffers_GRPCTest_SRCS
+ include/flatbuffers/flatbuffers.h
+ include/flatbuffers/grpc.h
+ tests/monster_test.grpc.fb.h
+ tests/monster_test.grpc.fb.cc
+ grpc/tests/grpctest.cpp
+ # file generated by running compiler on samples/monster.fbs
+ ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
+)
+
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
@@ -129,6 +143,7 @@ if(BIICODE)
endif()
include_directories(include)
+include_directories(grpc)
if(FLATBUFFERS_BUILD_FLATLIB)
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
@@ -174,6 +189,14 @@ if(FLATBUFFERS_BUILD_TESTS)
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
endif()
+if(FLATBUFFERS_BUILD_GRPCTEST)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
+ endif()
+ add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
+ target_link_libraries(grpctest grpc++_unsecure grpc pthread dl)
+endif()
+
if(FLATBUFFERS_INSTALL)
install(DIRECTORY include/flatbuffers DESTINATION include)
if(FLATBUFFERS_BUILD_FLATLIB)
diff --git a/android/jni/Application.mk b/android/jni/Application.mk
index 56952fc96..2fc9c7379 100755
--- a/android/jni/Application.mk
+++ b/android/jni/Application.mk
@@ -18,5 +18,5 @@ APP_PROJECT_PATH := $(call my-dir)/..
APP_STL := gnustl_static
APP_ABI := armeabi-v7a
-NDK_TOOLCHAIN_VERSION := 4.8
+
APP_CPPFLAGS += -std=c++11
diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md
index 886fbd9b8..ad584c739 100755
--- a/docs/source/Compiler.md
+++ b/docs/source/Compiler.md
@@ -33,6 +33,8 @@ For any schema input files, one or more generators can be specified:
- `--php`: Generate PHP code.
+- `--grpc`: Generate RPC stub code for GRPC.
+
For any data input files:
- `--binary`, `-b` : If data is contained in this file, generate a
diff --git a/docs/source/Schemas.md b/docs/source/Schemas.md
index 4004803de..5bcaccb37 100755
--- a/docs/source/Schemas.md
+++ b/docs/source/Schemas.md
@@ -237,7 +237,8 @@ as the response (both of which must be table types):
}
What code this produces and how it is used depends on language and RPC system
-used, FlatBuffers itself does not offer this functionality.
+used, there is preliminary support for GRPC through the `--grpc` code generator,
+see `grpc/tests` for an example.
### Comments & documentation
@@ -271,7 +272,7 @@ Current understood attributes:
the union field should have id 8, and the unions type field will
implicitly be 7.
IDs allow the fields to be placed in any order in the schema.
- When a new field is added to the schema is must use the next available ID.
+ When a new field is added to the schema it must use the next available ID.
- `deprecated` (on a field): do not generate accessors for this field
anymore, code should stop using this data.
- `required` (on a non-scalar table field): this field must always be set.
@@ -333,6 +334,10 @@ JSON:
- A field that has the value `null` (e.g. `field: null`) is intended to
have the default value for that field (thus has the same effect as if
that field wasn't specified at all).
+- It has some built in conversion functions, so you can write for example
+ `rad(180)` where ever you'd normally write `3.14159`.
+ Currently supports the following functions: `rad`, `deg`, `cos`, `sin`,
+ `tan`, `acos`, `asin`, `atan`.
When parsing JSON, it recognizes the following escape codes in strings:
diff --git a/docs/source/Tutorial.md b/docs/source/Tutorial.md
index 1e48796d9..6f6ac9a51 100644
--- a/docs/source/Tutorial.md
+++ b/docs/source/Tutorial.md
@@ -790,6 +790,14 @@ offsets.
~~~
+
+
+Note there's additional convenience overloads of `CreateVector`, allowing you
+to work with data that's not in a `std::vector`, or allowing you to generate
+elements by calling a lambda. For the common case of `std::vector`
+there's also `CreateVectorOfStrings`.
+
+
To create a `struct`, use the `Vec3` class/struct that was generated by
the schema compiler:
@@ -1075,7 +1083,7 @@ Here is a repetition these lines, to help highlight them more clearly:
~~~{.c}
// Add union type and data simultanously.
- ns(Monster_equipped_Weapon_add(B, axe));
+ ns(Monster_equipped_Weapon_add(B, axe));
~~~
diff --git a/grpc/README.md b/grpc/README.md
new file mode 100644
index 000000000..13485198c
--- /dev/null
+++ b/grpc/README.md
@@ -0,0 +1,11 @@
+GRPC implementation and test
+============================
+
+NOTE: files in `src/` are shared with the GRPC project, and maintained there
+(any changes should be submitted to GRPC instead). These files are copied
+from GRPC, and work with both the Protobuf and FlatBuffers code generator.
+
+`tests/` contains a GRPC specific test, you need to have built and installed
+the GRPC libraries for this to compile. This test will build using the
+`FLATBUFFERS_BUILD_GRPCTEST` option to the main FlatBuffers CMake project.
+
diff --git a/grpc/src/compiler/cpp_generator.cc b/grpc/src/compiler/cpp_generator.cc
new file mode 100644
index 000000000..9319c4193
--- /dev/null
+++ b/grpc/src/compiler/cpp_generator.cc
@@ -0,0 +1,1202 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include