remove old flatbuffer
diff --git a/third_party/flatbuffers/CMake/BuildFlatBuffers.cmake b/third_party/flatbuffers/CMake/BuildFlatBuffers.cmake deleted file mode 100644 index 42f78de..0000000 --- a/third_party/flatbuffers/CMake/BuildFlatBuffers.cmake +++ /dev/null
@@ -1,148 +0,0 @@ -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# General function to create FlatBuffer build rules for the given list of -# schemas. -# -# flatbuffers_schemas: A list of flatbuffer schema files to process. -# -# schema_include_dirs: A list of schema file include directories, which will be -# passed to flatc via the -I parameter. -# -# custom_target_name: The generated files will be added as dependencies for a -# new custom target with this name. You should add that target as a dependency -# for your main target to ensure these files are built. You can also retrieve -# various properties from this target, such as GENERATED_INCLUDES_DIR, -# BINARY_SCHEMAS_DIR, and COPY_TEXT_SCHEMAS_DIR. -# -# additional_dependencies: A list of additional dependencies that you'd like -# all generated files to depend on. Pass in a blank string if you have none. -# -# generated_includes_dir: Where to generate the C++ header files for these -# schemas. The generated includes directory will automatically be added to -# CMake's include directories, and will be where generated header files are -# placed. This parameter is optional; pass in empty string if you don't want to -# generate include files for these schemas. -# -# binary_schemas_dir: If you specify an optional binary schema directory, binary -# schemas will be generated for these schemas as well, and placed into the given -# directory. -# -# copy_text_schemas_dir: If you want all text schemas (including schemas from -# all schema include directories) copied into a directory (for example, if you -# need them within your project to build JSON files), you can specify that -# folder here. All text schemas will be copied to that folder. -# -# IMPORTANT: Make sure you quote all list arguments you pass to this function! -# Otherwise CMake will only pass in the first element. -# Example: build_flatbuffers("${fb_files}" "${include_dirs}" target_name ...) -function(build_flatbuffers flatbuffers_schemas - schema_include_dirs - custom_target_name - additional_dependencies - generated_includes_dir - binary_schemas_dir - copy_text_schemas_dir) - - # Test if including from FindFlatBuffers - if(FLATBUFFERS_FLATC_EXECUTABLE) - set(FLATC_TARGET "") - set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE}) - else() - 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. - set(include_params "") - set(all_generated_files "") - foreach (include_dir ${schema_include_dirs}) - set(include_params -I ${include_dir} ${include_params}) - if (NOT ${copy_text_schemas_dir} STREQUAL "") - # Copy text schemas from dependent folders. - file(GLOB_RECURSE dependent_schemas ${include_dir}/${schema_glob}) - foreach (dependent_schema ${dependent_schemas}) - file(COPY ${dependent_schema} DESTINATION ${copy_text_schemas_dir}) - endforeach() - endif() - endforeach() - - foreach(schema ${flatbuffers_schemas}) - get_filename_component(filename ${schema} NAME_WE) - # For each schema, do the things we requested. - if (NOT ${generated_includes_dir} STREQUAL "") - set(generated_include ${generated_includes_dir}/${filename}_generated.h) - add_custom_command( - OUTPUT ${generated_include} - COMMAND ${FLATC} ${FLATC_SCHEMA_ARGS} - -o ${generated_includes_dir} - ${include_params} - -c ${schema} - DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}) - list(APPEND all_generated_files ${generated_include}) - endif() - - if (NOT ${binary_schemas_dir} STREQUAL "") - set(binary_schema ${binary_schemas_dir}/${filename}.bfbs) - add_custom_command( - OUTPUT ${binary_schema} - COMMAND ${FLATC} -b --schema - -o ${binary_schemas_dir} - ${include_params} - ${schema} - DEPENDS ${FLATC_TARGET} ${schema} ${additional_dependencies}) - list(APPEND all_generated_files ${binary_schema}) - endif() - - if (NOT ${copy_text_schemas_dir} STREQUAL "") - file(COPY ${schema} DESTINATION ${copy_text_schemas_dir}) - endif() - endforeach() - - # Create a custom target that depends on all the generated files. - # This is the target that you can depend on to trigger all these - # to be built. - add_custom_target(${custom_target_name} - DEPENDS ${all_generated_files} ${additional_dependencies}) - - # Register the include directory we are using. - if (NOT ${generated_includes_dir} STREQUAL "") - include_directories(${generated_includes_dir}) - set_property(TARGET ${custom_target_name} - PROPERTY GENERATED_INCLUDES_DIR - ${generated_includes_dir}) - endif() - - # Register the binary schemas dir we are using. - if (NOT ${binary_schemas_dir} STREQUAL "") - set_property(TARGET ${custom_target_name} - PROPERTY BINARY_SCHEMAS_DIR - ${binary_schemas_dir}) - endif() - - # Register the text schema copy dir we are using. - if (NOT ${copy_text_schemas_dir} STREQUAL "") - set_property(TARGET ${custom_target_name} - PROPERTY COPY_TEXT_SCHEMAS_DIR - ${copy_text_schemas_dir}) - endif() -endfunction()
diff --git a/third_party/flatbuffers/CMake/FindFlatBuffers.cmake b/third_party/flatbuffers/CMake/FindFlatBuffers.cmake deleted file mode 100644 index 675ea88..0000000 --- a/third_party/flatbuffers/CMake/FindFlatBuffers.cmake +++ /dev/null
@@ -1,60 +0,0 @@ -# Copyright 2014 Stefan.Eilemann@epfl.ch -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Find the flatbuffers schema compiler -# -# Output Variables: -# * FLATBUFFERS_FLATC_EXECUTABLE the flatc compiler executable -# * FLATBUFFERS_FOUND -# -# Provides: -# * FLATBUFFERS_GENERATE_C_HEADERS(Name <files>) creates the C++ headers -# for the given flatbuffer schema files. -# Returns the header files in ${Name}_OUTPUTS - -set(FLATBUFFERS_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) - -find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc) -find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(flatbuffers - DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR) - -if(FLATBUFFERS_FOUND) - function(FLATBUFFERS_GENERATE_C_HEADERS Name) - set(FLATC_OUTPUTS) - foreach(FILE ${ARGN}) - get_filename_component(FLATC_OUTPUT ${FILE} NAME_WE) - set(FLATC_OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/${FLATC_OUTPUT}_generated.h") - list(APPEND FLATC_OUTPUTS ${FLATC_OUTPUT}) - - add_custom_command(OUTPUT ${FLATC_OUTPUT} - COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} - ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE} - COMMENT "Building C++ header for ${FILE}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - endforeach() - set(${Name}_OUTPUTS ${FLATC_OUTPUTS} PARENT_SCOPE) - endfunction() - - set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIR}) - include_directories(${CMAKE_BINARY_DIR}) -else() - set(FLATBUFFERS_INCLUDE_DIR) -endif() - -include("${FLATBUFFERS_CMAKE_DIR}/BuildFlatBuffers.cmake") \ No newline at end of file
diff --git a/third_party/flatbuffers/CMake/PackageDebian.cmake b/third_party/flatbuffers/CMake/PackageDebian.cmake deleted file mode 100644 index ebe8931..0000000 --- a/third_party/flatbuffers/CMake/PackageDebian.cmake +++ /dev/null
@@ -1,57 +0,0 @@ -# ------------------- Debianization --------------------- -if (UNIX) - - # Set build environment - SET(CPACK_GENERATOR "TGZ;DEB") - SET(CPACK_SOURCE_TGZ "ON") - - # Common package information - SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY - "FlatBuffers is an efficient cross platform serialization library for C++, with support for Java, C# and Go. It was created at Google specifically for game development and other performance-critical applications.") - SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers") - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Vitaly Isaev <vitalyisaev2@gmail.com>") - - # Derive package version from git - EXECUTE_PROCESS( - COMMAND date +%Y%m%d - OUTPUT_VARIABLE DATE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - EXECUTE_PROCESS( - COMMAND git describe - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}") - string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}") - string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}") - string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}") - SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) - SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) - SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) - SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}") - SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") - - # Derive architecture - IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) - FIND_PROGRAM(DPKG_CMD dpkg) - IF(NOT DPKG_CMD) - MESSAGE(STATUS "Can not find dpkg in your path, default to i386.") - SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) - ENDIF(NOT DPKG_CMD) - EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture - OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) - - # Package name - SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers") - SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt) - SET(CPACK_PACKAGE_FILE_NAME - "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") - -endif(UNIX) - -INCLUDE(CPack)
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCCompiler.cmake b/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCCompiler.cmake deleted file mode 100644 index f40522e..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCCompiler.cmake +++ /dev/null
@@ -1,67 +0,0 @@ -set(CMAKE_C_COMPILER "/usr/bin/cc") -set(CMAKE_C_COMPILER_ARG1 "") -set(CMAKE_C_COMPILER_ID "GNU") -set(CMAKE_C_COMPILER_VERSION "5.4.0") -set(CMAKE_C_COMPILER_WRAPPER "") -set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") -set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert") -set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") -set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") -set(CMAKE_C11_COMPILE_FEATURES "c_static_assert") - -set(CMAKE_C_PLATFORM_ID "Linux") -set(CMAKE_C_SIMULATE_ID "") -set(CMAKE_C_SIMULATE_VERSION "") - -set(CMAKE_AR "/usr/bin/ar") -set(CMAKE_RANLIB "/usr/bin/ranlib") -set(CMAKE_LINKER "/usr/bin/ld") -set(CMAKE_COMPILER_IS_GNUCC 1) -set(CMAKE_C_COMPILER_LOADED 1) -set(CMAKE_C_COMPILER_WORKS TRUE) -set(CMAKE_C_ABI_COMPILED TRUE) -set(CMAKE_COMPILER_IS_MINGW ) -set(CMAKE_COMPILER_IS_CYGWIN ) -if(CMAKE_COMPILER_IS_CYGWIN) - set(CYGWIN 1) - set(UNIX 1) -endif() - -set(CMAKE_C_COMPILER_ENV_VAR "CC") - -if(CMAKE_COMPILER_IS_MINGW) - set(MINGW 1) -endif() -set(CMAKE_C_COMPILER_ID_RUN 1) -set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) -set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) -set(CMAKE_C_LINKER_PREFERENCE 10) - -# Save compiler ABI information. -set(CMAKE_C_SIZEOF_DATA_PTR "8") -set(CMAKE_C_COMPILER_ABI "ELF") -set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") - -if(CMAKE_C_SIZEOF_DATA_PTR) - set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") -endif() - -if(CMAKE_C_COMPILER_ABI) - set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") -endif() - -if(CMAKE_C_LIBRARY_ARCHITECTURE) - set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") -endif() - -set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") -if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) - set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") -endif() - - - - -set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") -set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") -set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake b/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake deleted file mode 100644 index 013ee92..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake +++ /dev/null
@@ -1,68 +0,0 @@ -set(CMAKE_CXX_COMPILER "/usr/bin/c++") -set(CMAKE_CXX_COMPILER_ARG1 "") -set(CMAKE_CXX_COMPILER_ID "GNU") -set(CMAKE_CXX_COMPILER_VERSION "5.4.0") -set(CMAKE_CXX_COMPILER_WRAPPER "") -set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "98") -set(CMAKE_CXX_COMPILE_FEATURES "cxx_template_template_parameters;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates") -set(CMAKE_CXX98_COMPILE_FEATURES "cxx_template_template_parameters") -set(CMAKE_CXX11_COMPILE_FEATURES "cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") -set(CMAKE_CXX14_COMPILE_FEATURES "cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates") - -set(CMAKE_CXX_PLATFORM_ID "Linux") -set(CMAKE_CXX_SIMULATE_ID "") -set(CMAKE_CXX_SIMULATE_VERSION "") - -set(CMAKE_AR "/usr/bin/ar") -set(CMAKE_RANLIB "/usr/bin/ranlib") -set(CMAKE_LINKER "/usr/bin/ld") -set(CMAKE_COMPILER_IS_GNUCXX 1) -set(CMAKE_CXX_COMPILER_LOADED 1) -set(CMAKE_CXX_COMPILER_WORKS TRUE) -set(CMAKE_CXX_ABI_COMPILED TRUE) -set(CMAKE_COMPILER_IS_MINGW ) -set(CMAKE_COMPILER_IS_CYGWIN ) -if(CMAKE_COMPILER_IS_CYGWIN) - set(CYGWIN 1) - set(UNIX 1) -endif() - -set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") - -if(CMAKE_COMPILER_IS_MINGW) - set(MINGW 1) -endif() -set(CMAKE_CXX_COMPILER_ID_RUN 1) -set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) -set(CMAKE_CXX_LINKER_PREFERENCE 30) -set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) - -# Save compiler ABI information. -set(CMAKE_CXX_SIZEOF_DATA_PTR "8") -set(CMAKE_CXX_COMPILER_ABI "ELF") -set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") - -if(CMAKE_CXX_SIZEOF_DATA_PTR) - set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") -endif() - -if(CMAKE_CXX_COMPILER_ABI) - set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") -endif() - -if(CMAKE_CXX_LIBRARY_ARCHITECTURE) - set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") -endif() - -set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "") -if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX) - set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}") -endif() - - - - -set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c") -set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") -set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin b/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin deleted file mode 100755 index c87e38c..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin b/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin deleted file mode 100755 index fa40640..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeSystem.cmake b/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeSystem.cmake deleted file mode 100644 index 60ce33f..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CMakeSystem.cmake +++ /dev/null
@@ -1,15 +0,0 @@ -set(CMAKE_HOST_SYSTEM "Linux-4.4.0-72-generic") -set(CMAKE_HOST_SYSTEM_NAME "Linux") -set(CMAKE_HOST_SYSTEM_VERSION "4.4.0-72-generic") -set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") - - - -set(CMAKE_SYSTEM "Linux-4.4.0-72-generic") -set(CMAKE_SYSTEM_NAME "Linux") -set(CMAKE_SYSTEM_VERSION "4.4.0-72-generic") -set(CMAKE_SYSTEM_PROCESSOR "x86_64") - -set(CMAKE_CROSSCOMPILING "FALSE") - -set(CMAKE_SYSTEM_LOADED 1)
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdC/CMakeCCompilerId.c b/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdC/CMakeCCompilerId.c deleted file mode 100644 index 570a15e..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdC/CMakeCCompilerId.c +++ /dev/null
@@ -1,544 +0,0 @@ -#ifdef __cplusplus -# error "A C++ compiler has been selected for C." -#endif - -#if defined(__18CXX) -# define ID_VOID_MAIN -#endif - - -/* Version number components: V=Version, R=Revision, P=Patch - Version date components: YYYY=Year, MM=Month, DD=Day */ - -#if defined(__INTEL_COMPILER) || defined(__ICC) -# define COMPILER_ID "Intel" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif - /* __INTEL_COMPILER = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) -# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# if defined(__INTEL_COMPILER_UPDATE) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) -# else -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) -# endif -# if defined(__INTEL_COMPILER_BUILD_DATE) - /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ -# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) -# endif -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif - -#elif defined(__PATHCC__) -# define COMPILER_ID "PathScale" -# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) -# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) -# if defined(__PATHCC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) -# endif - -#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) -# define COMPILER_ID "Embarcadero" -# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) -# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) -# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) - -#elif defined(__BORLANDC__) -# define COMPILER_ID "Borland" - /* __BORLANDC__ = 0xVRR */ -# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) -# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) - -#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__WATCOMC__) -# define COMPILER_ID "OpenWatcom" - /* __WATCOMC__ = VVRP + 1100 */ -# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__SUNPRO_C) -# define COMPILER_ID "SunPro" -# if __SUNPRO_C >= 0x5100 - /* __SUNPRO_C = 0xVRRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) -# else - /* __SUNPRO_CC = 0xVRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) -# endif - -#elif defined(__HP_cc) -# define COMPILER_ID "HP" - /* __HP_cc = VVRRPP */ -# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) -# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) -# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) - -#elif defined(__DECC) -# define COMPILER_ID "Compaq" - /* __DECC_VER = VVRRTPPPP */ -# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) -# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) -# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) - -#elif defined(__IBMC__) && defined(__COMPILER_VER__) -# define COMPILER_ID "zOS" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 -# define COMPILER_ID "XL" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 -# define COMPILER_ID "VisualAge" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__PGI) -# define COMPILER_ID "PGI" -# define COMPILER_VERSION_MAJOR DEC(__PGIC__) -# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) -# if defined(__PGIC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) -# endif - -#elif defined(_CRAYC) -# define COMPILER_ID "Cray" -# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) -# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) - -#elif defined(__TI_COMPILER_VERSION__) -# define COMPILER_ID "TI" - /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ -# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) -# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) -# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) - -#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) -# define COMPILER_ID "Fujitsu" - -#elif defined(__TINYC__) -# define COMPILER_ID "TinyCC" - -#elif defined(__SCO_VERSION__) -# define COMPILER_ID "SCO" - -#elif defined(__clang__) && defined(__apple_build_version__) -# define COMPILER_ID "AppleClang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif -# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) - -#elif defined(__clang__) -# define COMPILER_ID "Clang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif - -#elif defined(__GNUC__) -# define COMPILER_ID "GNU" -# define COMPILER_VERSION_MAJOR DEC(__GNUC__) -# if defined(__GNUC_MINOR__) -# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) -# endif -# if defined(__GNUC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -# endif - -#elif defined(_MSC_VER) -# define COMPILER_ID "MSVC" - /* _MSC_VER = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) -# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) -# if defined(_MSC_FULL_VER) -# if _MSC_VER >= 1400 - /* _MSC_FULL_VER = VVRRPPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) -# else - /* _MSC_FULL_VER = VVRRPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) -# endif -# endif -# if defined(_MSC_BUILD) -# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) -# endif - -#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -# define COMPILER_ID "ADSP" -#if defined(__VISUALDSPVERSION__) - /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ -# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) -# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) -# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) -#endif - -#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) -# define COMPILER_ID "IAR" - -#elif defined(__ARMCC_VERSION) -# define COMPILER_ID "ARMCC" -#if __ARMCC_VERSION >= 1000000 - /* __ARMCC_VERSION = VRRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#else - /* __ARMCC_VERSION = VRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#endif - - -#elif defined(SDCC) -# define COMPILER_ID "SDCC" - /* SDCC = VRP */ -# define COMPILER_VERSION_MAJOR DEC(SDCC/100) -# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) -# define COMPILER_VERSION_PATCH DEC(SDCC % 10) - -#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) -# define COMPILER_ID "MIPSpro" -# if defined(_SGI_COMPILER_VERSION) - /* _SGI_COMPILER_VERSION = VRP */ -# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) -# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) -# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) -# else - /* _COMPILER_VERSION = VRP */ -# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) -# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) -# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) -# endif - - -/* These compilers are either not known or too old to define an - identification macro. Try to identify the platform and guess that - it is the native compiler. */ -#elif defined(__sgi) -# define COMPILER_ID "MIPSpro" - -#elif defined(__hpux) || defined(__hpua) -# define COMPILER_ID "HP" - -#else /* unknown compiler */ -# define COMPILER_ID "" -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; -#ifdef SIMULATE_ID -char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; -#endif - -#ifdef __QNXNTO__ -char const* qnxnto = "INFO" ":" "qnxnto[]"; -#endif - -#if defined(__CRAYXE) || defined(__CRAYXC) -char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; -#endif - -#define STRINGIFY_HELPER(X) #X -#define STRINGIFY(X) STRINGIFY_HELPER(X) - -/* Identify known platforms by name. */ -#if defined(__linux) || defined(__linux__) || defined(linux) -# define PLATFORM_ID "Linux" - -#elif defined(__CYGWIN__) -# define PLATFORM_ID "Cygwin" - -#elif defined(__MINGW32__) -# define PLATFORM_ID "MinGW" - -#elif defined(__APPLE__) -# define PLATFORM_ID "Darwin" - -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -# define PLATFORM_ID "Windows" - -#elif defined(__FreeBSD__) || defined(__FreeBSD) -# define PLATFORM_ID "FreeBSD" - -#elif defined(__NetBSD__) || defined(__NetBSD) -# define PLATFORM_ID "NetBSD" - -#elif defined(__OpenBSD__) || defined(__OPENBSD) -# define PLATFORM_ID "OpenBSD" - -#elif defined(__sun) || defined(sun) -# define PLATFORM_ID "SunOS" - -#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) -# define PLATFORM_ID "AIX" - -#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) -# define PLATFORM_ID "IRIX" - -#elif defined(__hpux) || defined(__hpux__) -# define PLATFORM_ID "HP-UX" - -#elif defined(__HAIKU__) -# define PLATFORM_ID "Haiku" - -#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) -# define PLATFORM_ID "BeOS" - -#elif defined(__QNX__) || defined(__QNXNTO__) -# define PLATFORM_ID "QNX" - -#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) -# define PLATFORM_ID "Tru64" - -#elif defined(__riscos) || defined(__riscos__) -# define PLATFORM_ID "RISCos" - -#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) -# define PLATFORM_ID "SINIX" - -#elif defined(__UNIX_SV__) -# define PLATFORM_ID "UNIX_SV" - -#elif defined(__bsdos__) -# define PLATFORM_ID "BSDOS" - -#elif defined(_MPRAS) || defined(MPRAS) -# define PLATFORM_ID "MP-RAS" - -#elif defined(__osf) || defined(__osf__) -# define PLATFORM_ID "OSF1" - -#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) -# define PLATFORM_ID "SCO_SV" - -#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) -# define PLATFORM_ID "ULTRIX" - -#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) -# define PLATFORM_ID "Xenix" - -#elif defined(__WATCOMC__) -# if defined(__LINUX__) -# define PLATFORM_ID "Linux" - -# elif defined(__DOS__) -# define PLATFORM_ID "DOS" - -# elif defined(__OS2__) -# define PLATFORM_ID "OS2" - -# elif defined(__WINDOWS__) -# define PLATFORM_ID "Windows3x" - -# else /* unknown platform */ -# define PLATFORM_ID "" -# endif - -#else /* unknown platform */ -# define PLATFORM_ID "" - -#endif - -/* For windows compilers MSVC and Intel we can determine - the architecture of the compiler being used. This is because - the compilers do not have flags that can change the architecture, - but rather depend on which compiler is being used -*/ -#if defined(_WIN32) && defined(_MSC_VER) -# if defined(_M_IA64) -# define ARCHITECTURE_ID "IA64" - -# elif defined(_M_X64) || defined(_M_AMD64) -# define ARCHITECTURE_ID "x64" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# elif defined(_M_ARM) -# if _M_ARM == 4 -# define ARCHITECTURE_ID "ARMV4I" -# elif _M_ARM == 5 -# define ARCHITECTURE_ID "ARMV5I" -# else -# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) -# endif - -# elif defined(_M_MIPS) -# define ARCHITECTURE_ID "MIPS" - -# elif defined(_M_SH) -# define ARCHITECTURE_ID "SHx" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__WATCOMC__) -# if defined(_M_I86) -# define ARCHITECTURE_ID "I86" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#else -# define ARCHITECTURE_ID "" -#endif - -/* Convert integer to decimal digit literals. */ -#define DEC(n) \ - ('0' + (((n) / 10000000)%10)), \ - ('0' + (((n) / 1000000)%10)), \ - ('0' + (((n) / 100000)%10)), \ - ('0' + (((n) / 10000)%10)), \ - ('0' + (((n) / 1000)%10)), \ - ('0' + (((n) / 100)%10)), \ - ('0' + (((n) / 10)%10)), \ - ('0' + ((n) % 10)) - -/* Convert integer to hex digit literals. */ -#define HEX(n) \ - ('0' + ((n)>>28 & 0xF)), \ - ('0' + ((n)>>24 & 0xF)), \ - ('0' + ((n)>>20 & 0xF)), \ - ('0' + ((n)>>16 & 0xF)), \ - ('0' + ((n)>>12 & 0xF)), \ - ('0' + ((n)>>8 & 0xF)), \ - ('0' + ((n)>>4 & 0xF)), \ - ('0' + ((n) & 0xF)) - -/* Construct a string literal encoding the version number components. */ -#ifdef COMPILER_VERSION_MAJOR -char const info_version[] = { - 'I', 'N', 'F', 'O', ':', - 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', - COMPILER_VERSION_MAJOR, -# ifdef COMPILER_VERSION_MINOR - '.', COMPILER_VERSION_MINOR, -# ifdef COMPILER_VERSION_PATCH - '.', COMPILER_VERSION_PATCH, -# ifdef COMPILER_VERSION_TWEAK - '.', COMPILER_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct a string literal encoding the version number components. */ -#ifdef SIMULATE_VERSION_MAJOR -char const info_simulate_version[] = { - 'I', 'N', 'F', 'O', ':', - 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', - SIMULATE_VERSION_MAJOR, -# ifdef SIMULATE_VERSION_MINOR - '.', SIMULATE_VERSION_MINOR, -# ifdef SIMULATE_VERSION_PATCH - '.', SIMULATE_VERSION_PATCH, -# ifdef SIMULATE_VERSION_TWEAK - '.', SIMULATE_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; -char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; - - - - -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" -#if !defined(__STDC_VERSION__) - "90" -#elif __STDC_VERSION__ >= 201000L - "11" -#elif __STDC_VERSION__ >= 199901L - "99" -#else -#endif -"]"; - -/*--------------------------------------------------------------------------*/ - -#ifdef ID_VOID_MAIN -void main() {} -#else -int main(int argc, char* argv[]) -{ - int require = 0; - require += info_compiler[argc]; - require += info_platform[argc]; - require += info_arch[argc]; -#ifdef COMPILER_VERSION_MAJOR - require += info_version[argc]; -#endif -#ifdef SIMULATE_ID - require += info_simulate[argc]; -#endif -#ifdef SIMULATE_VERSION_MAJOR - require += info_simulate_version[argc]; -#endif -#if defined(__CRAYXE) || defined(__CRAYXC) - require += info_cray[argc]; -#endif - require += info_language_dialect_default[argc]; - (void)argv; - return require; -} -#endif
diff --git a/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp b/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp deleted file mode 100644 index e6d8536..0000000 --- a/third_party/flatbuffers/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp +++ /dev/null
@@ -1,533 +0,0 @@ -/* This source file must have a .cpp extension so that all C++ compilers - recognize the extension without flags. Borland does not know .cxx for - example. */ -#ifndef __cplusplus -# error "A C compiler has been selected for C++." -#endif - - -/* Version number components: V=Version, R=Revision, P=Patch - Version date components: YYYY=Year, MM=Month, DD=Day */ - -#if defined(__COMO__) -# define COMPILER_ID "Comeau" - /* __COMO_VERSION__ = VRR */ -# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) -# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) - -#elif defined(__INTEL_COMPILER) || defined(__ICC) -# define COMPILER_ID "Intel" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif - /* __INTEL_COMPILER = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) -# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# if defined(__INTEL_COMPILER_UPDATE) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) -# else -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) -# endif -# if defined(__INTEL_COMPILER_BUILD_DATE) - /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ -# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) -# endif -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif - -#elif defined(__PATHCC__) -# define COMPILER_ID "PathScale" -# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) -# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) -# if defined(__PATHCC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) -# endif - -#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) -# define COMPILER_ID "Embarcadero" -# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) -# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) -# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) - -#elif defined(__BORLANDC__) -# define COMPILER_ID "Borland" - /* __BORLANDC__ = 0xVRR */ -# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) -# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) - -#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__WATCOMC__) -# define COMPILER_ID "OpenWatcom" - /* __WATCOMC__ = VVRP + 1100 */ -# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__SUNPRO_CC) -# define COMPILER_ID "SunPro" -# if __SUNPRO_CC >= 0x5100 - /* __SUNPRO_CC = 0xVRRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) -# else - /* __SUNPRO_CC = 0xVRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) -# endif - -#elif defined(__HP_aCC) -# define COMPILER_ID "HP" - /* __HP_aCC = VVRRPP */ -# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) -# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) -# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) - -#elif defined(__DECCXX) -# define COMPILER_ID "Compaq" - /* __DECCXX_VER = VVRRTPPPP */ -# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) -# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) -# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) - -#elif defined(__IBMCPP__) && defined(__COMPILER_VER__) -# define COMPILER_ID "zOS" - /* __IBMCPP__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) - -#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 -# define COMPILER_ID "XL" - /* __IBMCPP__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) - -#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 -# define COMPILER_ID "VisualAge" - /* __IBMCPP__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) - -#elif defined(__PGI) -# define COMPILER_ID "PGI" -# define COMPILER_VERSION_MAJOR DEC(__PGIC__) -# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) -# if defined(__PGIC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) -# endif - -#elif defined(_CRAYC) -# define COMPILER_ID "Cray" -# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) -# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) - -#elif defined(__TI_COMPILER_VERSION__) -# define COMPILER_ID "TI" - /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ -# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) -# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) -# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) - -#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) -# define COMPILER_ID "Fujitsu" - -#elif defined(__SCO_VERSION__) -# define COMPILER_ID "SCO" - -#elif defined(__clang__) && defined(__apple_build_version__) -# define COMPILER_ID "AppleClang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif -# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) - -#elif defined(__clang__) -# define COMPILER_ID "Clang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif - -#elif defined(__GNUC__) -# define COMPILER_ID "GNU" -# define COMPILER_VERSION_MAJOR DEC(__GNUC__) -# if defined(__GNUC_MINOR__) -# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) -# endif -# if defined(__GNUC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -# endif - -#elif defined(_MSC_VER) -# define COMPILER_ID "MSVC" - /* _MSC_VER = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) -# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) -# if defined(_MSC_FULL_VER) -# if _MSC_VER >= 1400 - /* _MSC_FULL_VER = VVRRPPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) -# else - /* _MSC_FULL_VER = VVRRPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) -# endif -# endif -# if defined(_MSC_BUILD) -# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) -# endif - -#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -# define COMPILER_ID "ADSP" -#if defined(__VISUALDSPVERSION__) - /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ -# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) -# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) -# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) -#endif - -#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) -# define COMPILER_ID "IAR" - -#elif defined(__ARMCC_VERSION) -# define COMPILER_ID "ARMCC" -#if __ARMCC_VERSION >= 1000000 - /* __ARMCC_VERSION = VRRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#else - /* __ARMCC_VERSION = VRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#endif - - -#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) -# define COMPILER_ID "MIPSpro" -# if defined(_SGI_COMPILER_VERSION) - /* _SGI_COMPILER_VERSION = VRP */ -# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) -# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) -# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) -# else - /* _COMPILER_VERSION = VRP */ -# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) -# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) -# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) -# endif - - -/* These compilers are either not known or too old to define an - identification macro. Try to identify the platform and guess that - it is the native compiler. */ -#elif defined(__sgi) -# define COMPILER_ID "MIPSpro" - -#elif defined(__hpux) || defined(__hpua) -# define COMPILER_ID "HP" - -#else /* unknown compiler */ -# define COMPILER_ID "" -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; -#ifdef SIMULATE_ID -char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; -#endif - -#ifdef __QNXNTO__ -char const* qnxnto = "INFO" ":" "qnxnto[]"; -#endif - -#if defined(__CRAYXE) || defined(__CRAYXC) -char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; -#endif - -#define STRINGIFY_HELPER(X) #X -#define STRINGIFY(X) STRINGIFY_HELPER(X) - -/* Identify known platforms by name. */ -#if defined(__linux) || defined(__linux__) || defined(linux) -# define PLATFORM_ID "Linux" - -#elif defined(__CYGWIN__) -# define PLATFORM_ID "Cygwin" - -#elif defined(__MINGW32__) -# define PLATFORM_ID "MinGW" - -#elif defined(__APPLE__) -# define PLATFORM_ID "Darwin" - -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -# define PLATFORM_ID "Windows" - -#elif defined(__FreeBSD__) || defined(__FreeBSD) -# define PLATFORM_ID "FreeBSD" - -#elif defined(__NetBSD__) || defined(__NetBSD) -# define PLATFORM_ID "NetBSD" - -#elif defined(__OpenBSD__) || defined(__OPENBSD) -# define PLATFORM_ID "OpenBSD" - -#elif defined(__sun) || defined(sun) -# define PLATFORM_ID "SunOS" - -#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) -# define PLATFORM_ID "AIX" - -#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) -# define PLATFORM_ID "IRIX" - -#elif defined(__hpux) || defined(__hpux__) -# define PLATFORM_ID "HP-UX" - -#elif defined(__HAIKU__) -# define PLATFORM_ID "Haiku" - -#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) -# define PLATFORM_ID "BeOS" - -#elif defined(__QNX__) || defined(__QNXNTO__) -# define PLATFORM_ID "QNX" - -#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) -# define PLATFORM_ID "Tru64" - -#elif defined(__riscos) || defined(__riscos__) -# define PLATFORM_ID "RISCos" - -#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) -# define PLATFORM_ID "SINIX" - -#elif defined(__UNIX_SV__) -# define PLATFORM_ID "UNIX_SV" - -#elif defined(__bsdos__) -# define PLATFORM_ID "BSDOS" - -#elif defined(_MPRAS) || defined(MPRAS) -# define PLATFORM_ID "MP-RAS" - -#elif defined(__osf) || defined(__osf__) -# define PLATFORM_ID "OSF1" - -#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) -# define PLATFORM_ID "SCO_SV" - -#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) -# define PLATFORM_ID "ULTRIX" - -#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) -# define PLATFORM_ID "Xenix" - -#elif defined(__WATCOMC__) -# if defined(__LINUX__) -# define PLATFORM_ID "Linux" - -# elif defined(__DOS__) -# define PLATFORM_ID "DOS" - -# elif defined(__OS2__) -# define PLATFORM_ID "OS2" - -# elif defined(__WINDOWS__) -# define PLATFORM_ID "Windows3x" - -# else /* unknown platform */ -# define PLATFORM_ID "" -# endif - -#else /* unknown platform */ -# define PLATFORM_ID "" - -#endif - -/* For windows compilers MSVC and Intel we can determine - the architecture of the compiler being used. This is because - the compilers do not have flags that can change the architecture, - but rather depend on which compiler is being used -*/ -#if defined(_WIN32) && defined(_MSC_VER) -# if defined(_M_IA64) -# define ARCHITECTURE_ID "IA64" - -# elif defined(_M_X64) || defined(_M_AMD64) -# define ARCHITECTURE_ID "x64" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# elif defined(_M_ARM) -# if _M_ARM == 4 -# define ARCHITECTURE_ID "ARMV4I" -# elif _M_ARM == 5 -# define ARCHITECTURE_ID "ARMV5I" -# else -# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) -# endif - -# elif defined(_M_MIPS) -# define ARCHITECTURE_ID "MIPS" - -# elif defined(_M_SH) -# define ARCHITECTURE_ID "SHx" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__WATCOMC__) -# if defined(_M_I86) -# define ARCHITECTURE_ID "I86" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#else -# define ARCHITECTURE_ID "" -#endif - -/* Convert integer to decimal digit literals. */ -#define DEC(n) \ - ('0' + (((n) / 10000000)%10)), \ - ('0' + (((n) / 1000000)%10)), \ - ('0' + (((n) / 100000)%10)), \ - ('0' + (((n) / 10000)%10)), \ - ('0' + (((n) / 1000)%10)), \ - ('0' + (((n) / 100)%10)), \ - ('0' + (((n) / 10)%10)), \ - ('0' + ((n) % 10)) - -/* Convert integer to hex digit literals. */ -#define HEX(n) \ - ('0' + ((n)>>28 & 0xF)), \ - ('0' + ((n)>>24 & 0xF)), \ - ('0' + ((n)>>20 & 0xF)), \ - ('0' + ((n)>>16 & 0xF)), \ - ('0' + ((n)>>12 & 0xF)), \ - ('0' + ((n)>>8 & 0xF)), \ - ('0' + ((n)>>4 & 0xF)), \ - ('0' + ((n) & 0xF)) - -/* Construct a string literal encoding the version number components. */ -#ifdef COMPILER_VERSION_MAJOR -char const info_version[] = { - 'I', 'N', 'F', 'O', ':', - 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', - COMPILER_VERSION_MAJOR, -# ifdef COMPILER_VERSION_MINOR - '.', COMPILER_VERSION_MINOR, -# ifdef COMPILER_VERSION_PATCH - '.', COMPILER_VERSION_PATCH, -# ifdef COMPILER_VERSION_TWEAK - '.', COMPILER_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct a string literal encoding the version number components. */ -#ifdef SIMULATE_VERSION_MAJOR -char const info_simulate_version[] = { - 'I', 'N', 'F', 'O', ':', - 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', - SIMULATE_VERSION_MAJOR, -# ifdef SIMULATE_VERSION_MINOR - '.', SIMULATE_VERSION_MINOR, -# ifdef SIMULATE_VERSION_PATCH - '.', SIMULATE_VERSION_PATCH, -# ifdef SIMULATE_VERSION_TWEAK - '.', SIMULATE_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; -char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; - - - - -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" -#if __cplusplus >= 201402L - "14" -#elif __cplusplus >= 201103L - "11" -#else - "98" -#endif -"]"; - -/*--------------------------------------------------------------------------*/ - -int main(int argc, char* argv[]) -{ - int require = 0; - require += info_compiler[argc]; - require += info_platform[argc]; -#ifdef COMPILER_VERSION_MAJOR - require += info_version[argc]; -#endif -#ifdef SIMULATE_ID - require += info_simulate[argc]; -#endif -#ifdef SIMULATE_VERSION_MAJOR - require += info_simulate_version[argc]; -#endif -#if defined(__CRAYXE) || defined(__CRAYXC) - require += info_cray[argc]; -#endif - require += info_language_dialect_default[argc]; - (void)argv; - return require; -}
diff --git a/third_party/flatbuffers/CMakeFiles/CMakeDirectoryInformation.cmake b/third_party/flatbuffers/CMakeFiles/CMakeDirectoryInformation.cmake deleted file mode 100644 index 7c5eeea..0000000 --- a/third_party/flatbuffers/CMakeFiles/CMakeDirectoryInformation.cmake +++ /dev/null
@@ -1,16 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Relative path conversion top directories. -set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/alain/flatbuffers") -set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/alain/flatbuffers") - -# Force unix paths in dependencies. -set(CMAKE_FORCE_UNIX_PATHS 1) - - -# The C and CXX include file regular expressions for this directory. -set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") -set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") -set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) -set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
diff --git a/third_party/flatbuffers/CMakeFiles/CMakeOutput.log b/third_party/flatbuffers/CMakeFiles/CMakeOutput.log deleted file mode 100644 index c7192f0..0000000 --- a/third_party/flatbuffers/CMakeFiles/CMakeOutput.log +++ /dev/null
@@ -1,554 +0,0 @@ -The system is: Linux - 4.4.0-72-generic - x86_64 -Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. -Compiler: /usr/bin/cc -Build flags: -Id flags: - -The output was: -0 - - -Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" - -The C compiler identification is GNU, found in "/home/alain/flatbuffers/CMakeFiles/3.5.1/CompilerIdC/a.out" - -Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. -Compiler: /usr/bin/c++ -Build flags: -Id flags: - -The output was: -0 - - -Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" - -The CXX compiler identification is GNU, found in "/home/alain/flatbuffers/CMakeFiles/3.5.1/CompilerIdCXX/a.out" - -Determining if the C compiler works passed with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_01020/fast" -/usr/bin/make -f CMakeFiles/cmTC_01020.dir/build.make CMakeFiles/cmTC_01020.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_01020.dir/testCCompiler.c.o -/usr/bin/cc -o CMakeFiles/cmTC_01020.dir/testCCompiler.c.o -c /home/alain/flatbuffers/CMakeFiles/CMakeTmp/testCCompiler.c -Linking C executable cmTC_01020 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_01020.dir/link.txt --verbose=1 -/usr/bin/cc CMakeFiles/cmTC_01020.dir/testCCompiler.c.o -o cmTC_01020 -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - -Detecting C compiler ABI info compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_f07e3/fast" -/usr/bin/make -f CMakeFiles/cmTC_f07e3.dir/build.make CMakeFiles/cmTC_f07e3.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -/usr/bin/cc -o CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.5/Modules/CMakeCCompilerABI.c -Linking C executable cmTC_f07e3 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f07e3.dir/link.txt --verbose=1 -/usr/bin/cc -v CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -o cmTC_f07e3 -rdynamic -Using built-in specs. -COLLECT_GCC=/usr/bin/cc -COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -Target: x86_64-linux-gnu -Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu -Thread model: posix -gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) -COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ -LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f07e3' '-rdynamic' '-mtune=generic' '-march=x86-64' - /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpJXzxC.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTC_f07e3 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - -Parsed C implicit link information from above output: - link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] - ignore line: [Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp] - ignore line: [] - ignore line: [Run Build Command:"/usr/bin/make" "cmTC_f07e3/fast"] - ignore line: [/usr/bin/make -f CMakeFiles/cmTC_f07e3.dir/build.make CMakeFiles/cmTC_f07e3.dir/build] - ignore line: [make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp'] - ignore line: [Building C object CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o] - ignore line: [/usr/bin/cc -o CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.5/Modules/CMakeCCompilerABI.c] - ignore line: [Linking C executable cmTC_f07e3] - ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f07e3.dir/link.txt --verbose=1] - ignore line: [/usr/bin/cc -v CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -o cmTC_f07e3 -rdynamic ] - ignore line: [Using built-in specs.] - ignore line: [COLLECT_GCC=/usr/bin/cc] - ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper] - ignore line: [Target: x86_64-linux-gnu] - ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu] - ignore line: [Thread model: posix] - ignore line: [gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ] - ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/] - ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_f07e3' '-rdynamic' '-mtune=generic' '-march=x86-64'] - link line: [ /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccpJXzxC.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTC_f07e3 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o] - arg [/usr/lib/gcc/x86_64-linux-gnu/5/collect2] ==> ignore - arg [-plugin] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so] ==> ignore - arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper] ==> ignore - arg [-plugin-opt=-fresolution=/tmp/ccpJXzxC.res] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore - arg [-plugin-opt=-pass-through=-lc] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore - arg [--sysroot=/] ==> ignore - arg [--build-id] ==> ignore - arg [--eh-frame-hdr] ==> ignore - arg [-m] ==> ignore - arg [elf_x86_64] ==> ignore - arg [--hash-style=gnu] ==> ignore - arg [--as-needed] ==> ignore - arg [-export-dynamic] ==> ignore - arg [-dynamic-linker] ==> ignore - arg [/lib64/ld-linux-x86-64.so.2] ==> ignore - arg [-zrelro] ==> ignore - arg [-o] ==> ignore - arg [cmTC_f07e3] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o] ==> ignore - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] - arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu] - arg [-L/lib/../lib] ==> dir [/lib/../lib] - arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu] - arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../..] - arg [CMakeFiles/cmTC_f07e3.dir/CMakeCCompilerABI.c.o] ==> ignore - arg [-lgcc] ==> lib [gcc] - arg [--as-needed] ==> ignore - arg [-lgcc_s] ==> lib [gcc_s] - arg [--no-as-needed] ==> ignore - arg [-lc] ==> lib [c] - arg [-lgcc] ==> lib [gcc] - arg [--as-needed] ==> ignore - arg [-lgcc_s] ==> lib [gcc_s] - arg [--no-as-needed] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/crtend.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o] ==> ignore - remove lib [gcc] - remove lib [gcc_s] - remove lib [gcc] - remove lib [gcc_s] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5] ==> [/usr/lib/gcc/x86_64-linux-gnu/5] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] ==> [/usr/lib] - collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu] - collapse library dir [/lib/../lib] ==> [/lib] - collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] - collapse library dir [/usr/lib/../lib] ==> [/usr/lib] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../..] ==> [/usr/lib] - implicit libs: [c] - implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib] - implicit fwks: [] - - - - -Detecting C [-std=c11] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_268e5/fast" -/usr/bin/make -f CMakeFiles/cmTC_268e5.dir/build.make CMakeFiles/cmTC_268e5.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_268e5.dir/feature_tests.c.o -/usr/bin/cc -std=c11 -o CMakeFiles/cmTC_268e5.dir/feature_tests.c.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.c -Linking C executable cmTC_268e5 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_268e5.dir/link.txt --verbose=1 -/usr/bin/cc CMakeFiles/cmTC_268e5.dir/feature_tests.c.o -o cmTC_268e5 -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: C_FEATURE:1c_function_prototypes - Feature record: C_FEATURE:1c_restrict - Feature record: C_FEATURE:1c_static_assert - Feature record: C_FEATURE:1c_variadic_macros - - -Detecting C [-std=c99] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_f08a0/fast" -/usr/bin/make -f CMakeFiles/cmTC_f08a0.dir/build.make CMakeFiles/cmTC_f08a0.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_f08a0.dir/feature_tests.c.o -/usr/bin/cc -std=c99 -o CMakeFiles/cmTC_f08a0.dir/feature_tests.c.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.c -Linking C executable cmTC_f08a0 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f08a0.dir/link.txt --verbose=1 -/usr/bin/cc CMakeFiles/cmTC_f08a0.dir/feature_tests.c.o -o cmTC_f08a0 -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: C_FEATURE:1c_function_prototypes - Feature record: C_FEATURE:1c_restrict - Feature record: C_FEATURE:0c_static_assert - Feature record: C_FEATURE:1c_variadic_macros - - -Detecting C [-std=c90] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_de240/fast" -/usr/bin/make -f CMakeFiles/cmTC_de240.dir/build.make CMakeFiles/cmTC_de240.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building C object CMakeFiles/cmTC_de240.dir/feature_tests.c.o -/usr/bin/cc -std=c90 -o CMakeFiles/cmTC_de240.dir/feature_tests.c.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.c -Linking C executable cmTC_de240 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_de240.dir/link.txt --verbose=1 -/usr/bin/cc CMakeFiles/cmTC_de240.dir/feature_tests.c.o -o cmTC_de240 -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: C_FEATURE:1c_function_prototypes - Feature record: C_FEATURE:0c_restrict - Feature record: C_FEATURE:0c_static_assert - Feature record: C_FEATURE:0c_variadic_macros -Determining if the CXX compiler works passed with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_09f2d/fast" -/usr/bin/make -f CMakeFiles/cmTC_09f2d.dir/build.make CMakeFiles/cmTC_09f2d.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_09f2d.dir/testCXXCompiler.cxx.o -/usr/bin/c++ -o CMakeFiles/cmTC_09f2d.dir/testCXXCompiler.cxx.o -c /home/alain/flatbuffers/CMakeFiles/CMakeTmp/testCXXCompiler.cxx -Linking CXX executable cmTC_09f2d -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_09f2d.dir/link.txt --verbose=1 -/usr/bin/c++ CMakeFiles/cmTC_09f2d.dir/testCXXCompiler.cxx.o -o cmTC_09f2d -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - -Detecting CXX compiler ABI info compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_58731/fast" -/usr/bin/make -f CMakeFiles/cmTC_58731.dir/build.make CMakeFiles/cmTC_58731.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -/usr/bin/c++ -o CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp -Linking CXX executable cmTC_58731 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_58731.dir/link.txt --verbose=1 -/usr/bin/c++ -v CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_58731 -rdynamic -Using built-in specs. -COLLECT_GCC=/usr/bin/c++ -COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -Target: x86_64-linux-gnu -Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu -Thread model: posix -gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) -COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ -LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ -COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_58731' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64' - /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccADydt5.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTC_58731 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - -Parsed CXX implicit link information from above output: - link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] - ignore line: [Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp] - ignore line: [] - ignore line: [Run Build Command:"/usr/bin/make" "cmTC_58731/fast"] - ignore line: [/usr/bin/make -f CMakeFiles/cmTC_58731.dir/build.make CMakeFiles/cmTC_58731.dir/build] - ignore line: [make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp'] - ignore line: [Building CXX object CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o] - ignore line: [/usr/bin/c++ -o CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp] - ignore line: [Linking CXX executable cmTC_58731] - ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_58731.dir/link.txt --verbose=1] - ignore line: [/usr/bin/c++ -v CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_58731 -rdynamic ] - ignore line: [Using built-in specs.] - ignore line: [COLLECT_GCC=/usr/bin/c++] - ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper] - ignore line: [Target: x86_64-linux-gnu] - ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu] - ignore line: [Thread model: posix] - ignore line: [gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ] - ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/] - ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/] - ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_58731' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64'] - link line: [ /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccADydt5.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTC_58731 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o] - arg [/usr/lib/gcc/x86_64-linux-gnu/5/collect2] ==> ignore - arg [-plugin] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so] ==> ignore - arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper] ==> ignore - arg [-plugin-opt=-fresolution=/tmp/ccADydt5.res] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc] ==> ignore - arg [-plugin-opt=-pass-through=-lc] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore - arg [-plugin-opt=-pass-through=-lgcc] ==> ignore - arg [--sysroot=/] ==> ignore - arg [--build-id] ==> ignore - arg [--eh-frame-hdr] ==> ignore - arg [-m] ==> ignore - arg [elf_x86_64] ==> ignore - arg [--hash-style=gnu] ==> ignore - arg [--as-needed] ==> ignore - arg [-export-dynamic] ==> ignore - arg [-dynamic-linker] ==> ignore - arg [/lib64/ld-linux-x86-64.so.2] ==> ignore - arg [-zrelro] ==> ignore - arg [-o] ==> ignore - arg [cmTC_58731] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o] ==> ignore - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] - arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu] - arg [-L/lib/../lib] ==> dir [/lib/../lib] - arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu] - arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib] - arg [-L/usr/lib/gcc/x86_64-linux-gnu/5/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../..] - arg [CMakeFiles/cmTC_58731.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore - arg [-lstdc++] ==> lib [stdc++] - arg [-lm] ==> lib [m] - arg [-lgcc_s] ==> lib [gcc_s] - arg [-lgcc] ==> lib [gcc] - arg [-lc] ==> lib [c] - arg [-lgcc_s] ==> lib [gcc_s] - arg [-lgcc] ==> lib [gcc] - arg [/usr/lib/gcc/x86_64-linux-gnu/5/crtend.o] ==> ignore - arg [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o] ==> ignore - remove lib [gcc_s] - remove lib [gcc] - remove lib [gcc_s] - remove lib [gcc] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5] ==> [/usr/lib/gcc/x86_64-linux-gnu/5] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib] ==> [/usr/lib] - collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu] - collapse library dir [/lib/../lib] ==> [/lib] - collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] - collapse library dir [/usr/lib/../lib] ==> [/usr/lib] - collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/5/../../..] ==> [/usr/lib] - implicit libs: [stdc++;m;c] - implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib] - implicit fwks: [] - - - - -Detecting CXX [-std=c++14] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_9439e/fast" -/usr/bin/make -f CMakeFiles/cmTC_9439e.dir/build.make CMakeFiles/cmTC_9439e.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_9439e.dir/feature_tests.cxx.o -/usr/bin/c++ -std=c++14 -o CMakeFiles/cmTC_9439e.dir/feature_tests.cxx.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.cxx -Linking CXX executable cmTC_9439e -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9439e.dir/link.txt --verbose=1 -/usr/bin/c++ CMakeFiles/cmTC_9439e.dir/feature_tests.cxx.o -o cmTC_9439e -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers - Feature record: CXX_FEATURE:1cxx_alias_templates - Feature record: CXX_FEATURE:1cxx_alignas - Feature record: CXX_FEATURE:1cxx_alignof - Feature record: CXX_FEATURE:1cxx_attributes - Feature record: CXX_FEATURE:1cxx_attribute_deprecated - Feature record: CXX_FEATURE:1cxx_auto_type - Feature record: CXX_FEATURE:1cxx_binary_literals - Feature record: CXX_FEATURE:1cxx_constexpr - Feature record: CXX_FEATURE:1cxx_contextual_conversions - Feature record: CXX_FEATURE:1cxx_decltype - Feature record: CXX_FEATURE:1cxx_decltype_auto - Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types - Feature record: CXX_FEATURE:1cxx_default_function_template_args - Feature record: CXX_FEATURE:1cxx_defaulted_functions - Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers - Feature record: CXX_FEATURE:1cxx_delegating_constructors - Feature record: CXX_FEATURE:1cxx_deleted_functions - Feature record: CXX_FEATURE:1cxx_digit_separators - Feature record: CXX_FEATURE:1cxx_enum_forward_declarations - Feature record: CXX_FEATURE:1cxx_explicit_conversions - Feature record: CXX_FEATURE:1cxx_extended_friend_declarations - Feature record: CXX_FEATURE:1cxx_extern_templates - Feature record: CXX_FEATURE:1cxx_final - Feature record: CXX_FEATURE:1cxx_func_identifier - Feature record: CXX_FEATURE:1cxx_generalized_initializers - Feature record: CXX_FEATURE:1cxx_generic_lambdas - Feature record: CXX_FEATURE:1cxx_inheriting_constructors - Feature record: CXX_FEATURE:1cxx_inline_namespaces - Feature record: CXX_FEATURE:1cxx_lambdas - Feature record: CXX_FEATURE:1cxx_lambda_init_captures - Feature record: CXX_FEATURE:1cxx_local_type_template_args - Feature record: CXX_FEATURE:1cxx_long_long_type - Feature record: CXX_FEATURE:1cxx_noexcept - Feature record: CXX_FEATURE:1cxx_nonstatic_member_init - Feature record: CXX_FEATURE:1cxx_nullptr - Feature record: CXX_FEATURE:1cxx_override - Feature record: CXX_FEATURE:1cxx_range_for - Feature record: CXX_FEATURE:1cxx_raw_string_literals - Feature record: CXX_FEATURE:1cxx_reference_qualified_functions - Feature record: CXX_FEATURE:1cxx_relaxed_constexpr - Feature record: CXX_FEATURE:1cxx_return_type_deduction - Feature record: CXX_FEATURE:1cxx_right_angle_brackets - Feature record: CXX_FEATURE:1cxx_rvalue_references - Feature record: CXX_FEATURE:1cxx_sizeof_member - Feature record: CXX_FEATURE:1cxx_static_assert - Feature record: CXX_FEATURE:1cxx_strong_enums - Feature record: CXX_FEATURE:1cxx_template_template_parameters - Feature record: CXX_FEATURE:1cxx_thread_local - Feature record: CXX_FEATURE:1cxx_trailing_return_types - Feature record: CXX_FEATURE:1cxx_unicode_literals - Feature record: CXX_FEATURE:1cxx_uniform_initialization - Feature record: CXX_FEATURE:1cxx_unrestricted_unions - Feature record: CXX_FEATURE:1cxx_user_literals - Feature record: CXX_FEATURE:1cxx_variable_templates - Feature record: CXX_FEATURE:1cxx_variadic_macros - Feature record: CXX_FEATURE:1cxx_variadic_templates - - -Detecting CXX [-std=c++11] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_9b133/fast" -/usr/bin/make -f CMakeFiles/cmTC_9b133.dir/build.make CMakeFiles/cmTC_9b133.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_9b133.dir/feature_tests.cxx.o -/usr/bin/c++ -std=c++11 -o CMakeFiles/cmTC_9b133.dir/feature_tests.cxx.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.cxx -Linking CXX executable cmTC_9b133 -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9b133.dir/link.txt --verbose=1 -/usr/bin/c++ CMakeFiles/cmTC_9b133.dir/feature_tests.cxx.o -o cmTC_9b133 -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers - Feature record: CXX_FEATURE:1cxx_alias_templates - Feature record: CXX_FEATURE:1cxx_alignas - Feature record: CXX_FEATURE:1cxx_alignof - Feature record: CXX_FEATURE:1cxx_attributes - Feature record: CXX_FEATURE:0cxx_attribute_deprecated - Feature record: CXX_FEATURE:1cxx_auto_type - Feature record: CXX_FEATURE:0cxx_binary_literals - Feature record: CXX_FEATURE:1cxx_constexpr - Feature record: CXX_FEATURE:0cxx_contextual_conversions - Feature record: CXX_FEATURE:1cxx_decltype - Feature record: CXX_FEATURE:0cxx_decltype_auto - Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types - Feature record: CXX_FEATURE:1cxx_default_function_template_args - Feature record: CXX_FEATURE:1cxx_defaulted_functions - Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers - Feature record: CXX_FEATURE:1cxx_delegating_constructors - Feature record: CXX_FEATURE:1cxx_deleted_functions - Feature record: CXX_FEATURE:0cxx_digit_separators - Feature record: CXX_FEATURE:1cxx_enum_forward_declarations - Feature record: CXX_FEATURE:1cxx_explicit_conversions - Feature record: CXX_FEATURE:1cxx_extended_friend_declarations - Feature record: CXX_FEATURE:1cxx_extern_templates - Feature record: CXX_FEATURE:1cxx_final - Feature record: CXX_FEATURE:1cxx_func_identifier - Feature record: CXX_FEATURE:1cxx_generalized_initializers - Feature record: CXX_FEATURE:0cxx_generic_lambdas - Feature record: CXX_FEATURE:1cxx_inheriting_constructors - Feature record: CXX_FEATURE:1cxx_inline_namespaces - Feature record: CXX_FEATURE:1cxx_lambdas - Feature record: CXX_FEATURE:0cxx_lambda_init_captures - Feature record: CXX_FEATURE:1cxx_local_type_template_args - Feature record: CXX_FEATURE:1cxx_long_long_type - Feature record: CXX_FEATURE:1cxx_noexcept - Feature record: CXX_FEATURE:1cxx_nonstatic_member_init - Feature record: CXX_FEATURE:1cxx_nullptr - Feature record: CXX_FEATURE:1cxx_override - Feature record: CXX_FEATURE:1cxx_range_for - Feature record: CXX_FEATURE:1cxx_raw_string_literals - Feature record: CXX_FEATURE:1cxx_reference_qualified_functions - Feature record: CXX_FEATURE:0cxx_relaxed_constexpr - Feature record: CXX_FEATURE:0cxx_return_type_deduction - Feature record: CXX_FEATURE:1cxx_right_angle_brackets - Feature record: CXX_FEATURE:1cxx_rvalue_references - Feature record: CXX_FEATURE:1cxx_sizeof_member - Feature record: CXX_FEATURE:1cxx_static_assert - Feature record: CXX_FEATURE:1cxx_strong_enums - Feature record: CXX_FEATURE:1cxx_template_template_parameters - Feature record: CXX_FEATURE:1cxx_thread_local - Feature record: CXX_FEATURE:1cxx_trailing_return_types - Feature record: CXX_FEATURE:1cxx_unicode_literals - Feature record: CXX_FEATURE:1cxx_uniform_initialization - Feature record: CXX_FEATURE:1cxx_unrestricted_unions - Feature record: CXX_FEATURE:1cxx_user_literals - Feature record: CXX_FEATURE:0cxx_variable_templates - Feature record: CXX_FEATURE:1cxx_variadic_macros - Feature record: CXX_FEATURE:1cxx_variadic_templates - - -Detecting CXX [-std=c++98] compiler features compiled with the following output: -Change Dir: /home/alain/flatbuffers/CMakeFiles/CMakeTmp - -Run Build Command:"/usr/bin/make" "cmTC_767fe/fast" -/usr/bin/make -f CMakeFiles/cmTC_767fe.dir/build.make CMakeFiles/cmTC_767fe.dir/build -make[1]: Entering directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' -Building CXX object CMakeFiles/cmTC_767fe.dir/feature_tests.cxx.o -/usr/bin/c++ -std=c++98 -o CMakeFiles/cmTC_767fe.dir/feature_tests.cxx.o -c /home/alain/flatbuffers/CMakeFiles/feature_tests.cxx -Linking CXX executable cmTC_767fe -/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_767fe.dir/link.txt --verbose=1 -/usr/bin/c++ CMakeFiles/cmTC_767fe.dir/feature_tests.cxx.o -o cmTC_767fe -rdynamic -make[1]: Leaving directory '/home/alain/flatbuffers/CMakeFiles/CMakeTmp' - - - Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers - Feature record: CXX_FEATURE:0cxx_alias_templates - Feature record: CXX_FEATURE:0cxx_alignas - Feature record: CXX_FEATURE:0cxx_alignof - Feature record: CXX_FEATURE:0cxx_attributes - Feature record: CXX_FEATURE:0cxx_attribute_deprecated - Feature record: CXX_FEATURE:0cxx_auto_type - Feature record: CXX_FEATURE:0cxx_binary_literals - Feature record: CXX_FEATURE:0cxx_constexpr - Feature record: CXX_FEATURE:0cxx_contextual_conversions - Feature record: CXX_FEATURE:0cxx_decltype - Feature record: CXX_FEATURE:0cxx_decltype_auto - Feature record: CXX_FEATURE:0cxx_decltype_incomplete_return_types - Feature record: CXX_FEATURE:0cxx_default_function_template_args - Feature record: CXX_FEATURE:0cxx_defaulted_functions - Feature record: CXX_FEATURE:0cxx_defaulted_move_initializers - Feature record: CXX_FEATURE:0cxx_delegating_constructors - Feature record: CXX_FEATURE:0cxx_deleted_functions - Feature record: CXX_FEATURE:0cxx_digit_separators - Feature record: CXX_FEATURE:0cxx_enum_forward_declarations - Feature record: CXX_FEATURE:0cxx_explicit_conversions - Feature record: CXX_FEATURE:0cxx_extended_friend_declarations - Feature record: CXX_FEATURE:0cxx_extern_templates - Feature record: CXX_FEATURE:0cxx_final - Feature record: CXX_FEATURE:0cxx_func_identifier - Feature record: CXX_FEATURE:0cxx_generalized_initializers - Feature record: CXX_FEATURE:0cxx_generic_lambdas - Feature record: CXX_FEATURE:0cxx_inheriting_constructors - Feature record: CXX_FEATURE:0cxx_inline_namespaces - Feature record: CXX_FEATURE:0cxx_lambdas - Feature record: CXX_FEATURE:0cxx_lambda_init_captures - Feature record: CXX_FEATURE:0cxx_local_type_template_args - Feature record: CXX_FEATURE:0cxx_long_long_type - Feature record: CXX_FEATURE:0cxx_noexcept - Feature record: CXX_FEATURE:0cxx_nonstatic_member_init - Feature record: CXX_FEATURE:0cxx_nullptr - Feature record: CXX_FEATURE:0cxx_override - Feature record: CXX_FEATURE:0cxx_range_for - Feature record: CXX_FEATURE:0cxx_raw_string_literals - Feature record: CXX_FEATURE:0cxx_reference_qualified_functions - Feature record: CXX_FEATURE:0cxx_relaxed_constexpr - Feature record: CXX_FEATURE:0cxx_return_type_deduction - Feature record: CXX_FEATURE:0cxx_right_angle_brackets - Feature record: CXX_FEATURE:0cxx_rvalue_references - Feature record: CXX_FEATURE:0cxx_sizeof_member - Feature record: CXX_FEATURE:0cxx_static_assert - Feature record: CXX_FEATURE:0cxx_strong_enums - Feature record: CXX_FEATURE:1cxx_template_template_parameters - Feature record: CXX_FEATURE:0cxx_thread_local - Feature record: CXX_FEATURE:0cxx_trailing_return_types - Feature record: CXX_FEATURE:0cxx_unicode_literals - Feature record: CXX_FEATURE:0cxx_uniform_initialization - Feature record: CXX_FEATURE:0cxx_unrestricted_unions - Feature record: CXX_FEATURE:0cxx_user_literals - Feature record: CXX_FEATURE:0cxx_variable_templates - Feature record: CXX_FEATURE:0cxx_variadic_macros - Feature record: CXX_FEATURE:0cxx_variadic_templates
diff --git a/third_party/flatbuffers/CMakeFiles/CMakeRuleHashes.txt b/third_party/flatbuffers/CMakeFiles/CMakeRuleHashes.txt deleted file mode 100644 index 38f186f..0000000 --- a/third_party/flatbuffers/CMakeFiles/CMakeRuleHashes.txt +++ /dev/null
@@ -1,3 +0,0 @@ -# Hashes of file build rules. -245267531140c1e4cbb6844a7544380e samples/monster_generated.h -58bc14d032700fdc5864bd7e359f5a07 tests/monster_test_generated.h
diff --git a/third_party/flatbuffers/CMakeFiles/Makefile.cmake b/third_party/flatbuffers/CMakeFiles/Makefile.cmake deleted file mode 100644 index 8c40da2..0000000 --- a/third_party/flatbuffers/CMakeFiles/Makefile.cmake +++ /dev/null
@@ -1,121 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# The generator used is: -set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") - -# The top level Makefile was generated from the following files: -set(CMAKE_MAKEFILE_DEPENDS - "CMakeCache.txt" - "CMake/BuildFlatBuffers.cmake" - "CMakeFiles/3.5.1/CMakeCCompiler.cmake" - "CMakeFiles/3.5.1/CMakeCXXCompiler.cmake" - "CMakeFiles/3.5.1/CMakeSystem.cmake" - "CMakeFiles/feature_tests.c" - "CMakeFiles/feature_tests.cxx" - "CMakeLists.txt" - "/usr/share/cmake-3.5/Modules/CMakeCCompiler.cmake.in" - "/usr/share/cmake-3.5/Modules/CMakeCCompilerABI.c" - "/usr/share/cmake-3.5/Modules/CMakeCInformation.cmake" - "/usr/share/cmake-3.5/Modules/CMakeCXXCompiler.cmake.in" - "/usr/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp" - "/usr/share/cmake-3.5/Modules/CMakeCXXInformation.cmake" - "/usr/share/cmake-3.5/Modules/CMakeCommonLanguageInclude.cmake" - "/usr/share/cmake-3.5/Modules/CMakeCompilerIdDetection.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCCompiler.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCXXCompiler.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCompileFeatures.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCompilerABI.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineCompilerId.cmake" - "/usr/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake" - "/usr/share/cmake-3.5/Modules/CMakeFindBinUtils.cmake" - "/usr/share/cmake-3.5/Modules/CMakeGenericSystem.cmake" - "/usr/share/cmake-3.5/Modules/CMakeLanguageInformation.cmake" - "/usr/share/cmake-3.5/Modules/CMakeParseArguments.cmake" - "/usr/share/cmake-3.5/Modules/CMakeParseImplicitLinkInfo.cmake" - "/usr/share/cmake-3.5/Modules/CMakeSystem.cmake.in" - "/usr/share/cmake-3.5/Modules/CMakeSystemSpecificInformation.cmake" - "/usr/share/cmake-3.5/Modules/CMakeSystemSpecificInitialize.cmake" - "/usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake" - "/usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake" - "/usr/share/cmake-3.5/Modules/CMakeTestCompilerCommon.cmake" - "/usr/share/cmake-3.5/Modules/CMakeUnixFindMake.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/ADSP-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/ARMCC-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/AppleClang-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Borland-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Clang-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Clang-DetermineCompilerInternal.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Compaq-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Cray-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Embarcadero-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Fujitsu-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GHS-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU-C-FeatureTests.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU-C.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU-CXX-FeatureTests.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU-CXX.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/GNU.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/HP-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/HP-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/IAR-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Intel-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/MIPSpro-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/MSVC-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/PGI-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/PathScale-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/SCO-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/SDCC-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/SunPro-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/TI-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/Watcom-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/XL-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/XL-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/zOS-C-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake" - "/usr/share/cmake-3.5/Modules/Internal/FeatureTesting.cmake" - "/usr/share/cmake-3.5/Modules/MultiArchCross.cmake" - "/usr/share/cmake-3.5/Modules/Platform/Linux-CXX.cmake" - "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU-C.cmake" - "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU-CXX.cmake" - "/usr/share/cmake-3.5/Modules/Platform/Linux-GNU.cmake" - "/usr/share/cmake-3.5/Modules/Platform/Linux.cmake" - "/usr/share/cmake-3.5/Modules/Platform/UnixPaths.cmake" - ) - -# The corresponding makefile is: -set(CMAKE_MAKEFILE_OUTPUTS - "Makefile" - "CMakeFiles/cmake.check_cache" - ) - -# Byproducts of CMake generate step: -set(CMAKE_MAKEFILE_PRODUCTS - "CMakeFiles/3.5.1/CMakeSystem.cmake" - "CMakeFiles/3.5.1/CMakeCCompiler.cmake" - "CMakeFiles/3.5.1/CMakeCXXCompiler.cmake" - "CMakeFiles/3.5.1/CMakeCCompiler.cmake" - "CMakeFiles/3.5.1/CMakeCXXCompiler.cmake" - "CMakeFiles/CMakeDirectoryInformation.cmake" - ) - -# Dependency information for all targets: -set(CMAKE_DEPEND_INFO_FILES - "CMakeFiles/flattests.dir/DependInfo.cmake" - "CMakeFiles/flatc.dir/DependInfo.cmake" - "CMakeFiles/flatbuffers.dir/DependInfo.cmake" - "CMakeFiles/flatsamplebinary.dir/DependInfo.cmake" - "CMakeFiles/flathash.dir/DependInfo.cmake" - "CMakeFiles/flatsampletext.dir/DependInfo.cmake" - )
diff --git a/third_party/flatbuffers/CMakeFiles/Makefile2 b/third_party/flatbuffers/CMakeFiles/Makefile2 deleted file mode 100644 index 940fcfc..0000000 --- a/third_party/flatbuffers/CMakeFiles/Makefile2 +++ /dev/null
@@ -1,293 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Default target executed when no arguments are given to make. -default_target: all - -.PHONY : default_target - -# The main recursive all target -all: - -.PHONY : all - -# The main recursive preinstall target -preinstall: - -.PHONY : preinstall - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -#============================================================================= -# Target rules for target CMakeFiles/flattests.dir - -# All Build rule for target. -CMakeFiles/flattests.dir/all: CMakeFiles/flatc.dir/all - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/depend - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=38,39,40,41,42,43,44,45,46 "Built target flattests" -.PHONY : CMakeFiles/flattests.dir/all - -# Include target in all. -all: CMakeFiles/flattests.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flattests.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 27 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flattests.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flattests.dir/rule - -# Convenience name for target. -flattests: CMakeFiles/flattests.dir/rule - -.PHONY : flattests - -# clean rule for target. -CMakeFiles/flattests.dir/clean: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/clean -.PHONY : CMakeFiles/flattests.dir/clean - -# clean rule for target. -clean: CMakeFiles/flattests.dir/clean - -.PHONY : clean - -#============================================================================= -# Target rules for target CMakeFiles/flatc.dir - -# All Build rule for target. -CMakeFiles/flatc.dir/all: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/depend - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 "Built target flatc" -.PHONY : CMakeFiles/flatc.dir/all - -# Include target in all. -all: CMakeFiles/flatc.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flatc.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 18 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flatc.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flatc.dir/rule - -# Convenience name for target. -flatc: CMakeFiles/flatc.dir/rule - -.PHONY : flatc - -# clean rule for target. -CMakeFiles/flatc.dir/clean: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/clean -.PHONY : CMakeFiles/flatc.dir/clean - -# clean rule for target. -clean: CMakeFiles/flatc.dir/clean - -.PHONY : clean - -#============================================================================= -# Target rules for target CMakeFiles/flatbuffers.dir - -# All Build rule for target. -CMakeFiles/flatbuffers.dir/all: - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/depend - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=1,2,3,4,5,6 "Built target flatbuffers" -.PHONY : CMakeFiles/flatbuffers.dir/all - -# Include target in all. -all: CMakeFiles/flatbuffers.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flatbuffers.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 6 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flatbuffers.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flatbuffers.dir/rule - -# Convenience name for target. -flatbuffers: CMakeFiles/flatbuffers.dir/rule - -.PHONY : flatbuffers - -# clean rule for target. -CMakeFiles/flatbuffers.dir/clean: - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/clean -.PHONY : CMakeFiles/flatbuffers.dir/clean - -# clean rule for target. -clean: CMakeFiles/flatbuffers.dir/clean - -.PHONY : clean - -#============================================================================= -# Target rules for target CMakeFiles/flatsamplebinary.dir - -# All Build rule for target. -CMakeFiles/flatsamplebinary.dir/all: CMakeFiles/flatc.dir/all - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/depend - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=27,28,29 "Built target flatsamplebinary" -.PHONY : CMakeFiles/flatsamplebinary.dir/all - -# Include target in all. -all: CMakeFiles/flatsamplebinary.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flatsamplebinary.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 21 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flatsamplebinary.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flatsamplebinary.dir/rule - -# Convenience name for target. -flatsamplebinary: CMakeFiles/flatsamplebinary.dir/rule - -.PHONY : flatsamplebinary - -# clean rule for target. -CMakeFiles/flatsamplebinary.dir/clean: - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/clean -.PHONY : CMakeFiles/flatsamplebinary.dir/clean - -# clean rule for target. -clean: CMakeFiles/flatsamplebinary.dir/clean - -.PHONY : clean - -#============================================================================= -# Target rules for target CMakeFiles/flathash.dir - -# All Build rule for target. -CMakeFiles/flathash.dir/all: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/depend - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=25,26 "Built target flathash" -.PHONY : CMakeFiles/flathash.dir/all - -# Include target in all. -all: CMakeFiles/flathash.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flathash.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 2 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flathash.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flathash.dir/rule - -# Convenience name for target. -flathash: CMakeFiles/flathash.dir/rule - -.PHONY : flathash - -# clean rule for target. -CMakeFiles/flathash.dir/clean: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/clean -.PHONY : CMakeFiles/flathash.dir/clean - -# clean rule for target. -clean: CMakeFiles/flathash.dir/clean - -.PHONY : clean - -#============================================================================= -# Target rules for target CMakeFiles/flatsampletext.dir - -# All Build rule for target. -CMakeFiles/flatsampletext.dir/all: CMakeFiles/flatc.dir/all - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/depend - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=30,31,32,33,34,35,36,37 "Built target flatsampletext" -.PHONY : CMakeFiles/flatsampletext.dir/all - -# Include target in all. -all: CMakeFiles/flatsampletext.dir/all - -.PHONY : all - -# Build rule for subdir invocation for target. -CMakeFiles/flatsampletext.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 26 - $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/flatsampletext.dir/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : CMakeFiles/flatsampletext.dir/rule - -# Convenience name for target. -flatsampletext: CMakeFiles/flatsampletext.dir/rule - -.PHONY : flatsampletext - -# clean rule for target. -CMakeFiles/flatsampletext.dir/clean: - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/clean -.PHONY : CMakeFiles/flatsampletext.dir/clean - -# clean rule for target. -clean: CMakeFiles/flatsampletext.dir/clean - -.PHONY : clean - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system -
diff --git a/third_party/flatbuffers/CMakeFiles/TargetDirectories.txt b/third_party/flatbuffers/CMakeFiles/TargetDirectories.txt deleted file mode 100644 index a72639e..0000000 --- a/third_party/flatbuffers/CMakeFiles/TargetDirectories.txt +++ /dev/null
@@ -1,13 +0,0 @@ -/home/alain/flatbuffers/CMakeFiles/rebuild_cache.dir -/home/alain/flatbuffers/CMakeFiles/install.dir -/home/alain/flatbuffers/CMakeFiles/flattests.dir -/home/alain/flatbuffers/CMakeFiles/flatc.dir -/home/alain/flatbuffers/CMakeFiles/list_install_components.dir -/home/alain/flatbuffers/CMakeFiles/install/strip.dir -/home/alain/flatbuffers/CMakeFiles/install/local.dir -/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir -/home/alain/flatbuffers/CMakeFiles/flatsamplebinary.dir -/home/alain/flatbuffers/CMakeFiles/flathash.dir -/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir -/home/alain/flatbuffers/CMakeFiles/test.dir -/home/alain/flatbuffers/CMakeFiles/edit_cache.dir
diff --git a/third_party/flatbuffers/CMakeFiles/cmake.check_cache b/third_party/flatbuffers/CMakeFiles/cmake.check_cache deleted file mode 100644 index 3dccd73..0000000 --- a/third_party/flatbuffers/CMakeFiles/cmake.check_cache +++ /dev/null
@@ -1 +0,0 @@ -# This file is generated by cmake for dependency checking of the CMakeCache.txt file
diff --git a/third_party/flatbuffers/CMakeFiles/feature_tests.bin b/third_party/flatbuffers/CMakeFiles/feature_tests.bin deleted file mode 100755 index 4c5b364..0000000 --- a/third_party/flatbuffers/CMakeFiles/feature_tests.bin +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/CMakeFiles/feature_tests.c b/third_party/flatbuffers/CMakeFiles/feature_tests.c deleted file mode 100644 index 6590dde..0000000 --- a/third_party/flatbuffers/CMakeFiles/feature_tests.c +++ /dev/null
@@ -1,34 +0,0 @@ - - const char features[] = {"\n" -"C_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 -"1" -#else -"0" -#endif -"c_function_prototypes\n" -"C_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -"1" -#else -"0" -#endif -"c_restrict\n" -"C_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L -"1" -#else -"0" -#endif -"c_static_assert\n" -"C_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -"1" -#else -"0" -#endif -"c_variadic_macros\n" - -}; - -int main(int argc, char** argv) { (void)argv; return features[argc]; }
diff --git a/third_party/flatbuffers/CMakeFiles/feature_tests.cxx b/third_party/flatbuffers/CMakeFiles/feature_tests.cxx deleted file mode 100644 index b93418c..0000000 --- a/third_party/flatbuffers/CMakeFiles/feature_tests.cxx +++ /dev/null
@@ -1,405 +0,0 @@ - - const char features[] = {"\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L -"1" -#else -"0" -#endif -"cxx_aggregate_default_initializers\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_alias_templates\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_alignas\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_alignof\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_attributes\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_attribute_deprecated\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_auto_type\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_binary_literals\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_constexpr\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_contextual_conversions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_decltype\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_decltype_auto\n" -"CXX_FEATURE:" -#if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_decltype_incomplete_return_types\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_default_function_template_args\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_defaulted_functions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_defaulted_move_initializers\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_delegating_constructors\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_deleted_functions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_digit_separators\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_enum_forward_declarations\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_explicit_conversions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_extended_friend_declarations\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_extern_templates\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_final\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_func_identifier\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_generalized_initializers\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_generic_lambdas\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_inheriting_constructors\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_inline_namespaces\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_lambdas\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_lambda_init_captures\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_local_type_template_args\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_long_long_type\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_noexcept\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_nonstatic_member_init\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_nullptr\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_override\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_range_for\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_raw_string_literals\n" -"CXX_FEATURE:" -#if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_reference_qualified_functions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L -"1" -#else -"0" -#endif -"cxx_relaxed_constexpr\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L -"1" -#else -"0" -#endif -"cxx_return_type_deduction\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_right_angle_brackets\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_rvalue_references\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_sizeof_member\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_static_assert\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_strong_enums\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && __cplusplus -"1" -#else -"0" -#endif -"cxx_template_template_parameters\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_thread_local\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_trailing_return_types\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_unicode_literals\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_uniform_initialization\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_unrestricted_unions\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L -"1" -#else -"0" -#endif -"cxx_user_literals\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L -"1" -#else -"0" -#endif -"cxx_variable_templates\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_variadic_macros\n" -"CXX_FEATURE:" -#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) -"1" -#else -"0" -#endif -"cxx_variadic_templates\n" - -}; - -int main(int argc, char** argv) { (void)argv; return features[argc]; }
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/CXX.includecache deleted file mode 100644 index ba96c23..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/CXX.includecache +++ /dev/null
@@ -1,146 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/src/code_generators.cpp -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -assert.h -- -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_gen_text.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_parser.cpp -algorithm -- -list -- -math.h -- -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/reflection.cpp -flatbuffers/reflection.h -/home/alain/flatbuffers/src/flatbuffers/reflection.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/util.cpp -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -include/flatbuffers/code_generators.h -map -- -sstream -- -flatbuffers/idl.h -include/flatbuffers/flatbuffers/idl.h - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- - -include/flatbuffers/hash.h -cstdint -- -cstring -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/idl.h -map -- -stack -- -memory -- -functional -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/hash.h -include/flatbuffers/flatbuffers/hash.h -flatbuffers/reflection.h -include/flatbuffers/flatbuffers/reflection.h - -include/flatbuffers/reflection.h -flatbuffers/reflection_generated.h -include/flatbuffers/flatbuffers/reflection_generated.h - -include/flatbuffers/reflection_generated.h -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/util.h -fstream -- -iomanip -- -string -- -sstream -- -stdint.h -- -stdlib.h -- -assert.h -- -windows.h -- -winbase.h -- -direct.h -- -limits.h -- -sys/types.h -- -sys/stat.h -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/DependInfo.cmake deleted file mode 100644 index 1561d48..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/DependInfo.cmake +++ /dev/null
@@ -1,28 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/src/code_generators.cpp" "/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_text.cpp" "/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o" - "/home/alain/flatbuffers/src/idl_parser.cpp" "/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o" - "/home/alain/flatbuffers/src/reflection.cpp" "/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/src/reflection.cpp.o" - "/home/alain/flatbuffers/src/util.cpp" "/home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/src/util.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/build.make b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/build.make deleted file mode 100644 index a98c2a1..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/build.make +++ /dev/null
@@ -1,222 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flatbuffers.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flatbuffers.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flatbuffers.dir/flags.make - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: CMakeFiles/flatbuffers.dir/flags.make -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: src/code_generators.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o -c /home/alain/flatbuffers/src/code_generators.cpp - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatbuffers.dir/src/code_generators.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/code_generators.cpp > CMakeFiles/flatbuffers.dir/src/code_generators.cpp.i - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatbuffers.dir/src/code_generators.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/code_generators.cpp -o CMakeFiles/flatbuffers.dir/src/code_generators.cpp.s - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.requires: - -.PHONY : CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.requires - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.provides: CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.requires - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.provides.build -.PHONY : CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.provides - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.provides.build: CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o - - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: CMakeFiles/flatbuffers.dir/flags.make -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: src/idl_parser.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o -c /home/alain/flatbuffers/src/idl_parser.cpp - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_parser.cpp > CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.i - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_parser.cpp -o CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.s - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.requires: - -.PHONY : CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.requires - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.provides: CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.requires - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.provides.build -.PHONY : CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.provides - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.provides.build: CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o - - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: CMakeFiles/flatbuffers.dir/flags.make -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Building CXX object CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o -c /home/alain/flatbuffers/src/idl_gen_text.cpp - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_text.cpp > CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.i - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_text.cpp -o CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.s - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.requires: - -.PHONY : CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.requires - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.provides: CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.requires - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.provides.build -.PHONY : CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.provides - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.provides.build: CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o - - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: CMakeFiles/flatbuffers.dir/flags.make -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: src/reflection.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_4) "Building CXX object CMakeFiles/flatbuffers.dir/src/reflection.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatbuffers.dir/src/reflection.cpp.o -c /home/alain/flatbuffers/src/reflection.cpp - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatbuffers.dir/src/reflection.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/reflection.cpp > CMakeFiles/flatbuffers.dir/src/reflection.cpp.i - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatbuffers.dir/src/reflection.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/reflection.cpp -o CMakeFiles/flatbuffers.dir/src/reflection.cpp.s - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.requires: - -.PHONY : CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.requires - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.provides: CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.requires - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.provides.build -.PHONY : CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.provides - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.provides.build: CMakeFiles/flatbuffers.dir/src/reflection.cpp.o - - -CMakeFiles/flatbuffers.dir/src/util.cpp.o: CMakeFiles/flatbuffers.dir/flags.make -CMakeFiles/flatbuffers.dir/src/util.cpp.o: src/util.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Building CXX object CMakeFiles/flatbuffers.dir/src/util.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatbuffers.dir/src/util.cpp.o -c /home/alain/flatbuffers/src/util.cpp - -CMakeFiles/flatbuffers.dir/src/util.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatbuffers.dir/src/util.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/util.cpp > CMakeFiles/flatbuffers.dir/src/util.cpp.i - -CMakeFiles/flatbuffers.dir/src/util.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatbuffers.dir/src/util.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/util.cpp -o CMakeFiles/flatbuffers.dir/src/util.cpp.s - -CMakeFiles/flatbuffers.dir/src/util.cpp.o.requires: - -.PHONY : CMakeFiles/flatbuffers.dir/src/util.cpp.o.requires - -CMakeFiles/flatbuffers.dir/src/util.cpp.o.provides: CMakeFiles/flatbuffers.dir/src/util.cpp.o.requires - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/util.cpp.o.provides.build -.PHONY : CMakeFiles/flatbuffers.dir/src/util.cpp.o.provides - -CMakeFiles/flatbuffers.dir/src/util.cpp.o.provides.build: CMakeFiles/flatbuffers.dir/src/util.cpp.o - - -# Object files for target flatbuffers -flatbuffers_OBJECTS = \ -"CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o" \ -"CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o" \ -"CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o" \ -"CMakeFiles/flatbuffers.dir/src/reflection.cpp.o" \ -"CMakeFiles/flatbuffers.dir/src/util.cpp.o" - -# External object files for target flatbuffers -flatbuffers_EXTERNAL_OBJECTS = - -libflatbuffers.a: CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o -libflatbuffers.a: CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o -libflatbuffers.a: CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o -libflatbuffers.a: CMakeFiles/flatbuffers.dir/src/reflection.cpp.o -libflatbuffers.a: CMakeFiles/flatbuffers.dir/src/util.cpp.o -libflatbuffers.a: CMakeFiles/flatbuffers.dir/build.make -libflatbuffers.a: CMakeFiles/flatbuffers.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Linking CXX static library libflatbuffers.a" - $(CMAKE_COMMAND) -P CMakeFiles/flatbuffers.dir/cmake_clean_target.cmake - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flatbuffers.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flatbuffers.dir/build: libflatbuffers.a - -.PHONY : CMakeFiles/flatbuffers.dir/build - -CMakeFiles/flatbuffers.dir/requires: CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o.requires -CMakeFiles/flatbuffers.dir/requires: CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o.requires -CMakeFiles/flatbuffers.dir/requires: CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o.requires -CMakeFiles/flatbuffers.dir/requires: CMakeFiles/flatbuffers.dir/src/reflection.cpp.o.requires -CMakeFiles/flatbuffers.dir/requires: CMakeFiles/flatbuffers.dir/src/util.cpp.o.requires - -.PHONY : CMakeFiles/flatbuffers.dir/requires - -CMakeFiles/flatbuffers.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flatbuffers.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flatbuffers.dir/clean - -CMakeFiles/flatbuffers.dir/depend: - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flatbuffers.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flatbuffers.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean.cmake deleted file mode 100644 index 82bc6d3..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean.cmake +++ /dev/null
@@ -1,14 +0,0 @@ -file(REMOVE_RECURSE - "CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o" - "CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o" - "CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o" - "CMakeFiles/flatbuffers.dir/src/reflection.cpp.o" - "CMakeFiles/flatbuffers.dir/src/util.cpp.o" - "libflatbuffers.pdb" - "libflatbuffers.a" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flatbuffers.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean_target.cmake b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean_target.cmake deleted file mode 100644 index dc1f66a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/cmake_clean_target.cmake +++ /dev/null
@@ -1,3 +0,0 @@ -file(REMOVE_RECURSE - "libflatbuffers.a" -)
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.internal deleted file mode 100644 index a6e31a9..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.internal +++ /dev/null
@@ -1,38 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o - /home/alain/flatbuffers/src/code_generators.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o - /home/alain/flatbuffers/src/idl_gen_text.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o - /home/alain/flatbuffers/src/idl_parser.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o - /home/alain/flatbuffers/src/reflection.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatbuffers.dir/src/util.cpp.o - /home/alain/flatbuffers/src/util.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/util.h
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.make deleted file mode 100644 index 4e6687a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/depend.make +++ /dev/null
@@ -1,38 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: src/code_generators.cpp -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: src/idl_parser.cpp -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: src/reflection.cpp -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatbuffers.dir/src/reflection.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatbuffers.dir/src/util.cpp.o: src/util.cpp -CMakeFiles/flatbuffers.dir/src/util.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatbuffers.dir/src/util.cpp.o: include/flatbuffers/util.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/flags.make deleted file mode 100644 index 6fddb3a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/link.txt deleted file mode 100644 index d8000a6..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/link.txt +++ /dev/null
@@ -1,2 +0,0 @@ -/usr/bin/ar qc libflatbuffers.a CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o CMakeFiles/flatbuffers.dir/src/reflection.cpp.o CMakeFiles/flatbuffers.dir/src/util.cpp.o -/usr/bin/ranlib libflatbuffers.a
diff --git a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/progress.make deleted file mode 100644 index daba7fa..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatbuffers.dir/progress.make +++ /dev/null
@@ -1,7 +0,0 @@ -CMAKE_PROGRESS_1 = 1 -CMAKE_PROGRESS_2 = 2 -CMAKE_PROGRESS_3 = 3 -CMAKE_PROGRESS_4 = 4 -CMAKE_PROGRESS_5 = 5 -CMAKE_PROGRESS_6 = 6 -
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flatc.dir/CXX.includecache deleted file mode 100644 index eef92cd..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/CXX.includecache +++ /dev/null
@@ -1,316 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc -map -- -src/compiler/cpp_generator.h -/home/alain/flatbuffers/grpc/src/compiler/src/compiler/cpp_generator.h -sstream -- - -/home/alain/flatbuffers/grpc/src/compiler/go_generator.cc -map -- -cctype -- -sstream -- -src/compiler/go_generator.h -/home/alain/flatbuffers/grpc/src/compiler/src/compiler/go_generator.h - -/home/alain/flatbuffers/src/code_generators.cpp -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -assert.h -- -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/flatc.cpp -flatbuffers/flatc.h -/home/alain/flatbuffers/src/flatbuffers/flatc.h - -/home/alain/flatbuffers/src/flatc_main.cpp -flatbuffers/flatc.h -/home/alain/flatbuffers/src/flatbuffers/flatc.h - -/home/alain/flatbuffers/src/idl_gen_cpp.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_fbs.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_general.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -algorithm -- - -/home/alain/flatbuffers/src/idl_gen_go.cpp -string -- -sstream -- -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -direct.h -- -sys/stat.h -- - -/home/alain/flatbuffers/src/idl_gen_grpc.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -src/compiler/cpp_generator.h -/home/alain/flatbuffers/src/src/compiler/cpp_generator.h -src/compiler/go_generator.h -/home/alain/flatbuffers/src/src/compiler/go_generator.h - -/home/alain/flatbuffers/src/idl_gen_js.cpp -unordered_set -- -unordered_map -- -cassert -- -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_php.cpp -string -- -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_python.cpp -string -- -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_text.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_parser.cpp -algorithm -- -list -- -math.h -- -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/reflection.cpp -flatbuffers/reflection.h -/home/alain/flatbuffers/src/flatbuffers/reflection.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/util.cpp -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -grpc/src/compiler/cpp_generator.h -memory -- -vector -- -src/compiler/schema_interface.h -grpc/src/compiler/src/compiler/schema_interface.h - -grpc/src/compiler/go_generator.h -memory -- -vector -- -src/compiler/schema_interface.h -grpc/src/compiler/src/compiler/schema_interface.h - -grpc/src/compiler/schema_interface.h -map -- -memory -- -vector -- -string -- - -include/flatbuffers/code_generators.h -map -- -sstream -- -flatbuffers/idl.h -include/flatbuffers/flatbuffers/idl.h - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- - -include/flatbuffers/flatc.h -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/idl.h -include/flatbuffers/flatbuffers/idl.h -flatbuffers/util.h -include/flatbuffers/flatbuffers/util.h -functional -- -limits -- -string -- - -include/flatbuffers/hash.h -cstdint -- -cstring -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/idl.h -map -- -stack -- -memory -- -functional -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/hash.h -include/flatbuffers/flatbuffers/hash.h -flatbuffers/reflection.h -include/flatbuffers/flatbuffers/reflection.h - -include/flatbuffers/reflection.h -flatbuffers/reflection_generated.h -include/flatbuffers/flatbuffers/reflection_generated.h - -include/flatbuffers/reflection_generated.h -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/util.h -fstream -- -iomanip -- -string -- -sstream -- -stdint.h -- -stdlib.h -- -assert.h -- -windows.h -- -winbase.h -- -direct.h -- -limits.h -- -sys/types.h -- -sys/stat.h -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flatc.dir/DependInfo.cmake deleted file mode 100644 index 72846b0..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/DependInfo.cmake +++ /dev/null
@@ -1,40 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o" - "/home/alain/flatbuffers/grpc/src/compiler/go_generator.cc" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o" - "/home/alain/flatbuffers/src/code_generators.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/code_generators.cpp.o" - "/home/alain/flatbuffers/src/flatc.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/flatc.cpp.o" - "/home/alain/flatbuffers/src/flatc_main.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/flatc_main.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_cpp.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_fbs.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_general.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_go.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_grpc.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_js.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_php.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_python.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_text.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o" - "/home/alain/flatbuffers/src/idl_parser.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/idl_parser.cpp.o" - "/home/alain/flatbuffers/src/reflection.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/reflection.cpp.o" - "/home/alain/flatbuffers/src/util.cpp" "/home/alain/flatbuffers/CMakeFiles/flatc.dir/src/util.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/build.make b/third_party/flatbuffers/CMakeFiles/flatc.dir/build.make deleted file mode 100644 index 39d3f8c..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/build.make +++ /dev/null
@@ -1,545 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flatc.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flatc.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flatc.dir/flags.make - -CMakeFiles/flatc.dir/src/code_generators.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/code_generators.cpp.o: src/code_generators.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/code_generators.cpp.o -c /home/alain/flatbuffers/src/code_generators.cpp - -CMakeFiles/flatc.dir/src/code_generators.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/code_generators.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/code_generators.cpp > CMakeFiles/flatc.dir/src/code_generators.cpp.i - -CMakeFiles/flatc.dir/src/code_generators.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/code_generators.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/code_generators.cpp -o CMakeFiles/flatc.dir/src/code_generators.cpp.s - -CMakeFiles/flatc.dir/src/code_generators.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/code_generators.cpp.o.requires - -CMakeFiles/flatc.dir/src/code_generators.cpp.o.provides: CMakeFiles/flatc.dir/src/code_generators.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/code_generators.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/code_generators.cpp.o.provides - -CMakeFiles/flatc.dir/src/code_generators.cpp.o.provides.build: CMakeFiles/flatc.dir/src/code_generators.cpp.o - - -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: src/idl_parser.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_parser.cpp.o -c /home/alain/flatbuffers/src/idl_parser.cpp - -CMakeFiles/flatc.dir/src/idl_parser.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_parser.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_parser.cpp > CMakeFiles/flatc.dir/src/idl_parser.cpp.i - -CMakeFiles/flatc.dir/src/idl_parser.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_parser.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_parser.cpp -o CMakeFiles/flatc.dir/src/idl_parser.cpp.s - -CMakeFiles/flatc.dir/src/idl_parser.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_parser.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_parser.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_parser.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_parser.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_parser.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_parser.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_parser.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o -c /home/alain/flatbuffers/src/idl_gen_text.cpp - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_text.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_text.cpp > CMakeFiles/flatc.dir/src/idl_gen_text.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_text.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_text.cpp -o CMakeFiles/flatc.dir/src/idl_gen_text.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o - - -CMakeFiles/flatc.dir/src/reflection.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/reflection.cpp.o: src/reflection.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_4) "Building CXX object CMakeFiles/flatc.dir/src/reflection.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/reflection.cpp.o -c /home/alain/flatbuffers/src/reflection.cpp - -CMakeFiles/flatc.dir/src/reflection.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/reflection.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/reflection.cpp > CMakeFiles/flatc.dir/src/reflection.cpp.i - -CMakeFiles/flatc.dir/src/reflection.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/reflection.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/reflection.cpp -o CMakeFiles/flatc.dir/src/reflection.cpp.s - -CMakeFiles/flatc.dir/src/reflection.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/reflection.cpp.o.requires - -CMakeFiles/flatc.dir/src/reflection.cpp.o.provides: CMakeFiles/flatc.dir/src/reflection.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/reflection.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/reflection.cpp.o.provides - -CMakeFiles/flatc.dir/src/reflection.cpp.o.provides.build: CMakeFiles/flatc.dir/src/reflection.cpp.o - - -CMakeFiles/flatc.dir/src/util.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/util.cpp.o: src/util.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Building CXX object CMakeFiles/flatc.dir/src/util.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/util.cpp.o -c /home/alain/flatbuffers/src/util.cpp - -CMakeFiles/flatc.dir/src/util.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/util.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/util.cpp > CMakeFiles/flatc.dir/src/util.cpp.i - -CMakeFiles/flatc.dir/src/util.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/util.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/util.cpp -o CMakeFiles/flatc.dir/src/util.cpp.s - -CMakeFiles/flatc.dir/src/util.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/util.cpp.o.requires - -CMakeFiles/flatc.dir/src/util.cpp.o.provides: CMakeFiles/flatc.dir/src/util.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/util.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/util.cpp.o.provides - -CMakeFiles/flatc.dir/src/util.cpp.o.provides.build: CMakeFiles/flatc.dir/src/util.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: src/idl_gen_cpp.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o -c /home/alain/flatbuffers/src/idl_gen_cpp.cpp - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_cpp.cpp > CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_cpp.cpp -o CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: src/idl_gen_general.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_7) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o -c /home/alain/flatbuffers/src/idl_gen_general.cpp - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_general.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_general.cpp > CMakeFiles/flatc.dir/src/idl_gen_general.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_general.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_general.cpp -o CMakeFiles/flatc.dir/src/idl_gen_general.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: src/idl_gen_go.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_8) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o -c /home/alain/flatbuffers/src/idl_gen_go.cpp - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_go.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_go.cpp > CMakeFiles/flatc.dir/src/idl_gen_go.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_go.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_go.cpp -o CMakeFiles/flatc.dir/src/idl_gen_go.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: src/idl_gen_js.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_9) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o -c /home/alain/flatbuffers/src/idl_gen_js.cpp - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_js.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_js.cpp > CMakeFiles/flatc.dir/src/idl_gen_js.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_js.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_js.cpp -o CMakeFiles/flatc.dir/src/idl_gen_js.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: src/idl_gen_php.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_10) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o -c /home/alain/flatbuffers/src/idl_gen_php.cpp - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_php.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_php.cpp > CMakeFiles/flatc.dir/src/idl_gen_php.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_php.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_php.cpp -o CMakeFiles/flatc.dir/src/idl_gen_php.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: src/idl_gen_python.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_11) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o -c /home/alain/flatbuffers/src/idl_gen_python.cpp - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_python.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_python.cpp > CMakeFiles/flatc.dir/src/idl_gen_python.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_python.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_python.cpp -o CMakeFiles/flatc.dir/src/idl_gen_python.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: src/idl_gen_fbs.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_12) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o -c /home/alain/flatbuffers/src/idl_gen_fbs.cpp - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_fbs.cpp > CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_fbs.cpp -o CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o - - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: src/idl_gen_grpc.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_13) "Building CXX object CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o -c /home/alain/flatbuffers/src/idl_gen_grpc.cpp - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_grpc.cpp > CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.i - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_grpc.cpp -o CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.s - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.requires - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.provides: CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.provides - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.provides.build: CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o - - -CMakeFiles/flatc.dir/src/flatc.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/flatc.cpp.o: src/flatc.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_14) "Building CXX object CMakeFiles/flatc.dir/src/flatc.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/flatc.cpp.o -c /home/alain/flatbuffers/src/flatc.cpp - -CMakeFiles/flatc.dir/src/flatc.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/flatc.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/flatc.cpp > CMakeFiles/flatc.dir/src/flatc.cpp.i - -CMakeFiles/flatc.dir/src/flatc.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/flatc.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/flatc.cpp -o CMakeFiles/flatc.dir/src/flatc.cpp.s - -CMakeFiles/flatc.dir/src/flatc.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/flatc.cpp.o.requires - -CMakeFiles/flatc.dir/src/flatc.cpp.o.provides: CMakeFiles/flatc.dir/src/flatc.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/flatc.cpp.o.provides - -CMakeFiles/flatc.dir/src/flatc.cpp.o.provides.build: CMakeFiles/flatc.dir/src/flatc.cpp.o - - -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: src/flatc_main.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_15) "Building CXX object CMakeFiles/flatc.dir/src/flatc_main.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/src/flatc_main.cpp.o -c /home/alain/flatbuffers/src/flatc_main.cpp - -CMakeFiles/flatc.dir/src/flatc_main.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/src/flatc_main.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/flatc_main.cpp > CMakeFiles/flatc.dir/src/flatc_main.cpp.i - -CMakeFiles/flatc.dir/src/flatc_main.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/src/flatc_main.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/flatc_main.cpp -o CMakeFiles/flatc.dir/src/flatc_main.cpp.s - -CMakeFiles/flatc.dir/src/flatc_main.cpp.o.requires: - -.PHONY : CMakeFiles/flatc.dir/src/flatc_main.cpp.o.requires - -CMakeFiles/flatc.dir/src/flatc_main.cpp.o.provides: CMakeFiles/flatc.dir/src/flatc_main.cpp.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc_main.cpp.o.provides.build -.PHONY : CMakeFiles/flatc.dir/src/flatc_main.cpp.o.provides - -CMakeFiles/flatc.dir/src/flatc_main.cpp.o.provides.build: CMakeFiles/flatc.dir/src/flatc_main.cpp.o - - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o: grpc/src/compiler/cpp_generator.cc - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_16) "Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o -c /home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc > CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.i - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc -o CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.s - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.requires: - -.PHONY : CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.requires - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.provides: CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.provides.build -.PHONY : CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.provides - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.provides.build: CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o - - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o: CMakeFiles/flatc.dir/flags.make -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o: grpc/src/compiler/go_generator.cc - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_17) "Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o -c /home/alain/flatbuffers/grpc/src/compiler/go_generator.cc - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/grpc/src/compiler/go_generator.cc > CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.i - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/grpc/src/compiler/go_generator.cc -o CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.s - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.requires: - -.PHONY : CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.requires - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.provides: CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.requires - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.provides.build -.PHONY : CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.provides - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.provides.build: CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o - - -# Object files for target flatc -flatc_OBJECTS = \ -"CMakeFiles/flatc.dir/src/code_generators.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_parser.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o" \ -"CMakeFiles/flatc.dir/src/reflection.cpp.o" \ -"CMakeFiles/flatc.dir/src/util.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o" \ -"CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o" \ -"CMakeFiles/flatc.dir/src/flatc.cpp.o" \ -"CMakeFiles/flatc.dir/src/flatc_main.cpp.o" \ -"CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o" \ -"CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o" - -# External object files for target flatc -flatc_EXTERNAL_OBJECTS = - -flatc: CMakeFiles/flatc.dir/src/code_generators.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_parser.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o -flatc: CMakeFiles/flatc.dir/src/reflection.cpp.o -flatc: CMakeFiles/flatc.dir/src/util.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o -flatc: CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o -flatc: CMakeFiles/flatc.dir/src/flatc.cpp.o -flatc: CMakeFiles/flatc.dir/src/flatc_main.cpp.o -flatc: CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o -flatc: CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o -flatc: CMakeFiles/flatc.dir/build.make -flatc: CMakeFiles/flatc.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_18) "Linking CXX executable flatc" - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flatc.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flatc.dir/build: flatc - -.PHONY : CMakeFiles/flatc.dir/build - -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/code_generators.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_parser.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/reflection.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/util.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/flatc.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/src/flatc_main.cpp.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o.requires -CMakeFiles/flatc.dir/requires: CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o.requires - -.PHONY : CMakeFiles/flatc.dir/requires - -CMakeFiles/flatc.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flatc.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flatc.dir/clean - -CMakeFiles/flatc.dir/depend: - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flatc.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flatc.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flatc.dir/cmake_clean.cmake deleted file mode 100644 index 8bae0d8..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/cmake_clean.cmake +++ /dev/null
@@ -1,26 +0,0 @@ -file(REMOVE_RECURSE - "CMakeFiles/flatc.dir/src/code_generators.cpp.o" - "CMakeFiles/flatc.dir/src/idl_parser.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o" - "CMakeFiles/flatc.dir/src/reflection.cpp.o" - "CMakeFiles/flatc.dir/src/util.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o" - "CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o" - "CMakeFiles/flatc.dir/src/flatc.cpp.o" - "CMakeFiles/flatc.dir/src/flatc_main.cpp.o" - "CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o" - "CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o" - "flatc.pdb" - "flatc" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flatc.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.internal deleted file mode 100644 index 1ffab00..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.internal +++ /dev/null
@@ -1,139 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o - /home/alain/flatbuffers/grpc/src/compiler/cpp_generator.cc - grpc/src/compiler/cpp_generator.h - grpc/src/compiler/schema_interface.h -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o - /home/alain/flatbuffers/grpc/src/compiler/go_generator.cc - grpc/src/compiler/go_generator.h - grpc/src/compiler/schema_interface.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o - /home/alain/flatbuffers/src/code_generators.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/flatc.cpp.o - /home/alain/flatbuffers/src/flatc.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/flatc.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o - /home/alain/flatbuffers/src/flatc_main.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/flatc.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o - /home/alain/flatbuffers/src/idl_gen_cpp.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o - /home/alain/flatbuffers/src/idl_gen_fbs.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o - /home/alain/flatbuffers/src/idl_gen_general.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o - /home/alain/flatbuffers/src/idl_gen_go.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o - /home/alain/flatbuffers/src/idl_gen_grpc.cpp - grpc/src/compiler/cpp_generator.h - grpc/src/compiler/go_generator.h - grpc/src/compiler/schema_interface.h - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o - /home/alain/flatbuffers/src/idl_gen_js.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o - /home/alain/flatbuffers/src/idl_gen_php.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o - /home/alain/flatbuffers/src/idl_gen_python.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o - /home/alain/flatbuffers/src/idl_gen_text.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o - /home/alain/flatbuffers/src/idl_parser.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/reflection.cpp.o - /home/alain/flatbuffers/src/reflection.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatc.dir/src/util.cpp.o - /home/alain/flatbuffers/src/util.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/util.h
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.make deleted file mode 100644 index 157b490..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/depend.make +++ /dev/null
@@ -1,139 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o: grpc/src/compiler/cpp_generator.cc -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o: grpc/src/compiler/cpp_generator.h -CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o: grpc/src/compiler/schema_interface.h - -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o: grpc/src/compiler/go_generator.cc -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o: grpc/src/compiler/go_generator.h -CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o: grpc/src/compiler/schema_interface.h - -CMakeFiles/flatc.dir/src/code_generators.cpp.o: src/code_generators.cpp -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/code_generators.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/flatc.cpp.o: src/flatc.cpp -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/flatc.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/flatc.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: src/flatc_main.cpp -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/flatc.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/flatc_main.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: src/idl_gen_cpp.cpp -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: src/idl_gen_fbs.cpp -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: src/idl_gen_general.cpp -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: src/idl_gen_go.cpp -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: src/idl_gen_grpc.cpp -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: grpc/src/compiler/cpp_generator.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: grpc/src/compiler/go_generator.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: grpc/src/compiler/schema_interface.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: src/idl_gen_js.cpp -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: src/idl_gen_php.cpp -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: src/idl_gen_python.cpp -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: src/idl_parser.cpp -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/idl_parser.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/reflection.cpp.o: src/reflection.cpp -CMakeFiles/flatc.dir/src/reflection.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/reflection.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatc.dir/src/reflection.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatc.dir/src/reflection.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatc.dir/src/util.cpp.o: src/util.cpp -CMakeFiles/flatc.dir/src/util.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatc.dir/src/util.cpp.o: include/flatbuffers/util.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flatc.dir/flags.make deleted file mode 100644 index 6fddb3a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flatc.dir/link.txt deleted file mode 100644 index 44501a3..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/link.txt +++ /dev/null
@@ -1 +0,0 @@ -/usr/bin/c++ -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char CMakeFiles/flatc.dir/src/code_generators.cpp.o CMakeFiles/flatc.dir/src/idl_parser.cpp.o CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o CMakeFiles/flatc.dir/src/reflection.cpp.o CMakeFiles/flatc.dir/src/util.cpp.o CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o CMakeFiles/flatc.dir/src/flatc.cpp.o CMakeFiles/flatc.dir/src/flatc_main.cpp.o CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o -o flatc -rdynamic
diff --git a/third_party/flatbuffers/CMakeFiles/flatc.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flatc.dir/progress.make deleted file mode 100644 index 47ef266..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatc.dir/progress.make +++ /dev/null
@@ -1,19 +0,0 @@ -CMAKE_PROGRESS_1 = 7 -CMAKE_PROGRESS_2 = 8 -CMAKE_PROGRESS_3 = 9 -CMAKE_PROGRESS_4 = 10 -CMAKE_PROGRESS_5 = 11 -CMAKE_PROGRESS_6 = 12 -CMAKE_PROGRESS_7 = 13 -CMAKE_PROGRESS_8 = 14 -CMAKE_PROGRESS_9 = 15 -CMAKE_PROGRESS_10 = 16 -CMAKE_PROGRESS_11 = 17 -CMAKE_PROGRESS_12 = 18 -CMAKE_PROGRESS_13 = 19 -CMAKE_PROGRESS_14 = 20 -CMAKE_PROGRESS_15 = 21 -CMAKE_PROGRESS_16 = 22 -CMAKE_PROGRESS_17 = 23 -CMAKE_PROGRESS_18 = 24 -
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flathash.dir/CXX.includecache deleted file mode 100644 index 0136ce9..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/CXX.includecache +++ /dev/null
@@ -1,58 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/src/flathash.cpp -iostream -- -sstream -- -string -- -flatbuffers/hash.h -/home/alain/flatbuffers/src/flatbuffers/hash.h -stdio.h -- - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- - -include/flatbuffers/hash.h -cstdint -- -cstring -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flathash.dir/DependInfo.cmake deleted file mode 100644 index e4553be..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/DependInfo.cmake +++ /dev/null
@@ -1,24 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/src/flathash.cpp" "/home/alain/flatbuffers/CMakeFiles/flathash.dir/src/flathash.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/build.make b/third_party/flatbuffers/CMakeFiles/flathash.dir/build.make deleted file mode 100644 index a76bbfb..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/build.make +++ /dev/null
@@ -1,113 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flathash.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flathash.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flathash.dir/flags.make - -CMakeFiles/flathash.dir/src/flathash.cpp.o: CMakeFiles/flathash.dir/flags.make -CMakeFiles/flathash.dir/src/flathash.cpp.o: src/flathash.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/flathash.dir/src/flathash.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flathash.dir/src/flathash.cpp.o -c /home/alain/flatbuffers/src/flathash.cpp - -CMakeFiles/flathash.dir/src/flathash.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flathash.dir/src/flathash.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/flathash.cpp > CMakeFiles/flathash.dir/src/flathash.cpp.i - -CMakeFiles/flathash.dir/src/flathash.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flathash.dir/src/flathash.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/flathash.cpp -o CMakeFiles/flathash.dir/src/flathash.cpp.s - -CMakeFiles/flathash.dir/src/flathash.cpp.o.requires: - -.PHONY : CMakeFiles/flathash.dir/src/flathash.cpp.o.requires - -CMakeFiles/flathash.dir/src/flathash.cpp.o.provides: CMakeFiles/flathash.dir/src/flathash.cpp.o.requires - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/src/flathash.cpp.o.provides.build -.PHONY : CMakeFiles/flathash.dir/src/flathash.cpp.o.provides - -CMakeFiles/flathash.dir/src/flathash.cpp.o.provides.build: CMakeFiles/flathash.dir/src/flathash.cpp.o - - -# Object files for target flathash -flathash_OBJECTS = \ -"CMakeFiles/flathash.dir/src/flathash.cpp.o" - -# External object files for target flathash -flathash_EXTERNAL_OBJECTS = - -flathash: CMakeFiles/flathash.dir/src/flathash.cpp.o -flathash: CMakeFiles/flathash.dir/build.make -flathash: CMakeFiles/flathash.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable flathash" - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flathash.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flathash.dir/build: flathash - -.PHONY : CMakeFiles/flathash.dir/build - -CMakeFiles/flathash.dir/requires: CMakeFiles/flathash.dir/src/flathash.cpp.o.requires - -.PHONY : CMakeFiles/flathash.dir/requires - -CMakeFiles/flathash.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flathash.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flathash.dir/clean - -CMakeFiles/flathash.dir/depend: - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flathash.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flathash.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flathash.dir/cmake_clean.cmake deleted file mode 100644 index d0f3575..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/cmake_clean.cmake +++ /dev/null
@@ -1,10 +0,0 @@ -file(REMOVE_RECURSE - "CMakeFiles/flathash.dir/src/flathash.cpp.o" - "flathash.pdb" - "flathash" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flathash.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.internal deleted file mode 100644 index 1d1d1fc..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.internal +++ /dev/null
@@ -1,7 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flathash.dir/src/flathash.cpp.o - /home/alain/flatbuffers/src/flathash.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.make deleted file mode 100644 index 9d33014..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/depend.make +++ /dev/null
@@ -1,7 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flathash.dir/src/flathash.cpp.o: src/flathash.cpp -CMakeFiles/flathash.dir/src/flathash.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flathash.dir/src/flathash.cpp.o: include/flatbuffers/hash.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flathash.dir/flags.make deleted file mode 100644 index 6fddb3a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flathash.dir/link.txt deleted file mode 100644 index 33d528f..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/link.txt +++ /dev/null
@@ -1 +0,0 @@ -/usr/bin/c++ -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char CMakeFiles/flathash.dir/src/flathash.cpp.o -o flathash -rdynamic
diff --git a/third_party/flatbuffers/CMakeFiles/flathash.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flathash.dir/progress.make deleted file mode 100644 index 9fd0bf5..0000000 --- a/third_party/flatbuffers/CMakeFiles/flathash.dir/progress.make +++ /dev/null
@@ -1,3 +0,0 @@ -CMAKE_PROGRESS_1 = 25 -CMAKE_PROGRESS_2 = 26 -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/CXX.includecache deleted file mode 100644 index 7e2a58c..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/CXX.includecache +++ /dev/null
@@ -1,46 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/samples/monster_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/samples/flatbuffers/flatbuffers.h - -/home/alain/flatbuffers/samples/sample_binary.cpp -monster_generated.h -/home/alain/flatbuffers/samples/monster_generated.h - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/DependInfo.cmake deleted file mode 100644 index 7e9a1cf..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/DependInfo.cmake +++ /dev/null
@@ -1,24 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/samples/sample_binary.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/build.make b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/build.make deleted file mode 100644 index ebb08c6..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/build.make +++ /dev/null
@@ -1,117 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flatsamplebinary.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flatsamplebinary.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flatsamplebinary.dir/flags.make - -samples/monster_generated.h: flatc - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Generating samples/monster_generated.h" - ./flatc -c --no-includes --gen-mutable --gen-object-api -o samples /home/alain/flatbuffers/samples/monster.fbs - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o: CMakeFiles/flatsamplebinary.dir/flags.make -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o: samples/sample_binary.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o -c /home/alain/flatbuffers/samples/sample_binary.cpp - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/samples/sample_binary.cpp > CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.i - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/samples/sample_binary.cpp -o CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.s - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.requires: - -.PHONY : CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.requires - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.provides: CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.provides.build -.PHONY : CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.provides - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.provides.build: CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o - - -# Object files for target flatsamplebinary -flatsamplebinary_OBJECTS = \ -"CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o" - -# External object files for target flatsamplebinary -flatsamplebinary_EXTERNAL_OBJECTS = - -flatsamplebinary: CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o -flatsamplebinary: CMakeFiles/flatsamplebinary.dir/build.make -flatsamplebinary: CMakeFiles/flatsamplebinary.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Linking CXX executable flatsamplebinary" - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flatsamplebinary.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flatsamplebinary.dir/build: flatsamplebinary - -.PHONY : CMakeFiles/flatsamplebinary.dir/build - -CMakeFiles/flatsamplebinary.dir/requires: CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o.requires - -.PHONY : CMakeFiles/flatsamplebinary.dir/requires - -CMakeFiles/flatsamplebinary.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flatsamplebinary.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flatsamplebinary.dir/clean - -CMakeFiles/flatsamplebinary.dir/depend: samples/monster_generated.h - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flatsamplebinary.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flatsamplebinary.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/cmake_clean.cmake deleted file mode 100644 index b1d09e4..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/cmake_clean.cmake +++ /dev/null
@@ -1,11 +0,0 @@ -file(REMOVE_RECURSE - "samples/monster_generated.h" - "CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o" - "flatsamplebinary.pdb" - "flatsamplebinary" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flatsamplebinary.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.internal deleted file mode 100644 index d13bbad..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.internal +++ /dev/null
@@ -1,7 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o - /home/alain/flatbuffers/samples/monster_generated.h - /home/alain/flatbuffers/samples/sample_binary.cpp - include/flatbuffers/flatbuffers.h
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.make deleted file mode 100644 index 4717048..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/depend.make +++ /dev/null
@@ -1,7 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o: samples/monster_generated.h -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o: samples/sample_binary.cpp -CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o: include/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/flags.make deleted file mode 100644 index 6fddb3a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/link.txt deleted file mode 100644 index 3fa33a2..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/link.txt +++ /dev/null
@@ -1 +0,0 @@ -/usr/bin/c++ -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o -o flatsamplebinary -rdynamic
diff --git a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/progress.make deleted file mode 100644 index 3a30df4..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsamplebinary.dir/progress.make +++ /dev/null
@@ -1,4 +0,0 @@ -CMAKE_PROGRESS_1 = 27 -CMAKE_PROGRESS_2 = 28 -CMAKE_PROGRESS_3 = 29 -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/CXX.includecache deleted file mode 100644 index 1d4bd2d..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/CXX.includecache +++ /dev/null
@@ -1,158 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/samples/monster_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/samples/flatbuffers/flatbuffers.h - -/home/alain/flatbuffers/samples/sample_text.cpp -flatbuffers/idl.h -/home/alain/flatbuffers/samples/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/samples/flatbuffers/util.h -monster_generated.h -/home/alain/flatbuffers/samples/monster_generated.h - -/home/alain/flatbuffers/src/code_generators.cpp -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -assert.h -- -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_gen_text.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_parser.cpp -algorithm -- -list -- -math.h -- -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/reflection.cpp -flatbuffers/reflection.h -/home/alain/flatbuffers/src/flatbuffers/reflection.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/util.cpp -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -include/flatbuffers/code_generators.h -map -- -sstream -- -flatbuffers/idl.h -include/flatbuffers/flatbuffers/idl.h - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- - -include/flatbuffers/hash.h -cstdint -- -cstring -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/idl.h -map -- -stack -- -memory -- -functional -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/hash.h -include/flatbuffers/flatbuffers/hash.h -flatbuffers/reflection.h -include/flatbuffers/flatbuffers/reflection.h - -include/flatbuffers/reflection.h -flatbuffers/reflection_generated.h -include/flatbuffers/flatbuffers/reflection_generated.h - -include/flatbuffers/reflection_generated.h -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/util.h -fstream -- -iomanip -- -string -- -sstream -- -stdint.h -- -stdlib.h -- -assert.h -- -windows.h -- -winbase.h -- -direct.h -- -limits.h -- -sys/types.h -- -sys/stat.h -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/DependInfo.cmake deleted file mode 100644 index 8e79318..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/DependInfo.cmake +++ /dev/null
@@ -1,29 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/samples/sample_text.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o" - "/home/alain/flatbuffers/src/code_generators.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_text.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o" - "/home/alain/flatbuffers/src/idl_parser.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o" - "/home/alain/flatbuffers/src/reflection.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/src/reflection.cpp.o" - "/home/alain/flatbuffers/src/util.cpp" "/home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/src/util.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/build.make b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/build.make deleted file mode 100644 index caf6cd8..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/build.make +++ /dev/null
@@ -1,252 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flatsampletext.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flatsampletext.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flatsampletext.dir/flags.make - -samples/monster_generated.h: flatc - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Generating samples/monster_generated.h" - ./flatc -c --no-includes --gen-mutable --gen-object-api -o samples /home/alain/flatbuffers/samples/monster.fbs - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: src/code_generators.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o -c /home/alain/flatbuffers/src/code_generators.cpp - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/src/code_generators.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/code_generators.cpp > CMakeFiles/flatsampletext.dir/src/code_generators.cpp.i - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/src/code_generators.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/code_generators.cpp -o CMakeFiles/flatsampletext.dir/src/code_generators.cpp.s - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.requires - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.provides: CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.provides - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o - - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: src/idl_parser.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Building CXX object CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o -c /home/alain/flatbuffers/src/idl_parser.cpp - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_parser.cpp > CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.i - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_parser.cpp -o CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.s - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.requires - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.provides: CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.provides - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o - - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_4) "Building CXX object CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o -c /home/alain/flatbuffers/src/idl_gen_text.cpp - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_text.cpp > CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.i - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_text.cpp -o CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.s - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.requires - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.provides: CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.provides - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o - - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: src/reflection.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Building CXX object CMakeFiles/flatsampletext.dir/src/reflection.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/src/reflection.cpp.o -c /home/alain/flatbuffers/src/reflection.cpp - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/src/reflection.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/reflection.cpp > CMakeFiles/flatsampletext.dir/src/reflection.cpp.i - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/src/reflection.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/reflection.cpp -o CMakeFiles/flatsampletext.dir/src/reflection.cpp.s - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.requires - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.provides: CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.provides - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/src/reflection.cpp.o - - -CMakeFiles/flatsampletext.dir/src/util.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/src/util.cpp.o: src/util.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Building CXX object CMakeFiles/flatsampletext.dir/src/util.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/src/util.cpp.o -c /home/alain/flatbuffers/src/util.cpp - -CMakeFiles/flatsampletext.dir/src/util.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/src/util.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/util.cpp > CMakeFiles/flatsampletext.dir/src/util.cpp.i - -CMakeFiles/flatsampletext.dir/src/util.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/src/util.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/util.cpp -o CMakeFiles/flatsampletext.dir/src/util.cpp.s - -CMakeFiles/flatsampletext.dir/src/util.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/src/util.cpp.o.requires - -CMakeFiles/flatsampletext.dir/src/util.cpp.o.provides: CMakeFiles/flatsampletext.dir/src/util.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/util.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/src/util.cpp.o.provides - -CMakeFiles/flatsampletext.dir/src/util.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/src/util.cpp.o - - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: CMakeFiles/flatsampletext.dir/flags.make -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: samples/sample_text.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_7) "Building CXX object CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o -c /home/alain/flatbuffers/samples/sample_text.cpp - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/samples/sample_text.cpp > CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.i - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/samples/sample_text.cpp -o CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.s - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.requires: - -.PHONY : CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.requires - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.provides: CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.requires - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.provides.build -.PHONY : CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.provides - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.provides.build: CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o - - -# Object files for target flatsampletext -flatsampletext_OBJECTS = \ -"CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o" \ -"CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o" \ -"CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o" \ -"CMakeFiles/flatsampletext.dir/src/reflection.cpp.o" \ -"CMakeFiles/flatsampletext.dir/src/util.cpp.o" \ -"CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o" - -# External object files for target flatsampletext -flatsampletext_EXTERNAL_OBJECTS = - -flatsampletext: CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/src/reflection.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/src/util.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o -flatsampletext: CMakeFiles/flatsampletext.dir/build.make -flatsampletext: CMakeFiles/flatsampletext.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_8) "Linking CXX executable flatsampletext" - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flatsampletext.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flatsampletext.dir/build: flatsampletext - -.PHONY : CMakeFiles/flatsampletext.dir/build - -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o.requires -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o.requires -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o.requires -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/src/reflection.cpp.o.requires -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/src/util.cpp.o.requires -CMakeFiles/flatsampletext.dir/requires: CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o.requires - -.PHONY : CMakeFiles/flatsampletext.dir/requires - -CMakeFiles/flatsampletext.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flatsampletext.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flatsampletext.dir/clean - -CMakeFiles/flatsampletext.dir/depend: samples/monster_generated.h - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flatsampletext.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flatsampletext.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/cmake_clean.cmake deleted file mode 100644 index e763e61..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/cmake_clean.cmake +++ /dev/null
@@ -1,16 +0,0 @@ -file(REMOVE_RECURSE - "samples/monster_generated.h" - "CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o" - "CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o" - "CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o" - "CMakeFiles/flatsampletext.dir/src/reflection.cpp.o" - "CMakeFiles/flatsampletext.dir/src/util.cpp.o" - "CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o" - "flatsampletext.pdb" - "flatsampletext" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flatsampletext.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.internal deleted file mode 100644 index 8fd7cf9..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.internal +++ /dev/null
@@ -1,47 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o - /home/alain/flatbuffers/samples/monster_generated.h - /home/alain/flatbuffers/samples/sample_text.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o - /home/alain/flatbuffers/src/code_generators.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o - /home/alain/flatbuffers/src/idl_gen_text.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o - /home/alain/flatbuffers/src/idl_parser.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o - /home/alain/flatbuffers/src/reflection.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flatsampletext.dir/src/util.cpp.o - /home/alain/flatbuffers/src/util.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/util.h
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.make deleted file mode 100644 index 5002df4..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/depend.make +++ /dev/null
@@ -1,47 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: samples/monster_generated.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: samples/sample_text.cpp -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: src/code_generators.cpp -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: src/idl_parser.cpp -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: src/reflection.cpp -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flatsampletext.dir/src/reflection.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flatsampletext.dir/src/util.cpp.o: src/util.cpp -CMakeFiles/flatsampletext.dir/src/util.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flatsampletext.dir/src/util.cpp.o: include/flatbuffers/util.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/flags.make deleted file mode 100644 index 6fddb3a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/link.txt deleted file mode 100644 index 535e01a..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/link.txt +++ /dev/null
@@ -1 +0,0 @@ -/usr/bin/c++ -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o CMakeFiles/flatsampletext.dir/src/reflection.cpp.o CMakeFiles/flatsampletext.dir/src/util.cpp.o CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o -o flatsampletext -rdynamic
diff --git a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/progress.make deleted file mode 100644 index 7218115..0000000 --- a/third_party/flatbuffers/CMakeFiles/flatsampletext.dir/progress.make +++ /dev/null
@@ -1,9 +0,0 @@ -CMAKE_PROGRESS_1 = 30 -CMAKE_PROGRESS_2 = 31 -CMAKE_PROGRESS_3 = 32 -CMAKE_PROGRESS_4 = 33 -CMAKE_PROGRESS_5 = 34 -CMAKE_PROGRESS_6 = 35 -CMAKE_PROGRESS_7 = 36 -CMAKE_PROGRESS_8 = 37 -
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/CXX.includecache b/third_party/flatbuffers/CMakeFiles/flattests.dir/CXX.includecache deleted file mode 100644 index 35de61e..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/CXX.includecache +++ /dev/null
@@ -1,206 +0,0 @@ -#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) - -#IncludeRegexScan: ^.*$ - -#IncludeRegexComplain: ^$ - -#IncludeRegexTransform: - -/home/alain/flatbuffers/src/code_generators.cpp -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h -assert.h -- -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_gen_fbs.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h -flatbuffers/code_generators.h -/home/alain/flatbuffers/src/flatbuffers/code_generators.h - -/home/alain/flatbuffers/src/idl_gen_text.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/src/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/idl_parser.cpp -algorithm -- -list -- -math.h -- -flatbuffers/idl.h -/home/alain/flatbuffers/src/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/reflection.cpp -flatbuffers/reflection.h -/home/alain/flatbuffers/src/flatbuffers/reflection.h -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/src/util.cpp -flatbuffers/util.h -/home/alain/flatbuffers/src/flatbuffers/util.h - -/home/alain/flatbuffers/tests/monster_test_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/tests/flatbuffers/flatbuffers.h - -/home/alain/flatbuffers/tests/namespace_test/namespace_test1_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/tests/namespace_test/flatbuffers/flatbuffers.h - -/home/alain/flatbuffers/tests/namespace_test/namespace_test2_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/tests/namespace_test/flatbuffers/flatbuffers.h -namespace_test1_generated.h -/home/alain/flatbuffers/tests/namespace_test/namespace_test1_generated.h - -/home/alain/flatbuffers/tests/test.cpp -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/tests/flatbuffers/flatbuffers.h -flatbuffers/idl.h -/home/alain/flatbuffers/tests/flatbuffers/idl.h -flatbuffers/util.h -/home/alain/flatbuffers/tests/flatbuffers/util.h -monster_test_generated.h -/home/alain/flatbuffers/tests/monster_test_generated.h -namespace_test/namespace_test1_generated.h -/home/alain/flatbuffers/tests/namespace_test/namespace_test1_generated.h -namespace_test/namespace_test2_generated.h -/home/alain/flatbuffers/tests/namespace_test/namespace_test2_generated.h -union_vector/union_vector_generated.h -/home/alain/flatbuffers/tests/union_vector/union_vector_generated.h -random -- -flatbuffers/flexbuffers.h -/home/alain/flatbuffers/tests/flatbuffers/flexbuffers.h -android/log.h -- - -/home/alain/flatbuffers/tests/union_vector/union_vector_generated.h -flatbuffers/flatbuffers.h -/home/alain/flatbuffers/tests/union_vector/flatbuffers/flatbuffers.h - -include/flatbuffers/code_generators.h -map -- -sstream -- -flatbuffers/idl.h -include/flatbuffers/flatbuffers/idl.h - -include/flatbuffers/flatbuffers.h -assert.h -- -cstdint -- -cstddef -- -cstdlib -- -cstring -- -string -- -utility -- -utility.h -- -type_traits -- -vector -- -set -- -algorithm -- -memory -- -functional -- - -include/flatbuffers/flexbuffers.h -map -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/util.h -include/flatbuffers/flatbuffers/util.h -intrin.h -- - -include/flatbuffers/hash.h -cstdint -- -cstring -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/idl.h -map -- -stack -- -memory -- -functional -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -flatbuffers/hash.h -include/flatbuffers/flatbuffers/hash.h -flatbuffers/reflection.h -include/flatbuffers/flatbuffers/reflection.h - -include/flatbuffers/reflection.h -flatbuffers/reflection_generated.h -include/flatbuffers/flatbuffers/reflection_generated.h - -include/flatbuffers/reflection_generated.h -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h - -include/flatbuffers/util.h -fstream -- -iomanip -- -string -- -sstream -- -stdint.h -- -stdlib.h -- -assert.h -- -windows.h -- -winbase.h -- -direct.h -- -limits.h -- -sys/types.h -- -sys/stat.h -- -flatbuffers/flatbuffers.h -include/flatbuffers/flatbuffers/flatbuffers.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/DependInfo.cmake b/third_party/flatbuffers/CMakeFiles/flattests.dir/DependInfo.cmake deleted file mode 100644 index b3dbb5f..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/DependInfo.cmake +++ /dev/null
@@ -1,36 +0,0 @@ -# The set of languages for which implicit dependencies are needed: -set(CMAKE_DEPENDS_LANGUAGES - "CXX" - ) -# The set of files for implicit dependencies of each language: -set(CMAKE_DEPENDS_CHECK_CXX - "/home/alain/flatbuffers/src/code_generators.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/code_generators.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_fbs.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o" - "/home/alain/flatbuffers/src/idl_gen_text.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o" - "/home/alain/flatbuffers/src/idl_parser.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/idl_parser.cpp.o" - "/home/alain/flatbuffers/src/reflection.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/reflection.cpp.o" - "/home/alain/flatbuffers/src/util.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/src/util.cpp.o" - "/home/alain/flatbuffers/tests/test.cpp" "/home/alain/flatbuffers/CMakeFiles/flattests.dir/tests/test.cpp.o" - ) -set(CMAKE_CXX_COMPILER_ID "GNU") - -# Preprocessor definitions for this target. -set(CMAKE_TARGET_DEFINITIONS_CXX - "FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1" - "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE" - ) - -# The include file search paths: -set(CMAKE_CXX_TARGET_INCLUDE_PATH - "include" - "grpc" - "tests" - "samples" - ) - -# Targets to which this target links. -set(CMAKE_TARGET_LINKED_INFO_FILES - ) - -# Fortran module output directory. -set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/build.make b/third_party/flatbuffers/CMakeFiles/flattests.dir/build.make deleted file mode 100644 index db2d56e..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/build.make +++ /dev/null
@@ -1,279 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Delete rule output on recipe failure. -.DELETE_ON_ERROR: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -# Include any dependencies generated for this target. -include CMakeFiles/flattests.dir/depend.make - -# Include the progress variables for this target. -include CMakeFiles/flattests.dir/progress.make - -# Include the compile flags for this target's objects. -include CMakeFiles/flattests.dir/flags.make - -tests/monster_test_generated.h: flatc - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Generating tests/monster_test_generated.h" - ./flatc -c --no-includes --gen-mutable --gen-object-api -o tests /home/alain/flatbuffers/tests/monster_test.fbs - -CMakeFiles/flattests.dir/src/code_generators.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/code_generators.cpp.o: src/code_generators.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/flattests.dir/src/code_generators.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/code_generators.cpp.o -c /home/alain/flatbuffers/src/code_generators.cpp - -CMakeFiles/flattests.dir/src/code_generators.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/code_generators.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/code_generators.cpp > CMakeFiles/flattests.dir/src/code_generators.cpp.i - -CMakeFiles/flattests.dir/src/code_generators.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/code_generators.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/code_generators.cpp -o CMakeFiles/flattests.dir/src/code_generators.cpp.s - -CMakeFiles/flattests.dir/src/code_generators.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/code_generators.cpp.o.requires - -CMakeFiles/flattests.dir/src/code_generators.cpp.o.provides: CMakeFiles/flattests.dir/src/code_generators.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/code_generators.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/code_generators.cpp.o.provides - -CMakeFiles/flattests.dir/src/code_generators.cpp.o.provides.build: CMakeFiles/flattests.dir/src/code_generators.cpp.o - - -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: src/idl_parser.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Building CXX object CMakeFiles/flattests.dir/src/idl_parser.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/idl_parser.cpp.o -c /home/alain/flatbuffers/src/idl_parser.cpp - -CMakeFiles/flattests.dir/src/idl_parser.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/idl_parser.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_parser.cpp > CMakeFiles/flattests.dir/src/idl_parser.cpp.i - -CMakeFiles/flattests.dir/src/idl_parser.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/idl_parser.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_parser.cpp -o CMakeFiles/flattests.dir/src/idl_parser.cpp.s - -CMakeFiles/flattests.dir/src/idl_parser.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/idl_parser.cpp.o.requires - -CMakeFiles/flattests.dir/src/idl_parser.cpp.o.provides: CMakeFiles/flattests.dir/src/idl_parser.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_parser.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/idl_parser.cpp.o.provides - -CMakeFiles/flattests.dir/src/idl_parser.cpp.o.provides.build: CMakeFiles/flattests.dir/src/idl_parser.cpp.o - - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_4) "Building CXX object CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o -c /home/alain/flatbuffers/src/idl_gen_text.cpp - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/idl_gen_text.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_text.cpp > CMakeFiles/flattests.dir/src/idl_gen_text.cpp.i - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/idl_gen_text.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_text.cpp -o CMakeFiles/flattests.dir/src/idl_gen_text.cpp.s - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.requires - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.provides: CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.provides - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.provides.build: CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o - - -CMakeFiles/flattests.dir/src/reflection.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/reflection.cpp.o: src/reflection.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Building CXX object CMakeFiles/flattests.dir/src/reflection.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/reflection.cpp.o -c /home/alain/flatbuffers/src/reflection.cpp - -CMakeFiles/flattests.dir/src/reflection.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/reflection.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/reflection.cpp > CMakeFiles/flattests.dir/src/reflection.cpp.i - -CMakeFiles/flattests.dir/src/reflection.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/reflection.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/reflection.cpp -o CMakeFiles/flattests.dir/src/reflection.cpp.s - -CMakeFiles/flattests.dir/src/reflection.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/reflection.cpp.o.requires - -CMakeFiles/flattests.dir/src/reflection.cpp.o.provides: CMakeFiles/flattests.dir/src/reflection.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/reflection.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/reflection.cpp.o.provides - -CMakeFiles/flattests.dir/src/reflection.cpp.o.provides.build: CMakeFiles/flattests.dir/src/reflection.cpp.o - - -CMakeFiles/flattests.dir/src/util.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/util.cpp.o: src/util.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Building CXX object CMakeFiles/flattests.dir/src/util.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/util.cpp.o -c /home/alain/flatbuffers/src/util.cpp - -CMakeFiles/flattests.dir/src/util.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/util.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/util.cpp > CMakeFiles/flattests.dir/src/util.cpp.i - -CMakeFiles/flattests.dir/src/util.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/util.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/util.cpp -o CMakeFiles/flattests.dir/src/util.cpp.s - -CMakeFiles/flattests.dir/src/util.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/util.cpp.o.requires - -CMakeFiles/flattests.dir/src/util.cpp.o.provides: CMakeFiles/flattests.dir/src/util.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/util.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/util.cpp.o.provides - -CMakeFiles/flattests.dir/src/util.cpp.o.provides.build: CMakeFiles/flattests.dir/src/util.cpp.o - - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: src/idl_gen_fbs.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_7) "Building CXX object CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o -c /home/alain/flatbuffers/src/idl_gen_fbs.cpp - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/src/idl_gen_fbs.cpp > CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.i - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/src/idl_gen_fbs.cpp -o CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.s - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.requires - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.provides: CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.provides - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.provides.build: CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o - - -CMakeFiles/flattests.dir/tests/test.cpp.o: CMakeFiles/flattests.dir/flags.make -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/test.cpp - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_8) "Building CXX object CMakeFiles/flattests.dir/tests/test.cpp.o" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/flattests.dir/tests/test.cpp.o -c /home/alain/flatbuffers/tests/test.cpp - -CMakeFiles/flattests.dir/tests/test.cpp.i: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/flattests.dir/tests/test.cpp.i" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alain/flatbuffers/tests/test.cpp > CMakeFiles/flattests.dir/tests/test.cpp.i - -CMakeFiles/flattests.dir/tests/test.cpp.s: cmake_force - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/flattests.dir/tests/test.cpp.s" - /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alain/flatbuffers/tests/test.cpp -o CMakeFiles/flattests.dir/tests/test.cpp.s - -CMakeFiles/flattests.dir/tests/test.cpp.o.requires: - -.PHONY : CMakeFiles/flattests.dir/tests/test.cpp.o.requires - -CMakeFiles/flattests.dir/tests/test.cpp.o.provides: CMakeFiles/flattests.dir/tests/test.cpp.o.requires - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/tests/test.cpp.o.provides.build -.PHONY : CMakeFiles/flattests.dir/tests/test.cpp.o.provides - -CMakeFiles/flattests.dir/tests/test.cpp.o.provides.build: CMakeFiles/flattests.dir/tests/test.cpp.o - - -# Object files for target flattests -flattests_OBJECTS = \ -"CMakeFiles/flattests.dir/src/code_generators.cpp.o" \ -"CMakeFiles/flattests.dir/src/idl_parser.cpp.o" \ -"CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o" \ -"CMakeFiles/flattests.dir/src/reflection.cpp.o" \ -"CMakeFiles/flattests.dir/src/util.cpp.o" \ -"CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o" \ -"CMakeFiles/flattests.dir/tests/test.cpp.o" - -# External object files for target flattests -flattests_EXTERNAL_OBJECTS = - -flattests: CMakeFiles/flattests.dir/src/code_generators.cpp.o -flattests: CMakeFiles/flattests.dir/src/idl_parser.cpp.o -flattests: CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o -flattests: CMakeFiles/flattests.dir/src/reflection.cpp.o -flattests: CMakeFiles/flattests.dir/src/util.cpp.o -flattests: CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o -flattests: CMakeFiles/flattests.dir/tests/test.cpp.o -flattests: CMakeFiles/flattests.dir/build.make -flattests: CMakeFiles/flattests.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/flatbuffers/CMakeFiles --progress-num=$(CMAKE_PROGRESS_9) "Linking CXX executable flattests" - $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/flattests.dir/link.txt --verbose=$(VERBOSE) - -# Rule to build all files generated by this target. -CMakeFiles/flattests.dir/build: flattests - -.PHONY : CMakeFiles/flattests.dir/build - -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/code_generators.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/idl_parser.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/reflection.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/util.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o.requires -CMakeFiles/flattests.dir/requires: CMakeFiles/flattests.dir/tests/test.cpp.o.requires - -.PHONY : CMakeFiles/flattests.dir/requires - -CMakeFiles/flattests.dir/clean: - $(CMAKE_COMMAND) -P CMakeFiles/flattests.dir/cmake_clean.cmake -.PHONY : CMakeFiles/flattests.dir/clean - -CMakeFiles/flattests.dir/depend: tests/monster_test_generated.h - cd /home/alain/flatbuffers && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers /home/alain/flatbuffers/CMakeFiles/flattests.dir/DependInfo.cmake --color=$(COLOR) -.PHONY : CMakeFiles/flattests.dir/depend -
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/cmake_clean.cmake b/third_party/flatbuffers/CMakeFiles/flattests.dir/cmake_clean.cmake deleted file mode 100644 index 46f8d97..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/cmake_clean.cmake +++ /dev/null
@@ -1,17 +0,0 @@ -file(REMOVE_RECURSE - "tests/monster_test_generated.h" - "CMakeFiles/flattests.dir/src/code_generators.cpp.o" - "CMakeFiles/flattests.dir/src/idl_parser.cpp.o" - "CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o" - "CMakeFiles/flattests.dir/src/reflection.cpp.o" - "CMakeFiles/flattests.dir/src/util.cpp.o" - "CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o" - "CMakeFiles/flattests.dir/tests/test.cpp.o" - "flattests.pdb" - "flattests" -) - -# Per-language clean rules from dependency scanning. -foreach(lang CXX) - include(CMakeFiles/flattests.dir/cmake_clean_${lang}.cmake OPTIONAL) -endforeach()
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.internal b/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.internal deleted file mode 100644 index 8329ea0..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.internal +++ /dev/null
@@ -1,60 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flattests.dir/src/code_generators.cpp.o - /home/alain/flatbuffers/src/code_generators.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o - /home/alain/flatbuffers/src/idl_gen_fbs.cpp - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o - /home/alain/flatbuffers/src/idl_gen_text.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o - /home/alain/flatbuffers/src/idl_parser.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/src/reflection.cpp.o - /home/alain/flatbuffers/src/reflection.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/src/util.cpp.o - /home/alain/flatbuffers/src/util.cpp - include/flatbuffers/flatbuffers.h - include/flatbuffers/util.h -CMakeFiles/flattests.dir/tests/test.cpp.o - /home/alain/flatbuffers/tests/monster_test_generated.h - /home/alain/flatbuffers/tests/namespace_test/namespace_test1_generated.h - /home/alain/flatbuffers/tests/namespace_test/namespace_test2_generated.h - /home/alain/flatbuffers/tests/test.cpp - /home/alain/flatbuffers/tests/union_vector/union_vector_generated.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/flexbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/util.h
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.make b/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.make deleted file mode 100644 index 41f54fc..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/depend.make +++ /dev/null
@@ -1,60 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -CMakeFiles/flattests.dir/src/code_generators.cpp.o: src/code_generators.cpp -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/src/code_generators.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: src/idl_gen_fbs.cpp -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/code_generators.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: src/idl_gen_text.cpp -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: src/idl_parser.cpp -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/src/idl_parser.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/src/reflection.cpp.o: src/reflection.cpp -CMakeFiles/flattests.dir/src/reflection.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/reflection.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/src/reflection.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/src/reflection.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/src/util.cpp.o: src/util.cpp -CMakeFiles/flattests.dir/src/util.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/src/util.cpp.o: include/flatbuffers/util.h - -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/monster_test_generated.h -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/namespace_test/namespace_test1_generated.h -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/namespace_test/namespace_test2_generated.h -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/test.cpp -CMakeFiles/flattests.dir/tests/test.cpp.o: tests/union_vector/union_vector_generated.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/flatbuffers.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/flexbuffers.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/hash.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/idl.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/reflection.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/reflection_generated.h -CMakeFiles/flattests.dir/tests/test.cpp.o: include/flatbuffers/util.h -
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/flags.make b/third_party/flatbuffers/CMakeFiles/flattests.dir/flags.make deleted file mode 100644 index c56d648..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/flags.make +++ /dev/null
@@ -1,10 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# compile CXX with /usr/bin/c++ -CXX_FLAGS = -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char - -CXX_DEFINES = -DFLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1 -DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - -CXX_INCLUDES = -I/home/alain/flatbuffers/include -I/home/alain/flatbuffers/grpc -I/home/alain/flatbuffers/tests -I/home/alain/flatbuffers/samples -
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/link.txt b/third_party/flatbuffers/CMakeFiles/flattests.dir/link.txt deleted file mode 100644 index 1b6d013..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/link.txt +++ /dev/null
@@ -1 +0,0 @@ -/usr/bin/c++ -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -fsigned-char CMakeFiles/flattests.dir/src/code_generators.cpp.o CMakeFiles/flattests.dir/src/idl_parser.cpp.o CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o CMakeFiles/flattests.dir/src/reflection.cpp.o CMakeFiles/flattests.dir/src/util.cpp.o CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o CMakeFiles/flattests.dir/tests/test.cpp.o -o flattests -rdynamic
diff --git a/third_party/flatbuffers/CMakeFiles/flattests.dir/progress.make b/third_party/flatbuffers/CMakeFiles/flattests.dir/progress.make deleted file mode 100644 index b1d90db..0000000 --- a/third_party/flatbuffers/CMakeFiles/flattests.dir/progress.make +++ /dev/null
@@ -1,10 +0,0 @@ -CMAKE_PROGRESS_1 = 38 -CMAKE_PROGRESS_2 = 39 -CMAKE_PROGRESS_3 = 40 -CMAKE_PROGRESS_4 = 41 -CMAKE_PROGRESS_5 = 42 -CMAKE_PROGRESS_6 = 43 -CMAKE_PROGRESS_7 = 44 -CMAKE_PROGRESS_8 = 45 -CMAKE_PROGRESS_9 = 46 -
diff --git a/third_party/flatbuffers/CMakeFiles/progress.marks b/third_party/flatbuffers/CMakeFiles/progress.marks deleted file mode 100644 index 9e5feb5..0000000 --- a/third_party/flatbuffers/CMakeFiles/progress.marks +++ /dev/null
@@ -1 +0,0 @@ -46
diff --git a/third_party/flatbuffers/CMakeLists.txt b/third_party/flatbuffers/CMakeLists.txt deleted file mode 100644 index 5d3c44d..0000000 --- a/third_party/flatbuffers/CMakeLists.txt +++ /dev/null
@@ -1,254 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(FlatBuffers) - -# NOTE: Code coverage only works on Linux & OSX. -option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF) -option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON) -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) -option(FLATBUFFERS_BUILD_SHAREDLIB - "Enable the build of the flatbuffers shared library" - OFF) - -if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS) - message(WARNING - "Cannot build tests without building the compiler. Tests will be disabled.") - set(FLATBUFFERS_BUILD_TESTS OFF) -endif() - -set(FlatBuffers_Library_SRCS - include/flatbuffers/code_generators.h - include/flatbuffers/flatbuffers.h - include/flatbuffers/hash.h - include/flatbuffers/idl.h - include/flatbuffers/util.h - include/flatbuffers/reflection.h - include/flatbuffers/reflection_generated.h - include/flatbuffers/flexbuffers.h - src/code_generators.cpp - src/idl_parser.cpp - src/idl_gen_text.cpp - src/reflection.cpp - src/util.cpp -) - -set(FlatBuffers_Compiler_SRCS - ${FlatBuffers_Library_SRCS} - src/idl_gen_cpp.cpp - src/idl_gen_general.cpp - src/idl_gen_go.cpp - src/idl_gen_js.cpp - src/idl_gen_php.cpp - src/idl_gen_python.cpp - src/idl_gen_fbs.cpp - src/idl_gen_grpc.cpp - src/flatc.cpp - src/flatc_main.cpp - grpc/src/compiler/schema_interface.h - grpc/src/compiler/cpp_generator.h - grpc/src/compiler/cpp_generator.cc - grpc/src/compiler/go_generator.h - grpc/src/compiler/go_generator.cc -) - -set(FlatHash_SRCS - include/flatbuffers/hash.h - src/flathash.cpp -) - -set(FlatBuffers_Tests_SRCS - ${FlatBuffers_Library_SRCS} - src/idl_gen_fbs.cpp - tests/test.cpp - # file generate by running compiler on tests/monster_test.fbs - ${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h -) - -set(FlatBuffers_Sample_Binary_SRCS - include/flatbuffers/flatbuffers.h - samples/sample_binary.cpp - # file generated by running compiler on samples/monster.fbs - ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h -) - -set(FlatBuffers_Sample_Text_SRCS - ${FlatBuffers_Library_SRCS} - samples/sample_text.cpp - # file generated by running compiler on samples/monster.fbs - ${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}) - -if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") - # do not apply any global settings if the toolchain - # is being configured externally -elseif(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra") -elseif(CMAKE_COMPILER_IS_GNUCXX) - if(CYGWIN) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -std=gnu++11") - else(CYGWIN) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -std=c++0x") - endif(CYGWIN) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror=shadow") - if (GCC_VERSION VERSION_GREATER 4.4) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result \ - -Wunused-parameter -Werror=unused-parameter") - endif() - - # Certain platforms such as ARM do not use signed chars by default - # which causes issues with certain bounds checks. - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -fsigned-char") - -elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic \ - -Wextra") - if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -stdlib=libc++") - endif() - if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR - "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")) - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} -lc++abi") - endif() - - # Certain platforms such as ARM do not use signed chars by default - # which causes issues with certain bounds checks. - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -fsigned-char") - -elseif(MSVC) - # Visual Studio pedantic build settings - # warning C4512: assignment operator could not be generated - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512") -endif() - -if(FLATBUFFERS_CODE_COVERAGE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage") - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") -endif() - -if(BIICODE) - include(biicode/cmake/biicode.cmake) - return() -endif() - -include_directories(include) -include_directories(grpc) - -if(FLATBUFFERS_BUILD_FLATLIB) -add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS}) -endif() - -if(FLATBUFFERS_BUILD_FLATC) - add_executable(flatc ${FlatBuffers_Compiler_SRCS}) - if(NOT FLATBUFFERS_FLATC_EXECUTABLE) - set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>) - endif() -endif() - -if(FLATBUFFERS_BUILD_FLATHASH) - add_executable(flathash ${FlatHash_SRCS}) -endif() - -if(FLATBUFFERS_BUILD_SHAREDLIB) - add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS}) - set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers) -endif() - -function(compile_flatbuffers_schema_to_cpp SRC_FBS) - get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) - string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) - add_custom_command( - OUTPUT ${GEN_HEADER} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable - --gen-object-api -o "${SRC_FBS_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" - DEPENDS flatc) -endfunction() - -function(compile_flatbuffers_schema_to_binary SRC_FBS) - get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) - string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS}) - add_custom_command( - OUTPUT ${GEN_BINARY_SCHEMA} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" - DEPENDS flatc) -endfunction() - -if(FLATBUFFERS_BUILD_TESTS) - compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests) - add_executable(flattests ${FlatBuffers_Tests_SRCS}) - set_property(TARGET flattests - PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1) - - compile_flatbuffers_schema_to_cpp(samples/monster.fbs) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples) - add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) - 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) - install(TARGETS flatbuffers DESTINATION lib) - endif() - if(FLATBUFFERS_BUILD_FLATC) - install(TARGETS flatc DESTINATION bin) - endif() - if(FLATBUFFERS_BUILD_SHAREDLIB) - install(TARGETS flatbuffers_shared DESTINATION lib) - endif() -endif() - -if(FLATBUFFERS_BUILD_TESTS) - enable_testing() - - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION - "${CMAKE_CURRENT_BINARY_DIR}") - add_test(NAME flattests COMMAND flattests) -endif() - -include(CMake/BuildFlatBuffers.cmake) - -if(FLATBUFFERS_PACKAGE_DEBIAN) - include(CMake/PackageDebian.cmake) -endif()
diff --git a/third_party/flatbuffers/CONTRIBUTING.md b/third_party/flatbuffers/CONTRIBUTING.md deleted file mode 100644 index 17428ad..0000000 --- a/third_party/flatbuffers/CONTRIBUTING.md +++ /dev/null
@@ -1,42 +0,0 @@ -Contributing {#contributing} -============ - -Want to contribute? Great! First, read this page (including the small print at -the end). - -# Before you contribute -Before we can use your code, you must sign the -[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) -(CLA), which you can do online. The CLA is necessary mainly because you own the -copyright to your changes, even after your contribution becomes part of our -codebase, so we need your permission to use and distribute your code. We also -need to be sure of various other things—for instance that you'll tell us if you -know that your code infringes on other people's patents. You don't have to sign -the CLA until after you've submitted your code for review and a member has -approved it, but you must do it before we can put your code into our codebase. -Before you start working on a larger contribution, you should get in touch with -us first through the issue tracker with your idea so that we can help out and -possibly guide you. Coordinating up front makes it much easier to avoid -frustration later on. - -# Code reviews -All submissions, including submissions by project members, require review. We -use Github pull requests for this purpose. - -Some tips for good pull requests: -* Use our code - [style guide](https://google.github.io/styleguide/cppguide.html). - When in doubt, try to stay true to the existing code of the project. -* Write a descriptive commit message. What problem are you solving and what - are the consequences? Where and what did you test? Some good tips: - [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message) - and [here](https://www.kernel.org/doc/Documentation/SubmittingPatches). -* If your PR consists of multiple commits which are successive improvements / - fixes to your first commit, consider squashing them into a single commit - (`git rebase -i`) such that your PR is a single commit on top of the current - HEAD. This make reviewing the code so much easier, and our history more - readable. - -# The small print -Contributions made by corporations are covered by a different agreement than -the one above, the Software Grant and Corporate Contributor License Agreement.
diff --git a/third_party/flatbuffers/CTestTestfile.cmake b/third_party/flatbuffers/CTestTestfile.cmake deleted file mode 100644 index c4fd7aa..0000000 --- a/third_party/flatbuffers/CTestTestfile.cmake +++ /dev/null
@@ -1,7 +0,0 @@ -# CMake generated Testfile for -# Source directory: /home/alain/flatbuffers -# Build directory: /home/alain/flatbuffers -# -# This file includes the relevant testing commands required for -# testing this directory and lists subdirectories to be tested as well. -add_test(flattests "/home/alain/flatbuffers/flattests")
diff --git a/third_party/flatbuffers/LICENSE.txt b/third_party/flatbuffers/LICENSE.txt deleted file mode 100644 index a4c5efd..0000000 --- a/third_party/flatbuffers/LICENSE.txt +++ /dev/null
@@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2014 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.
diff --git a/third_party/flatbuffers/Makefile b/third_party/flatbuffers/Makefile deleted file mode 100644 index b472e1f..0000000 --- a/third_party/flatbuffers/Makefile +++ /dev/null
@@ -1,956 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 - -# Default target executed when no arguments are given to make. -default_target: all - -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/alain/flatbuffers - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/alain/flatbuffers - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache - -.PHONY : rebuild_cache/fast - -# Special rule for the target install -install: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/bin/cmake -P cmake_install.cmake -.PHONY : install - -# Special rule for the target install -install/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/bin/cmake -P cmake_install.cmake -.PHONY : install/fast - -# Special rule for the target list_install_components -list_install_components: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" -.PHONY : list_install_components - -# Special rule for the target list_install_components -list_install_components/fast: list_install_components - -.PHONY : list_install_components/fast - -# Special rule for the target install/strip -install/strip: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip - -# Special rule for the target install/strip -install/strip/fast: install/strip - -.PHONY : install/strip/fast - -# Special rule for the target install/local -install/local: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local - -# Special rule for the target install/local -install/local/fast: install/local - -.PHONY : install/local/fast - -# Special rule for the target test -test: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..." - /usr/bin/ctest --force-new-ctest-process $(ARGS) -.PHONY : test - -# Special rule for the target test -test/fast: test - -.PHONY : test/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." - /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache - -.PHONY : edit_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles /home/alain/flatbuffers/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/flatbuffers/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean - -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named flattests - -# Build rule for target. -flattests: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flattests -.PHONY : flattests - -# fast build rule for target. -flattests/fast: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/build -.PHONY : flattests/fast - -#============================================================================= -# Target rules for targets named flatc - -# Build rule for target. -flatc: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flatc -.PHONY : flatc - -# fast build rule for target. -flatc/fast: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/build -.PHONY : flatc/fast - -#============================================================================= -# Target rules for targets named flatbuffers - -# Build rule for target. -flatbuffers: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flatbuffers -.PHONY : flatbuffers - -# fast build rule for target. -flatbuffers/fast: - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/build -.PHONY : flatbuffers/fast - -#============================================================================= -# Target rules for targets named flatsamplebinary - -# Build rule for target. -flatsamplebinary: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flatsamplebinary -.PHONY : flatsamplebinary - -# fast build rule for target. -flatsamplebinary/fast: - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/build -.PHONY : flatsamplebinary/fast - -#============================================================================= -# Target rules for targets named flathash - -# Build rule for target. -flathash: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flathash -.PHONY : flathash - -# fast build rule for target. -flathash/fast: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/build -.PHONY : flathash/fast - -#============================================================================= -# Target rules for targets named flatsampletext - -# Build rule for target. -flatsampletext: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 flatsampletext -.PHONY : flatsampletext - -# fast build rule for target. -flatsampletext/fast: - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/build -.PHONY : flatsampletext/fast - -grpc/src/compiler/cpp_generator.o: grpc/src/compiler/cpp_generator.cc.o - -.PHONY : grpc/src/compiler/cpp_generator.o - -# target to build an object file -grpc/src/compiler/cpp_generator.cc.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o -.PHONY : grpc/src/compiler/cpp_generator.cc.o - -grpc/src/compiler/cpp_generator.i: grpc/src/compiler/cpp_generator.cc.i - -.PHONY : grpc/src/compiler/cpp_generator.i - -# target to preprocess a source file -grpc/src/compiler/cpp_generator.cc.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.i -.PHONY : grpc/src/compiler/cpp_generator.cc.i - -grpc/src/compiler/cpp_generator.s: grpc/src/compiler/cpp_generator.cc.s - -.PHONY : grpc/src/compiler/cpp_generator.s - -# target to generate assembly for a file -grpc/src/compiler/cpp_generator.cc.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.s -.PHONY : grpc/src/compiler/cpp_generator.cc.s - -grpc/src/compiler/go_generator.o: grpc/src/compiler/go_generator.cc.o - -.PHONY : grpc/src/compiler/go_generator.o - -# target to build an object file -grpc/src/compiler/go_generator.cc.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o -.PHONY : grpc/src/compiler/go_generator.cc.o - -grpc/src/compiler/go_generator.i: grpc/src/compiler/go_generator.cc.i - -.PHONY : grpc/src/compiler/go_generator.i - -# target to preprocess a source file -grpc/src/compiler/go_generator.cc.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.i -.PHONY : grpc/src/compiler/go_generator.cc.i - -grpc/src/compiler/go_generator.s: grpc/src/compiler/go_generator.cc.s - -.PHONY : grpc/src/compiler/go_generator.s - -# target to generate assembly for a file -grpc/src/compiler/go_generator.cc.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.s -.PHONY : grpc/src/compiler/go_generator.cc.s - -samples/sample_binary.o: samples/sample_binary.cpp.o - -.PHONY : samples/sample_binary.o - -# target to build an object file -samples/sample_binary.cpp.o: - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.o -.PHONY : samples/sample_binary.cpp.o - -samples/sample_binary.i: samples/sample_binary.cpp.i - -.PHONY : samples/sample_binary.i - -# target to preprocess a source file -samples/sample_binary.cpp.i: - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.i -.PHONY : samples/sample_binary.cpp.i - -samples/sample_binary.s: samples/sample_binary.cpp.s - -.PHONY : samples/sample_binary.s - -# target to generate assembly for a file -samples/sample_binary.cpp.s: - $(MAKE) -f CMakeFiles/flatsamplebinary.dir/build.make CMakeFiles/flatsamplebinary.dir/samples/sample_binary.cpp.s -.PHONY : samples/sample_binary.cpp.s - -samples/sample_text.o: samples/sample_text.cpp.o - -.PHONY : samples/sample_text.o - -# target to build an object file -samples/sample_text.cpp.o: - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o -.PHONY : samples/sample_text.cpp.o - -samples/sample_text.i: samples/sample_text.cpp.i - -.PHONY : samples/sample_text.i - -# target to preprocess a source file -samples/sample_text.cpp.i: - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.i -.PHONY : samples/sample_text.cpp.i - -samples/sample_text.s: samples/sample_text.cpp.s - -.PHONY : samples/sample_text.s - -# target to generate assembly for a file -samples/sample_text.cpp.s: - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.s -.PHONY : samples/sample_text.cpp.s - -src/code_generators.o: src/code_generators.cpp.o - -.PHONY : src/code_generators.o - -# target to build an object file -src/code_generators.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/code_generators.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/code_generators.cpp.o - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/code_generators.cpp.o -.PHONY : src/code_generators.cpp.o - -src/code_generators.i: src/code_generators.cpp.i - -.PHONY : src/code_generators.i - -# target to preprocess a source file -src/code_generators.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/code_generators.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/code_generators.cpp.i - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/code_generators.cpp.i - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/code_generators.cpp.i -.PHONY : src/code_generators.cpp.i - -src/code_generators.s: src/code_generators.cpp.s - -.PHONY : src/code_generators.s - -# target to generate assembly for a file -src/code_generators.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/code_generators.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/code_generators.cpp.s - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/code_generators.cpp.s - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/code_generators.cpp.s -.PHONY : src/code_generators.cpp.s - -src/flatc.o: src/flatc.cpp.o - -.PHONY : src/flatc.o - -# target to build an object file -src/flatc.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc.cpp.o -.PHONY : src/flatc.cpp.o - -src/flatc.i: src/flatc.cpp.i - -.PHONY : src/flatc.i - -# target to preprocess a source file -src/flatc.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc.cpp.i -.PHONY : src/flatc.cpp.i - -src/flatc.s: src/flatc.cpp.s - -.PHONY : src/flatc.s - -# target to generate assembly for a file -src/flatc.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc.cpp.s -.PHONY : src/flatc.cpp.s - -src/flatc_main.o: src/flatc_main.cpp.o - -.PHONY : src/flatc_main.o - -# target to build an object file -src/flatc_main.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc_main.cpp.o -.PHONY : src/flatc_main.cpp.o - -src/flatc_main.i: src/flatc_main.cpp.i - -.PHONY : src/flatc_main.i - -# target to preprocess a source file -src/flatc_main.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc_main.cpp.i -.PHONY : src/flatc_main.cpp.i - -src/flatc_main.s: src/flatc_main.cpp.s - -.PHONY : src/flatc_main.s - -# target to generate assembly for a file -src/flatc_main.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/flatc_main.cpp.s -.PHONY : src/flatc_main.cpp.s - -src/flathash.o: src/flathash.cpp.o - -.PHONY : src/flathash.o - -# target to build an object file -src/flathash.cpp.o: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/src/flathash.cpp.o -.PHONY : src/flathash.cpp.o - -src/flathash.i: src/flathash.cpp.i - -.PHONY : src/flathash.i - -# target to preprocess a source file -src/flathash.cpp.i: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/src/flathash.cpp.i -.PHONY : src/flathash.cpp.i - -src/flathash.s: src/flathash.cpp.s - -.PHONY : src/flathash.s - -# target to generate assembly for a file -src/flathash.cpp.s: - $(MAKE) -f CMakeFiles/flathash.dir/build.make CMakeFiles/flathash.dir/src/flathash.cpp.s -.PHONY : src/flathash.cpp.s - -src/idl_gen_cpp.o: src/idl_gen_cpp.cpp.o - -.PHONY : src/idl_gen_cpp.o - -# target to build an object file -src/idl_gen_cpp.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o -.PHONY : src/idl_gen_cpp.cpp.o - -src/idl_gen_cpp.i: src/idl_gen_cpp.cpp.i - -.PHONY : src/idl_gen_cpp.i - -# target to preprocess a source file -src/idl_gen_cpp.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.i -.PHONY : src/idl_gen_cpp.cpp.i - -src/idl_gen_cpp.s: src/idl_gen_cpp.cpp.s - -.PHONY : src/idl_gen_cpp.s - -# target to generate assembly for a file -src/idl_gen_cpp.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.s -.PHONY : src/idl_gen_cpp.cpp.s - -src/idl_gen_fbs.o: src/idl_gen_fbs.cpp.o - -.PHONY : src/idl_gen_fbs.o - -# target to build an object file -src/idl_gen_fbs.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o -.PHONY : src/idl_gen_fbs.cpp.o - -src/idl_gen_fbs.i: src/idl_gen_fbs.cpp.i - -.PHONY : src/idl_gen_fbs.i - -# target to preprocess a source file -src/idl_gen_fbs.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.i -.PHONY : src/idl_gen_fbs.cpp.i - -src/idl_gen_fbs.s: src/idl_gen_fbs.cpp.s - -.PHONY : src/idl_gen_fbs.s - -# target to generate assembly for a file -src/idl_gen_fbs.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.s -.PHONY : src/idl_gen_fbs.cpp.s - -src/idl_gen_general.o: src/idl_gen_general.cpp.o - -.PHONY : src/idl_gen_general.o - -# target to build an object file -src/idl_gen_general.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_general.cpp.o -.PHONY : src/idl_gen_general.cpp.o - -src/idl_gen_general.i: src/idl_gen_general.cpp.i - -.PHONY : src/idl_gen_general.i - -# target to preprocess a source file -src/idl_gen_general.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_general.cpp.i -.PHONY : src/idl_gen_general.cpp.i - -src/idl_gen_general.s: src/idl_gen_general.cpp.s - -.PHONY : src/idl_gen_general.s - -# target to generate assembly for a file -src/idl_gen_general.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_general.cpp.s -.PHONY : src/idl_gen_general.cpp.s - -src/idl_gen_go.o: src/idl_gen_go.cpp.o - -.PHONY : src/idl_gen_go.o - -# target to build an object file -src/idl_gen_go.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o -.PHONY : src/idl_gen_go.cpp.o - -src/idl_gen_go.i: src/idl_gen_go.cpp.i - -.PHONY : src/idl_gen_go.i - -# target to preprocess a source file -src/idl_gen_go.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_go.cpp.i -.PHONY : src/idl_gen_go.cpp.i - -src/idl_gen_go.s: src/idl_gen_go.cpp.s - -.PHONY : src/idl_gen_go.s - -# target to generate assembly for a file -src/idl_gen_go.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_go.cpp.s -.PHONY : src/idl_gen_go.cpp.s - -src/idl_gen_grpc.o: src/idl_gen_grpc.cpp.o - -.PHONY : src/idl_gen_grpc.o - -# target to build an object file -src/idl_gen_grpc.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o -.PHONY : src/idl_gen_grpc.cpp.o - -src/idl_gen_grpc.i: src/idl_gen_grpc.cpp.i - -.PHONY : src/idl_gen_grpc.i - -# target to preprocess a source file -src/idl_gen_grpc.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.i -.PHONY : src/idl_gen_grpc.cpp.i - -src/idl_gen_grpc.s: src/idl_gen_grpc.cpp.s - -.PHONY : src/idl_gen_grpc.s - -# target to generate assembly for a file -src/idl_gen_grpc.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.s -.PHONY : src/idl_gen_grpc.cpp.s - -src/idl_gen_js.o: src/idl_gen_js.cpp.o - -.PHONY : src/idl_gen_js.o - -# target to build an object file -src/idl_gen_js.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_js.cpp.o -.PHONY : src/idl_gen_js.cpp.o - -src/idl_gen_js.i: src/idl_gen_js.cpp.i - -.PHONY : src/idl_gen_js.i - -# target to preprocess a source file -src/idl_gen_js.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_js.cpp.i -.PHONY : src/idl_gen_js.cpp.i - -src/idl_gen_js.s: src/idl_gen_js.cpp.s - -.PHONY : src/idl_gen_js.s - -# target to generate assembly for a file -src/idl_gen_js.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_js.cpp.s -.PHONY : src/idl_gen_js.cpp.s - -src/idl_gen_php.o: src/idl_gen_php.cpp.o - -.PHONY : src/idl_gen_php.o - -# target to build an object file -src/idl_gen_php.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o -.PHONY : src/idl_gen_php.cpp.o - -src/idl_gen_php.i: src/idl_gen_php.cpp.i - -.PHONY : src/idl_gen_php.i - -# target to preprocess a source file -src/idl_gen_php.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_php.cpp.i -.PHONY : src/idl_gen_php.cpp.i - -src/idl_gen_php.s: src/idl_gen_php.cpp.s - -.PHONY : src/idl_gen_php.s - -# target to generate assembly for a file -src/idl_gen_php.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_php.cpp.s -.PHONY : src/idl_gen_php.cpp.s - -src/idl_gen_python.o: src/idl_gen_python.cpp.o - -.PHONY : src/idl_gen_python.o - -# target to build an object file -src/idl_gen_python.cpp.o: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o -.PHONY : src/idl_gen_python.cpp.o - -src/idl_gen_python.i: src/idl_gen_python.cpp.i - -.PHONY : src/idl_gen_python.i - -# target to preprocess a source file -src/idl_gen_python.cpp.i: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_python.cpp.i -.PHONY : src/idl_gen_python.cpp.i - -src/idl_gen_python.s: src/idl_gen_python.cpp.s - -.PHONY : src/idl_gen_python.s - -# target to generate assembly for a file -src/idl_gen_python.cpp.s: - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_python.cpp.s -.PHONY : src/idl_gen_python.cpp.s - -src/idl_gen_text.o: src/idl_gen_text.cpp.o - -.PHONY : src/idl_gen_text.o - -# target to build an object file -src/idl_gen_text.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o -.PHONY : src/idl_gen_text.cpp.o - -src/idl_gen_text.i: src/idl_gen_text.cpp.i - -.PHONY : src/idl_gen_text.i - -# target to preprocess a source file -src/idl_gen_text.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_text.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_text.cpp.i - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.i - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.i -.PHONY : src/idl_gen_text.cpp.i - -src/idl_gen_text.s: src/idl_gen_text.cpp.s - -.PHONY : src/idl_gen_text.s - -# target to generate assembly for a file -src/idl_gen_text.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_gen_text.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_gen_text.cpp.s - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.s - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.s -.PHONY : src/idl_gen_text.cpp.s - -src/idl_parser.o: src/idl_parser.cpp.o - -.PHONY : src/idl_parser.o - -# target to build an object file -src/idl_parser.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_parser.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_parser.cpp.o - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o -.PHONY : src/idl_parser.cpp.o - -src/idl_parser.i: src/idl_parser.cpp.i - -.PHONY : src/idl_parser.i - -# target to preprocess a source file -src/idl_parser.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_parser.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_parser.cpp.i - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.i - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.i -.PHONY : src/idl_parser.cpp.i - -src/idl_parser.s: src/idl_parser.cpp.s - -.PHONY : src/idl_parser.s - -# target to generate assembly for a file -src/idl_parser.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/idl_parser.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/idl_parser.cpp.s - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.s - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.s -.PHONY : src/idl_parser.cpp.s - -src/reflection.o: src/reflection.cpp.o - -.PHONY : src/reflection.o - -# target to build an object file -src/reflection.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/reflection.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/reflection.cpp.o - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/reflection.cpp.o - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/reflection.cpp.o -.PHONY : src/reflection.cpp.o - -src/reflection.i: src/reflection.cpp.i - -.PHONY : src/reflection.i - -# target to preprocess a source file -src/reflection.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/reflection.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/reflection.cpp.i - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/reflection.cpp.i - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/reflection.cpp.i -.PHONY : src/reflection.cpp.i - -src/reflection.s: src/reflection.cpp.s - -.PHONY : src/reflection.s - -# target to generate assembly for a file -src/reflection.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/reflection.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/reflection.cpp.s - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/reflection.cpp.s - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/reflection.cpp.s -.PHONY : src/reflection.cpp.s - -src/util.o: src/util.cpp.o - -.PHONY : src/util.o - -# target to build an object file -src/util.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/util.cpp.o - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/util.cpp.o - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/util.cpp.o - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/util.cpp.o -.PHONY : src/util.cpp.o - -src/util.i: src/util.cpp.i - -.PHONY : src/util.i - -# target to preprocess a source file -src/util.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/util.cpp.i - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/util.cpp.i - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/util.cpp.i - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/util.cpp.i -.PHONY : src/util.cpp.i - -src/util.s: src/util.cpp.s - -.PHONY : src/util.s - -# target to generate assembly for a file -src/util.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/src/util.cpp.s - $(MAKE) -f CMakeFiles/flatc.dir/build.make CMakeFiles/flatc.dir/src/util.cpp.s - $(MAKE) -f CMakeFiles/flatbuffers.dir/build.make CMakeFiles/flatbuffers.dir/src/util.cpp.s - $(MAKE) -f CMakeFiles/flatsampletext.dir/build.make CMakeFiles/flatsampletext.dir/src/util.cpp.s -.PHONY : src/util.cpp.s - -tests/test.o: tests/test.cpp.o - -.PHONY : tests/test.o - -# target to build an object file -tests/test.cpp.o: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/tests/test.cpp.o -.PHONY : tests/test.cpp.o - -tests/test.i: tests/test.cpp.i - -.PHONY : tests/test.i - -# target to preprocess a source file -tests/test.cpp.i: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/tests/test.cpp.i -.PHONY : tests/test.cpp.i - -tests/test.s: tests/test.cpp.s - -.PHONY : tests/test.s - -# target to generate assembly for a file -tests/test.cpp.s: - $(MAKE) -f CMakeFiles/flattests.dir/build.make CMakeFiles/flattests.dir/tests/test.cpp.s -.PHONY : tests/test.cpp.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... rebuild_cache" - @echo "... install" - @echo "... flattests" - @echo "... flatc" - @echo "... list_install_components" - @echo "... install/strip" - @echo "... install/local" - @echo "... flatbuffers" - @echo "... flatsamplebinary" - @echo "... flathash" - @echo "... flatsampletext" - @echo "... test" - @echo "... edit_cache" - @echo "... grpc/src/compiler/cpp_generator.o" - @echo "... grpc/src/compiler/cpp_generator.i" - @echo "... grpc/src/compiler/cpp_generator.s" - @echo "... grpc/src/compiler/go_generator.o" - @echo "... grpc/src/compiler/go_generator.i" - @echo "... grpc/src/compiler/go_generator.s" - @echo "... samples/sample_binary.o" - @echo "... samples/sample_binary.i" - @echo "... samples/sample_binary.s" - @echo "... samples/sample_text.o" - @echo "... samples/sample_text.i" - @echo "... samples/sample_text.s" - @echo "... src/code_generators.o" - @echo "... src/code_generators.i" - @echo "... src/code_generators.s" - @echo "... src/flatc.o" - @echo "... src/flatc.i" - @echo "... src/flatc.s" - @echo "... src/flatc_main.o" - @echo "... src/flatc_main.i" - @echo "... src/flatc_main.s" - @echo "... src/flathash.o" - @echo "... src/flathash.i" - @echo "... src/flathash.s" - @echo "... src/idl_gen_cpp.o" - @echo "... src/idl_gen_cpp.i" - @echo "... src/idl_gen_cpp.s" - @echo "... src/idl_gen_fbs.o" - @echo "... src/idl_gen_fbs.i" - @echo "... src/idl_gen_fbs.s" - @echo "... src/idl_gen_general.o" - @echo "... src/idl_gen_general.i" - @echo "... src/idl_gen_general.s" - @echo "... src/idl_gen_go.o" - @echo "... src/idl_gen_go.i" - @echo "... src/idl_gen_go.s" - @echo "... src/idl_gen_grpc.o" - @echo "... src/idl_gen_grpc.i" - @echo "... src/idl_gen_grpc.s" - @echo "... src/idl_gen_js.o" - @echo "... src/idl_gen_js.i" - @echo "... src/idl_gen_js.s" - @echo "... src/idl_gen_php.o" - @echo "... src/idl_gen_php.i" - @echo "... src/idl_gen_php.s" - @echo "... src/idl_gen_python.o" - @echo "... src/idl_gen_python.i" - @echo "... src/idl_gen_python.s" - @echo "... src/idl_gen_text.o" - @echo "... src/idl_gen_text.i" - @echo "... src/idl_gen_text.s" - @echo "... src/idl_parser.o" - @echo "... src/idl_parser.i" - @echo "... src/idl_parser.s" - @echo "... src/reflection.o" - @echo "... src/reflection.i" - @echo "... src/reflection.s" - @echo "... src/util.o" - @echo "... src/util.i" - @echo "... src/util.s" - @echo "... tests/test.o" - @echo "... tests/test.i" - @echo "... tests/test.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system -
diff --git a/third_party/flatbuffers/android/.project b/third_party/flatbuffers/android/.project deleted file mode 100755 index e7d5931..0000000 --- a/third_party/flatbuffers/android/.project +++ /dev/null
@@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (c) 2014 Google, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - --> -<projectDescription> - <name>FlatBufferTest</name> -</projectDescription>
diff --git a/third_party/flatbuffers/android/AndroidManifest.xml b/third_party/flatbuffers/android/AndroidManifest.xml deleted file mode 100755 index a15f547..0000000 --- a/third_party/flatbuffers/android/AndroidManifest.xml +++ /dev/null
@@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (c) 2013 Google, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - --> -<!-- BEGIN_INCLUDE(manifest) --> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.FlatBufferTest" - android:versionCode="1" - android:versionName="1.0"> - - <uses-feature android:glEsVersion="0x00020000"></uses-feature> - <!-- This is the platform API where NativeActivity was introduced. --> - <uses-sdk android:minSdkVersion="9" /> - - <!-- This .apk has no Java code itself, so set hasCode to false. --> - <application android:label="@string/app_name" android:hasCode="false"> - - <!-- Our activity is the built-in NativeActivity framework class. - This will take care of integrating with our NDK code. --> - <activity android:name="android.app.NativeActivity" - android:label="@string/app_name" - android:configChanges="orientation|keyboardHidden" - android:screenOrientation="landscape"> - <!-- Tell NativeActivity the name of or .so --> - <meta-data android:name="android.app.lib_name" - android:value="FlatBufferTest" /> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> -<!-- END_INCLUDE(manifest) -->
diff --git a/third_party/flatbuffers/android/build_apk.sh b/third_party/flatbuffers/android/build_apk.sh deleted file mode 100755 index 1b9f4a4..0000000 --- a/third_party/flatbuffers/android/build_apk.sh +++ /dev/null
@@ -1,511 +0,0 @@ -#!/bin/bash -eu -# -# Copyright (c) 2013 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. -# -# Build, deploy, debug / execute a native Android package based upon -# NativeActivity. - -declare -r script_directory=$(dirname $0) -declare -r android_root=${script_directory}/../../../../../../ -declare -r script_name=$(basename $0) -declare -r android_manifest=AndroidManifest.xml -declare -r os_name=$(uname -s) - -# Minimum Android target version supported by this project. -: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10} -# Directory containing the Android SDK -# (http://developer.android.com/sdk/index.html). -: ${ANDROID_SDK_HOME:=} -# Directory containing the Android NDK -# (http://developer.android.com/tools/sdk/ndk/index.html). -: ${NDK_HOME:=} - -# Display script help and exit. -usage() { - echo " -Build the Android package in the current directory and deploy it to a -connected device. - -Usage: ${script_name} \\ - [ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \ - [LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...] - -ADB_DEVICE=serial_number: - serial_number specifies the device to deploy the built apk to if multiple - Android devices are connected to the host. -BUILD=0: - Disables the build of the package. -DEPLOY=0: - Disables the deployment of the built apk to the Android device. -RUN_DEBUGGER=1: - Launches the application in gdb after it has been deployed. To debug in - gdb, NDK_DEBUG=1 must also be specified on the command line to build a - debug apk. -LAUNCH=0: - Disable the launch of the apk on the Android device. -SWIG_BIN=swig_binary_directory: - The directory where the SWIG binary lives. No need to set this if SWIG is - installed and point to from your PATH variable. -SWIG_LIB=swig_include_directory: - The directory where SWIG shared include files are, usually obtainable from - commandline with \"swig -swiglib\". No need to set this if SWIG is installed - and point to from your PATH variable. -ndk-build arguments...: - Additional arguments for ndk-build. See ndk-build -h for more information. -" >&2 - exit 1 -} - -# Get the number of CPU cores present on the host. -get_number_of_cores() { - case ${os_name} in - Darwin) - sysctl hw.ncpu | awk '{ print $2 }' - ;; - CYGWIN*|Linux) - awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo - ;; - *) - echo 1 - ;; - esac -} - -# Get the package name from an AndroidManifest.xml file. -get_package_name_from_manifest() { - xmllint --xpath 'string(/manifest/@package)' "${1}" -} - -# Get the library name from an AndroidManifest.xml file. -get_library_name_from_manifest() { - echo "\ -setns android=http://schemas.android.com/apk/res/android -xpath string(/manifest/application/activity\ -[@android:name=\"android.app.NativeActivity\"]/meta-data\ -[@android:name=\"android.app.lib_name\"]/@android:value)" | - xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }' -} - -# Get the number of Android devices connected to the system. -get_number_of_devices_connected() { - adb devices -l | \ - awk '/^..*$/ { if (p) { print $0 } } - /List of devices attached/ { p = 1 }' | \ - wc -l - return ${PIPESTATUS[0]} -} - -# Kill a process and its' children. This is provided for cygwin which -# doesn't ship with pkill. -kill_process_group() { - local parent_pid="${1}" - local child_pid= - for child_pid in $(ps -f | \ - awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do - kill_process_group "${child_pid}" - done - kill "${parent_pid}" 2>/dev/null -} - -# Find and run "adb". -adb() { - local adb_path= - for path in "$(which adb 2>/dev/null)" \ - "${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \ - "${android_root}/prebuilts/sdk/platform-tools/adb"; do - if [[ -e "${path}" ]]; then - adb_path="${path}" - break - fi - done - if [[ "${adb_path}" == "" ]]; then - echo -e "Unable to find adb." \ - "\nAdd the Android ADT sdk/platform-tools directory to the" \ - "PATH." >&2 - exit 1 - fi - "${adb_path}" "$@" -} - -# Find and run "android". -android() { - local android_executable=android - if echo "${os_name}" | grep -q CYGWIN; then - android_executable=android.bat - fi - local android_path= - for path in "$(which ${android_executable})" \ - "${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \ - "${android_root}/prebuilts/sdk/tools/${android_executable}"; do - if [[ -e "${path}" ]]; then - android_path="${path}" - break - fi - done - if [[ "${android_path}" == "" ]]; then - echo -e "Unable to find android tool." \ - "\nAdd the Android ADT sdk/tools directory to the PATH." >&2 - exit 1 - fi - # Make sure ant is installed. - if [[ "$(which ant)" == "" ]]; then - echo -e "Unable to find ant." \ - "\nPlease install ant and add to the PATH." >&2 - exit 1 - fi - - "${android_path}" "$@" -} - -# Find and run "ndk-build" -ndkbuild() { - local ndkbuild_path= - for path in "$(which ndk-build 2>/dev/null)" \ - "${NDK_HOME}/ndk-build" \ - "${android_root}/prebuilts/ndk/current/ndk-build"; do - if [[ -e "${path}" ]]; then - ndkbuild_path="${path}" - break - fi - done - if [[ "${ndkbuild_path}" == "" ]]; then - echo -e "Unable to find ndk-build." \ - "\nAdd the Android NDK directory to the PATH." >&2 - exit 1 - fi - "${ndkbuild_path}" "$@" -} - -# Get file modification time of $1 in seconds since the epoch. -stat_mtime() { - local filename="${1}" - case ${os_name} in - Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;; - *) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;; - esac -} - -# Build the native (C/C++) build targets in the current directory. -build_native_targets() { - # Save the list of output modules in the install directory so that it's - # possible to restore their timestamps after the build is complete. This - # works around a bug in ndk/build/core/setup-app.mk which results in the - # unconditional execution of the clean-installed-binaries rule. - restore_libraries="$(find libs -type f 2>/dev/null | \ - sed -E 's@^libs/(.*)@\1@')" - - # Build native code. - ndkbuild -j$(get_number_of_cores) "$@" - - # Restore installed libraries. - # Obviously this is a nasty hack (along with ${restore_libraries} above) as - # it assumes it knows where the NDK will be placing output files. - ( - IFS=$'\n' - for libpath in ${restore_libraries}; do - source_library="obj/local/${libpath}" - target_library="libs/${libpath}" - if [[ -e "${source_library}" ]]; then - cp -a "${source_library}" "${target_library}" - fi - done - ) -} - -# Select the oldest installed android build target that is at least as new as -# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found, -# this function prints an error message and exits with an error. -select_android_build_target() { - local -r android_targets_installed=$( \ - android list targets | \ - awk -F'"' '/^id:.*android/ { print $2 }') - local android_build_target= - for android_target in $(echo "${android_targets_installed}" | \ - awk -F- '{ print $2 }' | sort -n); do - local isNumber='^[0-9]+$' - # skip preview API releases e.g. 'android-L' - if [[ $android_target =~ $isNumber ]]; then - if [[ $((android_target)) -ge \ - $((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then - android_build_target="android-${android_target}" - break - fi - # else - # The API version is a letter, so skip it. - fi - done - if [[ "${android_build_target}" == "" ]]; then - echo -e \ - "Found installed Android targets:" \ - "$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \ - "\nAndroid SDK platform" \ - "android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \ - "must be installed to build this project." \ - "\nUse the \"android\" application to install API" \ - "$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2 - exit 1 - fi - echo "${android_build_target}" -} - -# Sign unsigned apk $1 and write the result to $2 with key store file $3 and -# password $4. -# If a key store file $3 and password $4 aren't specified, a temporary -# (60 day) key is generated and used to sign the package. -sign_apk() { - local unsigned_apk="${1}" - local signed_apk="${2}" - if [[ $(stat_mtime "${unsigned_apk}") -gt \ - $(stat_mtime "${signed_apk}") ]]; then - local -r key_alias=$(basename ${signed_apk} .apk) - local keystore="${3}" - local key_password="${4}" - [[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore" - [[ "${key_password}" == "" ]] && \ - key_password="${key_alias}123456" - if [[ ! -e ${keystore} ]]; then - keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \ - -storepass ${key_password} \ - -keypass ${key_password} -keystore ${keystore} \ - -alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60 - fi - cp "${unsigned_apk}" "${signed_apk}" - jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \ - -keystore ${keystore} -storepass ${key_password} \ - -keypass ${key_password} "${signed_apk}" ${key_alias} - fi -} - -# Build the apk $1 for package filename $2 in the current directory using the -# ant build target $3. -build_apk() { - local -r output_apk="${1}" - local -r package_filename="${2}" - local -r ant_target="${3}" - # Get the list of installed android targets and select the oldest target - # that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION. - local -r android_build_target=$(select_android_build_target) - [[ "${android_build_target}" == "" ]] && exit 1 - echo "Building ${output_apk} for target ${android_build_target}" >&2 - - # Create / update build.xml and local.properties files. - if [[ $(stat_mtime "${android_manifest}") -gt \ - $(stat_mtime build.xml) ]]; then - android update project --target "${android_build_target}" \ - -n ${package_filename} --path . - fi - - # Use ant to build the apk. - ant -quiet ${ant_target} - - # Sign release apks with a temporary key as these packages will not be - # redistributed. - local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk" - if [[ "${ant_target}" == "release" ]]; then - sign_apk "${unsigned_apk}" "${output_apk}" "" "" - fi -} - -# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device" -# or an empty string. If $3 is an empty string adb will fail when multiple -# devices are connected to the host system. -install_apk() { - local -r uninstall_package_name="${1}" - local -r install_apk="${2}" - local -r adb_device="${3}" - # Uninstall the package if it's already installed. - adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \ - true # no error check - - # Install the apk. - # NOTE: The following works around adb not returning an error code when - # it fails to install an apk. - echo "Install ${install_apk}" >&2 - local -r adb_install_result=$(adb ${adb_device} install "${install_apk}") - echo "${adb_install_result}" - if echo "${adb_install_result}" | grep -qF 'Failure ['; then - exit 1 - fi -} - -# Launch previously installed package $1 on device $2. -# If $2 is an empty string adb will fail when multiple devices are connected -# to the host system. -launch_package() { - ( - # Determine the SDK version of Android on the device. - local -r android_sdk_version=$( - adb ${adb_device} shell cat system/build.prop | \ - awk -F= '/ro.build.version.sdk/ { - v=$2; sub(/[ \r\n]/, "", v); print v - }') - - # Clear logs from previous runs. - # Note that logcat does not just 'tail' the logs, it dumps the entire log - # history. - adb ${adb_device} logcat -c - - local finished_msg='Displayed '"${package_name}" - local timeout_msg='Activity destroy timeout.*'"${package_name}" - # Maximum time to wait before stopping log monitoring. 0 = infinity. - local launch_timeout=0 - # If this is a Gingerbread device, kill log monitoring after 10 seconds. - if [[ $((android_sdk_version)) -le 10 ]]; then - launch_timeout=10 - fi - # Display logcat in the background. - # Stop displaying the log when the app launch / execution completes or the - # logcat - ( - adb ${adb_device} logcat | \ - awk " - { - print \$0 - } - - /ActivityManager.*: ${finished_msg}/ { - exit 0 - } - - /ActivityManager.*: ${timeout_msg}/ { - exit 0 - }" & - adb_logcat_pid=$!; - if [[ $((launch_timeout)) -gt 0 ]]; then - sleep $((launch_timeout)); - kill ${adb_logcat_pid}; - else - wait ${adb_logcat_pid}; - fi - ) & - logcat_pid=$! - # Kill adb logcat if this shell exits. - trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT - - # If the SDK is newer than 10, "am" supports stopping an activity. - adb_stop_activity= - if [[ $((android_sdk_version)) -gt 10 ]]; then - adb_stop_activity=-S - fi - - # Launch the activity and wait for it to complete. - adb ${adb_device} shell am start ${adb_stop_activity} -n \ - ${package_name}/android.app.NativeActivity - - wait "${logcat_pid}" - ) -} - -# See usage(). -main() { - # Parse arguments for this script. - local adb_device= - local ant_target=release - local disable_deploy=0 - local disable_build=0 - local run_debugger=0 - local launch=1 - local build_package=1 - for opt; do - case ${opt} in - # NDK_DEBUG=0 tells ndk-build to build this as debuggable but to not - # modify the underlying code whereas NDK_DEBUG=1 also builds as debuggable - # but does modify the code - NDK_DEBUG=1) ant_target=debug ;; - NDK_DEBUG=0) ant_target=debug ;; - ADB_DEVICE*) adb_device="$(\ - echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;; - BUILD=0) disable_build=1 ;; - DEPLOY=0) disable_deploy=1 ;; - RUN_DEBUGGER=1) run_debugger=1 ;; - LAUNCH=0) launch=0 ;; - clean) build_package=0 disable_deploy=1 launch=0 ;; - -h|--help|help) usage ;; - esac - done - - # If a target device hasn't been specified and multiple devices are connected - # to the host machine, display an error. - local -r devices_connected=$(get_number_of_devices_connected) - if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \ - ($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \ - $((run_debugger)) -ne 0) ]]; then - if [[ $((disable_deploy)) -ne 0 ]]; then - echo "Deployment enabled, disable using DEPLOY=0" >&2 - fi - if [[ $((launch)) -ne 0 ]]; then - echo "Launch enabled." >&2 - fi - if [[ $((disable_deploy)) -eq 0 ]]; then - echo "Deployment enabled." >&2 - fi - if [[ $((run_debugger)) -ne 0 ]]; then - echo "Debugger launch enabled." >&2 - fi - echo " -Multiple Android devices are connected to this host. Either disable deployment -and execution of the built .apk using: - \"${script_name} DEPLOY=0 LAUNCH=0\" - -or specify a device to deploy to using: - \"${script_name} ADB_DEVICE=\${device_serial}\". - -The Android devices connected to this machine are: -$(adb devices -l) -" >&2 - exit 1 - fi - - if [[ $((disable_build)) -eq 0 ]]; then - # Build the native target. - build_native_targets "$@" - fi - - # Get the package name from the manifest. - local -r package_name=$(get_package_name_from_manifest "${android_manifest}") - if [[ "${package_name}" == "" ]]; then - echo -e "No package name specified in ${android_manifest},"\ - "skipping apk build, deploy" - "\nand launch steps." >&2 - exit 0 - fi - local -r package_basename=${package_name/*./} - local package_filename=$(get_library_name_from_manifest ${android_manifest}) - [[ "${package_filename}" == "" ]] && package_filename="${package_basename}" - - # Output apk name. - local -r output_apk="bin/${package_filename}-${ant_target}.apk" - - if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then - # Build the apk. - build_apk "${output_apk}" "${package_filename}" "${ant_target}" - fi - - # Deploy to the device. - if [[ $((disable_deploy)) -eq 0 ]]; then - install_apk "${package_name}" "${output_apk}" "${adb_device}" - fi - - if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then - # Start debugging. - ndk-gdb ${adb_device} --start - elif [[ $((launch)) -eq 1 ]]; then - launch_package "${package_name}" "${adb_device}" - fi -} - -main "$@"
diff --git a/third_party/flatbuffers/android/jni/Android.mk b/third_party/flatbuffers/android/jni/Android.mk deleted file mode 100755 index 0269dd3..0000000 --- a/third_party/flatbuffers/android/jni/Android.mk +++ /dev/null
@@ -1,58 +0,0 @@ -# Copyright (c) 2013 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. - -LOCAL_PATH := $(call my-dir)/../.. - -include $(LOCAL_PATH)/android/jni/include.mk -LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH)) - -# Empty static library so that other projects can include just the basic -# FlatBuffers headers as a module. -include $(CLEAR_VARS) -LOCAL_MODULE := flatbuffers -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall \ - -DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - -include $(BUILD_STATIC_LIBRARY) - -# static library that additionally includes text parsing/generation/reflection -# for projects that want richer functionality. -include $(CLEAR_VARS) -LOCAL_MODULE := flatbuffers_extra -LOCAL_SRC_FILES := src/idl_parser.cpp \ - src/idl_gen_text.cpp \ - src/reflection.cpp \ - src/util.cpp \ - src/code_generators.cpp -LOCAL_STATIC_LIBRARIES := flatbuffers -include $(BUILD_STATIC_LIBRARY) - -# FlatBuffers test -include $(CLEAR_VARS) -LOCAL_MODULE := FlatBufferTest -LOCAL_SRC_FILES := android/jni/main.cpp \ - tests/test.cpp \ - src/idl_gen_fbs.cpp \ - src/idl_gen_general.cpp -LOCAL_LDLIBS := -llog -landroid -LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra -LOCAL_ARM_MODE := arm -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,android/native_app_glue) - -$(call import-add-path,$(LOCAL_PATH)/../..)
diff --git a/third_party/flatbuffers/android/jni/Application.mk b/third_party/flatbuffers/android/jni/Application.mk deleted file mode 100755 index 2fc9c73..0000000 --- a/third_party/flatbuffers/android/jni/Application.mk +++ /dev/null
@@ -1,22 +0,0 @@ -# Copyright (c) 2014 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. -APP_PLATFORM := android-10 -APP_PROJECT_PATH := $(call my-dir)/.. -APP_STL := gnustl_static - -APP_ABI := armeabi-v7a - -APP_CPPFLAGS += -std=c++11
diff --git a/third_party/flatbuffers/android/jni/build_flatc.bat b/third_party/flatbuffers/android/jni/build_flatc.bat deleted file mode 100755 index 0b3f2ad..0000000 --- a/third_party/flatbuffers/android/jni/build_flatc.bat +++ /dev/null
@@ -1,68 +0,0 @@ -@rem Copyright (c) 2013 Google, Inc. -@rem -@rem This software is provided 'as-is', without any express or implied -@rem warranty. In no event will the authors be held liable for any damages -@rem arising from the use of this software. -@rem Permission is granted to anyone to use this software for any purpose, -@rem including commercial applications, and to alter it and redistribute it -@rem freely, subject to the following restrictions: -@rem 1. The origin of this software must not be misrepresented; you must not -@rem claim that you wrote the original software. If you use this software -@rem in a product, an acknowledgment in the product documentation would be -@rem appreciated but is not required. -@rem 2. Altered source versions must be plainly marked as such, and must not be -@rem misrepresented as being the original software. -@rem 3. This notice may not be removed or altered from any source distribution. -@echo off - -setlocal enabledelayedexpansion - -set thispath=%~dp0 - -rem Path to cmake passed in by caller. -set cmake=%1 -rem Path to cmake project to build. -set cmake_project_path=%2 - -rem Newest and oldest version of Visual Studio that it's possible to select. -set visual_studio_version_max=20 -set visual_studio_version_min=8 - -rem Determine the newest version of Visual Studio installed on this machine. -set visual_studio_version= -for /L %%a in (%visual_studio_version_max%,-1,%visual_studio_version_min%) do ( - echo Searching for Visual Studio %%a >&2 - reg query HKLM\SOFTWARE\Microsoft\VisualStudio\%%a.0 /ve 1>NUL 2>NUL - if !ERRORLEVEL! EQU 0 ( - set visual_studio_version=%%a - goto found_vs - ) -) -echo Unable to determine whether Visual Studio is installed. >&2 -exit /B 1 -:found_vs - -rem Map Visual Studio version to cmake generator name. -if "%visual_studio_version%"=="8" ( - set cmake_generator=Visual Studio 8 2005 -) -if "%visual_studio_version%"=="9" ( - set cmake_generator=Visual Studio 9 2008 -) -if %visual_studio_version% GEQ 10 ( - set cmake_generator=Visual Studio %visual_studio_version% -) -rem Set visual studio version variable for msbuild. -set VisualStudioVersion=%visual_studio_version%.0 - -rem Generate Visual Studio solution. -echo Generating solution for %cmake_generator%. >&2 -cd "%cmake_project_path%" -%cmake% -G"%cmake_generator%" -if %ERRORLEVEL% NEQ 0 ( - exit /B %ERRORLEVEL% -) - -rem Build flatc -python %thispath%\msbuild.py flatc.vcxproj -if ERRORLEVEL 1 exit /B 1
diff --git a/third_party/flatbuffers/android/jni/include.mk b/third_party/flatbuffers/android/jni/include.mk deleted file mode 100644 index b53e257..0000000 --- a/third_party/flatbuffers/android/jni/include.mk +++ /dev/null
@@ -1,237 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This file contains utility functions for Android projects using Flatbuffers. -# To use this file, include it in your project's Android.mk by calling near the -# top of your android makefile like so: -# -# include $(FLATBUFFERS_DIR)/android/jni/include.mk -# -# You will also need to import the flatbuffers module using the standard -# import-module function. -# -# The main functionality this file provides are the following functions: -# flatbuffers_fbs_to_h: Converts flatbuffer schema paths to header paths. -# flatbuffers_header_build_rule: -# Creates a build rule for a schema's generated header. This build rule -# has a dependency on the flatc compiler which will be built if necessary. -# flatbuffers_header_build_rules: -# Creates build rules for generated headers for each schema listed and sets -# up depenedendies. -# -# More information and example usage can be found in the comments preceeding -# each function. - -# Targets to build the Flatbuffers compiler as well as some utility definitions -ifeq (,$(FLATBUFFERS_INCLUDE_MK_)) -FLATBUFFERS_INCLUDE_MK_ := 1 - -# Portable version of $(realpath) that omits drive letters on Windows. -realpath-portable = $(join $(filter %:,$(subst :,: ,$1)),\ - $(realpath $(filter-out %:,$(subst :,: ,$1)))) - -PROJECT_OS := $(OS) -ifeq (,$(OS)) -PROJECT_OS := $(shell uname -s) -else -ifneq ($(findstring Windows,$(PROJECT_OS)),) -PROJECT_OS := Windows -endif -endif - -# The following block generates build rules which result in headers being -# rebuilt from flatbuffers schemas. - -FLATBUFFERS_CMAKELISTS_DIR := \ - $(call realpath-portable,$(dir $(lastword $(MAKEFILE_LIST)))/../..) - -# Directory that contains the FlatBuffers compiler. -ifeq (Windows,$(PROJECT_OS)) -FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR) -FLATBUFFERS_FLATC := $(lastword \ - $(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc.exe) \ - $(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc.exe)) -endif -ifeq (Linux,$(PROJECT_OS)) -FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR) -FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/flatc -endif -ifeq (Darwin,$(PROJECT_OS)) -FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR) -FLATBUFFERS_FLATC := $(lastword \ - $(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc) \ - $(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc)) -endif - -FLATBUFFERS_FLATC_ARGS?= - -# Search for cmake. -CMAKE_ROOT := \ - $(call realpath-portable,$(LOCAL_PATH)/../../../../../../prebuilts/cmake) -ifeq (,$(CMAKE)) -ifeq (Linux,$(PROJECT_OS)) -CMAKE := $(wildcard $(CMAKE_ROOT)/linux-x86/current/bin/cmake*) -endif -ifeq (Darwin,$(PROJECT_OS)) -CMAKE := \ - $(wildcard $(CMAKE_ROOT)/darwin-x86_64/current/*.app/Contents/bin/cmake) -endif -ifeq (Windows,$(PROJECT_OS)) -CMAKE := $(wildcard $(CMAKE_ROOT)/windows/current/bin/cmake*) -endif -endif -ifeq (,$(CMAKE)) -CMAKE := cmake -endif - -# Windows friendly portable local path. -# GNU-make doesn't like : in paths, must use relative paths on Windows. -ifeq (Windows,$(PROJECT_OS)) -PORTABLE_LOCAL_PATH = -else -PORTABLE_LOCAL_PATH = $(LOCAL_PATH)/ -endif - -# Generate a host build rule for the flatbuffers compiler. -ifeq (Windows,$(PROJECT_OS)) -define build_flatc_recipe - $(FLATBUFFERS_CMAKELISTS_DIR)\android\jni\build_flatc.bat \ - $(CMAKE) $(FLATBUFFERS_CMAKELISTS_DIR) -endef -endif -ifeq (Linux,$(PROJECT_OS)) -define build_flatc_recipe - +cd $(FLATBUFFERS_CMAKELISTS_DIR) && \ - $(CMAKE) . && \ - $(MAKE) flatc -endef -endif -ifeq (Darwin,$(PROJECT_OS)) -define build_flatc_recipe - cd $(FLATBUFFERS_CMAKELISTS_DIR) && "$(CMAKE)" -GXcode . && \ - xcodebuild -target flatc -endef -endif -ifeq (,$(build_flatc_recipe)) -ifeq (,$(FLATBUFFERS_FLATC)) -$(error flatc binary not found!) -endif -endif - -# Generate a build rule for flatc. -ifeq ($(strip $(FLATBUFFERS_FLATC)),) -flatc_target := build_flatc -.PHONY: $(flatc_target) -FLATBUFFERS_FLATC := \ - python $(FLATBUFFERS_CMAKELISTS_DIR)/android/jni/run_flatc.py \ - $(FLATBUFFERS_CMAKELISTS_DIR) -else -flatc_target := $(FLATBUFFERS_FLATC) -endif -$(flatc_target): - $(call build_flatc_recipe) - -# $(flatbuffers_fbs_to_h schema_dir,output_dir,path) -# -# Convert the specified schema path to a Flatbuffers generated header path. -# For example: -# -# $(call flatbuffers_fbs_to_h,$(MY_PROJ_DIR)/schemas,\ -# $(MY_PROJ_DIR)/gen/include,$(MY_PROJ_DIR)/schemas/example.fbs) -# -# This will convert the file path `$(MY_PROJ_DIR)/schemas/example.fbs)` to -# `$(MY_PROJ_DIR)/gen/include/example_generated.h` -define flatbuffers_fbs_to_h -$(subst $(1),$(2),$(patsubst %.fbs,%_generated.h,$(3))) -endef - -# $(flatbuffers_header_build_rule schema_file,schema_dir,output_dir,\ -# schema_include_dirs) -# -# Generate a build rule that will convert a Flatbuffers schema to a generated -# header derived from the schema filename using flatbuffers_fbs_to_h. For -# example: -# -# $(call flatbuffers_header_build_rule,$(MY_PROJ_DIR)/schemas/example.fbs,\ -# $(MY_PROJ_DIR)/schemas,$(MY_PROJ_DIR)/gen/include) -# -# The final argument, schema_include_dirs, is optional and is only needed when -# the schema files depend on other schema files outside their own directory. -define flatbuffers_header_build_rule -$(eval \ - $(call flatbuffers_fbs_to_h,$(2),$(3),$(1)): $(1) $(flatc_target) - $(call host-echo-build-step,generic,Generate) \ - $(subst $(LOCAL_PATH)/,,$(call flatbuffers_fbs_to_h,$(2),$(3),$(1))) - $(hide) $$(FLATBUFFERS_FLATC) $(FLATBUFFERS_FLATC_ARGS) \ - $(foreach include,$(4),-I $(include)) -o $$(dir $$@) -c $$<) -endef - -# TODO: Remove when the LOCAL_PATH expansion bug in the NDK is fixed. -# Override the default behavior of local-source-file-path to workaround -# a bug which prevents the build of deeply nested projects when NDK_OUT is -# set. -local-source-file-path=\ -$(if $(call host-path-is-absolute,$1),$1,$(call \ - realpath-portable,$(LOCAL_PATH)/$1)) - - -# $(flatbuffers_header_build_rules schema_files,schema_dir,output_dir,\ -# schema_include_dirs,src_files,[build_target],[dependencies])) -# -# $(1) schema_files: Space separated list of flatbuffer schema files. -# $(2) schema_dir: Directory containing the flatbuffer schemas. -# $(3) output_dir: Where to place the generated files. -# $(4) schema_include_dirs: Directories to include when generating schemas. -# $(5) src_files: Files that should depend upon the headers generated from the -# flatbuffer schemas. -# $(6) build_target: Name of a build target that depends upon all generated -# headers. -# $(7) dependencies: Space seperated list of additional build targets src_files -# should depend upon. -# -# Use this in your own Android.mk file to generate build rules that will -# generate header files for your flatbuffer schemas as well as automatically -# set your source files to be dependent on the generated headers. For example: -# -# $(call flatbuffers_header_build_rules,$(MY_PROJ_SCHEMA_FILES),\ -# $(MY_PROJ_SCHEMA_DIR),$(MY_PROJ_GENERATED_OUTPUT_DIR), -# $(MY_PROJ_SCHEMA_INCLUDE_DIRS),$(LOCAL_SRC_FILES)) -# -# NOTE: Due problesm with path processing in ndk-build when presented with -# deeply nested projects must redefine LOCAL_PATH after include this makefile -# using: -# -# LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH)) -# -define flatbuffers_header_build_rules -$(foreach schema,$(1),\ - $(call flatbuffers_header_build_rule,\ - $(schema),$(strip $(2)),$(strip $(3)),$(strip $(4))))\ -$(foreach src,$(strip $(5)),\ - $(eval $(call local-source-file-path,$(src)): \ - $(foreach schema,$(strip $(1)),\ - $(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))))\ -$(if $(6),\ - $(foreach schema,$(strip $(1)),\ - $(eval $(6): \ - $(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))),)\ -$(if $(7),\ - $(foreach src,$(strip $(5)),\ - $(eval $(call local-source-file-path,$(src)): $(strip $(7)))),)\ -$(if $(7),\ - $(foreach dependency,$(strip $(7)),\ - $(eval $(6): $(dependency))),) -endef - -endif # FLATBUFFERS_INCLUDE_MK_
diff --git a/third_party/flatbuffers/android/jni/main.cpp b/third_party/flatbuffers/android/jni/main.cpp deleted file mode 100644 index 0d64349..0000000 --- a/third_party/flatbuffers/android/jni/main.cpp +++ /dev/null
@@ -1,26 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <android_native_app_glue.h> - -extern int main(int argc, char **argv); - -void android_main(android_app *app) { - // Make sure glue isn't stripped. - app_dummy(); - - main(0, NULL); -}
diff --git a/third_party/flatbuffers/android/jni/msbuild.py b/third_party/flatbuffers/android/jni/msbuild.py deleted file mode 100644 index 5f92d70..0000000 --- a/third_party/flatbuffers/android/jni/msbuild.py +++ /dev/null
@@ -1,77 +0,0 @@ -#!/usr/bin/python -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Simple script that locates the newest MSBuild in one of several locations. - -This script will find the highest version number of MSBuild and run it, -passing its arguments through to MSBuild. -""" - -import glob -import os -import re -import string -import subprocess -import sys - -SYSTEMROOT = os.getenv("SYSTEMROOT", "c:\\windows") -PROGRAM_FILES = os.getenv("ProgramFiles", "c:\\Program Files") -PROGRAM_FILES_X86 = os.getenv("ProgramFiles(x86)", "c:\\Program Files (x86)") - -SEARCH_FOLDERS = [ PROGRAM_FILES + "\\MSBuild\\*\\Bin\\MSBuild.exe", - PROGRAM_FILES_X86 + "\\MSBuild\\*\\Bin\\MSBuild.exe", - SYSTEMROOT + "\\Microsoft.NET\Framework\\*\\MSBuild.exe" ] - -def compare_version(a, b): - """Compare two version number strings of the form W.X.Y.Z. - - The numbers are compared most-significant to least-significant. - For example, 12.345.67.89 > 2.987.88.99. - - Args: - a: First version number string to compare - b: Second version number string to compare - - Returns: - 0 if the numbers are identical, a positive number if 'a' is larger, and - a negative number if 'b' is larger. - """ - aa = string.split(a, ".") - bb = string.split(b, ".") - for i in range(0, 4): - if aa[i] != bb[i]: - return cmp(int(aa[i]), int(bb[i])) - return 0 - -def main(): - msbuilds = [] - - for folder in SEARCH_FOLDERS: - for file in glob.glob(folder): - p = subprocess.Popen([file, "/version"], stdout=subprocess.PIPE) - out, err = p.communicate() - match = re.search("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", out, re.M) - if match: - msbuilds.append({ 'ver':match.group(), 'exe':file }) - msbuilds.sort(lambda x, y: compare_version(x['ver'], y['ver']), reverse=True) - if len(msbuilds) == 0: - print "Unable to find MSBuild.\n" - return -1; - cmd = [msbuilds[0]['exe']] - cmd.extend(sys.argv[1:]) - return subprocess.call(cmd) - -if __name__ == '__main__': - sys.exit(main())
diff --git a/third_party/flatbuffers/android/jni/run_flatc.py b/third_party/flatbuffers/android/jni/run_flatc.py deleted file mode 100755 index cda13bb..0000000 --- a/third_party/flatbuffers/android/jni/run_flatc.py +++ /dev/null
@@ -1,46 +0,0 @@ -#!/usr/bin/python -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import platform -import subprocess -import sys - -EXECUTABLE_EXTENSION = '.exe' if platform.system() == 'Windows' else '' -# Paths to search for flatc relative to the current working directory. -FLATC_SEARCH_PATHS = [os.path.curdir, 'Release', 'Debug'] - -def main(): - """Script that finds and runs flatc built from source.""" - if len(sys.argv) < 2: - sys.stderr.write('Usage: run_flatc.py flatbuffers_dir [flatc_args]\n') - return 1 - cwd = os.getcwd() - flatc = '' - flatbuffers_dir = sys.argv[1] - for path in FLATC_SEARCH_PATHS: - current = os.path.join(flatbuffers_dir, path, - 'flatc' + EXECUTABLE_EXTENSION) - if os.path.exists(current): - flatc = current - break - if not flatc: - sys.stderr.write('flatc not found\n') - return 1 - command = [flatc] + sys.argv[2:] - return subprocess.call(command) - -if __name__ == '__main__': - sys.exit(main())
diff --git a/third_party/flatbuffers/android/res/values/strings.xml b/third_party/flatbuffers/android/res/values/strings.xml deleted file mode 100755 index ec75239..0000000 --- a/third_party/flatbuffers/android/res/values/strings.xml +++ /dev/null
@@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (c) 2014 Google, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - --> -<resources> - <string name="app_name">FlatBufferTest</string> -</resources>
diff --git a/third_party/flatbuffers/appveyor.yml b/third_party/flatbuffers/appveyor.yml deleted file mode 100644 index f350f06..0000000 --- a/third_party/flatbuffers/appveyor.yml +++ /dev/null
@@ -1,46 +0,0 @@ -branches: - only: - - master - -os: Visual Studio 2015 - -platform: - - x86 - - x64 - -configuration: - - Debug - - Release - -before_build: - - cmake -G"Visual Studio 10 2010" - # This cuts down on a lot of noise generated by xamarin warnings. - - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets" - -build: - project: ALL_BUILD.vcxproj - verbosity: minimal - -test_script: - - rem "---------------- C++ -----------------" - - "%CONFIGURATION%\\flattests.exe" - - rem "---------------- Java -----------------" - - "cd tests" - - "java -version" - - "JavaTest.bat" - - rem "---------------- JS -----------------" - - "node --version" - - "..\\%CONFIGURATION%\\flatc -b monster_test.fbs unicode_test.json" - - "node JavaScriptTest ./monster_test_generated" - - rem "---------------- C# -----------------" - # Have to compile this here rather than in "build" above because AppVeyor only - # supports building one project?? - - "cd FlatBuffers.Test" - - "msbuild.exe /property:Configuration=Release;OutputPath=tempcs /verbosity:minimal FlatBuffers.Test.csproj" - - "tempcs\\FlatBuffers.Test.exe" - # TODO: add more languages. - - "cd ..\\.." - -artifacts: - - path: $(CONFIGURATION)\\flatc.exe - name: flatc.exe
diff --git a/third_party/flatbuffers/biicode.conf b/third_party/flatbuffers/biicode.conf deleted file mode 100644 index b205168..0000000 --- a/third_party/flatbuffers/biicode.conf +++ /dev/null
@@ -1,7 +0,0 @@ -# Biicode configuration file -[paths] - include -[mains] - !android/* -[tests] - tests/*
diff --git a/third_party/flatbuffers/biicode/README.md b/third_party/flatbuffers/biicode/README.md deleted file mode 100644 index 8b0a185..0000000 --- a/third_party/flatbuffers/biicode/README.md +++ /dev/null
@@ -1,21 +0,0 @@ -Biicode C/C++ dependency manager -================================= - -[](https://www.biicode.com/fenix/flatbuffers) - -New with biicode? Check the [Getting Started Guide](http://docs.biicode.com/c++/gettingstarted.html). - -How to build it? ------------------- -Building it is too easy: - - $ git clone git@github.com:google/flatbuffers.git - $ cd flatbuffers - $ bii init -L && bii build - $ ./bin/any_executable - -Or run its tests: - - $ bii test - -You can check [the examples/flatbuffers block](https://www.biicode.com/examples/flatbuffers). \ No newline at end of file
diff --git a/third_party/flatbuffers/biicode/cmake/biicode.cmake b/third_party/flatbuffers/biicode/cmake/biicode.cmake deleted file mode 100644 index 85b15ed..0000000 --- a/third_party/flatbuffers/biicode/cmake/biicode.cmake +++ /dev/null
@@ -1,18 +0,0 @@ -set(BII_TESTS_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -# Copying data files to project/bin folder -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/samples") - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/monster.fbs" - "${CMAKE_CURRENT_SOURCE_DIR}/samples/monsterdata.json" - DESTINATION - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/samples") -endif() -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests") - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" - DESTINATION - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") -endif() - -ADD_BIICODE_TARGETS() - -string(REPLACE " " ";" REPLACED_FLAGS ${CMAKE_CXX_FLAGS}) -target_compile_options(${BII_BLOCK_TARGET} INTERFACE ${REPLACED_FLAGS}) \ No newline at end of file
diff --git a/third_party/flatbuffers/biicode/support/bii-travis.sh b/third_party/flatbuffers/biicode/support/bii-travis.sh deleted file mode 100755 index 67854c7..0000000 --- a/third_party/flatbuffers/biicode/support/bii-travis.sh +++ /dev/null
@@ -1,30 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -sudo apt-get update -qq -sudo apt-get install libglu1-mesa-dev xorg-dev -wget http://www.biicode.com/downloads/latest/ubuntu64 -mv ubuntu64 bii-ubuntu64.deb -(sudo dpkg -i bii-ubuntu64.deb) && sudo apt-get -f install -rm bii-ubuntu64.deb -wget https://s3.amazonaws.com/biibinaries/thirdparty/cmake-3.0.2-Linux-64.tar.gz -tar -xzf cmake-3.0.2-Linux-64.tar.gz -sudo cp -fR cmake-3.0.2-Linux-64/* /usr -rm -rf cmake-3.0.2-Linux-64 -rm cmake-3.0.2-Linux-64.tar.gz - -cmake --version -bii init -l && bii configure -DCMAKE_BUILD_TYPE=$1 && bii test \ No newline at end of file
diff --git a/third_party/flatbuffers/cmake_install.cmake b/third_party/flatbuffers/cmake_install.cmake deleted file mode 100644 index 6feae12..0000000 --- a/third_party/flatbuffers/cmake_install.cmake +++ /dev/null
@@ -1,68 +0,0 @@ -# Install script for directory: /home/alain/flatbuffers - -# Set the install prefix -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "/usr/local") -endif() -string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - if(BUILD_TYPE) - string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - else() - set(CMAKE_INSTALL_CONFIG_NAME "") - endif() - message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -endif() - -# Set the component getting installed. -if(NOT CMAKE_INSTALL_COMPONENT) - if(COMPONENT) - message(STATUS "Install component: \"${COMPONENT}\"") - set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - else() - set(CMAKE_INSTALL_COMPONENT) - endif() -endif() - -# Install shared libraries without execute permission? -if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - set(CMAKE_INSTALL_SO_NO_EXE "1") -endif() - -if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") - file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include" TYPE DIRECTORY FILES "/home/alain/flatbuffers/include/flatbuffers") -endif() - -if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") - file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/home/alain/flatbuffers/libflatbuffers.a") -endif() - -if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified") - if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc" AND - NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc") - file(RPATH_CHECK - FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc" - RPATH "") - endif() - file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "/home/alain/flatbuffers/flatc") - if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc" AND - NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc") - if(CMAKE_INSTALL_DO_STRIP) - execute_process(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/flatc") - endif() - endif() -endif() - -if(CMAKE_INSTALL_COMPONENT) - set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") -else() - set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") -endif() - -string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT - "${CMAKE_INSTALL_MANIFEST_FILES}") -file(WRITE "/home/alain/flatbuffers/${CMAKE_INSTALL_MANIFEST}" - "${CMAKE_INSTALL_MANIFEST_CONTENT}")
diff --git a/third_party/flatbuffers/composer.json b/third_party/flatbuffers/composer.json deleted file mode 100644 index 807709c..0000000 --- a/third_party/flatbuffers/composer.json +++ /dev/null
@@ -1,18 +0,0 @@ -{ - "name": "google/flatbuffers", - "type": "library", - "description": "FlatBuffers for PHP", - "keywords": ["google", "flatbuffers", "serialization"], - "homepage": "https://github.com/google/flatbuffers", - "license": "Apache-2.0", - "require": { - "php": ">=5.4" - }, - "require-dev": { - }, - "autoload": { - "psr-4": { - "Google\\FlatBuffers\\": "php" - } - } -} \ No newline at end of file
diff --git a/third_party/flatbuffers/docs/footer.html b/third_party/flatbuffers/docs/footer.html deleted file mode 100755 index 42bc5f2..0000000 --- a/third_party/flatbuffers/docs/footer.html +++ /dev/null
@@ -1,14 +0,0 @@ -<!-- Google Analytics --> -<script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-49880327-7', 'auto'); - ga('send', 'pageview'); - -</script> - -</body> -</html>
diff --git a/third_party/flatbuffers/docs/header.html b/third_party/flatbuffers/docs/header.html deleted file mode 100644 index 0266e7c..0000000 --- a/third_party/flatbuffers/docs/header.html +++ /dev/null
@@ -1,62 +0,0 @@ -<!-- HTML header for doxygen 1.8.6--> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> -<meta http-equiv="X-UA-Compatible" content="IE=9"/> -<meta name="generator" content="Doxygen $doxygenversion"/> -<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME--> -<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME--> -<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/> -<script type="text/javascript" src="$relpath^jquery.js"></script> -<script type="text/javascript" src="$relpath^dynsections.js"></script> -$treeview -$search -$mathjax -<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" /> -<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,700" rel="stylesheet"> -$extrastylesheet -</head> -<body> -<div id="top"><!-- do not remove this div, it is closed by doxygen! --> - -<!--BEGIN TITLEAREA--> -<div id="titlearea" style="height: 110px;"> -<table cellspacing="0" cellpadding="0"> - <tbody> - <tr style="height: 56px;"> - <!--BEGIN PROJECT_LOGO--> - <td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td> - <!--END PROJECT_LOGO--> - <td id="commonprojectlogo"> - <img alt="Logo" src="$relpath^fpl_logo_small.png"/> - </td> - <!--BEGIN PROJECT_NAME--> - <td style="padding-left: 0.5em;"> - <div id="projectname">$projectname - <!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER--> - </div> - <div style="font-size:12px;"> - An open source project by <a href="https://developers.google.com/games/#Tools">FPL</a>. - </div> - <!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF--> - </td> - <!--END PROJECT_NAME--> - <!--BEGIN !PROJECT_NAME--> - <!--BEGIN PROJECT_BRIEF--> - <td style="padding-left: 0.5em;"> - <div id="projectbrief">$projectbrief</div> - </td> - <!--END PROJECT_BRIEF--> - <!--END !PROJECT_NAME--> - <!--BEGIN DISABLE_INDEX--> - <!--BEGIN SEARCHENGINE--> - <td>$searchbox</td> - <!--END SEARCHENGINE--> - <!--END DISABLE_INDEX--> - </tr> - </tbody> -</table> -</div> -<!--END TITLEAREA--> -<!-- end header part -->
diff --git a/third_party/flatbuffers/docs/images/fpl_logo_small.png b/third_party/flatbuffers/docs/images/fpl_logo_small.png deleted file mode 100644 index 2c728f3..0000000 --- a/third_party/flatbuffers/docs/images/fpl_logo_small.png +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/docs/images/ftv2mnode.png b/third_party/flatbuffers/docs/images/ftv2mnode.png deleted file mode 100644 index 3caf47d..0000000 --- a/third_party/flatbuffers/docs/images/ftv2mnode.png +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/docs/images/ftv2pnode.png b/third_party/flatbuffers/docs/images/ftv2pnode.png deleted file mode 100644 index f1aaad3..0000000 --- a/third_party/flatbuffers/docs/images/ftv2pnode.png +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/docs/source/Benchmarks.md b/third_party/flatbuffers/docs/source/Benchmarks.md deleted file mode 100755 index e5e5847..0000000 --- a/third_party/flatbuffers/docs/source/Benchmarks.md +++ /dev/null
@@ -1,63 +0,0 @@ -Benchmarks {#flatbuffers_benchmarks} -========== - -Comparing against other serialization solutions, running on Windows 7 -64bit. We use the LITE runtime for Protocol Buffers (less code / lower -overhead), Rapid JSON (one of the fastest C++ JSON parsers around), -and pugixml, also one of the fastest XML parsers. - -We also compare against code that doesn't use a serialization library -at all (the column "Raw structs"), which is what you get if you write -hardcoded code that just writes structs. This is the fastest possible, -but of course is not cross platform nor has any kind of forwards / -backwards compatibility. - -We compare against Flatbuffers with the binary wire format (as -intended), and also with JSON as the wire format with the optional JSON -parser (which, using a schema, parses JSON into a binary buffer that can -then be accessed as before). - -The benchmark object is a set of about 10 objects containing an array, 4 -strings, and a large variety of int/float scalar values of all sizes, -meant to be representative of game data, e.g. a scene format. - -| | FlatBuffers (binary) | Protocol Buffers LITE | Rapid JSON | FlatBuffers (JSON) | pugixml | Raw structs | -|--------------------------------------------------------|-----------------------|-----------------------|-----------------------|------------------------| ----------------------| ----------------------| -| Decode + Traverse + Dealloc (1 million times, seconds) | 0.08 | 302 | 583 | 105 | 196 | 0.02 | -| Decode / Traverse / Dealloc (breakdown) | 0 / 0.08 / 0 | 220 / 0.15 / 81 | 294 / 0.9 / 287 | 70 / 0.08 / 35 | 41 / 3.9 / 150 | 0 / 0.02 / 0 | -| Encode (1 million times, seconds) | 3.2 | 185 | 650 | 169 | 273 | 0.15 | -| Wire format size (normal / zlib, bytes) | 344 / 220 | 228 / 174 | 1475 / 322 | 1029 / 298 | 1137 / 341 | 312 / 187 | -| Memory needed to store decoded wire (bytes / blocks) | 0 / 0 | 760 / 20 | 65689 / 4 | 328 / 1 | 34194 / 3 | 0 / 0 | -| Transient memory allocated during decode (KB) | 0 | 1 | 131 | 4 | 34 | 0 | -| Generated source code size (KB) | 4 | 61 | 0 | 4 | 0 | 0 | -| Field access in handwritten traversal code | typed accessors | typed accessors | manual error checking | typed accessors | manual error checking | typed but no safety | -| Library source code (KB) | 15 | some subset of 3800 | 87 | 43 | 327 | 0 | - -### Some other serialization systems we compared against but did not benchmark (yet), in rough order of applicability: - -- Cap'n'Proto promises to reduce Protocol Buffers much like FlatBuffers does, - though with a more complicated binary encoding and less flexibility (no - optional fields to allow deprecating fields or serializing with missing - fields for which defaults exist). - It currently also isn't fully cross-platform portable (lack of VS support). -- msgpack: has very minimal forwards/backwards compatibility support when used - with the typed C++ interface. Also lacks VS2010 support. -- Thrift: very similar to Protocol Buffers, but appears to be less efficient, - and have more dependencies. -- YAML: a superset of JSON and otherwise very similar. Used by e.g. Unity. -- C# comes with built-in serialization functionality, as used by Unity also. - Being tied to the language, and having no automatic versioning support - limits its applicability. -- Project Anarchy (the free mobile engine by Havok) comes with a serialization - system, that however does no automatic versioning (have to code around new - fields manually), is very much tied to the rest of the engine, and works - without a schema to generate code (tied to your C++ class definition). - -### Code for benchmarks - -Code for these benchmarks sits in `benchmarks/` in git branch `benchmarks`. -It sits in its own branch because it has submodule dependencies that the main -project doesn't need, and the code standards do not meet those of the main -project. Please read `benchmarks/cpp/README.txt` before working with the code. - -<br>
diff --git a/third_party/flatbuffers/docs/source/Building.md b/third_party/flatbuffers/docs/source/Building.md deleted file mode 100755 index daeeb1e..0000000 --- a/third_party/flatbuffers/docs/source/Building.md +++ /dev/null
@@ -1,67 +0,0 @@ -Building {#flatbuffers_guide_building} -======== - -## Building with CMake - -The distribution comes with a `cmake` file that should allow -you to build project/make files for any platform. For details on `cmake`, see -<http://www.cmake.org>. In brief, depending on your platform, use one of -e.g.: - - cmake -G "Unix Makefiles" - cmake -G "Visual Studio 10" - cmake -G "Xcode" - -Then, build as normal for your platform. This should result in a `flatc` -executable, essential for the next steps. -Note that to use clang instead of gcc, you may need to set up your environment -variables, e.g. -`CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -G "Unix Makefiles"`. - -Optionally, run the `flattests` executable from the root `flatbuffers/` -directory to ensure everything is working correctly on your system. If this -fails, please contact us! - -Building should also produce two sample executables, `flatsamplebinary` and -`flatsampletext`, see the corresponding `.cpp` files in the -`flatbuffers/samples` directory. - -*Note that you MUST be in the root of the FlatBuffers distribution when you -run 'flattests' or `flatsampletext`, or it will fail to load its files.* - -## Building for Android - -There is a `flatbuffers/android` directory that contains all you need to build -the test executable on android (use the included `build_apk.sh` script, or use -`ndk_build` / `adb` etc. as usual). Upon running, it will output to the log -if tests succeeded or not. - -You may also run an android sample from inside the `flatbuffers/samples`, by -running the `android_sample.sh` script. Optionally, you may go to the -`flatbuffers/samples/android` folder and build the sample with the -`build_apk.sh` script or `ndk_build` / `adb` etc. - -## Using FlatBuffers in your own projects. - -For C++, there is usually no runtime to compile, as the code consists of a -single header, `include/flatbuffers/flatbuffers.h`. You should add the -`include` folder to your include paths. If you wish to be -able to load schemas and/or parse text into binary buffers at runtime, -you additionally need the other headers in `include/flatbuffers`. You must -also compile/link `src/idl_parser.cpp` (and `src/idl_gen_text.cpp` if you -also want to be able convert binary to text). - -To see how to include FlatBuffers in any of our supported languages, please -view the [Tutorial](@ref flatbuffers_guide_tutorial) and select your appropriate -language using the radio buttons. - -#### For Google Play apps - -For applications on Google Play that integrate this library, usage is tracked. -This tracking is done automatically using the embedded version string -(flatbuffer_version_string), and helps us continue to optimize it. -Aside from consuming a few extra bytes in your application binary, it shouldn't -affect your application at all. We use this information to let us know if -FlatBuffers is useful and if we should continue to invest in it. Since this is -open source, you are free to remove the version string but we would appreciate -if you would leave it in.
diff --git a/third_party/flatbuffers/docs/source/CONTRIBUTING.md b/third_party/flatbuffers/docs/source/CONTRIBUTING.md deleted file mode 120000 index f939e75..0000000 --- a/third_party/flatbuffers/docs/source/CONTRIBUTING.md +++ /dev/null
@@ -1 +0,0 @@ -../../CONTRIBUTING.md \ No newline at end of file
diff --git a/third_party/flatbuffers/docs/source/CUsage.md b/third_party/flatbuffers/docs/source/CUsage.md deleted file mode 100644 index 9aafa6f..0000000 --- a/third_party/flatbuffers/docs/source/CUsage.md +++ /dev/null
@@ -1,224 +0,0 @@ -Use in C {#flatbuffers_guide_use_c} -========== - -The C language binding exists in a separate project named [FlatCC](https://github.com/dvidelabs/flatcc). - -The `flatcc` C schema compiler can generate code offline as well as -online via a C library. It can also generate buffer verifiers and fast -JSON parsers, printers. - -Great care has been taken to ensure compatibily with the main `flatc` -project. - -## General Documention - -- [Tutorial](@ref flatbuffers_guide_tutorial) - select C as language - when scrolling down -- [FlatCC Guide](https://github.com/dvidelabs/flatcc#flatcc-flatbuffers-in-c-for-c) -- [The C Builder Interface](https://github.com/dvidelabs/flatcc/blob/master/doc/builder.md#the-builder-interface) -- [The Monster Sample in C](https://github.com/dvidelabs/flatcc/blob/master/samples/monster/monster.c) -- [GitHub](https://github.com/dvidelabs/flatcc) - - -## Supported Platforms - -- Ubuntu (clang / gcc, ninja / gnu make) -- OS-X (clang / gcc, ninja / gnu make) -- Windows MSVC 2010, 2013, 2015 - -CI builds recent versions of gcc, clang and MSVC on OS-X, Ubuntu, and -Windows, and occasionally older compiler versions. See main project [Status](https://github.com/dvidelabs/flatcc#status). - -Other platforms may well work, including Centos, but are not tested -regularly. - -The monster sample project was specifically written for C99 in order to -follow the C++ version and for that reason it will not work with MSVC -2010. - -## Modular Object Creation - -In the tutorial we used the call `Monster_create_as_root` to create the -root buffer object since this is easier in simple use cases. Sometimes -we need more modularity so we can reuse a function to create nested -tables and root tables the same way. For this we need the -`flatcc_builder_buffer_create_call`. It is best to keep `flatcc_builder` -calls isolated at the top driver level, so we get: - -<div class="language-c"> -~~~{.c} - ns(Monster_ref_t) create_orc(flatcc_builder_t *B) - { - // ... same as in the tutorial. - return s(Monster_create(B, ...)); - } - - void create_monster_buffer() - { - uint8_t *buf; - size_t size; - flatcc_builder_t builder, *B; - - // Initialize the builder object. - B = &builder; - flatcc_builder_init(B); - // Only use `buffer_create` without `create/start/end_as_root`. - flatcc_builder_buffer_create(create_orc(B)); - // Allocate and copy buffer to user memory. - buf = flatcc_builder_finalize_buffer(B, &size); - // ... write the buffer to disk or network, or something. - - free(buf); - flatcc_builder_clear(B); - } -~~~ -</div> - -The same principle applies with `start/end` vs `start/end_as_root` in -the top-down approach. - - -## Top Down Example - -The tutorial uses a bottom up approach. In C it is also possible to use -a top-down approach by starting and ending objects nested within each -other. In the tutorial there is no deep nesting, so the difference is -limited, but it shows the idea: - -<div class="language-c"> -<br> -~~~{.c} - uint8_t treasure[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - size_t treasure_count = c_vec_len(treasure); - ns(Weapon_ref_t) axe; - - // NOTE: if we use end_as_root, we MUST also start as root. - ns(Monster_start_as_root(B)); - ns(Monster_pos_create(B, 1.0f, 2.0f, 3.0f)); - ns(Monster_hp_add(B, 300)); - ns(Monster_mana_add(B, 150)); - // We use create_str instead of add because we have no existing string reference. - ns(Monster_name_create_str(B, "Orc")); - // Again we use create because we no existing vector object, only a C-array. - ns(Monster_inventory_create(B, treasure, treasure_count)); - ns(Monster_color_add(B, ns(Color_Red))); - if (1) { - ns(Monster_weapons_start(B)); - ns(Monster_weapons_push_create(B, flatbuffers_string_create_str(B, "Sword"), 3)); - // We reuse the axe object later. Note that we dereference a pointer - // because push always returns a short-term pointer to the stored element. - // We could also have created the axe object first and simply pushed it. - axe = *ns(Monster_weapons_push_create(B, flatbuffers_string_create_str(B, "Axe"), 5)); - ns(Monster_weapons_end(B)); - } else { - // We can have more control with the table elements added to a vector: - // - ns(Monster_weapons_start(B)); - ns(Monster_weapons_push_start(B)); - ns(Weapon_name_create_str(B, "Sword")); - ns(Weapon_damage_add(B, 3)); - ns(Monster_weapons_push_end(B)); - ns(Monster_weapons_push_start(B)); - ns(Monster_weapons_push_start(B)); - ns(Weapon_name_create_str(B, "Axe")); - ns(Weapon_damage_add(B, 5)); - axe = *ns(Monster_weapons_push_end(B)); - ns(Monster_weapons_end(B)); - } - // Unions can get their type by using a type-specific add/create/start method. - ns(Monster_equipped_Weapon_add(B, axe)); - - ns(Monster_end_as_root(B)); -~~~ -</div> - - -## Basic Reflection - -The C-API does support reading binary schema (.bfbs) -files via code generated from the `reflection.fbs` schema, and an -[example usage](https://github.com/dvidelabs/flatcc/tree/master/samples/reflection) -shows how to use this. The reflection schema files are pre-generated -in the [runtime distribution](https://github.com/dvidelabs/flatcc/tree/master/include/flatcc/reflection). - - -## Mutations and Reflection - -The C-API does not support mutating reflection like C++ does, nor does -the reader interface support mutating scalars (and it is generally -unsafe to do so even after verification). - -The generated reader interface supports sorting vectors in-place after -casting them to a mutating type because it is not practical to do so -while building a buffer. This is covered in the builder documentation. -The reflection example makes use of this feature to look up objects by -name. - -It is possible to build new buffers using complex objects from existing -buffers as source. This can be very efficient due to direct copy -semantics without endian conversion or temporary stack allocation. - -Scalars, structs and strings can be used as source, as well vectors of -these. - -It is currently not possible to use an existing table or vector of table -as source, but it would be possible to add support for this at some -point. - - -## Namespaces - -The `FLATBUFFERS_WRAP_NAMESPACE` approach used in the tutorial is convenient -when each function has a very long namespace prefix. But it isn't always -the best approach. If the namespace is absent, or simple and -informative, we might as well use the prefix directly. The -[reflection example](https://github.com/dvidelabs/flatcc/blob/master/samples/reflection/bfbs2json.c) -mentioned above uses this approach. - - -## Checking for Present Members - -Not all languages support testing if a field is present, but in C we can -elaborate the reader section of the tutorial with tests for this. Recall -that `mana` was set to the default value `150` and therefore shouldn't -be present. - -<div class="language-c"> -~~~{.c} - int hp_present = ns(Monster_hp_is_present(monster)); // 1 - int mana_present = ns(Monster_mana_is_present(monster)); // 0 -~~~ -</div> - -## Alternative ways to add a Union - -In the tutorial we used a single call to add a union. Here we show -different ways to accomplish the same thing. The last form is rarely -used, but is the low-level way to do it. It can be used to group small -values together in the table by adding type and data at different -points in time. - -<div class="language-c"> -~~~{.c} - ns(Equipment_union_ref_t) equipped = ns(Equipment_as_Weapon(axe)); - ns(Monster_equipped_add(B, equipped)); - // or alternatively - ns(Monster_equipped_Weapon_add(B, axe); - // or alternatively - ns(Monster_equipped_add_type(B, ns(Equipment_Weapon)); - ns(Monster_equipped_add_member(B, axe)); -~~~ -</div> - -## Why not integrate with the `flatc` tool? - -[It was considered how the C code generator could be integrated into the -`flatc` tool](https://github.com/dvidelabs/flatcc/issues/1), but it -would either require that the standalone C implementation of the schema -compiler was dropped, or it would lead to excessive code duplication, or -a complicated intermediate representation would have to be invented. -Neither of these alternatives are very attractive, and it isn't a big -deal to use the `flatcc` tool instead of `flatc` given that the -FlatBuffers C runtime library needs to be made available regardless. - -
diff --git a/third_party/flatbuffers/docs/source/Compiler.md b/third_party/flatbuffers/docs/source/Compiler.md deleted file mode 100755 index 2be5a66..0000000 --- a/third_party/flatbuffers/docs/source/Compiler.md +++ /dev/null
@@ -1,127 +0,0 @@ -Using the schema compiler {#flatbuffers_guide_using_schema_compiler} -========================= - -Usage: - - flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] [ -S ] FILES... - [ -- FILES...] - -The files are read and parsed in order, and can contain either schemas -or data (see below). Data files are processed according to the definitions of -the most recent schema specified. - -`--` indicates that the following files are binary files in -FlatBuffer format conforming to the schema indicated before it. - -Depending on the flags passed, additional files may -be generated for each file processed: - -For any schema input files, one or more generators can be specified: - -- `--cpp`, `-c` : Generate a C++ header for all definitions in this file (as - `filename_generated.h`). - -- `--java`, `-j` : Generate Java code. - -- `--csharp`, `-n` : Generate C# code. - -- `--go`, `-g` : Generate Go code. - -- `--python`, `-p`: Generate Python code. - -- `--js`, `-s`: Generate JavaScript code. - -- `--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 - `filename.bin` containing the binary flatbuffer (or a different extension - if one is specified in the schema). - -- `--json`, `-t` : If data is contained in this file, generate a - `filename.json` representing the data in the flatbuffer. - -Additional options: - -- `-o PATH` : Output all generated files to PATH (either absolute, or - relative to the current directory). If omitted, PATH will be the - current directory. PATH should end in your systems path separator, - e.g. `/` or `\`. - -- `-I PATH` : when encountering `include` statements, attempt to load the - files from this path. Paths will be tried in the order given, and if all - fail (or none are specified) it will try to load relative to the path of - the schema file being parsed. - -- `-M` : Print make rules for generated files. - -- `--strict-json` : Require & generate strict JSON (field names are enclosed - in quotes, no trailing commas in tables/vectors). By default, no quotes are - required/generated, and trailing commas are allowed. - -- `--defaults-json` : Output fields whose value is equal to the default value - when writing JSON text. - -- `--no-prefix` : Don't prefix enum values in generated C++ by their enum - type. - -- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in - generated C++. This also implies `--no-prefix`. - -- `--gen-includes` : (deprecated), this is the default behavior. - If the original behavior is required (no include - statements) use `--no-includes.` - -- `--no-includes` : Don't generate include statements for included schemas the - generated file depends on (C++). - -- `--gen-mutable` : Generate additional non-const accessors for mutating - FlatBuffers in-place. - - `--gen-object-api` : Generate an additional object-based API. This API is - more convenient for object construction and mutation than the base API, - at the cost of efficiency (object allocation). Recommended only to be used - if other options are insufficient. - -- `--gen-onefile` : Generate single output file (useful for C#) - -- `--gen-all`: Generate not just code for the current schema files, but - for all files it includes as well. If the language uses a single file for - output (by default the case for C++ and JS), all code will end up in - this one file. - -- `--no-js-exports` : Removes Node.js style export lines (useful for JS) - -- `--goog-js-export` : Uses goog.exportsSymbol and goog.exportsProperty - instead of Node.js style exporting. Needed for compatibility with the - Google closure compiler (useful for JS). - -- `--raw-binary` : Allow binaries without a file_indentifier to be read. - This may crash flatc given a mismatched schema. - -- `--proto`: Expect input files to be .proto files (protocol buffers). - Output the corresponding .fbs file. - Currently supports: `package`, `message`, `enum`, nested declarations, - `import` (use `-I` for paths), `extend`, `oneof`, `group`. - Does not support, but will skip without error: `option`, `service`, - `extensions`, and most everything else. - -- `--schema`: Serialize schemas instead of JSON (use with -b). This will - output a binary version of the specified schema that itself corresponds - to the reflection/reflection.fbs schema. Loading this binary file is the - basis for reflection functionality. - -- `--bfbs-comments`: Add doc comments to the binary schema files. - -- `--conform FILE` : Specify a schema the following schemas should be - an evolution of. Gives errors if not. Useful to check if schema - modifications don't break schema evolution rules. - -- `--include-prefix PATH` : Prefix this path to any generated include - statements. - -NOTE: short-form options for generators are deprecated, use the long form -whenever possible.
diff --git a/third_party/flatbuffers/docs/source/CppUsage.md b/third_party/flatbuffers/docs/source/CppUsage.md deleted file mode 100755 index cff3071..0000000 --- a/third_party/flatbuffers/docs/source/CppUsage.md +++ /dev/null
@@ -1,432 +0,0 @@ -Use in C++ {#flatbuffers_guide_use_cpp} -========== - -## Before you get started - -Before diving into the FlatBuffers usage in C++, it should be noted that -the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide -to general FlatBuffers usage in all of the supported languages (including C++). -This page is designed to cover the nuances of FlatBuffers usage, specific to -C++. - -#### Prerequisites - -This page assumes you have written a FlatBuffers schema and compiled it -with the Schema Compiler. If you have not, please see -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) -and [Writing a schema](@ref flatbuffers_guide_writing_schema). - -Assuming you wrote a schema, say `mygame.fbs` (though the extension doesn't -matter), you've generated a C++ header called `mygame_generated.h` using the -compiler (e.g. `flatc -c mygame.fbs`), you can now start using this in -your program by including the header. As noted, this header relies on -`flatbuffers/flatbuffers.h`, which should be in your include path. - -## FlatBuffers C++ library code location - -The code for the FlatBuffers C++ library can be found at -`flatbuffers/include/flatbuffers`. You can browse the library code on the -[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/include/flatbuffers). - -## Testing the FlatBuffers C++ library - -The code to test the C++ library can be found at `flatbuffers/tests`. -The test code itself is located in -[test.cpp](https://github.com/google/flatbuffers/blob/master/tests/test.cpp). - -This test file is built alongside `flatc`. To review how to build the project, -please read the [Building](@ref flatbuffers_guide_building) documenation. - -To run the tests, execute `flattests` from the root `flatbuffers/` directory. -For example, on [Linux](https://en.wikipedia.org/wiki/Linux), you would simply -run: `./flattests`. - -## Using the FlatBuffers C++ library - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in C++.* - -FlatBuffers supports both reading and writing FlatBuffers in C++. - -To use FlatBuffers in your code, first generate the C++ classes from your -schema with the `--cpp` option to `flatc`. Then you can include both FlatBuffers -and the generated code to read or write FlatBuffers. - -For example, here is how you would read a FlatBuffer binary file in C++: -First, include the library and generated code. Then read the file into -a `char *` array, which you pass to `GetMonster()`. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - #include "flatbuffers/flatbuffers.h" - #include "monster_test_generate.h" - #include <cstdio> // For printing and file access. - - FILE* file = fopen("monsterdata_test.mon", "rb"); - fseek(file, 0L, SEEK_END); - int length = ftell(file); - fseek(file, 0L, SEEK_SET); - char *data = new char[length]; - fread(data, sizeof(char), length, file); - fclose(file); - - auto monster = GetMonster(data); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -`monster` is of type `Monster *`, and points to somewhere *inside* your -buffer (root object pointers are not the same as `buffer_pointer` !). -If you look in your generated header, you'll see it has -convenient accessors for all fields, e.g. `hp()`, `mana()`, etc: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - printf("%d\n", monster->hp()); // `80` - printf("%d\n", monster->mana()); // default value of `150` - printf("%s\n", monster->name()->c_str()); // "MyMonster" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*Note: That we never stored a `mana` value, so it will return the default.* - -## Object based API. {#flatbuffers_cpp_object_based_api} - -FlatBuffers is all about memory efficiency, which is why its base API is written -around using as little as possible of it. This does make the API clumsier -(requiring pre-order construction of all data, and making mutation harder). - -For times when efficiency is less important a more convenient object based API -can be used (through `--gen-object-api`) that is able to unpack & pack a -FlatBuffer into objects and standard STL containers, allowing for convenient -construction, access and mutation. - -To use: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - // Autogenerated class from table Monster. - MonsterT monsterobj; - - // Deserialize from buffer into object. - UnPackTo(&monsterobj, flatbuffer); - - // Update object directly like a C++ class instance. - cout << monsterobj->name; // This is now a std::string! - monsterobj->name = "Bob"; // Change the name. - - // Serialize into new flatbuffer. - FlatBufferBuilder fbb; - Pack(fbb, &monsterobj); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following attributes are specific to the object-based API code generation: - -- `native_inline` (on a field): Because FlatBuffer tables and structs are - optionally present in a given buffer, they are best represented as pointers - (specifically std::unique_ptrs) in the native class since they can be null. - This attribute changes the member declaration to use the type directly - rather than wrapped in a unique_ptr. - -- `native_default`: "value" (on a field): For members that are declared - "native_inline", the value specified with this attribute will be included - verbatim in the class constructor initializer list for this member. - -- `native_type`' "type" (on a struct): In some cases, a more optimal C++ data - type exists for a given struct. For example, the following schema: - - struct Vec2 { - x: float; - y: float; - } - - generates the following Object-Based API class: - - struct Vec2T : flatbuffers::NativeTable { - float x; - float y; - }; - - However, it can be useful to instead use a user-defined C++ type since it - can provide more functionality, eg. - - struct vector2 { - float x = 0, y = 0; - vector2 operator+(vector2 rhs) const { ... } - vector2 operator-(vector2 rhs) const { ... } - float length() const { ... } - // etc. - }; - - The `native_type` attribute will replace the usage of the generated class - with the given type. So, continuing with the example, the generated - code would use |vector2| in place of |Vec2T| for all generated code. - - However, becuase the native_type is unknown to flatbuffers, the user must - provide the following functions to aide in the serialization process: - - namespace flatbuffers { - FlatbufferStruct Pack(const native_type& obj); - native_type UnPack(const FlatbufferStruct& obj); - } - -Finally, the following top-level attribute - -- native_include: "path" (at file level): Because the `native_type` attribute - can be used to introduce types that are unknown to flatbuffers, it may be - necessary to include "external" header files in the generated code. This - attribute can be used to directly add an #include directive to the top of - the generated code that includes the specified path directly. - -# External references. - -An additional feature of the object API is the ability to allow you to load -multiple independent FlatBuffers, and have them refer to eachothers objects -using hashes which are then represented as typed pointers in the object API. - -To make this work have a field in the objects you want to referred to which is -using the string hashing feature (see `hash` attribute in the -[schema](@ref flatbuffers_guide_writing_schema) documentation). Then you have -a similar hash in the field referring to it, along with a `cpp_type` -attribute specifying the C++ type this will refer to (this can be any C++ -type, and will get a `*` added). - -Then, in JSON or however you create these buffers, make sure they use the -same string (or hash). - -When you call `UnPack` (or `Create`), you'll need a function that maps from -hash to the object (see `resolver_function_t` for details). - -# Using different pointer types. - -By default the object tree is built out of `std::unique_ptr`, but you can -influence this either globally (using the `--cpp-ptr-type` argument to -`flatc`) or per field (using the `cpp_ptr_type` attribute) to by any smart -pointer type (`my_ptr<T>`), or by specifying `naked` as the type to get `T *` -pointers. Unlike the smart pointers, naked pointers do not manage memory for -you, so you'll have to manage their lifecycles manually. - - -# Using different string type. - -By default the object tree is built out of `std::string`, but you can -influence this either globally (using the `--cpp-str-type` argument to -`flatc`) or per field using the `cpp_str_type` attribute. - -The type must support T::c_str() and T::length() as member functions. - -## Reflection (& Resizing) - -There is experimental support for reflection in FlatBuffers, allowing you to -read and write data even if you don't know the exact format of a buffer, and -even allows you to change sizes of strings and vectors in-place. - -The way this works is very elegant; there is actually a FlatBuffer schema that -describes schemas (!) which you can find in `reflection/reflection.fbs`. -The compiler, `flatc`, can write out any schemas it has just parsed as a binary -FlatBuffer, corresponding to this meta-schema. - -Loading in one of these binary schemas at runtime allows you traverse any -FlatBuffer data that corresponds to it without knowing the exact format. You -can query what fields are present, and then read/write them after. - -For convenient field manipulation, you can include the header -`flatbuffers/reflection.h` which includes both the generated code from the meta -schema, as well as a lot of helper functions. - -And example of usage, for the time being, can be found in -`test.cpp/ReflectionTest()`. - -## Storing maps / dictionaries in a FlatBuffer - -FlatBuffers doesn't support maps natively, but there is support to -emulate their behavior with vectors and binary search, which means you -can have fast lookups directly from a FlatBuffer without having to unpack -your data into a `std::map` or similar. - -To use it: -- Designate one of the fields in a table as they "key" field. You do this - by setting the `key` attribute on this field, e.g. - `name:string (key)`. - You may only have one key field, and it must be of string or scalar type. -- Write out tables of this type as usual, collect their offsets in an - array or vector. -- Instead of `CreateVector`, call `CreateVectorOfSortedTables`, - which will first sort all offsets such that the tables they refer to - are sorted by the key field, then serialize it. -- Now when you're accessing the FlatBuffer, you can use `Vector::LookupByKey` - instead of just `Vector::Get` to access elements of the vector, e.g.: - `myvector->LookupByKey("Fred")`, which returns a pointer to the - corresponding table type, or `nullptr` if not found. - `LookupByKey` performs a binary search, so should have a similar speed to - `std::map`, though may be faster because of better caching. `LookupByKey` - only works if the vector has been sorted, it will likely not find elements - if it hasn't been sorted. - -## Direct memory access - -As you can see from the above examples, all elements in a buffer are -accessed through generated accessors. This is because everything is -stored in little endian format on all platforms (the accessor -performs a swap operation on big endian machines), and also because -the layout of things is generally not known to the user. - -For structs, layout is deterministic and guaranteed to be the same -accross platforms (scalars are aligned to their -own size, and structs themselves to their largest member), and you -are allowed to access this memory directly by using `sizeof()` and -`memcpy` on the pointer to a struct, or even an array of structs. - -To compute offsets to sub-elements of a struct, make sure they -are a structs themselves, as then you can use the pointers to -figure out the offset without having to hardcode it. This is -handy for use of arrays of structs with calls like `glVertexAttribPointer` -in OpenGL or similar APIs. - -It is important to note is that structs are still little endian on all -machines, so only use tricks like this if you can guarantee you're not -shipping on a big endian machine (an `assert(FLATBUFFERS_LITTLEENDIAN)` -would be wise). - -## Access of untrusted buffers - -The generated accessor functions access fields over offsets, which is -very quick. These offsets are not verified at run-time, so a malformed -buffer could cause a program to crash by accessing random memory. - -When you're processing large amounts of data from a source you know (e.g. -your own generated data on disk), this is acceptable, but when reading -data from the network that can potentially have been modified by an -attacker, this is undesirable. - -For this reason, you can optionally use a buffer verifier before you -access the data. This verifier will check all offsets, all sizes of -fields, and null termination of strings to ensure that when a buffer -is accessed, all reads will end up inside the buffer. - -Each root type will have a verification function generated for it, -e.g. for `Monster`, you can call: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - bool ok = VerifyMonsterBuffer(Verifier(buf, len)); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -if `ok` is true, the buffer is safe to read. - -Besides untrusted data, this function may be useful to call in debug -mode, as extra insurance against data being corrupted somewhere along -the way. - -While verifying a buffer isn't "free", it is typically faster than -a full traversal (since any scalar data is not actually touched), -and since it may cause the buffer to be brought into cache before -reading, the actual overhead may be even lower than expected. - -In specialized cases where a denial of service attack is possible, -the verifier has two additional constructor arguments that allow -you to limit the nesting depth and total amount of tables the -verifier may encounter before declaring the buffer malformed. The default is -`Verifier(buf, len, 64 /* max depth */, 1000000, /* max tables */)` which -should be sufficient for most uses. - -## Text & schema parsing - -Using binary buffers with the generated header provides a super low -overhead use of FlatBuffer data. There are, however, times when you want -to use text formats, for example because it interacts better with source -control, or you want to give your users easy access to data. - -Another reason might be that you already have a lot of data in JSON -format, or a tool that generates JSON, and if you can write a schema for -it, this will provide you an easy way to use that data directly. - -(see the schema documentation for some specifics on the JSON format -accepted). - -There are two ways to use text formats: - -#### Using the compiler as a conversion tool - -This is the preferred path, as it doesn't require you to add any new -code to your program, and is maximally efficient since you can ship with -binary data. The disadvantage is that it is an extra step for your -users/developers to perform, though you might be able to automate it. - - flatc -b myschema.fbs mydata.json - -This will generate the binary file `mydata_wire.bin` which can be loaded -as before. - -#### Making your program capable of loading text directly - -This gives you maximum flexibility. You could even opt to support both, -i.e. check for both files, and regenerate the binary from text when -required, otherwise just load the binary. - -This option is currently only available for C++, or Java through JNI. - -As mentioned in the section "Building" above, this technique requires -you to link a few more files into your program, and you'll want to include -`flatbuffers/idl.h`. - -Load text (either a schema or json) into an in-memory buffer (there is a -convenient `LoadFile()` utility function in `flatbuffers/util.h` if you -wish). Construct a parser: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - flatbuffers::Parser parser; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now you can parse any number of text files in sequence: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} - parser.Parse(text_file.c_str()); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This works similarly to how the command-line compiler works: a sequence -of files parsed by the same `Parser` object allow later files to -reference definitions in earlier files. Typically this means you first -load a schema file (which populates `Parser` with definitions), followed -by one or more JSON files. - -As optional argument to `Parse`, you may specify a null-terminated list of -include paths. If not specified, any include statements try to resolve from -the current directory. - -If there were any parsing errors, `Parse` will return `false`, and -`Parser::err` contains a human readable error string with a line number -etc, which you should present to the creator of that file. - -After each JSON file, the `Parser::fbb` member variable is the -`FlatBufferBuilder` that contains the binary buffer version of that -file, that you can access as described above. - -`samples/sample_text.cpp` is a code sample showing the above operations. - -## Threading - -Reading a FlatBuffer does not touch any memory outside the original buffer, -and is entirely read-only (all const), so is safe to access from multiple -threads even without synchronisation primitives. - -Creating a FlatBuffer is not thread safe. All state related to building -a FlatBuffer is contained in a FlatBufferBuilder instance, and no memory -outside of it is touched. To make this thread safe, either do not -share instances of FlatBufferBuilder between threads (recommended), or -manually wrap it in synchronisation primites. There's no automatic way to -accomplish this, by design, as we feel multithreaded construction -of a single buffer will be rare, and synchronisation overhead would be costly. - -## Advanced union features - -The C++ implementation currently supports vectors of unions (i.e. you can -declare a field as `[T]` where `T` is a union type instead of a table type). It -also supports structs and strings in unions, besides tables. - -For an example of these features, see `tests/union_vector`, and -`UnionVectorTest` in `test.cpp`. - -Since these features haven't been ported to other languages yet, if you -choose to use them, you won't be able to use these buffers in other languages -(`flatc` will refuse to compile a schema that uses these features). - -These features reduce the amount of "table wrapping" that was previously -needed to use unions. - -To use scalars, simply wrap them in a struct. - -<br>
diff --git a/third_party/flatbuffers/docs/source/FlatBuffers.md b/third_party/flatbuffers/docs/source/FlatBuffers.md deleted file mode 100644 index d228bd4..0000000 --- a/third_party/flatbuffers/docs/source/FlatBuffers.md +++ /dev/null
@@ -1,168 +0,0 @@ -FlatBuffers {#flatbuffers_index} -=========== - -# Overview {#flatbuffers_overview} - -[FlatBuffers](@ref flatbuffers_overview) is an efficient cross platform -serialization library for C++, C#, C, Go, Java, JavaScript, PHP, and Python. -It was originally created at Google for game development and other -performance-critical applications. - -It is available as Open Source on [GitHub](http://github.com/google/flatbuffers) -under the Apache license, v2 (see LICENSE.txt). - -## Why use FlatBuffers? - -- **Access to serialized data without parsing/unpacking** - What sets - FlatBuffers apart is that it represents hierarchical data in a flat - binary buffer in such a way that it can still be accessed directly - without parsing/unpacking, while also still supporting data - structure evolution (forwards/backwards compatibility). - -- **Memory efficiency and speed** - The only memory needed to access - your data is that of the buffer. It requires 0 additional allocations - (in C++, other languages may vary). FlatBuffers is also very - suitable for use with mmap (or streaming), requiring only part of the - buffer to be in memory. Access is close to the speed of raw - struct access with only one extra indirection (a kind of vtable) to - allow for format evolution and optional fields. It is aimed at - projects where spending time and space (many memory allocations) to - be able to access or construct serialized data is undesirable, such - as in games or any other performance sensitive applications. See the - [benchmarks](@ref flatbuffers_benchmarks) for details. - -- **Flexible** - Optional fields means not only do you get great - forwards and backwards compatibility (increasingly important for - long-lived games: don't have to update all data with each new - version!). It also means you have a lot of choice in what data you - write and what data you don't, and how you design data structures. - -- **Tiny code footprint** - Small amounts of generated code, and just - a single small header as the minimum dependency, which is very easy - to integrate. Again, see the benchmark section for details. - -- **Strongly typed** - Errors happen at compile time rather than - manually having to write repetitive and error prone run-time checks. - Useful code can be generated for you. - -- **Convenient to use** - Generated C++ code allows for terse access - & construction code. Then there's optional functionality for parsing - schemas and JSON-like text representations at runtime efficiently if - needed (faster and more memory efficient than other JSON - parsers). - - Java and Go code supports object-reuse. C# has efficient struct based - accessors. - -- **Cross platform code with no dependencies** - C++ code will work - with any recent gcc/clang and VS2010. Comes with build files for the tests & - samples (Android .mk files, and cmake for all other platforms). - -### Why not use Protocol Buffers, or .. ? - -Protocol Buffers is indeed relatively similar to FlatBuffers, -with the primary difference being that FlatBuffers does not need a parsing/ -unpacking step to a secondary representation before you can -access data, often coupled with per-object memory allocation. The code -is an order of magnitude bigger, too. Protocol Buffers has neither optional -text import/export nor schema language features like unions. - -### But all the cool kids use JSON! - -JSON is very readable (which is why we use it as our optional text -format) and very convenient when used together with dynamically typed -languages (such as JavaScript). When serializing data from statically -typed languages, however, JSON not only has the obvious drawback of runtime -inefficiency, but also forces you to write *more* code to access data -(counterintuitively) due to its dynamic-typing serialization system. -In this context, it is only a better choice for systems that have very -little to no information ahead of time about what data needs to be stored. - -If you do need to store data that doesn't fit a schema, FlatBuffers also -offers a schema-less (self-describing) version! - -Read more about the "why" of FlatBuffers in the -[white paper](@ref flatbuffers_white_paper). - -### Who uses FlatBuffers? -- [Cocos2d-x](http://www.cocos2d-x.org/), the #1 open source mobile game - engine, uses it to serialize all their - [game data](http://www.cocos2d-x.org/reference/native-cpp/V3.5/d7/d2d/namespaceflatbuffers.html). -- [Facebook](http://facebook.com/) uses it for client-server communication in - their Android app. They have a nice - [article](https://code.facebook.com/posts/872547912839369/improving-facebook-s-performance-on-android-with-flatbuffers/) - explaining how it speeds up loading their posts. -- [Fun Propulsion Labs](https://developers.google.com/games/#Tools) - at Google uses it extensively in all their libraries and games. - -## Usage in brief - -This section is a quick rundown of how to use this system. Subsequent -sections provide a more in-depth usage guide. - -- Write a schema file that allows you to define the data structures - you may want to serialize. Fields can have a scalar type - (ints/floats of all sizes), or they can be a: string; array of any type; - reference to yet another object; or, a set of possible objects (unions). - Fields are optional and have defaults, so they don't need to be - present for every object instance. - -- Use `flatc` (the FlatBuffer compiler) to generate a C++ header (or - Java/C#/Go/Python.. classes) with helper classes to access and construct - serialized data. This header (say `mydata_generated.h`) only depends on - `flatbuffers.h`, which defines the core functionality. - -- Use the `FlatBufferBuilder` class to construct a flat binary buffer. - The generated functions allow you to add objects to this - buffer recursively, often as simply as making a single function call. - -- Store or send your buffer somewhere! - -- When reading it back, you can obtain the pointer to the root object - from the binary buffer, and from there traverse it conveniently - in-place with `object->field()`. - -## In-depth documentation - -- How to [build the compiler](@ref flatbuffers_guide_building) and samples on - various platforms. -- How to [use the compiler](@ref flatbuffers_guide_using_schema_compiler). -- How to [write a schema](@ref flatbuffers_guide_writing_schema). -- How to [use the generated C++ code](@ref flatbuffers_guide_use_cpp) in your - own programs. -- How to [use the generated Java/C# code](@ref flatbuffers_guide_use_java_c-sharp) - in your own programs. -- How to [use the generated Go code](@ref flatbuffers_guide_use_go) in your - own programs. -- How to [use FlatBuffers in C with `flatcc`](@ref flatbuffers_guide_use_c) in your - own programs. -- [Support matrix](@ref flatbuffers_support) for platforms/languages/features. -- Some [benchmarks](@ref flatbuffers_benchmarks) showing the advantage of - using FlatBuffers. -- A [white paper](@ref flatbuffers_white_paper) explaining the "why" of - FlatBuffers. -- How to use the [schema-less](@ref flexbuffers) version of - FlatBuffers. -- A description of the [internals](@ref flatbuffers_internals) of FlatBuffers. -- A formal [grammar](@ref flatbuffers_grammar) of the schema language. - -## Online resources - -- [GitHub repository](http://github.com/google/flatbuffers) -- [Landing page](http://google.github.io/flatbuffers) -- [FlatBuffers Google Group](https://groups.google.com/forum/#!forum/flatbuffers) -- [FlatBuffers Issues Tracker](http://github.com/google/flatbuffers/issues) -- Independent implementations & tools: - - [FlatCC](https://github.com/dvidelabs/flatcc) Alternative FlatBuffers - parser, code generator and runtime all in C. -- Videos: - - Colt's [DevByte](https://www.youtube.com/watch?v=iQTxMkSJ1dQ). - - GDC 2015 [Lightning Talk](https://www.youtube.com/watch?v=olmL1fUnQAQ). - - FlatBuffers for [Go](https://www.youtube.com/watch?v=-BPVId_lA5w). - - Evolution of FlatBuffers - [visualization](https://www.youtube.com/watch?v=a0QE0xS8rKM). -- Useful documentation created by others: - - [FlatBuffers in Go](https://rwinslow.com/tags/flatbuffers/) - - [FlatBuffers in Android](http://frogermcs.github.io/flatbuffers-in-android-introdution/) - - [Parsing JSON to FlatBuffers in Java](http://frogermcs.github.io/json-parsing-with-flatbuffers-in-android/) - - [FlatBuffers in Unity](http://exiin.com/blog/flatbuffers-for-unity-sample-code/)
diff --git a/third_party/flatbuffers/docs/source/FlexBuffers.md b/third_party/flatbuffers/docs/source/FlexBuffers.md deleted file mode 100644 index 5d592fe..0000000 --- a/third_party/flatbuffers/docs/source/FlexBuffers.md +++ /dev/null
@@ -1,156 +0,0 @@ -FlexBuffers {#flexbuffers} -========== - -FlatBuffers was designed around schemas, because when you want maximum -performance and data consistency, strong typing is helpful. - -There are however times when you want to store data that doesn't fit a -schema, because you can't know ahead of time what all needs to be stored. - -For this, FlatBuffers has a dedicated format, called FlexBuffers. -This is a binary format that can be used in conjunction -with FlatBuffers (by storing a part of a buffer in FlexBuffers -format), or also as its own independent serialization format. - -While it loses the strong typing, you retain the most unique advantage -FlatBuffers has over other serialization formats (schema-based or not): -FlexBuffers can also be accessed without parsing / copying / object allocation. -This is a huge win in efficiency / memory friendly-ness, and allows unique -use cases such as mmap-ing large amounts of free-form data. - -FlexBuffers' design and implementation allows for a very compact encoding, -combining automatic pooling of strings with automatic sizing of containers to -their smallest possible representation (8/16/32/64 bits). Many values and -offsets can be encoded in just 8 bits. While a schema-less representation is -usually more bulky because of the need to be self-descriptive, FlexBuffers -generates smaller binaries for many cases than regular FlatBuffers. - -FlexBuffers is still slower than regular FlatBuffers though, so we recommend to -only use it if you need it. - - -# Usage - -This is for C++, other languages may follow. - -Include the header `flexbuffers.h`, which in turn depends on `flatbuffers.h` -and `util.h`. - -To create a buffer: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} -flexbuffers::Builder fbb; -fbb.Int(13); -fbb.Finish(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You create any value, followed by `Finish`. Unlike FlatBuffers which requires -the root value to be a table, here any value can be the root, including a lonely -int value. - -You can now access the `std::vector<uint8_t>` that contains the encoded value -as `fbb.GetBuffer()`. Write it, send it, or store it in a parent FlatBuffer. In -this case, the buffer is just 3 bytes in size. - -To read this value back, you could just say: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} -auto root = flexbuffers::GetRoot(my_buffer); -int64_t i = root.AsInt64(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -FlexBuffers stores ints only as big as needed, so it doesn't differentiate -between different sizes of ints. You can ask for the 64 bit version, -regardless of what you put in. In fact, since you demand to read the root -as an int, if you supply a buffer that actually contains a float, or a -string with numbers in it, it will convert it for you on the fly as well, -or return 0 if it can't. If instead you actually want to know what is inside -the buffer before you access it, you can call `root.GetType()` or `root.IsInt()` -etc. - -Here's a slightly more complex value you could write instead of `fbb.Int` above: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} -fbb.Map([&]() { - fbb.Vector("vec", [&]() { - fbb.Int(-100); - fbb.String("Fred"); - fbb.IndirectFloat(4.0f); - }); - fbb.UInt("foo", 100); -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This stores the equivalent of the JSON value -`{ vec: [ -100, "Fred", 4.0 ], foo: 100 }`. The root is a dictionary that has -just two key-value pairs, with keys `vec` and `foo`. Unlike FlatBuffers, it -actually has to store these keys in the buffer (which it does only once if -you store multiple such objects, by pooling key values), but also unlike -FlatBuffers it has no restriction on the keys (fields) that you use. - -The map constructor uses a C++11 Lambda to group its children, but you can -also use more conventional start/end calls if you prefer. - -The first value in the map is a vector. You'll notice that unlike FlatBuffers, -you can use mixed types. There is also a `TypedVector` variant that only -allows a single type, and uses a bit less memory. - -`IndirectFloat` is an interesting feature that allows you to store values -by offset rather than inline. Though that doesn't make any visible change -to the user, the consequence is that large values (especially doubles or -64 bit ints) that occur more than once can be shared. Another use case is -inside of vectors, where the largest element makes up the size of all elements -(e.g. a single double forces all elements to 64bit), so storing a lot of small -integers together with a double is more efficient if the double is indirect. - -Accessing it: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} -auto map = flexbuffers::GetRoot(my_buffer).AsMap(); -map.size(); // 2 -auto vec = map["vec"].AsVector(); -vec.size(); // 3 -vec[0].AsInt64(); // -100; -vec[1].AsString().c_str(); // "Fred"; -vec[1].AsInt64(); // 0 (Number parsing failed). -vec[2].AsDouble(); // 4.0 -vec[2].AsString().IsTheEmptyString(); // true (Wrong Type). -vec[2].AsString().c_str(); // "" (This still works though). -vec[2].ToString().c_str(); // "4" (Or have it converted). -map["foo"].AsUInt8(); // 100 -map["unknown"].IsNull(); // true -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -# Binary encoding - -A description of how FlexBuffers are encoded is in the -[internals](Internals.md#flexbuffers) document. - - -# Efficiency tips - -* Vectors generally are a lot more efficient than maps, so prefer them over maps - when possible for small objects. Instead of a map with keys `x`, `y` and `z`, - use a vector. Better yet, use a typed vector. Or even better, use a fixed - size typed vector. -* Maps are backwards compatible with vectors, and can be iterated as such. - You can iterate either just the values (`map.Values()`), or in parallel with - the keys vector (`map.Keys()`). If you intend - to access most or all elements, this is faster than looking up each element - by key, since that involves a binary search of the key vector. -* When possible, don't mix values that require a big bit width (such as double) - in a large vector of smaller values, since all elements will take on this - width. Use `IndirectDouble` when this is a possibility. Note that - integers automatically use the smallest width possible, i.e. if you ask - to serialize an int64_t whose value is actually small, you will use less - bits. Doubles are represented as floats whenever possible losslessly, but - this is only possible for few values. - Since nested vectors/maps are stored over offsets, they typically don't - affect the vector width. -* To store large arrays of byte data, use a blob. If you'd use a typed - vector, the bit width of the size field may make it use more space than - expected, and may not be compatible with `memcpy`. - Similarly, large arrays of (u)int16_t may be better off stored as a - binary blob if their size could exceed 64k elements. - Construction and use are otherwise similar to strings.
diff --git a/third_party/flatbuffers/docs/source/GoApi.md b/third_party/flatbuffers/docs/source/GoApi.md deleted file mode 100644 index 98be2b6..0000000 --- a/third_party/flatbuffers/docs/source/GoApi.md +++ /dev/null
@@ -1,26 +0,0 @@ -Go API -====== - -\addtogroup flatbuffers_go_api - -<!-- Note: The `GoApi_generate.txt` code snippet was generated using `godoc` and - customized for use with this markdown file. To regenerate the file, use the - `godoc` tool (http://godoc.org) with the files in the `flatbuffers/go` - folder. - - You may need to ensure that copies of the files exist in the `src/` - subfolder at the path set by the `$GOROOT` environment variable. You can - either move the files to `$GOROOT/src/flatbuffers` manually, if `$GOROOT` - is already set, otherwise you will need to manually set the `$GOROOT` - variable to a path and create `src/flatbuffers` subfolders at that path. - Then copy the flatbuffers files into `$GOROOT/src/flatbuffers`. (Some - versions of `godoc` include a `-path` flag. This could be used instead, if - available). - - Once the files exist at the `$GOROOT/src/flatbuffers` location, you can - regenerate this doc using the following command: - `godoc flatbuffers > GoApi_generated.txt`. - - After the documentation is generated, you will have to manually remove any - non-user facing documentation from this file. --> -\snippet GoApi_generated.txt Go API
diff --git a/third_party/flatbuffers/docs/source/GoApi_generated.txt b/third_party/flatbuffers/docs/source/GoApi_generated.txt deleted file mode 100644 index 3d4e0fc..0000000 --- a/third_party/flatbuffers/docs/source/GoApi_generated.txt +++ /dev/null
@@ -1,125 +0,0 @@ -// This file was generated using `godoc` and customized for use with the -// API Reference documentation. To recreate this file, use the `godoc` tool -// (http://godoc.org) with the files in the `flatbuffers/go` folder. -// -// Note: You may need to ensure that copies of the files exist in the -// `src/` subfolder at the path set by the `$GOROOT` environment variable. -// You can either move the files to `$GOROOT/src/flatbuffers` manually, if -// `$GOROOT` is already set, otherwise you will need to manually set the -// `$GOROOT` variable to a path and create `src/flatbuffers` subfolders at that -// path. Then copy these files into `$GOROOT/src/flatbuffers`. (Some versions of -// `godoc` include a `-path` flag. This could be used instead, if available). -// -// Once the files exist at the `$GOROOT/src/flatbuffers` location, you can -// regenerate this doc using the following command: -// `godoc flatbuffers > GoApi_generated.txt`. -// -// After the documentation is generated, you will have to manually remove any -// non-user facing documentation from this file. - -/// [Go API] -PACKAGE DOCUMENTATION - -package flatbuffers - Package flatbuffers provides facilities to read and write flatbuffers - objects. - -TYPES - -type Builder struct { - // `Bytes` gives raw access to the buffer. Most users will want to use - // FinishedBytes() instead. - Bytes []byte -} - Builder is a state machine for creating FlatBuffer objects. Use a - Builder to construct object(s) starting from leaf nodes. - - A Builder constructs byte buffers in a last-first manner for simplicity - and performance. - -FUNCTIONS - -func NewBuilder(initialSize int) *Builder - NewBuilder initializes a Builder of size `initial_size`. The internal - buffer is grown as needed. - -func (b *Builder) CreateByteString(s []byte) UOffsetT - CreateByteString writes a byte slice as a string (null-terminated). - -func (b *Builder) CreateByteVector(v []byte) UOffsetT - CreateByteVector writes a ubyte vector - -func (b *Builder) CreateString(s string) UOffsetT - CreateString writes a null-terminated string as a vector. - -func (b *Builder) EndVector(vectorNumElems int) UOffsetT - EndVector writes data necessary to finish vector construction. - -func (b *Builder) Finish(rootTable UOffsetT) - Finish finalizes a buffer, pointing to the given `rootTable`. - -func (b *Builder) FinishedBytes() []byte - FinishedBytes returns a pointer to the written data in the byte buffer. - Panics if the builder is not in a finished state (which is caused by - calling `Finish()`). - -func (b *Builder) Head() UOffsetT - Head gives the start of useful data in the underlying byte buffer. Note: - unlike other functions, this value is interpreted as from the left. - -func (b *Builder) PrependBool(x bool) - PrependBool prepends a bool to the Builder buffer. Aligns and checks for - space. - -func (b *Builder) PrependByte(x byte) - PrependByte prepends a byte to the Builder buffer. Aligns and checks for - space. - -func (b *Builder) PrependFloat32(x float32) - PrependFloat32 prepends a float32 to the Builder buffer. Aligns and - checks for space. - -func (b *Builder) PrependFloat64(x float64) - PrependFloat64 prepends a float64 to the Builder buffer. Aligns and - checks for space. - -func (b *Builder) PrependInt16(x int16) - PrependInt16 prepends a int16 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependInt32(x int32) - PrependInt32 prepends a int32 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependInt64(x int64) - PrependInt64 prepends a int64 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependInt8(x int8) - PrependInt8 prepends a int8 to the Builder buffer. Aligns and checks for - space. - -func (b *Builder) PrependUOffsetT(off UOffsetT) - PrependUOffsetT prepends an UOffsetT, relative to where it will be - written. - -func (b *Builder) PrependUint16(x uint16) - PrependUint16 prepends a uint16 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependUint32(x uint32) - PrependUint32 prepends a uint32 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependUint64(x uint64) - PrependUint64 prepends a uint64 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) PrependUint8(x uint8) - PrependUint8 prepends a uint8 to the Builder buffer. Aligns and checks - for space. - -func (b *Builder) Reset() - Reset truncates the underlying Builder buffer, facilitating alloc-free - reuse of a Builder. It also resets bookkeeping data. -/// [Go API]
diff --git a/third_party/flatbuffers/docs/source/GoUsage.md b/third_party/flatbuffers/docs/source/GoUsage.md deleted file mode 100644 index ab6ddbd..0000000 --- a/third_party/flatbuffers/docs/source/GoUsage.md +++ /dev/null
@@ -1,99 +0,0 @@ -Use in Go {#flatbuffers_guide_use_go} -========= - -## Before you get started - -Before diving into the FlatBuffers usage in Go, it should be noted that -the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide -to general FlatBuffers usage in all of the supported languages (including Go). -This page is designed to cover the nuances of FlatBuffers usage, specific to -Go. - -You should also have read the [Building](@ref flatbuffers_guide_building) -documentation to build `flatc` and should be familiar with -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and -[Writing a schema](@ref flatbuffers_guide_writing_schema). - -## FlatBuffers Go library code location - -The code for the FlatBuffers Go library can be found at -`flatbuffers/go`. You can browse the library code on the [FlatBuffers -GitHub page](https://github.com/google/flatbuffers/tree/master/go). - -## Testing the FlatBuffers Go library - -The code to test the Go library can be found at `flatbuffers/tests`. -The test code itself is located in [go_test.go](https://github.com/google/ -flatbuffers/blob/master/tests/go_test.go). - -To run the tests, use the [GoTest.sh](https://github.com/google/flatbuffers/ -blob/master/tests/GoTest.sh) shell script. - -*Note: The shell script requires [Go](https://golang.org/doc/install) to -be installed.* - -## Using the FlatBuffers Go library - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in Go.* - -FlatBuffers supports reading and writing binary FlatBuffers in Go. - -To use FlatBuffers in your own code, first generate Go classes from your -schema with the `--go` option to `flatc`. Then you can include both FlatBuffers -and the generated code to read or write a FlatBuffer. - -For example, here is how you would read a FlatBuffer binary file in Go: First, -include the library and generated code. Then read a FlatBuffer binary file into -a `[]byte`, which you pass to the `GetRootAsMonster` function: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go} - import ( - example "MyGame/Example" - flatbuffers "github.com/google/flatbuffers/go" - - io/ioutil - ) - - buf, err := ioutil.ReadFile("monster.dat") - // handle err - monster := example.GetRootAsMonster(buf, 0) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now you can access values like this: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go} - hp := monster.Hp() - pos := monster.Pos(nil) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -In some cases it's necessary to modify values in an existing FlatBuffer in place (without creating a copy). For this reason, scalar fields of a Flatbuffer table or struct can be mutated. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go} - monster := example.GetRootAsMonster(buf, 0) - - // Set table field. - if ok := monster.MutateHp(10); !ok { - panic("failed to mutate Hp") - } - - // Set struct field. - monster.Pos().MutateZ(4) - - // This mutation will fail because the mana field is not available in - // the buffer. It should be set when creating the buffer. - if ok := monster.MutateMana(20); !ok { - panic("failed to mutate Hp") - } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The term `mutate` is used instead of `set` to indicate that this is a special use case. All mutate functions return a boolean value which is false if the field we're trying to mutate is not available in the buffer. - -## Text Parsing - -There currently is no support for parsing text (Schema's and JSON) directly -from Go, though you could use the C++ parser through cgo. Please see the -C++ documentation for more on text parsing. - -<br>
diff --git a/third_party/flatbuffers/docs/source/Grammar.md b/third_party/flatbuffers/docs/source/Grammar.md deleted file mode 100755 index b6b48c0..0000000 --- a/third_party/flatbuffers/docs/source/Grammar.md +++ /dev/null
@@ -1,48 +0,0 @@ -Grammar of the schema language {#flatbuffers_grammar} -============================== - -schema = include* - ( namespace\_decl | type\_decl | enum\_decl | root\_decl | - file_extension_decl | file_identifier_decl | - attribute\_decl | object )* - -include = `include` string\_constant `;` - -namespace\_decl = `namespace` ident ( `.` ident )* `;` - -attribute\_decl = `attribute` string\_constant `;` - -type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}` - -enum\_decl = ( `enum` | `union` ) ident [ `:` type ] metadata `{` commasep( -enumval\_decl ) `}` - -root\_decl = `root_type` ident `;` - -field\_decl = ident `:` type [ `=` scalar ] metadata `;` - -type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` | -`float` | `long` | `ulong` | `double` - | `string` | `[` type `]` | ident - -enumval\_decl = ident [ `=` integer\_constant ] - -metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ] - -scalar = integer\_constant | float\_constant - -object = { commasep( ident `:` value ) } - -single\_value = scalar | string\_constant - -value = single\_value | object | `[` commasep( value ) `]` - -commasep(x) = [ x ( `,` x )\* ] - -file_extension_decl = `file_extension` string\_constant `;` - -file_identifier_decl = `file_identifier` string\_constant `;` - -integer\_constant = -?[0-9]+ | `true` | `false` - -float\_constant = -?[0-9]+.[0-9]+((e|E)(+|-)?[0-9]+)?
diff --git a/third_party/flatbuffers/docs/source/Internals.md b/third_party/flatbuffers/docs/source/Internals.md deleted file mode 100755 index de7a07e..0000000 --- a/third_party/flatbuffers/docs/source/Internals.md +++ /dev/null
@@ -1,439 +0,0 @@ -FlatBuffer Internals {#flatbuffers_internals} -==================== - -This section is entirely optional for the use of FlatBuffers. In normal -usage, you should never need the information contained herein. If you're -interested however, it should give you more of an appreciation of why -FlatBuffers is both efficient and convenient. - -### Format components - -A FlatBuffer is a binary file and in-memory format consisting mostly of -scalars of various sizes, all aligned to their own size. Each scalar is -also always represented in little-endian format, as this corresponds to -all commonly used CPUs today. FlatBuffers will also work on big-endian -machines, but will be slightly slower because of additional -byte-swap intrinsics. - -On purpose, the format leaves a lot of details about where exactly -things live in memory undefined, e.g. fields in a table can have any -order, and objects to some extent can be stored in many orders. This is -because the format doesn't need this information to be efficient, and it -leaves room for optimization and extension (for example, fields can be -packed in a way that is most compact). Instead, the format is defined in -terms of offsets and adjacency only. This may mean two different -implementations may produce different binaries given the same input -values, and this is perfectly valid. - -### Format identification - -The format also doesn't contain information for format identification -and versioning, which is also by design. FlatBuffers is a statically typed -system, meaning the user of a buffer needs to know what kind of buffer -it is. FlatBuffers can of course be wrapped inside other containers -where needed, or you can use its union feature to dynamically identify -multiple possible sub-objects stored. Additionally, it can be used -together with the schema parser if full reflective capabilities are -desired. - -Versioning is something that is intrinsically part of the format (the -optionality / extensibility of fields), so the format itself does not -need a version number (it's a meta-format, in a sense). We're hoping -that this format can accommodate all data needed. If format breaking -changes are ever necessary, it would become a new kind of format rather -than just a variation. - -### Offsets - -The most important and generic offset type (see `flatbuffers.h`) is -`uoffset_t`, which is currently always a `uint32_t`, and is used to -refer to all tables/unions/strings/vectors (these are never stored -in-line). 32bit is -intentional, since we want to keep the format binary compatible between -32 and 64bit systems, and a 64bit offset would bloat the size for almost -all uses. A version of this format with 64bit (or 16bit) offsets is easy to set -when needed. Unsigned means they can only point in one direction, which -typically is forward (towards a higher memory location). Any backwards -offsets will be explicitly marked as such. - -The format starts with an `uoffset_t` to the root object in the buffer. - -We have two kinds of objects, structs and tables. - -### Structs - -These are the simplest, and as mentioned, intended for simple data that -benefits from being extra efficient and doesn't need versioning / -extensibility. They are always stored inline in their parent (a struct, -table, or vector) for maximum compactness. Structs define a consistent -memory layout where all components are aligned to their size, and -structs aligned to their largest scalar member. This is done independent -of the alignment rules of the underlying compiler to guarantee a cross -platform compatible layout. This layout is then enforced in the generated -code. - -### Tables - -Unlike structs, these are not stored in inline in their parent, but are -referred to by offset. - -They start with an `soffset_t` to a vtable. This is a signed version of -`uoffset_t`, since vtables may be stored anywhere relative to the object. -This offset is substracted (not added) from the object start to arrive at -the vtable start. This offset is followed by all the -fields as aligned scalars (or offsets). Unlike structs, not all fields -need to be present. There is no set order and layout. - -To be able to access fields regardless of these uncertainties, we go -through a vtable of offsets. Vtables are shared between any objects that -happen to have the same vtable values. - -The elements of a vtable are all of type `voffset_t`, which is -a `uint16_t`. The first element is the size of the vtable in bytes, -including the size element. The second one is the size of the object, in bytes -(including the vtable offset). This size could be used for streaming, to know -how many bytes to read to be able to access all *inline* fields of the object. -The remaining elements are the N offsets, where N is the amount of fields -declared in the schema when the code that constructed this buffer was -compiled (thus, the size of the table is N + 2). - -All accessor functions in the generated code for tables contain the -offset into this table as a constant. This offset is checked against the -first field (the number of elements), to protect against newer code -reading older data. If this offset is out of range, or the vtable entry -is 0, that means the field is not present in this object, and the -default value is return. Otherwise, the entry is used as offset to the -field to be read. - -### Strings and Vectors - -Strings are simply a vector of bytes, and are always -null-terminated. Vectors are stored as contiguous aligned scalar -elements prefixed by a 32bit element count (not including any -null termination). Neither is stored inline in their parent, but are referred to -by offset. - -### Construction - -The current implementation constructs these buffers backwards (starting -at the highest memory address of the buffer), since -that significantly reduces the amount of bookkeeping and simplifies the -construction API. - -### Code example - -Here's an example of the code that gets generated for the `samples/monster.fbs`. -What follows is the entire file, broken up by comments: - - // automatically generated, do not modify - - #include "flatbuffers/flatbuffers.h" - - namespace MyGame { - namespace Sample { - -Nested namespace support. - - enum { - Color_Red = 0, - Color_Green = 1, - Color_Blue = 2, - }; - - inline const char **EnumNamesColor() { - static const char *names[] = { "Red", "Green", "Blue", nullptr }; - return names; - } - - inline const char *EnumNameColor(int e) { return EnumNamesColor()[e]; } - -Enums and convenient reverse lookup. - - enum { - Any_NONE = 0, - Any_Monster = 1, - }; - - inline const char **EnumNamesAny() { - static const char *names[] = { "NONE", "Monster", nullptr }; - return names; - } - - inline const char *EnumNameAny(int e) { return EnumNamesAny()[e]; } - -Unions share a lot with enums. - - struct Vec3; - struct Monster; - -Predeclare all data types since circular references between types are allowed -(circular references between object are not, though). - - MANUALLY_ALIGNED_STRUCT(4) Vec3 { - private: - float x_; - float y_; - float z_; - - public: - Vec3(float x, float y, float z) - : x_(flatbuffers::EndianScalar(x)), y_(flatbuffers::EndianScalar(y)), z_(flatbuffers::EndianScalar(z)) {} - - float x() const { return flatbuffers::EndianScalar(x_); } - float y() const { return flatbuffers::EndianScalar(y_); } - float z() const { return flatbuffers::EndianScalar(z_); } - }; - STRUCT_END(Vec3, 12); - -These ugly macros do a couple of things: they turn off any padding the compiler -might normally do, since we add padding manually (though none in this example), -and they enforce alignment chosen by FlatBuffers. This ensures the layout of -this struct will look the same regardless of compiler and platform. Note that -the fields are private: this is because these store little endian scalars -regardless of platform (since this is part of the serialized data). -`EndianScalar` then converts back and forth, which is a no-op on all current -mobile and desktop platforms, and a single machine instruction on the few -remaining big endian platforms. - - struct Monster : private flatbuffers::Table { - const Vec3 *pos() const { return GetStruct<const Vec3 *>(4); } - int16_t mana() const { return GetField<int16_t>(6, 150); } - int16_t hp() const { return GetField<int16_t>(8, 100); } - const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(10); } - const flatbuffers::Vector<uint8_t> *inventory() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(14); } - int8_t color() const { return GetField<int8_t>(16, 2); } - }; - -Tables are a bit more complicated. A table accessor struct is used to point at -the serialized data for a table, which always starts with an offset to its -vtable. It derives from `Table`, which contains the `GetField` helper functions. -GetField takes a vtable offset, and a default value. It will look in the vtable -at that offset. If the offset is out of bounds (data from an older version) or -the vtable entry is 0, the field is not present and the default is returned. -Otherwise, it uses the entry as an offset into the table to locate the field. - - struct MonsterBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_pos(const Vec3 *pos) { fbb_.AddStruct(4, pos); } - void add_mana(int16_t mana) { fbb_.AddElement<int16_t>(6, mana, 150); } - void add_hp(int16_t hp) { fbb_.AddElement<int16_t>(8, hp, 100); } - void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(10, name); } - void add_inventory(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory) { fbb_.AddOffset(14, inventory); } - void add_color(int8_t color) { fbb_.AddElement<int8_t>(16, color, 2); } - MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - flatbuffers::Offset<Monster> Finish() { return flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 7)); } - }; - -`MonsterBuilder` is the base helper struct to construct a table using a -`FlatBufferBuilder`. You can add the fields in any order, and the `Finish` -call will ensure the correct vtable gets generated. - - inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb, - const Vec3 *pos, int16_t mana, - int16_t hp, - flatbuffers::Offset<flatbuffers::String> name, - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> inventory, - int8_t color) { - MonsterBuilder builder_(_fbb); - builder_.add_inventory(inventory); - builder_.add_name(name); - builder_.add_pos(pos); - builder_.add_hp(hp); - builder_.add_mana(mana); - builder_.add_color(color); - return builder_.Finish(); - } - -`CreateMonster` is a convenience function that calls all functions in -`MonsterBuilder` above for you. Note that if you pass values which are -defaults as arguments, it will not actually construct that field, so -you can probably use this function instead of the builder class in -almost all cases. - - inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot<Monster>(buf); } - -This function is only generated for the root table type, to be able to -start traversing a FlatBuffer from a raw buffer pointer. - - }; // namespace MyGame - }; // namespace Sample - -### Encoding example. - -Below is a sample encoding for the following JSON corresponding to the above -schema: - - { pos: { x: 1, y: 2, z: 3 }, name: "fred", hp: 50 } - -Resulting in this binary buffer: - - // Start of the buffer: - uint32_t 20 // Offset to the root table. - - // Start of the vtable. Not shared in this example, but could be: - uint16_t 16 // Size of table, starting from here. - uint16_t 22 // Size of object inline data. - uint16_t 4, 0, 20, 16, 0, 0 // Offsets to fields from start of (root) table, 0 for not present. - - // Start of the root table: - int32_t 16 // Offset to vtable used (default negative direction) - float 1, 2, 3 // the Vec3 struct, inline. - uint32_t 8 // Offset to the name string. - int16_t 50 // hp field. - int16_t 0 // Padding for alignment. - - // Start of name string: - uint32_t 4 // Length of string. - int8_t 'f', 'r', 'e', 'd', 0, 0, 0, 0 // Text + 0 termination + padding. - -Note that this not the only possible encoding, since the writer has some -flexibility in which of the children of root object to write first (though in -this case there's only one string), and what order to write the fields in. -Different orders may also cause different alignments to happen. - -# FlexBuffers - -The [schema-less](@ref flexbuffers) version of FlatBuffers have their -own encoding, detailed here. - -It shares many properties mentioned above, in that all data is accessed -over offsets, all scalars are aligned to their own size, and -all data is always stored in little endian format. - -One difference is that FlexBuffers are built front to back, so children are -stored before parents, and the root of the data starts at the last byte. - -Another difference is that scalar data is stored with a variable number of bits -(8/16/32/64). The current width is always determined by the *parent*, i.e. if -the scalar sits in a vector, the vector determines the bit width for all -elements at once. Selecting the minimum bit width for a particular vector is -something the encoder does automatically and thus is typically of no concern -to the user, though being aware of this feature (and not sticking a double in -the same vector as a bunch of byte sized elements) is helpful for efficiency. - -Unlike FlatBuffers there is only one kind of offset, and that is an unsigned -integer indicating the number of bytes in a negative direction from the address -of itself (where the offset is stored). - -### Vectors - -The representation of the vector is at the core of how FlexBuffers works (since -maps are really just a combination of 2 vectors), so it is worth starting there. - -As mentioned, a vector is governed by a single bit width (supplied by its -parent). This includes the size field. For example, a vector that stores the -integer values `1, 2, 3` is encoded as follows: - - uint8_t 3, 1, 2, 3, 4, 4, 4 - -The first `3` is the size field, and is placed before the vector (an offset -from the parent to this vector points to the first element, not the size -field, so the size field is effectively at index -1). -Since this is an untyped vector `SL_VECTOR`, it is followed by 3 type -bytes (one per element of the vector), which are always following the vector, -and are always a uint8_t even if the vector is made up of bigger scalars. - -### Types - -A type byte is made up of 2 components (see flexbuffers.h for exact values): - -* 2 lower bits representing the bit-width of the child (8, 16, 32, 64). - This is only used if the child is accessed over an offset, such as a child - vector. It is ignored for inline types. -* 6 bits representing the actual type (see flexbuffers.h). - -Thus, in this example `4` means 8 bit child (value 0, unused, since the value is -in-line), type `SL_INT` (value 1). - -### Typed Vectors - -These are like the Vectors above, but omit the type bytes. The type is instead -determined by the vector type supplied by the parent. Typed vectors are only -available for a subset of types for which these savings can be significant, -namely inline signed/unsigned integers (`TYPE_VECTOR_INT` / `TYPE_VECTOR_UINT`), -floats (`TYPE_VECTOR_FLOAT`), and keys (`TYPE_VECTOR_KEY`, see below). - -Additionally, for scalars, there are fixed length vectors of sizes 2 / 3 / 4 -that don't store the size (`TYPE_VECTOR_INT2` etc.), for an additional savings -in space when storing common vector or color data. - -### Scalars - -FlexBuffers supports integers (`TYPE_INT` and `TYPE_UINT`) and floats -(`TYPE_FLOAT`), available in the bit-widths mentioned above. They can be stored -both inline and over an offset (`TYPE_INDIRECT_*`). - -The offset version is useful to encode costly 64bit (or even 32bit) quantities -into vectors / maps of smaller sizes, and to share / repeat a value multiple -times. - -### Blobs, Strings and Keys. - -A blob (`TYPE_BLOB`) is encoded similar to a vector, with one difference: the -elements are always `uint8_t`. The parent bit width only determines the width of -the size field, allowing blobs to be large without the elements being large. - -Strings (`TYPE_STRING`) are similar to blobs, except they have an additional 0 -termination byte for convenience, and they MUST be UTF-8 encoded (since an -accessor in a language that does not support pointers to UTF-8 data may have to -convert them to a native string type). - -A "Key" (`TYPE_KEY`) is similar to a string, but doesn't store the size -field. They're so named because they are used with maps, which don't care -for the size, and can thus be even more compact. Unlike strings, keys cannot -contain bytes of value 0 as part of their data (size can only be determined by -`strlen`), so while you can use them outside the context of maps if you so -desire, you're usually better off with strings. - -### Maps - -A map (`TYPE_MAP`) is like an (untyped) vector, but with 2 prefixes before the -size field: - -| index | field | -| ----: | :----------------------------------------------------------- | -| -3 | An offset to the keys vector (may be shared between tables). | -| -2 | Byte width of the keys vector. | -| -1 | Size (from here on it is compatible with `TYPE_VECTOR`) | -| 0 | Elements. | -| Size | Types. | - -Since a map is otherwise the same as a vector, it can be iterated like -a vector (which is probably faster than lookup by key). - -The keys vector is a typed vector of keys. Both the keys and corresponding -values *have* to be stored in sorted order (as determined by `strcmp`), such -that lookups can be made using binary search. - -The reason the key vector is a seperate structure from the value vector is -such that it can be shared between multiple value vectors, and also to -allow it to be treated as its own indivual vector in code. - -An example map { foo: 13, bar: 14 } would be encoded as: - - 0 : uint8_t 'f', 'o', 'o', 0 - 4 : uint8_t 'b', 'a', 'r', 0 - 8 : uint8_t 2 // key vector of size 2 - // key vector offset points here - 9 : uint8_t 9, 6 // offsets to foo_key and bar_key - 11: uint8_t 3, 1 // offset to key vector, and its byte width - 13: uint8_t 2 // value vector of size - // value vector offset points here - 14: uint8_t 13, 14 // values - 16: uint8_t 4, 4 // types - -### The root - -As mentioned, the root starts at the end of the buffer. -The last uint8_t is the width in bytes of the root (normally the parent -determines the width, but the root has no parent). The uint8_t before this is -the type of the root, and the bytes before that are the root value (of the -number of bytes specified by the last byte). - -So for example, the integer value `13` as root would be: - - uint8_t 13, 4, 1 // Value, type, root byte width. - - -<br>
diff --git a/third_party/flatbuffers/docs/source/JavaCsharpUsage.md b/third_party/flatbuffers/docs/source/JavaCsharpUsage.md deleted file mode 100755 index cc58f85..0000000 --- a/third_party/flatbuffers/docs/source/JavaCsharpUsage.md +++ /dev/null
@@ -1,171 +0,0 @@ -Use in Java/C# {#flatbuffers_guide_use_java_c-sharp} -============== - -## Before you get started - -Before diving into the FlatBuffers usage in Java or C#, it should be noted that -the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to -general FlatBuffers usage in all of the supported languages (including both Java -and C#). This page is designed to cover the nuances of FlatBuffers usage, -specific to Java and C#. - -You should also have read the [Building](@ref flatbuffers_guide_building) -documentation to build `flatc` and should be familiar with -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and -[Writing a schema](@ref flatbuffers_guide_writing_schema). - -## FlatBuffers Java and C-sharp code location - -#### Java - -The code for the FlatBuffers Java library can be found at -`flatbuffers/java/com/google/flatbuffers`. You can browse the library on the -[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/ -java/com/google/flatbuffers). - -#### C-sharp - -The code for the FlatBuffers C# library can be found at -`flatbuffers/net/FlatBuffers`. You can browse the library on the -[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/net/ -FlatBuffers). - -## Testing the FlatBuffers Java and C-sharp libraries - -The code to test the libraries can be found at `flatbuffers/tests`. - -#### Java - -The test code for Java is located in [JavaTest.java](https://github.com/google -/flatbuffers/blob/master/tests/JavaTest.java). - -To run the tests, use either [JavaTest.sh](https://github.com/google/ -flatbuffers/blob/master/tests/JavaTest.sh) or [JavaTest.bat](https://github.com/ -google/flatbuffers/blob/master/tests/JavaTest.bat), depending on your operating -system. - -*Note: These scripts require that [Java](https://www.oracle.com/java/index.html) -is installed.* - -#### C-sharp - -The test code for C# is located in the [FlatBuffers.Test](https://github.com/ -google/flatbuffers/tree/master/tests/FlatBuffers.Test) subfolder. To run the -tests, open `FlatBuffers.Test.csproj` in [Visual Studio]( -https://www.visualstudio.com), and compile/run the project. - -Optionally, you can run this using [Mono](http://www.mono-project.com/) instead. -Once you have installed `Mono`, you can run the tests from the command line -by running the following commands from inside the `FlatBuffers.Test` folder: - -~~~{.sh} - mcs *.cs ../MyGame/Example/*.cs ../../net/FlatBuffers/*.cs - mono Assert.exe -~~~ - -## Using the FlatBuffers Java (and C#) library - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in Java or C#.* - -FlatBuffers supports reading and writing binary FlatBuffers in Java and C#. - -To use FlatBuffers in your own code, first generate Java classes from your -schema with the `--java` option to `flatc`. (Or for C# with `--csharp`). -Then you can include both FlatBuffers and the generated code to read -or write a FlatBuffer. - -For example, here is how you would read a FlatBuffer binary file in Java: -First, import the library and generated code. Then, you read a FlatBuffer binary -file into a `byte[]`. You then turn the `byte[]` into a `ByteBuffer`, which you -pass to the `getRootAsMyRootType` function: - -*Note: The code here is written from the perspective of Java. Code for both -languages is both generated and used in nearly the exact same way, with only -minor differences. These differences are -[explained in a section below](#differences_in_c-sharp).* - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.java} - import MyGame.Example.*; - import com.google.flatbuffers.FlatBufferBuilder; - - // This snippet ignores exceptions for brevity. - File file = new File("monsterdata_test.mon"); - RandomAccessFile f = new RandomAccessFile(file, "r"); - byte[] data = new byte[(int)f.length()]; - f.readFully(data); - f.close(); - - ByteBuffer bb = ByteBuffer.wrap(data); - Monster monster = Monster.getRootAsMonster(bb); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now you can access the data from the `Monster monster`: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.java} - short hp = monster.hp(); - Vec3 pos = monster.pos(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -<a name="differences_in_c-sharp"> -#### Differences in C-sharp -</a> - -C# code works almost identically to Java, with only a few minor differences. -You can see an example of C# code in -`tests/FlatBuffers.Test/FlatBuffersExampleTests.cs` or -`samples/SampleBinary.cs`. - -First of all, naming follows standard C# style with `PascalCasing` identifiers, -e.g. `GetRootAsMyRootType`. Also, values (except vectors and unions) are -available as properties instead of parameterless accessor methods as in Java. -The performance-enhancing methods to which you can pass an already created -object are prefixed with `Get`, e.g.: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs} - // property - var pos = monster.Pos; - - // method filling a preconstructed object - var preconstructedPos = new Vec3(); - monster.GetPos(preconstructedPos); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Storing dictionaries in a FlatBuffer - -FlatBuffers doesn't support dictionaries natively, but there is support to -emulate their behavior with vectors and binary search, which means you -can have fast lookups directly from a FlatBuffer without having to unpack -your data into a `Dictionary` or similar. - -To use it: -- Designate one of the fields in a table as they "key" field. You do this - by setting the `key` attribute on this field, e.g. - `name:string (key)`. - You may only have one key field, and it must be of string or scalar type. -- Write out tables of this type as usual, collect their offsets in an - array. -- Instead of calling standard generated method, - e.g.: `Monster.createTestarrayoftablesVector`, - call `CreateMySortedVectorOfTables` in C# or - `createSortedVectorOfTables` (from the `FlatBufferBuilder` object) in Java, - which will first sort all offsets such that the tables they refer to - are sorted by the key field, then serialize it. -- Now when you're accessing the FlatBuffer, you can use `LookupByKey` - to access elements of the vector, e.g.: - `Monster.lookupByKey(tablesVectorOffset, "Frodo", dataBuffer)`, - which returns an object of the corresponding table type, - or `null` if not found. - `LookupByKey` performs a binary search, so should have a similar speed to - `Dictionary`, though may be faster because of better caching. `LookupByKey` - only works if the vector has been sorted, it will likely not find elements - if it hasn't been sorted. - -## Text parsing - -There currently is no support for parsing text (Schema's and JSON) directly -from Java or C#, though you could use the C++ parser through native call -interfaces available to each language. Please see the -C++ documentation for more on text parsing. - -<br>
diff --git a/third_party/flatbuffers/docs/source/JavaScriptUsage.md b/third_party/flatbuffers/docs/source/JavaScriptUsage.md deleted file mode 100755 index c321c95..0000000 --- a/third_party/flatbuffers/docs/source/JavaScriptUsage.md +++ /dev/null
@@ -1,105 +0,0 @@ -Use in JavaScript {#flatbuffers_guide_use_javascript} -================= - -## Before you get started - -Before diving into the FlatBuffers usage in JavaScript, it should be noted that -the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to -general FlatBuffers usage in all of the supported languages -(including JavaScript). This page is specifically designed to cover the nuances -of FlatBuffers usage in JavaScript. - -You should also have read the [Building](@ref flatbuffers_guide_building) -documentation to build `flatc` and should be familiar with -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and -[Writing a schema](@ref flatbuffers_guide_writing_schema). - -## FlatBuffers JavaScript library code location - -The code for the FlatBuffers JavaScript library can be found at -`flatbuffers/js`. You can browse the library code on the [FlatBuffers -GitHub page](https://github.com/google/flatbuffers/tree/master/js). - -## Testing the FlatBuffers JavaScript library - -The code to test the JavaScript library can be found at `flatbuffers/tests`. -The test code itself is located in [JavaScriptTest.js](https://github.com/ -google/flatbuffers/blob/master/tests/JavaScriptTest.js). - -To run the tests, use the [JavaScriptTest.sh](https://github.com/google/ -flatbuffers/blob/master/tests/JavaScriptTest.sh) shell script. - -*Note: The JavaScript test file requires [Node.js](https://nodejs.org/en/).* - -## Using the FlatBuffers JavaScript libary - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in JavaScript.* - -FlatBuffers supports both reading and writing FlatBuffers in JavaScript. - -To use FlatBuffers in your own code, first generate JavaScript classes from your -schema with the `--js` option to `flatc`. Then you can include both FlatBuffers -and the generated code to read or write a FlatBuffer. - -For example, here is how you would read a FlatBuffer binary file in Javascript: -First, include the library and generated code. Then read the file into an -`Uint8Array`. Make a `flatbuffers.ByteBuffer` out of the `Uint8Array`, and pass -the ByteBuffer to the `getRootAsMonster` function. - -*Note: Both JavaScript module loaders (e.g. Node.js) and browser-based -HTML/JavaScript code segments are shown below in the following snippet:* - -~~~{.js} - // Note: These require functions are specific to JavaScript module loaders - // (namely, Node.js). See below for a browser-based example. - var fs = require('fs'); - - var flatbuffers = require('../flatbuffers').flatbuffers; - var MyGame = require('./monster_generated').MyGame; - - var data = new Uint8Array(fs.readFileSync('monster.dat')); - var buf = new flatbuffers.ByteBuffer(data); - - var monster = MyGame.Example.Monster.getRootAsMonster(buf); - - //--------------------------------------------------------------------------// - - // Note: This code is specific to browser-based HTML/JavaScript. See above - // for the code using JavaScript module loaders (e.g. Node.js). - <script src="../js/flatbuffers.js"></script> - <script src="monster_generated.js"></script> - <script> - function readFile() { - var reader = new FileReader(); // This example uses the HTML5 FileReader. - var file = document.getElementById( - 'file_input').files[0]; // "monster.dat" from the HTML <input> field. - - reader.onload = function() { // Executes after the file is read. - var data = new Uint8Array(reader.result); - - var buf = new flatbuffers.ByteBuffer(data); - - var monster = MyGame.Example.Monster.getRootAsMonster(buf); - } - - reader.readAsArrayBuffer(file); - } - </script> - - // Open the HTML file in a browser and select "monster.dat" from with the - // <input> field. - <input type="file" id="file_input" onchange="readFile();"> -~~~ - -Now you can access values like this: - -~~~{.js} - var hp = monster.hp(); - var pos = monster.pos(); -~~~ - -## Text parsing FlatBuffers in JavaScript - -There currently is no support for parsing text (Schema's and JSON) directly -from JavaScript.
diff --git a/third_party/flatbuffers/docs/source/PHPUsage.md b/third_party/flatbuffers/docs/source/PHPUsage.md deleted file mode 100644 index cdff449..0000000 --- a/third_party/flatbuffers/docs/source/PHPUsage.md +++ /dev/null
@@ -1,89 +0,0 @@ -Use in PHP {#flatbuffers_guide_use_php} -========== - -## Before you get started - -Before diving into the FlatBuffers usage in PHP, it should be noted that -the [Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to -general FlatBuffers usage in all of the supported languages -(including PHP). This page is specifically designed to cover the nuances of -FlatBuffers usage in PHP. - -You should also have read the [Building](@ref flatbuffers_guide_building) -documentation to build `flatc` and should be familiar with -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and -[Writing a schema](@ref flatbuffers_guide_writing_schema). - -## FlatBuffers PHP library code location - -The code for FlatBuffers PHP library can be found at `flatbuffers/php`. You -can browse the library code on the [FlatBuffers -GitHub page](https://github.com/google/flatbuffers/tree/master/php). - -## Testing the FlatBuffers JavaScript library - -The code to test the PHP library can be found at `flatbuffers/tests`. -The test code itself is located in [phpTest.php](https://github.com/google/ -flatbuffers/blob/master/tests/phpTest.php). - -You can run the test with `php phpTest.php` from the command line. - -*Note: The PHP test file requires -[PHP](http://php.net/manual/en/install.php) to be installed.* - -## Using theFlatBuffers PHP library - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in PHP.* - -FlatBuffers supports both reading and writing FlatBuffers in PHP. - -To use FlatBuffers in your own code, first generate PHP classes from your schema -with the `--php` option to `flatc`. Then you can include both FlatBuffers and -the generated code to read or write a FlatBuffer. - -For example, here is how you would read a FlatBuffer binary file in PHP: -First, include the library and generated code (using the PSR `autoload` -function). Then you can read a FlatBuffer binary file, which you -pass the contents of to the `GetRootAsMonster` function: - -~~~{.php} - // It is recommended that your use PSR autoload when using FlatBuffers in PHP. - // Here is an example: - function __autoload($class_name) { - // The last segment of the class name matches the file name. - $class = substr($class_name, strrpos($class_name, "\\") + 1); - $root_dir = join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)))); // `flatbuffers` root. - - // Contains the `*.php` files for the FlatBuffers library and the `flatc` generated files. - $paths = array(join(DIRECTORY_SEPARATOR, array($root_dir, "php")), - join(DIRECTORY_SEPARATOR, array($root_dir, "tests", "MyGame", "Example"))); - foreach ($paths as $path) { - $file = join(DIRECTORY_SEPARATOR, array($path, $class . ".php")); - if (file_exists($file)) { - require($file); - break; - } - } - - // Read the contents of the FlatBuffer binary file. - $filename = "monster.dat"; - $handle = fopen($filename, "rb"); - $contents = $fread($handle, filesize($filename)); - fclose($handle); - - // Pass the contents to `GetRootAsMonster`. - $monster = \MyGame\Example\Monster::GetRootAsMonster($contents); -~~~ - -Now you can access values like this: - -~~~{.php} - $hp = $monster->GetHp(); - $pos = $monster->GetPos(); -~~~ - -## Text Parsing - -There currently is no support for parsing text (Schema's and JSON) directly -from PHP.
diff --git a/third_party/flatbuffers/docs/source/PythonUsage.md b/third_party/flatbuffers/docs/source/PythonUsage.md deleted file mode 100755 index 2a0cdde..0000000 --- a/third_party/flatbuffers/docs/source/PythonUsage.md +++ /dev/null
@@ -1,73 +0,0 @@ -Use in Python {#flatbuffers_guide_use_python} -============= - -## Before you get started - -Before diving into the FlatBuffers usage in Python, it should be noted that the -[Tutorial](@ref flatbuffers_guide_tutorial) page has a complete guide to general -FlatBuffers usage in all of the supported languages (including Python). This -page is designed to cover the nuances of FlatBuffers usage, specific to -Python. - -You should also have read the [Building](@ref flatbuffers_guide_building) -documentation to build `flatc` and should be familiar with -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) and -[Writing a schema](@ref flatbuffers_guide_writing_schema). - -## FlatBuffers Python library code location - -The code for the FlatBuffers Python library can be found at -`flatbuffers/python/flatbuffers`. You can browse the library code on the -[FlatBuffers GitHub page](https://github.com/google/flatbuffers/tree/master/ -python). - -## Testing the FlatBuffers Python library - -The code to test the Python library can be found at `flatbuffers/tests`. -The test code itself is located in [py_test.py](https://github.com/google/ -flatbuffers/blob/master/tests/py_test.py). - -To run the tests, use the [PythonTest.sh](https://github.com/google/flatbuffers/ -blob/master/tests/PythonTest.sh) shell script. - -*Note: This script requires [python](https://www.python.org/) to be -installed.* - -## Using the FlatBuffers Python library - -*Note: See [Tutorial](@ref flatbuffers_guide_tutorial) for a more in-depth -example of how to use FlatBuffers in Python.* - -There is support for both reading and writing FlatBuffers in Python. - -To use FlatBuffers in your own code, first generate Python classes from your -schema with the `--python` option to `flatc`. Then you can include both -FlatBuffers and the generated code to read or write a FlatBuffer. - -For example, here is how you would read a FlatBuffer binary file in Python: -First, import the library and the generated code. Then read a FlatBuffer binary -file into a `bytearray`, which you pass to the `GetRootAsMonster` function: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py} - import MyGame.Example as example - import flatbuffers - - buf = open('monster.dat', 'rb').read() - buf = bytearray(buf) - monster = example.GetRootAsMonster(buf, 0) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Now you can access values like this: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py} - hp = monster.Hp() - pos = monster.Pos() -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Text Parsing - -There currently is no support for parsing text (Schema's and JSON) directly -from Python, though you could use the C++ parser through SWIG or ctypes. Please -see the C++ documentation for more on text parsing. - -<br>
diff --git a/third_party/flatbuffers/docs/source/README_TO_GENERATE_DOCS.md b/third_party/flatbuffers/docs/source/README_TO_GENERATE_DOCS.md deleted file mode 100644 index 5df0b6a..0000000 --- a/third_party/flatbuffers/docs/source/README_TO_GENERATE_DOCS.md +++ /dev/null
@@ -1,32 +0,0 @@ -## Prerequisites - -To generate the docs for FlatBuffers from the source files, you -will first need to install two programs. - -1. You will need to install `doxygen`. See - [Download Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html). - -2. You will need to install `doxypypy` to format python comments appropriately. - Install it from [here](https://github.com/Feneric/doxypypy). - -*Note: You will need both `doxygen` and `doxypypy` to be in your -[PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable.* - -After you have both of those files installed and in your path, you need to -set up the `py_filter` to invoke `doxypypy` from `doxygen`. - -Follow the steps -[here](https://github.com/Feneric/doxypypy#invoking-doxypypy-from-doxygen). - -## Generating Docs - -Run the following commands to generate the docs: - -`cd flatbuffers/docs/source` -`doxygen` - -The output is placed in `flatbuffers/docs/html`. - -*Note: The Go API Reference code must be generated ahead of time. For -instructions on how to regenerated this file, please read the comments -in `GoApi.md`.*
diff --git a/third_party/flatbuffers/docs/source/Schemas.md b/third_party/flatbuffers/docs/source/Schemas.md deleted file mode 100755 index c4a9421..0000000 --- a/third_party/flatbuffers/docs/source/Schemas.md +++ /dev/null
@@ -1,545 +0,0 @@ -Writing a schema {#flatbuffers_guide_writing_schema} -================ - -The syntax of the schema language (aka IDL, [Interface Definition Language][]) -should look quite familiar to users of any of the C family of -languages, and also to users of other IDLs. Let's look at an example -first: - - // example IDL file - - namespace MyGame; - - attribute "priority"; - - enum Color : byte { Red = 1, Green, Blue } - - union Any { Monster, Weapon, Pickup } - - struct Vec3 { - x:float; - y:float; - z:float; - } - - table Monster { - pos:Vec3; - mana:short = 150; - hp:short = 100; - name:string; - friendly:bool = false (deprecated, priority: 1); - inventory:[ubyte]; - color:Color = Blue; - test:Any; - } - - root_type Monster; - -(`Weapon` & `Pickup` not defined as part of this example). - -### Tables - -Tables are the main way of defining objects in FlatBuffers, and consist -of a name (here `Monster`) and a list of fields. Each field has a name, -a type, and optionally a default value (if omitted, it defaults to `0` / -`NULL`). - -Each field is optional: It does not have to appear in the wire -representation, and you can choose to omit fields for each individual -object. As a result, you have the flexibility to add fields without fear of -bloating your data. This design is also FlatBuffer's mechanism for forward -and backwards compatibility. Note that: - -- You can add new fields in the schema ONLY at the end of a table - definition. Older data will still - read correctly, and give you the default value when read. Older code - will simply ignore the new field. - If you want to have flexibility to use any order for fields in your - schema, you can manually assign ids (much like Protocol Buffers), - see the `id` attribute below. - -- You cannot delete fields you don't use anymore from the schema, - but you can simply - stop writing them into your data for almost the same effect. - Additionally you can mark them as `deprecated` as in the example - above, which will prevent the generation of accessors in the - generated C++, as a way to enforce the field not being used any more. - (careful: this may break code!). - -- You may change field names and table names, if you're ok with your - code breaking until you've renamed them there too. - -See "Schema evolution examples" below for more on this -topic. - -### Structs - -Similar to a table, only now none of the fields are optional (so no defaults -either), and fields may not be added or be deprecated. Structs may only contain -scalars or other structs. Use this for -simple objects where you are very sure no changes will ever be made -(as quite clear in the example `Vec3`). Structs use less memory than -tables and are even faster to access (they are always stored in-line in their -parent object, and use no virtual table). - -### Types - -Built-in scalar types are: - -- 8 bit: `byte`, `ubyte`, `bool` - -- 16 bit: `short`, `ushort` - -- 32 bit: `int`, `uint`, `float` - -- 64 bit: `long`, `ulong`, `double` - -Built-in non-scalar types: - -- Vector of any other type (denoted with `[type]`). Nesting vectors - is not supported, instead you can wrap the inner vector in a table. - -- `string`, which may only hold UTF-8 or 7-bit ASCII. For other text encodings - or general binary data use vectors (`[byte]` or `[ubyte]`) instead. - -- References to other tables or structs, enums or unions (see - below). - -You can't change types of fields once they're used, with the exception -of same-size data where a `reinterpret_cast` would give you a desirable result, -e.g. you could change a `uint` to an `int` if no values in current data use the -high bit yet. - -### (Default) Values - -Values are a sequence of digits. Values may be optionally followed by a decimal -point (`.`) and more digits, for float constants, or optionally prefixed by -a `-`. Floats may also be in scientific notation; optionally ending with an `e` -or `E`, followed by a `+` or `-` and more digits. - -Only scalar values can have defaults, non-scalar (string/vector/table) fields -default to `NULL` when not present. - -You generally do not want to change default values after they're initially -defined. Fields that have the default value are not actually stored in the -serialized data (see also Gotchas below) but are generated in code, -so when you change the default, you'd -now get a different value than from code generated from an older version of -the schema. There are situations, however, where this may be -desirable, especially if you can ensure a simultaneous rebuild of -all code. - -### Enums - -Define a sequence of named constants, each with a given value, or -increasing by one from the previous one. The default first value -is `0`. As you can see in the enum declaration, you specify the underlying -integral type of the enum with `:` (in this case `byte`), which then determines -the type of any fields declared with this enum type. - -Typically, enum values should only ever be added, never removed (there is no -deprecation for enums). This requires code to handle forwards compatibility -itself, by handling unknown enum values. - -### Unions - -Unions share a lot of properties with enums, but instead of new names -for constants, you use names of tables. You can then declare -a union field, which can hold a reference to any of those types, and -additionally a hidden field with the suffix `_type` is generated that -holds the corresponding enum value, allowing you to know which type to -cast to at runtime. - -Unions are a good way to be able to send multiple message types as a FlatBuffer. -Note that because a union field is really two fields, it must always be -part of a table, it cannot be the root of a FlatBuffer by itself. - -If you have a need to distinguish between different FlatBuffers in a more -open-ended way, for example for use as files, see the file identification -feature below. - -There is an experimental support only in C++ for a vector of unions -(and types). In the example IDL file above, use [Any] to add a -vector of Any to Monster table. - -### Namespaces - -These will generate the corresponding namespace in C++ for all helper -code, and packages in Java. You can use `.` to specify nested namespaces / -packages. - -### Includes - -You can include other schemas files in your current one, e.g.: - - include "mydefinitions.fbs"; - -This makes it easier to refer to types defined elsewhere. `include` -automatically ensures each file is parsed just once, even when referred to -more than once. - -When using the `flatc` compiler to generate code for schema definitions, -only definitions in the current file will be generated, not those from the -included files (those you still generate separately). - -### Root type - -This declares what you consider to be the root table (or struct) of the -serialized data. This is particularly important for parsing JSON data, -which doesn't include object type information. - -### File identification and extension - -Typically, a FlatBuffer binary buffer is not self-describing, i.e. it -needs you to know its schema to parse it correctly. But if you -want to use a FlatBuffer as a file format, it would be convenient -to be able to have a "magic number" in there, like most file formats -have, to be able to do a sanity check to see if you're reading the -kind of file you're expecting. - -Now, you can always prefix a FlatBuffer with your own file header, -but FlatBuffers has a built-in way to add an identifier to a -FlatBuffer that takes up minimal space, and keeps the buffer -compatible with buffers that don't have such an identifier. - -You can specify in a schema, similar to `root_type`, that you intend -for this type of FlatBuffer to be used as a file format: - - file_identifier "MYFI"; - -Identifiers must always be exactly 4 characters long. These 4 characters -will end up as bytes at offsets 4-7 (inclusive) in the buffer. - -For any schema that has such an identifier, `flatc` will automatically -add the identifier to any binaries it generates (with `-b`), -and generated calls like `FinishMonsterBuffer` also add the identifier. -If you have specified an identifier and wish to generate a buffer -without one, you can always still do so by calling -`FlatBufferBuilder::Finish` explicitly. - -After loading a buffer, you can use a call like -`MonsterBufferHasIdentifier` to check if the identifier is present. - -Note that this is best for open-ended uses such as files. If you simply wanted -to send one of a set of possible messages over a network for example, you'd -be better off with a union. - -Additionally, by default `flatc` will output binary files as `.bin`. -This declaration in the schema will change that to whatever you want: - - file_extension "ext"; - -### RPC interface declarations - -You can declare RPC calls in a schema, that define a set of functions -that take a FlatBuffer as an argument (the request) and return a FlatBuffer -as the response (both of which must be table types): - - rpc_service MonsterStorage { - Store(Monster):StoreResponse; - Retrieve(MonsterId):Monster; - } - -What code this produces and how it is used depends on language and RPC system -used, there is preliminary support for GRPC through the `--grpc` code generator, -see `grpc/tests` for an example. - -### Comments & documentation - -May be written as in most C-based languages. Additionally, a triple -comment (`///`) on a line by itself signals that a comment is documentation -for whatever is declared on the line after it -(table/struct/field/enum/union/element), and the comment is output -in the corresponding C++ code. Multiple such lines per item are allowed. - -### Attributes - -Attributes may be attached to a declaration, behind a field, or after -the name of a table/struct/enum/union. These may either have a value or -not. Some attributes like `deprecated` are understood by the compiler; -user defined ones need to be declared with the attribute declaration -(like `priority` in the example above), and are -available to query if you parse the schema at runtime. -This is useful if you write your own code generators/editors etc., and -you wish to add additional information specific to your tool (such as a -help text). - -Current understood attributes: - -- `id: n` (on a table field): manually set the field identifier to `n`. - If you use this attribute, you must use it on ALL fields of this table, - and the numbers must be a contiguous range from 0 onwards. - Additionally, since a union type effectively adds two fields, its - id must be that of the second field (the first field is the type - field and not explicitly declared in the schema). - For example, if the last field before the union field had id 6, - 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 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. - By default, all fields are optional, i.e. may be left out. This is - desirable, as it helps with forwards/backwards compatibility, and - flexibility of data structures. It is also a burden on the reading code, - since for non-scalar fields it requires you to check against NULL and - take appropriate action. By specifying this field, you force code that - constructs FlatBuffers to ensure this field is initialized, so the reading - code may access it directly, without checking for NULL. If the constructing - code does not initialize this field, they will get an assert, and also - the verifier will fail on buffers that have missing required fields. -- `force_align: size` (on a struct): force the alignment of this struct - to be something higher than what it is naturally aligned to. Causes - these structs to be aligned to that amount inside a buffer, IF that - buffer is allocated with that alignment (which is not necessarily - the case for buffers accessed directly inside a `FlatBufferBuilder`). -- `bit_flags` (on an enum): the values of this field indicate bits, - meaning that any value N specified in the schema will end up - representing 1<<N, or if you don't specify values at all, you'll get - the sequence 1, 2, 4, 8, ... -- `nested_flatbuffer: "table_name"` (on a field): this indicates that the field - (which must be a vector of ubyte) contains flatbuffer data, for which the - root type is given by `table_name`. The generated code will then produce - a convenient accessor for the nested FlatBuffer. -- `key` (on a field): this field is meant to be used as a key when sorting - a vector of the type of table it sits in. Can be used for in-place - binary search. -- `hash` (on a field). This is an (un)signed 32/64 bit integer field, whose - value during JSON parsing is allowed to be a string, which will then be - stored as its hash. The value of attribute is the hashing algorithm to - use, one of `fnv1_32` `fnv1_64` `fnv1a_32` `fnv1a_64`. -- `original_order` (on a table): since elements in a table do not need - to be stored in any particular order, they are often optimized for - space by sorting them to size. This attribute stops that from happening. - There should generally not be any reason to use this flag. -- 'native_*'. Several attributes have been added to support the [C++ object - Based API](@ref flatbuffers_cpp_object_based_api). All such attributes - are prefixed with the term "native_". - - -## JSON Parsing - -The same parser that parses the schema declarations above is also able -to parse JSON objects that conform to this schema. So, unlike other JSON -parsers, this parser is strongly typed, and parses directly into a FlatBuffer -(see the compiler documentation on how to do this from the command line, or -the C++ documentation on how to do this at runtime). - -Besides needing a schema, there are a few other changes to how it parses -JSON: - -- It accepts field names with and without quotes, like many JSON parsers - already do. It outputs them without quotes as well, though can be made - to output them using the `strict_json` flag. -- If a field has an enum type, the parser will recognize symbolic enum - values (with or without quotes) instead of numbers, e.g. - `field: EnumVal`. If a field is of integral type, you can still use - symbolic names, but values need to be prefixed with their type and - need to be quoted, e.g. `field: "Enum.EnumVal"`. For enums - representing flags, you may place multiple inside a string - separated by spaces to OR them, e.g. - `field: "EnumVal1 EnumVal2"` or `field: "Enum.EnumVal1 Enum.EnumVal2"`. -- Similarly, for unions, these need to specified with two fields much like - you do when serializing from code. E.g. for a field `foo`, you must - add a field `foo_type: FooOne` right before the `foo` field, where - `FooOne` would be the table out of the union you want to use. -- 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: - -- `\n` - linefeed. -- `\t` - tab. -- `\r` - carriage return. -- `\b` - backspace. -- `\f` - form feed. -- `\"` - double quote. -- `\\` - backslash. -- `\/` - forward slash. -- `\uXXXX` - 16-bit unicode code point, converted to the equivalent UTF-8 - representation. -- `\xXX` - 8-bit binary hexadecimal number XX. This is the only one that is - not in the JSON spec (see http://json.org/), but is needed to be able to - encode arbitrary binary in strings to text and back without losing - information (e.g. the byte 0xFF can't be represented in standard JSON). - -It also generates these escape codes back again when generating JSON from a -binary representation. - -## Guidelines - -### Efficiency - -FlatBuffers is all about efficiency, but to realize that efficiency you -require an efficient schema. There are usually multiple choices on -how to represent data that have vastly different size characteristics. - -It is very common nowadays to represent any kind of data as dictionaries -(as in e.g. JSON), because of its flexibility and extensibility. While -it is possible to emulate this in FlatBuffers (as a vector -of tables with key and value(s)), this is a bad match for a strongly -typed system like FlatBuffers, leading to relatively large binaries. -FlatBuffer tables are more flexible than classes/structs in most systems, -since having a large number of fields only few of which are actually -used is still efficient. You should thus try to organize your data -as much as possible such that you can use tables where you might be -tempted to use a dictionary. - -Similarly, strings as values should only be used when they are -truely open-ended. If you can, always use an enum instead. - -FlatBuffers doesn't have inheritance, so the way to represent a set -of related data structures is a union. Unions do have a cost however, -so an alternative to a union is to have a single table that has -all the fields of all the data structures you are trying to -represent, if they are relatively similar / share many fields. -Again, this is efficient because optional fields are cheap. - -FlatBuffers supports the full range of integer sizes, so try to pick -the smallest size needed, rather than defaulting to int/long. - -Remember that you can share data (refer to the same string/table -within a buffer), so factoring out repeating data into its own -data structure may be worth it. - -### Style guide - -Identifiers in a schema are meant to translate to many different programming -languages, so using the style of your "main" language is generally a bad idea. - -For this reason, below is a suggested style guide to adhere to, to keep schemas -consistent for interoperation regardless of the target language. - -Where possible, the code generators for specific languages will generate -identifiers that adhere to the language style, based on the schema identifiers. - -- Table, struct, enum and rpc names (types): UpperCamelCase. -- Table and struct field names: snake_case. This is translated to lowerCamelCase - automatically for some languages, e.g. Java. -- Enum values: UpperCamelCase. -- namespaces: UpperCamelCase. - -Formatting (this is less important, but still worth adhering to): - -- Opening brace: on the same line as the start of the declaration. -- Spacing: Indent by 2 spaces. None around `:` for types, on both sides for `=`. - -For an example, see the schema at the top of this file. - -## Gotchas - -### Schemas and version control - -FlatBuffers relies on new field declarations being added at the end, and earlier -declarations to not be removed, but be marked deprecated when needed. We think -this is an improvement over the manual number assignment that happens in -Protocol Buffers (and which is still an option using the `id` attribute -mentioned above). - -One place where this is possibly problematic however is source control. If user -A adds a field, generates new binary data with this new schema, then tries to -commit both to source control after user B already committed a new field also, -and just auto-merges the schema, the binary files are now invalid compared to -the new schema. - -The solution of course is that you should not be generating binary data before -your schema changes have been committed, ensuring consistency with the rest of -the world. If this is not practical for you, use explicit field ids, which -should always generate a merge conflict if two people try to allocate the same -id. - -### Schema evolution examples - -Some examples to clarify what happens as you change a schema: - -If we have the following original schema: - - table { a:int; b:int; } - -And we extend it: - - table { a:int; b:int; c:int; } - -This is ok. Code compiled with the old schema reading data generated with the -new one will simply ignore the presence of the new field. Code compiled with the -new schema reading old data will get the default value for `c` (which is 0 -in this case, since it is not specified). - - table { a:int (deprecated); b:int; } - -This is also ok. Code compiled with the old schema reading newer data will now -always get the default value for `a` since it is not present. Code compiled -with the new schema now cannot read nor write `a` anymore (any existing code -that tries to do so will result in compile errors), but can still read -old data (they will ignore the field). - - table { c:int a:int; b:int; } - -This is NOT ok, as this makes the schemas incompatible. Old code reading newer -data will interpret `c` as if it was `a`, and new code reading old data -accessing `a` will instead receive `b`. - - table { c:int (id: 2); a:int (id: 0); b:int (id: 1); } - -This is ok. If your intent was to order/group fields in a way that makes sense -semantically, you can do so using explicit id assignment. Now we are compatible -with the original schema, and the fields can be ordered in any way, as long as -we keep the sequence of ids. - - table { b:int; } - -NOT ok. We can only remove a field by deprecation, regardless of wether we use -explicit ids or not. - - table { a:uint; b:uint; } - -This is MAYBE ok, and only in the case where the type change is the same size, -like here. If old data never contained any negative numbers, this will be -safe to do. - - table { a:int = 1; b:int = 2; } - -Generally NOT ok. Any older data written that had 0 values were not written to -the buffer, and rely on the default value to be recreated. These will now have -those values appear to `1` and `2` instead. There may be cases in which this -is ok, but care must be taken. - - table { aa:int; bb:int; } - -Occasionally ok. You've renamed fields, which will break all code (and JSON -files!) that use this schema, but as long as the change is obvious, this is not -incompatible with the actual binary buffers, since those only ever address -fields by id/offset. -<br> - -### Testing whether a field is present in a table - -Most serialization formats (e.g. JSON or Protocol Buffers) make it very -explicit in the format whether a field is present in an object or not, -allowing you to use this as "extra" information. - -In FlatBuffers, this also holds for everything except scalar values. - -FlatBuffers by default will not write fields that are equal to the default -value (for scalars), sometimes resulting in a significant space savings. - -However, this also means testing whether a field is "present" is somewhat -meaningless, since it does not tell you if the field was actually written by -calling `add_field` style calls, unless you're only interested in this -information for non-default values. - -Some `FlatBufferBuilder` implementations have an option called `force_defaults` -that circumvents this behavior, and writes fields even if they are equal to -the default. You can then use `IsFieldPresent` to query this. - -Another option that works in all languages is to wrap a scalar field in a -struct. This way it will return null if it is not present. The cool thing -is that structs don't take up any more space than the scalar they represent. - - [Interface Definition Language]: https://en.wikipedia.org/wiki/Interface_description_language
diff --git a/third_party/flatbuffers/docs/source/Support.md b/third_party/flatbuffers/docs/source/Support.md deleted file mode 100755 index 7bc3348..0000000 --- a/third_party/flatbuffers/docs/source/Support.md +++ /dev/null
@@ -1,44 +0,0 @@ -Platform / Language / Feature support {#flatbuffers_support} -===================================== - -FlatBuffers is actively being worked on, which means that certain platform / -language / feature combinations may not be available yet. - -This page tries to track those issues, to make informed decisions easier. -In general: - - * Languages: language support beyond the ones created by the original - FlatBuffer authors typically depends on community contributions. - * Features: C++ was the first language supported, since our original - target was high performance game development. It thus has the richest - feature set, and is likely most robust. Other languages are catching up - however. - * Platforms: All language implementations are typically portable to most - platforms, unless where noted otherwise. - -NOTE: this table is a start, it needs to be extended. - -Feature | C++ | Java | C# | Go | Python | JS | C | PHP | Ruby ------------------------------- | ------ | ------ | ------ | ------ | ------ | --------- | ------ | --- | ---- -Codegen for all basic features | Yes | Yes | Yes | Yes | Yes | Yes | Yes | WiP | WiP -JSON parsing | Yes | No | No | No | No | No | Yes | No | No -Simple mutation | Yes | WIP | WIP | No | No | No | No | No | No -Reflection | Yes | No | No | No | No | No | Basic | No | No -Buffer verifier | Yes | No | No | No | No | No | Yes | No | No -Testing: basic | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? -Testing: fuzz | Yes | No | No | Yes | Yes | No | No | ? | ? -Performance: | Superb | Great | Great | Great | Ok | ? | Superb | ? | ? -Platform: Windows | VS2010 | Yes | Yes | ? | ? | ? | VS2010 | ? | ? -Platform: Linux | GCC282 | Yes | ? | Yes | Yes | ? | Yes | ? | ? -Platform: OS X | Xcode4 | ? | ? | ? | Yes | ? | Yes | ? | ? -Platform: Android | NDK10d | Yes | ? | ? | ? | ? | ? | ? | ? -Platform: iOS | ? | ? | ? | ? | ? | ? | ? | ? | ? -Engine: Unity | ? | ? | Yes | ? | ? | ? | ? | ? | ? -Primary authors (github) | gwvo | gwvo | ev*/js*| rw | rw | evanw/ev* | mik* | ch* | rw - - * ev = evolutional - * js = jonsimantov - * mik = mikkelfj - * ch = chobie - -<br>
diff --git a/third_party/flatbuffers/docs/source/Tutorial.md b/third_party/flatbuffers/docs/source/Tutorial.md deleted file mode 100644 index 7d9c6d9..0000000 --- a/third_party/flatbuffers/docs/source/Tutorial.md +++ /dev/null
@@ -1,1943 +0,0 @@ -Tutorial {#flatbuffers_guide_tutorial} -======== - -## Overview - -This tutorial provides a basic example of how to work with -[FlatBuffers](@ref flatbuffers_overview). We will step through a simple example -application, which shows you how to: - - - Write a FlatBuffer `schema` file. - - Use the `flatc` FlatBuffer compiler. - - Parse [JSON](http://json.org) files that conform to a schema into - FlatBuffer binary files. - - Use the generated files in many of the supported languages (such as C++, - Java, and more.) - -During this example, imagine that you are creating a game where the main -character, the hero of the story, needs to slay some `orc`s. We will walk -through each step necessary to create this monster type using FlatBuffers. - -Please select your desired language for our quest: -\htmlonly -<form> - <input type="radio" name="language" value="cpp" checked="checked">C++</input> - <input type="radio" name="language" value="java">Java</input> - <input type="radio" name="language" value="csharp">C#</input> - <input type="radio" name="language" value="go">Go</input> - <input type="radio" name="language" value="python">Python</input> - <input type="radio" name="language" value="javascript">JavaScript</input> - <input type="radio" name="language" value="php">PHP</input> - <input type="radio" name="language" value="c">C</input> -</form> -\endhtmlonly - -\htmlonly -<script> - /** - * Check if an HTML `class` attribute is in the language-specific format. - * @param {string} languageClass An HTML `class` attribute in the format - * 'language-{lang}', where {lang} is a programming language (e.g. 'cpp', - * 'java', 'go', etc.). - * @return {boolean} Returns `true` if `languageClass` was in the valid - * format, prefixed with 'language-'. Otherwise, it returns false. - */ - function isProgrammingLanguageClassName(languageClass) { - if (languageClass && languageClass.substring(0, 9) == 'language-' && - languageClass.length > 8) { - return true; - } else { - return false; - } - } - - /** - * Given a language-specific HTML `class` attribute, extract the language. - * @param {string} languageClass The string name of an HTML `class` attribute, - * in the format `language-{lang}`, where {lang} is a programming language - * (e.g. 'cpp', 'java', 'go', etc.). - * @return {string} Returns a string containing only the {lang} portion of - * the class name. If the input was invalid, then it returns `null`. - */ - function extractProgrammingLanguageFromLanguageClass(languageClass) { - if (isProgrammingLanguageClassName(languageClass)) { - return languageClass.substring(9); - } else { - return null; - } - } - - /** - * Hide every code snippet, except for the language that is selected. - */ - function displayChosenLanguage() { - var selection = $('input:checked').val(); - - var htmlElements = document.getElementsByTagName('*'); - for (var i = 0; i < htmlElements.length; i++) { - if (isProgrammingLanguageClassName(htmlElements[i].className)) { - if (extractProgrammingLanguageFromLanguageClass( - htmlElements[i].className).toLowerCase() != selection) { - htmlElements[i].style.display = 'none'; - } else { - htmlElements[i].style.display = 'initial'; - } - } - } - } - - $( document ).ready(displayChosenLanguage); - - $('input[type=radio]').on("click", displayChosenLanguage); -</script> -\endhtmlonly - -## Where to Find the Example Code - -Samples demonstating the concepts in this example are located in the source code -package, under the `samples` directory. You can browse the samples on GitHub -[here](https://github.com/google/flatbuffers/tree/master/samples). - -<div class="language-c"> -*Note: The above does not apply to C, instead [look here](https://github.com/dvidelabs/flatcc/tree/master/samples).* -</div> - -For your chosen language, please cross-reference with: - -<div class="language-cpp"> -[sample_binary.cpp](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.cpp) -</div> -<div class="language-java"> -[SampleBinary.java](https://github.com/google/flatbuffers/blob/master/samples/SampleBinary.java) -</div> -<div class="language-csharp"> -[SampleBinary.cs](https://github.com/google/flatbuffers/blob/master/samples/SampleBinary.cs) -</div> -<div class="language-go"> -[sample_binary.go](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.go) -</div> -<div class="language-python"> -[sample_binary.py](https://github.com/google/flatbuffers/blob/master/samples/sample_binary.py) -</div> -<div class="language-javascript"> -[samplebinary.js](https://github.com/google/flatbuffers/blob/master/samples/samplebinary.js) -</div> -<div class="language-php"> -[SampleBinary.php](https://github.com/google/flatbuffers/blob/master/samples/SampleBinary.php) -</div> -<div class="language-c"> -[monster.c](https://github.com/dvidelabs/flatcc/blob/master/samples/monster/monster.c) -</div> - -## Writing the Monsters' FlatBuffer Schema - -To start working with FlatBuffers, you first need to create a `schema` file, -which defines the format for each data structure you wish to serialize. Here is -the `schema` that defines the template for our monsters: - -~~~ - // Example IDL file for our monster's schema. - - namespace MyGame.Sample; - - enum Color:byte { Red = 0, Green, Blue = 2 } - - union Equipment { Weapon } // Optionally add more tables. - - struct Vec3 { - x:float; - y:float; - z:float; - } - - table Monster { - pos:Vec3; // Struct. - mana:short = 150; - hp:short = 100; - name:string; - friendly:bool = false (deprecated); - inventory:[ubyte]; // Vector of scalars. - color:Color = Blue; // Enum. - weapons:[Weapon]; // Vector of tables. - equipped:Equipment; // Union. - } - - table Weapon { - name:string; - damage:short; - } - - root_type Monster; -~~~ - -As you can see, the syntax for the `schema` -[Interface Definition Language (IDL)](https://en.wikipedia.org/wiki/Interface_description_language) -is similar to those of the C family of languages, and other IDL languages. Let's -examine each part of this `schema` to determine what it does. - -The `schema` starts with a `namespace` declaration. This determines the -corresponding package/namespace for the generated code. In our example, we have -the `Sample` namespace inside of the `MyGame` namespace. - -Next, we have an `enum` definition. In this example, we have an `enum` of type -`byte`, named `Color`. We have three values in this `enum`: `Red`, `Green`, and -`Blue`. We specify `Red = 0` and `Blue = 2`, but we do not specify an explicit -value for `Green`. Since the behavior of an `enum` is to increment if -unspecified, `Green` will receive the implicit value of `1`. - -Following the `enum` is a `union`. The `union` in this example is not very -useful, as it only contains the one `table` (named `Weapon`). If we had created -multiple tables that we would want the `union` to be able to reference, we -could add more elements to the `union Equipment`. - -After the `union` comes a `struct Vec3`, which represents a floating point -vector with `3` dimensions. We use a `struct` here, over a `table`, because -`struct`s are ideal for data structures that will not change, since they use -less memory and have faster lookup. - -The `Monster` table is the main object in our FlatBuffer. This will be used as -the template to store our `orc` monster. We specify some default values for -fields, such as `mana:short = 150`. All unspecified fields will default to `0` -or `NULL`. Another thing to note is the line -`friendly:bool = false (deprecated);`. Since you cannot delete fields from a -`table` (to support backwards compatability), you can set fields as -`deprecated`, which will prevent the generation of accessors for this field in -the generated code. Be careful when using `deprecated`, however, as it may break -legacy code that used this accessor. - -The `Weapon` table is a sub-table used within our FlatBuffer. It is -used twice: once within the `Monster` table and once within the `Equipment` -enum. For our `Monster`, it is used to populate a `vector of tables` via the -`weapons` field within our `Monster`. It is also the only table referenced by -the `Equipment` enum. - -The last part of the `schema` is the `root_type`. The root type declares what -will be the root table for the serialized data. In our case, the root type is -our `Monster` table. - -#### More Information About Schemas - -You can find a complete guide to writing `schema` files in the -[Writing a schema](@ref flatbuffers_guide_writing_schema) section of the -Programmer's Guide. You can also view the formal -[Grammar of the schema language](@ref flatbuffers_grammar). - -## Compiling the Monsters' Schema - -After you have written the FlatBuffers schema, the next step is to compile it. - -If you have not already done so, please follow -[these instructions](@ref flatbuffers_guide_building) to build `flatc`, the -FlatBuffer compiler. - -Once `flatc` is built successfully, compile the schema for your language: - -<div class="language-c"> -*Note: If you're working in C, you need to use the separate project [FlatCC](https://github.com/dvidelabs/flatcc) which contains a schema compiler and runtime library in C for C.* -<br> -See [flatcc build instructions](https://github.com/dvidelabs/flatcc#building). -<br> -Please be aware of the difference between `flatc` and `flatcc` tools. -<br> -</div> - -<div class="language-cpp"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --cpp samples/monster.fbs -~~~ -</div> -<div class="language-java"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --java samples/monster.fbs -~~~ -</div> -<div class="language-csharp"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --csharp samples/monster.fbs -~~~ -</div> -<div class="language-go"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --go samples/monster.fbs -~~~ -</div> -<div class="language-python"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --python samples/monster.fbs -~~~ -</div> -<div class="language-javascript"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --javascript samples/monster.fbs -~~~ -</div> -<div class="language-php"> -~~~{.sh} - cd flatbuffers/sample - ./../flatc --php samples/monster.fbs -~~~ -</div> -<div class="language-c"> -~~~{.sh} - cd flatcc - mkdir -p build/tmp/samples/monster - bin/flatcc -a -o build/tmp/samples/monster samples/monster/monster.fbs - # or just - flatcc/samples/monster/build.sh -~~~ -</div> - -For a more complete guide to using the `flatc` compiler, please read the -[Using the schema compiler](@ref flatbuffers_guide_using_schema_compiler) -section of the Programmer's Guide. - -## Reading and Writing Monster FlatBuffers - -Now that we have compiled the schema for our programming language, we can -start creating some monsters and serializing/deserializing them from -FlatBuffers. - -#### Creating and Writing Orc FlatBuffers - -The first step is to import/include the library, generated files, etc. - -<div class="language-cpp"> -~~~{.cpp} - #include "monster_generate.h" // This was generated by `flatc`. - - using namespace MyGame::Sample; // Specified in the schema. -~~~ -</div> -<div class="language-java"> -~~~{.java} - import MyGame.Sample.*; //The `flatc` generated files. (Monster, Vec3, etc.) - - import com.google.flatbuffers.FlatBufferBuilder; -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - using FlatBuffers; - using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.) -~~~ -</div> -<div class="language-go"> -~~~{.go} - import ( - flatbuffers "github.com/google/flatbuffers/go" - sample "MyGame/Sample" - ) -~~~ -</div> -<div class="language-python"> -~~~{.py} - import flatbuffers - - # Generated by `flatc`. - import MyGame.Sample.Color - import MyGame.Sample.Equipment - import MyGame.Sample.Monster - import MyGame.Sample.Vec3 - import MyGame.Sample.Weapon -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // The following code is for JavaScript module loaders (e.g. Node.js). See - // below for a browser-based HTML/JavaScript example of including the library. - var flatbuffers = require('/js/flatbuffers').flatbuffers; - var MyGame = require('./monster_generated').MyGame; // Generated by `flatc`. - - //--------------------------------------------------------------------------// - - // The following code is for browser-based HTML/JavaScript. Use the above code - // for JavaScript module loaders (e.g. Node.js). - <script src="../js/flatbuffers.js"></script> - <script src="monster_generated.js"></script> // Generated by `flatc`. -~~~ -</div> -<div class="language-php"> -~~~{.php} - // It is recommended that your use PSR autoload when using FlatBuffers in PHP. - // Here is an example from `SampleBinary.php`: - function __autoload($class_name) { - // The last segment of the class name matches the file name. - $class = substr($class_name, strrpos($class_name, "\\") + 1); - $root_dir = join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)))); // `flatbuffers` root. - - // Contains the `*.php` files for the FlatBuffers library and the `flatc` generated files. - $paths = array(join(DIRECTORY_SEPARATOR, array($root_dir, "php")), - join(DIRECTORY_SEPARATOR, array($root_dir, "samples", "MyGame", "Sample"))); - foreach ($paths as $path) { - $file = join(DIRECTORY_SEPARATOR, array($path, $class . ".php")); - if (file_exists($file)) { - require($file); - break; - } - } - } -~~~ -</div> -<div class="language-c"> -~~~{.c} - #include "monster_builder.h" // Generated by `flatcc`. - - // Convenient namespace macro to manage long namespace prefix. - #undef ns - #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(MyGame_Sample, x) // Specified in the schema. - - // A helper to simplify creating vectors from C-arrays. - #define c_vec_len(V) (sizeof(V)/sizeof((V)[0])) -~~~ -</div> - -Now we are ready to start building some buffers. In order to start, we need -to create an instance of the `FlatBufferBuilder`, which will contain the buffer -as it grows. You can pass an initial size of the buffer (here 1024 bytes), -which will grow automatically if needed: - -<div class="language-cpp"> -~~~{.cpp} - // Create a `FlatBufferBuilder`, which will be used to create our - // monsters' FlatBuffers. - flatbuffers::FlatBufferBuilder builder(1024); -~~~ -</div> -<div class="language-java"> -~~~{.java} - // Create a `FlatBufferBuilder`, which will be used to create our - // monsters' FlatBuffers. - FlatBufferBuilder builder = new FlatBufferBuilder(1024); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // Create a `FlatBufferBuilder`, which will be used to create our - // monsters' FlatBuffers. - var builder = new FlatBufferBuilder(1024); -~~~ -</div> -<div class="language-go"> -~~~{.go} - // Create a `FlatBufferBuilder`, which will be used to create our - // monsters' FlatBuffers. - builder := flatbuffers.NewBuilder(1024) -~~~ -</div> -<div class="language-python"> -~~~{.py} - # Create a `FlatBufferBuilder`, which will be used to create our - # monsters' FlatBuffers. - builder = flatbuffers.Builder(1024) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // Create a `flatbuffer.Builder`, which will be used to create our - // monsters' FlatBuffers. - var builder = new flatbuffers.Builder(1024); -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Create a `FlatBufferBuilder`, which will be used to create our - // monsters' FlatBuffers. - $builder = new Google\FlatBuffers\FlatbufferBuilder(1024); -~~~ -</div> -<div class="language-c"> -~~~{.c} - flatcc_builder_t builder, *B; - B = &builder; - // Initialize the builder object. - flatcc_builder_init(B); -~~~ -</div> - -After creating the `builder`, we can start serializing our data. Before we make -our `orc` Monster, lets create some `Weapon`s: a `Sword` and an `Axe`. - -<div class="language-cpp"> -~~~{.cpp} - auto weapon_one_name = builder.CreateString("Sword"); - short weapon_one_damage = 3; - - auto weapon_two_name = builder.CreateString("Axe"); - short weapon_two_damage = 5; - - // Use the `CreateWeapon` shortcut to create Weapons with all the fields set. - auto sword = CreateWeapon(builder, weapon_one_name, weapon_one_damage); - auto axe = CreateWeapon(builder, weapon_two_name, weapon_two_damage); -~~~ -</div> -<div class="language-java"> -~~~{.java} - int weaponOneName = builder.createString("Sword") - short weaponOneDamage = 3; - - int weaponTwoName = builder.createString("Axe"); - short weaponTwoDamage = 5; - - // Use the `createWeapon()` helper function to create the weapons, since we set every field. - int sword = Weapon.createWeapon(builder, weaponOneName, weaponOneDamage); - int axe = Weapon.createWeapon(builder, weaponTwoName, weaponTwoDamage); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - var weaponOneName = builder.CreateString("Sword"); - var weaponOneDamage = 3; - - var weaponTwoName = builder.CreateString("Axe"); - var weaponTwoDamage = 5; - - // Use the `CreateWeapon()` helper function to create the weapons, since we set every field. - var sword = Weapon.CreateWeapon(builder, weaponOneName, (short)weaponOneDamage); - var axe = Weapon.CreateWeapon(builder, weaponTwoName, (short)weaponTwoDamage); -~~~ -</div> -<div class="language-go"> -~~~{.go} - weaponOne := builder.CreateString("Sword") - weaponTwo := builder.CreateString("Axe") - - // Create the first `Weapon` ("Sword"). - sample.WeaponStart(builder) - sample.Weapon.AddName(builder, weaponOne) - sample.Weapon.AddDamage(builder, 3) - sword := sample.WeaponEnd(builder) - - // Create the second `Weapon` ("Axe"). - sample.WeaponStart(builder) - sample.Weapon.AddName(builder, weaponTwo) - sample.Weapon.AddDamage(builder, 5) - axe := sample.WeaponEnd(builder) -~~~ -</div> -<div class="language-python"> -~~~{.py} - weapon_one = builder.CreateString('Sword') - weapon_two = builder.CreateString('Axe') - - # Create the first `Weapon` ('Sword'). - MyGame.Sample.Weapon.WeaponStart(builder) - MyGame.Sample.Weapon.WeaponAddName(builder, weapon_one) - MyGame.Sample.Weapon.WeaponAddDamage(builder, 3) - sword = MyGame.Sample.Weapon.WeaponEnd(builder) - - # Create the second `Weapon` ('Axe'). - MyGame.Sample.Weapon.WeaponStart(builder) - MyGame.Sample.Weapon.WeaponAddName(builder, weapon_two) - MyGame.Sample.Weapon.WeaponAddDamage(builder, 5) - axe = MyGame.Sample.Weapon.WeaponEnd(builder) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var weaponOne = builder.createString('Sword'); - var weaponTwo = builder.createString('Axe'); - - // Create the first `Weapon` ('Sword'). - MyGame.Sample.Weapon.startWeapon(builder); - MyGame.Sample.Weapon.addName(builder, weaponOne); - MyGame.Sample.Weapon.addDamage(builder, 3); - var sword = MyGame.Sample.Weapon.endWeapon(builder); - - // Create the second `Weapon` ('Axe'). - MyGame.Sample.Weapon.startWeapon(builder); - MyGame.Sample.Weapon.addName(builder, weaponTwo); - MyGame.Sample.Weapon.addDamage(builder, 5); - var axe = MyGame.Sample.Weapon.endWeapon(builder); -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Create the `Weapon`s using the `createWeapon()` helper function. - $weapon_one_name = $builder->createString("Sword"); - $sword = \MyGame\Sample\Weapon::CreateWeapon($builder, $weapon_one_name, 3); - - $weapon_two_name = $builder->createString("Axe"); - $axe = \MyGame\Sample\Weapon::CreateWeapon($builder, $weapon_two_name, 5); - - // Create an array from the two `Weapon`s and pass it to the - // `CreateWeaponsVector()` method to create a FlatBuffer vector. - $weaps = array($sword, $axe); - $weapons = \MyGame\Sample\Monster::CreateWeaponsVector($builder, $weaps); -~~~ -</div> -<div class="language-c"> -~~~{.c} - ns(Weapon_ref_t) weapon_one_name = flatbuffers_string_create_str(B, "Sword"); - uint16_t weapon_one_damage = 3; - - ns(Weapon_ref_t) weapon_two_name = flatbuffers_string_create_str(B, "Axe"); - uint16_t weapon_two_damage = 5; - - ns(Weapon_ref_t) sword = ns(Weapon_create(B, weapon_one_name, weapon_one_damage)); - ns(Weapon_ref_t) axe = ns(Weapon_create(B, weapon_two_name, weapon_two_damage)); -~~~ -</div> - -Now let's create our monster, the `orc`. For this `orc`, lets make him -`red` with rage, positioned at `(1.0, 2.0, 3.0)`, and give him -a large pool of hit points with `300`. We can give him a vector of weapons -to choose from (our `Sword` and `Axe` from earlier). In this case, we will -equip him with the `Axe`, since it is the most powerful of the two. Lastly, -let's fill his inventory with some potential treasures that can be taken once he -is defeated. - -Before we serialize a monster, we need to first serialize any objects that are -contained there-in, i.e. we serialize the data tree using depth-first, pre-order -traversal. This is generally easy to do on any tree structures. - -<div class="language-cpp"> -~~~{.cpp} - // Serialize a name for our monster, called "Orc". - auto name = builder.CreateString("Orc"); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - unsigned char treasure = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto inventory = builder.CreateVector(treasure, 10); -~~~ -</div> -<div class="language-java"> -~~~{.java} - // Serialize a name for our monster, called "Orc". - int name = builder.createString("Orc"); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - byte[] treasure = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - int inv = Monster.createInventoryVector(builder, treasure); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // Serialize a name for our monster, called "Orc". - var name = builder.CreateString("Orc"); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - // Note: Since we prepend the bytes, this loop iterates in reverse order. - Monster.StartInventoryVector(builder, 10); - for (int i = 9; i >= 0; i--) - { - builder.AddByte((byte)i); - } - var inv = builder.EndVector(); -~~~ -</div> -<div class="language-go"> -~~~{.go} - // Serialize a name for our monster, called "Orc". - name := builder.CreateString("Orc") - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - // Note: Since we prepend the bytes, this loop iterates in reverse. - sample.MonsterStartInventoryVector(builder, 10) - for i := 9; i >= 0; i-- { - builder.PrependByte(byte(i)) - } - int := builder.EndVector(10) -~~~ -</div> -<div class="language-python"> -~~~{.py} - # Serialize a name for our monster, called "Orc". - name = builder.CreateString("Orc") - - # Create a `vector` representing the inventory of the Orc. Each number - # could correspond to an item that can be claimed after he is slain. - # Note: Since we prepend the bytes, this loop iterates in reverse. - MyGame.Sample.Monster.MonsterStartInventoryVector(builder, 10) - for i in reversed(range(0, 10)): - builder.PrependByte(i) - inv = builder.EndVector(10) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // Serialize a name for our monster, called 'Orc'. - var name = builder.createString('Orc'); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - var treasure = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - var inv = MyGame.Sample.Monster.createInventoryVector(builder, treasure); -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Serialize a name for our monster, called "Orc". - $name = $builder->createString("Orc"); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - $treasure = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); - $inv = \MyGame\Sample\Monster::CreateInventoryVector($builder, $treasure); -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Serialize a name for our monster, called "Orc". - // The _str suffix indicates the source is an ascii-z string. - flatbuffers_string_ref_t name = flatbuffers_string_create_str(B, "Orc"); - - // Create a `vector` representing the inventory of the Orc. Each number - // could correspond to an item that can be claimed after he is slain. - uint8_t treasure[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - flatbuffers_uint8_vec_ref_t inventory; - // `c_vec_len` is the convenience macro we defined earlier. - inventory = flatbuffers_uint8_vec_create(B, treasure, c_vec_len(treasure)); -~~~ -</div> - -We serialized two built-in data types (`string` and `vector`) and captured -their return values. These values are offsets into the serialized data, -indicating where they are stored, such that we can refer to them below when -adding fields to our monster. - -*Note: To create a `vector` of nested objects (e.g. `table`s, `string`s, or -other `vector`s), collect their offsets into a temporary data structure, and -then create an additional `vector` containing their offsets.* - -For example, take a look at the two `Weapon`s that we created earlier (`Sword` -and `Axe`). These are both FlatBuffer `table`s, whose offsets we now store in -memory. Therefore we can create a FlatBuffer `vector` to contain these -offsets. - -<div class="language-cpp"> -~~~{.cpp} - // Place the weapons into a `std::vector`, then convert that into a FlatBuffer `vector`. - std::vector<flatbuffers::Offset<Weapon>> weapons_vector; - weapons_vector.push_back(sword); - weapons_vector.push_back(axe); - auto weapons = builder.CreateVector(weapons_vector); -~~~ -</div> -<div class="language-java"> -~~~{.java} - // Place the two weapons into an array, and pass it to the `createWeaponsVector()` method to - // create a FlatBuffer vector. - int[] weaps = new int[2]; - weaps[0] = sword; - weaps[1] = axe; - - // Pass the `weaps` array into the `createWeaponsVector()` method to create a FlatBuffer vector. - int weapons = Monster.createWeaponsVector(builder, weaps); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - var weaps = new Offset<Weapon>[2]; - weaps[0] = sword; - weaps[1] = axe; - - // Pass the `weaps` array into the `CreateWeaponsVector()` method to create a FlatBuffer vector. - var weapons = Monster.CreateWeaponsVector(builder, weaps); -~~~ -</div> -<div class="language-go"> -~~~{.go} - // Create a FlatBuffer vector and prepend the weapons. - // Note: Since we prepend the data, prepend them in reverse order. - sample.MonsterStartWeaponsVector(builder, 2) - builder.PrependUOffsetT(axe) - builder.PrependUOffsetT(sword) - weapons := builder.EndVector(2) -~~~ -</div> -<div class="language-python"> -~~~{.py} - # Create a FlatBuffer vector and prepend the weapons. - # Note: Since we prepend the data, prepend them in reverse order. - MyGame.Sample.Monster.MonsterStartWeaponsVector(builder, 2) - builder.PrependUOffsetTRelative(axe) - builder.PrependUOffsetTRelative(sword) - weapons = builder.EndVector(2) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // Create an array from the two `Weapon`s and pass it to the - // `createWeaponsVector()` method to create a FlatBuffer vector. - var weaps = [sword, axe]; - var weapons = MyGame.Sample.Monster.createWeaponsVector(builder, weaps); -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Create an array from the two `Weapon`s and pass it to the - // `CreateWeaponsVector()` method to create a FlatBuffer vector. - $weaps = array($sword, $axe); - $weapons = \MyGame\Sample\Monster::CreateWeaponsVector($builder, $weaps); -~~~ -</div> -<div class="language-c"> -~~~{.c} - // We use the internal builder stack to implement a dynamic vector. - ns(Weapon_vec_start(B)); - ns(Weapon_vec_push(B, sword)); - ns(Weapon_vec_push(B, axe)); - ns(Weapon_vec_ref_t) weapons = ns(Weapon_vec_end(B)); -~~~ -</div> - -<div class="language-cpp"> -<br> -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<std::string>` -there's also `CreateVectorOfStrings`. -</div> - -We have now serialized the non-scalar components of the orc, so we -can serialize the monster itself: - -<div class="language-cpp"> -~~~{.cpp} - // Set his hit points to 300 and his mana to 150. - int hp = 300; - int mana = 150; - - // Finally, create the monster using the `CreateMonster` helper function - // to set all fields. - auto orc = CreateMonster(builder, Vec3(1.0f, 2.0f, 3.0f), mana, hp, name, - inventory, Color_Red, weapons, Equipment_Weapon, - axe.Union()); -~~~ -</div> -<div class="language-java"> -~~~{.java} - // Create our monster using `startMonster()` and `endMonster()`. - Monster.startMonster(builder); - Monster.addPos(builder, Vec3.createVec3(builder, 1.0f, 2.0f, 3.0f)); - Monster.addName(builder, name); - Monster.addColor(builder, Color.Red); - Monster.addHp(builder, (short)300); - Monster.addInventory(builder, inv); - Monster.addWeapons(builder, weapons); - Monster.addEquippedType(builder, Equipment.Weapon); - Monster.addEquipped(builder, axe); - int orc = Monster.endMonster(builder); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // Create our monster using `StartMonster()` and `EndMonster()`. - Monster.StartMonster(builder); - Monster.AddPos(builder, Vec3.CreateVec3(builder, 1.0f, 2.0f, 3.0f)); - Monster.AddHp(builder, (short)300); - Monster.AddName(builder, name); - Monster.AddInventory(builder, inv); - Monster.AddColor(builder, Color.Red); - Monster.AddWeapons(builder, weapons); - Monster.AddEquippedType(builder, Equipment.Weapon); - Monster.AddEquipped(builder, axe.Value); // Axe - var orc = Monster.EndMonster(builder); -~~~ -</div> -<div class="language-go"> -~~~{.go} - // Create our monster using `MonsterStart()` and `MonsterEnd()`. - sample.MonsterStart(builder) - sample.MonsterAddPos(builder, sample.CreateVec3(builder, 1.0, 2.0, 3.0)) - sample.MonsterAddHp(builder, 300) - sample.MonsterAddName(builder, name) - sample.MonsterAddInventory(builder, inv) - sample.MonsterAddColor(builder, sample.ColorRed) - sample.MonsterAddWeapons(builder, weapons) - sample.MonsterAddEquippedType(builder, sample.EquipmentWeapon) - sample.MonsterAddEquipped(builder, axe) - orc := sample.MonsterEnd(builder) -~~~ -</div> -<div class="language-python"> -~~~{.py} - # Create our monster by using `MonsterStart()` and `MonsterEnd()`. - MyGame.Sample.Monster.MonsterStart(builder) - MyGame.Sample.Monster.MonsterAddPos(builder, - MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0)) - MyGame.Sample.Monster.MonsterAddHp(builder, 300) - MyGame.Sample.Monster.MonsterAddName(builder, name) - MyGame.Sample.Monster.MonsterAddInventory(builder, inv) - MyGame.Sample.Monster.MonsterAddColor(builder, - MyGame.Sample.Color.Color().Red) - MyGame.Sample.Monster.MonsterAddWeapons(builder, weapons) - MyGame.Sample.Monster.MonsterAddEquippedType( - builder, MyGame.Sample.Equipment.Equipment().Weapon) - MyGame.Sample.Monster.MonsterAddEquipped(builder, axe) - orc = MyGame.Sample.Monster.MonsterEnd(builder) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // Create our monster by using `startMonster()` and `endMonster()`. - MyGame.Sample.Monster.startMonster(builder); - MyGame.Sample.Monster.addPos(builder, - MyGame.Sample.Vec3.createVec3(builder, 1.0, 2.0, 3.0)); - MyGame.Sample.Monster.addHp(builder, 300); - MyGame.Sample.Monster.addColor(builder, MyGame.Sample.Color.Red) - MyGame.Sample.Monster.addName(builder, name); - MyGame.Sample.Monster.addInventory(builder, inv); - MyGame.Sample.Monster.addWeapons(builder, weapons); - MyGame.Sample.Monster.addEquippedType(builder, MyGame.Sample.Equipment.Weapon); - MyGame.Sample.Monster.addEquipped(builder, axe); - var orc = MyGame.Sample.Monster.endMonster(builder); -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Create our monster by using `StartMonster()` and `EndMonster()`. - \MyGame\Sample\Monster::StartMonster($builder); - \MyGame\Sample\Monster::AddPos($builder, - \MyGame\Sample\Vec3::CreateVec3($builder, 1.0, 2.0, 3.0)); - \MyGame\Sample\Monster::AddHp($builder, 300); - \MyGame\Sample\Monster::AddName($builder, $name); - \MyGame\Sample\Monster::AddInventory($builder, $inv); - \MyGame\Sample\Monster::AddColor($builder, \MyGame\Sample\Color::Red); - \MyGame\Sample\Monster::AddWeapons($builder, $weapons); - \MyGame\Sample\Monster::AddEquippedType($builder, \MyGame\Sample\Equipment::Weapon); - \MyGame\Sample\Monster::AddEquipped($builder, $axe); - $orc = \MyGame\Sample\Monster::EndMonster($builder); -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Set his hit points to 300 and his mana to 150. - uint16_t hp = 300; - uint16_t mana = 150; - - // Define an equipment union. `create` calls in C has a single - // argument for unions where C++ has both a type and a data argument. - ns(Equipment_union_ref_t) equipped = ns(Equipment_as_Weapon(axe)); - ns(Vec3_t) pos = { 1.0f, 2.0f, 3.0f }; - ns(Monster_create_as_root(B, &pos, mana, hp, name, inventory, ns(Color_Red), - weapons, equipped)); -~~~ -</div> - -Note how we create `Vec3` struct in-line in the table. Unlike tables, structs -are simple combinations of scalars that are always stored inline, just like -scalars themselves. - -**Important**: you should not nest tables or any other objects, which is why -we created all the strings/vectors/tables that this monster refers to before -`start`. If you try to create any of them between `start` and `end`, you -will get an assert/exception/panic depending on your language. - -*Note: Since we are passing `150` as the `mana` field, which happens to be the -default value, the field will not actually be written to the buffer, since the -default value will be returned on query anyway. This is a nice space savings, -especially if default values are common in your data. It also means that you do -not need to be worried of adding a lot of fields that are only used in a small -number of instances, as it will not bloat the buffer if unused.* - -<div class="language-cpp"> -<br> -If you do not wish to set every field in a `table`, it may be more convenient to -manually set each field of your monster, instead of calling `CreateMonster()`. -The following snippet is functionally equivalent to the above code, but provides -a bit more flexibility. -<br> -~~~{.cpp} - // You can use this code instead of `CreateMonster()`, to create our orc - // manually. - MonsterBuilder monster_builder(builder); - monster_builder.add_pos(&pos); - monster_builder.add_hp(hp); - monster_builder.add_name(name); - monster_builder.add_inventory(inventory); - monster_builder.add_color(Color_Red); - monster_builder.add_weapons(weapons); - monster_builder.add_equipped_type(Equipment_Weapon); - monster_builder.add_equpped(axe); - auto orc = monster_builder.Finish(); -~~~ -</div> -<div class="language-c"> -If you do not wish to set every field in a `table`, it may be more convenient to -manually set each field of your monster, instead of calling `create_monster_as_root()`. -The following snippet is functionally equivalent to the above code, but provides -a bit more flexibility. -<br> -~~~{.c} - // It is important to pair `start_as_root` with `end_as_root`. - ns(Monster_start_as_root(B)); - ns(Monster_pos_create(B, 1.0f, 2.0f, 3.0f)); - // or alternatively - //ns(Monster_pos_add(&pos); - - ns(Monster_hp_add(B, hp)); - // Notice that `Monser_name_add` adds a string reference unlike the - // add_str and add_strn variants. - ns(Monster_name_add(B, name)); - ns(Monster_inventory_add(B, inventory)); - ns(Monster_color_add(B, ns(Color_Red))); - ns(Monster_weapons_add(B, weapons)); - ns(Monster_equipped_add(B, equipped)); - // Complete the monster object and make it the buffer root object. - ns(Monster_end_as_root(B)); -~~~ -</div> - -Before finishing the serialization, let's take a quick look at FlatBuffer -`union Equipped`. There are two parts to each FlatBuffer `union`. The first, is -a hidden field `_type`, that is generated to hold the type of `table` referred -to by the `union`. This allows you to know which type to cast to at runtime. -Second, is the `union`'s data. - -In our example, the last two things we added to our `Monster` were the -`Equipped Type` and the `Equipped` union itself. - -Here is a repetition these lines, to help highlight them more clearly: - -<div class="language-cpp"> - ~~~{.cpp} - monster_builder.add_equipped_type(Equipment_Weapon); // Union type - monster_builder.add_equipped(axe); // Union data - ~~~ -</div> -<div class="language-java"> - ~~~{.java} - Monster.addEquippedType(builder, Equipment.Weapon); // Union type - Monster.addEquipped(axe); // Union data - ~~~ -</div> -<div class="language-csharp"> - ~~~{.cs} - Monster.AddEquippedType(builder, Equipment.Weapon); // Union type - Monster.AddEquipped(builder, axe.Value); // Union data - ~~~ -</div> -<div class="language-go"> - ~~~{.go} - sample.MonsterAddEquippedType(builder, sample.EquipmentWeapon) // Union type - sample.MonsterAddEquipped(builder, axe) // Union data - ~~~ -</div> -<div class="language-python"> - ~~~{.py} - MyGame.Sample.Monster.MonsterAddEquippedType( # Union type - builder, MyGame.Sample.Equipment.Equipment().Weapon) - MyGame.Sample.Monster.MonsterAddEquipped(builder, axe) # Union data - ~~~ -</div> -<div class="language-javascript"> - ~~~{.js} - MyGame.Sample.Monster.addEquippedType(builder, MyGame.Sample.Equipment.Weapon); // Union type - MyGame.Sample.Monster.addEquipped(builder, axe); // Union data - ~~~ -</div> -<div class="language-php"> - ~~~{.php} - \MyGame\Sample\Monster::AddEquippedType($builder, \MyGame\Sample\Equipment::Weapon); // Union type - \MyGame\Sample\Monster::AddEquipped($builder, $axe); // Union data - ~~~ -</div> -<div class="language-c"> -~~~{.c} - // Add union type and data simultanously. - ns(Monster_equipped_Weapon_add(B, axe)); -~~~ -</div> - -After you have created your buffer, you will have the offset to the root of the -data in the `orc` variable, so you can finish the buffer by calling the -appropriate `finish` method. - - -<div class="language-cpp"> -~~~{.cpp} - // Call `Finish()` to instruct the builder that this monster is complete. - // Note: Regardless of how you created the `orc`, you still need to call - // `Finish()` on the `FlatBufferBuilder`. - builder.Finish(orc); // You could also call `FinishMonsterBuffer(builder, - // orc);`. -~~~ -</div> -<div class="language-java"> -~~~{.java} - // Call `finish()` to instruct the builder that this monster is complete. - builder.finish(orc); // You could also call `Monster.finishMonsterBuffer(builder, orc);`. -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // Call `Finish()` to instruct the builder that this monster is complete. - builder.Finish(orc.Value); // You could also call `Monster.FinishMonsterBuffer(builder, orc);`. -~~~ -</div> -<div class="language-go"> -~~~{.go} - // Call `Finish()` to instruct the builder that this monster is complete. - builder.Finish(orc) -~~~ -</div> -<div class="language-python"> -~~~{.py} - # Call `Finish()` to instruct the builder that this monster is complete. - builder.Finish(orc) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // Call `finish()` to instruct the builder that this monster is complete. - builder.finish(orc); // You could also call `MyGame.Example.Monster.finishMonsterBuffer(builder, - // orc);`. -~~~ -</div> -<div class="language-php"> -~~~{.php} - // Call `finish()` to instruct the builder that this monster is complete. - $builder->finish($orc); // You may also call `\MyGame\Sample\Monster::FinishMonsterBuffer( - // $builder, $orc);`. -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Because we used `Monster_create_as_root`, we do not need a `finish` call in C`. -~~~ -</div> - -The buffer is now ready to be stored somewhere, sent over the network, be -compressed, or whatever you'd like to do with it. You can access the buffer -like so: - -<div class="language-cpp"> -~~~{.cpp} - // This must be called after `Finish()`. - uint8_t *buf = builder.GetBufferPointer(); - int size = builder.GetSize(); // Returns the size of the buffer that - // `GetBufferPointer()` points to. -~~~ -</div> -<div class="language-java"> -~~~{.java} - // This must be called after `finish()`. - java.nio.ByteBuffer buf = builder.dataBuffer(); - // The data in this ByteBuffer does NOT start at 0, but at buf.position(). - // The number of bytes is buf.remaining(). - - // Alternatively this copies the above data out of the ByteBuffer for you: - bytes[] buf = builder.sizedByteArray(); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // This must be called after `Finish()`. - var buf = builder.DataBuffer; // Of type `FlatBuffers.ByteBuffer`. - // The data in this ByteBuffer does NOT start at 0, but at buf.Position. - // The end of the data is marked by buf.Length, so the size is - // buf.Length - buf.Position. - - // Alternatively this copies the above data out of the ByteBuffer for you: - bytes[] buf = builder.SizedByteArray(); -~~~ -</div> -<div class="language-go"> -~~~{.go} - // This must be called after `Finish()`. - buf := builder.FinishedBytes() // Of type `byte[]`. -~~~ -</div> -<div class="language-python"> -~~~{.py} - # This must be called after `Finish()`. - buf = builder.Output() // Of type `bytearray`. -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // This must be called after `finish()`. - var buf = builder.asUint8Array(); // Of type `Uint8Array`. -~~~ -</div> -<div class="language-php"> -~~~{.php} - // This must be called after `finish()`. - $buf = $builder->dataBuffer(); // Of type `Google\FlatBuffers\ByteBuffer` - // The data in this ByteBuffer does NOT start at 0, but at buf->getPosition(). - // The end of the data is marked by buf->capacity(), so the size is - // buf->capacity() - buf->getPosition(). -~~~ -</div> -<div class="language-c"> -~~~{.c} - uint8_t *buf; - size_t size; - - // Allocate and extract a readable buffer from internal builder heap. - // The returned buffer must be deallocated using `free`. - // NOTE: Finalizing the buffer does NOT change the builder, it - // just creates a snapshot of the builder content. - buf = flatcc_builder_finalize_buffer(B, &size); - // use buf - free(buf); - - // Optionally reset builder to reuse builder without deallocating - // internal stack and heap. - flatcc_builder_reset(B); - // build next buffer. - // ... - - // Cleanup. - flatcc_builder_clear(B); -~~~ -</div> - -Now you can write the bytes to a file, send them over the network.. -**Make sure your file mode (or tranfer protocol) is set to BINARY, not text.** -If you transfer a FlatBuffer in text mode, the buffer will be corrupted, -which will lead to hard to find problems when you read the buffer. - -#### Reading Orc FlatBuffers - -Now that we have successfully created an `Orc` FlatBuffer, the monster data can -be saved, sent over a network, etc. Let's now adventure into the inverse, and -deserialize a FlatBuffer. - -This section requires the same import/include, namespace, etc. requirements as -before: - -<div class="language-cpp"> -~~~{.cpp} - #include "monster_generate.h" // This was generated by `flatc`. - - using namespace MyGame::Sample; // Specified in the schema. -~~~ -</div> -<div class="language-java"> -~~~{.java} - import MyGame.Sample.*; //The `flatc` generated files. (Monster, Vec3, etc.) - - import com.google.flatbuffers.FlatBufferBuilder; -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - using FlatBuffers; - using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.) -~~~ -</div> -<div class="language-go"> -~~~{.go} - import ( - flatbuffers "github.com/google/flatbuffers/go" - sample "MyGame/Sample" - ) -~~~ -</div> -<div class="language-python"> -~~~{.py} - import flatbuffers - - # Generated by `flatc`. - import MyGame.Sample.Any - import MyGame.Sample.Color - import MyGame.Sample.Monster - import MyGame.Sample.Vec3 -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - // The following code is for JavaScript module loaders (e.g. Node.js). See - // below for a browser-based HTML/JavaScript example of including the library. - var flatbuffers = require('/js/flatbuffers').flatbuffers; - var MyGame = require('./monster_generated').MyGame; // Generated by `flatc`. - - //--------------------------------------------------------------------------// - - // The following code is for browser-based HTML/JavaScript. Use the above code - // for JavaScript module loaders (e.g. Node.js). - <script src="../js/flatbuffers.js"></script> - <script src="monster_generated.js"></script> // Generated by `flatc`. -~~~ -</div> -<div class="language-php"> -~~~{.php} - // It is recommended that your use PSR autoload when using FlatBuffers in PHP. - // Here is an example from `SampleBinary.php`: - function __autoload($class_name) { - // The last segment of the class name matches the file name. - $class = substr($class_name, strrpos($class_name, "\\") + 1); - $root_dir = join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)))); // `flatbuffers` root. - - // Contains the `*.php` files for the FlatBuffers library and the `flatc` generated files. - $paths = array(join(DIRECTORY_SEPARATOR, array($root_dir, "php")), - join(DIRECTORY_SEPARATOR, array($root_dir, "samples", "MyGame", "Sample"))); - foreach ($paths as $path) { - $file = join(DIRECTORY_SEPARATOR, array($path, $class . ".php")); - if (file_exists($file)) { - require($file); - break; - } - } - } -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Only needed if we don't have `#include "monster_builder.h"`. - #include "monster_reader.h" - - #undef ns - #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(MyGame_Sample, x) // Specified in the schema. -~~~ -</div> - -Then, assuming you have a buffer of bytes received from disk, -network, etc., you can create start accessing the buffer like so: - -**Again, make sure you read the bytes in BINARY mode, otherwise the code below -won't work** - -<div class="language-cpp"> -~~~{.cpp} - uint8_t *buffer_pointer = /* the data you just read */; - - // Get a pointer to the root object inside the buffer. - auto monster = GetMonster(buffer_pointer); - - // `monster` is of type `Monster *`. - // Note: root object pointers are NOT the same as `buffer_pointer`. -~~~ -</div> -<div class="language-java"> -~~~{.java} - byte[] bytes = /* the data you just read */ - java.nio.ByteBuffer buf = java.nio.ByteBuffer.wrap(bytes); - - // Get an accessor to the root object inside the buffer. - Monster monster = Monster.getRootAsMonster(buf); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - byte[] bytes = /* the data you just read */ - var buf = new ByteBuffer(bytes); - - // Get an accessor to the root object inside the buffer. - var monster = Monster.GetRootAsMonster(buf); -~~~ -</div> -<div class="language-go"> -~~~{.go} - var buf []byte = /* the data you just read */ - - // Get an accessor to the root object inside the buffer. - monster := sample.GetRootAsMonster(buf, 0) - - // Note: We use `0` for the offset here, which is typical for most buffers - // you would read. If you wanted to read from `builder.Bytes` directly, you - // would need to pass in the offset of `builder.Head()`, as the builder - // constructs the buffer backwards, so may not start at offset 0. -~~~ -</div> -<div class="language-python"> -~~~{.py} - buf = /* the data you just read, in an object of type "bytearray" */ - - // Get an accessor to the root object inside the buffer. - monster = MyGame.Sample.Monster.Monster.GetRootAsMonster(buf, 0) - - # Note: We use `0` for the offset here, which is typical for most buffers - # you would read. If you wanted to read from the `builder.Bytes` directly, - # you would need to pass in the offset of `builder.Head()`, as the builder - # constructs the buffer backwards, so may not start at offset 0. -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var bytes = /* the data you just read, in an object of type "Uint8Array" */ - var buf = new flatbuffers.ByteBuffer(bytes); - - // Get an accessor to the root object inside the buffer. - var monster = MyGame.Sample.Monster.getRootAsMonster(buf); -~~~ -</div> -<div class="language-php"> -~~~{.php} - $bytes = /* the data you just read, in a string */ - $buf = Google\FlatBuffers\ByteBuffer::wrap($bytes); - - // Get an accessor to the root object inside the buffer. - $monster = \MyGame\Sample\Monster::GetRootAsMonster($buf); -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Note that we use the `table_t` suffix when reading a table object - // as opposed to the `ref_t` suffix used during the construction of - // the buffer. - ns(Monster_table_t) monster = ns(Monster_as_root(buffer)); - - // Note: root object pointers are NOT the same as the `buffer` pointer. -~~~ -</div> - -If you look in the generated files from the schema compiler, you will see it generated -accessors for all non-`deprecated` fields. For example: - -<div class="language-cpp"> -~~~{.cpp} - auto hp = monster->hp(); - auto mana = monster->mana(); - auto name = monster->name()->c_str(); -~~~ -</div> -<div class="language-java"> -~~~{.java} - short hp = monster.hp(); - short mana = monster.mana(); - String name = monster.name(); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - // For C#, unlike other languages support by FlatBuffers, most values (except for - // vectors and unions) are available as propreties instead of asccessor methods. - var hp = monster.Hp - var mana = monster.Mana - var name = monster.Name -~~~ -</div> -<div class="language-go"> -~~~{.go} - hp := monster.Hp() - mana := monster.Mana() - name := string(monster.Name()) // Note: `monster.Name()` returns a byte[]. -~~~ -</div> -<div class="language-python"> -~~~{.py} - hp = monster.Hp() - mana = monster.Mana() - name = monster.Name() -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var hp = $monster.hp(); - var mana = $monster.mana(); - var name = $monster.name(); -~~~ -</div> -<div class="language-php"> -~~~{.php} - $hp = $monster->getHp(); - $mana = $monster->getMana(); - $name = monster->getName(); -~~~ -</div> -<div class="language-c"> -~~~{.c} - uint16_t hp = ns(Monster_hp(monster)); - uint16_t mana = ns(Monster_mana(monster)); - flatbuffers_string_t name = ns(Monster_name(monster)); -~~~ -</div> - -These should hold `300`, `150`, and `"Orc"` respectively. - -*Note: The default value `150` wasn't stored in `mana`, but we are still able to retrieve it.* - -To access sub-objects, in the case of our `pos`, which is a `Vec3`: - -<div class="language-cpp"> -~~~{.cpp} - auto pos = monster->pos(); - auto x = pos->x(); - auto y = pos->y(); - auto z = pos->z(); -~~~ -</div> -<div class="language-java"> -~~~{.java} - Vec3 pos = monster.pos(); - float x = pos.x(); - float y = pos.y(); - float z = pos.z(); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - var pos = monster.Pos - var x = pos.X - var y = pos.Y - var z = pos.Z -~~~ -</div> -<div class="language-go"> -~~~{.go} - pos := monster.Pos(nil) - x := pos.X() - y := pos.Y() - z := pos.Z() - - // Note: Whenever you access a new object, like in `Pos()`, a new temporary - // accessor object gets created. If your code is very performance sensitive, - // you can pass in a pointer to an existing `Vec3` instead of `nil`. This - // allows you to reuse it across many calls to reduce the amount of object - // allocation/garbage collection. -~~~ -</div> -<div class="language-python"> -~~~{.py} - pos = monster.Pos() - x = pos.X() - y = pos.Y() - z = pos.Z() -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var pos = monster.pos(); - var x = pos.x(); - var y = pos.y(); - var z = pos.z(); -~~~ -</div> -<div class="language-php"> -~~~{.php} - $pos = $monster->getPos(); - $x = $pos->getX(); - $y = $pos->getY(); - $z = $pos->getZ(); -~~~ -</div> -<div class="language-c"> -~~~{.c} - ns(Vec3_struct_t) pos = ns(Monster_pos(monster)); - float x = ns(Vec3_x(pos)); - float y = ns(Vec3_y(pos)); - float z = ns(Vec3_z(pos)); -~~~ -</div> - -`x`, `y`, and `z` will contain `1.0`, `2.0`, and `3.0`, respectively. - -*Note: Had we not set `pos` during serialization, it would be a `NULL`-value.* - -Similarly, we can access elements of the inventory `vector` by indexing it. You -can also iterate over the length of the array/vector representing the -FlatBuffers `vector`. - -<div class="language-cpp"> -~~~{.cpp} - auto inv = monster->inventory(); // A pointer to a `flatbuffers::Vector<>`. - auto inv_len = inv->Length(); - auto third_item = inv->Get(2); -~~~ -</div> -<div class="language-java"> -~~~{.java} - int invLength = monster.inventoryLength(); - byte thirdItem = monster.inventory(2); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - int invLength = monster.InventoryLength; - var thirdItem = monster.GetInventory(2); -~~~ -</div> -<div class="language-go"> -~~~{.go} - invLength := monster.InventoryLength() - thirdItem := monster.Inventory(2) -~~~ -</div> -<div class="language-python"> -~~~{.py} - inv_len = monster.InventoryLength() - third_item = monster.Inventory(2) -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var invLength = monster.inventoryLength(); - var thirdItem = monster.inventory(2); -~~~ -</div> -<div class="language-php"> -~~~{.php} - $inv_len = $monster->getInventoryLength(); - $third_item = $monster->getInventory(2); -~~~ -</div> -<div class="language-c"> -~~~{.c} - // If `inv` hasn't been set, it will be null. It is valid get - // the length of null which will be 0, useful for iteration. - flatbuffers_uint8_vec_t inv = ns(Monster_inventory(monster)); - size_t inv_len = flatbuffers_uint8_vec_len(inv); -~~~ -</div> - -For `vector`s of `table`s, you can access the elements like any other vector, -except your need to handle the result as a FlatBuffer `table`: - -<div class="language-cpp"> -~~~{.cpp} - auto weapons = monster->weapons(); // A pointer to a `flatbuffers::Vector<>`. - auto weapon_len = weapons->Length(); - auto second_weapon_name = weapons->Get(1)->name()->str(); - auto second_weapon_damage = weapons->Get(1)->damage() -~~~ -</div> -<div class="language-java"> -~~~{.java} - int weaponsLength = monster.weaponsLength(); - String secondWeaponName = monster.weapons(1).name(); - short secondWeaponDamage = monster.weapons(1).damage(); -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - int weaponsLength = monster.WeaponsLength; - var secondWeaponName = monster.GetWeapons(1).Name; - var secondWeaponDamage = monster.GetWeapons(1).Damage; -~~~ -</div> -<div class="language-go"> -~~~{.go} - weaponLength := monster.WeaponsLength() - weapon := new(sample.Weapon) // We need a `sample.Weapon` to pass into `monster.Weapons()` - // to capture the output of the function. - if monster.Weapons(weapon, 1) { - secondWeaponName := weapon.Name() - secondWeaponDamage := weapon.Damage() - } -~~~ -</div> -<div class="language-python"> -~~~{.py} - weapons_length = monster.WeaponsLength() - second_weapon_name = monster.Weapons(1).Name() - second_weapon_damage = monster.Weapons(1).Damage() -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var weaponsLength = monster.weaponsLength(); - var secondWeaponName = monster.weapons(1).name(); - var secondWeaponDamage = monster.weapons(1).damage(); -~~~ -</div> -<div class="language-php"> -~~~{.php} - $weapons_len = $monster->getWeaponsLength(); - $second_weapon_name = $monster->getWeapons(1)->getName(); - $second_weapon_damage = $monster->getWeapons(1)->getDamage(); -~~~ -</div> -<div class="language-c"> -~~~{.c} - ns(Weapon_vec_t) weapons = ns(Monster_weapons(monster)); - size_t weapons_len = ns(Weapon_vec_len(weapons)); - // We can use `const char *` instead of `flatbuffers_string_t`. - const char *second_weapon_name = ns(Weapon_name(ns(Weapon_vec_at(weapons, 1)))); - uint16_t second_weapon_damage = ns(Weapon_damage(ns(Weapon_vec_at(weapons, 1)))); -~~~ -</div> - -Last, we can access our `Equipped` FlatBuffer `union`. Just like when we created -the `union`, we need to get both parts of the `union`: the type and the data. - -We can access the type to dynamically cast the data as needed (since the -`union` only stores a FlatBuffer `table`). - -<div class="language-cpp"> -~~~{.cpp} - auto union_type = monster.equipped_type(); - - if (union_type == Equipment_Weapon) { - auto weapon = static_cast<const Weapon*>(monster->equipped()); // Requires `static_cast` - // to type `const Weapon*`. - - auto weapon_name = weapon->name()->str(); // "Axe" - auto weapon_damage = weapon->damage(); // 5 - } -~~~ -</div> -<div class="language-java"> -~~~{.java} - int unionType = monster.EquippedType(); - - if (unionType == Equipment.Weapon) { - Weapon weapon = (Weapon)monster.equipped(new Weapon()); // Requires explicit cast - // to `Weapon`. - - String weaponName = weapon.name(); // "Axe" - short weaponDamage = weapon.damage(); // 5 - } -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - var unionType = monster.EquippedType; - - if (unionType == Equipment.Weapon) { - var weapon = (Weapon)monster.GetEquipped(new Weapon()); // Requires explicit cast - // to `Weapon`. - - var weaponName = weapon.Name; // "Axe" - var weaponDamage = weapon.Damage; // 5 - } -~~~ -</div> -<div class="language-go"> -~~~{.go} - // We need a `flatbuffers.Table` to capture the output of the - // `monster.Equipped()` function. - unionTable := new(flatbuffers.Table) - - if monster.Equipped(unionTable) { - unionType := monster.EquippedType() - - if unionType == sample.EquipmentWeapon { - // Create a `sample.Weapon` object that can be initialized with the contents - // of the `flatbuffers.Table` (`unionTable`), which was populated by - // `monster.Equipped()`. - unionWeapon = new(sample.Weapon) - unionWeapon.Init(unionTable.Bytes, unionTable.Pos) - - weaponName = unionWeapon.Name() - weaponDamage = unionWeapon.Damage() - } - } -~~~ -</div> -<div class="language-python"> -~~~{.py} - union_type = monster.EquippedType() - - if union_type == MyGame.Sample.Equipment.Equipment().Weapon: - # `monster.Equipped()` returns a `flatbuffers.Table`, which can be used to - # initialize a `MyGame.Sample.Weapon.Weapon()`. - union_weapon = MyGame.Sample.Weapon.Weapon() - union_weapon.Init(monster.Equipped().Bytes, monster.Equipped().Pos) - - weapon_name = union_weapon.Name() // 'Axe' - weapon_damage = union_weapon.Damage() // 5 -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - var unionType = monster.equippedType(); - - if (unionType == MyGame.Sample.Equipment.Weapon) { - var weapon_name = monster.equipped(new MyGame.Sample.Weapon()).name(); // 'Axe' - var weapon_damage = monster.equipped(new MyGame.Sample.Weapon()).damage(); // 5 - } -~~~ -</div> -<div class="language-php"> -~~~{.php} - $union_type = $monster->getEquippedType(); - - if ($union_type == \MyGame\Sample\Equipment::Weapon) { - $weapon_name = $monster->getEquipped(new \MyGame\Sample\Weapon())->getName(); // "Axe" - $weapon_damage = $monster->getEquipped(new \MyGame\Sample\Weapon())->getDamage(); // 5 - } -~~~ -</div> -<div class="language-c"> -~~~{.c} - // Access union type field. - if (ns(Monster_equipped_type(monster)) == ns(Equipment_Weapon)) { - // Cast to appropriate type: - // C allows for silent void pointer assignment, so we need no explicit cast. - ns(Weapon_table_t) weapon = ns(Monster_equipped(monster)); - const char *weapon_name = ns(Weapon_name(weapon)); // "Axe" - uint16_t weapon_damage = ns(Weapon_damage(weapon)); // 5 - } -~~~ -</div> - -## Mutating FlatBuffers - -As you saw above, typically once you have created a FlatBuffer, it is read-only -from that moment on. There are, however, cases where you have just received a -FlatBuffer, and you'd like to modify something about it before sending it on to -another recipient. With the above functionality, you'd have to generate an -entirely new FlatBuffer, while tracking what you modified in your own data -structures. This is inconvenient. - -For this reason FlatBuffers can also be mutated in-place. While this is great -for making small fixes to an existing buffer, you generally want to create -buffers from scratch whenever possible, since it is much more efficient and the -API is much more general purpose. - -To get non-const accessors, invoke `flatc` with `--gen-mutable`. - -Similar to how we read fields using the accessors above, we can now use the -mutators like so: - -<div class="language-cpp"> -~~~{.cpp} - auto monster = GetMutableMonster(buffer_pointer); // non-const - monster->mutate_hp(10); // Set the table `hp` field. - monster->mutable_pos()->mutate_z(4); // Set struct field. - monster->mutable_inventory()->Mutate(0, 1); // Set vector element. -~~~ -</div> -<div class="language-java"> -~~~{.java} - Monster monster = Monster.getRootAsMonster(buf); - monster.mutateHp(10); // Set table field. - monster.pos().mutateZ(4); // Set struct field. - monster.mutateInventory(0, 1); // Set vector element. -~~~ -</div> -<div class="language-csharp"> -~~~{.cs} - var monster = Monster.GetRootAsMonster(buf); - monster.MutateHp(10); // Set table field. - monster.Pos.MutateZ(4); // Set struct field. - monster.MutateInventory(0, 1); // Set vector element. -~~~ -</div> -<div class="language-go"> -~~~{.go} - <API for mutating FlatBuffers is not yet available in Go.> -~~~ -</div> -<div class="language-python"> -~~~{.py} - <API for mutating FlatBuffers is not yet available in Python.> -~~~ -</div> -<div class="language-javascript"> -~~~{.js} - <API for mutating FlatBuffers is not yet support in JavaScript.> -~~~ -</div> -<div class="language-php"> -~~~{.php} - <API for mutating FlatBuffers is not yet supported in PHP.> -~~~ -</div> -<div class="language-c"> -~~~{.c} - <API for in-place mutating FlatBuffers will not be supported in C - (except in-place vector sorting is possible).> -~~~ -</div> - -We use the somewhat verbose term `mutate` instead of `set` to indicate that this -is a special use case, not to be confused with the default way of constructing -FlatBuffer data. - -After the above mutations, you can send on the FlatBuffer to a new recipient -without any further work! - -Note that any `mutate` functions on a table will return a boolean, which is -`false` if the field we're trying to set is not present in the buffer. Fields -that are not present if they weren't set, or even if they happen to be equal to -the default value. For example, in the creation code above, the `mana` -field is equal to `150`, which is the default value, so it was never stored in -the buffer. Trying to call the corresponding `mutate` method for `mana` on such -data will return `false`, and the value won't actually be modified! - -One way to solve this is to call `ForceDefaults` on a FlatBufferBuilder to -force all fields you set to actually be written. This, of course, increases the -size of the buffer somewhat, but this may be acceptable for a mutable buffer. - -If this is not sufficient, other ways of mutating FlatBuffers may be supported -in your language through an object based API (`--gen-object-api`) or reflection. -See the individual language documents for support. - -## JSON with FlatBuffers - -#### Using `flatc` as a Conversion Tool - -This is often the preferred method to use JSON with FlatBuffers, as it doesn't -require you to add any new code to your program. It is also efficient, since you -can ship with the binary data. The drawback is that it requires an extra step -for your users/developers to perform (although it may be able to be automated -as part of your compilation). - -Lets say you have a JSON file that describes your monster. In this example, -we will use the file `flatbuffers/samples/monsterdata.json`. - -Here are the contents of the file: - -~~~{.json} -{ - pos: { - x: 1, - y: 2, - z: 3 - }, - hp: 300, - name: "Orc" -} -~~~ - -You can run this file through the `flatc` compile with the `-b` flag and -our `monster.fbs` schema to produce a FlatBuffer binary file. - -~~~{.sh} -./../flatc -b monster.fbs monsterdata.json -~~~ - -The output of this will be a file `monsterdata.bin`, which will contain the -FlatBuffer binary representation of the contents from our `.json` file. - -<div class="language-cpp"> -*Note: If you're working in C++, you can also parse JSON at runtime. See the -[Use in C++](@ref flatbuffers_guide_use_cpp) section of the Programmer's -Guide for more information.* -</div> -<div class="language-c"> -*Note: If you're working in C, the `flatcc --json` (not `flatc`) -compiler will generate schema specific high performance json parsers and -printers that you can compile and use at runtime. The `flatc` compiler (not -`flatcc`) on the other hand, is still useful for general offline json to -flatbuffer conversion from a given schema. There are no current plans -for `flatcc` to support this.* -</div> - -## Advanced Features for Each Language - -Each language has a dedicated `Use in XXX` page in the Programmer's Guide -to cover the nuances of FlatBuffers in that language. - -For your chosen language, see: - -<div class="language-cpp"> -[Use in C++](@ref flatbuffers_guide_use_cpp) -</div> -<div class="language-java"> -[Use in Java/C#](@ref flatbuffers_guide_use_java_c-sharp) -</div> -<div class="language-csharp"> -[Use in Java/C#](@ref flatbuffers_guide_use_java_c-sharp) -</div> -<div class="language-go"> -[Use in Go](@ref flatbuffers_guide_use_go) -</div> -<div class="language-python"> -[Use in Python](@ref flatbuffers_guide_use_python) -</div> -<div class="language-javascript"> -[Use in JavaScript](@ref flatbuffers_guide_use_javascript) -</div> -<div class="language-php"> -[Use in PHP](@ref flatbuffers_guide_use_php) -</div> -<div class="language-c"> -[Use in C](@ref flatbuffers_guide_use_c) -</div> - -<br>
diff --git a/third_party/flatbuffers/docs/source/WhitePaper.md b/third_party/flatbuffers/docs/source/WhitePaper.md deleted file mode 100755 index e504ada..0000000 --- a/third_party/flatbuffers/docs/source/WhitePaper.md +++ /dev/null
@@ -1,128 +0,0 @@ -FlatBuffers white paper {#flatbuffers_white_paper} -======================= - -This document tries to shed some light on to the "why" of FlatBuffers, a -new serialization library. - -## Motivation - -Back in the good old days, performance was all about instructions and -cycles. Nowadays, processing units have run so far ahead of the memory -subsystem, that making an efficient application should start and finish -with thinking about memory. How much you use of it. How you lay it out -and access it. How you allocate it. When you copy it. - -Serialization is a pervasive activity in a lot programs, and a common -source of memory inefficiency, with lots of temporary data structures -needed to parse and represent data, and inefficient allocation patterns -and locality. - -If it would be possible to do serialization with no temporary objects, -no additional allocation, no copying, and good locality, this could be -of great value. The reason serialization systems usually don't manage -this is because it goes counter to forwards/backwards compatability, and -platform specifics like endianness and alignment. - -FlatBuffers is what you get if you try anyway. - -In particular, FlatBuffers focus is on mobile hardware (where memory -size and memory bandwidth is even more constrained than on desktop -hardware), and applications that have the highest performance needs: -games. - -## FlatBuffers - -*This is a summary of FlatBuffers functionality, with some rationale. -A more detailed description can be found in the FlatBuffers -documentation.* - -### Summary - -A FlatBuffer is a binary buffer containing nested objects (structs, -tables, vectors,..) organized using offsets so that the data can be -traversed in-place just like any pointer-based data structure. Unlike -most in-memory data structures however, it uses strict rules of -alignment and endianness (always little) to ensure these buffers are -cross platform. Additionally, for objects that are tables, FlatBuffers -provides forwards/backwards compatibility and general optionality of -fields, to support most forms of format evolution. - -You define your object types in a schema, which can then be compiled to -C++ or Java for low to zero overhead reading & writing. -Optionally, JSON data can be dynamically parsed into buffers. - -### Tables - -Tables are the cornerstone of FlatBuffers, since format evolution is -essential for most applications of serialization. Typically, dealing -with format changes is something that can be done transparently during -the parsing process of most serialization solutions out there. -But a FlatBuffer isn't parsed before it is accessed. - -Tables get around this by using an extra indirection to access fields, -through a *vtable*. Each table comes with a vtable (which may be shared -between multiple tables with the same layout), and contains information -where fields for this particular kind of instance of vtable are stored. -The vtable may also indicate that the field is not present (because this -FlatBuffer was written with an older version of the software, of simply -because the information was not necessary for this instance, or deemed -deprecated), in which case a default value is returned. - -Tables have a low overhead in memory (since vtables are small and -shared) and in access cost (an extra indirection), but provide great -flexibility. Tables may even cost less memory than the equivalent -struct, since fields do not need to be stored when they are equal to -their default. - -FlatBuffers additionally offers "naked" structs, which do not offer -forwards/backwards compatibility, but can be even smaller (useful for -very small objects that are unlikely to change, like e.g. a coordinate -pair or a RGBA color). - -### Schemas - -While schemas reduce some generality (you can't just read any data -without having its schema), they have a lot of upsides: - -- Most information about the format can be factored into the generated - code, reducing memory needed to store data, and time to access it. - -- The strong typing of the data definitions means less error - checking/handling at runtime (less can go wrong). - -- A schema enables us to access a buffer without parsing. - -FlatBuffer schemas are fairly similar to those of the incumbent, -Protocol Buffers, and generally should be readable to those familiar -with the C family of languages. We chose to improve upon the features -offered by .proto files in the following ways: - -- Deprecation of fields instead of manual field id assignment. - Extending an object in a .proto means hunting for a free slot among - the numbers (preferring lower numbers since they have a more compact - representation). Besides being inconvenient, it also makes removing - fields problematic: you either have to keep them, not making it - obvious that this field shouldn't be read/written anymore, and still - generating accessors. Or you remove it, but now you risk that - there's still old data around that uses that field by the time - someone reuses that field id, with nasty consequences. - -- Differentiating between tables and structs (see above). Effectively - all table fields are `optional`, and all struct fields are - `required`. - -- Having a native vector type instead of `repeated`. This gives you a - length without having to collect all items, and in the case of - scalars provides for a more compact representation, and one that - guarantees adjacency. - -- Having a native `union` type instead of using a series of `optional` - fields, all of which must be checked individually. - -- Being able to define defaults for all scalars, instead of having to - deal with their optionality at each access. - -- A parser that can deal with both schemas and data definitions (JSON - compatible) uniformly. - -<br>
diff --git a/third_party/flatbuffers/docs/source/doxyfile b/third_party/flatbuffers/docs/source/doxyfile deleted file mode 100755 index 770da9f..0000000 --- a/third_party/flatbuffers/docs/source/doxyfile +++ /dev/null
@@ -1,2364 +0,0 @@ -# Doxyfile 1.8.5 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "FlatBuffers" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = ".." - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese- -# Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en, -# Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, -# Turkish, Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = NO - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = YES - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 2 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = NO # Due to the multiple languages included in the API - # reference for FlatBuffers, the Auto-links were - # wrong more often than not. - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = NO - -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: NO. - -SORT_BRIEF_DOCS = YES - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. - -GENERATE_TODOLIST = NO - -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. - -GENERATE_TESTLIST = NO - -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = NO - -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if <section_label> ... \endif and \cond <section_label> -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = doxygen_layout.xml - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. Do not use file names with spaces, bibtex cannot handle them. See -# also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = NO - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. - -INPUT = "FlatBuffers.md" \ - "Building.md" \ - "Compiler.md" \ - "Schemas.md" \ - "CppUsage.md" \ - "CUsage.md" \ - "GoUsage.md" \ - "JavaCsharpUsage.md" \ - "JavaScriptUsage.md" \ - "PHPUsage.md" \ - "PythonUsage.md" \ - "Support.md" \ - "Benchmarks.md" \ - "WhitePaper.md" \ - "FlexBuffers.md" \ - "Internals.md" \ - "Grammar.md" \ - "../../CONTRIBUTING.md" \ - "Tutorial.md" \ - "GoApi.md" \ - "groups" \ - "../../java/com/google/flatbuffers" \ - "../../python/flatbuffers/builder.py" \ - "../../js/flatbuffers.js" \ - "../../php/FlatbufferBuilder.php" \ - "../../net/FlatBuffers/FlatBufferBuilder.cs" \ - "../../include/flatbuffers/flatbuffers.h" \ - "../../go/builder.go" - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.as \ - *.js \ - *.go - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = *_test.py | - __init__.py - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = "GoApi_generated.txt" - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# <filter> <input-file> -# -# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = *.py=py_filter - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = FlatBuffers.md - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = NO - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = ../header.html - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = ../footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- -# defined cascading style sheet that is included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet file to the output directory. For an example -# see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = style.css - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = "../images/fpl_logo_small.png" \ - "../images/ftv2mnode.png" \ - "../images/ftv2pnode.png" - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use <access key> + S -# (what the <access key> is depends on the OS and browser, but it is typically -# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down -# key> to jump into the search results window, the results can be navigated -# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel -# the search. The filter options can be selected when the cursor is inside the -# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys> -# to select a filter and <Enter> or <escape> to activate or cancel the filter -# option. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There -# are two flavours of web server based searching depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. See -# the section "External Indexing and Searching" for details. -# The default value is: NO. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain the -# search results. -# -# Doxygen ships with an example indexer ( doxyindexer) and search engine -# (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). -# -# See the section "External Indexing and Searching" for details. -# The default value is: NO. -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will return the search results when EXTERNAL_SEARCH is enabled. -# -# Doxygen ships with an example indexer ( doxyindexer) and search engine -# (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. -# The default file is: searchdata.xml. -# This tag requires that the tag SEARCHENGINE is set to YES. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of -# to a relative location where the documentation can be found. The format is: -# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... -# This tag requires that the tag SEARCHENGINE is set to YES. - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output. -# The default value is: YES. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: latex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. -# -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate -# index for LaTeX. -# The default file is: makeindex. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX -# documents. This may be useful for small projects and may help to save some -# trees in general. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used by the -# printer. -# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x -# 14 inches) and executive (7.25 x 10.5 inches). -# The default value is: a4. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names -# that should be included in the LaTeX output. To get the times font for -# instance you can specify -# EXTRA_PACKAGES=times -# If left blank no extra packages will be included. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the -# generated LaTeX document. The header should contain everything until the first -# chapter. If it is left blank doxygen will generate a standard header. See -# section "Doxygen usage" for information on how to let doxygen write the -# default header to a separate file. -# -# Note: Only use a user-defined header if you know what you are doing! The -# following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will -# replace them by respectively the title of the page, the current date and time, -# only the current date, the version number of doxygen, the project name (see -# PROJECT_NAME), or the project number (see PROJECT_NUMBER). -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the -# generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. -# -# Note: Only use a user-defined footer if you know what you are doing! -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_FOOTER = - -# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the LATEX_OUTPUT output -# directory. Note that the files will be copied as-is; there are no commands or -# markers available. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_EXTRA_FILES = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is -# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will -# contain links (just like the HTML output) instead of page references. This -# makes the output suitable for online browsing using a PDF viewer. -# The default value is: YES. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -PDF_HYPERLINKS = YES - -# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES to get a -# higher quality PDF documentation. -# The default value is: YES. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode -# command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. This option is also used -# when generating formulas in HTML. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_BATCHMODE = NO - -# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the -# index chapters (such as File Index, Compound Index, etc.) in the output. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_HIDE_INDICES = NO - -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. -# The default value is: plain. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The -# RTF output is optimized for Word 97 and may not look too pretty with other RTF -# readers/editors. -# The default value is: NO. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: rtf. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF -# documents. This may be useful for small projects and may help to save some -# trees in general. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will -# contain hyperlink fields. The RTF file will contain links (just like the HTML -# output) instead of page references. This makes the output suitable for online -# browsing using Word or some other Word compatible readers that support those -# fields. -# -# Note: WordPad (write) and others do not support links. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. -# -# See also section "Doxygen usage" for information on how to generate the -# default style sheet that doxygen normally uses. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for -# classes and files. -# The default value is: NO. - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. A directory man3 will be created inside the directory specified by -# MAN_OUTPUT. -# The default directory is: man. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to the generated -# man pages. In case the manual section does not start with a number, the number -# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is -# optional. -# The default value is: .3. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it -# will generate one additional man file for each entity documented in the real -# man page(s). These additional files only source the real man page, but without -# them the man command would be unable to find the correct page. -# The default value is: NO. -# This tag requires that the tag GENERATE_MAN is set to YES. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that -# captures the structure of the code including all documentation. -# The default value is: NO. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: xml. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify a XML DTD, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program -# listings (including syntax highlighting and cross-referencing information) to -# the XML output. Note that enabling this will significantly increase the size -# of the XML output. -# The default value is: YES. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- - -# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files -# that can be used to generate PDF. -# The default value is: NO. - -GENERATE_DOCBOOK = NO - -# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in -# front of it. -# The default directory is: docbook. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_OUTPUT = docbook - -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen -# Definitions (see http://autogen.sf.net) file that captures the structure of -# the code including all documentation. Note that this feature is still -# experimental and incomplete at the moment. -# The default value is: NO. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module -# file that captures the structure of the code including all documentation. -# -# Note that this feature is still experimental and incomplete at the moment. -# The default value is: NO. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary -# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI -# output from the Perl module output. -# The default value is: NO. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely -# formatted so it can be parsed by a human reader. This is useful if you want to -# understand what is going on. On the other hand, if this tag is set to NO the -# size of the Perl module output will be much smaller and Perl will parse it -# just the same. -# The default value is: YES. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file are -# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful -# so different doxyrules.make files included by the same Makefile don't -# overwrite each other's variables. -# This tag requires that the tag GENERATE_PERLMOD is set to YES. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all -# C-preprocessor directives found in the sources and include files. -# The default value is: YES. - -ENABLE_PREPROCESSING = NO - -# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names -# in the source code. If set to NO only conditional compilation will be -# performed. Macro expansion can be done in a controlled way by setting -# EXPAND_ONLY_PREDEF to YES. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then -# the macro expansion is limited to the macros specified with the PREDEFINED and -# EXPAND_AS_DEFINED tags. -# The default value is: NO. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES the includes files in the -# INCLUDE_PATH will be searched if a #include is found. -# The default value is: YES. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by the -# preprocessor. -# This tag requires that the tag SEARCH_INCLUDES is set to YES. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will be -# used. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that are -# defined before the preprocessor is started (similar to the -D option of e.g. -# gcc). The argument of the tag is a list of macros of the form: name or -# name=definition (no spaces). If the definition and the "=" are omitted, "=1" -# is assumed. To prevent a macro definition from being undefined via #undef or -# recursively expanded use the := operator instead of the = operator. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this -# tag can be used to specify a list of macro names that should be expanded. The -# macro definition that is found in the sources will be used. Use the PREDEFINED -# tag if you want to use a different macro definition that overrules the -# definition found in the source code. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an -# all uppercase name, and do not end with a semicolon. Such function macros are -# typically used for boiler-plate code, and will confuse the parser if not -# removed. -# The default value is: YES. -# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tag files. For each tag -# file the location of the external documentation should be added. The format of -# a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where loc1 and loc2 can be relative or absolute paths or URLs. See the -# section "Linking to external documentation" for more information about the use -# of tag files. -# Note: Each tag file must have an unique name (where the name does NOT include -# the path). If a tag file is not located in the directory in which doxygen is -# run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create a -# tag file that is based on the input files it reads. See section "Linking to -# external documentation" for more information about the usage of tag files. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external class will be listed in the -# class index. If set to NO only the inherited external classes will be listed. -# The default value is: NO. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in -# the modules index. If set to NO, only the current project's groups will be -# listed. -# The default value is: YES. - -EXTERNAL_GROUPS = NO - -# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in -# the related pages index. If set to NO, only the current project's pages will -# be listed. -# The default value is: YES. - -EXTERNAL_PAGES = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide inheritance -# and usage relations if the target is undocumented or is not a class. -# The default value is: YES. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz (see: -# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent -# Bell Labs. The other options in this section have no effect if this option is -# set to NO -# The default value is: NO. - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed -# to run in parallel. When set to 0 doxygen will base this on the number of -# processors available in the system. You can set it explicitly to a value -# larger than 0 to get control over the balance between CPU load and processing -# speed. -# Minimum value: 0, maximum value: 32, default value: 0. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_NUM_THREADS = 0 - -# When you want a differently looking font n the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_FONTPATH = - -# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for -# each documented class showing the direct and indirect inheritance relations. -# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a -# graph for each documented class showing the direct and indirect implementation -# dependencies (inheritance, containment, and class references variables) of the -# class with other documented classes. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for -# groups, showing the direct groups dependencies. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside the -# class node. If there are many fields or methods and many nodes the graph may -# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the -# number of items for each type to make the size more manageable. Set this to 0 -# for no limit. Note that the threshold may be exceeded by 50% before the limit -# is enforced. So when you set the threshold to 10, up to 15 fields may appear, -# but if the number exceeds 15, the total amount of fields shown is limited to -# 10. -# Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. - -UML_LIMIT_NUM_FIELDS = 10 - -# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and -# collaboration graphs will show the relations between templates and their -# instances. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -TEMPLATE_RELATIONS = NO - -# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to -# YES then doxygen will generate a graph for each documented file showing the -# direct and indirect include dependencies of the file with other documented -# files. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -INCLUDE_GRAPH = YES - -# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are -# set to YES then doxygen will generate a graph for each documented file showing -# the direct and indirect include dependencies of the file with other documented -# files. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH tag is set to YES then doxygen will generate a call -# dependency graph for every global function or class method. -# -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller -# dependency graph for every global function or class method. -# -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical -# hierarchy of all classes instead of a textual one. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the -# dependencies a directory has on other directories in a graphical way. The -# dependency relations are determined by the #include relations between the -# files in the directories. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. -# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order -# to make the SVG files visible in IE 9+ (other browsers do not have this -# requirement). -# Possible values are: png, jpg, gif and svg. -# The default value is: png. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# -# Note that this requires a modern browser other than Internet Explorer. Tested -# and working are Firefox, Chrome, Safari, and Opera. -# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make -# the SVG files visible. Older versions of IE do not have SVG support. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -INTERACTIVE_SVG = NO - -# The DOT_PATH tag can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the \dotfile -# command). -# This tag requires that the tag HAVE_DOT is set to YES. - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the \mscfile -# command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes -# that will be shown in the graph. If the number of nodes in a graph becomes -# larger than this value, doxygen will truncate the graph, which is visualized -# by representing a node as a red box. Note that doxygen if the number of direct -# children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that -# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -# Minimum value: 0, maximum value: 10000, default value: 50. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs -# generated by dot. A depth value of 3 means that only nodes reachable from the -# root by following a path via at most 3 edges will be shown. Nodes that lay -# further from the root node will be omitted. Note that setting this option to 1 -# or 2 may greatly reduce the computation time needed for large code bases. Also -# note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -# Minimum value: 0, maximum value: 1000, default value: 0. -# This tag requires that the tag HAVE_DOT is set to YES. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) support -# this, this feature is disabled by default. -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page -# explaining the meaning of the various boxes and arrows in the dot generated -# graphs. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot -# files that are used to generate the various graphs. -# The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_CLEANUP = YES
diff --git a/third_party/flatbuffers/docs/source/doxygen_layout.xml b/third_party/flatbuffers/docs/source/doxygen_layout.xml deleted file mode 100644 index 77866df..0000000 --- a/third_party/flatbuffers/docs/source/doxygen_layout.xml +++ /dev/null
@@ -1,234 +0,0 @@ -<!-- Copyright 2015 Google Inc. All rights reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<doxygenlayout version="1.0"> - <navindex> - <tab type="mainpage" visible="no" title=""/> - <tab type="usergroup" url="" title="Programmer's Guide"> - <tab type="user" url="@ref flatbuffers_guide_building" - title="Building"/> - <tab type="user" url="@ref flatbuffers_guide_tutorial" title="Tutorial"/> - <tab type="user" url="@ref flatbuffers_guide_using_schema_compiler" - title="Using the schema compiler"/> - <tab type="user" url="@ref flatbuffers_guide_writing_schema" - title="Writing a schema"/> - <tab type="user" url="@ref flatbuffers_guide_use_cpp" - title="Use in C++"/> - <tab type="user" url="@ref flatbuffers_guide_use_c" - title="Use in C"/> - <tab type="user" url="@ref flatbuffers_guide_use_go" - title="Use in Go"/> - <tab type="user" url="@ref flatbuffers_guide_use_java_c-sharp" - title="Use in Java/C#"/> - <tab type="user" url="@ref flatbuffers_guide_use_javascript" - title="Use in JavaScript"/> - <tab type="user" url="@ref flatbuffers_guide_use_php" - title="Use in PHP"/> - <tab type="user" url="@ref flatbuffers_guide_use_python" - title="Use in Python"/> - <tab type="user" url="@ref flexbuffers" - title="Schema-less version"/> - </tab> - <tab type="user" url="@ref flatbuffers_support" - title="Platform / Language / Feature support"/> - <tab type="user" url="@ref flatbuffers_benchmarks" - title="Benchmarks"/> - <tab type="user" url="@ref flatbuffers_white_paper" - title="FlatBuffers white paper"/> - <tab type="user" url="@ref flatbuffers_internals" - title="FlatBuffers internals"/> - <tab type="user" url="@ref flatbuffers_grammar" - title="Grammar of the schema language"/> - <tab type="usergroup" url="" title="API Reference"> - <tab type="modules" visible="yes" title="APIs" intro=""/> - <tab type="classes" visible="yes" title=""> - <tab type="classlist" visible="yes" title="" intro=""/> - <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> - <tab type="hierarchy" visible="yes" title="" intro=""/> - <tab type="classmembers" visible="yes" title="" intro=""/> - </tab> - </tab> - <tab type="user" url="@ref contributing" title="Contributing"/> - </navindex> - - <!-- Layout definition for a class page --> - <class> - <briefdescription visible="yes"/> - <includes visible="$SHOW_INCLUDE_FILES"/> - <inheritancegraph visible="$CLASS_GRAPH"/> - <collaborationgraph visible="$COLLABORATION_GRAPH"/> - <detaileddescription title=""/> - <memberdecl> - <nestedclasses visible="yes" title=""/> - <publictypes title=""/> - <services title=""/> - <interfaces title=""/> - <publicslots title=""/> - <signals title=""/> - <publicmethods title=""/> - <publicstaticmethods title=""/> - <publicattributes title=""/> - <publicstaticattributes title=""/> - <protectedtypes title=""/> - <protectedslots title=""/> - <protectedmethods title=""/> - <protectedstaticmethods title=""/> - <protectedattributes title=""/> - <protectedstaticattributes title=""/> - <packagetypes title=""/> - <packagemethods title=""/> - <packagestaticmethods title=""/> - <packageattributes title=""/> - <packagestaticattributes title=""/> - <properties title=""/> - <events title=""/> - <privatetypes title=""/> - <privateslots title=""/> - <privatemethods title=""/> - <privatestaticmethods title=""/> - <privateattributes title=""/> - <privatestaticattributes title=""/> - <friends title=""/> - <related title="" subtitle=""/> - <membergroups visible="yes"/> - </memberdecl> - <memberdef> - <inlineclasses title=""/> - <typedefs title=""/> - <enums title=""/> - <services title=""/> - <interfaces title=""/> - <constructors title=""/> - <functions title=""/> - <related title=""/> - <variables title=""/> - <properties title=""/> - <events title=""/> - </memberdef> - <allmemberslink visible="yes"/> - <usedfiles visible="$SHOW_USED_FILES"/> - <authorsection visible="yes"/> - </class> - - <!-- Layout definition for a namespace page --> - <namespace> - <briefdescription visible="yes"/> - <memberdecl> - <nestednamespaces visible="yes" title=""/> - <constantgroups visible="yes" title=""/> - <classes visible="yes" title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - <membergroups visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - <memberdef> - <inlineclasses title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - </memberdef> - <authorsection visible="yes"/> - </namespace> - - <!-- Layout definition for a file page --> - <file> - <briefdescription visible="yes"/> - <includes visible="$SHOW_INCLUDE_FILES"/> - <includegraph visible="$INCLUDE_GRAPH"/> - <includedbygraph visible="$INCLUDED_BY_GRAPH"/> - <sourcelink visible="yes"/> - <detaileddescription title=""/> - <memberdecl> - <classes visible="yes" title=""/> - <namespaces visible="yes" title=""/> - <constantgroups visible="yes" title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - <membergroups visible="yes"/> - </memberdecl> - <memberdef> - <inlineclasses title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <functions title=""/> - <variables title=""/> - </memberdef> - <authorsection/> - </file> - - <!-- Layout definition for a group page --> - <group> - <briefdescription visible="yes"/> - <groupgraph visible="$GROUP_GRAPHS"/> - <detaileddescription title=""/> - <memberdecl> - <nestedgroups visible="yes" title=""/> - <dirs visible="yes" title=""/> - <files visible="yes" title=""/> - <namespaces visible="yes" title=""/> - <classes visible="yes" title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <enumvalues title=""/> - <functions title=""/> - <variables title=""/> - <signals title=""/> - <publicslots title=""/> - <protectedslots title=""/> - <privateslots title=""/> - <events title=""/> - <properties title=""/> - <friends title=""/> - <membergroups visible="yes"/> - </memberdecl> - <memberdef> - <pagedocs/> - <inlineclasses title=""/> - <defines title=""/> - <typedefs title=""/> - <enums title=""/> - <enumvalues title=""/> - <functions title=""/> - <variables title=""/> - <signals title=""/> - <publicslots title=""/> - <protectedslots title=""/> - <privateslots title=""/> - <events title=""/> - <properties title=""/> - <friends title=""/> - </memberdef> - <authorsection visible="yes"/> - </group> - - <!-- Layout definition for a directory page --> - <directory> - <briefdescription visible="yes"/> - <directorygraph visible="yes"/> - <memberdecl> - <dirs visible="yes"/> - <files visible="yes"/> - </memberdecl> - <detaileddescription title=""/> - </directory> -</doxygenlayout>
diff --git a/third_party/flatbuffers/docs/source/groups b/third_party/flatbuffers/docs/source/groups deleted file mode 100644 index e0d97a7..0000000 --- a/third_party/flatbuffers/docs/source/groups +++ /dev/null
@@ -1,20 +0,0 @@ -/// @defgroup flatbuffers_cpp_api C++ API -/// @brief FlatBuffers API for C++ - -/// @defgroup flatbuffers_csharp_api C# API -/// @brief FlatBuffers API for C# - -/// @defgroup flatbuffers_go_api Go API -/// @brief FlatBuffers API for Go - -/// @defgroup flatbuffers_java_api Java API -/// @brief FlatBuffers API for Java - -/// @defgroup flatbuffers_javascript_api JavaScript API -/// @brief FlatBuffers API for JavaScript - -/// @defgroup flatbuffers_php_api PHP API -/// @brief FlatBuffers API for PHP - -/// @defgroup flatbuffers_python_api Python API -/// @brief FlatBuffers API for Python
diff --git a/third_party/flatbuffers/docs/source/style.css b/third_party/flatbuffers/docs/source/style.css deleted file mode 100644 index 6045a97..0000000 --- a/third_party/flatbuffers/docs/source/style.css +++ /dev/null
@@ -1,396 +0,0 @@ -body, -#projectname, -table, -div, -p, -dl, -.title, -.tabs, -.tabs2, -.tabs3, -#nav-tree .label { - font-family: roboto, sans-serif; -} - -#commonprojectlogo { - padding: 5px 0px 5px 15px; -} - -#projectname { - color: #00bcd4; - font-size: 280%; - padding: 15px 0px; - font-weight: 300; -} - -#titlearea { - border-bottom: 2px solid #e5e5e5; -} - -.title { - color: #212121; - font: 300 34px/40px Roboto,sans-serif; -} - -#nav-tree { - background-color: #fff; -} - -#navrow1, #navrow2 { - border-bottom: 2px solid #e7e7e7; -} - -.tabs, .tabs2, .tabs3 { - font-size: 14px; -} - -.tabs, -.tabs2, -.tabs3, -.tablist li, -.tablist li.current a { - background-image: none; -} - -.tablist { - list-style: none; -} - -.tablist li, .tablist li p { - margin: 0; -} - -.tablist li a, -.tablist li.current a { - color: #757575; - text-shadow: none; -} - -.tablist li.current a { - background: #00bcd4; - color: #fff; -} - -.tablist a { - background-image: none; - border-right: 2px solid #e5e5e5; - font-weight: normal; -} - -.tablist a:hover, -.tablist li.current a:hover { - background-image: none; - text-decoration: underline; - text-shadow: none; -} - -.tablist a:hover { - color: #00bcd4; -} - -.tablist li.current a:hover { - color: #fff; -} - -div.header { - background-color: #f7f7f7; - background-image: none; - border-bottom: none; -} - -#MSearchBox { - border: 1px solid #ccc; - border-radius: 5px; - display: inline-block; - height: 20px; - right: 10px; -} - -#MSearchBox .left, -#MSearchBox .right, -#MSearchField { - background: none; -} - -a.SelectItem:hover { - background-color: #00bcd4; -} - -#nav-tree { - background-image: none; -} - -#nav-tree .selected { - background-image: none; - text-shadow: none; - background-color: #f7f7f7; -} - -#nav-tree a { - color: #212121; -} - -#nav-tree .selected a { - color: #0288d1; -} - -#nav-tree .item:hover { - background-color: #f7f7f7; -} - -#nav-tree .item:hover a { - color: #0288d1; -} - -#nav-tree .label { - font-size: 13px; -} - -#nav-sync { - display: none; -} - -.ui-resizable-e { - background: #ebebeb; - border-left: 1px solid #ddd; - border-right: 1px solid #ddd; -} - -.contents tr td .image { - margin-top: 24px; -} - -.image { - text-align: left; - margin-bottom: 8px; -} - -a:link, -a:visited, -.contents a:link, -.contents a:visited, -a.el { - color: #0288d1; - font-weight: normal; - text-decoration: none; -} - -div.contents { - margin-right: 12px; -} - -.directory tr, .directory tr.even { - background: #7cb342; - border-top: 1px solid #7cb342; -} - -.directory td, -.directory td.entry, -.directory td.desc { - background: rgba(255,255,255,.95); - border-left: none; - color: #212121; - padding-top: 10px; - padding-bottom: 10px; - padding-left: 8px; - padding-right: 8px; -} - -.directory tr#row_0_ { - border-top-color: #7cb342; -} - -.directory tr#row_0_ td { - background: #7cb342; - color: #fff; - font-size: 18px; -} - -.memSeparator { - border-bottom: none; -} - -.memitem { - background: #7cb342; -} - -.memproto, dl.reflist dt { - background: #7cb342; - background-image: none; - border: none; - box-shadow: none; - -webkit-box-shadow: none; - color: #fff; - text-shadow: none; -} - -.memproto .memtemplate, -.memproto a.el, -.memproto .paramname { - color: #fff; -} - -.memdoc, dl.reflist dd { - border: none; - background-color: rgba(255,255,255,.95); - background-image: none; - box-shadow: none; - -webkit-box-shadow: none; - -webkit-border-bottom-left-radius: 0; - -webkit-border-bottom-right-radius: 0; -} - -.memitem, table.doxtable, table.memberdecls { - margin-bottom: 24px; -} - -table.doxtable th { - background: #7cb342; -} - -table.doxtable tr { - background: #7cb342; - border-top: 1px solid #7cb342; -} - -table.doxtable td, table.doxtable th { - border: none; - padding: 10px 8px; -} - -table.doxtable td { - background-color: rgba(255,255,255,.95); -} - -.memberdecls { - background: #7cb342; - border-top: 1px solid #7cb342; -} - -.memberdecls .heading h2 { - border-bottom: none; - color: #fff; - font-size: 110%; - font-weight: bold; - margin: 0 0 0 6px; -} - -.memberdecls tr:not(.heading) td { - background-color: rgba(255,255,255,.95); -} - -h1, h2, h2.groupheader, h3, h4, h5, h6 { - color: #212121; -} - -h1 { - border-bottom: 1px solid #ebebeb; - font: 400 28px/32px Roboto,sans-serif; - letter-spacing: -.01em; - margin: 40px 0 20px; - padding-bottom: 3px; -} - -h2, h2.groupheader { - border-bottom: 1px solid #ebebeb; - font: 400 23px/32px Roboto,sans-serif; - letter-spacing: -.01em; - margin: 40px 0 20px; - padding-bottom: 3px; -} - -h3 { - font: 500 20px/32px Roboto,sans-serif; - margin: 32px 0 16px; -} - -h4 { - font: 500 18px/32px Roboto,sans-serif; - margin: 32px 0 16px; -} - -ol, -ul { - margin: 0; - padding-left: 40px; -} - -ol { - list-style: decimal outside; -} - -ol ol { - list-style-type: lower-alpha; -} - -ol ol ol { - list-style-type: lower-roman; -} - -ul { - list-style: disc outside; -} - -li, -li p { - margin: 8px 0; - padding: 0; -} - -div.summary -{ - float: none; - font-size: 8pt; - padding-left: 5px; - width: calc(100% - 10px); - text-align: left; - display: block; -} - -div.ingroups { - margin-top: 8px; -} - -div.fragment { - border: 1px solid #ddd; - color: #455a64; - font: 14px/20px Roboto Mono, monospace; - padding: 8px; -} - -div.line { - line-height: 1.5; - font-size: inherit; -} - -code, pre { - color: #455a64; - background: #f7f7f7; - font: 400 100% Roboto Mono,monospace; - padding: 1px 4px; -} - -span.preprocessor, span.comment { - color: #0b8043; -} - -span.keywordtype { - color: #0097a7; -} - -.paramname { - color: #ef6c00; -} - -.memTemplParams { - color: #ef6c00; -} - -span.mlabel { - background: rgba(255,255,255,.25); - border: none; -} - -blockquote { - border: 1px solid #ddd; -}
diff --git a/third_party/flatbuffers/go/builder.go b/third_party/flatbuffers/go/builder.go deleted file mode 100644 index cf21dd5..0000000 --- a/third_party/flatbuffers/go/builder.go +++ /dev/null
@@ -1,747 +0,0 @@ -package flatbuffers - -// Builder is a state machine for creating FlatBuffer objects. -// Use a Builder to construct object(s) starting from leaf nodes. -// -// A Builder constructs byte buffers in a last-first manner for simplicity and -// performance. -type Builder struct { - // `Bytes` gives raw access to the buffer. Most users will want to use - // FinishedBytes() instead. - Bytes []byte - - minalign int - vtable []UOffsetT - objectEnd UOffsetT - vtables []UOffsetT - head UOffsetT - nested bool - finished bool -} - -// NewBuilder initializes a Builder of size `initial_size`. -// The internal buffer is grown as needed. -func NewBuilder(initialSize int) *Builder { - if initialSize <= 0 { - initialSize = 0 - } - - b := &Builder{} - b.Bytes = make([]byte, initialSize) - b.head = UOffsetT(initialSize) - b.minalign = 1 - b.vtables = make([]UOffsetT, 0, 16) // sensible default capacity - - return b -} - -// Reset truncates the underlying Builder buffer, facilitating alloc-free -// reuse of a Builder. It also resets bookkeeping data. -func (b *Builder) Reset() { - if b.Bytes != nil { - b.Bytes = b.Bytes[:cap(b.Bytes)] - } - - if b.vtables != nil { - b.vtables = b.vtables[:0] - } - - if b.vtable != nil { - b.vtable = b.vtable[:0] - } - - b.head = UOffsetT(len(b.Bytes)) - b.minalign = 1 - b.nested = false - b.finished = false -} - -// FinishedBytes returns a pointer to the written data in the byte buffer. -// Panics if the builder is not in a finished state (which is caused by calling -// `Finish()`). -func (b *Builder) FinishedBytes() []byte { - b.assertFinished() - return b.Bytes[b.Head():] -} - -// StartObject initializes bookkeeping for writing a new object. -func (b *Builder) StartObject(numfields int) { - b.assertNotNested() - b.nested = true - - // use 32-bit offsets so that arithmetic doesn't overflow. - if cap(b.vtable) < numfields || b.vtable == nil { - b.vtable = make([]UOffsetT, numfields) - } else { - b.vtable = b.vtable[:numfields] - for i := 0; i < len(b.vtable); i++ { - b.vtable[i] = 0 - } - } - - b.objectEnd = b.Offset() - b.minalign = 1 -} - -// WriteVtable serializes the vtable for the current object, if applicable. -// -// Before writing out the vtable, this checks pre-existing vtables for equality -// to this one. If an equal vtable is found, point the object to the existing -// vtable and return. -// -// Because vtable values are sensitive to alignment of object data, not all -// logically-equal vtables will be deduplicated. -// -// A vtable has the following format: -// <VOffsetT: size of the vtable in bytes, including this value> -// <VOffsetT: size of the object in bytes, including the vtable offset> -// <VOffsetT: offset for a field> * N, where N is the number of fields in -// the schema for this type. Includes deprecated fields. -// Thus, a vtable is made of 2 + N elements, each SizeVOffsetT bytes wide. -// -// An object has the following format: -// <SOffsetT: offset to this object's vtable (may be negative)> -// <byte: data>+ -func (b *Builder) WriteVtable() (n UOffsetT) { - // Prepend a zero scalar to the object. Later in this function we'll - // write an offset here that points to the object's vtable: - b.PrependSOffsetT(0) - - objectOffset := b.Offset() - existingVtable := UOffsetT(0) - - // Search backwards through existing vtables, because similar vtables - // are likely to have been recently appended. See - // BenchmarkVtableDeduplication for a case in which this heuristic - // saves about 30% of the time used in writing objects with duplicate - // tables. - for i := len(b.vtables) - 1; i >= 0; i-- { - // Find the other vtable, which is associated with `i`: - vt2Offset := b.vtables[i] - vt2Start := len(b.Bytes) - int(vt2Offset) - vt2Len := GetVOffsetT(b.Bytes[vt2Start:]) - - metadata := VtableMetadataFields * SizeVOffsetT - vt2End := vt2Start + int(vt2Len) - vt2 := b.Bytes[vt2Start+metadata : vt2End] - - // Compare the other vtable to the one under consideration. - // If they are equal, store the offset and break: - if vtableEqual(b.vtable, objectOffset, vt2) { - existingVtable = vt2Offset - break - } - } - - if existingVtable == 0 { - // Did not find a vtable, so write this one to the buffer. - - // Write out the current vtable in reverse , because - // serialization occurs in last-first order: - for i := len(b.vtable) - 1; i >= 0; i-- { - var off UOffsetT - if b.vtable[i] != 0 { - // Forward reference to field; - // use 32bit number to assert no overflow: - off = objectOffset - b.vtable[i] - } - - b.PrependVOffsetT(VOffsetT(off)) - } - - // The two metadata fields are written last. - - // First, store the object bytesize: - objectSize := objectOffset - b.objectEnd - b.PrependVOffsetT(VOffsetT(objectSize)) - - // Second, store the vtable bytesize: - vBytes := (len(b.vtable) + VtableMetadataFields) * SizeVOffsetT - b.PrependVOffsetT(VOffsetT(vBytes)) - - // Next, write the offset to the new vtable in the - // already-allocated SOffsetT at the beginning of this object: - objectStart := SOffsetT(len(b.Bytes)) - SOffsetT(objectOffset) - WriteSOffsetT(b.Bytes[objectStart:], - SOffsetT(b.Offset())-SOffsetT(objectOffset)) - - // Finally, store this vtable in memory for future - // deduplication: - b.vtables = append(b.vtables, b.Offset()) - } else { - // Found a duplicate vtable. - - objectStart := SOffsetT(len(b.Bytes)) - SOffsetT(objectOffset) - b.head = UOffsetT(objectStart) - - // Write the offset to the found vtable in the - // already-allocated SOffsetT at the beginning of this object: - WriteSOffsetT(b.Bytes[b.head:], - SOffsetT(existingVtable)-SOffsetT(objectOffset)) - } - - b.vtable = b.vtable[:0] - return objectOffset -} - -// EndObject writes data necessary to finish object construction. -func (b *Builder) EndObject() UOffsetT { - b.assertNested() - n := b.WriteVtable() - b.nested = false - return n -} - -// Doubles the size of the byteslice, and copies the old data towards the -// end of the new byteslice (since we build the buffer backwards). -func (b *Builder) growByteBuffer() { - if (int64(len(b.Bytes)) & int64(0xC0000000)) != 0 { - panic("cannot grow buffer beyond 2 gigabytes") - } - newLen := len(b.Bytes) * 2 - if newLen == 0 { - newLen = 1 - } - - if cap(b.Bytes) >= newLen { - b.Bytes = b.Bytes[:newLen] - } else { - extension := make([]byte, newLen-len(b.Bytes)) - b.Bytes = append(b.Bytes, extension...) - } - - middle := newLen / 2 - copy(b.Bytes[middle:], b.Bytes[:middle]) -} - -// Head gives the start of useful data in the underlying byte buffer. -// Note: unlike other functions, this value is interpreted as from the left. -func (b *Builder) Head() UOffsetT { - return b.head -} - -// Offset relative to the end of the buffer. -func (b *Builder) Offset() UOffsetT { - return UOffsetT(len(b.Bytes)) - b.head -} - -// Pad places zeros at the current offset. -func (b *Builder) Pad(n int) { - for i := 0; i < n; i++ { - b.PlaceByte(0) - } -} - -// Prep prepares to write an element of `size` after `additional_bytes` -// have been written, e.g. if you write a string, you need to align such -// the int length field is aligned to SizeInt32, and the string data follows it -// directly. -// If all you need to do is align, `additionalBytes` will be 0. -func (b *Builder) Prep(size, additionalBytes int) { - // Track the biggest thing we've ever aligned to. - if size > b.minalign { - b.minalign = size - } - // Find the amount of alignment needed such that `size` is properly - // aligned after `additionalBytes`: - alignSize := (^(len(b.Bytes) - int(b.Head()) + additionalBytes)) + 1 - alignSize &= (size - 1) - - // Reallocate the buffer if needed: - for int(b.head) <= alignSize+size+additionalBytes { - oldBufSize := len(b.Bytes) - b.growByteBuffer() - b.head += UOffsetT(len(b.Bytes) - oldBufSize) - } - b.Pad(alignSize) -} - -// PrependSOffsetT prepends an SOffsetT, relative to where it will be written. -func (b *Builder) PrependSOffsetT(off SOffsetT) { - b.Prep(SizeSOffsetT, 0) // Ensure alignment is already done. - if !(UOffsetT(off) <= b.Offset()) { - panic("unreachable: off <= b.Offset()") - } - off2 := SOffsetT(b.Offset()) - off + SOffsetT(SizeSOffsetT) - b.PlaceSOffsetT(off2) -} - -// PrependUOffsetT prepends an UOffsetT, relative to where it will be written. -func (b *Builder) PrependUOffsetT(off UOffsetT) { - b.Prep(SizeUOffsetT, 0) // Ensure alignment is already done. - if !(off <= b.Offset()) { - panic("unreachable: off <= b.Offset()") - } - off2 := b.Offset() - off + UOffsetT(SizeUOffsetT) - b.PlaceUOffsetT(off2) -} - -// StartVector initializes bookkeeping for writing a new vector. -// -// A vector has the following format: -// <UOffsetT: number of elements in this vector> -// <T: data>+, where T is the type of elements of this vector. -func (b *Builder) StartVector(elemSize, numElems, alignment int) UOffsetT { - b.assertNotNested() - b.nested = true - b.Prep(SizeUint32, elemSize*numElems) - b.Prep(alignment, elemSize*numElems) // Just in case alignment > int. - return b.Offset() -} - -// EndVector writes data necessary to finish vector construction. -func (b *Builder) EndVector(vectorNumElems int) UOffsetT { - b.assertNested() - - // we already made space for this, so write without PrependUint32 - b.PlaceUOffsetT(UOffsetT(vectorNumElems)) - - b.nested = false - return b.Offset() -} - -// CreateString writes a null-terminated string as a vector. -func (b *Builder) CreateString(s string) UOffsetT { - b.assertNotNested() - b.nested = true - - b.Prep(int(SizeUOffsetT), (len(s)+1)*SizeByte) - b.PlaceByte(0) - - l := UOffsetT(len(s)) - - b.head -= l - copy(b.Bytes[b.head:b.head+l], s) - - return b.EndVector(len(s)) -} - -// CreateByteString writes a byte slice as a string (null-terminated). -func (b *Builder) CreateByteString(s []byte) UOffsetT { - b.assertNotNested() - b.nested = true - - b.Prep(int(SizeUOffsetT), (len(s)+1)*SizeByte) - b.PlaceByte(0) - - l := UOffsetT(len(s)) - - b.head -= l - copy(b.Bytes[b.head:b.head+l], s) - - return b.EndVector(len(s)) -} - -// CreateByteVector writes a ubyte vector -func (b *Builder) CreateByteVector(v []byte) UOffsetT { - b.assertNotNested() - b.nested = true - - b.Prep(int(SizeUOffsetT), len(v)*SizeByte) - - l := UOffsetT(len(v)) - - b.head -= l - copy(b.Bytes[b.head:b.head+l], v) - - return b.EndVector(len(v)) -} - -func (b *Builder) assertNested() { - // If you get this assert, you're in an object while trying to write - // data that belongs outside of an object. - // To fix this, write non-inline data (like vectors) before creating - // objects. - if !b.nested { - panic("Incorrect creation order: must be inside object.") - } -} - -func (b *Builder) assertNotNested() { - // If you hit this, you're trying to construct a Table/Vector/String - // during the construction of its parent table (between the MyTableBuilder - // and builder.Finish()). - // Move the creation of these sub-objects to above the MyTableBuilder to - // not get this assert. - // Ignoring this assert may appear to work in simple cases, but the reason - // it is here is that storing objects in-line may cause vtable offsets - // to not fit anymore. It also leads to vtable duplication. - if b.nested { - panic("Incorrect creation order: object must not be nested.") - } -} - -func (b *Builder) assertFinished() { - // If you get this assert, you're attempting to get access a buffer - // which hasn't been finished yet. Be sure to call builder.Finish() - // with your root table. - // If you really need to access an unfinished buffer, use the Bytes - // buffer directly. - if !b.finished { - panic("Incorrect use of FinishedBytes(): must call 'Finish' first.") - } -} - -// PrependBoolSlot prepends a bool onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependBoolSlot(o int, x, d bool) { - val := byte(0) - if x { - val = 1 - } - def := byte(0) - if d { - def = 1 - } - b.PrependByteSlot(o, val, def) -} - -// PrependByteSlot prepends a byte onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependByteSlot(o int, x, d byte) { - if x != d { - b.PrependByte(x) - b.Slot(o) - } -} - -// PrependUint8Slot prepends a uint8 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependUint8Slot(o int, x, d uint8) { - if x != d { - b.PrependUint8(x) - b.Slot(o) - } -} - -// PrependUint16Slot prepends a uint16 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependUint16Slot(o int, x, d uint16) { - if x != d { - b.PrependUint16(x) - b.Slot(o) - } -} - -// PrependUint32Slot prepends a uint32 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependUint32Slot(o int, x, d uint32) { - if x != d { - b.PrependUint32(x) - b.Slot(o) - } -} - -// PrependUint64Slot prepends a uint64 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependUint64Slot(o int, x, d uint64) { - if x != d { - b.PrependUint64(x) - b.Slot(o) - } -} - -// PrependInt8Slot prepends a int8 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependInt8Slot(o int, x, d int8) { - if x != d { - b.PrependInt8(x) - b.Slot(o) - } -} - -// PrependInt16Slot prepends a int16 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependInt16Slot(o int, x, d int16) { - if x != d { - b.PrependInt16(x) - b.Slot(o) - } -} - -// PrependInt32Slot prepends a int32 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependInt32Slot(o int, x, d int32) { - if x != d { - b.PrependInt32(x) - b.Slot(o) - } -} - -// PrependInt64Slot prepends a int64 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependInt64Slot(o int, x, d int64) { - if x != d { - b.PrependInt64(x) - b.Slot(o) - } -} - -// PrependFloat32Slot prepends a float32 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependFloat32Slot(o int, x, d float32) { - if x != d { - b.PrependFloat32(x) - b.Slot(o) - } -} - -// PrependFloat64Slot prepends a float64 onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependFloat64Slot(o int, x, d float64) { - if x != d { - b.PrependFloat64(x) - b.Slot(o) - } -} - -// PrependUOffsetTSlot prepends an UOffsetT onto the object at vtable slot `o`. -// If value `x` equals default `d`, then the slot will be set to zero and no -// other data will be written. -func (b *Builder) PrependUOffsetTSlot(o int, x, d UOffsetT) { - if x != d { - b.PrependUOffsetT(x) - b.Slot(o) - } -} - -// PrependStructSlot prepends a struct onto the object at vtable slot `o`. -// Structs are stored inline, so nothing additional is being added. -// In generated code, `d` is always 0. -func (b *Builder) PrependStructSlot(voffset int, x, d UOffsetT) { - if x != d { - b.assertNested() - if x != b.Offset() { - panic("inline data write outside of object") - } - b.Slot(voffset) - } -} - -// Slot sets the vtable key `voffset` to the current location in the buffer. -func (b *Builder) Slot(slotnum int) { - b.vtable[slotnum] = UOffsetT(b.Offset()) -} - -// Finish finalizes a buffer, pointing to the given `rootTable`. -func (b *Builder) Finish(rootTable UOffsetT) { - b.assertNotNested() - b.Prep(b.minalign, SizeUOffsetT) - b.PrependUOffsetT(rootTable) - b.finished = true -} - -// vtableEqual compares an unwritten vtable to a written vtable. -func vtableEqual(a []UOffsetT, objectStart UOffsetT, b []byte) bool { - if len(a)*SizeVOffsetT != len(b) { - return false - } - - for i := 0; i < len(a); i++ { - x := GetVOffsetT(b[i*SizeVOffsetT : (i+1)*SizeVOffsetT]) - - // Skip vtable entries that indicate a default value. - if x == 0 && a[i] == 0 { - continue - } - - y := SOffsetT(objectStart) - SOffsetT(a[i]) - if SOffsetT(x) != y { - return false - } - } - return true -} - -// PrependBool prepends a bool to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependBool(x bool) { - b.Prep(SizeBool, 0) - b.PlaceBool(x) -} - -// PrependUint8 prepends a uint8 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependUint8(x uint8) { - b.Prep(SizeUint8, 0) - b.PlaceUint8(x) -} - -// PrependUint16 prepends a uint16 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependUint16(x uint16) { - b.Prep(SizeUint16, 0) - b.PlaceUint16(x) -} - -// PrependUint32 prepends a uint32 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependUint32(x uint32) { - b.Prep(SizeUint32, 0) - b.PlaceUint32(x) -} - -// PrependUint64 prepends a uint64 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependUint64(x uint64) { - b.Prep(SizeUint64, 0) - b.PlaceUint64(x) -} - -// PrependInt8 prepends a int8 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependInt8(x int8) { - b.Prep(SizeInt8, 0) - b.PlaceInt8(x) -} - -// PrependInt16 prepends a int16 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependInt16(x int16) { - b.Prep(SizeInt16, 0) - b.PlaceInt16(x) -} - -// PrependInt32 prepends a int32 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependInt32(x int32) { - b.Prep(SizeInt32, 0) - b.PlaceInt32(x) -} - -// PrependInt64 prepends a int64 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependInt64(x int64) { - b.Prep(SizeInt64, 0) - b.PlaceInt64(x) -} - -// PrependFloat32 prepends a float32 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependFloat32(x float32) { - b.Prep(SizeFloat32, 0) - b.PlaceFloat32(x) -} - -// PrependFloat64 prepends a float64 to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependFloat64(x float64) { - b.Prep(SizeFloat64, 0) - b.PlaceFloat64(x) -} - -// PrependByte prepends a byte to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependByte(x byte) { - b.Prep(SizeByte, 0) - b.PlaceByte(x) -} - -// PrependVOffsetT prepends a VOffsetT to the Builder buffer. -// Aligns and checks for space. -func (b *Builder) PrependVOffsetT(x VOffsetT) { - b.Prep(SizeVOffsetT, 0) - b.PlaceVOffsetT(x) -} - -// PlaceBool prepends a bool to the Builder, without checking for space. -func (b *Builder) PlaceBool(x bool) { - b.head -= UOffsetT(SizeBool) - WriteBool(b.Bytes[b.head:], x) -} - -// PlaceUint8 prepends a uint8 to the Builder, without checking for space. -func (b *Builder) PlaceUint8(x uint8) { - b.head -= UOffsetT(SizeUint8) - WriteUint8(b.Bytes[b.head:], x) -} - -// PlaceUint16 prepends a uint16 to the Builder, without checking for space. -func (b *Builder) PlaceUint16(x uint16) { - b.head -= UOffsetT(SizeUint16) - WriteUint16(b.Bytes[b.head:], x) -} - -// PlaceUint32 prepends a uint32 to the Builder, without checking for space. -func (b *Builder) PlaceUint32(x uint32) { - b.head -= UOffsetT(SizeUint32) - WriteUint32(b.Bytes[b.head:], x) -} - -// PlaceUint64 prepends a uint64 to the Builder, without checking for space. -func (b *Builder) PlaceUint64(x uint64) { - b.head -= UOffsetT(SizeUint64) - WriteUint64(b.Bytes[b.head:], x) -} - -// PlaceInt8 prepends a int8 to the Builder, without checking for space. -func (b *Builder) PlaceInt8(x int8) { - b.head -= UOffsetT(SizeInt8) - WriteInt8(b.Bytes[b.head:], x) -} - -// PlaceInt16 prepends a int16 to the Builder, without checking for space. -func (b *Builder) PlaceInt16(x int16) { - b.head -= UOffsetT(SizeInt16) - WriteInt16(b.Bytes[b.head:], x) -} - -// PlaceInt32 prepends a int32 to the Builder, without checking for space. -func (b *Builder) PlaceInt32(x int32) { - b.head -= UOffsetT(SizeInt32) - WriteInt32(b.Bytes[b.head:], x) -} - -// PlaceInt64 prepends a int64 to the Builder, without checking for space. -func (b *Builder) PlaceInt64(x int64) { - b.head -= UOffsetT(SizeInt64) - WriteInt64(b.Bytes[b.head:], x) -} - -// PlaceFloat32 prepends a float32 to the Builder, without checking for space. -func (b *Builder) PlaceFloat32(x float32) { - b.head -= UOffsetT(SizeFloat32) - WriteFloat32(b.Bytes[b.head:], x) -} - -// PlaceFloat64 prepends a float64 to the Builder, without checking for space. -func (b *Builder) PlaceFloat64(x float64) { - b.head -= UOffsetT(SizeFloat64) - WriteFloat64(b.Bytes[b.head:], x) -} - -// PlaceByte prepends a byte to the Builder, without checking for space. -func (b *Builder) PlaceByte(x byte) { - b.head -= UOffsetT(SizeByte) - WriteByte(b.Bytes[b.head:], x) -} - -// PlaceVOffsetT prepends a VOffsetT to the Builder, without checking for space. -func (b *Builder) PlaceVOffsetT(x VOffsetT) { - b.head -= UOffsetT(SizeVOffsetT) - WriteVOffsetT(b.Bytes[b.head:], x) -} - -// PlaceSOffsetT prepends a SOffsetT to the Builder, without checking for space. -func (b *Builder) PlaceSOffsetT(x SOffsetT) { - b.head -= UOffsetT(SizeSOffsetT) - WriteSOffsetT(b.Bytes[b.head:], x) -} - -// PlaceUOffsetT prepends a UOffsetT to the Builder, without checking for space. -func (b *Builder) PlaceUOffsetT(x UOffsetT) { - b.head -= UOffsetT(SizeUOffsetT) - WriteUOffsetT(b.Bytes[b.head:], x) -}
diff --git a/third_party/flatbuffers/go/doc.go b/third_party/flatbuffers/go/doc.go deleted file mode 100644 index 694edc7..0000000 --- a/third_party/flatbuffers/go/doc.go +++ /dev/null
@@ -1,3 +0,0 @@ -// Package flatbuffers provides facilities to read and write flatbuffers -// objects. -package flatbuffers
diff --git a/third_party/flatbuffers/go/encode.go b/third_party/flatbuffers/go/encode.go deleted file mode 100644 index 48ff36e..0000000 --- a/third_party/flatbuffers/go/encode.go +++ /dev/null
@@ -1,216 +0,0 @@ -package flatbuffers - -import ( - "math" -) - -type ( - // A SOffsetT stores a signed offset into arbitrary data. - SOffsetT int32 - // A UOffsetT stores an unsigned offset into vector data. - UOffsetT uint32 - // A VOffsetT stores an unsigned offset in a vtable. - VOffsetT uint16 -) - -const ( - // VtableMetadataFields is the count of metadata fields in each vtable. - VtableMetadataFields = 2 -) - -// GetByte decodes a little-endian byte from a byte slice. -func GetByte(buf []byte) byte { - return byte(GetUint8(buf)) -} - -// GetBool decodes a little-endian bool from a byte slice. -func GetBool(buf []byte) bool { - return buf[0] == 1 -} - -// GetUint8 decodes a little-endian uint8 from a byte slice. -func GetUint8(buf []byte) (n uint8) { - n = uint8(buf[0]) - return -} - -// GetUint16 decodes a little-endian uint16 from a byte slice. -func GetUint16(buf []byte) (n uint16) { - n |= uint16(buf[0]) - n |= uint16(buf[1]) << 8 - return -} - -// GetUint32 decodes a little-endian uint32 from a byte slice. -func GetUint32(buf []byte) (n uint32) { - n |= uint32(buf[0]) - n |= uint32(buf[1]) << 8 - n |= uint32(buf[2]) << 16 - n |= uint32(buf[3]) << 24 - return -} - -// GetUint64 decodes a little-endian uint64 from a byte slice. -func GetUint64(buf []byte) (n uint64) { - n |= uint64(buf[0]) - n |= uint64(buf[1]) << 8 - n |= uint64(buf[2]) << 16 - n |= uint64(buf[3]) << 24 - n |= uint64(buf[4]) << 32 - n |= uint64(buf[5]) << 40 - n |= uint64(buf[6]) << 48 - n |= uint64(buf[7]) << 56 - return -} - -// GetInt8 decodes a little-endian int8 from a byte slice. -func GetInt8(buf []byte) (n int8) { - n = int8(buf[0]) - return -} - -// GetInt16 decodes a little-endian int16 from a byte slice. -func GetInt16(buf []byte) (n int16) { - n |= int16(buf[0]) - n |= int16(buf[1]) << 8 - return -} - -// GetInt32 decodes a little-endian int32 from a byte slice. -func GetInt32(buf []byte) (n int32) { - n |= int32(buf[0]) - n |= int32(buf[1]) << 8 - n |= int32(buf[2]) << 16 - n |= int32(buf[3]) << 24 - return -} - -// GetInt64 decodes a little-endian int64 from a byte slice. -func GetInt64(buf []byte) (n int64) { - n |= int64(buf[0]) - n |= int64(buf[1]) << 8 - n |= int64(buf[2]) << 16 - n |= int64(buf[3]) << 24 - n |= int64(buf[4]) << 32 - n |= int64(buf[5]) << 40 - n |= int64(buf[6]) << 48 - n |= int64(buf[7]) << 56 - return -} - -// GetFloat32 decodes a little-endian float32 from a byte slice. -func GetFloat32(buf []byte) float32 { - x := GetUint32(buf) - return math.Float32frombits(x) -} - -// GetFloat64 decodes a little-endian float64 from a byte slice. -func GetFloat64(buf []byte) float64 { - x := GetUint64(buf) - return math.Float64frombits(x) -} - -// GetUOffsetT decodes a little-endian UOffsetT from a byte slice. -func GetUOffsetT(buf []byte) UOffsetT { - return UOffsetT(GetInt32(buf)) -} - -// GetSOffsetT decodes a little-endian SOffsetT from a byte slice. -func GetSOffsetT(buf []byte) SOffsetT { - return SOffsetT(GetInt32(buf)) -} - -// GetVOffsetT decodes a little-endian VOffsetT from a byte slice. -func GetVOffsetT(buf []byte) VOffsetT { - return VOffsetT(GetUint16(buf)) -} - -// WriteByte encodes a little-endian uint8 into a byte slice. -func WriteByte(buf []byte, n byte) { - WriteUint8(buf, uint8(n)) -} - -// WriteBool encodes a little-endian bool into a byte slice. -func WriteBool(buf []byte, b bool) { - buf[0] = 0 - if b { - buf[0] = 1 - } -} - -// WriteUint8 encodes a little-endian uint8 into a byte slice. -func WriteUint8(buf []byte, n uint8) { - buf[0] = byte(n) -} - -// WriteUint16 encodes a little-endian uint16 into a byte slice. -func WriteUint16(buf []byte, n uint16) { - buf[0] = byte(n) - buf[1] = byte(n >> 8) -} - -// WriteUint32 encodes a little-endian uint32 into a byte slice. -func WriteUint32(buf []byte, n uint32) { - buf[0] = byte(n) - buf[1] = byte(n >> 8) - buf[2] = byte(n >> 16) - buf[3] = byte(n >> 24) -} - -// WriteUint64 encodes a little-endian uint64 into a byte slice. -func WriteUint64(buf []byte, n uint64) { - for i := uint(0); i < uint(SizeUint64); i++ { - buf[i] = byte(n >> (i * 8)) - } -} - -// WriteInt8 encodes a little-endian int8 into a byte slice. -func WriteInt8(buf []byte, n int8) { - buf[0] = byte(n) -} - -// WriteInt16 encodes a little-endian int16 into a byte slice. -func WriteInt16(buf []byte, n int16) { - buf[0] = byte(n) - buf[1] = byte(n >> 8) -} - -// WriteInt32 encodes a little-endian int32 into a byte slice. -func WriteInt32(buf []byte, n int32) { - buf[0] = byte(n) - buf[1] = byte(n >> 8) - buf[2] = byte(n >> 16) - buf[3] = byte(n >> 24) -} - -// WriteInt64 encodes a little-endian int64 into a byte slice. -func WriteInt64(buf []byte, n int64) { - for i := uint(0); i < uint(SizeInt64); i++ { - buf[i] = byte(n >> (i * 8)) - } -} - -// WriteFloat32 encodes a little-endian float32 into a byte slice. -func WriteFloat32(buf []byte, n float32) { - WriteUint32(buf, math.Float32bits(n)) -} - -// WriteFloat64 encodes a little-endian float64 into a byte slice. -func WriteFloat64(buf []byte, n float64) { - WriteUint64(buf, math.Float64bits(n)) -} - -// WriteVOffsetT encodes a little-endian VOffsetT into a byte slice. -func WriteVOffsetT(buf []byte, n VOffsetT) { - WriteUint16(buf, uint16(n)) -} - -// WriteSOffsetT encodes a little-endian SOffsetT into a byte slice. -func WriteSOffsetT(buf []byte, n SOffsetT) { - WriteInt32(buf, int32(n)) -} - -// WriteUOffsetT encodes a little-endian UOffsetT into a byte slice. -func WriteUOffsetT(buf []byte, n UOffsetT) { - WriteUint32(buf, uint32(n)) -}
diff --git a/third_party/flatbuffers/go/grpc.go b/third_party/flatbuffers/go/grpc.go deleted file mode 100644 index e7dabd3..0000000 --- a/third_party/flatbuffers/go/grpc.go +++ /dev/null
@@ -1,23 +0,0 @@ -package flatbuffers - -// Codec implements gRPC-go Codec which is used to encode and decode messages. -var Codec = "flatbuffers" - -type FlatbuffersCodec struct{} - -func (FlatbuffersCodec) Marshal(v interface{}) ([]byte, error) { - return v.(*Builder).FinishedBytes(), nil -} - -func (FlatbuffersCodec) Unmarshal(data []byte, v interface{}) error { - v.(flatbuffersInit).Init(data, GetUOffsetT(data)) - return nil -} - -func (FlatbuffersCodec) String() string { - return Codec -} - -type flatbuffersInit interface { - Init(data []byte, i UOffsetT) -}
diff --git a/third_party/flatbuffers/go/lib.go b/third_party/flatbuffers/go/lib.go deleted file mode 100644 index adfce52..0000000 --- a/third_party/flatbuffers/go/lib.go +++ /dev/null
@@ -1,13 +0,0 @@ -package flatbuffers - -// FlatBuffer is the interface that represents a flatbuffer. -type FlatBuffer interface { - Table() Table - Init(buf []byte, i UOffsetT) -} - -// GetRootAs is a generic helper to initialize a FlatBuffer with the provided buffer bytes and its data offset. -func GetRootAs(buf []byte, offset UOffsetT, fb FlatBuffer) { - n := GetUOffsetT(buf[offset:]) - fb.Init(buf, n+offset) -}
diff --git a/third_party/flatbuffers/go/sizes.go b/third_party/flatbuffers/go/sizes.go deleted file mode 100644 index ba22169..0000000 --- a/third_party/flatbuffers/go/sizes.go +++ /dev/null
@@ -1,55 +0,0 @@ -package flatbuffers - -import ( - "unsafe" -) - -const ( - // See http://golang.org/ref/spec#Numeric_types - - // SizeUint8 is the byte size of a uint8. - SizeUint8 = 1 - // SizeUint16 is the byte size of a uint16. - SizeUint16 = 2 - // SizeUint32 is the byte size of a uint32. - SizeUint32 = 4 - // SizeUint64 is the byte size of a uint64. - SizeUint64 = 8 - - // SizeInt8 is the byte size of a int8. - SizeInt8 = 1 - // SizeInt16 is the byte size of a int16. - SizeInt16 = 2 - // SizeInt32 is the byte size of a int32. - SizeInt32 = 4 - // SizeInt64 is the byte size of a int64. - SizeInt64 = 8 - - // SizeFloat32 is the byte size of a float32. - SizeFloat32 = 4 - // SizeFloat64 is the byte size of a float64. - SizeFloat64 = 8 - - // SizeByte is the byte size of a byte. - // The `byte` type is aliased (by Go definition) to uint8. - SizeByte = 1 - - // SizeBool is the byte size of a bool. - // The `bool` type is aliased (by flatbuffers convention) to uint8. - SizeBool = 1 - - // SizeSOffsetT is the byte size of an SOffsetT. - // The `SOffsetT` type is aliased (by flatbuffers convention) to int32. - SizeSOffsetT = 4 - // SizeUOffsetT is the byte size of an UOffsetT. - // The `UOffsetT` type is aliased (by flatbuffers convention) to uint32. - SizeUOffsetT = 4 - // SizeVOffsetT is the byte size of an VOffsetT. - // The `VOffsetT` type is aliased (by flatbuffers convention) to uint16. - SizeVOffsetT = 2 -) - -// byteSliceToString converts a []byte to string without a heap allocation. -func byteSliceToString(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -}
diff --git a/third_party/flatbuffers/go/struct.go b/third_party/flatbuffers/go/struct.go deleted file mode 100644 index 11258f7..0000000 --- a/third_party/flatbuffers/go/struct.go +++ /dev/null
@@ -1,8 +0,0 @@ -package flatbuffers - -// Struct wraps a byte slice and provides read access to its data. -// -// Structs do not have a vtable. -type Struct struct { - Table -}
diff --git a/third_party/flatbuffers/go/table.go b/third_party/flatbuffers/go/table.go deleted file mode 100644 index b273146..0000000 --- a/third_party/flatbuffers/go/table.go +++ /dev/null
@@ -1,505 +0,0 @@ -package flatbuffers - -// Table wraps a byte slice and provides read access to its data. -// -// The variable `Pos` indicates the root of the FlatBuffers object therein. -type Table struct { - Bytes []byte - Pos UOffsetT // Always < 1<<31. -} - -// Offset provides access into the Table's vtable. -// -// Fields which are deprecated are ignored by checking against the vtable's length. -func (t *Table) Offset(vtableOffset VOffsetT) VOffsetT { - vtable := UOffsetT(SOffsetT(t.Pos) - t.GetSOffsetT(t.Pos)) - if vtableOffset < t.GetVOffsetT(vtable) { - return t.GetVOffsetT(vtable + UOffsetT(vtableOffset)) - } - return 0 -} - -// Indirect retrieves the relative offset stored at `offset`. -func (t *Table) Indirect(off UOffsetT) UOffsetT { - return off + GetUOffsetT(t.Bytes[off:]) -} - -// String gets a string from data stored inside the flatbuffer. -func (t *Table) String(off UOffsetT) string { - b := t.ByteVector(off) - return byteSliceToString(b) -} - -// ByteVector gets a byte slice from data stored inside the flatbuffer. -func (t *Table) ByteVector(off UOffsetT) []byte { - off += GetUOffsetT(t.Bytes[off:]) - start := off + UOffsetT(SizeUOffsetT) - length := GetUOffsetT(t.Bytes[off:]) - return t.Bytes[start : start+length] -} - -// VectorLen retrieves the length of the vector whose offset is stored at -// "off" in this object. -func (t *Table) VectorLen(off UOffsetT) int { - off += t.Pos - off += GetUOffsetT(t.Bytes[off:]) - return int(GetUOffsetT(t.Bytes[off:])) -} - -// Vector retrieves the start of data of the vector whose offset is stored -// at "off" in this object. -func (t *Table) Vector(off UOffsetT) UOffsetT { - off += t.Pos - x := off + GetUOffsetT(t.Bytes[off:]) - // data starts after metadata containing the vector length - x += UOffsetT(SizeUOffsetT) - return x -} - -// Union initializes any Table-derived type to point to the union at the given -// offset. -func (t *Table) Union(t2 *Table, off UOffsetT) { - off += t.Pos - t2.Pos = off + t.GetUOffsetT(off) - t2.Bytes = t.Bytes -} - -// GetBool retrieves a bool at the given offset. -func (t *Table) GetBool(off UOffsetT) bool { - return GetBool(t.Bytes[off:]) -} - -// GetByte retrieves a byte at the given offset. -func (t *Table) GetByte(off UOffsetT) byte { - return GetByte(t.Bytes[off:]) -} - -// GetUint8 retrieves a uint8 at the given offset. -func (t *Table) GetUint8(off UOffsetT) uint8 { - return GetUint8(t.Bytes[off:]) -} - -// GetUint16 retrieves a uint16 at the given offset. -func (t *Table) GetUint16(off UOffsetT) uint16 { - return GetUint16(t.Bytes[off:]) -} - -// GetUint32 retrieves a uint32 at the given offset. -func (t *Table) GetUint32(off UOffsetT) uint32 { - return GetUint32(t.Bytes[off:]) -} - -// GetUint64 retrieves a uint64 at the given offset. -func (t *Table) GetUint64(off UOffsetT) uint64 { - return GetUint64(t.Bytes[off:]) -} - -// GetInt8 retrieves a int8 at the given offset. -func (t *Table) GetInt8(off UOffsetT) int8 { - return GetInt8(t.Bytes[off:]) -} - -// GetInt16 retrieves a int16 at the given offset. -func (t *Table) GetInt16(off UOffsetT) int16 { - return GetInt16(t.Bytes[off:]) -} - -// GetInt32 retrieves a int32 at the given offset. -func (t *Table) GetInt32(off UOffsetT) int32 { - return GetInt32(t.Bytes[off:]) -} - -// GetInt64 retrieves a int64 at the given offset. -func (t *Table) GetInt64(off UOffsetT) int64 { - return GetInt64(t.Bytes[off:]) -} - -// GetFloat32 retrieves a float32 at the given offset. -func (t *Table) GetFloat32(off UOffsetT) float32 { - return GetFloat32(t.Bytes[off:]) -} - -// GetFloat64 retrieves a float64 at the given offset. -func (t *Table) GetFloat64(off UOffsetT) float64 { - return GetFloat64(t.Bytes[off:]) -} - -// GetUOffsetT retrieves a UOffsetT at the given offset. -func (t *Table) GetUOffsetT(off UOffsetT) UOffsetT { - return GetUOffsetT(t.Bytes[off:]) -} - -// GetVOffsetT retrieves a VOffsetT at the given offset. -func (t *Table) GetVOffsetT(off UOffsetT) VOffsetT { - return GetVOffsetT(t.Bytes[off:]) -} - -// GetSOffsetT retrieves a SOffsetT at the given offset. -func (t *Table) GetSOffsetT(off UOffsetT) SOffsetT { - return GetSOffsetT(t.Bytes[off:]) -} - -// GetBoolSlot retrieves the bool that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetBoolSlot(slot VOffsetT, d bool) bool { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetBool(t.Pos + UOffsetT(off)) -} - -// GetByteSlot retrieves the byte that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetByteSlot(slot VOffsetT, d byte) byte { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetByte(t.Pos + UOffsetT(off)) -} - -// GetInt8Slot retrieves the int8 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetInt8Slot(slot VOffsetT, d int8) int8 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetInt8(t.Pos + UOffsetT(off)) -} - -// GetUint8Slot retrieves the uint8 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetUint8Slot(slot VOffsetT, d uint8) uint8 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetUint8(t.Pos + UOffsetT(off)) -} - -// GetInt16Slot retrieves the int16 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetInt16Slot(slot VOffsetT, d int16) int16 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetInt16(t.Pos + UOffsetT(off)) -} - -// GetUint16Slot retrieves the uint16 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetUint16Slot(slot VOffsetT, d uint16) uint16 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetUint16(t.Pos + UOffsetT(off)) -} - -// GetInt32Slot retrieves the int32 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetInt32Slot(slot VOffsetT, d int32) int32 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetInt32(t.Pos + UOffsetT(off)) -} - -// GetUint32Slot retrieves the uint32 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetUint32Slot(slot VOffsetT, d uint32) uint32 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetUint32(t.Pos + UOffsetT(off)) -} - -// GetInt64Slot retrieves the int64 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetInt64Slot(slot VOffsetT, d int64) int64 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetInt64(t.Pos + UOffsetT(off)) -} - -// GetUint64Slot retrieves the uint64 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetUint64Slot(slot VOffsetT, d uint64) uint64 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetUint64(t.Pos + UOffsetT(off)) -} - -// GetFloat32Slot retrieves the float32 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetFloat32Slot(slot VOffsetT, d float32) float32 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetFloat32(t.Pos + UOffsetT(off)) -} - -// GetFloat64Slot retrieves the float64 that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetFloat64Slot(slot VOffsetT, d float64) float64 { - off := t.Offset(slot) - if off == 0 { - return d - } - - return t.GetFloat64(t.Pos + UOffsetT(off)) -} - -// GetVOffsetTSlot retrieves the VOffsetT that the given vtable location -// points to. If the vtable value is zero, the default value `d` -// will be returned. -func (t *Table) GetVOffsetTSlot(slot VOffsetT, d VOffsetT) VOffsetT { - off := t.Offset(slot) - if off == 0 { - return d - } - return VOffsetT(off) -} - -// MutateBool updates a bool at the given offset. -func (t *Table) MutateBool(off UOffsetT, n bool) bool { - WriteBool(t.Bytes[off:], n) - return true -} - -// MutateByte updates a Byte at the given offset. -func (t *Table) MutateByte(off UOffsetT, n byte) bool { - WriteByte(t.Bytes[off:], n) - return true -} - -// MutateUint8 updates a Uint8 at the given offset. -func (t *Table) MutateUint8(off UOffsetT, n uint8) bool { - WriteUint8(t.Bytes[off:], n) - return true -} - -// MutateUint16 updates a Uint16 at the given offset. -func (t *Table) MutateUint16(off UOffsetT, n uint16) bool { - WriteUint16(t.Bytes[off:], n) - return true -} - -// MutateUint32 updates a Uint32 at the given offset. -func (t *Table) MutateUint32(off UOffsetT, n uint32) bool { - WriteUint32(t.Bytes[off:], n) - return true -} - -// MutateUint64 updates a Uint64 at the given offset. -func (t *Table) MutateUint64(off UOffsetT, n uint64) bool { - WriteUint64(t.Bytes[off:], n) - return true -} - -// MutateInt8 updates a Int8 at the given offset. -func (t *Table) MutateInt8(off UOffsetT, n int8) bool { - WriteInt8(t.Bytes[off:], n) - return true -} - -// MutateInt16 updates a Int16 at the given offset. -func (t *Table) MutateInt16(off UOffsetT, n int16) bool { - WriteInt16(t.Bytes[off:], n) - return true -} - -// MutateInt32 updates a Int32 at the given offset. -func (t *Table) MutateInt32(off UOffsetT, n int32) bool { - WriteInt32(t.Bytes[off:], n) - return true -} - -// MutateInt64 updates a Int64 at the given offset. -func (t *Table) MutateInt64(off UOffsetT, n int64) bool { - WriteInt64(t.Bytes[off:], n) - return true -} - -// MutateFloat32 updates a Float32 at the given offset. -func (t *Table) MutateFloat32(off UOffsetT, n float32) bool { - WriteFloat32(t.Bytes[off:], n) - return true -} - -// MutateFloat64 updates a Float64 at the given offset. -func (t *Table) MutateFloat64(off UOffsetT, n float64) bool { - WriteFloat64(t.Bytes[off:], n) - return true -} - -// MutateUOffsetT updates a UOffsetT at the given offset. -func (t *Table) MutateUOffsetT(off UOffsetT, n UOffsetT) bool { - WriteUOffsetT(t.Bytes[off:], n) - return true -} - -// MutateVOffsetT updates a VOffsetT at the given offset. -func (t *Table) MutateVOffsetT(off UOffsetT, n VOffsetT) bool { - WriteVOffsetT(t.Bytes[off:], n) - return true -} - -// MutateSOffsetT updates a SOffsetT at the given offset. -func (t *Table) MutateSOffsetT(off UOffsetT, n SOffsetT) bool { - WriteSOffsetT(t.Bytes[off:], n) - return true -} - -// MutateBoolSlot updates the bool at given vtable location -func (t *Table) MutateBoolSlot(slot VOffsetT, n bool) bool { - if off := t.Offset(slot); off != 0 { - t.MutateBool(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateByteSlot updates the byte at given vtable location -func (t *Table) MutateByteSlot(slot VOffsetT, n byte) bool { - if off := t.Offset(slot); off != 0 { - t.MutateByte(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateInt8Slot updates the int8 at given vtable location -func (t *Table) MutateInt8Slot(slot VOffsetT, n int8) bool { - if off := t.Offset(slot); off != 0 { - t.MutateInt8(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateUint8Slot updates the uint8 at given vtable location -func (t *Table) MutateUint8Slot(slot VOffsetT, n uint8) bool { - if off := t.Offset(slot); off != 0 { - t.MutateUint8(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateInt16Slot updates the int16 at given vtable location -func (t *Table) MutateInt16Slot(slot VOffsetT, n int16) bool { - if off := t.Offset(slot); off != 0 { - t.MutateInt16(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateUint16Slot updates the uint16 at given vtable location -func (t *Table) MutateUint16Slot(slot VOffsetT, n uint16) bool { - if off := t.Offset(slot); off != 0 { - t.MutateUint16(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateInt32Slot updates the int32 at given vtable location -func (t *Table) MutateInt32Slot(slot VOffsetT, n int32) bool { - if off := t.Offset(slot); off != 0 { - t.MutateInt32(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateUint32Slot updates the uint32 at given vtable location -func (t *Table) MutateUint32Slot(slot VOffsetT, n uint32) bool { - if off := t.Offset(slot); off != 0 { - t.MutateUint32(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateInt64Slot updates the int64 at given vtable location -func (t *Table) MutateInt64Slot(slot VOffsetT, n int64) bool { - if off := t.Offset(slot); off != 0 { - t.MutateInt64(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateUint64Slot updates the uint64 at given vtable location -func (t *Table) MutateUint64Slot(slot VOffsetT, n uint64) bool { - if off := t.Offset(slot); off != 0 { - t.MutateUint64(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateFloat32Slot updates the float32 at given vtable location -func (t *Table) MutateFloat32Slot(slot VOffsetT, n float32) bool { - if off := t.Offset(slot); off != 0 { - t.MutateFloat32(t.Pos+UOffsetT(off), n) - return true - } - - return false -} - -// MutateFloat64Slot updates the float64 at given vtable location -func (t *Table) MutateFloat64Slot(slot VOffsetT, n float64) bool { - if off := t.Offset(slot); off != 0 { - t.MutateFloat64(t.Pos+UOffsetT(off), n) - return true - } - - return false -}
diff --git a/third_party/flatbuffers/grpc/README.md b/third_party/flatbuffers/grpc/README.md deleted file mode 100644 index 1348519..0000000 --- a/third_party/flatbuffers/grpc/README.md +++ /dev/null
@@ -1,11 +0,0 @@ -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/third_party/flatbuffers/grpc/src/compiler/cpp_generator.cc b/third_party/flatbuffers/grpc/src/compiler/cpp_generator.cc deleted file mode 100644 index da58ee0..0000000 --- a/third_party/flatbuffers/grpc/src/compiler/cpp_generator.cc +++ /dev/null
@@ -1,1203 +0,0 @@ -/* - * - * 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 <map> - -#include "src/compiler/cpp_generator.h" - -#include <sstream> - -namespace grpc_cpp_generator { -namespace { - -template <class T> -grpc::string as_string(T x) { - std::ostringstream out; - out << x; - return out.str(); -} - -grpc::string FilenameIdentifier(const grpc::string &filename) { - grpc::string result; - for (unsigned i = 0; i < filename.size(); i++) { - char c = filename[i]; - if (isalnum(c)) { - result.push_back(c); - } else { - static char hex[] = "0123456789abcdef"; - result.push_back('_'); - result.push_back(hex[(c >> 4) & 0xf]); - result.push_back(hex[c & 0xf]); - } - } - return result; -} -} // namespace - -template<class T, size_t N> -T *array_end(T (&array)[N]) { return array + N; } - -void PrintIncludes(grpc_generator::Printer *printer, - const std::vector<grpc::string>& headers, const Parameters ¶ms) { - std::map<grpc::string, grpc::string> vars; - - vars["l"] = params.use_system_headers ? '<' : '"'; - vars["r"] = params.use_system_headers ? '>' : '"'; - - if (!params.grpc_search_path.empty()) { - vars["l"] += params.grpc_search_path; - if (params.grpc_search_path.back() != '/') { - vars["l"] += '/'; - } - } - - for (auto i = headers.begin(); i != headers.end(); i++) { - vars["h"] = *i; - printer->Print(vars, "#include $l$$h$$r$\n"); - } -} - -grpc::string GetHeaderPrologue(grpc_generator::File *file, const Parameters & /*params*/) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - - vars["filename"] = file->filename(); - vars["filename_identifier"] = FilenameIdentifier(file->filename()); - vars["filename_base"] = file->filename_without_ext(); - vars["message_header_ext"] = file->message_header_ext(); - - printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n"); - printer->Print(vars, - "// If you make any local change, they will be lost.\n"); - printer->Print(vars, "// source: $filename$\n"); - printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n"); - printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n"); - printer->Print(vars, "\n"); - printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n"); - printer->Print(vars, file->additional_headers().c_str()); - printer->Print(vars, "\n"); - } - return output; -} - -grpc::string GetHeaderIncludes(grpc_generator::File *file, - const Parameters ¶ms) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - - static const char *headers_strs[] = { - "grpc++/impl/codegen/async_stream.h", - "grpc++/impl/codegen/async_unary_call.h", - "grpc++/impl/codegen/rpc_method.h", - "grpc++/impl/codegen/service_type.h", - "grpc++/impl/codegen/status.h", - "grpc++/impl/codegen/stub_options.h", - "grpc++/impl/codegen/sync_stream.h" - }; - std::vector<grpc::string> headers(headers_strs, array_end(headers_strs)); - PrintIncludes(printer.get(), headers, params); - printer->Print(vars, "\n"); - printer->Print(vars, "namespace grpc {\n"); - printer->Print(vars, "class CompletionQueue;\n"); - printer->Print(vars, "class Channel;\n"); - printer->Print(vars, "class RpcService;\n"); - printer->Print(vars, "class ServerCompletionQueue;\n"); - printer->Print(vars, "class ServerContext;\n"); - printer->Print(vars, "} // namespace grpc\n\n"); - - if (!file->package().empty()) { - std::vector<grpc::string> parts = file->package_parts(); - - for (auto part = parts.begin(); part != parts.end(); part++) { - vars["part"] = *part; - printer->Print(vars, "namespace $part$ {\n"); - } - printer->Print(vars, "\n"); - } - } - return output; -} - -void PrintHeaderClientMethodInterfaces( - grpc_generator::Printer *printer, const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars, bool is_public) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - - if (is_public) { - if (method->NoStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::Status $Method$(::grpc::ClientContext* context, " - "const $Request$& request, $Response$* response) = 0;\n"); - printer->Print(*vars, - "std::unique_ptr< " - "::grpc::ClientAsyncResponseReaderInterface< $Response$>> " - "Async$Method$(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncResponseReaderInterface< $Response$>>(" - "Async$Method$Raw(context, request, cq));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientWriterInterface< $Request$>>" - " $Method$(" - "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientWriterInterface< $Request$>>" - "($Method$Raw(context, response));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncWriterInterface< $Request$>>" - " Async$Method$(::grpc::ClientContext* context, $Response$* " - "response, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncWriterInterface< $Request$>>(" - "Async$Method$Raw(context, response, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientReaderInterface< $Response$>>" - " $Method$(::grpc::ClientContext* context, const $Request$& request)" - " {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientReaderInterface< $Response$>>" - "($Method$Raw(context, request));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncReaderInterface< $Response$>> " - "Async$Method$(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderInterface< $Response$>>(" - "Async$Method$Raw(context, request, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->BidiStreaming()) { - printer->Print(*vars, - "std::unique_ptr< ::grpc::ClientReaderWriterInterface< " - "$Request$, $Response$>> " - "$Method$(::grpc::ClientContext* context) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientReaderWriterInterface< $Request$, $Response$>>(" - "$Method$Raw(context));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print( - *vars, - "std::unique_ptr< " - "::grpc::ClientAsyncReaderWriterInterface< $Request$, $Response$>> " - "Async$Method$(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderWriterInterface< $Request$, $Response$>>(" - "Async$Method$Raw(context, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } - } else { - if (method->NoStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncResponseReaderInterface< $Response$>* " - "Async$Method$Raw(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) = 0;\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::ClientWriterInterface< $Request$>*" - " $Method$Raw(" - "::grpc::ClientContext* context, $Response$* response) = 0;\n"); - printer->Print(*vars, - "virtual ::grpc::ClientAsyncWriterInterface< $Request$>*" - " Async$Method$Raw(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::CompletionQueue* cq, void* tag) = 0;\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::ClientReaderInterface< $Response$>* $Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request) = 0;\n"); - printer->Print( - *vars, - "virtual ::grpc::ClientAsyncReaderInterface< $Response$>* " - "Async$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq, void* tag) = 0;\n"); - } else if (method->BidiStreaming()) { - printer->Print(*vars, - "virtual ::grpc::ClientReaderWriterInterface< $Request$, " - "$Response$>* " - "$Method$Raw(::grpc::ClientContext* context) = 0;\n"); - printer->Print(*vars, - "virtual ::grpc::ClientAsyncReaderWriterInterface< " - "$Request$, $Response$>* " - "Async$Method$Raw(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq, void* tag) = 0;\n"); - } - } -} - -void PrintHeaderClientMethod(grpc_generator::Printer *printer, - const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars, - bool is_public) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - if (is_public) { - if (method->NoStreaming()) { - printer->Print( - *vars, - "::grpc::Status $Method$(::grpc::ClientContext* context, " - "const $Request$& request, $Response$* response) GRPC_OVERRIDE;\n"); - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> " - "Async$Method$(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncResponseReader< $Response$>>(" - "Async$Method$Raw(context, request, cq));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientWriter< $Request$>>" - " $Method$(" - "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< ::grpc::ClientWriter< $Request$>>" - "($Method$Raw(context, response));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print(*vars, - "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>" - " Async$Method$(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>>(" - "Async$Method$Raw(context, response, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientReader< $Response$>>" - " $Method$(::grpc::ClientContext* context, const $Request$& request)" - " {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientReader< $Response$>>" - "($Method$Raw(context, request));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> " - "Async$Method$(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print( - *vars, - "return std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>>(" - "Async$Method$Raw(context, request, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "std::unique_ptr< ::grpc::ClientReaderWriter< $Request$, $Response$>>" - " $Method$(::grpc::ClientContext* context) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientReaderWriter< $Request$, $Response$>>(" - "$Method$Raw(context));\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print(*vars, - "std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " - "$Request$, $Response$>> " - "Async$Method$(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Indent(); - printer->Print(*vars, - "return std::unique_ptr< " - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>>(" - "Async$Method$Raw(context, cq, tag));\n"); - printer->Outdent(); - printer->Print("}\n"); - } - } else { - if (method->NoStreaming()) { - printer->Print(*vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "Async$Method$Raw(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) GRPC_OVERRIDE;\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print(*vars, - "::grpc::ClientWriter< $Request$>* $Method$Raw(" - "::grpc::ClientContext* context, $Response$* response) " - "GRPC_OVERRIDE;\n"); - printer->Print( - *vars, - "::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw(" - "::grpc::ClientContext* context, $Response$* response, " - "::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print(*vars, - "::grpc::ClientReader< $Response$>* $Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request)" - " GRPC_OVERRIDE;\n"); - printer->Print( - *vars, - "::grpc::ClientAsyncReader< $Response$>* Async$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "::grpc::ClientReaderWriter< $Request$, $Response$>* " - "$Method$Raw(::grpc::ClientContext* context) GRPC_OVERRIDE;\n"); - printer->Print( - *vars, - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " - "Async$Method$Raw(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n"); - } - } -} - -void PrintHeaderClientMethodData(grpc_generator::Printer *printer, const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - printer->Print(*vars, "const ::grpc::RpcMethod rpcmethod_$Method$_;\n"); -} - -void PrintHeaderServerMethodSync(grpc_generator::Printer *printer, const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - if (method->NoStreaming()) { - printer->Print(*vars, - "virtual ::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response);\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print(*vars, - "virtual ::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response);\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print(*vars, - "virtual ::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer);\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);" - "\n"); - } -} - -void PrintHeaderServerMethodAsync( - grpc_generator::Printer *printer, - const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - printer->Print(*vars, "template <class BaseClass>\n"); - printer->Print(*vars, - "class WithAsyncMethod_$Method$ : public BaseClass {\n"); - printer->Print( - " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); - printer->Print(" public:\n"); - printer->Indent(); - printer->Print(*vars, - "WithAsyncMethod_$Method$() {\n" - " ::grpc::Service::MarkMethodAsync($Idx$);\n" - "}\n"); - printer->Print(*vars, - "~WithAsyncMethod_$Method$() GRPC_OVERRIDE {\n" - " BaseClassMustBeDerivedFromService(this);\n" - "}\n"); - if (method->NoStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - printer->Print( - *vars, - "void Request$Method$(" - "::grpc::ServerContext* context, $Request$* request, " - "::grpc::ServerAsyncResponseWriter< $Response$>* response, " - "::grpc::CompletionQueue* new_call_cq, " - "::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n"); - printer->Print(*vars, - " ::grpc::Service::RequestAsyncUnary($Idx$, context, " - "request, response, new_call_cq, notification_cq, tag);\n"); - printer->Print("}\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - printer->Print( - *vars, - "void Request$Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerAsyncReader< $Response$, $Request$>* reader, " - "::grpc::CompletionQueue* new_call_cq, " - "::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n"); - printer->Print(*vars, - " ::grpc::Service::RequestAsyncClientStreaming($Idx$, " - "context, reader, new_call_cq, notification_cq, tag);\n"); - printer->Print("}\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) GRPC_FINAL GRPC_OVERRIDE " - "{\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - printer->Print( - *vars, - "void Request$Method$(" - "::grpc::ServerContext* context, $Request$* request, " - "::grpc::ServerAsyncWriter< $Response$>* writer, " - "::grpc::CompletionQueue* new_call_cq, " - "::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n"); - printer->Print( - *vars, - " ::grpc::Service::RequestAsyncServerStreaming($Idx$, " - "context, request, writer, new_call_cq, notification_cq, tag);\n"); - printer->Print("}\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " - "GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - printer->Print( - *vars, - "void Request$Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerAsyncReaderWriter< $Response$, $Request$>* stream, " - "::grpc::CompletionQueue* new_call_cq, " - "::grpc::ServerCompletionQueue* notification_cq, void *tag) {\n"); - printer->Print(*vars, - " ::grpc::Service::RequestAsyncBidiStreaming($Idx$, " - "context, stream, new_call_cq, notification_cq, tag);\n"); - printer->Print("}\n"); - } - printer->Outdent(); - printer->Print(*vars, "};\n"); -} - -void PrintHeaderServerMethodGeneric( - grpc_generator::Printer *printer, - const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - printer->Print(*vars, "template <class BaseClass>\n"); - printer->Print(*vars, - "class WithGenericMethod_$Method$ : public BaseClass {\n"); - printer->Print( - " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); - printer->Print(" public:\n"); - printer->Indent(); - printer->Print(*vars, - "WithGenericMethod_$Method$() {\n" - " ::grpc::Service::MarkMethodGeneric($Idx$);\n" - "}\n"); - printer->Print(*vars, - "~WithGenericMethod_$Method$() GRPC_OVERRIDE {\n" - " BaseClassMustBeDerivedFromService(this);\n" - "}\n"); - if (method->NoStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) GRPC_FINAL GRPC_OVERRIDE " - "{\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "// disable synchronous version of this method\n" - "::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream) " - "GRPC_FINAL GRPC_OVERRIDE {\n" - " abort();\n" - " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" - "}\n"); - } - printer->Outdent(); - printer->Print(*vars, "};\n"); -} - -void PrintHeaderService(grpc_generator::Printer *printer, - const grpc_generator::Service *service, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Service"] = service->name(); - - printer->Print(*vars, - "class $Service$ GRPC_FINAL {\n" - " public:\n"); - printer->Indent(); - - // Client side - printer->Print( - "class StubInterface {\n" - " public:\n"); - printer->Indent(); - printer->Print("virtual ~StubInterface() {}\n"); - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, true); - } - printer->Outdent(); - printer->Print("private:\n"); - printer->Indent(); - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, false); - } - printer->Outdent(); - printer->Print("};\n"); - printer->Print( - "class Stub GRPC_FINAL : public StubInterface" - " {\n public:\n"); - printer->Indent(); - printer->Print("Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);\n"); - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethod(printer, service->method(i).get(), vars, true); - } - printer->Outdent(); - printer->Print("\n private:\n"); - printer->Indent(); - printer->Print("std::shared_ptr< ::grpc::ChannelInterface> channel_;\n"); - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethod(printer, service->method(i).get(), vars, false); - } - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethodData(printer, service->method(i).get(), vars); - } - printer->Outdent(); - printer->Print("};\n"); - printer->Print( - "static std::unique_ptr<Stub> NewStub(const std::shared_ptr< " - "::grpc::ChannelInterface>& channel, " - "const ::grpc::StubOptions& options = ::grpc::StubOptions());\n"); - - printer->Print("\n"); - - // Server side - base - printer->Print( - "class Service : public ::grpc::Service {\n" - " public:\n"); - printer->Indent(); - printer->Print("Service();\n"); - printer->Print("virtual ~Service();\n"); - for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderServerMethodSync(printer, service->method(i).get(), vars); - } - printer->Outdent(); - printer->Print("};\n"); - - // Server side - Asynchronous - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodAsync(printer, service->method(i).get(), vars); - } - - printer->Print("typedef "); - - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i).get()->name(); - printer->Print(*vars, "WithAsyncMethod_$method_name$<"); - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - printer->Print(" >"); - } - printer->Print(" AsyncService;\n"); - - // Server side - Generic - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars); - } - - printer->Outdent(); - printer->Print("};\n"); -} - -grpc::string GetHeaderServices(grpc_generator::File *file, - const Parameters ¶ms) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - // Package string is empty or ends with a dot. It is used to fully qualify - // method names. - vars["Package"] = file->package(); - if (!file->package().empty()) { - vars["Package"].append("."); - } - - if (!params.services_namespace.empty()) { - vars["services_namespace"] = params.services_namespace; - printer->Print(vars, "\nnamespace $services_namespace$ {\n\n"); - } - - for (int i = 0; i < file->service_count(); ++i) { - PrintHeaderService(printer.get(), file->service(i).get(), &vars); - printer->Print("\n"); - } - - if (!params.services_namespace.empty()) { - printer->Print(vars, "} // namespace $services_namespace$\n\n"); - } - } - return output; -} - -grpc::string GetHeaderEpilogue(grpc_generator::File *file, const Parameters & /*params*/) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - - vars["filename"] = file->filename(); - vars["filename_identifier"] = FilenameIdentifier(file->filename()); - - if (!file->package().empty()) { - std::vector<grpc::string> parts = file->package_parts(); - - for (auto part = parts.rbegin(); part != parts.rend(); part++) { - vars["part"] = *part; - printer->Print(vars, "} // namespace $part$\n"); - } - printer->Print(vars, "\n"); - } - - printer->Print(vars, "\n"); - printer->Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n"); - } - return output; -} - -grpc::string GetSourcePrologue(grpc_generator::File *file, const Parameters & /*params*/) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - - vars["filename"] = file->filename(); - vars["filename_base"] = file->filename_without_ext(); - vars["message_header_ext"] = file->message_header_ext(); - vars["service_header_ext"] = file->service_header_ext(); - - printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n"); - printer->Print(vars, - "// If you make any local change, they will be lost.\n"); - printer->Print(vars, "// source: $filename$\n\n"); - printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n"); - printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n"); - printer->Print("\n"); - } - return output; -} - -grpc::string GetSourceIncludes(grpc_generator::File *file, - const Parameters ¶ms) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - - static const char *headers_strs[] = { - "grpc++/impl/codegen/async_stream.h", - "grpc++/impl/codegen/async_unary_call.h", - "grpc++/impl/codegen/channel_interface.h", - "grpc++/impl/codegen/client_unary_call.h", - "grpc++/impl/codegen/method_handler_impl.h", - "grpc++/impl/codegen/rpc_service_method.h", - "grpc++/impl/codegen/service_type.h", - "grpc++/impl/codegen/sync_stream.h" - }; - std::vector<grpc::string> headers(headers_strs, array_end(headers_strs)); - PrintIncludes(printer.get(), headers, params); - - if (!file->package().empty()) { - printer->Print("\n"); - std::vector<grpc::string> parts = file->package_parts(); - - for (auto part = parts.begin(); part != parts.end(); part++) { - vars["part"] = *part; - printer->Print(vars, "namespace $part$ {\n"); - } - } - - printer->Print(vars, "\n"); - } - return output; -} - -void PrintSourceClientMethod(grpc_generator::Printer *printer, - const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - if (method->NoStreaming()) { - printer->Print(*vars, - "::grpc::Status $ns$$Service$::Stub::$Method$(" - "::grpc::ClientContext* context, " - "const $Request$& request, $Response$* response) {\n"); - printer->Print(*vars, - " return ::grpc::BlockingUnaryCall(channel_.get(), " - "rpcmethod_$Method$_, " - "context, request, response);\n" - "}\n\n"); - printer->Print( - *vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "$ns$$Service$::Stub::Async$Method$Raw(::grpc::ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); - printer->Print(*vars, - " return new " - "::grpc::ClientAsyncResponseReader< $Response$>(" - "channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print(*vars, - "::grpc::ClientWriter< $Request$>* " - "$ns$$Service$::Stub::$Method$Raw(" - "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Print(*vars, - " return new ::grpc::ClientWriter< $Request$>(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, response);\n" - "}\n\n"); - printer->Print(*vars, - "::grpc::ClientAsyncWriter< $Request$>* " - "$ns$$Service$::Stub::Async$Method$Raw(" - "::grpc::ClientContext* context, $Response$* response, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Print(*vars, - " return new ::grpc::ClientAsyncWriter< $Request$>(" - "channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, response, tag);\n" - "}\n\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "::grpc::ClientReader< $Response$>* " - "$ns$$Service$::Stub::$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request) {\n"); - printer->Print(*vars, - " return new ::grpc::ClientReader< $Response$>(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); - printer->Print(*vars, - "::grpc::ClientAsyncReader< $Response$>* " - "$ns$$Service$::Stub::Async$Method$Raw(" - "::grpc::ClientContext* context, const $Request$& request, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Print(*vars, - " return new ::grpc::ClientAsyncReader< $Response$>(" - "channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, request, tag);\n" - "}\n\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "::grpc::ClientReaderWriter< $Request$, $Response$>* " - "$ns$$Service$::Stub::$Method$Raw(::grpc::ClientContext* context) {\n"); - printer->Print(*vars, - " return new ::grpc::ClientReaderWriter< " - "$Request$, $Response$>(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context);\n" - "}\n\n"); - printer->Print( - *vars, - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* " - "$ns$$Service$::Stub::Async$Method$Raw(::grpc::ClientContext* context, " - "::grpc::CompletionQueue* cq, void* tag) {\n"); - printer->Print(*vars, - " return new " - "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>(" - "channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, tag);\n" - "}\n\n"); - } -} - -void PrintSourceServerMethod(grpc_generator::Printer *printer, - const grpc_generator::Method *method, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - if (method->NoStreaming()) { - printer->Print(*vars, - "::grpc::Status $ns$$Service$::Service::$Method$(" - "::grpc::ServerContext* context, " - "const $Request$* request, $Response$* response) {\n"); - printer->Print(" (void) context;\n"); - printer->Print(" (void) request;\n"); - printer->Print(" (void) response;\n"); - printer->Print( - " return ::grpc::Status(" - "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); - printer->Print("}\n\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print(*vars, - "::grpc::Status $ns$$Service$::Service::$Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReader< $Request$>* reader, " - "$Response$* response) {\n"); - printer->Print(" (void) context;\n"); - printer->Print(" (void) reader;\n"); - printer->Print(" (void) response;\n"); - printer->Print( - " return ::grpc::Status(" - "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); - printer->Print("}\n\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print(*vars, - "::grpc::Status $ns$$Service$::Service::$Method$(" - "::grpc::ServerContext* context, " - "const $Request$* request, " - "::grpc::ServerWriter< $Response$>* writer) {\n"); - printer->Print(" (void) context;\n"); - printer->Print(" (void) request;\n"); - printer->Print(" (void) writer;\n"); - printer->Print( - " return ::grpc::Status(" - "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); - printer->Print("}\n\n"); - } else if (method->BidiStreaming()) { - printer->Print(*vars, - "::grpc::Status $ns$$Service$::Service::$Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* " - "stream) {\n"); - printer->Print(" (void) context;\n"); - printer->Print(" (void) stream;\n"); - printer->Print( - " return ::grpc::Status(" - "::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"); - printer->Print("}\n\n"); - } -} - -void PrintSourceService(grpc_generator::Printer *printer, - const grpc_generator::Service *service, - std::map<grpc::string, grpc::string> *vars) { - (*vars)["Service"] = service->name(); - - printer->Print(*vars, - "static const char* $prefix$$Service$_method_names[] = {\n"); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Method"] = service->method(i).get()->name(); - printer->Print(*vars, " \"/$Package$$Service$/$Method$\",\n"); - } - printer->Print(*vars, "};\n\n"); - - printer->Print(*vars, - "std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub(" - "const std::shared_ptr< ::grpc::ChannelInterface>& channel, " - "const ::grpc::StubOptions& options) {\n" - " std::unique_ptr< $ns$$Service$::Stub> stub(new " - "$ns$$Service$::Stub(channel));\n" - " return stub;\n" - "}\n\n"); - printer->Print(*vars, - "$ns$$Service$::Stub::Stub(const std::shared_ptr< " - "::grpc::ChannelInterface>& channel)\n"); - printer->Indent(); - printer->Print(": channel_(channel)"); - for (int i = 0; i < service->method_count(); ++i) { - auto method = service->method(i); - (*vars)["Method"] = method->name(); - (*vars)["Idx"] = as_string(i); - if (method->NoStreaming()) { - (*vars)["StreamingType"] = "NORMAL_RPC"; - } else if (method->ClientOnlyStreaming()) { - (*vars)["StreamingType"] = "CLIENT_STREAMING"; - } else if (method->ServerOnlyStreaming()) { - (*vars)["StreamingType"] = "SERVER_STREAMING"; - } else { - (*vars)["StreamingType"] = "BIDI_STREAMING"; - } - printer->Print(*vars, - ", rpcmethod_$Method$_(" - "$prefix$$Service$_method_names[$Idx$], " - "::grpc::RpcMethod::$StreamingType$, " - "channel" - ")\n"); - } - printer->Print("{}\n\n"); - printer->Outdent(); - - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintSourceClientMethod(printer, service->method(i).get(), vars); - } - - printer->Print(*vars, "$ns$$Service$::Service::Service() {\n"); - printer->Indent(); - printer->Print(*vars, "(void)$prefix$$Service$_method_names;\n"); - for (int i = 0; i < service->method_count(); ++i) { - auto method = service->method(i); - (*vars)["Idx"] = as_string(i); - (*vars)["Method"] = method->name(); - (*vars)["Request"] = method->input_type_name(); - (*vars)["Response"] = method->output_type_name(); - if (method->NoStreaming()) { - printer->Print( - *vars, - "AddMethod(new ::grpc::RpcServiceMethod(\n" - " $prefix$$Service$_method_names[$Idx$],\n" - " ::grpc::RpcMethod::NORMAL_RPC,\n" - " new ::grpc::RpcMethodHandler< $ns$$Service$::Service, " - "$Request$, " - "$Response$>(\n" - " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); - } else if (method->ClientOnlyStreaming()) { - printer->Print( - *vars, - "AddMethod(new ::grpc::RpcServiceMethod(\n" - " $prefix$$Service$_method_names[$Idx$],\n" - " ::grpc::RpcMethod::CLIENT_STREAMING,\n" - " new ::grpc::ClientStreamingHandler< " - "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print( - *vars, - "AddMethod(new ::grpc::RpcServiceMethod(\n" - " $prefix$$Service$_method_names[$Idx$],\n" - " ::grpc::RpcMethod::SERVER_STREAMING,\n" - " new ::grpc::ServerStreamingHandler< " - "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); - } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "AddMethod(new ::grpc::RpcServiceMethod(\n" - " $prefix$$Service$_method_names[$Idx$],\n" - " ::grpc::RpcMethod::BIDI_STREAMING,\n" - " new ::grpc::BidiStreamingHandler< " - "$ns$$Service$::Service, $Request$, $Response$>(\n" - " std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n"); - } - } - printer->Outdent(); - printer->Print(*vars, "}\n\n"); - printer->Print(*vars, - "$ns$$Service$::Service::~Service() {\n" - "}\n\n"); - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["Idx"] = as_string(i); - PrintSourceServerMethod(printer, service->method(i).get(), vars); - } -} - -grpc::string GetSourceServices(grpc_generator::File *file, - const Parameters ¶ms) { - grpc::string output; - { - // Scope the output stream so it closes and finalizes output to the string. - auto printer = file->CreatePrinter(&output); - std::map<grpc::string, grpc::string> vars; - // Package string is empty or ends with a dot. It is used to fully qualify - // method names. - vars["Package"] = file->package(); - if (!file->package().empty()) { - vars["Package"].append("."); - } - if (!params.services_namespace.empty()) { - vars["ns"] = params.services_namespace + "::"; - vars["prefix"] = params.services_namespace; - } else { - vars["ns"] = ""; - vars["prefix"] = ""; - } - - for (int i = 0; i < file->service_count(); ++i) { - PrintSourceService(printer.get(), file->service(i).get(), &vars); - printer->Print("\n"); - } - } - return output; -} - -grpc::string GetSourceEpilogue(grpc_generator::File *file, const Parameters & /*params*/) { - grpc::string temp; - - if (!file->package().empty()) { - std::vector<grpc::string> parts = file->package_parts(); - - for (auto part = parts.begin(); part != parts.end(); part++) { - temp.append("} // namespace "); - temp.append(*part); - temp.append("\n"); - } - temp.append("\n"); - } - - return temp; -} - -} // namespace grpc_cpp_generator
diff --git a/third_party/flatbuffers/grpc/src/compiler/cpp_generator.h b/third_party/flatbuffers/grpc/src/compiler/cpp_generator.h deleted file mode 100644 index a4adee7..0000000 --- a/third_party/flatbuffers/grpc/src/compiler/cpp_generator.h +++ /dev/null
@@ -1,84 +0,0 @@ -/* - * - * 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. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H - -// cpp_generator.h/.cc do not directly depend on GRPC/ProtoBuf, such that they -// can be used to generate code for other serialization systems, such as -// FlatBuffers. - -#include <memory> -#include <vector> - -#include "src/compiler/schema_interface.h" - -namespace grpc_cpp_generator { - -// Contains all the parameters that are parsed from the command line. -struct Parameters { - // Puts the service into a namespace - grpc::string services_namespace; - // Use system includes (<>) or local includes ("") - bool use_system_headers; - // Prefix to any grpc include - grpc::string grpc_search_path; -}; - -// Return the prologue of the generated header file. -grpc::string GetHeaderPrologue(grpc_generator::File *file, const Parameters ¶ms); - -// Return the includes needed for generated header file. -grpc::string GetHeaderIncludes(grpc_generator::File *file, const Parameters ¶ms); - -// Return the includes needed for generated source file. -grpc::string GetSourceIncludes(grpc_generator::File *file, const Parameters ¶ms); - -// Return the epilogue of the generated header file. -grpc::string GetHeaderEpilogue(grpc_generator::File *file, const Parameters ¶ms); - -// Return the prologue of the generated source file. -grpc::string GetSourcePrologue(grpc_generator::File *file, const Parameters ¶ms); - -// Return the services for generated header file. -grpc::string GetHeaderServices(grpc_generator::File *file, const Parameters ¶ms); - -// Return the services for generated source file. -grpc::string GetSourceServices(grpc_generator::File *file, const Parameters ¶ms); - -// Return the epilogue of the generated source file. -grpc::string GetSourceEpilogue(grpc_generator::File *file, const Parameters ¶ms); - -} // namespace grpc_cpp_generator - -#endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
diff --git a/third_party/flatbuffers/grpc/src/compiler/go_generator.cc b/third_party/flatbuffers/grpc/src/compiler/go_generator.cc deleted file mode 100644 index ce4223d..0000000 --- a/third_party/flatbuffers/grpc/src/compiler/go_generator.cc +++ /dev/null
@@ -1,437 +0,0 @@ -/* - * - * 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 AN/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 <map> -#include <cctype> -#include <sstream> - -#include "src/compiler/go_generator.h" - -template <class T> -grpc::string as_string(T x) { - std::ostringstream out; - out << x; - return out.str(); -} - -namespace grpc_go_generator { - -// Returns string with first letter to lowerCase -grpc::string unexportName(grpc::string s) { - if (s.empty()) - return s; - s[0] = static_cast<char>(std::tolower(s[0])); - return s; -} - -// Returns string with first letter to uppercase -grpc::string exportName(grpc::string s) { - if (s.empty()) - return s; - s[0] = static_cast<char>(std::toupper(s[0])); - return s; -} - -// Generates imports for the service -void GenerateImports(grpc_generator::File *file, grpc_generator::Printer *printer, - std::map<grpc::string, grpc::string> vars) { - vars["filename"] = file->filename(); - printer->Print("//Generated by gRPC Go plugin\n"); - printer->Print("//If you make any local changes, they will be lost\n"); - printer->Print(vars, "//source: $filename$\n\n"); - printer->Print(vars, "package $Package$\n\n"); - if (file->additional_imports() != "") { - printer->Print(file->additional_imports().c_str()); - printer->Print("\n\n"); - } - printer->Print("import (\n"); - printer->Indent(); - printer->Print(vars, "$context$ \"golang.org/x/net/context\"\n"); - printer->Print(vars, "$grpc$ \"google.golang.org/grpc\"\n"); - printer->Outdent(); - printer->Print(")\n\n"); -} - -// Generates Server method signature source -void GenerateServerMethodSignature(const grpc_generator::Method *method, grpc_generator::Printer *printer, - std::map<grpc::string, grpc::string> vars) { - vars["Method"] = exportName(method->name()); - vars["Request"] = method->input_name(); - vars["Response"] = (vars["CustomMethodIO"] == "") ? method->output_name() : vars["CustomMethodIO"]; - if (method->NoStreaming()) { - printer->Print(vars, "$Method$($context$.Context, *$Request$) (*$Response$, error)"); - } else if (method->ServerOnlyStreaming()) { - printer->Print(vars, "$Method$(*$Request$, $Service$_$Method$Server) error"); - } else { - printer->Print(vars, "$Method$($Service$_$Method$Server) error"); - } -} - -void GenerateServerMethod(const grpc_generator::Method *method, grpc_generator::Printer *printer, - std::map<grpc::string, grpc::string> vars) { - vars["Method"] = exportName(method->name()); - vars["Request"] = method->input_name(); - vars["Response"] = (vars["CustomMethodIO"] == "") ? method->output_name() : vars["CustomMethodIO"]; - vars["FullMethodName"] = "/" + vars["Package"] + "." + vars["Service"] + "/" + vars["Method"]; - vars["Handler"] = "_" + vars["Service"] + "_" + vars["Method"] + "_Handler"; - if (method->NoStreaming()) { - printer->Print(vars, "func $Handler$(srv interface{}, ctx $context$.Context,\n\tdec func(interface{}) error, interceptor $grpc$.UnaryServerInterceptor) (interface{}, error) {\n"); - printer->Indent(); - printer->Print(vars, "in := new($Request$)\n"); - printer->Print("if err := dec(in); err != nil { return nil, err }\n"); - printer->Print(vars, "if interceptor == nil { return srv.($Service$Server).$Method$(ctx, in) }\n"); - printer->Print(vars, "info := &$grpc$.UnaryServerInfo{\n"); - printer->Indent(); - printer->Print("Server: srv,\n"); - printer->Print(vars, "FullMethod: \"$FullMethodName$\",\n"); - printer->Outdent(); - printer->Print("}\n\n"); - printer->Print(vars, "handler := func(ctx $context$.Context, req interface{}) (interface{}, error) {\n"); - printer->Indent(); - printer->Print(vars, "return srv.($Service$Server).$Method$(ctx, req.(* $Request$))\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print("return interceptor(ctx, in, info, handler)\n"); - printer->Outdent(); - printer->Print("}\n\n"); - return; - } - vars["StreamType"] = vars["ServiceUnexported"] + vars["Method"] + "Server"; - printer->Print(vars, "func $Handler$(srv interface{}, stream $grpc$.ServerStream) error {\n"); - printer->Indent(); - if (method->ServerOnlyStreaming()) { - printer->Print(vars, "m := new($Request$)\n"); - printer->Print(vars, "if err := stream.RecvMsg(m); err != nil { return err }\n"); - printer->Print(vars, "return srv.($Service$Server).$Method$(m, &$StreamType${stream})\n"); - } else { - printer->Print(vars, "return srv.($Service$Server).$Method$(&$StreamType${stream})\n"); - } - printer->Outdent(); - printer->Print("}\n\n"); - - bool genSend = method->BidiStreaming() || method->ServerOnlyStreaming(); - bool genRecv = method->BidiStreaming() || method->ClientOnlyStreaming(); - bool genSendAndClose = method->ClientOnlyStreaming(); - - printer->Print(vars, "type $Service$_$Method$Server interface { \n"); - printer->Indent(); - if (genSend) { - printer->Print(vars, "Send(* $Response$) error\n"); - } - if (genRecv) { - printer->Print(vars, "Recv() (* $Request$, error)\n"); - } - if (genSendAndClose) { - printer->Print(vars, "SendAndClose(* $Response$) error\n"); - } - printer->Print(vars, "$grpc$.ServerStream\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - printer->Print(vars, "type $StreamType$ struct {\n"); - printer->Indent(); - printer->Print(vars, "$grpc$.ServerStream\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - if (genSend) { - printer->Print(vars, "func (x *$StreamType$) Send(m *$Response$) error {\n"); - printer->Indent(); - printer->Print("return x.ServerStream.SendMsg(m)\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } - if (genRecv) { - printer->Print(vars, "func (x *$StreamType$) Recv() (*$Request$, error) {\n"); - printer->Indent(); - printer->Print(vars, "m := new($Request$)\n"); - printer->Print("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }\n"); - printer->Print("return m, nil\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } - if (genSendAndClose) { - printer->Print(vars, "func (x *$StreamType$) SendAndClose(m *$Response$) error {\n"); - printer->Indent(); - printer->Print("return x.ServerStream.SendMsg(m)\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } - -} - -// Generates Client method signature source -void GenerateClientMethodSignature(const grpc_generator::Method *method, grpc_generator::Printer *printer, - std::map<grpc::string, grpc::string> vars) { - vars["Method"] = exportName(method->name()); - vars["Request"] = ", in *" + ((vars["CustomMethodIO"] == "") ? method->input_name() : vars["CustomMethodIO"]); - if (method->ClientOnlyStreaming() || method->BidiStreaming()) { - vars["Request"] = ""; - } - vars["Response"] = "* " + method->output_name(); - if (method->ClientOnlyStreaming() || method->BidiStreaming() || method->ServerOnlyStreaming()) { - vars["Response"] = vars["Service"] + "_" + vars["Method"] + "Client" ; - } - printer->Print(vars, "$Method$(ctx $context$.Context$Request$, \n\topts... $grpc$.CallOption) ($Response$, error)"); -} - -// Generates Client method source -void GenerateClientMethod(const grpc_generator::Method *method, grpc_generator::Printer *printer, - std::map<grpc::string, grpc::string> vars) { - printer->Print(vars, "func (c *$ServiceUnexported$Client) "); - GenerateClientMethodSignature(method, printer, vars); - printer->Print(" {\n"); - printer->Indent(); - vars["Method"] = exportName(method->name()); - vars["Request"] = (vars["CustomMethodIO"] == "") ? method->input_name() : vars["CustomMethodIO"]; - vars["Response"] = method->output_name(); - vars["FullMethodName"] = "/" + vars["Package"] + "." + vars["Service"] + "/" + vars["Method"]; - if (method->NoStreaming()) { - printer->Print(vars, "out := new($Response$)\n"); - printer->Print(vars, "err := $grpc$.Invoke(ctx, \"$FullMethodName$\", in, out, c.cc, opts...)\n"); - printer->Print("if err != nil { return nil, err }\n"); - printer->Print("return out, nil\n"); - printer->Outdent(); - printer->Print("}\n\n"); - return; - } - vars["StreamType"] = vars["ServiceUnexported"] + vars["Method"] + "Client"; - printer->Print(vars, "stream, err := $grpc$.NewClientStream(ctx, &$MethodDesc$, c.cc, \"$FullMethodName$\", opts...)\n"); - printer->Print("if err != nil { return nil, err }\n"); - - printer->Print(vars, "x := &$StreamType${stream}\n"); - if (method->ServerOnlyStreaming()) { - printer->Print("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }\n"); - printer->Print("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }\n"); - } - printer->Print("return x,nil\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - bool genSend = method->BidiStreaming() || method->ClientOnlyStreaming(); - bool genRecv = method->BidiStreaming() || method->ServerOnlyStreaming(); - bool genCloseAndRecv = method->ClientOnlyStreaming(); - - //Stream interface - printer->Print(vars, "type $Service$_$Method$Client interface {\n"); - printer->Indent(); - if (genSend) { - printer->Print(vars, "Send(*$Request$) error\n"); - } - if (genRecv) { - printer->Print(vars, "Recv() (*$Response$, error)\n"); - } - if (genCloseAndRecv) { - printer->Print(vars, "CloseAndRecv() (*$Response$, error)\n"); - } - printer->Print(vars, "$grpc$.ClientStream\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - //Stream Client - printer->Print(vars, "type $StreamType$ struct{\n"); - printer->Indent(); - printer->Print(vars, "$grpc$.ClientStream\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - if (genSend) { - printer->Print(vars, "func (x *$StreamType$) Send(m *$Request$) error {\n"); - printer->Indent(); - printer->Print("return x.ClientStream.SendMsg(m)\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } - - if (genRecv) { - printer->Print(vars, "func (x *$StreamType$) Recv() (*$Response$, error) {\n"); - printer->Indent(); - printer->Print(vars, "m := new($Response$)\n"); - printer->Print("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }\n"); - printer->Print("return m, nil\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } - - if (genCloseAndRecv) { - printer->Print(vars, "func (x *$StreamType$) CloseAndRecv() (*$Response$, error) {\n"); - printer->Indent(); - printer->Print("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }\n"); - printer->Print(vars, "m := new ($Response$)\n"); - printer->Print("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }\n"); - printer->Print("return m, nil\n"); - printer->Outdent(); - printer->Print("}\n\n"); - } -} - -// Generates client API for the service -void GenerateService(const grpc_generator::Service *service, grpc_generator::Printer* printer, - std::map<grpc::string, grpc::string> vars) { - vars["Service"] = exportName(service->name()); - // Client Interface - printer->Print(vars, "// Client API for $Service$ service\n"); - printer->Print(vars, "type $Service$Client interface{\n"); - printer->Indent(); - for (int i = 0; i < service->method_count(); i++) { - GenerateClientMethodSignature(service->method(i).get(), printer, vars); - printer->Print("\n"); - } - printer->Outdent(); - printer->Print("}\n\n"); - - // Client structure - vars["ServiceUnexported"] = unexportName(vars["Service"]); - printer->Print(vars, "type $ServiceUnexported$Client struct {\n"); - printer->Indent(); - printer->Print(vars, "cc *$grpc$.ClientConn\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - // NewClient - printer->Print(vars, "func New$Service$Client(cc *$grpc$.ClientConn) $Service$Client {\n"); - printer->Indent(); - printer->Print(vars, "return &$ServiceUnexported$Client{cc}"); - printer->Outdent(); - printer->Print("\n}\n\n"); - - int unary_methods = 0, streaming_methods = 0; - vars["ServiceDesc"] = "_" + vars["Service"] + "_serviceDesc"; - for (int i = 0; i < service->method_count(); i++) { - auto method = service->method(i); - if (method->NoStreaming()) { - vars["MethodDesc"] = vars["ServiceDesc"] + ".Method[" + as_string(unary_methods) + "]"; - unary_methods++; - } else { - vars["MethodDesc"] = vars["ServiceDesc"] + ".Streams[" + as_string(streaming_methods) + "]"; - streaming_methods++; - } - GenerateClientMethod(method.get(), printer, vars); - } - - //Server Interface - printer->Print(vars, "// Server API for $Service$ service\n"); - printer->Print(vars, "type $Service$Server interface {\n"); - printer->Indent(); - for (int i = 0; i < service->method_count(); i++) { - GenerateServerMethodSignature(service->method(i).get(), printer, vars); - printer->Print("\n"); - } - printer->Outdent(); - printer->Print("}\n\n"); - - // Server registration. - printer->Print(vars, "func Register$Service$Server(s *$grpc$.Server, srv $Service$Server) {\n"); - printer->Indent(); - printer->Print(vars, "s.RegisterService(&$ServiceDesc$, srv)\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - for (int i = 0; i < service->method_count(); i++) { - GenerateServerMethod(service->method(i).get(), printer, vars); - printer->Print("\n"); - } - - - //Service Descriptor - printer->Print(vars, "var $ServiceDesc$ = $grpc$.ServiceDesc{\n"); - printer->Indent(); - printer->Print(vars, "ServiceName: \"$Package$.$Service$\",\n"); - printer->Print(vars, "HandlerType: (*$Service$Server)(nil),\n"); - printer->Print(vars, "Methods: []$grpc$.MethodDesc{\n"); - printer->Indent(); - for (int i = 0; i < service->method_count(); i++) { - auto method = service->method(i); - vars["Method"] = method->name(); - vars["Handler"] = "_" + vars["Service"] + "_" + vars["Method"] + "_Handler"; - if (method->NoStreaming()) { - printer->Print("{\n"); - printer->Indent(); - printer->Print(vars, "MethodName: \"$Method$\",\n"); - printer->Print(vars, "Handler: $Handler$, \n"); - printer->Outdent(); - printer->Print("},\n"); - } - } - printer->Outdent(); - printer->Print("},\n"); - printer->Print(vars, "Streams: []$grpc$.StreamDesc{\n"); - printer->Indent(); - for (int i = 0; i < service->method_count(); i++) { - auto method = service->method(i); - vars["Method"] = method->name(); - vars["Handler"] = "_" + vars["Service"] + "_" + vars["Method"] + "_Handler"; - if (!method->NoStreaming()) { - printer->Print("{\n"); - printer->Indent(); - printer->Print(vars, "StreamName: \"$Method$\",\n"); - printer->Print(vars, "Handler: $Handler$, \n"); - if (method->ClientOnlyStreaming()) { - printer->Print("ClientStreams: true,\n"); - } else if (method->ServerOnlyStreaming()) { - printer->Print("ServerStreams: true,\n"); - } else { - printer->Print("ServerStreams: true,\n"); - printer->Print("ClientStreams: true,\n"); - } - printer->Outdent(); - printer->Print("},\n"); - } - } - printer->Outdent(); - printer->Print("},\n"); - printer->Outdent(); - printer->Print("}\n\n"); - -} - - -// Returns source for the service -grpc::string GenerateServiceSource(grpc_generator::File *file, - const grpc_generator::Service *service, - grpc_go_generator::Parameters *parameters) { - grpc::string out; - auto p = file->CreatePrinter(&out); - auto printer = p.get(); - std::map<grpc::string, grpc::string> vars; - vars["Package"] = parameters->package_name; - vars["grpc"] = "grpc"; - vars["context"] = "context"; - GenerateImports(file, printer, vars); - if (parameters->custom_method_io_type != "") { - vars["CustomMethodIO"] = parameters->custom_method_io_type; - } - GenerateService(service, printer, vars); - return out; -} -}// Namespace grpc_go_generator
diff --git a/third_party/flatbuffers/grpc/src/compiler/go_generator.h b/third_party/flatbuffers/grpc/src/compiler/go_generator.h deleted file mode 100644 index a8f7a3d..0000000 --- a/third_party/flatbuffers/grpc/src/compiler/go_generator.h +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * - * 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. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_GO_GENERATOR_H -#define GRPC_INTERNAL_COMPILER_GO_GENERATOR_H - -//go generator is used to generate GRPC code for serialization system, such as flatbuffers -#include <memory> -#include <vector> - -#include "src/compiler/schema_interface.h" - -namespace grpc_go_generator { - -struct Parameters { - //Defines the custom parameter types for methods - //eg: flatbuffers uses flatbuffers.Builder as input for the client and output for the server - grpc::string custom_method_io_type; - - //Package name for the service - grpc::string package_name; -}; - -// Return the source of the generated service file. -grpc::string GenerateServiceSource(grpc_generator::File *file, - const grpc_generator::Service *service, - grpc_go_generator::Parameters *parameters); - -} - -#endif // GRPC_INTERNAL_COMPILER_GO_GENERATOR_H
diff --git a/third_party/flatbuffers/grpc/src/compiler/schema_interface.h b/third_party/flatbuffers/grpc/src/compiler/schema_interface.h deleted file mode 100644 index c9b7f46..0000000 --- a/third_party/flatbuffers/grpc/src/compiler/schema_interface.h +++ /dev/null
@@ -1,112 +0,0 @@ -/* - * - * 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. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H -#define GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H - -#include <map> -#include <memory> -#include <vector> - - #ifndef GRPC_CUSTOM_STRING - #include <string> - #define GRPC_CUSTOM_STRING std::string - #endif - -namespace grpc { - - typedef GRPC_CUSTOM_STRING string; - -} // namespace grpc - -namespace grpc_generator { - - // An abstract interface representing a method. - struct Method { - virtual ~Method() {} - - virtual grpc::string name() const = 0; - - virtual grpc::string input_type_name() const = 0; - virtual grpc::string output_type_name() const = 0; - virtual grpc::string input_name() const = 0; - virtual grpc::string output_name() const = 0; - - virtual bool NoStreaming() const = 0; - virtual bool ClientOnlyStreaming() const = 0; - virtual bool ServerOnlyStreaming() const = 0; - virtual bool BidiStreaming() const = 0; - }; - - // An abstract interface representing a service. - struct Service { - virtual ~Service() {} - - virtual grpc::string name() const = 0; - - virtual int method_count() const = 0; - virtual std::unique_ptr<const Method> method(int i) const = 0; - }; - - struct Printer { - virtual ~Printer() {} - - virtual void Print(const std::map<grpc::string, grpc::string> &vars, - const char *template_string) = 0; - virtual void Print(const char *string) = 0; - virtual void Indent() = 0; - virtual void Outdent() = 0; - }; - - // An interface that allows the source generated to be output using various - // libraries/idls/serializers. - struct File { - virtual ~File() {} - - virtual grpc::string filename() const = 0; - virtual grpc::string filename_without_ext() const = 0; - virtual grpc::string message_header_ext() const = 0; - virtual grpc::string service_header_ext() const = 0; - virtual grpc::string package() const = 0; - virtual std::vector<grpc::string> package_parts() const = 0; - virtual grpc::string additional_headers() const = 0; - virtual grpc::string additional_imports() const = 0; - - virtual int service_count() const = 0; - virtual std::unique_ptr<const Service> service(int i) const = 0; - - virtual std::unique_ptr<Printer> CreatePrinter(grpc::string *str) const = 0; - }; -} // namespace grpc_generator - -#endif // GRPC_INTERNAL_COMPILER_SCHEMA_INTERFACE_H
diff --git a/third_party/flatbuffers/grpc/tests/go_test.go b/third_party/flatbuffers/grpc/tests/go_test.go deleted file mode 100644 index 7192f97..0000000 --- a/third_party/flatbuffers/grpc/tests/go_test.go +++ /dev/null
@@ -1,93 +0,0 @@ -package testing - -import ( - "../../tests/MyGame/Example" - - "net" - "testing" - - "golang.org/x/net/context" - "google.golang.org/grpc" -) - -type server struct{} - -// test used to send and receive in grpc methods -var test = "Flatbuffers" -var addr = "0.0.0.0:50051" - -// gRPC server store method -func (s *server) Store(context context.Context, in *Example.Monster) (*flatbuffers.Builder, error) { - b := flatbuffers.NewBuilder(0) - i := b.CreateString(test) - Example.StatStart(b) - Example.StatAddId(b, i) - b.Finish(Example.StatEnd(b)) - return b, nil - -} - -// gRPC server retrieve method -func (s *server) Retrieve(context context.Context, in *Example.Stat) (*flatbuffers.Builder, error) { - b := flatbuffers.NewBuilder(0) - i := b.CreateString(test) - Example.MonsterStart(b) - Example.MonsterAddName(b, i) - b.Finish(Example.MonsterEnd(b)) - return b, nil -} - -func StoreClient(c Example.MonsterStorageClient, t *testing.T) { - b := flatbuffers.NewBuilder(0) - i := b.CreateString(test) - Example.MonsterStart(b) - Example.MonsterAddName(b, i) - b.Finish(Example.MonsterEnd(b)) - out, err := c.Store(context.Background(), b) - if err != nil { - t.Fatalf("Store client failed: %v", err) - } - if string(out.Id()) != test { - t.Errorf("StoreClient failed: expected=%s, got=%s\n", test, out.Id()) - t.Fail() - } -} - -func RetrieveClient(c Example.MonsterStorageClient, t *testing.T) { - b := flatbuffers.NewBuilder(0) - i := b.CreateString(test) - Example.StatStart(b) - Example.StatAddId(b, i) - b.Finish(Example.StatEnd(b)) - out, err := c.Retrieve(context.Background(), b) - if err != nil { - t.Fatalf("Retrieve client failed: %v", err) - } - if string(out.Name()) != test { - t.Errorf("RetrieveClient failed: expected=%s, got=%s\n", test, out.Name()) - t.Fail() - } -} - -func TestGRPC(t *testing.T) { - lis, err := net.Listen("tcp", addr) - if err != nil { - t.Fatalf("Failed to listen: %v", err) - } - ser := grpc.NewServer(grpc.CustomCodec(flatbuffers.FlatbuffersCodec{})) - Example.RegisterMonsterStorageServer(ser, &server{}) - go func() { - if err := ser.Serve(lis); err != nil { - t.Fatalf("Failed to serve: %v", err) - t.FailNow() - } - }() - conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithCodec(flatbuffers.FlatbuffersCodec{})) - if err != nil { - t.Fatalf("Failed to connect: %v", err) - } - defer conn.Close() - client := Example.NewMonsterStorageClient(conn) - StoreClient(client, t) - RetrieveClient(client, t) -}
diff --git a/third_party/flatbuffers/grpc/tests/grpctest.cpp b/third_party/flatbuffers/grpc/tests/grpctest.cpp deleted file mode 100644 index 77b79fc..0000000 --- a/third_party/flatbuffers/grpc/tests/grpctest.cpp +++ /dev/null
@@ -1,124 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <thread> - -#include <grpc++/grpc++.h> - -#include "monster_test_generated.h" -#include "monster_test.grpc.fb.h" - -using namespace MyGame::Example; - -// The callback implementation of our server, that derives from the generated -// code. It implements all rpcs specified in the FlatBuffers schema. -class ServiceImpl final : public MyGame::Example::MonsterStorage::Service { - virtual ::grpc::Status Store(::grpc::ServerContext* context, - const flatbuffers::BufferRef<Monster> *request, - flatbuffers::BufferRef<Stat> *response) - override { - // Create a response from the incoming request name. - fbb_.Clear(); - auto stat_offset = CreateStat(fbb_, fbb_.CreateString("Hello, " + - request->GetRoot()->name()->str())); - fbb_.Finish(stat_offset); - // Since we keep reusing the same FlatBufferBuilder, the memory it owns - // remains valid until the next call (this BufferRef doesn't own the - // memory it points to). - *response = flatbuffers::BufferRef<Stat>(fbb_.GetBufferPointer(), - fbb_.GetSize()); - return grpc::Status::OK; - } - virtual ::grpc::Status Retrieve(::grpc::ServerContext *context, - const flatbuffers::BufferRef<Stat> *request, - ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer) - override { - assert(false); // We're not actually using this RPC. - return grpc::Status::CANCELLED; - } - - private: - flatbuffers::FlatBufferBuilder fbb_; -}; - -// Track the server instance, so we can terminate it later. -grpc::Server *server_instance = nullptr; -// Mutex to protec this variable. -std::mutex wait_for_server; -std::condition_variable server_instance_cv; - -// This function implements the server thread. -void RunServer() { - auto server_address = "0.0.0.0:50051"; - // Callback interface we implemented above. - ServiceImpl service; - grpc::ServerBuilder builder; - builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); - builder.RegisterService(&service); - - // Start the server. Lock to change the variable we're changing. - wait_for_server.lock(); - server_instance = builder.BuildAndStart().release(); - wait_for_server.unlock(); - server_instance_cv.notify_one(); - - std::cout << "Server listening on " << server_address << std::endl; - // This will block the thread and serve requests. - server_instance->Wait(); -} - -int main(int /*argc*/, const char * /*argv*/[]) { - // Launch server. - std::thread server_thread(RunServer); - - // wait for server to spin up. - std::unique_lock<std::mutex> lock(wait_for_server); - while (!server_instance) server_instance_cv.wait(lock); - - // Now connect the client. - auto channel = grpc::CreateChannel("localhost:50051", - grpc::InsecureChannelCredentials()); - auto stub = MyGame::Example::MonsterStorage::NewStub(channel); - - grpc::ClientContext context; - - // Build a request with the name set. - flatbuffers::FlatBufferBuilder fbb; - auto monster_offset = CreateMonster(fbb, 0, 0, 0, fbb.CreateString("Fred")); - fbb.Finish(monster_offset); - auto request = flatbuffers::BufferRef<Monster>(fbb.GetBufferPointer(), - fbb.GetSize()); - flatbuffers::BufferRef<Stat> response; - - // The actual RPC. - auto status = stub->Store(&context, request, &response); - - if (status.ok()) { - auto resp = response.GetRoot()->id(); - std::cout << "RPC response: " << resp->str() << std::endl; - } else { - std::cout << "RPC failed" << std::endl; - } - - server_instance->Shutdown(); - - server_thread.join(); - - delete server_instance; - - return 0; -} -
diff --git a/third_party/flatbuffers/include/flatbuffers/code_generators.h b/third_party/flatbuffers/include/flatbuffers/code_generators.h deleted file mode 100644 index 3e85df2..0000000 --- a/third_party/flatbuffers/include/flatbuffers/code_generators.h +++ /dev/null
@@ -1,139 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_CODE_GENERATORS_H_ -#define FLATBUFFERS_CODE_GENERATORS_H_ - -#include <map> -#include <sstream> -#include "flatbuffers/idl.h" - -namespace flatbuffers { - -// Utility class to assist in generating code through use of text templates. -// -// Example code: -// CodeWriter code; -// code.SetValue("NAME", "Foo"); -// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; -// code.SetValue("NAME", "Bar"); -// code += "void {{NAME}}() { printf("%s", "{{NAME}}"); }"; -// std::cout << code.ToString() << std::endl; -// -// Output: -// void Foo() { printf("%s", "Foo"); } -// void Bar() { printf("%s", "Bar"); } -class CodeWriter { - public: - CodeWriter() {} - - // Clears the current "written" code. - void Clear() { - stream_.str(""); - stream_.clear(); - } - - // Associates a key with a value. All subsequent calls to operator+=, where - // the specified key is contained in {{ and }} delimiters will be replaced by - // the given value. - void SetValue(const std::string& key, const std::string& value) { - value_map_[key] = value; - } - - // Appends the given text to the generated code as well as a newline - // character. Any text within {{ and }} delimeters is replaced by values - // previously stored in the CodeWriter by calling SetValue above. The newline - // will be suppressed if the text ends with the \\ character. - void operator+=(std::string text); - - // Returns the current contents of the CodeWriter as a std::string. - std::string ToString() const { return stream_.str(); } - - private: - std::map<std::string, std::string> value_map_; - std::stringstream stream_; -}; - -class BaseGenerator { - public: - virtual bool generate() = 0; - - static std::string NamespaceDir(const Parser &parser, - const std::string &path, - const Namespace &ns); - - protected: - BaseGenerator(const Parser &parser, const std::string &path, - const std::string &file_name, - const std::string qualifying_start, - const std::string qualifying_separator) - : parser_(parser), - path_(path), - file_name_(file_name), - qualifying_start_(qualifying_start), - qualifying_separator_(qualifying_separator) {} - virtual ~BaseGenerator() {} - - // No copy/assign. - BaseGenerator &operator=(const BaseGenerator &); - BaseGenerator(const BaseGenerator &); - - std::string NamespaceDir(const Namespace &ns) const; - - static const char *FlatBuffersGeneratedWarning(); - - bool IsEverythingGenerated() const; - - static std::string FullNamespace(const char *separator, const Namespace &ns); - - static std::string LastNamespacePart(const Namespace &ns); - - // tracks the current namespace for early exit in WrapInNameSpace - // c++, java and csharp returns a different namespace from - // the following default (no early exit, always fully qualify), - // which works for js and php - virtual const Namespace *CurrentNameSpace() const { return nullptr; } - - // Ensure that a type is prefixed with its namespace whenever it is used - // outside of its namespace. - std::string WrapInNameSpace(const Namespace *ns, - const std::string &name) const; - - std::string WrapInNameSpace(const Definition &def) const; - - std::string GetNameSpace(const Definition &def) const; - - const Parser &parser_; - const std::string &path_; - const std::string &file_name_; - const std::string qualifying_start_; - const std::string qualifying_separator_; -}; - -struct CommentConfig { - const char *first_line; - const char *content_line_prefix; - const char *last_line; -}; - -extern void GenComment(const std::vector<std::string> &dc, - std::string *code_ptr, - const CommentConfig *config, - const char *prefix = ""); - -} // namespace flatbuffers - -#endif // FLATBUFFERS_CODE_GENERATORS_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/flatbuffers.h b/third_party/flatbuffers/include/flatbuffers/flatbuffers.h deleted file mode 100644 index e38e552..0000000 --- a/third_party/flatbuffers/include/flatbuffers/flatbuffers.h +++ /dev/null
@@ -1,2037 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_H_ -#define FLATBUFFERS_H_ - -#include <assert.h> - -#ifndef ARDUINO -#include <cstdint> -#endif -#include <cstddef> -#include <cstdlib> -#include <cstring> -#include <string> -#ifndef ARDUINO -#include <utility> -#else -#include <utility.h> -#endif -#include <type_traits> -#include <vector> -#include <set> -#include <algorithm> -#include <memory> - -#ifdef _STLPORT_VERSION - #define FLATBUFFERS_CPP98_STL -#endif -#ifndef FLATBUFFERS_CPP98_STL - #include <functional> -#endif - -/// @cond FLATBUFFERS_INTERNAL -#if __cplusplus <= 199711L && \ - (!defined(_MSC_VER) || _MSC_VER < 1600) && \ - (!defined(__GNUC__) || \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400)) - #error A C++11 compatible compiler with support for the auto typing is \ - required for FlatBuffers. - #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ -#endif - -#if !defined(__clang__) && \ - defined(__GNUC__) && \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600) - // Backwards compatability for g++ 4.4, and 4.5 which don't have the nullptr - // and constexpr keywords. Note the __clang__ check is needed, because clang - // presents itself as an older GNUC compiler. - #ifndef nullptr_t - const class nullptr_t { - public: - template<class T> inline operator T*() const { return 0; } - private: - void operator&() const; - } nullptr = {}; - #endif - #ifndef constexpr - #define constexpr const - #endif -#endif - -// The wire format uses a little endian encoding (since that's efficient for -// the common platforms). -#if !defined(FLATBUFFERS_LITTLEENDIAN) - #if defined(__GNUC__) || defined(__clang__) - #ifdef __BIG_ENDIAN__ - #define FLATBUFFERS_LITTLEENDIAN 0 - #else - #define FLATBUFFERS_LITTLEENDIAN 1 - #endif // __BIG_ENDIAN__ - #elif defined(_MSC_VER) - #if defined(_M_PPC) - #define FLATBUFFERS_LITTLEENDIAN 0 - #else - #define FLATBUFFERS_LITTLEENDIAN 1 - #endif - #else - #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN. - #endif -#endif // !defined(FLATBUFFERS_LITTLEENDIAN) - -#define FLATBUFFERS_VERSION_MAJOR 1 -#define FLATBUFFERS_VERSION_MINOR 6 -#define FLATBUFFERS_VERSION_REVISION 0 -#define FLATBUFFERS_STRING_EXPAND(X) #X -#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) - -#if (!defined(_MSC_VER) || _MSC_VER > 1600) && \ - (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) - #define FLATBUFFERS_FINAL_CLASS final -#else - #define FLATBUFFERS_FINAL_CLASS -#endif - -#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \ - (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) - #define FLATBUFFERS_CONSTEXPR constexpr -#else - #define FLATBUFFERS_CONSTEXPR -#endif - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \ - defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 - #define FLATBUFFERS_NOEXCEPT noexcept -#else - #define FLATBUFFERS_NOEXCEPT -#endif - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4127) // C4127: conditional expression is constant -#endif - -/// @endcond - -/// @file -namespace flatbuffers { - -/// @cond FLATBUFFERS_INTERNAL -// Our default offset / size type, 32bit on purpose on 64bit systems. -// Also, using a consistent offset type maintains compatibility of serialized -// offset values between 32bit and 64bit systems. -typedef uint32_t uoffset_t; - -// Signed offsets for references that can go in both directions. -typedef int32_t soffset_t; - -// Offset/index used in v-tables, can be changed to uint8_t in -// format forks to save a bit of space if desired. -typedef uint16_t voffset_t; - -typedef uintmax_t largest_scalar_t; - -// In 32bits, this evaluates to 2GB - 1 -#define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(soffset_t) * 8 - 1)) - 1) - -// We support aligning the contents of buffers up to this size. -#define FLATBUFFERS_MAX_ALIGNMENT 16 - -#ifndef FLATBUFFERS_CPP98_STL -// Pointer to relinquished memory. -typedef std::unique_ptr<uint8_t, std::function<void(uint8_t * /* unused */)>> - unique_ptr_t; -#endif - -// Wrapper for uoffset_t to allow safe template specialization. -template<typename T> struct Offset { - uoffset_t o; - Offset() : o(0) {} - Offset(uoffset_t _o) : o(_o) {} - Offset<void> Union() const { return Offset<void>(o); } -}; - -inline void EndianCheck() { - int endiantest = 1; - // If this fails, see FLATBUFFERS_LITTLEENDIAN above. - assert(*reinterpret_cast<char *>(&endiantest) == FLATBUFFERS_LITTLEENDIAN); - (void)endiantest; -} - -template<typename T> T EndianSwap(T t) { - #if defined(_MSC_VER) - #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort - #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong - #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64 - #else - #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 - // __builtin_bswap16 was missing prior to GCC 4.8. - #define FLATBUFFERS_BYTESWAP16(x) \ - static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16)) - #else - #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16 - #endif - #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32 - #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64 - #endif - if (sizeof(T) == 1) { // Compile-time if-then's. - return t; - } else if (sizeof(T) == 2) { - auto r = FLATBUFFERS_BYTESWAP16(*reinterpret_cast<uint16_t *>(&t)); - return *reinterpret_cast<T *>(&r); - } else if (sizeof(T) == 4) { - auto r = FLATBUFFERS_BYTESWAP32(*reinterpret_cast<uint32_t *>(&t)); - return *reinterpret_cast<T *>(&r); - } else if (sizeof(T) == 8) { - auto r = FLATBUFFERS_BYTESWAP64(*reinterpret_cast<uint64_t *>(&t)); - return *reinterpret_cast<T *>(&r); - } else { - assert(0); - } -} - -template<typename T> T EndianScalar(T t) { - #if FLATBUFFERS_LITTLEENDIAN - return t; - #else - return EndianSwap(t); - #endif -} - -template<typename T> T ReadScalar(const void *p) { - return EndianScalar(*reinterpret_cast<const T *>(p)); -} - -template<typename T> void WriteScalar(void *p, T t) { - *reinterpret_cast<T *>(p) = EndianScalar(t); -} - -template<typename T> size_t AlignOf() { - #ifdef _MSC_VER - return __alignof(T); - #else - #ifndef alignof - return __alignof__(T); - #else - return alignof(T); - #endif - #endif -} - -// When we read serialized data from memory, in the case of most scalars, -// we want to just read T, but in the case of Offset, we want to actually -// perform the indirection and return a pointer. -// The template specialization below does just that. -// It is wrapped in a struct since function templates can't overload on the -// return type like this. -// The typedef is for the convenience of callers of this function -// (avoiding the need for a trailing return decltype) -template<typename T> struct IndirectHelper { - typedef T return_type; - typedef T mutable_return_type; - static const size_t element_stride = sizeof(T); - static return_type Read(const uint8_t *p, uoffset_t i) { - return EndianScalar((reinterpret_cast<const T *>(p))[i]); - } -}; -template<typename T> struct IndirectHelper<Offset<T>> { - typedef const T *return_type; - typedef T *mutable_return_type; - static const size_t element_stride = sizeof(uoffset_t); - static return_type Read(const uint8_t *p, uoffset_t i) { - p += i * sizeof(uoffset_t); - return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p)); - } -}; -template<typename T> struct IndirectHelper<const T *> { - typedef const T *return_type; - typedef T *mutable_return_type; - static const size_t element_stride = sizeof(T); - static return_type Read(const uint8_t *p, uoffset_t i) { - return reinterpret_cast<const T *>(p + i * sizeof(T)); - } -}; - -// An STL compatible iterator implementation for Vector below, effectively -// calling Get() for every element. -template<typename T, typename IT> -struct VectorIterator - : public std::iterator<std::random_access_iterator_tag, IT, uoffset_t> { - - typedef std::iterator<std::random_access_iterator_tag, IT, uoffset_t> super_type; - -public: - VectorIterator(const uint8_t *data, uoffset_t i) : - data_(data + IndirectHelper<T>::element_stride * i) {} - VectorIterator(const VectorIterator &other) : data_(other.data_) {} - #ifndef FLATBUFFERS_CPP98_STL - VectorIterator(VectorIterator &&other) : data_(std::move(other.data_)) {} - #endif - - VectorIterator &operator=(const VectorIterator &other) { - data_ = other.data_; - return *this; - } - - VectorIterator &operator=(VectorIterator &&other) { - data_ = other.data_; - return *this; - } - - bool operator==(const VectorIterator &other) const { - return data_ == other.data_; - } - - bool operator<(const VectorIterator &other) const { - return data_ < other.data_; - } - - bool operator!=(const VectorIterator &other) const { - return data_ != other.data_; - } - - ptrdiff_t operator-(const VectorIterator &other) const { - return (data_ - other.data_) / IndirectHelper<T>::element_stride; - } - - typename super_type::value_type operator *() const { - return IndirectHelper<T>::Read(data_, 0); - } - - typename super_type::value_type operator->() const { - return IndirectHelper<T>::Read(data_, 0); - } - - VectorIterator &operator++() { - data_ += IndirectHelper<T>::element_stride; - return *this; - } - - VectorIterator operator++(int) { - VectorIterator temp(data_, 0); - data_ += IndirectHelper<T>::element_stride; - return temp; - } - - VectorIterator operator+(const uoffset_t &offset) const { - return VectorIterator(data_ + offset * IndirectHelper<T>::element_stride, 0); - } - - VectorIterator& operator+=(const uoffset_t &offset) { - data_ += offset * IndirectHelper<T>::element_stride; - return *this; - } - - VectorIterator &operator--() { - data_ -= IndirectHelper<T>::element_stride; - return *this; - } - - VectorIterator operator--(int) { - VectorIterator temp(data_, 0); - data_ -= IndirectHelper<T>::element_stride; - return temp; - } - - VectorIterator operator-(const uoffset_t &offset) { - return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride, 0); - } - - VectorIterator& operator-=(const uoffset_t &offset) { - data_ -= offset * IndirectHelper<T>::element_stride; - return *this; - } - -private: - const uint8_t *data_; -}; - -struct String; - -// This is used as a helper type for accessing vectors. -// Vector::data() assumes the vector elements start after the length field. -template<typename T> class Vector { -public: - typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type> - iterator; - typedef VectorIterator<T, typename IndirectHelper<T>::return_type> - const_iterator; - - uoffset_t size() const { return EndianScalar(length_); } - - // Deprecated: use size(). Here for backwards compatibility. - uoffset_t Length() const { return size(); } - - typedef typename IndirectHelper<T>::return_type return_type; - typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type; - - return_type Get(uoffset_t i) const { - assert(i < size()); - return IndirectHelper<T>::Read(Data(), i); - } - - return_type operator[](uoffset_t i) const { return Get(i); } - - // If this is a Vector of enums, T will be its storage type, not the enum - // type. This function makes it convenient to retrieve value with enum - // type E. - template<typename E> E GetEnum(uoffset_t i) const { - return static_cast<E>(Get(i)); - } - - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is the right type! - template<typename U> const U *GetAs(uoffset_t i) const { - return reinterpret_cast<const U *>(Get(i)); - } - - // If this a vector of unions, this does the cast for you. There's no check - // to make sure this is actually a string! - const String *GetAsString(uoffset_t i) const { - return reinterpret_cast<const String *>(Get(i)); - } - - const void *GetStructFromOffset(size_t o) const { - return reinterpret_cast<const void *>(Data() + o); - } - - iterator begin() { return iterator(Data(), 0); } - const_iterator begin() const { return const_iterator(Data(), 0); } - - iterator end() { return iterator(Data(), size()); } - const_iterator end() const { return const_iterator(Data(), size()); } - - // Change elements if you have a non-const pointer to this object. - // Scalars only. See reflection.h, and the documentation. - void Mutate(uoffset_t i, const T& val) { - assert(i < size()); - WriteScalar(data() + i, val); - } - - // Change an element of a vector of tables (or strings). - // "val" points to the new table/string, as you can obtain from - // e.g. reflection::AddFlatBuffer(). - void MutateOffset(uoffset_t i, const uint8_t *val) { - assert(i < size()); - assert(sizeof(T) == sizeof(uoffset_t)); - WriteScalar(data() + i, - static_cast<uoffset_t>(val - (Data() + i * sizeof(uoffset_t)))); - } - - // Get a mutable pointer to tables/strings inside this vector. - mutable_return_type GetMutableObject(uoffset_t i) const { - assert(i < size()); - return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i)); - } - - // The raw data in little endian format. Use with care. - const uint8_t *Data() const { - return reinterpret_cast<const uint8_t *>(&length_ + 1); - } - - uint8_t *Data() { - return reinterpret_cast<uint8_t *>(&length_ + 1); - } - - // Similarly, but typed, much like std::vector::data - const T *data() const { return reinterpret_cast<const T *>(Data()); } - T *data() { return reinterpret_cast<T *>(Data()); } - - template<typename K> return_type LookupByKey(K key) const { - void *search_result = std::bsearch(&key, Data(), size(), - IndirectHelper<T>::element_stride, KeyCompare<K>); - - if (!search_result) { - return nullptr; // Key not found. - } - - const uint8_t *element = reinterpret_cast<const uint8_t *>(search_result); - - return IndirectHelper<T>::Read(element, 0); - } - -protected: - // This class is only used to access pre-existing data. Don't ever - // try to construct these manually. - Vector(); - - uoffset_t length_; - -private: - // This class is a pointer. Copying will therefore create an invalid object. - // Private and unimplemented copy constructor. - Vector(const Vector&); - - template<typename K> static int KeyCompare(const void *ap, const void *bp) { - const K *key = reinterpret_cast<const K *>(ap); - const uint8_t *data = reinterpret_cast<const uint8_t *>(bp); - auto table = IndirectHelper<T>::Read(data, 0); - - // std::bsearch compares with the operands transposed, so we negate the - // result here. - return -table->KeyCompareWithValue(*key); - } -}; - -// Represent a vector much like the template above, but in this case we -// don't know what the element types are (used with reflection.h). -class VectorOfAny { -public: - uoffset_t size() const { return EndianScalar(length_); } - - const uint8_t *Data() const { - return reinterpret_cast<const uint8_t *>(&length_ + 1); - } - uint8_t *Data() { - return reinterpret_cast<uint8_t *>(&length_ + 1); - } -protected: - VectorOfAny(); - - uoffset_t length_; - -private: - VectorOfAny(const VectorOfAny&); -}; - -#ifndef FLATBUFFERS_CPP98_STL -template<typename T, typename U> -Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) { - static_assert(std::is_base_of<T, U>::value, "Unrelated types"); - return reinterpret_cast<Vector<Offset<T>> *>(ptr); -} - -template<typename T, typename U> -const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) { - static_assert(std::is_base_of<T, U>::value, "Unrelated types"); - return reinterpret_cast<const Vector<Offset<T>> *>(ptr); -} -#endif - -// Convenient helper function to get the length of any vector, regardless -// of wether it is null or not (the field is not set). -template<typename T> static inline size_t VectorLength(const Vector<T> *v) { - return v ? v->Length() : 0; -} - -struct String : public Vector<char> { - const char *c_str() const { return reinterpret_cast<const char *>(Data()); } - std::string str() const { return std::string(c_str(), Length()); } - - bool operator <(const String &o) const { - return strcmp(c_str(), o.c_str()) < 0; - } -}; - -// Simple indirection for buffer allocation, to allow this to be overridden -// with custom allocation (see the FlatBufferBuilder constructor). -class simple_allocator { - public: - virtual ~simple_allocator() {} - virtual uint8_t *allocate(size_t size) const { return new uint8_t[size]; } - virtual void deallocate(uint8_t *p) const { delete[] p; } -}; - -// This is a minimal replication of std::vector<uint8_t> functionality, -// except growing from higher to lower addresses. i.e push_back() inserts data -// in the lowest address in the vector. -class vector_downward { - public: - explicit vector_downward(size_t initial_size, - const simple_allocator &allocator) - : reserved_((initial_size + sizeof(largest_scalar_t) - 1) & - ~(sizeof(largest_scalar_t) - 1)), - buf_(allocator.allocate(reserved_)), - cur_(buf_ + reserved_), - allocator_(allocator) {} - - ~vector_downward() { - if (buf_) - allocator_.deallocate(buf_); - } - - void clear() { - if (buf_ == nullptr) - buf_ = allocator_.allocate(reserved_); - - cur_ = buf_ + reserved_; - } - - #ifndef FLATBUFFERS_CPP98_STL - // Relinquish the pointer to the caller. - unique_ptr_t release() { - // Actually deallocate from the start of the allocated memory. - std::function<void(uint8_t *)> deleter( - std::bind(&simple_allocator::deallocate, allocator_, buf_)); - - // Point to the desired offset. - unique_ptr_t retval(data(), deleter); - - // Don't deallocate when this instance is destroyed. - buf_ = nullptr; - cur_ = nullptr; - - return retval; - } - #endif - - size_t growth_policy(size_t bytes) { - return (bytes / 2) & ~(sizeof(largest_scalar_t) - 1); - } - - uint8_t *make_space(size_t len) { - if (len > static_cast<size_t>(cur_ - buf_)) { - reallocate(len); - } - cur_ -= len; - // Beyond this, signed offsets may not have enough range: - // (FlatBuffers > 2GB not supported). - assert(size() < FLATBUFFERS_MAX_BUFFER_SIZE); - return cur_; - } - - uoffset_t size() const { - assert(cur_ != nullptr && buf_ != nullptr); - return static_cast<uoffset_t>(reserved_ - (cur_ - buf_)); - } - - uint8_t *data() const { - assert(cur_ != nullptr); - return cur_; - } - - uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; } - - void push(const uint8_t *bytes, size_t num) { - auto dest = make_space(num); - memcpy(dest, bytes, num); - } - - // Specialized version of push() that avoids memcpy call for small data. - template<typename T> void push_small(const T& little_endian_t) { - auto dest = make_space(sizeof(T)); - *reinterpret_cast<T *>(dest) = little_endian_t; - } - - // fill() is most frequently called with small byte counts (<= 4), - // which is why we're using loops rather than calling memset. - void fill(size_t zero_pad_bytes) { - auto dest = make_space(zero_pad_bytes); - for (size_t i = 0; i < zero_pad_bytes; i++) dest[i] = 0; - } - - // Version for when we know the size is larger. - void fill_big(size_t zero_pad_bytes) { - auto dest = make_space(zero_pad_bytes); - memset(dest, 0, zero_pad_bytes); - } - - void pop(size_t bytes_to_remove) { cur_ += bytes_to_remove; } - - private: - // You shouldn't really be copying instances of this class. - vector_downward(const vector_downward &); - vector_downward &operator=(const vector_downward &); - - size_t reserved_; - uint8_t *buf_; - uint8_t *cur_; // Points at location between empty (below) and used (above). - const simple_allocator &allocator_; - - void reallocate(size_t len) { - auto old_size = size(); - auto largest_align = AlignOf<largest_scalar_t>(); - reserved_ += (std::max)(len, growth_policy(reserved_)); - // Round up to avoid undefined behavior from unaligned loads and stores. - reserved_ = (reserved_ + (largest_align - 1)) & ~(largest_align - 1); - auto new_buf = allocator_.allocate(reserved_); - auto new_cur = new_buf + reserved_ - old_size; - memcpy(new_cur, cur_, old_size); - cur_ = new_cur; - allocator_.deallocate(buf_); - buf_ = new_buf; - } -}; - -// Converts a Field ID to a virtual table offset. -inline voffset_t FieldIndexToOffset(voffset_t field_id) { - // Should correspond to what EndTable() below builds up. - const int fixed_fields = 2; // Vtable size and Object Size. - return static_cast<voffset_t>((field_id + fixed_fields) * sizeof(voffset_t)); -} - -// Computes how many bytes you'd have to pad to be able to write an -// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in -// memory). -inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) { - return ((~buf_size) + 1) & (scalar_size - 1); -} - -template <typename T> const T* data(const std::vector<T> &v) { - return v.empty() ? nullptr : &v.front(); -} -template <typename T> T* data(std::vector<T> &v) { - return v.empty() ? nullptr : &v.front(); -} - -/// @endcond - -/// @addtogroup flatbuffers_cpp_api -/// @{ -/// @class FlatBufferBuilder -/// @brief Helper class to hold data needed in creation of a FlatBuffer. -/// To serialize data, you typically call one of the `Create*()` functions in -/// the generated code, which in turn call a sequence of `StartTable`/ -/// `PushElement`/`AddElement`/`EndTable`, or the builtin `CreateString`/ -/// `CreateVector` functions. Do this is depth-first order to build up a tree to -/// the root. `Finish()` wraps up the buffer ready for transport. -class FlatBufferBuilder -/// @cond FLATBUFFERS_INTERNAL -FLATBUFFERS_FINAL_CLASS -/// @endcond -{ - public: - /// @brief Default constructor for FlatBufferBuilder. - /// @param[in] initial_size The initial size of the buffer, in bytes. Defaults - /// to`1024`. - /// @param[in] allocator A pointer to the `simple_allocator` that should be - /// used. Defaults to `nullptr`, which means the `default_allocator` will be - /// be used. - explicit FlatBufferBuilder(uoffset_t initial_size = 1024, - const simple_allocator *allocator = nullptr) - : buf_(initial_size, allocator ? *allocator : default_allocator), - nested(false), finished(false), minalign_(1), force_defaults_(false), - dedup_vtables_(true), string_pool(nullptr) { - offsetbuf_.reserve(16); // Avoid first few reallocs. - vtables_.reserve(16); - EndianCheck(); - } - - ~FlatBufferBuilder() { - if (string_pool) delete string_pool; - } - - /// @brief Reset all the state in this FlatBufferBuilder so it can be reused - /// to construct another buffer. - void Clear() { - buf_.clear(); - offsetbuf_.clear(); - nested = false; - finished = false; - vtables_.clear(); - minalign_ = 1; - if (string_pool) string_pool->clear(); - } - - /// @brief The current size of the serialized buffer, counting from the end. - /// @return Returns an `uoffset_t` with the current size of the buffer. - uoffset_t GetSize() const { return buf_.size(); } - - /// @brief Get the serialized buffer (after you call `Finish()`). - /// @return Returns an `uint8_t` pointer to the FlatBuffer data inside the - /// buffer. - uint8_t *GetBufferPointer() const { - Finished(); - return buf_.data(); - } - - /// @brief Get a pointer to an unfinished buffer. - /// @return Returns a `uint8_t` pointer to the unfinished buffer. - uint8_t *GetCurrentBufferPointer() const { return buf_.data(); } - - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Get the released pointer to the serialized buffer. - /// @warning Do NOT attempt to use this FlatBufferBuilder afterwards! - /// @return The `unique_ptr` returned has a special allocator that knows how - /// to deallocate this pointer (since it points to the middle of an - /// allocation). Thus, do not mix this pointer with other `unique_ptr`'s, or - /// call `release()`/`reset()` on it. - unique_ptr_t ReleaseBufferPointer() { - Finished(); - return buf_.release(); - } - #endif - - /// @brief get the minimum alignment this buffer needs to be accessed - /// properly. This is only known once all elements have been written (after - /// you call Finish()). You can use this information if you need to embed - /// a FlatBuffer in some other buffer, such that you can later read it - /// without first having to copy it into its own buffer. - size_t GetBufferMinAlignment() { - Finished(); - return minalign_; - } - - /// @cond FLATBUFFERS_INTERNAL - void Finished() const { - // If you get this assert, you're attempting to get access a buffer - // which hasn't been finished yet. Be sure to call - // FlatBufferBuilder::Finish with your root table. - // If you really need to access an unfinished buffer, call - // GetCurrentBufferPointer instead. - assert(finished); - } - /// @endcond - - /// @brief In order to save space, fields that are set to their default value - /// don't get serialized into the buffer. - /// @param[in] bool fd When set to `true`, always serializes default values. - void ForceDefaults(bool fd) { force_defaults_ = fd; } - - /// @brief By default vtables are deduped in order to save space. - /// @param[in] bool dedup When set to `true`, dedup vtables. - void DedupVtables(bool dedup) { dedup_vtables_ = dedup; } - - /// @cond FLATBUFFERS_INTERNAL - void Pad(size_t num_bytes) { buf_.fill(num_bytes); } - - void Align(size_t elem_size) { - if (elem_size > minalign_) minalign_ = elem_size; - buf_.fill(PaddingBytes(buf_.size(), elem_size)); - } - - void PushFlatBuffer(const uint8_t *bytes, size_t size) { - PushBytes(bytes, size); - finished = true; - } - - void PushBytes(const uint8_t *bytes, size_t size) { - buf_.push(bytes, size); - } - - void PopBytes(size_t amount) { buf_.pop(amount); } - - template<typename T> void AssertScalarT() { - #ifndef FLATBUFFERS_CPP98_STL - // The code assumes power of 2 sizes and endian-swap-ability. - static_assert(std::is_scalar<T>::value - // The Offset<T> type is essentially a scalar but fails is_scalar. - || sizeof(T) == sizeof(Offset<void>), - "T must be a scalar type"); - #endif - } - - // Write a single aligned scalar to the buffer - template<typename T> uoffset_t PushElement(T element) { - AssertScalarT<T>(); - T litle_endian_element = EndianScalar(element); - Align(sizeof(T)); - buf_.push_small(litle_endian_element); - return GetSize(); - } - - template<typename T> uoffset_t PushElement(Offset<T> off) { - // Special case for offsets: see ReferTo below. - return PushElement(ReferTo(off.o)); - } - - // When writing fields, we track where they are, so we can create correct - // vtables later. - void TrackField(voffset_t field, uoffset_t off) { - FieldLoc fl = { off, field }; - offsetbuf_.push_back(fl); - } - - // Like PushElement, but additionally tracks the field this represents. - template<typename T> void AddElement(voffset_t field, T e, T def) { - // We don't serialize values equal to the default. - if (e == def && !force_defaults_) return; - auto off = PushElement(e); - TrackField(field, off); - } - - template<typename T> void AddOffset(voffset_t field, Offset<T> off) { - if (!off.o) return; // An offset of 0 means NULL, don't store. - AddElement(field, ReferTo(off.o), static_cast<uoffset_t>(0)); - } - - template<typename T> void AddStruct(voffset_t field, const T *structptr) { - if (!structptr) return; // Default, don't store. - Align(AlignOf<T>()); - buf_.push_small(*structptr); - TrackField(field, GetSize()); - } - - void AddStructOffset(voffset_t field, uoffset_t off) { - TrackField(field, off); - } - - // Offsets initially are relative to the end of the buffer (downwards). - // This function converts them to be relative to the current location - // in the buffer (when stored here), pointing upwards. - uoffset_t ReferTo(uoffset_t off) { - // Align to ensure GetSize() below is correct. - Align(sizeof(uoffset_t)); - // Offset must refer to something already in buffer. - assert(off && off <= GetSize()); - return GetSize() - off + static_cast<uoffset_t>(sizeof(uoffset_t)); - } - - void NotNested() { - // If you hit this, you're trying to construct a Table/Vector/String - // during the construction of its parent table (between the MyTableBuilder - // and table.Finish(). - // Move the creation of these sub-objects to above the MyTableBuilder to - // not get this assert. - // Ignoring this assert may appear to work in simple cases, but the reason - // it is here is that storing objects in-line may cause vtable offsets - // to not fit anymore. It also leads to vtable duplication. - assert(!nested); - } - - // From generated code (or from the parser), we call StartTable/EndTable - // with a sequence of AddElement calls in between. - uoffset_t StartTable() { - NotNested(); - nested = true; - return GetSize(); - } - - // This finishes one serialized object by generating the vtable if it's a - // table, comparing it against existing vtables, and writing the - // resulting vtable offset. - uoffset_t EndTable(uoffset_t start, voffset_t numfields) { - // If you get this assert, a corresponding StartTable wasn't called. - assert(nested); - // Write the vtable offset, which is the start of any Table. - // We fill it's value later. - auto vtableoffsetloc = PushElement<soffset_t>(0); - // Write a vtable, which consists entirely of voffset_t elements. - // It starts with the number of offsets, followed by a type id, followed - // by the offsets themselves. In reverse: - buf_.fill_big(numfields * sizeof(voffset_t)); - auto table_object_size = vtableoffsetloc - start; - assert(table_object_size < 0x10000); // Vtable use 16bit offsets. - PushElement<voffset_t>(static_cast<voffset_t>(table_object_size)); - PushElement<voffset_t>(FieldIndexToOffset(numfields)); - // Write the offsets into the table - for (auto field_location = offsetbuf_.begin(); - field_location != offsetbuf_.end(); - ++field_location) { - auto pos = static_cast<voffset_t>(vtableoffsetloc - field_location->off); - // If this asserts, it means you've set a field twice. - assert(!ReadScalar<voffset_t>(buf_.data() + field_location->id)); - WriteScalar<voffset_t>(buf_.data() + field_location->id, pos); - } - offsetbuf_.clear(); - auto vt1 = reinterpret_cast<voffset_t *>(buf_.data()); - auto vt1_size = ReadScalar<voffset_t>(vt1); - auto vt_use = GetSize(); - // See if we already have generated a vtable with this exact same - // layout before. If so, make it point to the old one, remove this one. - if (dedup_vtables_) { - for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { - auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*it)); - auto vt2_size = *vt2; - if (vt1_size != vt2_size || memcmp(vt2, vt1, vt1_size)) continue; - vt_use = *it; - buf_.pop(GetSize() - vtableoffsetloc); - break; - } - } - // If this is a new vtable, remember it. - if (vt_use == GetSize()) { - vtables_.push_back(vt_use); - } - // Fill the vtable offset we created above. - // The offset points from the beginning of the object to where the - // vtable is stored. - // Offsets default direction is downward in memory for future format - // flexibility (storing all vtables at the start of the file). - WriteScalar(buf_.data_at(vtableoffsetloc), - static_cast<soffset_t>(vt_use) - - static_cast<soffset_t>(vtableoffsetloc)); - - nested = false; - return vtableoffsetloc; - } - - // This checks a required field has been set in a given table that has - // just been constructed. - template<typename T> void Required(Offset<T> table, voffset_t field) { - auto table_ptr = buf_.data_at(table.o); - auto vtable_ptr = table_ptr - ReadScalar<soffset_t>(table_ptr); - bool ok = ReadScalar<voffset_t>(vtable_ptr + field) != 0; - // If this fails, the caller will show what field needs to be set. - assert(ok); - (void)ok; - } - - uoffset_t StartStruct(size_t alignment) { - Align(alignment); - return GetSize(); - } - - uoffset_t EndStruct() { return GetSize(); } - - void ClearOffsets() { offsetbuf_.clear(); } - - // Aligns such that when "len" bytes are written, an object can be written - // after it with "alignment" without padding. - void PreAlign(size_t len, size_t alignment) { - buf_.fill(PaddingBytes(GetSize() + len, alignment)); - } - template<typename T> void PreAlign(size_t len) { - AssertScalarT<T>(); - PreAlign(len, sizeof(T)); - } - /// @endcond - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const char pointer to the data to be stored as a string. - /// @param[in] len The number of bytes that should be stored from `str`. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateString(const char *str, size_t len) { - NotNested(); - PreAlign<uoffset_t>(len + 1); // Always 0-terminated. - buf_.fill(1); - PushBytes(reinterpret_cast<const uint8_t *>(str), len); - PushElement(static_cast<uoffset_t>(len)); - return Offset<String>(GetSize()); - } - - /// @brief Store a string in the buffer, which is null-terminated. - /// @param[in] str A const char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateString(const char *str) { - return CreateString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const reference to a std::string to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateString(const std::string &str) { - return CreateString(str.c_str(), str.length()); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const pointer to a `String` struct to add to the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset<String> CreateString(const String *str) { - return str ? CreateString(str->c_str(), str->Length()) : 0; - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// @param[in] str A const reference to a std::string like type with support - /// of T::c_str() and T::length() to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - template<typename T> - Offset<String> CreateString(const T &str) { - return CreateString(str.c_str(), str.length()); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to the data to be stored as a string. - /// @param[in] len The number of bytes that should be stored from `str`. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const char *str, size_t len) { - if (!string_pool) - string_pool = new StringOffsetMap(StringOffsetCompare(buf_)); - auto size_before_string = buf_.size(); - // Must first serialize the string, since the set is all offsets into - // buffer. - auto off = CreateString(str, len); - auto it = string_pool->find(off); - // If it exists we reuse existing serialized data! - if (it != string_pool->end()) { - // We can remove the string we serialized. - buf_.pop(buf_.size() - size_before_string); - return *it; - } - // Record this string for future use. - string_pool->insert(off); - return off; - } - - /// @brief Store a string in the buffer, which null-terminated. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const char pointer to a C-string to add to the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const char *str) { - return CreateSharedString(str, strlen(str)); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const reference to a std::string to store in the buffer. - /// @return Returns the offset in the buffer where the string starts. - Offset<String> CreateSharedString(const std::string &str) { - return CreateSharedString(str.c_str(), str.length()); - } - - /// @brief Store a string in the buffer, which can contain any binary data. - /// If a string with this exact contents has already been serialized before, - /// instead simply returns the offset of the existing string. - /// @param[in] str A const pointer to a `String` struct to add to the buffer. - /// @return Returns the offset in the buffer where the string starts - Offset<String> CreateSharedString(const String *str) { - return CreateSharedString(str->c_str(), str->Length()); - } - - /// @cond FLATBUFFERS_INTERNAL - uoffset_t EndVector(size_t len) { - assert(nested); // Hit if no corresponding StartVector. - nested = false; - return PushElement(static_cast<uoffset_t>(len)); - } - - void StartVector(size_t len, size_t elemsize) { - NotNested(); - nested = true; - PreAlign<uoffset_t>(len * elemsize); - PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t. - } - - // Call this right before StartVector/CreateVector if you want to force the - // alignment to be something different than what the element size would - // normally dictate. - // This is useful when storing a nested_flatbuffer in a vector of bytes, - // or when storing SIMD floats, etc. - void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { - PreAlign(len * elemsize, alignment); - } - - uint8_t *ReserveElements(size_t len, size_t elemsize) { - return buf_.make_space(len * elemsize); - } - /// @endcond - - /// @brief Serialize an array into a FlatBuffer `vector`. - /// @tparam T The data type of the array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<T>> CreateVector(const T *v, size_t len) { - StartVector(len, sizeof(T)); - if (sizeof(T) == 1) { - PushBytes(reinterpret_cast<const uint8_t *>(v), len); - } else { - for (auto i = len; i > 0; ) { - PushElement(v[--i]); - } - } - return Offset<Vector<T>>(EndVector(len)); - } - - /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. - /// @tparam T The data type of the `std::vector` elements. - /// @param v A const reference to the `std::vector` to serialize into the - /// buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<T>> CreateVector(const std::vector<T> &v) { - return CreateVector(data(v), v.size()); - } - - // vector<bool> may be implemented using a bit-set, so we can't access it as - // an array. Instead, read elements manually. - // Background: https://isocpp.org/blog/2012/11/on-vectorbool - Offset<Vector<uint8_t>> CreateVector(const std::vector<bool> &v) { - StartVector(v.size(), sizeof(uint8_t)); - for (auto i = v.size(); i > 0; ) { - PushElement(static_cast<uint8_t>(v[--i])); - } - return Offset<Vector<uint8_t>>(EndVector(v.size())); - } - - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize values returned by a function into a FlatBuffer `vector`. - /// This is a convenience function that takes care of iteration for you. - /// @tparam T The data type of the `std::vector` elements. - /// @param f A function that takes the current iteration 0..vector_size-1 and - /// returns any type that you can construct a FlatBuffers vector out of. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<T>> CreateVector(size_t vector_size, - const std::function<T (size_t i)> &f) { - std::vector<T> elems(vector_size); - for (size_t i = 0; i < vector_size; i++) elems[i] = f(i); - return CreateVector(elems); - } - #endif - - /// @brief Serialize a `std::vector<std::string>` into a FlatBuffer `vector`. - /// This is a convenience function for a common case. - /// @param v A const reference to the `std::vector` to serialize into the - /// buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - Offset<Vector<Offset<String>>> CreateVectorOfStrings( - const std::vector<std::string> &v) { - std::vector<Offset<String>> offsets(v.size()); - for (size_t i = 0; i < v.size(); i++) offsets[i] = CreateString(v[i]); - return CreateVector(offsets); - } - - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( - const T *v, size_t len) { - StartVector(len * sizeof(T) / AlignOf<T>(), AlignOf<T>()); - PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len); - return Offset<Vector<const T *>>(EndVector(len)); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfNativeStructs( - const S *v, size_t len) { - extern T Pack(const S&); - typedef T (*Pack_t)(const S&); - std::vector<T> vv(len); - std::transform(v, v+len, vv.begin(), *(Pack_t)&Pack); - return CreateVectorOfStructs<T>(vv.data(), vv.size()); - } - - - #ifndef FLATBUFFERS_CPP98_STL - /// @brief Serialize an array of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the struct array elements. - /// @param[in] f A function that takes the current iteration 0..vector_size-1 - /// and a pointer to the struct that must be filled. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - /// This is mostly useful when flatbuffers are generated with mutation - /// accessors. - template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( - size_t vector_size, const std::function<void(size_t i, T *)> &filler) { - StartVector(vector_size * sizeof(T) / AlignOf<T>(), AlignOf<T>()); - T *structs = reinterpret_cast<T *>(buf_.make_space(vector_size * sizeof(T))); - for (size_t i = 0; i < vector_size; i++) { - filler(i, structs); - structs++; - } - return Offset<Vector<const T *>>(EndVector(vector_size)); - } - #endif - - /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @param[in]] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs( - const std::vector<T> &v) { - return CreateVectorOfStructs(data(v), v.size()); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer `vector`. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. - /// @param[in]] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfNativeStructs( - const std::vector<S> &v) { - return CreateVectorOfNativeStructs<T, S>(data(v), v.size()); - } - - - /// @cond FLATBUFFERS_INTERNAL - template<typename T> - struct StructKeyComparator { - bool operator()(const T &a, const T &b) const { - return a.KeyCompareLessThan(&b); - } - - private: - StructKeyComparator& operator= (const StructKeyComparator&); - }; - /// @endcond - - /// @brief Serialize a `std::vector` of structs into a FlatBuffer `vector` - /// in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. - /// @param[in]] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<const T *>> CreateVectorOfSortedStructs( - std::vector<T> *v) { - return CreateVectorOfSortedStructs(data(*v), v->size()); - } - - /// @brief Serialize a `std::vector` of native structs into a FlatBuffer `vector` - /// in sorted order. - /// @tparam T The data type of the `std::vector` struct elements. - /// @tparam S The data type of the `std::vector` native struct elements. - /// @param[in]] v A const reference to the `std::vector` of structs to - /// serialize into the buffer as a `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs( - std::vector<S> *v) { - return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size()); - } - - /// @brief Serialize an array of structs into a FlatBuffer `vector` in sorted - /// order. - /// @tparam T The data type of the struct array elements. - /// @param[in] v A pointer to the array of type `T` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<const T *>> CreateVectorOfSortedStructs( - T *v, size_t len) { - std::sort(v, v + len, StructKeyComparator<T>()); - return CreateVectorOfStructs(v, len); - } - - /// @brief Serialize an array of native structs into a FlatBuffer `vector` in sorted - /// order. - /// @tparam T The data type of the struct array elements. - /// @tparam S The data type of the native struct array elements. - /// @param[in] v A pointer to the array of type `S` to serialize into the - /// buffer as a `vector`. - /// @param[in] len The number of elements to serialize. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T, typename S> Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs( - S *v, size_t len) { - extern T Pack(const S&); - typedef T (*Pack_t)(const S&); - std::vector<T> vv(len); - std::transform(v, v+len, vv.begin(), *(Pack_t)&Pack); - return CreateVectorOfSortedStructs<T>(vv, len); - } - - /// @cond FLATBUFFERS_INTERNAL - template<typename T> - struct TableKeyComparator { - TableKeyComparator(vector_downward& buf) : buf_(buf) {} - bool operator()(const Offset<T> &a, const Offset<T> &b) const { - auto table_a = reinterpret_cast<T *>(buf_.data_at(a.o)); - auto table_b = reinterpret_cast<T *>(buf_.data_at(b.o)); - return table_a->KeyCompareLessThan(table_b); - } - vector_downward& buf_; - - private: - TableKeyComparator& operator= (const TableKeyComparator&); - }; - /// @endcond - - /// @brief Serialize an array of `table` offsets as a `vector` in the buffer - /// in sorted order. - /// @tparam T The data type that the offset refers to. - /// @param[in] v An array of type `Offset<T>` that contains the `table` - /// offsets to store in the buffer in sorted order. - /// @param[in] len The number of elements to store in the `vector`. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<Offset<T>>> CreateVectorOfSortedTables( - Offset<T> *v, size_t len) { - std::sort(v, v + len, TableKeyComparator<T>(buf_)); - return CreateVector(v, len); - } - - /// @brief Serialize an array of `table` offsets as a `vector` in the buffer - /// in sorted order. - /// @tparam T The data type that the offset refers to. - /// @param[in] v An array of type `Offset<T>` that contains the `table` - /// offsets to store in the buffer in sorted order. - /// @return Returns a typed `Offset` into the serialized data indicating - /// where the vector is stored. - template<typename T> Offset<Vector<Offset<T>>> CreateVectorOfSortedTables( - std::vector<Offset<T>> *v) { - return CreateVectorOfSortedTables(data(*v), v->size()); - } - - /// @brief Specialized version of `CreateVector` for non-copying use cases. - /// Write the data any time later to the returned buffer pointer `buf`. - /// @param[in] len The number of elements to store in the `vector`. - /// @param[in] elemsize The size of each element in the `vector`. - /// @param[out] buf A pointer to a `uint8_t` pointer that can be - /// written to at a later time to serialize the data into a `vector` - /// in the buffer. - uoffset_t CreateUninitializedVector(size_t len, size_t elemsize, - uint8_t **buf) { - NotNested(); - StartVector(len, elemsize); - buf_.make_space(len * elemsize); - auto vec_start = GetSize(); - auto vec_end = EndVector(len); - *buf = buf_.data_at(vec_start); - return vec_end; - } - - /// @brief Specialized version of `CreateVector` for non-copying use cases. - /// Write the data any time later to the returned buffer pointer `buf`. - /// @tparam T The data type of the data that will be stored in the buffer - /// as a `vector`. - /// @param[in] len The number of elements to store in the `vector`. - /// @param[out] buf A pointer to a pointer of type `T` that can be - /// written to at a later time to serialize the data into a `vector` - /// in the buffer. - template<typename T> Offset<Vector<T>> CreateUninitializedVector( - size_t len, T **buf) { - return CreateUninitializedVector(len, sizeof(T), - reinterpret_cast<uint8_t **>(buf)); - } - - /// @brief Write a struct by itself, typically to be part of a union. - template<typename T> Offset<const T *> CreateStruct(const T &structobj) { - Align(AlignOf<T>()); - buf_.push_small(structobj); - return Offset<const T *>(GetSize()); - } - - /// @brief The length of a FlatBuffer file header. - static const size_t kFileIdentifierLength = 4; - - /// @brief Finish serializing a buffer by writing the root offset. - /// @param[in] file_identifier If a `file_identifier` is given, the buffer - /// will be prefixed with a standard FlatBuffers file header. - template<typename T> void Finish(Offset<T> root, - const char *file_identifier = nullptr) { - - Finish(root.o, file_identifier, false); - } - - /// @brief Finish a buffer with a 32 bit size field pre-fixed (size of the - /// buffer following the size field). These buffers are NOT compatible - /// with standard buffers created by Finish, i.e. you can't call GetRoot - /// on them, you have to use GetSizePrefixedRoot instead. - /// All >32 bit quantities in this buffer will be aligned when the whole - /// size pre-fixed buffer is aligned. - /// These kinds of buffers are useful for creating a stream of FlatBuffers. - template<typename T> void FinishSizePrefixed(Offset<T> root, - const char *file_identifier = nullptr) { - Finish(root.o, file_identifier, true); - } - - private: - // You shouldn't really be copying instances of this class. - FlatBufferBuilder(const FlatBufferBuilder &); - FlatBufferBuilder &operator=(const FlatBufferBuilder &); - - void Finish(uoffset_t root, const char *file_identifier, bool size_prefix) { - NotNested(); - // This will cause the whole buffer to be aligned. - PreAlign((size_prefix ? sizeof(uoffset_t) : 0) + - sizeof(uoffset_t) + - (file_identifier ? kFileIdentifierLength : 0), - minalign_); - if (file_identifier) { - assert(strlen(file_identifier) == kFileIdentifierLength); - PushBytes(reinterpret_cast<const uint8_t *>(file_identifier), - kFileIdentifierLength); - } - PushElement(ReferTo(root)); // Location of root. - if (size_prefix) { - PushElement(GetSize()); - } - finished = true; - } - - struct FieldLoc { - uoffset_t off; - voffset_t id; - }; - - simple_allocator default_allocator; - - vector_downward buf_; - - // Accumulating offsets of table members while it is being built. - std::vector<FieldLoc> offsetbuf_; - - // Ensure objects are not nested. - bool nested; - - // Ensure the buffer is finished before it is being accessed. - bool finished; - - std::vector<uoffset_t> vtables_; // todo: Could make this into a map? - - size_t minalign_; - - bool force_defaults_; // Serialize values equal to their defaults anyway. - - bool dedup_vtables_; - - struct StringOffsetCompare { - StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} - bool operator() (const Offset<String> &a, const Offset<String> &b) const { - auto stra = reinterpret_cast<const String *>(buf_->data_at(a.o)); - auto strb = reinterpret_cast<const String *>(buf_->data_at(b.o)); - return strncmp(stra->c_str(), strb->c_str(), - std::min(stra->size(), strb->size()) + 1) < 0; - } - const vector_downward *buf_; - }; - - // For use with CreateSharedString. Instantiated on first use only. - typedef std::set<Offset<String>, StringOffsetCompare> StringOffsetMap; - StringOffsetMap *string_pool; -}; -/// @} - -/// @cond FLATBUFFERS_INTERNAL -// Helpers to get a typed pointer to the root object contained in the buffer. -template<typename T> T *GetMutableRoot(void *buf) { - EndianCheck(); - return reinterpret_cast<T *>(reinterpret_cast<uint8_t *>(buf) + - EndianScalar(*reinterpret_cast<uoffset_t *>(buf))); -} - -template<typename T> const T *GetRoot(const void *buf) { - return GetMutableRoot<T>(const_cast<void *>(buf)); -} - -template<typename T> const T *GetSizePrefixedRoot(const void *buf) { - return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t)); -} - -/// Helpers to get a typed pointer to objects that are currently being built. -/// @warning Creating new objects will lead to reallocations and invalidates -/// the pointer! -template<typename T> T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, - Offset<T> offset) { - return reinterpret_cast<T *>(fbb.GetCurrentBufferPointer() + - fbb.GetSize() - offset.o); -} - -template<typename T> const T *GetTemporaryPointer(FlatBufferBuilder &fbb, - Offset<T> offset) { - return GetMutableTemporaryPointer<T>(fbb, offset); -} - -// Helper to see if the identifier in a buffer has the expected value. -inline bool BufferHasIdentifier(const void *buf, const char *identifier) { - return strncmp(reinterpret_cast<const char *>(buf) + sizeof(uoffset_t), - identifier, FlatBufferBuilder::kFileIdentifierLength) == 0; -} - -// Helper class to verify the integrity of a FlatBuffer -class Verifier FLATBUFFERS_FINAL_CLASS { - public: - Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, - uoffset_t _max_tables = 1000000) - : buf_(buf), end_(buf + buf_len), depth_(0), max_depth_(_max_depth), - num_tables_(0), max_tables_(_max_tables) - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - , upper_bound_(buf) - #endif - {} - - // Central location where any verification failures register. - bool Check(bool ok) const { - #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE - assert(ok); - #endif - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - if (!ok) - upper_bound_ = buf_; - #endif - return ok; - } - - // Verify any range within the buffer. - bool Verify(const void *elem, size_t elem_len) const { - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - auto upper_bound = reinterpret_cast<const uint8_t *>(elem) + elem_len; - if (upper_bound_ < upper_bound) - upper_bound_ = upper_bound; - #endif - return Check(elem_len <= (size_t) (end_ - buf_) && - elem >= buf_ && - elem <= end_ - elem_len); - } - - // Verify a range indicated by sizeof(T). - template<typename T> bool Verify(const void *elem) const { - return Verify(elem, sizeof(T)); - } - - // Verify a pointer (may be NULL) of a table type. - template<typename T> bool VerifyTable(const T *table) { - return !table || table->Verify(*this); - } - - // Verify a pointer (may be NULL) of any vector type. - template<typename T> bool Verify(const Vector<T> *vec) const { - const uint8_t *end; - return !vec || - VerifyVector(reinterpret_cast<const uint8_t *>(vec), sizeof(T), - &end); - } - - // Verify a pointer (may be NULL) of a vector to struct. - template<typename T> bool Verify(const Vector<const T *> *vec) const { - return Verify(reinterpret_cast<const Vector<T> *>(vec)); - } - - // Verify a pointer (may be NULL) to string. - bool Verify(const String *str) const { - const uint8_t *end; - return !str || - (VerifyVector(reinterpret_cast<const uint8_t *>(str), 1, &end) && - Verify(end, 1) && // Must have terminator - Check(*end == '\0')); // Terminating byte must be 0. - } - - // Common code between vectors and strings. - bool VerifyVector(const uint8_t *vec, size_t elem_size, - const uint8_t **end) const { - // Check we can read the size field. - if (!Verify<uoffset_t>(vec)) return false; - // Check the whole array. If this is a string, the byte past the array - // must be 0. - auto size = ReadScalar<uoffset_t>(vec); - auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; - if (!Check(size < max_elems)) - return false; // Protect against byte_size overflowing. - auto byte_size = sizeof(size) + elem_size * size; - *end = vec + byte_size; - return Verify(vec, byte_size); - } - - // Special case for string contents, after the above has been called. - bool VerifyVectorOfStrings(const Vector<Offset<String>> *vec) const { - if (vec) { - for (uoffset_t i = 0; i < vec->size(); i++) { - if (!Verify(vec->Get(i))) return false; - } - } - return true; - } - - // Special case for table contents, after the above has been called. - template<typename T> bool VerifyVectorOfTables(const Vector<Offset<T>> *vec) { - if (vec) { - for (uoffset_t i = 0; i < vec->size(); i++) { - if (!vec->Get(i)->Verify(*this)) return false; - } - } - return true; - } - - template<typename T> bool VerifyBufferFromStart(const char *identifier, - const uint8_t *start) { - if (identifier && - (size_t(end_ - start) < 2 * sizeof(flatbuffers::uoffset_t) || - !BufferHasIdentifier(start, identifier))) { - return false; - } - - // Call T::Verify, which must be in the generated code for this type. - return Verify<uoffset_t>(start) && - reinterpret_cast<const T *>(start + ReadScalar<uoffset_t>(start))-> - Verify(*this) - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - && GetComputedSize() - #endif - ; - } - - // Verify this whole buffer, starting with root type T. - template<typename T> bool VerifyBuffer() { - return VerifyBuffer<T>(nullptr); - } - - template<typename T> bool VerifyBuffer(const char *identifier) { - return VerifyBufferFromStart<T>(identifier, buf_); - } - - template<typename T> bool VerifySizePrefixedBuffer(const char *identifier) { - return Verify<uoffset_t>(buf_) && - ReadScalar<uoffset_t>(buf_) == end_ - buf_ - sizeof(uoffset_t) && - VerifyBufferFromStart<T>(identifier, buf_ + sizeof(uoffset_t)); - } - - // Called at the start of a table to increase counters measuring data - // structure depth and amount, and possibly bails out with false if - // limits set by the constructor have been hit. Needs to be balanced - // with EndTable(). - bool VerifyComplexity() { - depth_++; - num_tables_++; - return Check(depth_ <= max_depth_ && num_tables_ <= max_tables_); - } - - // Called at the end of a table to pop the depth count. - bool EndTable() { - depth_--; - return true; - } - - #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - // Returns the message size in bytes - size_t GetComputedSize() const { - uintptr_t size = upper_bound_ - buf_; - // Align the size to uoffset_t - size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1); - return (buf_ + size > end_) ? 0 : size; - } - #endif - - private: - const uint8_t *buf_; - const uint8_t *end_; - uoffset_t depth_; - uoffset_t max_depth_; - uoffset_t num_tables_; - uoffset_t max_tables_; -#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE - mutable const uint8_t *upper_bound_; -#endif -}; - -// Convenient way to bundle a buffer and its length, to pass it around -// typed by its root. -// A BufferRef does not own its buffer. -struct BufferRefBase {}; // for std::is_base_of -template<typename T> struct BufferRef : BufferRefBase { - BufferRef() : buf(nullptr), len(0), must_free(false) {} - BufferRef(uint8_t *_buf, uoffset_t _len) - : buf(_buf), len(_len), must_free(false) {} - - ~BufferRef() { if (must_free) free(buf); } - - const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); } - - bool Verify() { - Verifier verifier(buf, len); - return verifier.VerifyBuffer<T>(nullptr); - } - - uint8_t *buf; - uoffset_t len; - bool must_free; -}; - -// "structs" are flat structures that do not have an offset table, thus -// always have all members present and do not support forwards/backwards -// compatible extensions. - -class Struct FLATBUFFERS_FINAL_CLASS { - public: - template<typename T> T GetField(uoffset_t o) const { - return ReadScalar<T>(&data_[o]); - } - - template<typename T> T GetStruct(uoffset_t o) const { - return reinterpret_cast<T>(&data_[o]); - } - - const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } - uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } - - private: - uint8_t data_[1]; -}; - -// "tables" use an offset table (possibly shared) that allows fields to be -// omitted and added at will, but uses an extra indirection to read. -class Table { - public: - const uint8_t *GetVTable() const { - return data_ - ReadScalar<soffset_t>(data_); - } - - // This gets the field offset for any of the functions below it, or 0 - // if the field was not present. - voffset_t GetOptionalFieldOffset(voffset_t field) const { - // The vtable offset is always at the start. - auto vtable = GetVTable(); - // The first element is the size of the vtable (fields + type id + itself). - auto vtsize = ReadScalar<voffset_t>(vtable); - // If the field we're accessing is outside the vtable, we're reading older - // data, so it's the same as if the offset was 0 (not present). - return field < vtsize ? ReadScalar<voffset_t>(vtable + field) : 0; - } - - template<typename T> T GetField(voffset_t field, T defaultval) const { - auto field_offset = GetOptionalFieldOffset(field); - return field_offset ? ReadScalar<T>(data_ + field_offset) : defaultval; - } - - template<typename P> P GetPointer(voffset_t field) { - auto field_offset = GetOptionalFieldOffset(field); - auto p = data_ + field_offset; - return field_offset - ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p)) - : nullptr; - } - template<typename P> P GetPointer(voffset_t field) const { - return const_cast<Table *>(this)->GetPointer<P>(field); - } - - template<typename P> P GetStruct(voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - auto p = const_cast<uint8_t *>(data_ + field_offset); - return field_offset ? reinterpret_cast<P>(p) : nullptr; - } - - template<typename T> bool SetField(voffset_t field, T val, T def) { - auto field_offset = GetOptionalFieldOffset(field); - if (!field_offset) return val == def; - WriteScalar(data_ + field_offset, val); - return true; - } - - bool SetPointer(voffset_t field, const uint8_t *val) { - auto field_offset = GetOptionalFieldOffset(field); - if (!field_offset) return false; - WriteScalar(data_ + field_offset, - static_cast<uoffset_t>(val - (data_ + field_offset))); - return true; - } - - uint8_t *GetAddressOf(voffset_t field) { - auto field_offset = GetOptionalFieldOffset(field); - return field_offset ? data_ + field_offset : nullptr; - } - const uint8_t *GetAddressOf(voffset_t field) const { - return const_cast<Table *>(this)->GetAddressOf(field); - } - - bool CheckField(voffset_t field) const { - return GetOptionalFieldOffset(field) != 0; - } - - // Verify the vtable of this table. - // Call this once per table, followed by VerifyField once per field. - bool VerifyTableStart(Verifier &verifier) const { - // Check the vtable offset. - if (!verifier.Verify<soffset_t>(data_)) return false; - auto vtable = GetVTable(); - // Check the vtable size field, then check vtable fits in its entirety. - return verifier.VerifyComplexity() && - verifier.Verify<voffset_t>(vtable) && - (ReadScalar<voffset_t>(vtable) & (sizeof(voffset_t) - 1)) == 0 && - verifier.Verify(vtable, ReadScalar<voffset_t>(vtable)); - } - - // Verify a particular field. - template<typename T> bool VerifyField(const Verifier &verifier, - voffset_t field) const { - // Calling GetOptionalFieldOffset should be safe now thanks to - // VerifyTable(). - auto field_offset = GetOptionalFieldOffset(field); - // Check the actual field. - return !field_offset || verifier.Verify<T>(data_ + field_offset); - } - - // VerifyField for required fields. - template<typename T> bool VerifyFieldRequired(const Verifier &verifier, - voffset_t field) const { - auto field_offset = GetOptionalFieldOffset(field); - return verifier.Check(field_offset != 0) && - verifier.Verify<T>(data_ + field_offset); - } - - private: - // private constructor & copy constructor: you obtain instances of this - // class by pointing to existing data only - Table(); - Table(const Table &other); - - uint8_t data_[1]; -}; - -/// @brief This can compute the start of a FlatBuffer from a root pointer, i.e. -/// it is the opposite transformation of GetRoot(). -/// This may be useful if you want to pass on a root and have the recipient -/// delete the buffer afterwards. -inline const uint8_t *GetBufferStartFromRootPointer(const void *root) { - auto table = reinterpret_cast<const Table *>(root); - auto vtable = table->GetVTable(); - // Either the vtable is before the root or after the root. - auto start = std::min(vtable, reinterpret_cast<const uint8_t *>(root)); - // Align to at least sizeof(uoffset_t). - start = reinterpret_cast<const uint8_t *>( - reinterpret_cast<uintptr_t>(start) & ~(sizeof(uoffset_t) - 1)); - // Additionally, there may be a file_identifier in the buffer, and the root - // offset. The buffer may have been aligned to any size between - // sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align"). - // Sadly, the exact alignment is only known when constructing the buffer, - // since it depends on the presence of values with said alignment properties. - // So instead, we simply look at the next uoffset_t values (root, - // file_identifier, and alignment padding) to see which points to the root. - // None of the other values can "impersonate" the root since they will either - // be 0 or four ASCII characters. - static_assert(FlatBufferBuilder::kFileIdentifierLength == sizeof(uoffset_t), - "file_identifier is assumed to be the same size as uoffset_t"); - for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1; - possible_roots; - possible_roots--) { - start -= sizeof(uoffset_t); - if (ReadScalar<uoffset_t>(start) + start == - reinterpret_cast<const uint8_t *>(root)) return start; - } - // We didn't find the root, either the "root" passed isn't really a root, - // or the buffer is corrupt. - // Assert, because calling this function with bad data may cause reads - // outside of buffer boundaries. - assert(false); - return nullptr; -} - -// Base class for native objects (FlatBuffer data de-serialized into native -// C++ data structures). -// Contains no functionality, purely documentative. -struct NativeTable { -}; - -/// @brief Function types to be used with resolving hashes into objects and -/// back again. The resolver gets a pointer to a field inside an object API -/// object that is of the type specified in the schema using the attribute -/// `cpp_type` (it is thus important whatever you write to this address -/// matches that type). The value of this field is initially null, so you -/// may choose to implement a delayed binding lookup using this function -/// if you wish. The resolver does the opposite lookup, for when the object -/// is being serialized again. -typedef uint64_t hash_value_t; -#ifdef FLATBUFFERS_CPP98_STL - typedef void (*resolver_function_t)(void **pointer_adr, hash_value_t hash); - typedef hash_value_t (*rehasher_function_t)(void *pointer); -#else - typedef std::function<void (void **pointer_adr, hash_value_t hash)> - resolver_function_t; - typedef std::function<hash_value_t (void *pointer)> rehasher_function_t; -#endif - -// Helper function to test if a field is present, using any of the field -// enums in the generated code. -// `table` must be a generated table type. Since this is a template parameter, -// this is not typechecked to be a subclass of Table, so beware! -// Note: this function will return false for fields equal to the default -// value, since they're not stored in the buffer (unless force_defaults was -// used). -template<typename T> bool IsFieldPresent(const T *table, voffset_t field) { - // Cast, since Table is a private baseclass of any table types. - return reinterpret_cast<const Table *>(table)->CheckField(field); -} - -// Utility function for reverse lookups on the EnumNames*() functions -// (in the generated C++ code) -// names must be NULL terminated. -inline int LookupEnum(const char **names, const char *name) { - for (const char **p = names; *p; p++) - if (!strcmp(*p, name)) - return static_cast<int>(p - names); - return -1; -} - -// These macros allow us to layout a struct with a guarantee that they'll end -// up looking the same on different compilers and platforms. -// It does this by disallowing the compiler to do any padding, and then -// does padding itself by inserting extra padding fields that make every -// element aligned to its own size. -// Additionally, it manually sets the alignment of the struct as a whole, -// which is typically its largest element, or a custom size set in the schema -// by the force_align attribute. -// These are used in the generated code only. - -#if defined(_MSC_VER) - #define MANUALLY_ALIGNED_STRUCT(alignment) \ - __pragma(pack(1)); \ - struct __declspec(align(alignment)) - #define STRUCT_END(name, size) \ - __pragma(pack()); \ - static_assert(sizeof(name) == size, "compiler breaks packing rules") -#elif defined(__GNUC__) || defined(__clang__) - #define MANUALLY_ALIGNED_STRUCT(alignment) \ - _Pragma("pack(1)") \ - struct __attribute__((aligned(alignment))) - #define STRUCT_END(name, size) \ - _Pragma("pack()") \ - static_assert(sizeof(name) == size, "compiler breaks packing rules") -#else - #error Unknown compiler, please define structure alignment macros -#endif - -// String which identifies the current version of FlatBuffers. -// flatbuffer_version_string is used by Google developers to identify which -// applications uploaded to Google Play are using this library. This allows -// the development team at Google to determine the popularity of the library. -// How it works: Applications that are uploaded to the Google Play Store are -// scanned for this version string. We track which applications are using it -// to measure popularity. You are free to remove it (of course) but we would -// appreciate if you left it in. - -// Weak linkage is culled by VS & doesn't work on cygwin. -#if !defined(_WIN32) && !defined(__CYGWIN__) - -extern volatile __attribute__((weak)) const char *flatbuffer_version_string; -volatile __attribute__((weak)) const char *flatbuffer_version_string = - "FlatBuffers " - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); - -#endif // !defined(_WIN32) && !defined(__CYGWIN__) - -#define DEFINE_BITMASK_OPERATORS(E, T)\ - inline E operator | (E lhs, E rhs){\ - return E(T(lhs) | T(rhs));\ - }\ - inline E operator & (E lhs, E rhs){\ - return E(T(lhs) & T(rhs));\ - }\ - inline E operator ^ (E lhs, E rhs){\ - return E(T(lhs) ^ T(rhs));\ - }\ - inline E operator ~ (E lhs){\ - return E(~T(lhs));\ - }\ - inline E operator |= (E &lhs, E rhs){\ - lhs = lhs | rhs;\ - return lhs;\ - }\ - inline E operator &= (E &lhs, E rhs){\ - lhs = lhs & rhs;\ - return lhs;\ - }\ - inline E operator ^= (E &lhs, E rhs){\ - lhs = lhs ^ rhs;\ - return lhs;\ - }\ - inline bool operator !(E rhs) \ - {\ - return !bool(T(rhs)); \ - } -/// @endcond -} // namespace flatbuffers - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif // FLATBUFFERS_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/flatc.h b/third_party/flatbuffers/include/flatbuffers/flatc.h deleted file mode 100644 index e7bc835..0000000 --- a/third_party/flatbuffers/include/flatbuffers/flatc.h +++ /dev/null
@@ -1,96 +0,0 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include <functional> -#include <limits> -#include <string> - -#ifndef FLATC_H_ -#define FLATC_H_ - -namespace flatbuffers { - -class FlatCompiler { - public: - // Output generator for the various programming languages and formats we - // support. - struct Generator { - typedef bool (*GenerateFn)(const flatbuffers::Parser &parser, - const std::string &path, - const std::string &file_name); - typedef std::string (*MakeRuleFn)(const flatbuffers::Parser &parser, - const std::string &path, - const std::string &file_name); - - GenerateFn generate; - const char *generator_opt_short; - const char *generator_opt_long; - const char *lang_name; - GenerateFn generateGRPC; - flatbuffers::IDLOptions::Language lang; - const char *generator_help; - MakeRuleFn make_rule; - }; - - typedef void (*WarnFn)(const FlatCompiler *flatc, - const std::string &warn, - bool show_exe_name); - - typedef void (*ErrorFn)(const FlatCompiler *flatc, - const std::string &err, - bool usage, bool show_exe_name); - - // Parameters required to initialize the FlatCompiler. - struct InitParams { - InitParams() - : generators(nullptr), - num_generators(0), - warn_fn(nullptr), - error_fn(nullptr) {} - - const Generator* generators; - size_t num_generators; - WarnFn warn_fn; - ErrorFn error_fn; - }; - - explicit FlatCompiler(const InitParams& params) : params_(params) {} - - int Compile(int argc, const char** argv); - - std::string GetUsageString(const char* program_name) const; - - private: - void ParseFile(flatbuffers::Parser &parser, - const std::string &filename, - const std::string &contents, - std::vector<const char *> &include_directories) const; - - void Warn(const std::string &warn, bool show_exe_name = true) const; - - void Error(const std::string &err, bool usage = true, - bool show_exe_name = true) const; - - InitParams params_; -}; - - -} // namespace flatbuffers - -#endif // FLATC_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/flexbuffers.h b/third_party/flatbuffers/include/flatbuffers/flexbuffers.h deleted file mode 100644 index 2c7a25e..0000000 --- a/third_party/flatbuffers/include/flatbuffers/flexbuffers.h +++ /dev/null
@@ -1,1353 +0,0 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_FLEXBUFFERS_H_ -#define FLATBUFFERS_FLEXBUFFERS_H_ - -#include <map> -// We use the basic binary writing functions from the regular FlatBuffers. -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/util.h" - -#ifdef _MSC_VER -#include <intrin.h> -#endif - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4127) // C4127: conditional expression is constant -#endif - -namespace flexbuffers { - -class Reference; -class Map; - -// These are used in the lower 2 bits of a type field to determine the size of -// the elements (and or size field) of the item pointed to (e.g. vector). -enum BitWidth { - BIT_WIDTH_8 = 0, - BIT_WIDTH_16 = 1, - BIT_WIDTH_32 = 2, - BIT_WIDTH_64 = 3, -}; - -// These are used as the upper 6 bits of a type field to indicate the actual -// type. -enum Type { - TYPE_NULL = 0, - TYPE_INT = 1, - TYPE_UINT = 2, - TYPE_FLOAT = 3, - // Types above stored inline, types below store an offset. - TYPE_KEY = 4, - TYPE_STRING = 5, - TYPE_INDIRECT_INT = 6, - TYPE_INDIRECT_UINT = 7, - TYPE_INDIRECT_FLOAT = 8, - TYPE_MAP = 9, - TYPE_VECTOR = 10, // Untyped. - TYPE_VECTOR_INT = 11, // Typed any size (stores no type table). - TYPE_VECTOR_UINT = 12, - TYPE_VECTOR_FLOAT = 13, - TYPE_VECTOR_KEY = 14, - TYPE_VECTOR_STRING = 15, - TYPE_VECTOR_INT2 = 16, // Typed tuple (no type table, no size field). - TYPE_VECTOR_UINT2 = 17, - TYPE_VECTOR_FLOAT2 = 18, - TYPE_VECTOR_INT3 = 19, // Typed triple (no type table, no size field). - TYPE_VECTOR_UINT3 = 20, - TYPE_VECTOR_FLOAT3 = 21, - TYPE_VECTOR_INT4 = 22, // Typed quad (no type table, no size field). - TYPE_VECTOR_UINT4 = 23, - TYPE_VECTOR_FLOAT4 = 24, - TYPE_BLOB = 25, -}; - -inline bool IsInline(Type t) { return t <= TYPE_FLOAT; } - -inline bool IsTypedVectorElementType(Type t) { - return t >= TYPE_INT && t <= TYPE_STRING; -} - -inline bool IsTypedVector(Type t) { - return t >= TYPE_VECTOR_INT && t <= TYPE_VECTOR_STRING; -} - -inline bool IsFixedTypedVector(Type t) { - return t >= TYPE_VECTOR_INT2 && t <= TYPE_VECTOR_FLOAT4; -} - -inline Type ToTypedVector(Type t, size_t fixed_len = 0) { - assert(IsTypedVectorElementType(t)); - switch (fixed_len) { - case 0: return static_cast<Type>(t - TYPE_INT + TYPE_VECTOR_INT); - case 2: return static_cast<Type>(t - TYPE_INT + TYPE_VECTOR_INT2); - case 3: return static_cast<Type>(t - TYPE_INT + TYPE_VECTOR_INT3); - case 4: return static_cast<Type>(t - TYPE_INT + TYPE_VECTOR_INT4); - default: assert(0); return TYPE_NULL; - } -} - -inline Type ToTypedVectorElementType(Type t) { - assert(IsTypedVector(t)); - return static_cast<Type>(t - TYPE_VECTOR_INT + TYPE_INT); -} - -inline Type ToFixedTypedVectorElementType(Type t, uint8_t *len) { - assert(IsFixedTypedVector(t)); - auto fixed_type = t - TYPE_VECTOR_INT2; - *len = static_cast<uint8_t>(fixed_type / 3 + 2); // 3 types each, starting from length 2. - return static_cast<Type>(fixed_type % 3 + TYPE_INT); -} - -// TODO: implement proper support for 8/16bit floats, or decide not to -// support them. -typedef int16_t half; -typedef int8_t quarter; - -// TODO: can we do this without conditionals using intrinsics or inline asm -// on some platforms? Given branch prediction the method below should be -// decently quick, but it is the most frequently executed function. -// We could do an (unaligned) 64-bit read if we ifdef out the platforms for -// which that doesn't work (or where we'd read into un-owned memory). -template <typename R, typename T1, typename T2, typename T4, typename T8> -R ReadSizedScalar(const uint8_t *data, uint8_t byte_width) { - return byte_width < 4 - ? (byte_width < 2 ? static_cast<R>(flatbuffers::ReadScalar<T1>(data)) - : static_cast<R>(flatbuffers::ReadScalar<T2>(data))) - : (byte_width < 8 ? static_cast<R>(flatbuffers::ReadScalar<T4>(data)) - : static_cast<R>(flatbuffers::ReadScalar<T8>(data))); -} - - -inline int64_t ReadInt64(const uint8_t *data, uint8_t byte_width) { - return ReadSizedScalar<int64_t, int8_t, int16_t, int32_t, int64_t>(data, - byte_width); -} - -inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) { - // This is the "hottest" function (all offset lookups use this), so worth - // optimizing if possible. - // TODO: GCC apparently replaces memcpy by a rep movsb, but only if count is a - // constant, which here it isn't. Test if memcpy is still faster than - // the conditionals in ReadSizedScalar. Can also use inline asm. - #ifdef _MSC_VER - uint64_t u = 0; - __movsb(reinterpret_cast<uint8_t *>(&u), - reinterpret_cast<const uint8_t *>(data), byte_width); - return flatbuffers::EndianScalar(u); - #else - return ReadSizedScalar<uint64_t, uint8_t, uint16_t, uint32_t, uint64_t>( - data, byte_width); - #endif -} - -inline double ReadDouble(const uint8_t *data, uint8_t byte_width) { - return ReadSizedScalar<double, quarter, half, float, double>(data, - byte_width); -} - -inline const uint8_t *Indirect(const uint8_t *offset, uint8_t byte_width) { - return offset - ReadUInt64(offset, byte_width); -} - -template<typename T> const uint8_t *Indirect(const uint8_t *offset) { - return offset - flatbuffers::ReadScalar<T>(offset); -} - -inline BitWidth WidthU(uint64_t u) { - #define FLATBUFFERS_GET_FIELD_BIT_WIDTH(value, width) { \ - if (!((u) & ~((1ULL << (width)) - 1ULL))) return BIT_WIDTH_##width; \ - } - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 8); - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 16); - FLATBUFFERS_GET_FIELD_BIT_WIDTH(u, 32); - #undef FLATBUFFERS_GET_FIELD_BIT_WIDTH - return BIT_WIDTH_64; -} - -inline BitWidth WidthI(int64_t i) { - auto u = static_cast<uint64_t>(i) << 1; - return WidthU(i >= 0 ? u : ~u); -} - -inline BitWidth WidthF(double f) { - return static_cast<double>(static_cast<float>(f)) == f ? BIT_WIDTH_32 - : BIT_WIDTH_64; -} - -// Base class of all types below. -// Points into the data buffer and allows access to one type. -class Object { - public: - Object(const uint8_t *data, uint8_t byte_width) - : data_(data), byte_width_(byte_width) {} - - protected: - const uint8_t *data_; - uint8_t byte_width_; -}; - -// Stores size in `byte_width_` bytes before data_ pointer. -class Sized : public Object { - public: - Sized(const uint8_t *data, uint8_t byte_width) : Object(data, byte_width) {} - size_t size() const { - return static_cast<size_t>(ReadUInt64(data_ - byte_width_, byte_width_)); - } -}; - -class String : public Sized { - public: - String(const uint8_t *data, uint8_t byte_width) - : Sized(data, byte_width) {} - - size_t length() const { return size(); } - const char *c_str() const { return reinterpret_cast<const char *>(data_); } - std::string str() const { return std::string(c_str(), length()); } - - static String EmptyString() { - static const uint8_t empty_string[] = { 0/*len*/, 0/*terminator*/ }; - return String(empty_string + 1, 1); - } - bool IsTheEmptyString() const { return data_ == EmptyString().data_; } -}; - -class Blob : public Sized { - public: - Blob(const uint8_t *data, uint8_t byte_width) - : Sized(data, byte_width) {} - - static Blob EmptyBlob() { - static const uint8_t empty_blob[] = { 0/*len*/ }; - return Blob(empty_blob + 1, 1); - } - bool IsTheEmptyBlob() const { return data_ == EmptyBlob().data_; } -}; - -class Vector : public Sized { - public: - Vector(const uint8_t *data, uint8_t byte_width) - : Sized(data, byte_width) {} - - Reference operator[](size_t i) const; - - static Vector EmptyVector() { - static const uint8_t empty_vector[] = { 0/*len*/ }; - return Vector(empty_vector + 1, 1); - } - bool IsTheEmptyVector() const { return data_ == EmptyVector().data_; } -}; - -class TypedVector : public Sized { - public: - TypedVector(const uint8_t *data, uint8_t byte_width, Type element_type) - : Sized(data, byte_width), type_(element_type) {} - - Reference operator[](size_t i) const; - - static TypedVector EmptyTypedVector() { - static const uint8_t empty_typed_vector[] = { 0/*len*/ }; - return TypedVector(empty_typed_vector + 1, 1, TYPE_INT); - } - bool IsTheEmptyVector() const { - return data_ == TypedVector::EmptyTypedVector().data_; - } - - Type ElementType() { return type_; } - - private: - Type type_; - - friend Map; -}; - -class FixedTypedVector : public Object { - public: - FixedTypedVector(const uint8_t *data, uint8_t byte_width, Type element_type, - uint8_t len) - : Object(data, byte_width), type_(element_type), len_(len) {} - - Reference operator[](size_t i) const; - - static FixedTypedVector EmptyFixedTypedVector() { - static const uint8_t fixed_empty_vector[] = { 0/* unused */ }; - return FixedTypedVector(fixed_empty_vector, 1, TYPE_INT, 0); - } - bool IsTheEmptyFixedTypedVector() const { - return data_ == FixedTypedVector::EmptyFixedTypedVector().data_; - } - - Type ElementType() { return type_; } - uint8_t size() { return len_; } - - private: - Type type_; - uint8_t len_; -}; - -class Map : public Vector { - public: - Map(const uint8_t *data, uint8_t byte_width) - : Vector(data, byte_width) {} - - Reference operator[](const char *key) const; - Reference operator[](const std::string &key) const; - - Vector Values() const { return Vector(data_, byte_width_); } - - TypedVector Keys() const { - const size_t num_prefixed_fields = 3; - auto keys_offset = data_ - byte_width_ * num_prefixed_fields; - return TypedVector(Indirect(keys_offset, byte_width_), - static_cast<uint8_t>( - ReadUInt64(keys_offset + byte_width_, byte_width_)), - TYPE_KEY); - } - - static Map EmptyMap() { - static const uint8_t empty_map[] = { - 0/*keys_len*/, 0/*keys_offset*/, 1/*keys_width*/, 0/*len*/ - }; - return Map(empty_map + 4, 1); - } - - bool IsTheEmptyMap() const { - return data_ == EmptyMap().data_; - } -}; - -class Reference { - public: - Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width, - Type type) - : data_(data), parent_width_(parent_width), byte_width_(byte_width), - type_(type) {} - - Reference(const uint8_t *data, uint8_t parent_width, uint8_t packed_type) - : data_(data), parent_width_(parent_width) { - byte_width_ = 1U << static_cast<BitWidth>(packed_type & 3); - type_ = static_cast<Type>(packed_type >> 2); - } - - Type GetType() const { return type_; } - - bool IsNull() const { return type_ == TYPE_NULL; } - bool IsInt() const { return type_ == TYPE_INT || - type_ == TYPE_INDIRECT_INT; } - bool IsUInt() const { return type_ == TYPE_UINT|| - type_ == TYPE_INDIRECT_UINT;; } - bool IsIntOrUint() const { return IsInt() || IsUInt(); } - bool IsFloat() const { return type_ == TYPE_FLOAT || - type_ == TYPE_INDIRECT_FLOAT; } - bool IsNumeric() const { return IsIntOrUint() || IsFloat(); } - bool IsString() const { return type_ == TYPE_STRING; } - bool IsKey() const { return type_ == TYPE_KEY; } - bool IsVector() const { return type_ == TYPE_VECTOR || type_ == TYPE_MAP; } - bool IsMap() const { return type_ == TYPE_MAP; } - - // Reads any type as a int64_t. Never fails, does most sensible conversion. - // Truncates floats, strings are attempted to be parsed for a number, - // vectors/maps return their size. Returns 0 if all else fails. - int64_t AsInt64() const { - if (type_ == TYPE_INT) { - // A fast path for the common case. - return ReadInt64(data_, parent_width_); - } else switch (type_) { - case TYPE_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); - case TYPE_UINT: return ReadUInt64(data_, parent_width_); - case TYPE_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); - case TYPE_FLOAT: return static_cast<int64_t>( - ReadDouble(data_, parent_width_)); - case TYPE_INDIRECT_FLOAT: return static_cast<int64_t>( - ReadDouble(Indirect(), byte_width_)); - case TYPE_NULL: return 0; - case TYPE_STRING: return flatbuffers::StringToInt(AsString().c_str()); - case TYPE_VECTOR: return static_cast<int64_t>(AsVector().size()); - default: - // Convert other things to int. - return 0; - } - } - - // TODO: could specialize these to not use AsInt64() if that saves - // extension ops in generated code, and use a faster op than ReadInt64. - int32_t AsInt32() const { return static_cast<int32_t>(AsInt64()); } - int16_t AsInt16() const { return static_cast<int16_t>(AsInt64()); } - int8_t AsInt8() const { return static_cast<int8_t> (AsInt64()); } - - uint64_t AsUInt64() const { - if (type_ == TYPE_UINT) { - // A fast path for the common case. - return ReadUInt64(data_, parent_width_); - } else switch (type_) { - case TYPE_INDIRECT_UINT: return ReadUInt64(Indirect(), byte_width_); - case TYPE_INT: return ReadInt64(data_, parent_width_); - case TYPE_INDIRECT_INT: return ReadInt64(Indirect(), byte_width_); - case TYPE_FLOAT: return static_cast<uint64_t>( - ReadDouble(data_, parent_width_)); - case TYPE_INDIRECT_FLOAT: return static_cast<uint64_t>( - ReadDouble(Indirect(), byte_width_)); - case TYPE_NULL: return 0; - case TYPE_STRING: return flatbuffers::StringToUInt(AsString().c_str()); - case TYPE_VECTOR: return static_cast<uint64_t>(AsVector().size()); - default: - // Convert other things to uint. - return 0; - } - } - - uint32_t AsUInt32() const { return static_cast<uint32_t>(AsUInt64()); } - uint16_t AsUInt16() const { return static_cast<uint16_t>(AsUInt64()); } - uint8_t AsUInt8() const { return static_cast<uint8_t> (AsUInt64()); } - - double AsDouble() const { - if (type_ == TYPE_FLOAT) { - // A fast path for the common case. - return ReadDouble(data_, parent_width_); - } else switch (type_) { - case TYPE_INDIRECT_FLOAT: return ReadDouble(Indirect(), byte_width_); - case TYPE_INT: return static_cast<double>( - ReadInt64(data_, parent_width_)); - case TYPE_UINT: return static_cast<double>( - ReadUInt64(data_, parent_width_)); - case TYPE_INDIRECT_INT: return static_cast<double>( - ReadInt64(Indirect(), byte_width_)); - case TYPE_INDIRECT_UINT: return static_cast<double>( - ReadUInt64(Indirect(), byte_width_)); - case TYPE_NULL: return 0.0; - case TYPE_STRING: return strtod(AsString().c_str(), nullptr); - case TYPE_VECTOR: return static_cast<double>(AsVector().size()); - default: - // Convert strings and other things to float. - return 0; - } - } - - float AsFloat() const { return static_cast<float>(AsDouble()); } - - const char *AsKey() const { - if (type_ == TYPE_KEY) { - return reinterpret_cast<const char *>(Indirect()); - } else { - return ""; - } - } - - // This function returns the empty string if you try to read a not-string. - String AsString() const { - if (type_ == TYPE_STRING) { - return String(Indirect(), byte_width_); - } else { - return String::EmptyString(); - } - } - - // Unlike AsString(), this will convert any type to a std::string. - std::string ToString() const { - if (type_ == TYPE_STRING) { - return String(Indirect(), byte_width_).c_str(); - } else if (IsKey()) { - return AsKey(); - } else if (IsInt()) { - return flatbuffers::NumToString(AsInt64()); - } else if (IsUInt()) { - return flatbuffers::NumToString(AsUInt64()); - } else if (IsFloat()) { - return flatbuffers::NumToString(AsDouble()); - } else if (IsNull()) { - return "null"; - } else if (IsMap()) { - return "{..}"; // TODO: show elements. - } else if (IsVector()) { - return "[..]"; // TODO: show elements. - } else { - return "(?)"; - } - } - - // This function returns the empty blob if you try to read a not-blob. - // Strings can be viewed as blobs too. - Blob AsBlob() const { - if (type_ == TYPE_BLOB || type_ == TYPE_STRING) { - return Blob(Indirect(), byte_width_); - } else { - return Blob::EmptyBlob(); - } - } - - // This function returns the empty vector if you try to read a not-vector. - // Maps can be viewed as vectors too. - Vector AsVector() const { - if (type_ == TYPE_VECTOR || type_ == TYPE_MAP) { - return Vector(Indirect(), byte_width_); - } else { - return Vector::EmptyVector(); - } - } - - TypedVector AsTypedVector() const { - if (IsTypedVector(type_)) { - return TypedVector(Indirect(), byte_width_, - ToTypedVectorElementType(type_)); - } else { - return TypedVector::EmptyTypedVector(); - } - } - - FixedTypedVector AsFixedTypedVector() const { - if (IsFixedTypedVector(type_)) { - uint8_t len = 0; - auto vtype = ToFixedTypedVectorElementType(type_, &len); - return FixedTypedVector(Indirect(), byte_width_, vtype, len); - } else { - return FixedTypedVector::EmptyFixedTypedVector(); - } - } - - Map AsMap() const { - if (type_ == TYPE_MAP) { - return Map(Indirect(), byte_width_); - } else { - return Map::EmptyMap(); - } - } - - // Experimental: Mutation functions. - // These allow scalars in an already created buffer to be updated in-place. - // Since by default scalars are stored in the smallest possible space, - // the new value may not fit, in which case these functions return false. - // To avoid this, you can construct the values you intend to mutate using - // Builder::ForceMinimumBitWidth. - bool MutateInt(int64_t i) { - if (type_ == TYPE_INT) { - return Mutate(data_, i, parent_width_, WidthI(i)); - } else if (type_ == TYPE_INDIRECT_INT) { - return Mutate(Indirect(), i, byte_width_, WidthI(i)); - } else if (type_ == TYPE_UINT) { - auto u = static_cast<uint64_t>(i); - return Mutate(data_, u, parent_width_, WidthU(u)); - } else if (type_ == TYPE_INDIRECT_UINT) { - auto u = static_cast<uint64_t>(i); - return Mutate(Indirect(), u, byte_width_, WidthU(u)); - } else { - return false; - } - } - - bool MutateUInt(uint64_t u) { - if (type_ == TYPE_UINT) { - return Mutate(data_, u, parent_width_, WidthU(u)); - } else if (type_ == TYPE_INDIRECT_UINT) { - return Mutate(Indirect(), u, byte_width_, WidthU(u)); - } else if (type_ == TYPE_INT) { - auto i = static_cast<int64_t>(u); - return Mutate(data_, i, parent_width_, WidthI(i)); - } else if (type_ == TYPE_INDIRECT_INT) { - auto i = static_cast<int64_t>(u); - return Mutate(Indirect(), i, byte_width_, WidthI(i)); - } else { - return false; - } - } - - bool MutateFloat(float f) { - if (type_ == TYPE_FLOAT) { - return MutateF(data_, f, parent_width_, BIT_WIDTH_32); - } else if (type_ == TYPE_INDIRECT_FLOAT) { - return MutateF(Indirect(), f, byte_width_, BIT_WIDTH_32); - } else { - return false; - } - } - - bool MutateFloat(double d) { - if (type_ == TYPE_FLOAT) { - return MutateF(data_, d, parent_width_, WidthF(d)); - } else if (type_ == TYPE_INDIRECT_FLOAT) { - return MutateF(Indirect(), d, byte_width_, WidthF(d)); - } else { - return false; - } - } - - bool MutateString(const char *str, size_t len) { - auto s = AsString(); - if (s.IsTheEmptyString()) return false; - // This is very strict, could allow shorter strings, but that creates - // garbage. - if (s.length() != len) return false; - memcpy(const_cast<char *>(s.c_str()), str, len); - return true; - } - bool MutateString(const char *str) { - return MutateString(str, strlen(str)); - } - bool MutateString(const std::string &str) { - return MutateString(str.data(), str.length()); - } - - private: - const uint8_t *Indirect() const { - return flexbuffers::Indirect(data_, parent_width_); - } - - template<typename T> bool Mutate(const uint8_t *dest, T t, size_t byte_width, - BitWidth value_width) { - auto fits = static_cast<size_t>(static_cast<size_t>(1U) << value_width) <= byte_width; - if (fits) { - t = flatbuffers::EndianScalar(t); - memcpy(const_cast<uint8_t *>(dest), &t, byte_width); - } - return fits; - } - - template<typename T> bool MutateF(const uint8_t *dest, T t, size_t byte_width, - BitWidth value_width) { - if (byte_width == sizeof(double)) - return Mutate(dest, static_cast<double>(t), byte_width, value_width); - if (byte_width == sizeof(float)) - return Mutate(dest, static_cast<float>(t), byte_width, value_width); - assert(false); - return false; - } - - const uint8_t *data_; - uint8_t parent_width_; - uint8_t byte_width_; - Type type_; -}; - -inline uint8_t PackedType(BitWidth bit_width, Type type) { - return static_cast<uint8_t>(bit_width | (type << 2)); -} - -inline uint8_t NullPackedType() { - return PackedType(BIT_WIDTH_8, TYPE_NULL); -} - -// Vector accessors. -// Note: if you try to access outside of bounds, you get a Null value back -// instead. Normally this would be an assert, but since this is "dynamically -// typed" data, you may not want that (someone sends you a 2d vector and you -// wanted 3d). -// The Null converts seamlessly into a default value for any other type. -// TODO(wvo): Could introduce an #ifdef that makes this into an assert? -inline Reference Vector::operator[](size_t i) const { - auto len = size(); - if (i >= len) return Reference(nullptr, 1, NullPackedType()); - auto packed_type = (data_ + len * byte_width_)[i]; - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, packed_type); -} - -inline Reference TypedVector::operator[](size_t i) const { - auto len = size(); - if (i >= len) return Reference(nullptr, 1, NullPackedType()); - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, 1, type_); -} - -inline Reference FixedTypedVector::operator[](size_t i) const { - if (i >= len_) return Reference(nullptr, 1, NullPackedType()); - auto elem = data_ + i * byte_width_; - return Reference(elem, byte_width_, 1, type_); -} - -template<typename T> int KeyCompare(const void *key, const void *elem) { - auto str_elem = reinterpret_cast<const char *>( - Indirect<T>(reinterpret_cast<const uint8_t *>(elem))); - auto skey = reinterpret_cast<const char *>(key); - return strcmp(skey, str_elem); -} - -inline Reference Map::operator[](const char *key) const { - auto keys = Keys(); - // We can't pass keys.byte_width_ to the comparison function, so we have - // to pick the right one ahead of time. - int (*comp)(const void *, const void *) = nullptr; - switch (keys.byte_width_) { - case 1: comp = KeyCompare<uint8_t>; break; - case 2: comp = KeyCompare<uint16_t>; break; - case 4: comp = KeyCompare<uint32_t>; break; - case 8: comp = KeyCompare<uint64_t>; break; - } - auto res = std::bsearch(key, keys.data_, keys.size(), keys.byte_width_, comp); - if (!res) - return Reference(nullptr, 1, NullPackedType()); - auto i = (reinterpret_cast<uint8_t *>(res) - keys.data_) / keys.byte_width_; - return (*static_cast<const Vector *>(this))[i]; -} - -inline Reference Map::operator[](const std::string &key) const { - return (*this)[key.c_str()]; -} - -inline Reference GetRoot(const uint8_t *buffer, size_t size) { - // See Finish() below for the serialization counterpart of this. - // The root starts at the end of the buffer, so we parse backwards from there. - auto end = buffer + size; - auto byte_width = *--end; - auto packed_type = *--end; - end -= byte_width; // The root data item. - return Reference(end, byte_width, packed_type); -} - -inline Reference GetRoot(const std::vector<uint8_t> &buffer) { - return GetRoot(buffer.data(), buffer.size()); -} - -// Flags that configure how the Builder behaves. -// The "Share" flags determine if the Builder automatically tries to pool -// this type. Pooling can reduce the size of serialized data if there are -// multiple maps of the same kind, at the expense of slightly slower -// serialization (the cost of lookups) and more memory use (std::set). -// By default this is on for keys, but off for strings. -// Turn keys off if you have e.g. only one map. -// Turn strings on if you expect many non-unique string values. -// Additionally, sharing key vectors can save space if you have maps with -// identical field populations. -enum BuilderFlag { - BUILDER_FLAG_NONE = 0, - BUILDER_FLAG_SHARE_KEYS = 1, - BUILDER_FLAG_SHARE_STRINGS = 2, - BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3, - BUILDER_FLAG_SHARE_KEY_VECTORS = 4, - BUILDER_FLAG_SHARE_ALL = 7, -}; - -class Builder FLATBUFFERS_FINAL_CLASS { - public: - Builder(size_t initial_size = 256, - BuilderFlag flags = BUILDER_FLAG_SHARE_KEYS) - : buf_(initial_size), finished_(false), flags_(flags), - force_min_bit_width_(BIT_WIDTH_8), key_pool(KeyOffsetCompare(buf_)), - string_pool(StringOffsetCompare(buf_)) { - buf_.clear(); - } - - /// @brief Get the serialized buffer (after you call `Finish()`). - /// @return Returns a vector owned by this class. - const std::vector<uint8_t> &GetBuffer() const { - Finished(); - return buf_; - } - - // All value constructing functions below have two versions: one that - // takes a key (for placement inside a map) and one that doesn't (for inside - // vectors and elsewhere). - - void Null() { stack_.push_back(Value()); } - void Null(const char *key) { Key(key); Null(); } - - void Int(int64_t i) { stack_.push_back(Value(i, TYPE_INT, WidthI(i))); } - void Int(const char *key, int64_t i) { Key(key); Int(i); } - - void UInt(uint64_t u) { stack_.push_back(Value(u, TYPE_UINT, WidthU(u))); } - void UInt(const char *key, uint64_t u) { Key(key); Int(u); } - - void Float(float f) { stack_.push_back(Value(f)); } - void Float(const char *key, float f) { Key(key); Float(f); } - - void Double(double f) { stack_.push_back(Value(f)); } - void Double(const char *key, double d) { Key(key); Double(d); } - - void Bool(bool b) { Int(static_cast<int64_t>(b)); } - void Bool(const char *key, bool b) { Key(key); Bool(b); } - - void IndirectInt(int64_t i) { - PushIndirect(i, TYPE_INDIRECT_INT, WidthI(i)); - } - void IndirectInt(const char *key, int64_t i) { - Key(key); - IndirectInt(i); - } - - void IndirectUInt(uint64_t u) { - PushIndirect(u, TYPE_INDIRECT_UINT, WidthU(u)); - } - void IndirectUInt(const char *key, uint64_t u) { - Key(key); - IndirectUInt(u); - } - - void IndirectFloat(float f) { - PushIndirect(f, TYPE_INDIRECT_FLOAT, BIT_WIDTH_32); - } - void IndirectFloat(const char *key, float f) { - Key(key); - IndirectFloat(f); - } - - void IndirectDouble(double f) { - PushIndirect(f, TYPE_INDIRECT_FLOAT, WidthF(f)); - } - void IndirectDouble(const char *key, double d) { - Key(key); - IndirectDouble(d); - } - - size_t Key(const char *str, size_t len) { - auto sloc = buf_.size(); - WriteBytes(str, len + 1); - if (flags_ & BUILDER_FLAG_SHARE_KEYS) { - auto it = key_pool.find(sloc); - if (it != key_pool.end()) { - // Already in the buffer. Remove key we just serialized, and use - // existing offset instead. - buf_.resize(sloc); - sloc = *it; - } else { - key_pool.insert(sloc); - } - } - stack_.push_back(Value(static_cast<uint64_t>(sloc), TYPE_KEY, BIT_WIDTH_8)); - return sloc; - } - - size_t Key(const char *str) { return Key(str, strlen(str)); } - size_t Key(const std::string &str) { return Key(str.c_str(), str.size()); } - - size_t String(const char *str, size_t len) { - auto reset_to = buf_.size(); - auto sloc = CreateBlob(str, len, 1, TYPE_STRING); - if (flags_ & BUILDER_FLAG_SHARE_STRINGS) { - StringOffset so(sloc, len); - auto it = string_pool.find(so); - if (it != string_pool.end()) { - // Already in the buffer. Remove string we just serialized, and use - // existing offset instead. - buf_.resize(reset_to); - sloc = it->first; - stack_.back().u_ = sloc; - } else { - string_pool.insert(so); - } - } - return sloc; - } - size_t String(const char *str) { - return String(str, strlen(str)); - } - size_t String(const std::string &str) { - return String(str.c_str(), str.size()); - } - void String(const flexbuffers::String &str) { - String(str.c_str(), str.length()); - } - - void String(const char *key, const char *str) { - Key(key); - String(str); - } - void String(const char *key, const std::string &str) { - Key(key); - String(str); - } - void String(const char *key, const flexbuffers::String &str) { - Key(key); - String(str); - } - - size_t Blob(const void *data, size_t len) { - return CreateBlob(data, len, 0, TYPE_BLOB); - } - size_t Blob(const std::vector<uint8_t> &v) { - return CreateBlob(v.data(), v.size(), 0, TYPE_BLOB); - } - - // TODO(wvo): support all the FlexBuffer types (like flexbuffers::String), - // e.g. Vector etc. Also in overloaded versions. - // Also some FlatBuffers types? - - size_t StartVector() { return stack_.size(); } - size_t StartVector(const char *key) { Key(key); return stack_.size(); } - size_t StartMap() { return stack_.size(); } - size_t StartMap(const char *key) { Key(key); return stack_.size(); } - - // TODO(wvo): allow this to specify an aligment greater than the natural - // alignment. - size_t EndVector(size_t start, bool typed, bool fixed) { - auto vec = CreateVector(start, stack_.size() - start, 1, typed, fixed); - // Remove temp elements and return vector. - stack_.resize(start); - stack_.push_back(vec); - return static_cast<size_t>(vec.u_); - } - - size_t EndMap(size_t start) { - // We should have interleaved keys and values on the stack. - // Make sure it is an even number: - auto len = stack_.size() - start; - assert(!(len & 1)); - len /= 2; - // Make sure keys are all strings: - for (auto key = start; key < stack_.size(); key += 2) { - assert(stack_[key].type_ == TYPE_KEY); - } - // Now sort values, so later we can do a binary seach lookup. - // We want to sort 2 array elements at a time. - struct TwoValue { Value key; Value val; }; - // TODO(wvo): strict aliasing? - // TODO(wvo): allow the caller to indicate the data is already sorted - // for maximum efficiency? With an assert to check sortedness to make sure - // we're not breaking binary search. - // Or, we can track if the map is sorted as keys are added which would be - // be quite cheap (cheaper than checking it here), so we can skip this - // step automatically when appliccable, and encourage people to write in - // sorted fashion. - // std::sort is typically already a lot faster on sorted data though. - auto dict = reinterpret_cast<TwoValue *>(stack_.data() + start); - std::sort(dict, dict + len, - [&](const TwoValue &a, const TwoValue &b) -> bool { - auto as = reinterpret_cast<const char *>(buf_.data() + a.key.u_); - auto bs = reinterpret_cast<const char *>(buf_.data() + b.key.u_); - auto comp = strcmp(as, bs); - // If this assertion hits, you've added two keys with the same value to - // this map. - // TODO: Have to check for pointer equality, as some sort implementation - // apparently call this function with the same element?? Why? - assert(comp || &a == &b); - return comp < 0; - }); - // First create a vector out of all keys. - // TODO(wvo): if kBuilderFlagShareKeyVectors is true, see if we can share - // the first vector. - auto keys = CreateVector(start, len, 2, true, false); - auto vec = CreateVector(start + 1, len, 2, false, false, &keys); - // Remove temp elements and return map. - stack_.resize(start); - stack_.push_back(vec); - return static_cast<size_t>(vec.u_); - } - - template<typename F> size_t Vector(F f) { - auto start = StartVector(); - f(); - return EndVector(start, false, false); - } - template<typename F> size_t Vector(const char *key, F f) { - auto start = StartVector(key); - f(); - return EndVector(start, false, false); - } - template<typename T> void Vector(const T *elems, size_t len) { - if (std::is_scalar<T>::value) { - // This path should be a lot quicker and use less space. - ScalarVector(elems, len, false); - } else { - auto start = StartVector(); - for (size_t i = 0; i < len; i++) Add(elems[i]); - EndVector(start, false, false); - } - } - template<typename T> void Vector(const char *key, const T *elems, - size_t len) { - Key(key); - Vector(elems, len); - } - template<typename T> void Vector(const std::vector<T> &vec) { - Vector(vec.data(), vec.size()); - } - - template<typename F> size_t TypedVector(F f) { - auto start = StartVector(); - f(); - return EndVector(start, true, false); - } - template<typename F> size_t TypedVector(const char *key, F f) { - auto start = StartVector(key); - f(); - return EndVector(start, true, false); - } - - template<typename T> size_t FixedTypedVector(const T *elems, size_t len) { - // We only support a few fixed vector lengths. Anything bigger use a - // regular typed vector. - assert(len >= 2 && len <= 4); - // And only scalar values. - assert(std::is_scalar<T>::value); - return ScalarVector(elems, len, true); - } - - template<typename T> size_t FixedTypedVector(const char *key, const T *elems, - size_t len) { - Key(key); - return FixedTypedVector(elems, len); - } - - template<typename F> size_t Map(F f) { - auto start = StartMap(); - f(); - return EndMap(start); - } - template<typename F> size_t Map(const char *key, F f) { - auto start = StartMap(key); - f(); - return EndMap(start); - } - template<typename T> void Map(const std::map<std::string, T> &map) { - auto start = StartMap(); - for (auto it = map.begin(); it != map.end(); ++it) - Add(it->first.c_str(), it->second); - EndMap(start); - } - - // Overloaded Add that tries to call the correct function above. - void Add(int8_t i) { Int(i); } - void Add(int16_t i) { Int(i); } - void Add(int32_t i) { Int(i); } - void Add(int64_t i) { Int(i); } - void Add(uint8_t u) { UInt(u); } - void Add(uint16_t u) { UInt(u); } - void Add(uint32_t u) { UInt(u); } - void Add(uint64_t u) { UInt(u); } - void Add(float f) { Float(f); } - void Add(double d) { Double(d); } - void Add(bool b) { Bool(b); } - void Add(const char *str) { String(str); } - void Add(const std::string &str) { String(str); } - void Add(const flexbuffers::String &str) { String(str); } - - template<typename T> void Add(const std::vector<T> &vec) { - Vector(vec); - } - - template<typename T> void Add(const char *key, const T &t) { - Key(key); - Add(t); - } - - template<typename T> void Add(const std::map<std::string, T> &map) { - Map(map); - } - - template<typename T> void operator+=(const T &t) { - Add(t); - } - - // This function is useful in combination with the Mutate* functions above. - // It forces elements of vectors and maps to have a minimum size, such that - // they can later be updated without failing. - // Call with no arguments to reset. - void ForceMinimumBitWidth(BitWidth bw = BIT_WIDTH_8) { - force_min_bit_width_ = bw; - } - - void Finish() { - // If you hit this assert, you likely have objects that were never included - // in a parent. You need to have exactly one root to finish a buffer. - // Check your Start/End calls are matched, and all objects are inside - // some other object. - assert(stack_.size() == 1); - - // Write root value. - auto byte_width = Align(stack_[0].ElemWidth(buf_.size(), 0)); - WriteAny(stack_[0], byte_width); - // Write root type. - Write(stack_[0].StoredPackedType(), 1); - // Write root size. Normally determined by parent, but root has no parent :) - Write(byte_width, 1); - - finished_ = true; - } - - private: - void Finished() const { - // If you get this assert, you're attempting to get access a buffer - // which hasn't been finished yet. Be sure to call - // Builder::Finish with your root object. - assert(finished_); - } - - // Align to prepare for writing a scalar with a certain size. - uint8_t Align(BitWidth alignment) { - auto byte_width = 1U << alignment; - buf_.insert(buf_.end(), flatbuffers::PaddingBytes(buf_.size(), byte_width), - 0); - return static_cast<uint8_t>(byte_width); - } - - void WriteBytes(const void *val, size_t size) { - buf_.insert(buf_.end(), - reinterpret_cast<const uint8_t *>(val), - reinterpret_cast<const uint8_t *>(val) + size); - } - - template<typename T> void Write(T val, size_t byte_width) { - assert(sizeof(T) >= byte_width); - val = flatbuffers::EndianScalar(val); - WriteBytes(&val, byte_width); - } - - void WriteDouble(double f, uint8_t byte_width) { - switch (byte_width) { - case 8: Write(f, byte_width); break; - case 4: Write(static_cast<float>(f), byte_width); break; - //case 2: Write(static_cast<half>(f), byte_width); break; - //case 1: Write(static_cast<quarter>(f), byte_width); break; - default: assert(0); - } - } - - void WriteOffset(uint64_t o, uint8_t byte_width) { - auto reloff = buf_.size() - o; - assert(reloff < 1ULL << (byte_width * 8) || byte_width == 8); - Write(reloff, byte_width); - } - - template<typename T> void PushIndirect(T val, Type type, BitWidth bit_width) { - auto byte_width = Align(bit_width); - auto iloc = buf_.size(); - Write(val, byte_width); - stack_.push_back(Value(static_cast<uint64_t>(iloc), type, bit_width)); - } - - static BitWidth WidthB(size_t byte_width) { - switch (byte_width) { - case 1: return BIT_WIDTH_8; - case 2: return BIT_WIDTH_16; - case 4: return BIT_WIDTH_32; - case 8: return BIT_WIDTH_64; - default: assert(false); return BIT_WIDTH_64; - } - } - - template<typename T> static Type GetScalarType() { - assert(std::is_scalar<T>::value); - return std::is_floating_point<T>::value - ? TYPE_FLOAT - : (std::is_unsigned<T>::value ? TYPE_UINT : TYPE_INT); - } - - struct Value { - union { - int64_t i_; - uint64_t u_; - double f_; - }; - - Type type_; - - // For scalars: of itself, for vector: of its elements, for string: length. - BitWidth min_bit_width_; - - Value() : i_(0), type_(TYPE_NULL), min_bit_width_(BIT_WIDTH_8) {} - - Value(int64_t i, Type t, BitWidth bw) - : i_(i), type_(t), min_bit_width_(bw) {} - Value(uint64_t u, Type t, BitWidth bw) - : u_(u), type_(t), min_bit_width_(bw) {} - - Value(float f) - : f_(f), type_(TYPE_FLOAT), min_bit_width_(BIT_WIDTH_32) {} - Value(double f) - : f_(f), type_(TYPE_FLOAT), min_bit_width_(WidthF(f)) {} - - uint8_t StoredPackedType(BitWidth parent_bit_width_= BIT_WIDTH_8) const { - return PackedType(StoredWidth(parent_bit_width_), type_); - } - - BitWidth ElemWidth(size_t buf_size, size_t elem_index) const { - if (IsInline(type_)) { - return min_bit_width_; - } else { - // We have an absolute offset, but want to store a relative offset - // elem_index elements beyond the current buffer end. Since whether - // the relative offset fits in a certain byte_width depends on - // the size of the elements before it (and their alignment), we have - // to test for each size in turn. - for (size_t byte_width = 1; - byte_width <= sizeof(flatbuffers::largest_scalar_t); - byte_width *= 2) { - // Where are we going to write this offset? - auto offset_loc = - buf_size + - flatbuffers::PaddingBytes(buf_size, byte_width) + - elem_index * byte_width; - // Compute relative offset. - auto offset = offset_loc - u_; - // Does it fit? - auto bit_width = WidthU(offset); - if (static_cast<size_t>(static_cast<size_t>(1U) << bit_width) == byte_width) - return bit_width; - } - assert(false); // Must match one of the sizes above. - return BIT_WIDTH_64; - } - } - - BitWidth StoredWidth(BitWidth parent_bit_width_ = BIT_WIDTH_8) const { - if (IsInline(type_)) { - return std::max(min_bit_width_, parent_bit_width_); - } else { - return min_bit_width_; - } - } - }; - - void WriteAny(const Value &val, uint8_t byte_width) { - switch (val.type_) { - case TYPE_NULL: - case TYPE_INT: - Write(val.i_, byte_width); - break; - case TYPE_UINT: - Write(val.u_, byte_width); - break; - case TYPE_FLOAT: - WriteDouble(val.f_, byte_width); - break; - default: - WriteOffset(val.u_, byte_width); - break; - } - } - - size_t CreateBlob(const void *data, size_t len, size_t trailing, Type type) { - auto bit_width = WidthU(len); - auto byte_width = Align(bit_width); - Write<uint64_t>(len, byte_width); - auto sloc = buf_.size(); - WriteBytes(data, len + trailing); - stack_.push_back(Value(static_cast<uint64_t>(sloc), type, bit_width)); - return sloc; - } - - template<typename T> size_t ScalarVector(const T *elems, size_t len, - bool fixed) { - auto vector_type = GetScalarType<T>(); - auto byte_width = sizeof(T); - auto bit_width = WidthB(byte_width); - // If you get this assert, you're trying to write a vector with a size - // field that is bigger than the scalars you're trying to write (e.g. a - // byte vector > 255 elements). For such types, write a "blob" instead. - // TODO: instead of asserting, could write vector with larger elements - // instead, though that would be wasteful. - assert(WidthU(len) <= bit_width); - if (!fixed) Write<uint64_t>(len, byte_width); - auto vloc = buf_.size(); - for (size_t i = 0; i < len; i++) Write(elems[i], byte_width); - stack_.push_back(Value(static_cast<uint64_t>(vloc), - ToTypedVector(vector_type, fixed ? len : 0), - bit_width)); - return vloc; - } - - Value CreateVector(size_t start, size_t vec_len, size_t step, bool typed, - bool fixed, const Value *keys = nullptr) { - // Figure out smallest bit width we can store this vector with. - auto bit_width = std::max(force_min_bit_width_, WidthU(vec_len)); - auto prefix_elems = 1; - if (keys) { - // If this vector is part of a map, we will pre-fix an offset to the keys - // to this vector. - bit_width = std::max(bit_width, keys->ElemWidth(buf_.size(), 0)); - prefix_elems += 2; - } - Type vector_type = TYPE_KEY; - // Check bit widths and types for all elements. - for (size_t i = start; i < stack_.size(); i += step) { - auto elem_width = stack_[i].ElemWidth(buf_.size(), i + prefix_elems); - bit_width = std::max(bit_width, elem_width); - if (typed) { - if (i == start) { - vector_type = stack_[i].type_; - } else { - // If you get this assert, you are writing a typed vector with - // elements that are not all the same type. - assert(vector_type == stack_[i].type_); - } - } - } - // If you get this assert, your fixed types are not one of: - // Int / UInt / Float / Key. - assert(IsTypedVectorElementType(vector_type)); - auto byte_width = Align(bit_width); - // Write vector. First the keys width/offset if available, and size. - if (keys) { - WriteOffset(keys->u_, byte_width); - Write<uint64_t>(1U << keys->min_bit_width_, byte_width); - } - if (!fixed) Write<uint64_t>(vec_len, byte_width); - // Then the actual data. - auto vloc = buf_.size(); - for (size_t i = start; i < stack_.size(); i += step) { - WriteAny(stack_[i], byte_width); - } - // Then the types. - if (!typed) { - for (size_t i = start; i < stack_.size(); i += step) { - buf_.push_back(stack_[i].StoredPackedType(bit_width)); - } - } - return Value(static_cast<uint64_t>(vloc), keys - ? TYPE_MAP - : (typed - ? ToTypedVector(vector_type, fixed ? vec_len : 0) - : TYPE_VECTOR), - bit_width); - } - - // You shouldn't really be copying instances of this class. - Builder(const Builder &); - Builder &operator=(const Builder &); - - std::vector<uint8_t> buf_; - std::vector<Value> stack_; - - bool finished_; - - BuilderFlag flags_; - - BitWidth force_min_bit_width_; - - struct KeyOffsetCompare { - KeyOffsetCompare(const std::vector<uint8_t> &buf) : buf_(&buf) {} - bool operator() (size_t a, size_t b) const { - auto stra = reinterpret_cast<const char *>(buf_->data() + a); - auto strb = reinterpret_cast<const char *>(buf_->data() + b); - return strcmp(stra, strb) < 0; - } - const std::vector<uint8_t> *buf_; - }; - - typedef std::pair<size_t, size_t> StringOffset; - struct StringOffsetCompare { - StringOffsetCompare(const std::vector<uint8_t> &buf) : buf_(&buf) {} - bool operator() (const StringOffset &a, const StringOffset &b) const { - auto stra = reinterpret_cast<const char *>(buf_->data() + a.first); - auto strb = reinterpret_cast<const char *>(buf_->data() + b.first); - return strncmp(stra, strb, std::min(a.second, b.second) + 1) < 0; - } - const std::vector<uint8_t> *buf_; - }; - - typedef std::set<size_t, KeyOffsetCompare> KeyOffsetMap; - typedef std::set<StringOffset, StringOffsetCompare> StringOffsetMap; - - KeyOffsetMap key_pool; - StringOffsetMap string_pool; -}; - -} // namespace flexbuffers - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif // FLATBUFFERS_FLEXBUFFERS_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/grpc.h b/third_party/flatbuffers/include/flatbuffers/grpc.h deleted file mode 100644 index 48ff3c8..0000000 --- a/third_party/flatbuffers/include/flatbuffers/grpc.h +++ /dev/null
@@ -1,70 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_GRPC_H_ -#define FLATBUFFERS_GRPC_H_ - -// Helper functionality to glue FlatBuffers and GRPC. - -#include "grpc++/support/byte_buffer.h" -#include "grpc/byte_buffer_reader.h" - -namespace grpc { - -template <class T> -class SerializationTraits<T, typename std::enable_if<std::is_base_of< - flatbuffers::BufferRefBase, T>::value>::type> { - public: - // The type we're passing here is a BufferRef, which is already serialized - // FlatBuffer data, which then gets passed to GRPC. - static grpc::Status Serialize(const T& msg, - grpc_byte_buffer **buffer, - bool *own_buffer) { - // TODO(wvo): make this work without copying. - auto slice = gpr_slice_from_copied_buffer( - reinterpret_cast<const char *>(msg.buf), msg.len); - *buffer = grpc_raw_byte_buffer_create(&slice, 1); - *own_buffer = true; - return grpc::Status(); - } - - // There is no de-serialization step in FlatBuffers, so we just receive - // the data from GRPC. - static grpc::Status Deserialize(grpc_byte_buffer *buffer, T *msg) { - // TODO(wvo): make this more efficient / zero copy when possible. - auto len = grpc_byte_buffer_length(buffer); - msg->buf = reinterpret_cast<uint8_t *>(malloc(len)); - msg->len = static_cast<flatbuffers::uoffset_t>(len); - msg->must_free = true; - uint8_t *current = msg->buf; - grpc_byte_buffer_reader reader; - grpc_byte_buffer_reader_init(&reader, buffer); - gpr_slice slice; - while (grpc_byte_buffer_reader_next(&reader, &slice)) { - memcpy(current, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice)); - current += GPR_SLICE_LENGTH(slice); - gpr_slice_unref(slice); - } - GPR_ASSERT(current == msg->buf + msg->len); - grpc_byte_buffer_reader_destroy(&reader); - grpc_byte_buffer_destroy(buffer); - return grpc::Status(); - } -}; - -} // namespace grpc; - -#endif // FLATBUFFERS_GRPC_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/hash.h b/third_party/flatbuffers/include/flatbuffers/hash.h deleted file mode 100644 index 9ae37e5..0000000 --- a/third_party/flatbuffers/include/flatbuffers/hash.h +++ /dev/null
@@ -1,107 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_HASH_H_ -#define FLATBUFFERS_HASH_H_ - -#include <cstdint> -#include <cstring> - -#include "flatbuffers/flatbuffers.h" - -namespace flatbuffers { - -template <typename T> -struct FnvTraits { - static const T kFnvPrime; - static const T kOffsetBasis; -}; - -template <> -struct FnvTraits<uint32_t> { - static const uint32_t kFnvPrime = 0x01000193; - static const uint32_t kOffsetBasis = 0x811C9DC5; -}; - -template <> -struct FnvTraits<uint64_t> { - static const uint64_t kFnvPrime = 0x00000100000001b3ULL; - static const uint64_t kOffsetBasis = 0xcbf29ce484222645ULL; -}; - -template <typename T> -T HashFnv1(const char *input) { - T hash = FnvTraits<T>::kOffsetBasis; - for (const char *c = input; *c; ++c) { - hash *= FnvTraits<T>::kFnvPrime; - hash ^= static_cast<unsigned char>(*c); - } - return hash; -} - -template <typename T> -T HashFnv1a(const char *input) { - T hash = FnvTraits<T>::kOffsetBasis; - for (const char *c = input; *c; ++c) { - hash ^= static_cast<unsigned char>(*c); - hash *= FnvTraits<T>::kFnvPrime; - } - return hash; -} - -template <typename T> -struct NamedHashFunction { - const char *name; - - typedef T (*HashFunction)(const char*); - HashFunction function; -}; - -const NamedHashFunction<uint32_t> kHashFunctions32[] = { - { "fnv1_32", HashFnv1<uint32_t> }, - { "fnv1a_32", HashFnv1a<uint32_t> }, -}; - -const NamedHashFunction<uint64_t> kHashFunctions64[] = { - { "fnv1_64", HashFnv1<uint64_t> }, - { "fnv1a_64", HashFnv1a<uint64_t> }, -}; - -inline NamedHashFunction<uint32_t>::HashFunction FindHashFunction32( - const char *name) { - std::size_t size = sizeof(kHashFunctions32) / sizeof(kHashFunctions32[0]); - for (std::size_t i = 0; i < size; ++i) { - if (std::strcmp(name, kHashFunctions32[i].name) == 0) { - return kHashFunctions32[i].function; - } - } - return nullptr; -} - -inline NamedHashFunction<uint64_t>::HashFunction FindHashFunction64( - const char *name) { - std::size_t size = sizeof(kHashFunctions64) / sizeof(kHashFunctions64[0]); - for (std::size_t i = 0; i < size; ++i) { - if (std::strcmp(name, kHashFunctions64[i].name) == 0) { - return kHashFunctions64[i].function; - } - } - return nullptr; -} - -} // namespace flatbuffers - -#endif // FLATBUFFERS_HASH_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/idl.h b/third_party/flatbuffers/include/flatbuffers/idl.h deleted file mode 100644 index 94de836..0000000 --- a/third_party/flatbuffers/include/flatbuffers/idl.h +++ /dev/null
@@ -1,755 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_IDL_H_ -#define FLATBUFFERS_IDL_H_ - -#include <map> -#include <stack> -#include <memory> -#include <functional> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/hash.h" -#include "flatbuffers/reflection.h" - -// This file defines the data types representing a parsed IDL (Interface -// Definition Language) / schema file. - -namespace flatbuffers { - -// The order of these matters for Is*() functions below. -// Additionally, Parser::ParseType assumes bool..string is a contiguous range -// of type tokens. -#define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \ - TD(NONE, "", uint8_t, byte, byte, byte, uint8) \ - TD(UTYPE, "", uint8_t, byte, byte, byte, uint8) /* begin scalar/int */ \ - TD(BOOL, "bool", uint8_t, boolean,byte, bool, bool) \ - TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8) \ - TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8) \ - TD(SHORT, "short", int16_t, short, int16, short, int16) \ - TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16) \ - TD(INT, "int", int32_t, int, int32, int, int32) \ - TD(UINT, "uint", uint32_t, int, uint32, uint, uint32) \ - TD(LONG, "long", int64_t, long, int64, long, int64) \ - TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64) /* end int */ \ - TD(FLOAT, "float", float, float, float32, float, float32) /* begin float */ \ - TD(DOUBLE, "double", double, double, float64, double, float64) /* end float/scalar */ -#define FLATBUFFERS_GEN_TYPES_POINTER(TD) \ - TD(STRING, "string", Offset<void>, int, int, StringOffset, int) \ - TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int) \ - TD(STRUCT, "", Offset<void>, int, int, int, int) \ - TD(UNION, "", Offset<void>, int, int, int, int) - -// The fields are: -// - enum -// - FlatBuffers schema type. -// - C++ type. -// - Java type. -// - Go type. -// - C# / .Net type. -// - Python type. - -// using these macros, we can now write code dealing with types just once, e.g. - -/* -switch (type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - // do something specific to CTYPE here - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD -} -*/ - -#define FLATBUFFERS_GEN_TYPES(TD) \ - FLATBUFFERS_GEN_TYPES_SCALAR(TD) \ - FLATBUFFERS_GEN_TYPES_POINTER(TD) - -// Create an enum for all the types above. -#ifdef __GNUC__ -__extension__ // Stop GCC complaining about trailing comma with -Wpendantic. -#endif -enum BaseType { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - BASE_TYPE_ ## ENUM, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD -}; - -#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - static_assert(sizeof(CTYPE) <= sizeof(largest_scalar_t), \ - "define largest_scalar_t as " #CTYPE); - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) -#undef FLATBUFFERS_TD - -inline bool IsScalar (BaseType t) { return t >= BASE_TYPE_UTYPE && - t <= BASE_TYPE_DOUBLE; } -inline bool IsInteger(BaseType t) { return t >= BASE_TYPE_UTYPE && - t <= BASE_TYPE_ULONG; } -inline bool IsFloat (BaseType t) { return t == BASE_TYPE_FLOAT || - t == BASE_TYPE_DOUBLE; } -inline bool IsLong (BaseType t) { return t == BASE_TYPE_LONG || - t == BASE_TYPE_ULONG; } - -extern const char *const kTypeNames[]; -extern const char kTypeSizes[]; - -inline size_t SizeOf(BaseType t) { - return kTypeSizes[t]; -} - -struct StructDef; -struct EnumDef; -class Parser; - -// Represents any type in the IDL, which is a combination of the BaseType -// and additional information for vectors/structs_. -struct Type { - explicit Type(BaseType _base_type = BASE_TYPE_NONE, - StructDef *_sd = nullptr, EnumDef *_ed = nullptr) - : base_type(_base_type), - element(BASE_TYPE_NONE), - struct_def(_sd), - enum_def(_ed) - {} - - bool operator==(const Type &o) { - return base_type == o.base_type && element == o.element && - struct_def == o.struct_def && enum_def == o.enum_def; - } - - Type VectorType() const { return Type(element, struct_def, enum_def); } - - Offset<reflection::Type> Serialize(FlatBufferBuilder *builder) const; - - BaseType base_type; - BaseType element; // only set if t == BASE_TYPE_VECTOR - StructDef *struct_def; // only set if t or element == BASE_TYPE_STRUCT - EnumDef *enum_def; // set if t == BASE_TYPE_UNION / BASE_TYPE_UTYPE, - // or for an integral type derived from an enum. -}; - -// Represents a parsed scalar value, it's type, and field offset. -struct Value { - Value() : constant("0"), offset(static_cast<voffset_t>( - ~(static_cast<voffset_t>(0U)))) {} - Type type; - std::string constant; - voffset_t offset; -}; - -// Helper class that retains the original order of a set of identifiers and -// also provides quick lookup. -template<typename T> class SymbolTable { - public: - ~SymbolTable() { - for (auto it = vec.begin(); it != vec.end(); ++it) { - delete *it; - } - } - - bool Add(const std::string &name, T *e) { - vec.emplace_back(e); - auto it = dict.find(name); - if (it != dict.end()) return true; - dict[name] = e; - return false; - } - - void Move(const std::string &oldname, const std::string &newname) { - auto it = dict.find(oldname); - if (it != dict.end()) { - auto obj = it->second; - dict.erase(it); - dict[newname] = obj; - } else { - assert(false); - } - } - - T *Lookup(const std::string &name) const { - auto it = dict.find(name); - return it == dict.end() ? nullptr : it->second; - } - - public: - std::map<std::string, T *> dict; // quick lookup - std::vector<T *> vec; // Used to iterate in order of insertion -}; - -// A name space, as set in the schema. -struct Namespace { - std::vector<std::string> components; - - // Given a (potentally unqualified) name, return the "fully qualified" name - // which has a full namespaced descriptor. - // With max_components you can request less than the number of components - // the current namespace has. - std::string GetFullyQualifiedName(const std::string &name, - size_t max_components = 1000) const; -}; - -// Base class for all definition types (fields, structs_, enums_). -struct Definition { - Definition() : generated(false), defined_namespace(nullptr), - serialized_location(0), index(-1) {} - - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset< - reflection::KeyValue>>> - SerializeAttributes(FlatBufferBuilder *builder, - const Parser &parser) const; - - std::string name; - std::string file; - std::vector<std::string> doc_comment; - SymbolTable<Value> attributes; - bool generated; // did we already output code for this definition? - Namespace *defined_namespace; // Where it was defined. - - // For use with Serialize() - uoffset_t serialized_location; - int index; // Inside the vector it is stored. -}; - -struct FieldDef : public Definition { - FieldDef() : deprecated(false), required(false), key(false), padding(0) {} - - Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id, - const Parser &parser) const; - - Value value; - bool deprecated; // Field is allowed to be present in old data, but can't be - // written in new data nor accessed in new code. - bool required; // Field must always be present. - bool key; // Field functions as a key for creating sorted vectors. - bool native_inline; // Field will be defined inline (instead of as a pointer) - // for native tables if field is a struct. - size_t padding; // Bytes to always pad after this field. -}; - -struct StructDef : public Definition { - StructDef() - : fixed(false), - predecl(true), - sortbysize(true), - has_key(false), - minalign(1), - bytesize(0) - {} - - void PadLastField(size_t min_align) { - auto padding = PaddingBytes(bytesize, min_align); - bytesize += padding; - if (fields.vec.size()) fields.vec.back()->padding = padding; - } - - Offset<reflection::Object> Serialize(FlatBufferBuilder *builder, - const Parser &parser) const; - - SymbolTable<FieldDef> fields; - bool fixed; // If it's struct, not a table. - bool predecl; // If it's used before it was defined. - bool sortbysize; // Whether fields come in the declaration or size order. - bool has_key; // It has a key field. - size_t minalign; // What the whole object needs to be aligned to. - size_t bytesize; // Size if fixed. -}; - -inline bool IsStruct(const Type &type) { - return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed; -} - -inline size_t InlineSize(const Type &type) { - return IsStruct(type) ? type.struct_def->bytesize : SizeOf(type.base_type); -} - -inline size_t InlineAlignment(const Type &type) { - return IsStruct(type) ? type.struct_def->minalign : SizeOf(type.base_type); -} - -struct EnumVal { - EnumVal(const std::string &_name, int64_t _val) - : name(_name), value(_val) {} - - Offset<reflection::EnumVal> Serialize(FlatBufferBuilder *builder) const; - - std::string name; - std::vector<std::string> doc_comment; - int64_t value; - Type union_type; -}; - -struct EnumDef : public Definition { - EnumDef() : is_union(false), uses_type_aliases(false) {} - - EnumVal *ReverseLookup(int enum_idx, bool skip_union_default = true) { - for (auto it = vals.vec.begin() + static_cast<int>(is_union && - skip_union_default); - it != vals.vec.end(); ++it) { - if ((*it)->value == enum_idx) { - return *it; - } - } - return nullptr; - } - - Offset<reflection::Enum> Serialize(FlatBufferBuilder *builder, - const Parser &parser) const; - - SymbolTable<EnumVal> vals; - bool is_union; - bool uses_type_aliases; - Type underlying_type; -}; - -inline bool EqualByName(const Type &a, const Type &b) { - return a.base_type == b.base_type && a.element == b.element && - (a.struct_def == b.struct_def || - a.struct_def->name == b.struct_def->name) && - (a.enum_def == b.enum_def || - a.enum_def->name == b.enum_def->name); -} - -struct RPCCall { - std::string name; - SymbolTable<Value> attributes; - StructDef *request, *response; -}; - -struct ServiceDef : public Definition { - SymbolTable<RPCCall> calls; -}; - -// Container of options that may apply to any of the source/text generators. -struct IDLOptions { - bool strict_json; - bool skip_js_exports; - bool use_goog_js_export_format; - bool output_default_scalars_in_json; - int indent_step; - bool output_enum_identifiers; - bool prefixed_enums; - bool scoped_enums; - bool include_dependence_headers; - bool mutable_buffer; - bool one_file; - bool proto_mode; - bool generate_all; - bool skip_unexpected_fields_in_json; - bool generate_name_strings; - bool escape_proto_identifiers; - bool generate_object_based_api; - std::string cpp_object_api_pointer_type; - std::string cpp_object_api_string_type; - bool union_value_namespacing; - bool allow_non_utf8; - std::string include_prefix; - bool binary_schema_comments; - bool skip_flatbuffers_import; - std::string go_namespace; - bool reexport_ts_modules; - - // Possible options for the more general generator below. - enum Language { - kJava = 1 << 0, - kCSharp = 1 << 1, - kGo = 1 << 2, - kCpp = 1 << 3, - kJs = 1 << 4, - kPython = 1 << 5, - kPhp = 1 << 6, - kJson = 1 << 7, - kBinary = 1 << 8, - kTs = 1 << 9, - kMAX - }; - - Language lang; - - // The corresponding language bit will be set if a language is included - // for code generation. - unsigned long lang_to_generate; - - IDLOptions() - : strict_json(false), - skip_js_exports(false), - use_goog_js_export_format(false), - output_default_scalars_in_json(false), - indent_step(2), - output_enum_identifiers(true), prefixed_enums(true), scoped_enums(false), - include_dependence_headers(true), - mutable_buffer(false), - one_file(false), - proto_mode(false), - generate_all(false), - skip_unexpected_fields_in_json(false), - generate_name_strings(false), - escape_proto_identifiers(false), - generate_object_based_api(false), - cpp_object_api_pointer_type("std::unique_ptr"), - union_value_namespacing(true), - allow_non_utf8(false), - binary_schema_comments(false), - skip_flatbuffers_import(false), - reexport_ts_modules(true), - lang(IDLOptions::kJava), - lang_to_generate(0) {} -}; - -// This encapsulates where the parser is in the current source file. -struct ParserState { - ParserState() : cursor_(nullptr), line_(1), token_(-1) {} - - protected: - const char *cursor_; - int line_; // the current line being parsed - int token_; - - std::string attribute_; - std::vector<std::string> doc_comment_; -}; - -// A way to make error propagation less error prone by requiring values to be -// checked. -// Once you create a value of this type you must either: -// - Call Check() on it. -// - Copy or assign it to another value. -// Failure to do so leads to an assert. -// This guarantees that this as return value cannot be ignored. -class CheckedError { - public: - explicit CheckedError(bool error) - : is_error_(error), has_been_checked_(false) {} - - CheckedError &operator=(const CheckedError &other) { - is_error_ = other.is_error_; - has_been_checked_ = false; - other.has_been_checked_ = true; - return *this; - } - - CheckedError(const CheckedError &other) { - *this = other; // Use assignment operator. - } - - ~CheckedError() { assert(has_been_checked_); } - - bool Check() { has_been_checked_ = true; return is_error_; } - - private: - bool is_error_; - mutable bool has_been_checked_; -}; - -// Additionally, in GCC we can get these errors statically, for additional -// assurance: -#ifdef __GNUC__ -#define FLATBUFFERS_CHECKED_ERROR CheckedError \ - __attribute__((warn_unused_result)) -#else -#define FLATBUFFERS_CHECKED_ERROR CheckedError -#endif - -class Parser : public ParserState { - public: - explicit Parser(const IDLOptions &options = IDLOptions()) - : root_struct_def_(nullptr), - opts(options), - source_(nullptr), - anonymous_counter(0) { - // Just in case none are declared: - namespaces_.push_back(new Namespace()); - known_attributes_["deprecated"] = true; - known_attributes_["required"] = true; - known_attributes_["key"] = true; - known_attributes_["hash"] = true; - known_attributes_["id"] = true; - known_attributes_["force_align"] = true; - known_attributes_["bit_flags"] = true; - known_attributes_["original_order"] = true; - known_attributes_["nested_flatbuffer"] = true; - known_attributes_["csharp_partial"] = true; - known_attributes_["streaming"] = true; - known_attributes_["idempotent"] = true; - known_attributes_["cpp_type"] = true; - known_attributes_["cpp_ptr_type"] = true; - known_attributes_["cpp_str_type"] = true; - known_attributes_["native_inline"] = true; - known_attributes_["native_type"] = true; - known_attributes_["native_default"] = true; - } - - ~Parser() { - for (auto it = namespaces_.begin(); it != namespaces_.end(); ++it) { - delete *it; - } - } - - // Parse the string containing either schema or JSON data, which will - // populate the SymbolTable's or the FlatBufferBuilder above. - // include_paths is used to resolve any include statements, and typically - // should at least include the project path (where you loaded source_ from). - // include_paths must be nullptr terminated if specified. - // If include_paths is nullptr, it will attempt to load from the current - // directory. - // If the source was loaded from a file and isn't an include file, - // supply its name in source_filename. - bool Parse(const char *_source, const char **include_paths = nullptr, - const char *source_filename = nullptr); - - // Set the root type. May override the one set in the schema. - bool SetRootType(const char *name); - - // Mark all definitions as already having code generated. - void MarkGenerated(); - - // Get the files recursively included by the given file. The returned - // container will have at least the given file. - std::set<std::string> GetIncludedFilesRecursive( - const std::string &file_name) const; - - // Fills builder_ with a binary version of the schema parsed. - // See reflection/reflection.fbs - void Serialize(); - - // Checks that the schema represented by this parser is a safe evolution - // of the schema provided. Returns non-empty error on any problems. - std::string ConformTo(const Parser &base); - - FLATBUFFERS_CHECKED_ERROR CheckInRange(int64_t val, int64_t min, int64_t max); - -private: - FLATBUFFERS_CHECKED_ERROR Error(const std::string &msg); - FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val); - FLATBUFFERS_CHECKED_ERROR Next(); - FLATBUFFERS_CHECKED_ERROR SkipByteOrderMark(); - bool Is(int t); - FLATBUFFERS_CHECKED_ERROR Expect(int t); - std::string TokenToStringId(int t); - EnumDef *LookupEnum(const std::string &id); - FLATBUFFERS_CHECKED_ERROR ParseNamespacing(std::string *id, - std::string *last); - FLATBUFFERS_CHECKED_ERROR ParseTypeIdent(Type &type); - FLATBUFFERS_CHECKED_ERROR ParseType(Type &type); - FLATBUFFERS_CHECKED_ERROR AddField(StructDef &struct_def, - const std::string &name, const Type &type, - FieldDef **dest); - FLATBUFFERS_CHECKED_ERROR ParseField(StructDef &struct_def); - FLATBUFFERS_CHECKED_ERROR ParseString(Value &val); - FLATBUFFERS_CHECKED_ERROR ParseAnyValue(Value &val, FieldDef *field, - size_t parent_fieldn, - const StructDef *parent_struct_def); - FLATBUFFERS_CHECKED_ERROR ParseTable(const StructDef &struct_def, - std::string *value, uoffset_t *ovalue); - void SerializeStruct(const StructDef &struct_def, const Value &val); - void AddVector(bool sortbysize, int count); - FLATBUFFERS_CHECKED_ERROR ParseVector(const Type &type, uoffset_t *ovalue); - FLATBUFFERS_CHECKED_ERROR ParseMetaData(SymbolTable<Value> *attributes); - FLATBUFFERS_CHECKED_ERROR TryTypedValue(int dtoken, bool check, Value &e, - BaseType req, bool *destmatch); - FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef* field); - FLATBUFFERS_CHECKED_ERROR ParseSingleValue(Value &e); - FLATBUFFERS_CHECKED_ERROR ParseEnumFromString(Type &type, int64_t *result); - StructDef *LookupCreateStruct(const std::string &name, - bool create_if_new = true, - bool definition = false); - FLATBUFFERS_CHECKED_ERROR ParseEnum(bool is_union, EnumDef **dest); - FLATBUFFERS_CHECKED_ERROR ParseNamespace(); - FLATBUFFERS_CHECKED_ERROR StartStruct(const std::string &name, - StructDef **dest); - FLATBUFFERS_CHECKED_ERROR ParseDecl(); - FLATBUFFERS_CHECKED_ERROR ParseService(); - FLATBUFFERS_CHECKED_ERROR ParseProtoFields(StructDef *struct_def, - bool isextend, bool inside_oneof); - FLATBUFFERS_CHECKED_ERROR ParseProtoOption(); - FLATBUFFERS_CHECKED_ERROR ParseProtoKey(); - FLATBUFFERS_CHECKED_ERROR ParseProtoDecl(); - FLATBUFFERS_CHECKED_ERROR ParseProtoCurliesOrIdent(); - FLATBUFFERS_CHECKED_ERROR ParseTypeFromProtoType(Type *type); - FLATBUFFERS_CHECKED_ERROR SkipAnyJsonValue(); - FLATBUFFERS_CHECKED_ERROR SkipJsonObject(); - FLATBUFFERS_CHECKED_ERROR SkipJsonArray(); - FLATBUFFERS_CHECKED_ERROR SkipJsonString(); - FLATBUFFERS_CHECKED_ERROR DoParse(const char *_source, - const char **include_paths, - const char *source_filename); - FLATBUFFERS_CHECKED_ERROR CheckClash(std::vector<FieldDef*> &fields, - StructDef *struct_def, - const char *suffix, - BaseType baseType); - - public: - SymbolTable<Type> types_; - SymbolTable<StructDef> structs_; - SymbolTable<EnumDef> enums_; - SymbolTable<ServiceDef> services_; - std::vector<Namespace *> namespaces_; - std::string error_; // User readable error_ if Parse() == false - - FlatBufferBuilder builder_; // any data contained in the file - StructDef *root_struct_def_; - std::string file_identifier_; - std::string file_extension_; - - std::map<std::string, bool> included_files_; - std::map<std::string, std::set<std::string>> files_included_per_file_; - std::vector<std::string> native_included_files_; - - std::map<std::string, bool> known_attributes_; - - IDLOptions opts; - - private: - const char *source_; - - std::string file_being_parsed_; - - std::vector<std::pair<Value, FieldDef *>> field_stack_; - - int anonymous_counter; -}; - -// Utility functions for multiple generators: - -extern std::string MakeCamel(const std::string &in, bool first = true); - -// Generate text (JSON) from a given FlatBuffer, and a given Parser -// object that has been populated with the corresponding schema. -// If ident_step is 0, no indentation will be generated. Additionally, -// if it is less than 0, no linefeeds will be generated either. -// See idl_gen_text.cpp. -// strict_json adds "quotes" around field names if true. -// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8 -// byte arrays in String values), returns false. -extern bool GenerateText(const Parser &parser, - const void *flatbuffer, - std::string *text); -extern bool GenerateTextFile(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate binary files from a given FlatBuffer, and a given Parser -// object that has been populated with the corresponding schema. -// See idl_gen_general.cpp. -extern bool GenerateBinary(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a C++ header from the definitions in the Parser object. -// See idl_gen_cpp. -extern std::string GenerateCPP(const Parser &parser, - const std::string &include_guard_ident); -extern bool GenerateCPP(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate JavaScript or TypeScript code from the definitions in the Parser object. -// See idl_gen_js. -extern std::string GenerateJS(const Parser &parser); -extern bool GenerateJS(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate Go files from the definitions in the Parser object. -// See idl_gen_go.cpp. -extern bool GenerateGo(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate Java files from the definitions in the Parser object. -// See idl_gen_java.cpp. -extern bool GenerateJava(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate Php code from the definitions in the Parser object. -// See idl_gen_php. -extern bool GeneratePhp(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate Python files from the definitions in the Parser object. -// See idl_gen_python.cpp. -extern bool GeneratePython(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate C# files from the definitions in the Parser object. -// See idl_gen_csharp.cpp. -extern bool GenerateCSharp(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate Java/C#/.. files from the definitions in the Parser object. -// See idl_gen_general.cpp. -extern bool GenerateGeneral(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a schema file from the internal representation, useful after -// parsing a .proto schema. -extern std::string GenerateFBS(const Parser &parser, - const std::string &file_name); -extern bool GenerateFBS(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a make rule for the generated JavaScript or TypeScript code. -// See idl_gen_js.cpp. -extern std::string JSMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a make rule for the generated C++ header. -// See idl_gen_cpp.cpp. -extern std::string CPPMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a make rule for the generated Java/C#/... files. -// See idl_gen_general.cpp. -extern std::string GeneralMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate a make rule for the generated text (JSON) files. -// See idl_gen_text.cpp. -extern std::string TextMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_names); - -// Generate a make rule for the generated binary files. -// See idl_gen_general.cpp. -extern std::string BinaryMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate GRPC Cpp interfaces. -// See idl_gen_grpc.cpp. -bool GenerateCppGRPC(const Parser &parser, - const std::string &path, - const std::string &file_name); - -// Generate GRPC Go interfaces. -// See idl_gen_grpc.cpp. -bool GenerateGoGRPC(const Parser &parser, - const std::string &path, - const std::string &file_name); - -} // namespace flatbuffers - -#endif // FLATBUFFERS_IDL_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/reflection.h b/third_party/flatbuffers/include/flatbuffers/reflection.h deleted file mode 100644 index aab9f20..0000000 --- a/third_party/flatbuffers/include/flatbuffers/reflection.h +++ /dev/null
@@ -1,490 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_REFLECTION_H_ -#define FLATBUFFERS_REFLECTION_H_ - -// This is somewhat of a circular dependency because flatc (and thus this -// file) is needed to generate this header in the first place. -// Should normally not be a problem since it can be generated by the -// previous version of flatc whenever this code needs to change. -// See reflection/generate_code.sh -#include "flatbuffers/reflection_generated.h" - -// Helper functionality for reflection. - -namespace flatbuffers { - -// ------------------------- GETTERS ------------------------- - -inline bool IsScalar (reflection::BaseType t) { return t >= reflection::UType && - t <= reflection::Double; } -inline bool IsInteger(reflection::BaseType t) { return t >= reflection::UType && - t <= reflection::ULong; } -inline bool IsFloat (reflection::BaseType t) { return t == reflection::Float || - t == reflection::Double; } -inline bool IsLong (reflection::BaseType t) { return t == reflection::Long || - t == reflection::ULong; } - -// Size of a basic type, don't use with structs. -inline size_t GetTypeSize(reflection::BaseType base_type) { - // This needs to correspond to the BaseType enum. - static size_t sizes[] = { 0, 1, 1, 1, 1, 2, 2, 4, 4, 8, 8, 4, 8, 4, 4, 4, 4 }; - return sizes[base_type]; -} - -// Same as above, but now correctly returns the size of a struct if -// the field (or vector element) is a struct. -inline size_t GetTypeSizeInline(reflection::BaseType base_type, - int type_index, - const reflection::Schema &schema) { - if (base_type == reflection::Obj && - schema.objects()->Get(type_index)->is_struct()) { - return schema.objects()->Get(type_index)->bytesize(); - } else { - return GetTypeSize(base_type); - } -} - -// Get the root, regardless of what type it is. -inline Table *GetAnyRoot(uint8_t *flatbuf) { - return GetMutableRoot<Table>(flatbuf); -} -inline const Table *GetAnyRoot(const uint8_t *flatbuf) { - return GetRoot<Table>(flatbuf); -} - -// Get a field's default, if you know it's an integer, and its exact type. -template<typename T> T GetFieldDefaultI(const reflection::Field &field) { - assert(sizeof(T) == GetTypeSize(field.type()->base_type())); - return static_cast<T>(field.default_integer()); -} - -// Get a field's default, if you know it's floating point and its exact type. -template<typename T> T GetFieldDefaultF(const reflection::Field &field) { - assert(sizeof(T) == GetTypeSize(field.type()->base_type())); - return static_cast<T>(field.default_real()); -} - -// Get a field, if you know it's an integer, and its exact type. -template<typename T> T GetFieldI(const Table &table, - const reflection::Field &field) { - assert(sizeof(T) == GetTypeSize(field.type()->base_type())); - return table.GetField<T>(field.offset(), - static_cast<T>(field.default_integer())); -} - -// Get a field, if you know it's floating point and its exact type. -template<typename T> T GetFieldF(const Table &table, - const reflection::Field &field) { - assert(sizeof(T) == GetTypeSize(field.type()->base_type())); - return table.GetField<T>(field.offset(), - static_cast<T>(field.default_real())); -} - -// Get a field, if you know it's a string. -inline const String *GetFieldS(const Table &table, - const reflection::Field &field) { - assert(field.type()->base_type() == reflection::String); - return table.GetPointer<const String *>(field.offset()); -} - -// Get a field, if you know it's a vector. -template<typename T> Vector<T> *GetFieldV(const Table &table, - const reflection::Field &field) { - assert(field.type()->base_type() == reflection::Vector && - sizeof(T) == GetTypeSize(field.type()->element())); - return table.GetPointer<Vector<T> *>(field.offset()); -} - -// Get a field, if you know it's a vector, generically. -// To actually access elements, use the return value together with -// field.type()->element() in any of GetAnyVectorElemI below etc. -inline VectorOfAny *GetFieldAnyV(const Table &table, - const reflection::Field &field) { - return table.GetPointer<VectorOfAny *>(field.offset()); -} - -// Get a field, if you know it's a table. -inline Table *GetFieldT(const Table &table, - const reflection::Field &field) { - assert(field.type()->base_type() == reflection::Obj || - field.type()->base_type() == reflection::Union); - return table.GetPointer<Table *>(field.offset()); -} - -// Get a field, if you know it's a struct. -inline const Struct *GetFieldStruct(const Table &table, - const reflection::Field &field) { - // TODO: This does NOT check if the field is a table or struct, but we'd need - // access to the schema to check the is_struct flag. - assert(field.type()->base_type() == reflection::Obj); - return table.GetStruct<const Struct *>(field.offset()); -} - -// Get a structure's field, if you know it's a struct. -inline const Struct *GetFieldStruct(const Struct &structure, - const reflection::Field &field) { - assert(field.type()->base_type() == reflection::Obj); - return structure.GetStruct<const Struct *>(field.offset()); -} - -// Raw helper functions used below: get any value in memory as a 64bit int, a -// double or a string. -// All scalars get static_cast to an int64_t, strings use strtoull, every other -// data type returns 0. -int64_t GetAnyValueI(reflection::BaseType type, const uint8_t *data); -// All scalars static cast to double, strings use strtod, every other data -// type is 0.0. -double GetAnyValueF(reflection::BaseType type, const uint8_t *data); -// All scalars converted using stringstream, strings as-is, and all other -// data types provide some level of debug-pretty-printing. -std::string GetAnyValueS(reflection::BaseType type, const uint8_t *data, - const reflection::Schema *schema, - int type_index); - -// Get any table field as a 64bit int, regardless of what type it is. -inline int64_t GetAnyFieldI(const Table &table, - const reflection::Field &field) { - auto field_ptr = table.GetAddressOf(field.offset()); - return field_ptr ? GetAnyValueI(field.type()->base_type(), field_ptr) - : field.default_integer(); -} - -// Get any table field as a double, regardless of what type it is. -inline double GetAnyFieldF(const Table &table, - const reflection::Field &field) { - auto field_ptr = table.GetAddressOf(field.offset()); - return field_ptr ? GetAnyValueF(field.type()->base_type(), field_ptr) - : field.default_real(); -} - - -// Get any table field as a string, regardless of what type it is. -// You may pass nullptr for the schema if you don't care to have fields that -// are of table type pretty-printed. -inline std::string GetAnyFieldS(const Table &table, - const reflection::Field &field, - const reflection::Schema *schema) { - auto field_ptr = table.GetAddressOf(field.offset()); - return field_ptr ? GetAnyValueS(field.type()->base_type(), field_ptr, schema, - field.type()->index()) - : ""; -} - -// Get any struct field as a 64bit int, regardless of what type it is. -inline int64_t GetAnyFieldI(const Struct &st, - const reflection::Field &field) { - return GetAnyValueI(field.type()->base_type(), - st.GetAddressOf(field.offset())); -} - -// Get any struct field as a double, regardless of what type it is. -inline double GetAnyFieldF(const Struct &st, - const reflection::Field &field) { - return GetAnyValueF(field.type()->base_type(), - st.GetAddressOf(field.offset())); -} - -// Get any struct field as a string, regardless of what type it is. -inline std::string GetAnyFieldS(const Struct &st, - const reflection::Field &field) { - return GetAnyValueS(field.type()->base_type(), - st.GetAddressOf(field.offset()), nullptr, -1); -} - -// Get any vector element as a 64bit int, regardless of what type it is. -inline int64_t GetAnyVectorElemI(const VectorOfAny *vec, - reflection::BaseType elem_type, size_t i) { - return GetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i); -} - -// Get any vector element as a double, regardless of what type it is. -inline double GetAnyVectorElemF(const VectorOfAny *vec, - reflection::BaseType elem_type, size_t i) { - return GetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i); -} - -// Get any vector element as a string, regardless of what type it is. -inline std::string GetAnyVectorElemS(const VectorOfAny *vec, - reflection::BaseType elem_type, size_t i) { - return GetAnyValueS(elem_type, vec->Data() + GetTypeSize(elem_type) * i, - nullptr, -1); -} - -// Get a vector element that's a table/string/vector from a generic vector. -// Pass Table/String/VectorOfAny as template parameter. -// Warning: does no typechecking. -template<typename T> T *GetAnyVectorElemPointer(const VectorOfAny *vec, - size_t i) { - auto elem_ptr = vec->Data() + sizeof(uoffset_t) * i; - return (T *)(elem_ptr + ReadScalar<uoffset_t>(elem_ptr)); -} - -// Get the inline-address of a vector element. Useful for Structs (pass Struct -// as template arg), or being able to address a range of scalars in-line. -// Get elem_size from GetTypeSizeInline(). -// Note: little-endian data on all platforms, use EndianScalar() instead of -// raw pointer access with scalars). -template<typename T> T *GetAnyVectorElemAddressOf(const VectorOfAny *vec, - size_t i, - size_t elem_size) { - // C-cast to allow const conversion. - return (T *)(vec->Data() + elem_size * i); -} - -// Similarly, for elements of tables. -template<typename T> T *GetAnyFieldAddressOf(const Table &table, - const reflection::Field &field) { - return (T *)table.GetAddressOf(field.offset()); -} - -// Similarly, for elements of structs. -template<typename T> T *GetAnyFieldAddressOf(const Struct &st, - const reflection::Field &field) { - return (T *)st.GetAddressOf(field.offset()); -} - -// ------------------------- SETTERS ------------------------- - -// Set any scalar field, if you know its exact type. -template<typename T> bool SetField(Table *table, const reflection::Field &field, - T val) { - reflection::BaseType type = field.type()->base_type(); - if (!IsScalar(type)) { - return false; - } - assert(sizeof(T) == GetTypeSize(type)); - T def; - if (IsInteger(type)) { - def = GetFieldDefaultI<T>(field); - } else { - assert(IsFloat(type)); - def = GetFieldDefaultF<T>(field); - } - return table->SetField(field.offset(), val, def); -} - -// Raw helper functions used below: set any value in memory as a 64bit int, a -// double or a string. -// These work for all scalar values, but do nothing for other data types. -// To set a string, see SetString below. -void SetAnyValueI(reflection::BaseType type, uint8_t *data, int64_t val); -void SetAnyValueF(reflection::BaseType type, uint8_t *data, double val); -void SetAnyValueS(reflection::BaseType type, uint8_t *data, const char *val); - -// Set any table field as a 64bit int, regardless of type what it is. -inline bool SetAnyFieldI(Table *table, const reflection::Field &field, - int64_t val) { - auto field_ptr = table->GetAddressOf(field.offset()); - if (!field_ptr) return val == GetFieldDefaultI<int64_t>(field); - SetAnyValueI(field.type()->base_type(), field_ptr, val); - return true; -} - -// Set any table field as a double, regardless of what type it is. -inline bool SetAnyFieldF(Table *table, const reflection::Field &field, - double val) { - auto field_ptr = table->GetAddressOf(field.offset()); - if (!field_ptr) return val == GetFieldDefaultF<double>(field); - SetAnyValueF(field.type()->base_type(), field_ptr, val); - return true; -} - -// Set any table field as a string, regardless of what type it is. -inline bool SetAnyFieldS(Table *table, const reflection::Field &field, - const char *val) { - auto field_ptr = table->GetAddressOf(field.offset()); - if (!field_ptr) return false; - SetAnyValueS(field.type()->base_type(), field_ptr, val); - return true; -} - -// Set any struct field as a 64bit int, regardless of type what it is. -inline void SetAnyFieldI(Struct *st, const reflection::Field &field, - int64_t val) { - SetAnyValueI(field.type()->base_type(), st->GetAddressOf(field.offset()), - val); -} - -// Set any struct field as a double, regardless of type what it is. -inline void SetAnyFieldF(Struct *st, const reflection::Field &field, - double val) { - SetAnyValueF(field.type()->base_type(), st->GetAddressOf(field.offset()), - val); -} - -// Set any struct field as a string, regardless of type what it is. -inline void SetAnyFieldS(Struct *st, const reflection::Field &field, - const char *val) { - SetAnyValueS(field.type()->base_type(), st->GetAddressOf(field.offset()), - val); -} - -// Set any vector element as a 64bit int, regardless of type what it is. -inline void SetAnyVectorElemI(VectorOfAny *vec, reflection::BaseType elem_type, - size_t i, int64_t val) { - SetAnyValueI(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val); -} - -// Set any vector element as a double, regardless of type what it is. -inline void SetAnyVectorElemF(VectorOfAny *vec, reflection::BaseType elem_type, - size_t i, double val) { - SetAnyValueF(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val); -} - -// Set any vector element as a string, regardless of type what it is. -inline void SetAnyVectorElemS(VectorOfAny *vec, reflection::BaseType elem_type, - size_t i, const char *val) { - SetAnyValueS(elem_type, vec->Data() + GetTypeSize(elem_type) * i, val); -} - - -// ------------------------- RESIZING SETTERS ------------------------- - -// "smart" pointer for use with resizing vectors: turns a pointer inside -// a vector into a relative offset, such that it is not affected by resizes. -template<typename T, typename U> class pointer_inside_vector { - public: - pointer_inside_vector(T *ptr, std::vector<U> &vec) - : offset_(reinterpret_cast<uint8_t *>(ptr) - - reinterpret_cast<uint8_t *>(vec.data())), - vec_(vec) {} - - T *operator*() const { - return reinterpret_cast<T *>( - reinterpret_cast<uint8_t *>(vec_.data()) + offset_); - } - T *operator->() const { - return operator*(); - } - void operator=(const pointer_inside_vector &piv); - private: - size_t offset_; - std::vector<U> &vec_; -}; - -// Helper to create the above easily without specifying template args. -template<typename T, typename U> pointer_inside_vector<T, U> piv(T *ptr, - std::vector<U> &vec) { - return pointer_inside_vector<T, U>(ptr, vec); -} - -inline const char *UnionTypeFieldSuffix() { return "_type"; } - -// Helper to figure out the actual table type a union refers to. -inline const reflection::Object &GetUnionType( - const reflection::Schema &schema, const reflection::Object &parent, - const reflection::Field &unionfield, const Table &table) { - auto enumdef = schema.enums()->Get(unionfield.type()->index()); - // TODO: this is clumsy and slow, but no other way to find it? - auto type_field = parent.fields()->LookupByKey( - (unionfield.name()->str() + UnionTypeFieldSuffix()).c_str()); - assert(type_field); - auto union_type = GetFieldI<uint8_t>(table, *type_field); - auto enumval = enumdef->values()->LookupByKey(union_type); - return *enumval->object(); -} - -// Changes the contents of a string inside a FlatBuffer. FlatBuffer must -// live inside a std::vector so we can resize the buffer if needed. -// "str" must live inside "flatbuf" and may be invalidated after this call. -// If your FlatBuffer's root table is not the schema's root table, you should -// pass in your root_table type as well. -void SetString(const reflection::Schema &schema, const std::string &val, - const String *str, std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table = nullptr); - -// Resizes a flatbuffers::Vector inside a FlatBuffer. FlatBuffer must -// live inside a std::vector so we can resize the buffer if needed. -// "vec" must live inside "flatbuf" and may be invalidated after this call. -// If your FlatBuffer's root table is not the schema's root table, you should -// pass in your root_table type as well. -uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, - const VectorOfAny *vec, uoffset_t num_elems, - uoffset_t elem_size, std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table = nullptr); - -#ifndef FLATBUFFERS_CPP98_STL -template <typename T> -void ResizeVector(const reflection::Schema &schema, uoffset_t newsize, T val, - const Vector<T> *vec, std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table = nullptr) { - auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size()); - auto newelems = ResizeAnyVector(schema, newsize, - reinterpret_cast<const VectorOfAny *>(vec), - vec->size(), - static_cast<uoffset_t>(sizeof(T)), flatbuf, - root_table); - // Set new elements to "val". - for (int i = 0; i < delta_elem; i++) { - auto loc = newelems + i * sizeof(T); - auto is_scalar = std::is_scalar<T>::value; - if (is_scalar) { - WriteScalar(loc, val); - } else { // struct - *reinterpret_cast<T *>(loc) = val; - } - } -} -#endif - -// Adds any new data (in the form of a new FlatBuffer) to an existing -// FlatBuffer. This can be used when any of the above methods are not -// sufficient, in particular for adding new tables and new fields. -// This is potentially slightly less efficient than a FlatBuffer constructed -// in one piece, since the new FlatBuffer doesn't share any vtables with the -// existing one. -// The return value can now be set using Vector::MutateOffset or SetFieldT -// below. -const uint8_t *AddFlatBuffer(std::vector<uint8_t> &flatbuf, - const uint8_t *newbuf, size_t newlen); - -inline bool SetFieldT(Table *table, const reflection::Field &field, - const uint8_t *val) { - assert(sizeof(uoffset_t) == GetTypeSize(field.type()->base_type())); - return table->SetPointer(field.offset(), val); -} - -// ------------------------- COPYING ------------------------- - -// Generic copying of tables from a FlatBuffer into a FlatBuffer builder. -// Can be used to do any kind of merging/selecting you may want to do out -// of existing buffers. Also useful to reconstruct a whole buffer if the -// above resizing functionality has introduced garbage in a buffer you want -// to remove. -// Note: this does not deal with DAGs correctly. If the table passed forms a -// DAG, the copy will be a tree instead (with duplicates). Strings can be -// shared however, by passing true for use_string_pooling. - -Offset<const Table *> CopyTable(FlatBufferBuilder &fbb, - const reflection::Schema &schema, - const reflection::Object &objectdef, - const Table &table, - bool use_string_pooling = false); - -// Verifies the provided flatbuffer using reflection. -// root should point to the root type for this flatbuffer. -// buf should point to the start of flatbuffer data. -// length specifies the size of the flatbuffer data. -bool Verify(const reflection::Schema &schema, - const reflection::Object &root, - const uint8_t *buf, - size_t length); - -} // namespace flatbuffers - -#endif // FLATBUFFERS_REFLECTION_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/reflection_generated.h b/third_party/flatbuffers/include/flatbuffers/reflection_generated.h deleted file mode 100644 index b76814e..0000000 --- a/third_party/flatbuffers/include/flatbuffers/reflection_generated.h +++ /dev/null
@@ -1,881 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ -#define FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ - -#include "flatbuffers/flatbuffers.h" - -namespace reflection { - -struct Type; - -struct KeyValue; - -struct EnumVal; - -struct Enum; - -struct Field; - -struct Object; - -struct Schema; - -enum BaseType { - None = 0, - UType = 1, - Bool = 2, - Byte = 3, - UByte = 4, - Short = 5, - UShort = 6, - Int = 7, - UInt = 8, - Long = 9, - ULong = 10, - Float = 11, - Double = 12, - String = 13, - Vector = 14, - Obj = 15, - Union = 16 -}; - -inline const char **EnumNamesBaseType() { - static const char *names[] = { - "None", - "UType", - "Bool", - "Byte", - "UByte", - "Short", - "UShort", - "Int", - "UInt", - "Long", - "ULong", - "Float", - "Double", - "String", - "Vector", - "Obj", - "Union", - nullptr - }; - return names; -} - -inline const char *EnumNameBaseType(BaseType e) { - const size_t index = static_cast<int>(e); - return EnumNamesBaseType()[index]; -} - -struct Type FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_BASE_TYPE = 4, - VT_ELEMENT = 6, - VT_INDEX = 8 - }; - BaseType base_type() const { - return static_cast<BaseType>(GetField<int8_t>(VT_BASE_TYPE, 0)); - } - BaseType element() const { - return static_cast<BaseType>(GetField<int8_t>(VT_ELEMENT, 0)); - } - int32_t index() const { - return GetField<int32_t>(VT_INDEX, -1); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int8_t>(verifier, VT_BASE_TYPE) && - VerifyField<int8_t>(verifier, VT_ELEMENT) && - VerifyField<int32_t>(verifier, VT_INDEX) && - verifier.EndTable(); - } -}; - -struct TypeBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_base_type(BaseType base_type) { - fbb_.AddElement<int8_t>(Type::VT_BASE_TYPE, static_cast<int8_t>(base_type), 0); - } - void add_element(BaseType element) { - fbb_.AddElement<int8_t>(Type::VT_ELEMENT, static_cast<int8_t>(element), 0); - } - void add_index(int32_t index) { - fbb_.AddElement<int32_t>(Type::VT_INDEX, index, -1); - } - TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TypeBuilder &operator=(const TypeBuilder &); - flatbuffers::Offset<Type> Finish() { - const auto end = fbb_.EndTable(start_, 3); - auto o = flatbuffers::Offset<Type>(end); - return o; - } -}; - -inline flatbuffers::Offset<Type> CreateType( - flatbuffers::FlatBufferBuilder &_fbb, - BaseType base_type = None, - BaseType element = None, - int32_t index = -1) { - TypeBuilder builder_(_fbb); - builder_.add_index(index); - builder_.add_element(element); - builder_.add_base_type(base_type); - return builder_.Finish(); -} - -struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_KEY = 4, - VT_VALUE = 6 - }; - const flatbuffers::String *key() const { - return GetPointer<const flatbuffers::String *>(VT_KEY); - } - bool KeyCompareLessThan(const KeyValue *o) const { - return *key() < *o->key(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(key()->c_str(), val); - } - const flatbuffers::String *value() const { - return GetPointer<const flatbuffers::String *>(VT_VALUE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_KEY) && - verifier.Verify(key()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_VALUE) && - verifier.Verify(value()) && - verifier.EndTable(); - } -}; - -struct KeyValueBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_key(flatbuffers::Offset<flatbuffers::String> key) { - fbb_.AddOffset(KeyValue::VT_KEY, key); - } - void add_value(flatbuffers::Offset<flatbuffers::String> value) { - fbb_.AddOffset(KeyValue::VT_VALUE, value); - } - KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - KeyValueBuilder &operator=(const KeyValueBuilder &); - flatbuffers::Offset<KeyValue> Finish() { - const auto end = fbb_.EndTable(start_, 2); - auto o = flatbuffers::Offset<KeyValue>(end); - fbb_.Required(o, KeyValue::VT_KEY); - return o; - } -}; - -inline flatbuffers::Offset<KeyValue> CreateKeyValue( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> key = 0, - flatbuffers::Offset<flatbuffers::String> value = 0) { - KeyValueBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_key(key); - return builder_.Finish(); -} - -inline flatbuffers::Offset<KeyValue> CreateKeyValueDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *key = nullptr, - const char *value = nullptr) { - return reflection::CreateKeyValue( - _fbb, - key ? _fbb.CreateString(key) : 0, - value ? _fbb.CreateString(value) : 0); -} - -struct EnumVal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_NAME = 4, - VT_VALUE = 6, - VT_OBJECT = 8, - VT_UNION_TYPE = 10 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - int64_t value() const { - return GetField<int64_t>(VT_VALUE, 0); - } - bool KeyCompareLessThan(const EnumVal *o) const { - return value() < o->value(); - } - int KeyCompareWithValue(int64_t val) const { - const auto key = value(); - if (key < val) { - return -1; - } else if (key > val) { - return 1; - } else { - return 0; - } - } - const Object *object() const { - return GetPointer<const Object *>(VT_OBJECT); - } - const Type *union_type() const { - return GetPointer<const Type *>(VT_UNION_TYPE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_NAME) && - verifier.Verify(name()) && - VerifyField<int64_t>(verifier, VT_VALUE) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_OBJECT) && - verifier.VerifyTable(object()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_UNION_TYPE) && - verifier.VerifyTable(union_type()) && - verifier.EndTable(); - } -}; - -struct EnumValBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(EnumVal::VT_NAME, name); - } - void add_value(int64_t value) { - fbb_.AddElement<int64_t>(EnumVal::VT_VALUE, value, 0); - } - void add_object(flatbuffers::Offset<Object> object) { - fbb_.AddOffset(EnumVal::VT_OBJECT, object); - } - void add_union_type(flatbuffers::Offset<Type> union_type) { - fbb_.AddOffset(EnumVal::VT_UNION_TYPE, union_type); - } - EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - EnumValBuilder &operator=(const EnumValBuilder &); - flatbuffers::Offset<EnumVal> Finish() { - const auto end = fbb_.EndTable(start_, 4); - auto o = flatbuffers::Offset<EnumVal>(end); - fbb_.Required(o, EnumVal::VT_NAME); - return o; - } -}; - -inline flatbuffers::Offset<EnumVal> CreateEnumVal( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - int64_t value = 0, - flatbuffers::Offset<Object> object = 0, - flatbuffers::Offset<Type> union_type = 0) { - EnumValBuilder builder_(_fbb); - builder_.add_value(value); - builder_.add_union_type(union_type); - builder_.add_object(object); - builder_.add_name(name); - return builder_.Finish(); -} - -inline flatbuffers::Offset<EnumVal> CreateEnumValDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - int64_t value = 0, - flatbuffers::Offset<Object> object = 0, - flatbuffers::Offset<Type> union_type = 0) { - return reflection::CreateEnumVal( - _fbb, - name ? _fbb.CreateString(name) : 0, - value, - object, - union_type); -} - -struct Enum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_NAME = 4, - VT_VALUES = 6, - VT_IS_UNION = 8, - VT_UNDERLYING_TYPE = 10, - VT_ATTRIBUTES = 12, - VT_DOCUMENTATION = 14 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Enum *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } - const flatbuffers::Vector<flatbuffers::Offset<EnumVal>> *values() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<EnumVal>> *>(VT_VALUES); - } - bool is_union() const { - return GetField<uint8_t>(VT_IS_UNION, 0) != 0; - } - const Type *underlying_type() const { - return GetPointer<const Type *>(VT_UNDERLYING_TYPE); - } - const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *attributes() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_NAME) && - verifier.Verify(name()) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_VALUES) && - verifier.Verify(values()) && - verifier.VerifyVectorOfTables(values()) && - VerifyField<uint8_t>(verifier, VT_IS_UNION) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_UNDERLYING_TYPE) && - verifier.VerifyTable(underlying_type()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_ATTRIBUTES) && - verifier.Verify(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_DOCUMENTATION) && - verifier.Verify(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && - verifier.EndTable(); - } -}; - -struct EnumBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Enum::VT_NAME, name); - } - void add_values(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<EnumVal>>> values) { - fbb_.AddOffset(Enum::VT_VALUES, values); - } - void add_is_union(bool is_union) { - fbb_.AddElement<uint8_t>(Enum::VT_IS_UNION, static_cast<uint8_t>(is_union), 0); - } - void add_underlying_type(flatbuffers::Offset<Type> underlying_type) { - fbb_.AddOffset(Enum::VT_UNDERLYING_TYPE, underlying_type); - } - void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes) { - fbb_.AddOffset(Enum::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Enum::VT_DOCUMENTATION, documentation); - } - EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - EnumBuilder &operator=(const EnumBuilder &); - flatbuffers::Offset<Enum> Finish() { - const auto end = fbb_.EndTable(start_, 6); - auto o = flatbuffers::Offset<Enum>(end); - fbb_.Required(o, Enum::VT_NAME); - fbb_.Required(o, Enum::VT_VALUES); - fbb_.Required(o, Enum::VT_UNDERLYING_TYPE); - return o; - } -}; - -inline flatbuffers::Offset<Enum> CreateEnum( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<EnumVal>>> values = 0, - bool is_union = false, - flatbuffers::Offset<Type> underlying_type = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { - EnumBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); - builder_.add_underlying_type(underlying_type); - builder_.add_values(values); - builder_.add_name(name); - builder_.add_is_union(is_union); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Enum> CreateEnumDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - const std::vector<flatbuffers::Offset<EnumVal>> *values = nullptr, - bool is_union = false, - flatbuffers::Offset<Type> underlying_type = 0, - const std::vector<flatbuffers::Offset<KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { - return reflection::CreateEnum( - _fbb, - name ? _fbb.CreateString(name) : 0, - values ? _fbb.CreateVector<flatbuffers::Offset<EnumVal>>(*values) : 0, - is_union, - underlying_type, - attributes ? _fbb.CreateVector<flatbuffers::Offset<KeyValue>>(*attributes) : 0, - documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0); -} - -struct Field FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_NAME = 4, - VT_TYPE = 6, - VT_ID = 8, - VT_OFFSET = 10, - VT_DEFAULT_INTEGER = 12, - VT_DEFAULT_REAL = 14, - VT_DEPRECATED = 16, - VT_REQUIRED = 18, - VT_KEY = 20, - VT_ATTRIBUTES = 22, - VT_DOCUMENTATION = 24 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Field *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } - const Type *type() const { - return GetPointer<const Type *>(VT_TYPE); - } - uint16_t id() const { - return GetField<uint16_t>(VT_ID, 0); - } - uint16_t offset() const { - return GetField<uint16_t>(VT_OFFSET, 0); - } - int64_t default_integer() const { - return GetField<int64_t>(VT_DEFAULT_INTEGER, 0); - } - double default_real() const { - return GetField<double>(VT_DEFAULT_REAL, 0.0); - } - bool deprecated() const { - return GetField<uint8_t>(VT_DEPRECATED, 0) != 0; - } - bool required() const { - return GetField<uint8_t>(VT_REQUIRED, 0) != 0; - } - bool key() const { - return GetField<uint8_t>(VT_KEY, 0) != 0; - } - const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *attributes() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_NAME) && - verifier.Verify(name()) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_TYPE) && - verifier.VerifyTable(type()) && - VerifyField<uint16_t>(verifier, VT_ID) && - VerifyField<uint16_t>(verifier, VT_OFFSET) && - VerifyField<int64_t>(verifier, VT_DEFAULT_INTEGER) && - VerifyField<double>(verifier, VT_DEFAULT_REAL) && - VerifyField<uint8_t>(verifier, VT_DEPRECATED) && - VerifyField<uint8_t>(verifier, VT_REQUIRED) && - VerifyField<uint8_t>(verifier, VT_KEY) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_ATTRIBUTES) && - verifier.Verify(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_DOCUMENTATION) && - verifier.Verify(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && - verifier.EndTable(); - } -}; - -struct FieldBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Field::VT_NAME, name); - } - void add_type(flatbuffers::Offset<Type> type) { - fbb_.AddOffset(Field::VT_TYPE, type); - } - void add_id(uint16_t id) { - fbb_.AddElement<uint16_t>(Field::VT_ID, id, 0); - } - void add_offset(uint16_t offset) { - fbb_.AddElement<uint16_t>(Field::VT_OFFSET, offset, 0); - } - void add_default_integer(int64_t default_integer) { - fbb_.AddElement<int64_t>(Field::VT_DEFAULT_INTEGER, default_integer, 0); - } - void add_default_real(double default_real) { - fbb_.AddElement<double>(Field::VT_DEFAULT_REAL, default_real, 0.0); - } - void add_deprecated(bool deprecated) { - fbb_.AddElement<uint8_t>(Field::VT_DEPRECATED, static_cast<uint8_t>(deprecated), 0); - } - void add_required(bool required) { - fbb_.AddElement<uint8_t>(Field::VT_REQUIRED, static_cast<uint8_t>(required), 0); - } - void add_key(bool key) { - fbb_.AddElement<uint8_t>(Field::VT_KEY, static_cast<uint8_t>(key), 0); - } - void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes) { - fbb_.AddOffset(Field::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Field::VT_DOCUMENTATION, documentation); - } - FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - FieldBuilder &operator=(const FieldBuilder &); - flatbuffers::Offset<Field> Finish() { - const auto end = fbb_.EndTable(start_, 11); - auto o = flatbuffers::Offset<Field>(end); - fbb_.Required(o, Field::VT_NAME); - fbb_.Required(o, Field::VT_TYPE); - return o; - } -}; - -inline flatbuffers::Offset<Field> CreateField( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - flatbuffers::Offset<Type> type = 0, - uint16_t id = 0, - uint16_t offset = 0, - int64_t default_integer = 0, - double default_real = 0.0, - bool deprecated = false, - bool required = false, - bool key = false, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { - FieldBuilder builder_(_fbb); - builder_.add_default_real(default_real); - builder_.add_default_integer(default_integer); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); - builder_.add_type(type); - builder_.add_name(name); - builder_.add_offset(offset); - builder_.add_id(id); - builder_.add_key(key); - builder_.add_required(required); - builder_.add_deprecated(deprecated); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Field> CreateFieldDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - flatbuffers::Offset<Type> type = 0, - uint16_t id = 0, - uint16_t offset = 0, - int64_t default_integer = 0, - double default_real = 0.0, - bool deprecated = false, - bool required = false, - bool key = false, - const std::vector<flatbuffers::Offset<KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { - return reflection::CreateField( - _fbb, - name ? _fbb.CreateString(name) : 0, - type, - id, - offset, - default_integer, - default_real, - deprecated, - required, - key, - attributes ? _fbb.CreateVector<flatbuffers::Offset<KeyValue>>(*attributes) : 0, - documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0); -} - -struct Object FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_NAME = 4, - VT_FIELDS = 6, - VT_IS_STRUCT = 8, - VT_MINALIGN = 10, - VT_BYTESIZE = 12, - VT_ATTRIBUTES = 14, - VT_DOCUMENTATION = 16 - }; - const flatbuffers::String *name() const { - return GetPointer<const flatbuffers::String *>(VT_NAME); - } - bool KeyCompareLessThan(const Object *o) const { - return *name() < *o->name(); - } - int KeyCompareWithValue(const char *val) const { - return strcmp(name()->c_str(), val); - } - const flatbuffers::Vector<flatbuffers::Offset<Field>> *fields() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Field>> *>(VT_FIELDS); - } - bool is_struct() const { - return GetField<uint8_t>(VT_IS_STRUCT, 0) != 0; - } - int32_t minalign() const { - return GetField<int32_t>(VT_MINALIGN, 0); - } - int32_t bytesize() const { - return GetField<int32_t>(VT_BYTESIZE, 0); - } - const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *attributes() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<KeyValue>> *>(VT_ATTRIBUTES); - } - const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *documentation() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_DOCUMENTATION); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_NAME) && - verifier.Verify(name()) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_FIELDS) && - verifier.Verify(fields()) && - verifier.VerifyVectorOfTables(fields()) && - VerifyField<uint8_t>(verifier, VT_IS_STRUCT) && - VerifyField<int32_t>(verifier, VT_MINALIGN) && - VerifyField<int32_t>(verifier, VT_BYTESIZE) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_ATTRIBUTES) && - verifier.Verify(attributes()) && - verifier.VerifyVectorOfTables(attributes()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_DOCUMENTATION) && - verifier.Verify(documentation()) && - verifier.VerifyVectorOfStrings(documentation()) && - verifier.EndTable(); - } -}; - -struct ObjectBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_name(flatbuffers::Offset<flatbuffers::String> name) { - fbb_.AddOffset(Object::VT_NAME, name); - } - void add_fields(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Field>>> fields) { - fbb_.AddOffset(Object::VT_FIELDS, fields); - } - void add_is_struct(bool is_struct) { - fbb_.AddElement<uint8_t>(Object::VT_IS_STRUCT, static_cast<uint8_t>(is_struct), 0); - } - void add_minalign(int32_t minalign) { - fbb_.AddElement<int32_t>(Object::VT_MINALIGN, minalign, 0); - } - void add_bytesize(int32_t bytesize) { - fbb_.AddElement<int32_t>(Object::VT_BYTESIZE, bytesize, 0); - } - void add_attributes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes) { - fbb_.AddOffset(Object::VT_ATTRIBUTES, attributes); - } - void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { - fbb_.AddOffset(Object::VT_DOCUMENTATION, documentation); - } - ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - ObjectBuilder &operator=(const ObjectBuilder &); - flatbuffers::Offset<Object> Finish() { - const auto end = fbb_.EndTable(start_, 7); - auto o = flatbuffers::Offset<Object>(end); - fbb_.Required(o, Object::VT_NAME); - fbb_.Required(o, Object::VT_FIELDS); - return o; - } -}; - -inline flatbuffers::Offset<Object> CreateObject( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::String> name = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Field>>> fields = 0, - bool is_struct = false, - int32_t minalign = 0, - int32_t bytesize = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<KeyValue>>> attributes = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation = 0) { - ObjectBuilder builder_(_fbb); - builder_.add_documentation(documentation); - builder_.add_attributes(attributes); - builder_.add_bytesize(bytesize); - builder_.add_minalign(minalign); - builder_.add_fields(fields); - builder_.add_name(name); - builder_.add_is_struct(is_struct); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Object> CreateObjectDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const char *name = nullptr, - const std::vector<flatbuffers::Offset<Field>> *fields = nullptr, - bool is_struct = false, - int32_t minalign = 0, - int32_t bytesize = 0, - const std::vector<flatbuffers::Offset<KeyValue>> *attributes = nullptr, - const std::vector<flatbuffers::Offset<flatbuffers::String>> *documentation = nullptr) { - return reflection::CreateObject( - _fbb, - name ? _fbb.CreateString(name) : 0, - fields ? _fbb.CreateVector<flatbuffers::Offset<Field>>(*fields) : 0, - is_struct, - minalign, - bytesize, - attributes ? _fbb.CreateVector<flatbuffers::Offset<KeyValue>>(*attributes) : 0, - documentation ? _fbb.CreateVector<flatbuffers::Offset<flatbuffers::String>>(*documentation) : 0); -} - -struct Schema FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_OBJECTS = 4, - VT_ENUMS = 6, - VT_FILE_IDENT = 8, - VT_FILE_EXT = 10, - VT_ROOT_TABLE = 12 - }; - const flatbuffers::Vector<flatbuffers::Offset<Object>> *objects() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Object>> *>(VT_OBJECTS); - } - const flatbuffers::Vector<flatbuffers::Offset<Enum>> *enums() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Enum>> *>(VT_ENUMS); - } - const flatbuffers::String *file_ident() const { - return GetPointer<const flatbuffers::String *>(VT_FILE_IDENT); - } - const flatbuffers::String *file_ext() const { - return GetPointer<const flatbuffers::String *>(VT_FILE_EXT); - } - const Object *root_table() const { - return GetPointer<const Object *>(VT_ROOT_TABLE); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_OBJECTS) && - verifier.Verify(objects()) && - verifier.VerifyVectorOfTables(objects()) && - VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_ENUMS) && - verifier.Verify(enums()) && - verifier.VerifyVectorOfTables(enums()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_FILE_IDENT) && - verifier.Verify(file_ident()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_FILE_EXT) && - verifier.Verify(file_ext()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_ROOT_TABLE) && - verifier.VerifyTable(root_table()) && - verifier.EndTable(); - } -}; - -struct SchemaBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_objects(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Object>>> objects) { - fbb_.AddOffset(Schema::VT_OBJECTS, objects); - } - void add_enums(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Enum>>> enums) { - fbb_.AddOffset(Schema::VT_ENUMS, enums); - } - void add_file_ident(flatbuffers::Offset<flatbuffers::String> file_ident) { - fbb_.AddOffset(Schema::VT_FILE_IDENT, file_ident); - } - void add_file_ext(flatbuffers::Offset<flatbuffers::String> file_ext) { - fbb_.AddOffset(Schema::VT_FILE_EXT, file_ext); - } - void add_root_table(flatbuffers::Offset<Object> root_table) { - fbb_.AddOffset(Schema::VT_ROOT_TABLE, root_table); - } - SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SchemaBuilder &operator=(const SchemaBuilder &); - flatbuffers::Offset<Schema> Finish() { - const auto end = fbb_.EndTable(start_, 5); - auto o = flatbuffers::Offset<Schema>(end); - fbb_.Required(o, Schema::VT_OBJECTS); - fbb_.Required(o, Schema::VT_ENUMS); - return o; - } -}; - -inline flatbuffers::Offset<Schema> CreateSchema( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Object>>> objects = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Enum>>> enums = 0, - flatbuffers::Offset<flatbuffers::String> file_ident = 0, - flatbuffers::Offset<flatbuffers::String> file_ext = 0, - flatbuffers::Offset<Object> root_table = 0) { - SchemaBuilder builder_(_fbb); - builder_.add_root_table(root_table); - builder_.add_file_ext(file_ext); - builder_.add_file_ident(file_ident); - builder_.add_enums(enums); - builder_.add_objects(objects); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Schema> CreateSchemaDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector<flatbuffers::Offset<Object>> *objects = nullptr, - const std::vector<flatbuffers::Offset<Enum>> *enums = nullptr, - const char *file_ident = nullptr, - const char *file_ext = nullptr, - flatbuffers::Offset<Object> root_table = 0) { - return reflection::CreateSchema( - _fbb, - objects ? _fbb.CreateVector<flatbuffers::Offset<Object>>(*objects) : 0, - enums ? _fbb.CreateVector<flatbuffers::Offset<Enum>>(*enums) : 0, - file_ident ? _fbb.CreateString(file_ident) : 0, - file_ext ? _fbb.CreateString(file_ext) : 0, - root_table); -} - -inline const reflection::Schema *GetSchema(const void *buf) { - return flatbuffers::GetRoot<reflection::Schema>(buf); -} - -inline const char *SchemaIdentifier() { - return "BFBS"; -} - -inline bool SchemaBufferHasIdentifier(const void *buf) { - return flatbuffers::BufferHasIdentifier( - buf, SchemaIdentifier()); -} - -inline bool VerifySchemaBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier()); -} - -inline const char *SchemaExtension() { - return "bfbs"; -} - -inline void FinishSchemaBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<reflection::Schema> root) { - fbb.Finish(root, SchemaIdentifier()); -} - -} // namespace reflection - -#endif // FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
diff --git a/third_party/flatbuffers/include/flatbuffers/util.h b/third_party/flatbuffers/include/flatbuffers/util.h deleted file mode 100644 index 870d2b6..0000000 --- a/third_party/flatbuffers/include/flatbuffers/util.h +++ /dev/null
@@ -1,351 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLATBUFFERS_UTIL_H_ -#define FLATBUFFERS_UTIL_H_ - -#include <fstream> -#include <iomanip> -#include <string> -#include <sstream> -#include <stdint.h> -#include <stdlib.h> -#include <assert.h> -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX - #define NOMINMAX -#endif -#include <windows.h> -#include <winbase.h> -#include <direct.h> -#else -#include <limits.h> -#endif -#include <sys/types.h> -#include <sys/stat.h> - -#include "flatbuffers/flatbuffers.h" - - -namespace flatbuffers { - -// Convert an integer or floating point value to a string. -// In contrast to std::stringstream, "char" values are -// converted to a string of digits, and we don't use scientific notation. -template<typename T> std::string NumToString(T t) { - std::stringstream ss; - ss << t; - return ss.str(); -} -// Avoid char types used as character data. -template<> inline std::string NumToString<signed char>(signed char t) { - return NumToString(static_cast<int>(t)); -} -template<> inline std::string NumToString<unsigned char>(unsigned char t) { - return NumToString(static_cast<int>(t)); -} - -// Special versions for floats/doubles. -template<> inline std::string NumToString<double>(double t) { - // to_string() prints different numbers of digits for floats depending on - // platform and isn't available on Android, so we use stringstream - std::stringstream ss; - // Use std::fixed to surpress scientific notation. - ss << std::fixed << t; - auto s = ss.str(); - // Sadly, std::fixed turns "1" into "1.00000", so here we undo that. - auto p = s.find_last_not_of('0'); - if (p != std::string::npos) { - s.resize(p + 1); // Strip trailing zeroes. - if (s[s.size() - 1] == '.') - s.erase(s.size() - 1, 1); // Strip '.' if a whole number. - } - return s; -} -template<> inline std::string NumToString<float>(float t) { - return NumToString(static_cast<double>(t)); -} - -// Convert an integer value to a hexadecimal string. -// The returned string length is always xdigits long, prefixed by 0 digits. -// For example, IntToStringHex(0x23, 8) returns the string "00000023". -inline std::string IntToStringHex(int i, int xdigits) { - std::stringstream ss; - ss << std::setw(xdigits) - << std::setfill('0') - << std::hex - << std::uppercase - << i; - return ss.str(); -} - -// Portable implementation of strtoll(). -inline int64_t StringToInt(const char *str, char **endptr = nullptr, - int base = 10) { - #ifdef _MSC_VER - return _strtoi64(str, endptr, base); - #else - return strtoll(str, endptr, base); - #endif -} - -// Portable implementation of strtoull(). -inline uint64_t StringToUInt(const char *str, char **endptr = nullptr, - int base = 10) { - #ifdef _MSC_VER - return _strtoui64(str, endptr, base); - #else - return strtoull(str, endptr, base); - #endif -} - -typedef bool (*LoadFileFunction)(const char *filename, bool binary, - std::string *dest); -typedef bool (*FileExistsFunction)(const char *filename); - -LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function); - -FileExistsFunction SetFileExistsFunction(FileExistsFunction - file_exists_function); - - -// Check if file "name" exists. -bool FileExists(const char *name); - -// Check if "name" exists and it is also a directory. -bool DirExists(const char *name); - -// Load file "name" into "buf" returning true if successful -// false otherwise. If "binary" is false data is read -// using ifstream's text mode, otherwise data is read with -// no transcoding. -bool LoadFile(const char *name, bool binary, std::string *buf); - -// Save data "buf" of length "len" bytes into a file -// "name" returning true if successful, false otherwise. -// If "binary" is false data is written using ifstream's -// text mode, otherwise data is written with no -// transcoding. -inline bool SaveFile(const char *name, const char *buf, size_t len, - bool binary) { - std::ofstream ofs(name, binary ? std::ofstream::binary : std::ofstream::out); - if (!ofs.is_open()) return false; - ofs.write(buf, len); - return !ofs.bad(); -} - -// Save data "buf" into file "name" returning true if -// successful, false otherwise. If "binary" is false -// data is written using ifstream's text mode, otherwise -// data is written with no transcoding. -inline bool SaveFile(const char *name, const std::string &buf, bool binary) { - return SaveFile(name, buf.c_str(), buf.size(), binary); -} - -// Functionality for minimalistic portable path handling: - -static const char kPosixPathSeparator = '/'; -#ifdef _WIN32 -static const char kPathSeparator = '\\'; -static const char *PathSeparatorSet = "\\/"; // Intentionally no ':' -#else -static const char kPathSeparator = kPosixPathSeparator; -static const char *PathSeparatorSet = "/"; -#endif // _WIN32 - -// Returns the path with the extension, if any, removed. -inline std::string StripExtension(const std::string &filepath) { - size_t i = filepath.find_last_of("."); - return i != std::string::npos ? filepath.substr(0, i) : filepath; -} - -// Returns the extension, if any. -inline std::string GetExtension(const std::string &filepath) { - size_t i = filepath.find_last_of("."); - return i != std::string::npos ? filepath.substr(i + 1) : ""; -} - -// Return the last component of the path, after the last separator. -inline std::string StripPath(const std::string &filepath) { - size_t i = filepath.find_last_of(PathSeparatorSet); - return i != std::string::npos ? filepath.substr(i + 1) : filepath; -} - -// Strip the last component of the path + separator. -inline std::string StripFileName(const std::string &filepath) { - size_t i = filepath.find_last_of(PathSeparatorSet); - return i != std::string::npos ? filepath.substr(0, i) : ""; -} - -// Concatenates a path with a filename, regardless of wether the path -// ends in a separator or not. -inline std::string ConCatPathFileName(const std::string &path, - const std::string &filename) { - std::string filepath = path; - if (path.length() && path[path.size() - 1] != kPathSeparator && - path[path.size() - 1] != kPosixPathSeparator) - filepath += kPathSeparator; - filepath += filename; - return filepath; -} - -// This function ensure a directory exists, by recursively -// creating dirs for any parts of the path that don't exist yet. -inline void EnsureDirExists(const std::string &filepath) { - auto parent = StripFileName(filepath); - if (parent.length()) EnsureDirExists(parent); - #ifdef _WIN32 - (void)_mkdir(filepath.c_str()); - #else - mkdir(filepath.c_str(), S_IRWXU|S_IRGRP|S_IXGRP); - #endif -} - -// Obtains the absolute path from any other path. -// Returns the input path if the absolute path couldn't be resolved. -inline std::string AbsolutePath(const std::string &filepath) { - #ifdef FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION - return filepath; - #else - #ifdef _WIN32 - char abs_path[MAX_PATH]; - return GetFullPathNameA(filepath.c_str(), MAX_PATH, abs_path, nullptr) - #else - char abs_path[PATH_MAX]; - return realpath(filepath.c_str(), abs_path) - #endif - ? abs_path - : filepath; - #endif // FLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION -} - -// To and from UTF-8 unicode conversion functions - -// Convert a unicode code point into a UTF-8 representation by appending it -// to a string. Returns the number of bytes generated. -inline int ToUTF8(uint32_t ucc, std::string *out) { - assert(!(ucc & 0x80000000)); // Top bit can't be set. - // 6 possible encodings: http://en.wikipedia.org/wiki/UTF-8 - for (int i = 0; i < 6; i++) { - // Max bits this encoding can represent. - uint32_t max_bits = 6 + i * 5 + static_cast<int>(!i); - if (ucc < (1u << max_bits)) { // does it fit? - // Remaining bits not encoded in the first byte, store 6 bits each - uint32_t remain_bits = i * 6; - // Store first byte: - (*out) += static_cast<char>((0xFE << (max_bits - remain_bits)) | - (ucc >> remain_bits)); - // Store remaining bytes: - for (int j = i - 1; j >= 0; j--) { - (*out) += static_cast<char>(((ucc >> (j * 6)) & 0x3F) | 0x80); - } - return i + 1; // Return the number of bytes added. - } - } - assert(0); // Impossible to arrive here. - return -1; -} - -// Converts whatever prefix of the incoming string corresponds to a valid -// UTF-8 sequence into a unicode code. The incoming pointer will have been -// advanced past all bytes parsed. -// returns -1 upon corrupt UTF-8 encoding (ignore the incoming pointer in -// this case). -inline int FromUTF8(const char **in) { - int len = 0; - // Count leading 1 bits. - for (int mask = 0x80; mask >= 0x04; mask >>= 1) { - if (**in & mask) { - len++; - } else { - break; - } - } - if ((**in << len) & 0x80) return -1; // Bit after leading 1's must be 0. - if (!len) return *(*in)++; - // UTF-8 encoded values with a length are between 2 and 4 bytes. - if (len < 2 || len > 4) { - return -1; - } - // Grab initial bits of the code. - int ucc = *(*in)++ & ((1 << (7 - len)) - 1); - for (int i = 0; i < len - 1; i++) { - if ((**in & 0xC0) != 0x80) return -1; // Upper bits must 1 0. - ucc <<= 6; - ucc |= *(*in)++ & 0x3F; // Grab 6 more bits of the code. - } - // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for - // UTF-16 surrogate pairs). - if (ucc >= 0xD800 && ucc <= 0xDFFF) { - return -1; - } - // UTF-8 must represent code points in their shortest possible encoding. - switch (len) { - case 2: - // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF. - if (ucc < 0x0080 || ucc > 0x07FF) { - return -1; - } - break; - case 3: - // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF. - if (ucc < 0x0800 || ucc > 0xFFFF) { - return -1; - } - break; - case 4: - // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF. - if (ucc < 0x10000 || ucc > 0x10FFFF) { - return -1; - } - break; - } - return ucc; -} - -// Wraps a string to a maximum length, inserting new lines where necessary. Any -// existing whitespace will be collapsed down to a single space. A prefix or -// suffix can be provided, which will be inserted before or after a wrapped -// line, respectively. -inline std::string WordWrap(const std::string in, size_t max_length, - const std::string wrapped_line_prefix, - const std::string wrapped_line_suffix) { - std::istringstream in_stream(in); - std::string wrapped, line, word; - - in_stream >> word; - line = word; - - while (in_stream >> word) { - if ((line.length() + 1 + word.length() + wrapped_line_suffix.length()) < - max_length) { - line += " " + word; - } else { - wrapped += line + wrapped_line_suffix + "\n"; - line = wrapped_line_prefix + word; - } - } - wrapped += line; - - return wrapped; -} - -} // namespace flatbuffers - -#endif // FLATBUFFERS_UTIL_H_
diff --git a/third_party/flatbuffers/java/com/google/flatbuffers/Constants.java b/third_party/flatbuffers/java/com/google/flatbuffers/Constants.java deleted file mode 100644 index f590631..0000000 --- a/third_party/flatbuffers/java/com/google/flatbuffers/Constants.java +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.flatbuffers; - -/// @cond FLATBUFFERS_INTERNAL - -/** - * Class that holds shared constants - */ -public class Constants { - // Java doesn't seem to have these. - /** The number of bytes in an `byte`. */ - static final int SIZEOF_BYTE = 1; - /** The number of bytes in a `short`. */ - static final int SIZEOF_SHORT = 2; - /** The number of bytes in an `int`. */ - static final int SIZEOF_INT = 4; - /** The number of bytes in an `float`. */ - static final int SIZEOF_FLOAT = 4; - /** The number of bytes in an `long`. */ - static final int SIZEOF_LONG = 8; - /** The number of bytes in an `double`. */ - static final int SIZEOF_DOUBLE = 8; - /** The number of bytes in a file identifier. */ - static final int FILE_IDENTIFIER_LENGTH = 4; -} - -/// @endcond
diff --git a/third_party/flatbuffers/java/com/google/flatbuffers/FlatBufferBuilder.java b/third_party/flatbuffers/java/com/google/flatbuffers/FlatBufferBuilder.java deleted file mode 100644 index a138ed5..0000000 --- a/third_party/flatbuffers/java/com/google/flatbuffers/FlatBufferBuilder.java +++ /dev/null
@@ -1,858 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.flatbuffers; - -import static com.google.flatbuffers.Constants.*; - -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.util.Arrays; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.charset.Charset; - -/// @file -/// @addtogroup flatbuffers_java_api -/// @{ - -/** - * Class that helps you build a FlatBuffer. See the section - * "Use in Java/C#" in the main FlatBuffers documentation. - */ -public class FlatBufferBuilder { - /// @cond FLATBUFFERS_INTERNAL - ByteBuffer bb; // Where we construct the FlatBuffer. - int space; // Remaining space in the ByteBuffer. - static final Charset utf8charset = Charset.forName("UTF-8"); // The UTF-8 character set used by FlatBuffers. - int minalign = 1; // Minimum alignment encountered so far. - int[] vtable = null; // The vtable for the current table. - int vtable_in_use = 0; // The amount of fields we're actually using. - boolean nested = false; // Whether we are currently serializing a table. - boolean finished = false; // Whether the buffer is finished. - int object_start; // Starting offset of the current struct/table. - int[] vtables = new int[16]; // List of offsets of all vtables. - int num_vtables = 0; // Number of entries in `vtables` in use. - int vector_num_elems = 0; // For the current vector being built. - boolean force_defaults = false; // False omits default values from the serialized data. - CharsetEncoder encoder = utf8charset.newEncoder(); - ByteBuffer dst; - /// @endcond - - /** - * Start with a buffer of size `initial_size`, then grow as required. - * - * @param initial_size The initial size of the internal buffer to use. - */ - public FlatBufferBuilder(int initial_size) { - if (initial_size <= 0) initial_size = 1; - space = initial_size; - bb = newByteBuffer(initial_size); - } - - /** - * Start with a buffer of 1KiB, then grow as required. - */ - public FlatBufferBuilder() { - this(1024); - } - - /** - * Alternative constructor allowing reuse of {@link ByteBuffer}s. The builder - * can still grow the buffer as necessary. User classes should make sure - * to call {@link #dataBuffer()} to obtain the resulting encoded message. - * - * @param existing_bb The byte buffer to reuse. - */ - public FlatBufferBuilder(ByteBuffer existing_bb) { - init(existing_bb); - } - - /** - * Alternative initializer that allows reusing this object on an existing - * `ByteBuffer`. This method resets the builder's internal state, but keeps - * objects that have been allocated for temporary storage. - * - * @param existing_bb The byte buffer to reuse. - * @return Returns `this`. - */ - public FlatBufferBuilder init(ByteBuffer existing_bb){ - bb = existing_bb; - bb.clear(); - bb.order(ByteOrder.LITTLE_ENDIAN); - minalign = 1; - space = bb.capacity(); - vtable_in_use = 0; - nested = false; - finished = false; - object_start = 0; - num_vtables = 0; - vector_num_elems = 0; - return this; - } - - /** - * Reset the FlatBufferBuilder by purging all data that it holds. - */ - public void clear(){ - space = bb.capacity(); - bb.clear(); - minalign = 1; - while(vtable_in_use > 0) vtable[--vtable_in_use] = 0; - vtable_in_use = 0; - nested = false; - finished = false; - object_start = 0; - num_vtables = 0; - vector_num_elems = 0; - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * Create a `ByteBuffer` with a given capacity. - * - * @param capacity The size of the `ByteBuffer` to allocate. - * @return Returns the new `ByteBuffer` that was allocated. - */ - static ByteBuffer newByteBuffer(int capacity) { - ByteBuffer newbb = ByteBuffer.allocate(capacity); - newbb.order(ByteOrder.LITTLE_ENDIAN); - return newbb; - } - - /** - * Doubles the size of the backing {@link ByteBuffer} and copies the old data towards the - * end of the new buffer (since we build the buffer backwards). - * - * @param bb The current buffer with the existing data. - * @return A new byte buffer with the old data copied copied to it. The data is - * located at the end of the buffer. - */ - static ByteBuffer growByteBuffer(ByteBuffer bb) { - int old_buf_size = bb.capacity(); - if ((old_buf_size & 0xC0000000) != 0) // Ensure we don't grow beyond what fits in an int. - throw new AssertionError("FlatBuffers: cannot grow buffer beyond 2 gigabytes."); - int new_buf_size = old_buf_size << 1; - bb.position(0); - ByteBuffer nbb = newByteBuffer(new_buf_size); - nbb.position(new_buf_size - old_buf_size); - nbb.put(bb); - return nbb; - } - - /** - * Offset relative to the end of the buffer. - * - * @return Offset relative to the end of the buffer. - */ - public int offset() { - return bb.capacity() - space; - } - - /** - * Add zero valued bytes to prepare a new entry to be added. - * - * @param byte_size Number of bytes to add. - */ - public void pad(int byte_size) { - for (int i = 0; i < byte_size; i++) bb.put(--space, (byte)0); - } - - /** - * Prepare to write an element of `size` after `additional_bytes` - * have been written, e.g. if you write a string, you need to align such - * the int length field is aligned to {@link com.google.flatbuffers.Constants#SIZEOF_INT}, and - * the string data follows it directly. If all you need to do is alignment, `additional_bytes` - * will be 0. - * - * @param size This is the of the new element to write. - * @param additional_bytes The padding size. - */ - public void prep(int size, int additional_bytes) { - // Track the biggest thing we've ever aligned to. - if (size > minalign) minalign = size; - // Find the amount of alignment needed such that `size` is properly - // aligned after `additional_bytes` - int align_size = ((~(bb.capacity() - space + additional_bytes)) + 1) & (size - 1); - // Reallocate the buffer if needed. - while (space < align_size + size + additional_bytes) { - int old_buf_size = bb.capacity(); - bb = growByteBuffer(bb); - space += bb.capacity() - old_buf_size; - } - pad(align_size); - } - - /** - * Add a `boolean` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `boolean` to put into the buffer. - */ - public void putBoolean(boolean x) { bb.put (space -= Constants.SIZEOF_BYTE, (byte)(x ? 1 : 0)); } - - /** - * Add a `byte` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `byte` to put into the buffer. - */ - public void putByte (byte x) { bb.put (space -= Constants.SIZEOF_BYTE, x); } - - /** - * Add a `short` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `short` to put into the buffer. - */ - public void putShort (short x) { bb.putShort (space -= Constants.SIZEOF_SHORT, x); } - - /** - * Add an `int` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x An `int` to put into the buffer. - */ - public void putInt (int x) { bb.putInt (space -= Constants.SIZEOF_INT, x); } - - /** - * Add a `long` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `long` to put into the buffer. - */ - public void putLong (long x) { bb.putLong (space -= Constants.SIZEOF_LONG, x); } - - /** - * Add a `float` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `float` to put into the buffer. - */ - public void putFloat (float x) { bb.putFloat (space -= Constants.SIZEOF_FLOAT, x); } - - /** - * Add a `double` to the buffer, backwards from the current location. Doesn't align nor - * check for space. - * - * @param x A `double` to put into the buffer. - */ - public void putDouble (double x) { bb.putDouble(space -= Constants.SIZEOF_DOUBLE, x); } - /// @endcond - - /** - * Add a `boolean` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `boolean` to put into the buffer. - */ - public void addBoolean(boolean x) { prep(Constants.SIZEOF_BYTE, 0); putBoolean(x); } - - /** - * Add a `byte` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `byte` to put into the buffer. - */ - public void addByte (byte x) { prep(Constants.SIZEOF_BYTE, 0); putByte (x); } - - /** - * Add a `short` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `short` to put into the buffer. - */ - public void addShort (short x) { prep(Constants.SIZEOF_SHORT, 0); putShort (x); } - - /** - * Add an `int` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x An `int` to put into the buffer. - */ - public void addInt (int x) { prep(Constants.SIZEOF_INT, 0); putInt (x); } - - /** - * Add a `long` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `long` to put into the buffer. - */ - public void addLong (long x) { prep(Constants.SIZEOF_LONG, 0); putLong (x); } - - /** - * Add a `float` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `float` to put into the buffer. - */ - public void addFloat (float x) { prep(Constants.SIZEOF_FLOAT, 0); putFloat (x); } - - /** - * Add a `double` to the buffer, properly aligned, and grows the buffer (if necessary). - * - * @param x A `double` to put into the buffer. - */ - public void addDouble (double x) { prep(Constants.SIZEOF_DOUBLE, 0); putDouble (x); } - - /** - * Adds on offset, relative to where it will be written. - * - * @param off The offset to add. - */ - public void addOffset(int off) { - prep(SIZEOF_INT, 0); // Ensure alignment is already done. - assert off <= offset(); - off = offset() - off + SIZEOF_INT; - putInt(off); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * Start a new array/vector of objects. Users usually will not call - * this directly. The `FlatBuffers` compiler will create a start/end - * method for vector types in generated code. - * <p> - * The expected sequence of calls is: - * <ol> - * <li>Start the array using this method.</li> - * <li>Call {@link #addOffset(int)} `num_elems` number of times to set - * the offset of each element in the array.</li> - * <li>Call {@link #endVector()} to retrieve the offset of the array.</li> - * </ol> - * <p> - * For example, to create an array of strings, do: - * <pre>{@code - * // Need 10 strings - * FlatBufferBuilder builder = new FlatBufferBuilder(existingBuffer); - * int[] offsets = new int[10]; - * - * for (int i = 0; i < 10; i++) { - * offsets[i] = fbb.createString(" " + i); - * } - * - * // Have the strings in the buffer, but don't have a vector. - * // Add a vector that references the newly created strings: - * builder.startVector(4, offsets.length, 4); - * - * // Add each string to the newly created vector - * // The strings are added in reverse order since the buffer - * // is filled in back to front - * for (int i = offsets.length - 1; i >= 0; i--) { - * builder.addOffset(offsets[i]); - * } - * - * // Finish off the vector - * int offsetOfTheVector = fbb.endVector(); - * }</pre> - * - * @param elem_size The size of each element in the array. - * @param num_elems The number of elements in the array. - * @param alignment The alignment of the array. - */ - public void startVector(int elem_size, int num_elems, int alignment) { - notNested(); - vector_num_elems = num_elems; - prep(SIZEOF_INT, elem_size * num_elems); - prep(alignment, elem_size * num_elems); // Just in case alignment > int. - nested = true; - } - - /** - * Finish off the creation of an array and all its elements. The array - * must be created with {@link #startVector(int, int, int)}. - * - * @return The offset at which the newly created array starts. - * @see #startVector(int, int, int) - */ - public int endVector() { - if (!nested) - throw new AssertionError("FlatBuffers: endVector called without startVector"); - nested = false; - putInt(vector_num_elems); - return offset(); - } - /// @endcond - - /** - * Create a new array/vector and return a ByteBuffer to be filled later. - * Call {@link #endVector} after this method to get an offset to the beginning - * of vector. - * - * @param elem_size the size of each element in bytes. - * @param num_elems number of elements in the vector. - * @param alignment byte alignment. - * @return ByteBuffer with position and limit set to the space allocated for the array. - */ - public ByteBuffer createUnintializedVector(int elem_size, int num_elems, int alignment) { - int length = elem_size * num_elems; - startVector(elem_size, num_elems, alignment); - - bb.position(space -= length); - - // Slice and limit the copy vector to point to the 'array' - ByteBuffer copy = bb.slice().order(ByteOrder.LITTLE_ENDIAN); - copy.limit(length); - return copy; - } - - /** - * Create a vector of tables. - * - * @param offsets Offsets of the tables. - * @return Returns offset of the vector. - */ - public int createVectorOfTables(int[] offsets) { - notNested(); - startVector(Constants.SIZEOF_INT, offsets.length, Constants.SIZEOF_INT); - for(int i = offsets.length - 1; i >= 0; i--) addOffset(offsets[i]); - return endVector(); - } - - /** - * Create a vector of sorted by the key tables. - * - * @param obj Instance of the table subclass. - * @param offsets Offsets of the tables. - * @return Returns offset of the sorted vector. - */ - public <T extends Table> int createSortedVectorOfTables(T obj, int[] offsets) { - obj.sortTables(offsets, bb); - return createVectorOfTables(offsets); - } - - /** - * Encode the string `s` in the buffer using UTF-8. If {@code s} is - * already a {@link CharBuffer}, this method is allocation free. - * - * @param s The string to encode. - * @return The offset in the buffer where the encoded string starts. - */ - public int createString(CharSequence s) { - int length = s.length(); - int estimatedDstCapacity = (int) (length * encoder.maxBytesPerChar()); - if (dst == null || dst.capacity() < estimatedDstCapacity) { - dst = ByteBuffer.allocate(Math.max(128, estimatedDstCapacity)); - } - - dst.clear(); - - CharBuffer src = s instanceof CharBuffer ? (CharBuffer) s : - CharBuffer.wrap(s); - CoderResult result = encoder.encode(src, dst, true); - if (result.isError()) { - try { - result.throwException(); - } catch (CharacterCodingException x) { - throw new Error(x); - } - } - - dst.flip(); - return createString(dst); - } - - /** - * Create a string in the buffer from an already encoded UTF-8 string in a ByteBuffer. - * - * @param s An already encoded UTF-8 string as a `ByteBuffer`. - * @return The offset in the buffer where the encoded string starts. - */ - public int createString(ByteBuffer s) { - int length = s.remaining(); - addByte((byte)0); - startVector(1, length, 1); - bb.position(space -= length); - bb.put(s); - return endVector(); - } - - /** - * Create a byte array in the buffer. - * - * @param arr A source array with data - * @return The offset in the buffer where the encoded array starts. - */ - public int createByteVector(byte[] arr) { - int length = arr.length; - startVector(1, length, 1); - bb.position(space -= length); - bb.put(arr); - return endVector(); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * Should not be accessing the final buffer before it is finished. - */ - public void finished() { - if (!finished) - throw new AssertionError( - "FlatBuffers: you can only access the serialized buffer after it has been" + - " finished by FlatBufferBuilder.finish()."); - } - - /** - * Should not be creating any other object, string or vector - * while an object is being constructed. - */ - public void notNested() { - if (nested) - throw new AssertionError("FlatBuffers: object serialization must not be nested."); - } - - /** - * Structures are always stored inline, they need to be created right - * where they're used. You'll get this assertion failure if you - * created it elsewhere. - * - * @param obj The offset of the created object. - */ - public void Nested(int obj) { - if (obj != offset()) - throw new AssertionError("FlatBuffers: struct must be serialized inline."); - } - - /** - * Start encoding a new object in the buffer. Users will not usually need to - * call this directly. The `FlatBuffers` compiler will generate helper methods - * that call this method internally. - * <p> - * For example, using the "Monster" code found on the "landing page". An - * object of type `Monster` can be created using the following code: - * - * <pre>{@code - * int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] { - * fbb.createString("test1"), - * fbb.createString("test2") - * }); - * - * Monster.startMonster(fbb); - * Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0, - * Color.Green, (short)5, (byte)6)); - * Monster.addHp(fbb, (short)80); - * Monster.addName(fbb, str); - * Monster.addInventory(fbb, inv); - * Monster.addTestType(fbb, (byte)Any.Monster); - * Monster.addTest(fbb, mon2); - * Monster.addTest4(fbb, test4); - * Monster.addTestarrayofstring(fbb, testArrayOfString); - * int mon = Monster.endMonster(fbb); - * }</pre> - * <p> - * Here: - * <ul> - * <li>The call to `Monster#startMonster(FlatBufferBuilder)` will call this - * method with the right number of fields set.</li> - * <li>`Monster#endMonster(FlatBufferBuilder)` will ensure {@link #endObject()} is called.</li> - * </ul> - * <p> - * It's not recommended to call this method directly. If it's called manually, you must ensure - * to audit all calls to it whenever fields are added or removed from your schema. This is - * automatically done by the code generated by the `FlatBuffers` compiler. - * - * @param numfields The number of fields found in this object. - */ - public void startObject(int numfields) { - notNested(); - if (vtable == null || vtable.length < numfields) vtable = new int[numfields]; - vtable_in_use = numfields; - Arrays.fill(vtable, 0, vtable_in_use, 0); - nested = true; - object_start = offset(); - } - - /** - * Add a `boolean` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `boolean` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `boolean` default value to compare against when `force_defaults` is `false`. - */ - public void addBoolean(int o, boolean x, boolean d) { if(force_defaults || x != d) { addBoolean(x); slot(o); } } - - /** - * Add a `byte` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `byte` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `byte` default value to compare against when `force_defaults` is `false`. - */ - public void addByte (int o, byte x, int d) { if(force_defaults || x != d) { addByte (x); slot(o); } } - - /** - * Add a `short` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `short` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `short` default value to compare against when `force_defaults` is `false`. - */ - public void addShort (int o, short x, int d) { if(force_defaults || x != d) { addShort (x); slot(o); } } - - /** - * Add an `int` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x An `int` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d An `int` default value to compare against when `force_defaults` is `false`. - */ - public void addInt (int o, int x, int d) { if(force_defaults || x != d) { addInt (x); slot(o); } } - - /** - * Add a `long` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `long` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `long` default value to compare against when `force_defaults` is `false`. - */ - public void addLong (int o, long x, long d) { if(force_defaults || x != d) { addLong (x); slot(o); } } - - /** - * Add a `float` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `float` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `float` default value to compare against when `force_defaults` is `false`. - */ - public void addFloat (int o, float x, double d) { if(force_defaults || x != d) { addFloat (x); slot(o); } } - - /** - * Add a `double` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x A `double` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d A `double` default value to compare against when `force_defaults` is `false`. - */ - public void addDouble (int o, double x, double d) { if(force_defaults || x != d) { addDouble (x); slot(o); } } - - /** - * Add an `offset` to a table at `o` into its vtable, with value `x` and default `d`. - * - * @param o The index into the vtable. - * @param x An `offset` to put into the buffer, depending on how defaults are handled. If - * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the - * default value, it can be skipped. - * @param d An `offset` default value to compare against when `force_defaults` is `false`. - */ - public void addOffset (int o, int x, int d) { if(force_defaults || x != d) { addOffset (x); slot(o); } } - - /** - * Add a struct to the table. Structs are stored inline, so nothing additional is being added. - * - * @param voffset The index into the vtable. - * @param x The offset of the created struct. - * @param d The default value is always `0`. - */ - public void addStruct(int voffset, int x, int d) { - if(x != d) { - Nested(x); - slot(voffset); - } - } - - /** - * Set the current vtable at `voffset` to the current location in the buffer. - * - * @param voffset The index into the vtable to store the offset relative to the end of the - * buffer. - */ - public void slot(int voffset) { - vtable[voffset] = offset(); - } - - /** - * Finish off writing the object that is under construction. - * - * @return The offset to the object inside {@link #dataBuffer()}. - * @see #startObject(int) - */ - public int endObject() { - if (vtable == null || !nested) - throw new AssertionError("FlatBuffers: endObject called without startObject"); - addInt(0); - int vtableloc = offset(); - // Write out the current vtable. - for (int i = vtable_in_use - 1; i >= 0 ; i--) { - // Offset relative to the start of the table. - short off = (short)(vtable[i] != 0 ? vtableloc - vtable[i] : 0); - addShort(off); - } - - final int standard_fields = 2; // The fields below: - addShort((short)(vtableloc - object_start)); - addShort((short)((vtable_in_use + standard_fields) * SIZEOF_SHORT)); - - // Search for an existing vtable that matches the current one. - int existing_vtable = 0; - outer_loop: - for (int i = 0; i < num_vtables; i++) { - int vt1 = bb.capacity() - vtables[i]; - int vt2 = space; - short len = bb.getShort(vt1); - if (len == bb.getShort(vt2)) { - for (int j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) { - if (bb.getShort(vt1 + j) != bb.getShort(vt2 + j)) { - continue outer_loop; - } - } - existing_vtable = vtables[i]; - break outer_loop; - } - } - - if (existing_vtable != 0) { - // Found a match: - // Remove the current vtable. - space = bb.capacity() - vtableloc; - // Point table to existing vtable. - bb.putInt(space, existing_vtable - vtableloc); - } else { - // No match: - // Add the location of the current vtable to the list of vtables. - if (num_vtables == vtables.length) vtables = Arrays.copyOf(vtables, num_vtables * 2); - vtables[num_vtables++] = offset(); - // Point table to current vtable. - bb.putInt(bb.capacity() - vtableloc, offset() - vtableloc); - } - - nested = false; - return vtableloc; - } - - /** - * Checks that a required field has been set in a given table that has - * just been constructed. - * - * @param table The offset to the start of the table from the `ByteBuffer` capacity. - * @param field The offset to the field in the vtable. - */ - public void required(int table, int field) { - int table_start = bb.capacity() - table; - int vtable_start = table_start - bb.getInt(table_start); - boolean ok = bb.getShort(vtable_start + field) != 0; - // If this fails, the caller will show what field needs to be set. - if (!ok) - throw new AssertionError("FlatBuffers: field " + field + " must be set"); - } - /// @endcond - - /** - * Finalize a buffer, pointing to the given `root_table`. - * - * @param root_table An offset to be added to the buffer. - */ - public void finish(int root_table) { - prep(minalign, SIZEOF_INT); - addOffset(root_table); - bb.position(space); - finished = true; - } - - /** - * Finalize a buffer, pointing to the given `root_table`. - * - * @param root_table An offset to be added to the buffer. - * @param file_identifier A FlatBuffer file identifier to be added to the buffer before - * `root_table`. - */ - public void finish(int root_table, String file_identifier) { - prep(minalign, SIZEOF_INT + FILE_IDENTIFIER_LENGTH); - if (file_identifier.length() != FILE_IDENTIFIER_LENGTH) - throw new AssertionError("FlatBuffers: file identifier must be length " + - FILE_IDENTIFIER_LENGTH); - for (int i = FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) { - addByte((byte)file_identifier.charAt(i)); - } - finish(root_table); - } - - /** - * In order to save space, fields that are set to their default value - * don't get serialized into the buffer. Forcing defaults provides a - * way to manually disable this optimization. - * - * @param forceDefaults When set to `true`, always serializes default values. - * @return Returns `this`. - */ - public FlatBufferBuilder forceDefaults(boolean forceDefaults){ - this.force_defaults = forceDefaults; - return this; - } - - /** - * Get the ByteBuffer representing the FlatBuffer. Only call this after you've - * called `finish()`. The actual data starts at the ByteBuffer's current position, - * not necessarily at `0`. - * - * @return The {@link ByteBuffer} representing the FlatBuffer - */ - public ByteBuffer dataBuffer() { - finished(); - return bb; - } - - /** - * The FlatBuffer data doesn't start at offset 0 in the {@link ByteBuffer}, but - * now the {@code ByteBuffer}'s position is set to that location upon {@link #finish(int)}. - * - * @return The {@link ByteBuffer#position() position} the data starts in {@link #dataBuffer()} - * @deprecated This method should not be needed anymore, but is left - * here for the moment to document this API change. It will be removed in the future. - */ - @Deprecated - private int dataStart() { - finished(); - return space; - } - - /** - * A utility function to copy and return the ByteBuffer data from `start` to - * `start` + `length` as a `byte[]`. - * - * @param start Start copying at this offset. - * @param length How many bytes to copy. - * @return A range copy of the {@link #dataBuffer() data buffer}. - * @throws IndexOutOfBoundsException If the range of bytes is ouf of bound. - */ - public byte[] sizedByteArray(int start, int length){ - finished(); - byte[] array = new byte[length]; - bb.position(start); - bb.get(array); - return array; - } - - /** - * A utility function to copy and return the ByteBuffer data as a `byte[]`. - * - * @return A full copy of the {@link #dataBuffer() data buffer}. - */ - public byte[] sizedByteArray() { - return sizedByteArray(space, bb.capacity() - space); - } -} - -/// @}
diff --git a/third_party/flatbuffers/java/com/google/flatbuffers/Struct.java b/third_party/flatbuffers/java/com/google/flatbuffers/Struct.java deleted file mode 100644 index ae31553..0000000 --- a/third_party/flatbuffers/java/com/google/flatbuffers/Struct.java +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.flatbuffers; - -import java.nio.ByteBuffer; - -/// @cond FLATBUFFERS_INTERNAL - -/** - * All structs in the generated code derive from this class, and add their own accessors. - */ -public class Struct { - /** Used to hold the position of the `bb` buffer. */ - protected int bb_pos; - /** The underlying ByteBuffer to hold the data of the Struct. */ - protected ByteBuffer bb; -} - -/// @endcond
diff --git a/third_party/flatbuffers/java/com/google/flatbuffers/Table.java b/third_party/flatbuffers/java/com/google/flatbuffers/Table.java deleted file mode 100644 index b853842..0000000 --- a/third_party/flatbuffers/java/com/google/flatbuffers/Table.java +++ /dev/null
@@ -1,278 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.flatbuffers; - -import static com.google.flatbuffers.Constants.*; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CoderResult; - -/// @cond FLATBUFFERS_INTERNAL - -/** - * All tables in the generated code derive from this class, and add their own accessors. - */ -public class Table { - private final static ThreadLocal<CharsetDecoder> UTF8_DECODER = new ThreadLocal<CharsetDecoder>() { - @Override - protected CharsetDecoder initialValue() { - return Charset.forName("UTF-8").newDecoder(); - } - }; - public final static ThreadLocal<Charset> UTF8_CHARSET = new ThreadLocal<Charset>() { - @Override - protected Charset initialValue() { - return Charset.forName("UTF-8"); - } - }; - private final static ThreadLocal<CharBuffer> CHAR_BUFFER = new ThreadLocal<CharBuffer>(); - /** Used to hold the position of the `bb` buffer. */ - protected int bb_pos; - /** The underlying ByteBuffer to hold the data of the Table. */ - protected ByteBuffer bb; - - /** - * Get the underlying ByteBuffer. - * - * @return Returns the Table's ByteBuffer. - */ - public ByteBuffer getByteBuffer() { return bb; } - - /** - * Look up a field in the vtable. - * - * @param vtable_offset An `int` offset to the vtable in the Table's ByteBuffer. - * @return Returns an offset into the object, or `0` if the field is not present. - */ - protected int __offset(int vtable_offset) { - int vtable = bb_pos - bb.getInt(bb_pos); - return vtable_offset < bb.getShort(vtable) ? bb.getShort(vtable + vtable_offset) : 0; - } - - protected static int __offset(int vtable_offset, int offset, ByteBuffer bb) { - int vtable = bb.array().length - offset; - return bb.getShort(vtable + vtable_offset - bb.getInt(vtable)) + vtable; - } - - /** - * Retrieve a relative offset. - * - * @param offset An `int` index into the Table's ByteBuffer containing the relative offset. - * @return Returns the relative offset stored at `offset`. - */ - protected int __indirect(int offset) { - return offset + bb.getInt(offset); - } - - protected static int __indirect(int offset, ByteBuffer bb) { - return offset + bb.getInt(offset); - } - - /** - * Create a Java `String` from UTF-8 data stored inside the FlatBuffer. - * - * This allocates a new string and converts to wide chars upon each access, - * which is not very efficient. Instead, each FlatBuffer string also comes with an - * accessor based on __vector_as_bytebuffer below, which is much more efficient, - * assuming your Java program can handle UTF-8 data directly. - * - * @param offset An `int` index into the Table's ByteBuffer. - * @return Returns a `String` from the data stored inside the FlatBuffer at `offset`. - */ - protected String __string(int offset) { - CharsetDecoder decoder = UTF8_DECODER.get(); - decoder.reset(); - - offset += bb.getInt(offset); - ByteBuffer src = bb.duplicate().order(ByteOrder.LITTLE_ENDIAN); - int length = src.getInt(offset); - src.position(offset + SIZEOF_INT); - src.limit(offset + SIZEOF_INT + length); - - int required = (int)((float)length * decoder.maxCharsPerByte()); - CharBuffer dst = CHAR_BUFFER.get(); - if (dst == null || dst.capacity() < required) { - dst = CharBuffer.allocate(required); - CHAR_BUFFER.set(dst); - } - - dst.clear(); - - try { - CoderResult cr = decoder.decode(src, dst, true); - if (!cr.isUnderflow()) { - cr.throwException(); - } - } catch (CharacterCodingException x) { - throw new Error(x); - } - - return dst.flip().toString(); - } - - /** - * Get the length of a vector. - * - * @param offset An `int` index into the Table's ByteBuffer. - * @return Returns the length of the vector whose offset is stored at `offset`. - */ - protected int __vector_len(int offset) { - offset += bb_pos; - offset += bb.getInt(offset); - return bb.getInt(offset); - } - - /** - * Get the start data of a vector. - * - * @param offset An `int` index into the Table's ByteBuffer. - * @return Returns the start of the vector data whose offset is stored at `offset`. - */ - protected int __vector(int offset) { - offset += bb_pos; - return offset + bb.getInt(offset) + SIZEOF_INT; // data starts after the length - } - - /** - * Get a whole vector as a ByteBuffer. - * - * This is efficient, since it only allocates a new {@link ByteBuffer} object, - * but does not actually copy the data, it still refers to the same bytes - * as the original ByteBuffer. Also useful with nested FlatBuffers, etc. - * - * @param vector_offset The position of the vector in the byte buffer - * @param elem_size The size of each element in the array - * @return The {@link ByteBuffer} for the array - */ - protected ByteBuffer __vector_as_bytebuffer(int vector_offset, int elem_size) { - int o = __offset(vector_offset); - if (o == 0) return null; - ByteBuffer bb = this.bb.duplicate().order(ByteOrder.LITTLE_ENDIAN); - int vectorstart = __vector(o); - bb.position(vectorstart); - bb.limit(vectorstart + __vector_len(o) * elem_size); - return bb; - } - - /** - * Initialize any Table-derived type to point to the union at the given `offset`. - * - * @param t A `Table`-derived type that should point to the union at `offset`. - * @param offset An `int` index into the Table's ByteBuffer. - * @return Returns the Table that points to the union at `offset`. - */ - protected Table __union(Table t, int offset) { - offset += bb_pos; - t.bb_pos = offset + bb.getInt(offset); - t.bb = bb; - return t; - } - - /** - * Check if a {@link ByteBuffer} contains a file identifier. - * - * @param bb A {@code ByteBuffer} to check if it contains the identifier - * `ident`. - * @param ident A `String` identifier of the FlatBuffer file. - * @return True if the buffer contains the file identifier - */ - protected static boolean __has_identifier(ByteBuffer bb, String ident) { - if (ident.length() != FILE_IDENTIFIER_LENGTH) - throw new AssertionError("FlatBuffers: file identifier must be length " + - FILE_IDENTIFIER_LENGTH); - for (int i = 0; i < FILE_IDENTIFIER_LENGTH; i++) { - if (ident.charAt(i) != (char)bb.get(bb.position() + SIZEOF_INT + i)) return false; - } - return true; - } - - /** - * Sort tables by the key. - * - * @param offsets An 'int' indexes of the tables into the bb. - * @param bb A {@code ByteBuffer} to get the tables. - */ - protected void sortTables(int[] offsets, final ByteBuffer bb) { - Integer[] off = new Integer[offsets.length]; - for (int i = 0; i < offsets.length; i++) off[i] = offsets[i]; - java.util.Arrays.sort(off, new java.util.Comparator<Integer>() { - public int compare(Integer o1, Integer o2) { - return keysCompare(o1, o2, bb); - } - }); - for (int i = 0; i < offsets.length; i++) offsets[i] = off[i]; - } - - /** - * Compare two tables by the key. - * - * @param o1 An 'Integer' index of the first key into the bb. - * @param o2 An 'Integer' index of the second key into the bb. - * @param bb A {@code ByteBuffer} to get the keys. - */ - protected int keysCompare(Integer o1, Integer o2, ByteBuffer bb) { return 0; } - - /** - * Compare two strings in the buffer. - * - * @param offset_1 An 'int' index of the first string into the bb. - * @param offset_2 An 'int' index of the second string into the bb. - * @param bb A {@code ByteBuffer} to get the strings. - */ - protected static int compareStrings(int offset_1, int offset_2, ByteBuffer bb) { - offset_1 += bb.getInt(offset_1); - offset_2 += bb.getInt(offset_2); - int len_1 = bb.getInt(offset_1); - int len_2 = bb.getInt(offset_2); - int startPos_1 = offset_1 + SIZEOF_INT; - int startPos_2 = offset_2 + SIZEOF_INT; - int len = Math.min(len_1, len_2); - byte[] bbArray = bb.array(); - for(int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != bbArray[i + startPos_2]) - return bbArray[i + startPos_1] - bbArray[i + startPos_2]; - } - return len_1 - len_2; - } - - /** - * Compare string from the buffer with the 'String' object. - * - * @param offset_1 An 'int' index of the first string into the bb. - * @param key Second string as a byte array. - * @param bb A {@code ByteBuffer} to get the first string. - */ - protected static int compareStrings(int offset_1, byte[] key, ByteBuffer bb) { - offset_1 += bb.getInt(offset_1); - int len_1 = bb.getInt(offset_1); - int len_2 = key.length; - int startPos_1 = offset_1 + Constants.SIZEOF_INT; - int len = Math.min(len_1, len_2); - byte[] bbArray = bb.array(); - for (int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != key[i]) - return bbArray[i + startPos_1] - key[i]; - } - return len_1 - len_2; - } -} - -/// @endcond
diff --git a/third_party/flatbuffers/js/flatbuffers.js b/third_party/flatbuffers/js/flatbuffers.js deleted file mode 100644 index ccbd362..0000000 --- a/third_party/flatbuffers/js/flatbuffers.js +++ /dev/null
@@ -1,1196 +0,0 @@ -/// @file -/// @addtogroup flatbuffers_javascript_api -/// @{ -/// @cond FLATBUFFERS_INTERNAL - -/** - * @fileoverview - * - * Need to suppress 'global this' error so the Node.js export line doesn't cause - * closure compile to error out. - * @suppress {globalThis} - */ - -/** - * @const - * @namespace - */ -var flatbuffers = {}; - -/** - * @typedef {number} - */ -flatbuffers.Offset; - -/** - * @typedef {{ - * bb: flatbuffers.ByteBuffer, - * bb_pos: number - * }} - */ -flatbuffers.Table; - -/** - * @type {number} - * @const - */ -flatbuffers.SIZEOF_SHORT = 2; - -/** - * @type {number} - * @const - */ -flatbuffers.SIZEOF_INT = 4; - -/** - * @type {number} - * @const - */ -flatbuffers.FILE_IDENTIFIER_LENGTH = 4; - -/** - * @enum {number} - */ -flatbuffers.Encoding = { - UTF8_BYTES: 1, - UTF16_STRING: 2 -}; - -/** - * @type {Int32Array} - * @const - */ -flatbuffers.int32 = new Int32Array(2); - -/** - * @type {Float32Array} - * @const - */ -flatbuffers.float32 = new Float32Array(flatbuffers.int32.buffer); - -/** - * @type {Float64Array} - * @const - */ -flatbuffers.float64 = new Float64Array(flatbuffers.int32.buffer); - -/** - * @type {boolean} - * @const - */ -flatbuffers.isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1; - -//////////////////////////////////////////////////////////////////////////////// - -/** - * @constructor - * @param {number} low - * @param {number} high - */ -flatbuffers.Long = function(low, high) { - /** - * @type {number} - * @const - */ - this.low = low | 0; - - /** - * @type {number} - * @const - */ - this.high = high | 0; -}; - -/** - * @param {number} low - * @param {number} high - * @returns {flatbuffers.Long} - */ -flatbuffers.Long.create = function(low, high) { - // Special-case zero to avoid GC overhead for default values - return low == 0 && high == 0 ? flatbuffers.Long.ZERO : new flatbuffers.Long(low, high); -}; - -/** - * @returns {number} - */ -flatbuffers.Long.prototype.toFloat64 = function() { - return (this.low >>> 0) + this.high * 0x100000000; -}; - -/** - * @param {flatbuffers.Long} other - * @returns {boolean} - */ -flatbuffers.Long.prototype.equals = function(other) { - return this.low == other.low && this.high == other.high; -}; - -/** - * @type {flatbuffers.Long} - * @const - */ -flatbuffers.Long.ZERO = new flatbuffers.Long(0, 0); - -/// @endcond -//////////////////////////////////////////////////////////////////////////////// -/** - * Create a FlatBufferBuilder. - * - * @constructor - * @param {number=} opt_initial_size - */ -flatbuffers.Builder = function(opt_initial_size) { - if (!opt_initial_size) { - var initial_size = 1024; - } else { - var initial_size = opt_initial_size; - } - - /** - * @type {flatbuffers.ByteBuffer} - * @private - */ - this.bb = flatbuffers.ByteBuffer.allocate(initial_size); - - /** - * Remaining space in the ByteBuffer. - * - * @type {number} - * @private - */ - this.space = initial_size; - - /** - * Minimum alignment encountered so far. - * - * @type {number} - * @private - */ - this.minalign = 1; - - /** - * The vtable for the current table. - * - * @type {Array.<number>} - * @private - */ - this.vtable = null; - - /** - * The amount of fields we're actually using. - * - * @type {number} - * @private - */ - this.vtable_in_use = 0; - - /** - * Whether we are currently serializing a table. - * - * @type {boolean} - * @private - */ - this.isNested = false; - - /** - * Starting offset of the current struct/table. - * - * @type {number} - * @private - */ - this.object_start = 0; - - /** - * List of offsets of all vtables. - * - * @type {Array.<number>} - * @private - */ - this.vtables = []; - - /** - * For the current vector being built. - * - * @type {number} - * @private - */ - this.vector_num_elems = 0; - - /** - * False omits default values from the serialized data - * - * @type {boolean} - * @private - */ - this.force_defaults = false; -}; - -/** - * In order to save space, fields that are set to their default value - * don't get serialized into the buffer. Forcing defaults provides a - * way to manually disable this optimization. - * - * @param {boolean} forceDefaults true always serializes default values - */ -flatbuffers.Builder.prototype.forceDefaults = function(forceDefaults) { - this.force_defaults = forceDefaults; -}; - -/** - * Get the ByteBuffer representing the FlatBuffer. Only call this after you've - * called finish(). The actual data starts at the ByteBuffer's current position, - * not necessarily at 0. - * - * @returns {flatbuffers.ByteBuffer} - */ -flatbuffers.Builder.prototype.dataBuffer = function() { - return this.bb; -}; - -/** - * Get the bytes representing the FlatBuffer. Only call this after you've - * called finish(). - * - * @returns {Uint8Array} - */ -flatbuffers.Builder.prototype.asUint8Array = function() { - return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset()); -}; - -/// @cond FLATBUFFERS_INTERNAL -/** - * Prepare to write an element of `size` after `additional_bytes` have been - * written, e.g. if you write a string, you need to align such the int length - * field is aligned to 4 bytes, and the string data follows it directly. If all - * you need to do is alignment, `additional_bytes` will be 0. - * - * @param {number} size This is the of the new element to write - * @param {number} additional_bytes The padding size - */ -flatbuffers.Builder.prototype.prep = function(size, additional_bytes) { - // Track the biggest thing we've ever aligned to. - if (size > this.minalign) { - this.minalign = size; - } - - // Find the amount of alignment needed such that `size` is properly - // aligned after `additional_bytes` - var align_size = ((~(this.bb.capacity() - this.space + additional_bytes)) + 1) & (size - 1); - - // Reallocate the buffer if needed. - while (this.space < align_size + size + additional_bytes) { - var old_buf_size = this.bb.capacity(); - this.bb = flatbuffers.Builder.growByteBuffer(this.bb); - this.space += this.bb.capacity() - old_buf_size; - } - - this.pad(align_size); -}; - -/** - * @param {number} byte_size - */ -flatbuffers.Builder.prototype.pad = function(byte_size) { - for (var i = 0; i < byte_size; i++) { - this.bb.writeInt8(--this.space, 0); - } -}; - -/** - * @param {number} value - */ -flatbuffers.Builder.prototype.writeInt8 = function(value) { - this.bb.writeInt8(this.space -= 1, value); -}; - -/** - * @param {number} value - */ -flatbuffers.Builder.prototype.writeInt16 = function(value) { - this.bb.writeInt16(this.space -= 2, value); -}; - -/** - * @param {number} value - */ -flatbuffers.Builder.prototype.writeInt32 = function(value) { - this.bb.writeInt32(this.space -= 4, value); -}; - -/** - * @param {flatbuffers.Long} value - */ -flatbuffers.Builder.prototype.writeInt64 = function(value) { - this.bb.writeInt64(this.space -= 8, value); -}; - -/** - * @param {number} value - */ -flatbuffers.Builder.prototype.writeFloat32 = function(value) { - this.bb.writeFloat32(this.space -= 4, value); -}; - -/** - * @param {number} value - */ -flatbuffers.Builder.prototype.writeFloat64 = function(value) { - this.bb.writeFloat64(this.space -= 8, value); -}; -/// @endcond - -/** - * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {number} value The `int8` to add the the buffer. - */ -flatbuffers.Builder.prototype.addInt8 = function(value) { - this.prep(1, 0); - this.writeInt8(value); -}; - -/** - * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {number} value The `int16` to add the the buffer. - */ -flatbuffers.Builder.prototype.addInt16 = function(value) { - this.prep(2, 0); - this.writeInt16(value); -}; - -/** - * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {number} value The `int32` to add the the buffer. - */ -flatbuffers.Builder.prototype.addInt32 = function(value) { - this.prep(4, 0); - this.writeInt32(value); -}; - -/** - * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {flatbuffers.Long} value The `int64` to add the the buffer. - */ -flatbuffers.Builder.prototype.addInt64 = function(value) { - this.prep(8, 0); - this.writeInt64(value); -}; - -/** - * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {number} value The `float32` to add the the buffer. - */ -flatbuffers.Builder.prototype.addFloat32 = function(value) { - this.prep(4, 0); - this.writeFloat32(value); -}; - -/** - * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param {number} value The `float64` to add the the buffer. - */ -flatbuffers.Builder.prototype.addFloat64 = function(value) { - this.prep(8, 0); - this.writeFloat64(value); -}; - -/// @cond FLATBUFFERS_INTERNAL -/** - * @param {number} voffset - * @param {number} value - * @param {number} defaultValue - */ -flatbuffers.Builder.prototype.addFieldInt8 = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addInt8(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {number} value - * @param {number} defaultValue - */ -flatbuffers.Builder.prototype.addFieldInt16 = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addInt16(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {number} value - * @param {number} defaultValue - */ -flatbuffers.Builder.prototype.addFieldInt32 = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addInt32(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {flatbuffers.Long} value - * @param {flatbuffers.Long} defaultValue - */ -flatbuffers.Builder.prototype.addFieldInt64 = function(voffset, value, defaultValue) { - if (this.force_defaults || !value.equals(defaultValue)) { - this.addInt64(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {number} value - * @param {number} defaultValue - */ -flatbuffers.Builder.prototype.addFieldFloat32 = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addFloat32(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {number} value - * @param {number} defaultValue - */ -flatbuffers.Builder.prototype.addFieldFloat64 = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addFloat64(value); - this.slot(voffset); - } -}; - -/** - * @param {number} voffset - * @param {flatbuffers.Offset} value - * @param {flatbuffers.Offset} defaultValue - */ -flatbuffers.Builder.prototype.addFieldOffset = function(voffset, value, defaultValue) { - if (this.force_defaults || value != defaultValue) { - this.addOffset(value); - this.slot(voffset); - } -}; - -/** - * Structs are stored inline, so nothing additional is being added. `d` is always 0. - * - * @param {number} voffset - * @param {flatbuffers.Offset} value - * @param {flatbuffers.Offset} defaultValue - */ -flatbuffers.Builder.prototype.addFieldStruct = function(voffset, value, defaultValue) { - if (value != defaultValue) { - this.nested(value); - this.slot(voffset); - } -}; - -/** - * Structures are always stored inline, they need to be created right - * where they're used. You'll get this assertion failure if you - * created it elsewhere. - * - * @param {flatbuffers.Offset} obj The offset of the created object - */ -flatbuffers.Builder.prototype.nested = function(obj) { - if (obj != this.offset()) { - throw new Error('FlatBuffers: struct must be serialized inline.'); - } -}; - -/** - * Should not be creating any other object, string or vector - * while an object is being constructed - */ -flatbuffers.Builder.prototype.notNested = function() { - if (this.isNested) { - throw new Error('FlatBuffers: object serialization must not be nested.'); - } -}; - -/** - * Set the current vtable at `voffset` to the current location in the buffer. - * - * @param {number} voffset - */ -flatbuffers.Builder.prototype.slot = function(voffset) { - this.vtable[voffset] = this.offset(); -}; - -/** - * @returns {flatbuffers.Offset} Offset relative to the end of the buffer. - */ -flatbuffers.Builder.prototype.offset = function() { - return this.bb.capacity() - this.space; -}; - -/** - * Doubles the size of the backing ByteBuffer and copies the old data towards - * the end of the new buffer (since we build the buffer backwards). - * - * @param {flatbuffers.ByteBuffer} bb The current buffer with the existing data - * @returns {flatbuffers.ByteBuffer} A new byte buffer with the old data copied - * to it. The data is located at the end of the buffer. - * - * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass - * it a uint8Array we need to suppress the type check: - * @suppress {checkTypes} - */ -flatbuffers.Builder.growByteBuffer = function(bb) { - var old_buf_size = bb.capacity(); - - // Ensure we don't grow beyond what fits in an int. - if (old_buf_size & 0xC0000000) { - throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.'); - } - - var new_buf_size = old_buf_size << 1; - var nbb = flatbuffers.ByteBuffer.allocate(new_buf_size); - nbb.setPosition(new_buf_size - old_buf_size); - nbb.bytes().set(bb.bytes(), new_buf_size - old_buf_size); - return nbb; -}; -/// @endcond - -/** - * Adds on offset, relative to where it will be written. - * - * @param {flatbuffers.Offset} offset The offset to add. - */ -flatbuffers.Builder.prototype.addOffset = function(offset) { - this.prep(flatbuffers.SIZEOF_INT, 0); // Ensure alignment is already done. - this.writeInt32(this.offset() - offset + flatbuffers.SIZEOF_INT); -}; - -/// @cond FLATBUFFERS_INTERNAL -/** - * Start encoding a new object in the buffer. Users will not usually need to - * call this directly. The FlatBuffers compiler will generate helper methods - * that call this method internally. - * - * @param {number} numfields - */ -flatbuffers.Builder.prototype.startObject = function(numfields) { - this.notNested(); - if (this.vtable == null) { - this.vtable = []; - } - this.vtable_in_use = numfields; - for (var i = 0; i < numfields; i++) { - this.vtable[i] = 0; // This will push additional elements as needed - } - this.isNested = true; - this.object_start = this.offset(); -}; - -/** - * Finish off writing the object that is under construction. - * - * @returns {flatbuffers.Offset} The offset to the object inside `dataBuffer` - */ -flatbuffers.Builder.prototype.endObject = function() { - if (this.vtable == null || !this.isNested) { - throw new Error('FlatBuffers: endObject called without startObject'); - } - - this.addInt32(0); - var vtableloc = this.offset(); - - // Write out the current vtable. - for (var i = this.vtable_in_use - 1; i >= 0; i--) { - // Offset relative to the start of the table. - this.addInt16(this.vtable[i] != 0 ? vtableloc - this.vtable[i] : 0); - } - - var standard_fields = 2; // The fields below: - this.addInt16(vtableloc - this.object_start); - this.addInt16((this.vtable_in_use + standard_fields) * flatbuffers.SIZEOF_SHORT); - - // Search for an existing vtable that matches the current one. - var existing_vtable = 0; -outer_loop: - for (var i = 0; i < this.vtables.length; i++) { - var vt1 = this.bb.capacity() - this.vtables[i]; - var vt2 = this.space; - var len = this.bb.readInt16(vt1); - if (len == this.bb.readInt16(vt2)) { - for (var j = flatbuffers.SIZEOF_SHORT; j < len; j += flatbuffers.SIZEOF_SHORT) { - if (this.bb.readInt16(vt1 + j) != this.bb.readInt16(vt2 + j)) { - continue outer_loop; - } - } - existing_vtable = this.vtables[i]; - break; - } - } - - if (existing_vtable) { - // Found a match: - // Remove the current vtable. - this.space = this.bb.capacity() - vtableloc; - - // Point table to existing vtable. - this.bb.writeInt32(this.space, existing_vtable - vtableloc); - } else { - // No match: - // Add the location of the current vtable to the list of vtables. - this.vtables.push(this.offset()); - - // Point table to current vtable. - this.bb.writeInt32(this.bb.capacity() - vtableloc, this.offset() - vtableloc); - } - - this.isNested = false; - return vtableloc; -}; -/// @endcond - -/** - * Finalize a buffer, poiting to the given `root_table`. - * - * @param {flatbuffers.Offset} root_table - * @param {string=} opt_file_identifier - */ -flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier) { - if (opt_file_identifier) { - var file_identifier = opt_file_identifier; - this.prep(this.minalign, flatbuffers.SIZEOF_INT + - flatbuffers.FILE_IDENTIFIER_LENGTH); - if (file_identifier.length != flatbuffers.FILE_IDENTIFIER_LENGTH) { - throw new Error('FlatBuffers: file identifier must be length ' + - flatbuffers.FILE_IDENTIFIER_LENGTH); - } - for (var i = flatbuffers.FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) { - this.writeInt8(file_identifier.charCodeAt(i)); - } - } - this.prep(this.minalign, flatbuffers.SIZEOF_INT); - this.addOffset(root_table); - this.bb.setPosition(this.space); -}; - -/// @cond FLATBUFFERS_INTERNAL -/** - * This checks a required field has been set in a given table that has - * just been constructed. - * - * @param {flatbuffers.Offset} table - * @param {number} field - */ -flatbuffers.Builder.prototype.requiredField = function(table, field) { - var table_start = this.bb.capacity() - table; - var vtable_start = table_start - this.bb.readInt32(table_start); - var ok = this.bb.readInt16(vtable_start + field) != 0; - - // If this fails, the caller will show what field needs to be set. - if (!ok) { - throw new Error('FlatBuffers: field ' + field + ' must be set'); - } -}; - -/** - * Start a new array/vector of objects. Users usually will not call - * this directly. The FlatBuffers compiler will create a start/end - * method for vector types in generated code. - * - * @param {number} elem_size The size of each element in the array - * @param {number} num_elems The number of elements in the array - * @param {number} alignment The alignment of the array - */ -flatbuffers.Builder.prototype.startVector = function(elem_size, num_elems, alignment) { - this.notNested(); - this.vector_num_elems = num_elems; - this.prep(flatbuffers.SIZEOF_INT, elem_size * num_elems); - this.prep(alignment, elem_size * num_elems); // Just in case alignment > int. -}; - -/** - * Finish off the creation of an array and all its elements. The array must be - * created with `startVector`. - * - * @returns {flatbuffers.Offset} The offset at which the newly created array - * starts. - */ -flatbuffers.Builder.prototype.endVector = function() { - this.writeInt32(this.vector_num_elems); - return this.offset(); -}; -/// @endcond - -/** - * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed - * instead of a string, it is assumed to contain valid UTF-8 encoded data. - * - * @param {string|Uint8Array} s The string to encode - * @return {flatbuffers.Offset} The offset in the buffer where the encoded string starts - */ -flatbuffers.Builder.prototype.createString = function(s) { - if (s instanceof Uint8Array) { - var utf8 = s; - } else { - var utf8 = []; - var i = 0; - - while (i < s.length) { - var codePoint; - - // Decode UTF-16 - var a = s.charCodeAt(i++); - if (a < 0xD800 || a >= 0xDC00) { - codePoint = a; - } else { - var b = s.charCodeAt(i++); - codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00); - } - - // Encode UTF-8 - if (codePoint < 0x80) { - utf8.push(codePoint); - } else { - if (codePoint < 0x800) { - utf8.push(((codePoint >> 6) & 0x1F) | 0xC0); - } else { - if (codePoint < 0x10000) { - utf8.push(((codePoint >> 12) & 0x0F) | 0xE0); - } else { - utf8.push( - ((codePoint >> 18) & 0x07) | 0xF0, - ((codePoint >> 12) & 0x3F) | 0x80); - } - utf8.push(((codePoint >> 6) & 0x3F) | 0x80); - } - utf8.push((codePoint & 0x3F) | 0x80); - } - } - } - - this.addInt8(0); - this.startVector(1, utf8.length, 1); - this.bb.setPosition(this.space -= utf8.length); - for (var i = 0, offset = this.space, bytes = this.bb.bytes(); i < utf8.length; i++) { - bytes[offset++] = utf8[i]; - } - return this.endVector(); -}; - -/** - * A helper function to avoid generated code depending on this file directly. - * - * @param {number} low - * @param {number} high - * @returns {flatbuffers.Long} - */ -flatbuffers.Builder.prototype.createLong = function(low, high) { - return flatbuffers.Long.create(low, high); -}; -//////////////////////////////////////////////////////////////////////////////// -/// @cond FLATBUFFERS_INTERNAL -/** - * Create a new ByteBuffer with a given array of bytes (`Uint8Array`). - * - * @constructor - * @param {Uint8Array} bytes - */ -flatbuffers.ByteBuffer = function(bytes) { - /** - * @type {Uint8Array} - * @private - */ - this.bytes_ = bytes; - - /** - * @type {number} - * @private - */ - this.position_ = 0; -}; - -/** - * Create and allocate a new ByteBuffer with a given size. - * - * @param {number} byte_size - * @returns {flatbuffers.ByteBuffer} - */ -flatbuffers.ByteBuffer.allocate = function(byte_size) { - return new flatbuffers.ByteBuffer(new Uint8Array(byte_size)); -}; - -/** - * Get the underlying `Uint8Array`. - * - * @returns {Uint8Array} - */ -flatbuffers.ByteBuffer.prototype.bytes = function() { - return this.bytes_; -}; - -/** - * Get the buffer's position. - * - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.position = function() { - return this.position_; -}; - -/** - * Set the buffer's position. - * - * @param {number} position - */ -flatbuffers.ByteBuffer.prototype.setPosition = function(position) { - this.position_ = position; -}; - -/** - * Get the buffer's capacity. - * - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.capacity = function() { - return this.bytes_.length; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readInt8 = function(offset) { - return this.readUint8(offset) << 24 >> 24; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readUint8 = function(offset) { - return this.bytes_[offset]; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readInt16 = function(offset) { - return this.readUint16(offset) << 16 >> 16; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readUint16 = function(offset) { - return this.bytes_[offset] | this.bytes_[offset + 1] << 8; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readInt32 = function(offset) { - return this.bytes_[offset] | this.bytes_[offset + 1] << 8 | this.bytes_[offset + 2] << 16 | this.bytes_[offset + 3] << 24; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readUint32 = function(offset) { - return this.readInt32(offset) >>> 0; -}; - -/** - * @param {number} offset - * @returns {flatbuffers.Long} - */ -flatbuffers.ByteBuffer.prototype.readInt64 = function(offset) { - return new flatbuffers.Long(this.readInt32(offset), this.readInt32(offset + 4)); -}; - -/** - * @param {number} offset - * @returns {flatbuffers.Long} - */ -flatbuffers.ByteBuffer.prototype.readUint64 = function(offset) { - return new flatbuffers.Long(this.readUint32(offset), this.readUint32(offset + 4)); -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readFloat32 = function(offset) { - flatbuffers.int32[0] = this.readInt32(offset); - return flatbuffers.float32[0]; -}; - -/** - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.readFloat64 = function(offset) { - flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1] = this.readInt32(offset); - flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0] = this.readInt32(offset + 4); - return flatbuffers.float64[0]; -}; - -/** - * @param {number} offset - * @param {number|boolean} value - */ -flatbuffers.ByteBuffer.prototype.writeInt8 = function(offset, value) { - this.bytes_[offset] = /** @type {number} */(value); -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeUint8 = function(offset, value) { - this.bytes_[offset] = value; -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeInt16 = function(offset, value) { - this.bytes_[offset] = value; - this.bytes_[offset + 1] = value >> 8; -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeUint16 = function(offset, value) { - this.bytes_[offset] = value; - this.bytes_[offset + 1] = value >> 8; -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeInt32 = function(offset, value) { - this.bytes_[offset] = value; - this.bytes_[offset + 1] = value >> 8; - this.bytes_[offset + 2] = value >> 16; - this.bytes_[offset + 3] = value >> 24; -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeUint32 = function(offset, value) { - this.bytes_[offset] = value; - this.bytes_[offset + 1] = value >> 8; - this.bytes_[offset + 2] = value >> 16; - this.bytes_[offset + 3] = value >> 24; -}; - -/** - * @param {number} offset - * @param {flatbuffers.Long} value - */ -flatbuffers.ByteBuffer.prototype.writeInt64 = function(offset, value) { - this.writeInt32(offset, value.low); - this.writeInt32(offset + 4, value.high); -}; - -/** - * @param {number} offset - * @param {flatbuffers.Long} value - */ -flatbuffers.ByteBuffer.prototype.writeUint64 = function(offset, value) { - this.writeUint32(offset, value.low); - this.writeUint32(offset + 4, value.high); -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeFloat32 = function(offset, value) { - flatbuffers.float32[0] = value; - this.writeInt32(offset, flatbuffers.int32[0]); -}; - -/** - * @param {number} offset - * @param {number} value - */ -flatbuffers.ByteBuffer.prototype.writeFloat64 = function(offset, value) { - flatbuffers.float64[0] = value; - this.writeInt32(offset, flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1]); - this.writeInt32(offset + 4, flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0]); -}; - -/** - * Look up a field in the vtable, return an offset into the object, or 0 if the - * field is not present. - * - * @param {number} bb_pos - * @param {number} vtable_offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.__offset = function(bb_pos, vtable_offset) { - var vtable = bb_pos - this.readInt32(bb_pos); - return vtable_offset < this.readInt16(vtable) ? this.readInt16(vtable + vtable_offset) : 0; -}; - -/** - * Initialize any Table-derived type to point to the union at the given offset. - * - * @param {flatbuffers.Table} t - * @param {number} offset - * @returns {flatbuffers.Table} - */ -flatbuffers.ByteBuffer.prototype.__union = function(t, offset) { - t.bb_pos = offset + this.readInt32(offset); - t.bb = this; - return t; -}; - -/** - * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer. - * This allocates a new string and converts to wide chars upon each access. - * - * To avoid the conversion to UTF-16, pass flatbuffers.Encoding.UTF8_BYTES as - * the "optionalEncoding" argument. This is useful for avoiding conversion to - * and from UTF-16 when the data will just be packaged back up in another - * FlatBuffer later on. - * - * @param {number} offset - * @param {flatbuffers.Encoding=} opt_encoding Defaults to UTF16_STRING - * @returns {string|Uint8Array} - */ -flatbuffers.ByteBuffer.prototype.__string = function(offset, opt_encoding) { - offset += this.readInt32(offset); - - var length = this.readInt32(offset); - var result = ''; - var i = 0; - - offset += flatbuffers.SIZEOF_INT; - - if (opt_encoding === flatbuffers.Encoding.UTF8_BYTES) { - return this.bytes_.subarray(offset, offset + length); - } - - while (i < length) { - var codePoint; - - // Decode UTF-8 - var a = this.readUint8(offset + i++); - if (a < 0xC0) { - codePoint = a; - } else { - var b = this.readUint8(offset + i++); - if (a < 0xE0) { - codePoint = - ((a & 0x1F) << 6) | - (b & 0x3F); - } else { - var c = this.readUint8(offset + i++); - if (a < 0xF0) { - codePoint = - ((a & 0x0F) << 12) | - ((b & 0x3F) << 6) | - (c & 0x3F); - } else { - var d = this.readUint8(offset + i++); - codePoint = - ((a & 0x07) << 18) | - ((b & 0x3F) << 12) | - ((c & 0x3F) << 6) | - (d & 0x3F); - } - } - } - - // Encode UTF-16 - if (codePoint < 0x10000) { - result += String.fromCharCode(codePoint); - } else { - codePoint -= 0x10000; - result += String.fromCharCode( - (codePoint >> 10) + 0xD800, - (codePoint & ((1 << 10) - 1)) + 0xDC00); - } - } - - return result; -}; - -/** - * Retrieve the relative offset stored at "offset" - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.__indirect = function(offset) { - return offset + this.readInt32(offset); -}; - -/** - * Get the start of data of a vector whose offset is stored at "offset" in this object. - * - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.__vector = function(offset) { - return offset + this.readInt32(offset) + flatbuffers.SIZEOF_INT; // data starts after the length -}; - -/** - * Get the length of a vector whose offset is stored at "offset" in this object. - * - * @param {number} offset - * @returns {number} - */ -flatbuffers.ByteBuffer.prototype.__vector_len = function(offset) { - return this.readInt32(offset + this.readInt32(offset)); -}; - -/** - * @param {string} ident - * @returns {boolean} - */ -flatbuffers.ByteBuffer.prototype.__has_identifier = function(ident) { - if (ident.length != flatbuffers.FILE_IDENTIFIER_LENGTH) { - throw new Error('FlatBuffers: file identifier must be length ' + - flatbuffers.FILE_IDENTIFIER_LENGTH); - } - for (var i = 0; i < flatbuffers.FILE_IDENTIFIER_LENGTH; i++) { - if (ident.charCodeAt(i) != this.readInt8(this.position_ + flatbuffers.SIZEOF_INT + i)) { - return false; - } - } - return true; -}; - -/** - * A helper function to avoid generated code depending on this file directly. - * - * @param {number} low - * @param {number} high - * @returns {flatbuffers.Long} - */ -flatbuffers.ByteBuffer.prototype.createLong = function(low, high) { - return flatbuffers.Long.create(low, high); -}; - -// Exports for Node.js and RequireJS -this.flatbuffers = flatbuffers; - -/// @endcond -/// @}
diff --git a/third_party/flatbuffers/net/FlatBuffers/ByteBuffer.cs b/third_party/flatbuffers/net/FlatBuffers/ByteBuffer.cs deleted file mode 100755 index 37a2c7e..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/ByteBuffer.cs +++ /dev/null
@@ -1,457 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// There are 2 #defines that have an impact on performance of this ByteBuffer implementation -// -// UNSAFE_BYTEBUFFER -// This will use unsafe code to manipulate the underlying byte array. This -// can yield a reasonable performance increase. -// -// BYTEBUFFER_NO_BOUNDS_CHECK -// This will disable the bounds check asserts to the byte array. This can -// yield a small performance gain in normal code.. -// -// Using UNSAFE_BYTEBUFFER and BYTEBUFFER_NO_BOUNDS_CHECK together can yield a -// performance gain of ~15% for some operations, however doing so is potentially -// dangerous. Do so at your own risk! -// - -using System; - -namespace FlatBuffers -{ - /// <summary> - /// Class to mimic Java's ByteBuffer which is used heavily in Flatbuffers. - /// </summary> - public class ByteBuffer - { - private readonly byte[] _buffer; - private int _pos; // Must track start of the buffer. - - public int Length { get { return _buffer.Length; } } - - public byte[] Data { get { return _buffer; } } - - public ByteBuffer(byte[] buffer) : this(buffer, 0) { } - - public ByteBuffer(byte[] buffer, int pos) - { - _buffer = buffer; - _pos = pos; - } - - public int Position { - get { return _pos; } - set { _pos = value; } - } - - public void Reset() - { - _pos = 0; - } - - // Pre-allocated helper arrays for convertion. - private float[] floathelper = new[] { 0.0f }; - private int[] inthelper = new[] { 0 }; - private double[] doublehelper = new[] { 0.0 }; - private ulong[] ulonghelper = new[] { 0UL }; - - // Helper functions for the unsafe version. - static public ushort ReverseBytes(ushort input) - { - return (ushort)(((input & 0x00FFU) << 8) | - ((input & 0xFF00U) >> 8)); - } - static public uint ReverseBytes(uint input) - { - return ((input & 0x000000FFU) << 24) | - ((input & 0x0000FF00U) << 8) | - ((input & 0x00FF0000U) >> 8) | - ((input & 0xFF000000U) >> 24); - } - static public ulong ReverseBytes(ulong input) - { - return (((input & 0x00000000000000FFUL) << 56) | - ((input & 0x000000000000FF00UL) << 40) | - ((input & 0x0000000000FF0000UL) << 24) | - ((input & 0x00000000FF000000UL) << 8) | - ((input & 0x000000FF00000000UL) >> 8) | - ((input & 0x0000FF0000000000UL) >> 24) | - ((input & 0x00FF000000000000UL) >> 40) | - ((input & 0xFF00000000000000UL) >> 56)); - } - -#if !UNSAFE_BYTEBUFFER - // Helper functions for the safe (but slower) version. - protected void WriteLittleEndian(int offset, int count, ulong data) - { - if (BitConverter.IsLittleEndian) - { - for (int i = 0; i < count; i++) - { - _buffer[offset + i] = (byte)(data >> i * 8); - } - } - else - { - for (int i = 0; i < count; i++) - { - _buffer[offset + count - 1 - i] = (byte)(data >> i * 8); - } - } - } - - protected ulong ReadLittleEndian(int offset, int count) - { - AssertOffsetAndLength(offset, count); - ulong r = 0; - if (BitConverter.IsLittleEndian) - { - for (int i = 0; i < count; i++) - { - r |= (ulong)_buffer[offset + i] << i * 8; - } - } - else - { - for (int i = 0; i < count; i++) - { - r |= (ulong)_buffer[offset + count - 1 - i] << i * 8; - } - } - return r; - } -#endif // !UNSAFE_BYTEBUFFER - - - private void AssertOffsetAndLength(int offset, int length) - { - #if !BYTEBUFFER_NO_BOUNDS_CHECK - if (offset < 0 || - offset > _buffer.Length - length) - throw new ArgumentOutOfRangeException(); - #endif - } - - public void PutSbyte(int offset, sbyte value) - { - AssertOffsetAndLength(offset, sizeof(sbyte)); - _buffer[offset] = (byte)value; - } - - public void PutByte(int offset, byte value) - { - AssertOffsetAndLength(offset, sizeof(byte)); - _buffer[offset] = value; - } - - public void PutByte(int offset, byte value, int count) - { - AssertOffsetAndLength(offset, sizeof(byte) * count); - for (var i = 0; i < count; ++i) - _buffer[offset + i] = value; - } - - // this method exists in order to conform with Java ByteBuffer standards - public void Put(int offset, byte value) - { - PutByte(offset, value); - } - -#if UNSAFE_BYTEBUFFER - // Unsafe but more efficient versions of Put*. - public void PutShort(int offset, short value) - { - PutUshort(offset, (ushort)value); - } - - public unsafe void PutUshort(int offset, ushort value) - { - AssertOffsetAndLength(offset, sizeof(ushort)); - fixed (byte* ptr = _buffer) - { - *(ushort*)(ptr + offset) = BitConverter.IsLittleEndian - ? value - : ReverseBytes(value); - } - } - - public void PutInt(int offset, int value) - { - PutUint(offset, (uint)value); - } - - public unsafe void PutUint(int offset, uint value) - { - AssertOffsetAndLength(offset, sizeof(uint)); - fixed (byte* ptr = _buffer) - { - *(uint*)(ptr + offset) = BitConverter.IsLittleEndian - ? value - : ReverseBytes(value); - } - } - - public unsafe void PutLong(int offset, long value) - { - PutUlong(offset, (ulong)value); - } - - public unsafe void PutUlong(int offset, ulong value) - { - AssertOffsetAndLength(offset, sizeof(ulong)); - fixed (byte* ptr = _buffer) - { - *(ulong*)(ptr + offset) = BitConverter.IsLittleEndian - ? value - : ReverseBytes(value); - } - } - - public unsafe void PutFloat(int offset, float value) - { - AssertOffsetAndLength(offset, sizeof(float)); - fixed (byte* ptr = _buffer) - { - if (BitConverter.IsLittleEndian) - { - *(float*)(ptr + offset) = value; - } - else - { - *(uint*)(ptr + offset) = ReverseBytes(*(uint*)(&value)); - } - } - } - - public unsafe void PutDouble(int offset, double value) - { - AssertOffsetAndLength(offset, sizeof(double)); - fixed (byte* ptr = _buffer) - { - if (BitConverter.IsLittleEndian) - { - *(double*)(ptr + offset) = value; - - } - else - { - *(ulong*)(ptr + offset) = ReverseBytes(*(ulong*)(ptr + offset)); - } - } - } -#else // !UNSAFE_BYTEBUFFER - // Slower versions of Put* for when unsafe code is not allowed. - public void PutShort(int offset, short value) - { - AssertOffsetAndLength(offset, sizeof(short)); - WriteLittleEndian(offset, sizeof(short), (ulong)value); - } - - public void PutUshort(int offset, ushort value) - { - AssertOffsetAndLength(offset, sizeof(ushort)); - WriteLittleEndian(offset, sizeof(ushort), (ulong)value); - } - - public void PutInt(int offset, int value) - { - AssertOffsetAndLength(offset, sizeof(int)); - WriteLittleEndian(offset, sizeof(int), (ulong)value); - } - - public void PutUint(int offset, uint value) - { - AssertOffsetAndLength(offset, sizeof(uint)); - WriteLittleEndian(offset, sizeof(uint), (ulong)value); - } - - public void PutLong(int offset, long value) - { - AssertOffsetAndLength(offset, sizeof(long)); - WriteLittleEndian(offset, sizeof(long), (ulong)value); - } - - public void PutUlong(int offset, ulong value) - { - AssertOffsetAndLength(offset, sizeof(ulong)); - WriteLittleEndian(offset, sizeof(ulong), value); - } - - public void PutFloat(int offset, float value) - { - AssertOffsetAndLength(offset, sizeof(float)); - floathelper[0] = value; - Buffer.BlockCopy(floathelper, 0, inthelper, 0, sizeof(float)); - WriteLittleEndian(offset, sizeof(float), (ulong)inthelper[0]); - } - - public void PutDouble(int offset, double value) - { - AssertOffsetAndLength(offset, sizeof(double)); - doublehelper[0] = value; - Buffer.BlockCopy(doublehelper, 0, ulonghelper, 0, sizeof(double)); - WriteLittleEndian(offset, sizeof(double), ulonghelper[0]); - } - -#endif // UNSAFE_BYTEBUFFER - - public sbyte GetSbyte(int index) - { - AssertOffsetAndLength(index, sizeof(sbyte)); - return (sbyte)_buffer[index]; - } - - public byte Get(int index) - { - AssertOffsetAndLength(index, sizeof(byte)); - return _buffer[index]; - } - -#if UNSAFE_BYTEBUFFER - // Unsafe but more efficient versions of Get*. - public short GetShort(int offset) - { - return (short)GetUshort(offset); - } - - public unsafe ushort GetUshort(int offset) - { - AssertOffsetAndLength(offset, sizeof(ushort)); - fixed (byte* ptr = _buffer) - { - return BitConverter.IsLittleEndian - ? *(ushort*)(ptr + offset) - : ReverseBytes(*(ushort*)(ptr + offset)); - } - } - - public int GetInt(int offset) - { - return (int)GetUint(offset); - } - - public unsafe uint GetUint(int offset) - { - AssertOffsetAndLength(offset, sizeof(uint)); - fixed (byte* ptr = _buffer) - { - return BitConverter.IsLittleEndian - ? *(uint*)(ptr + offset) - : ReverseBytes(*(uint*)(ptr + offset)); - } - } - - public long GetLong(int offset) - { - return (long)GetUlong(offset); - } - - public unsafe ulong GetUlong(int offset) - { - AssertOffsetAndLength(offset, sizeof(ulong)); - fixed (byte* ptr = _buffer) - { - return BitConverter.IsLittleEndian - ? *(ulong*)(ptr + offset) - : ReverseBytes(*(ulong*)(ptr + offset)); - } - } - - public unsafe float GetFloat(int offset) - { - AssertOffsetAndLength(offset, sizeof(float)); - fixed (byte* ptr = _buffer) - { - if (BitConverter.IsLittleEndian) - { - return *(float*)(ptr + offset); - } - else - { - uint uvalue = ReverseBytes(*(uint*)(ptr + offset)); - return *(float*)(&uvalue); - } - } - } - - public unsafe double GetDouble(int offset) - { - AssertOffsetAndLength(offset, sizeof(double)); - fixed (byte* ptr = _buffer) - { - if (BitConverter.IsLittleEndian) - { - return *(double*)(ptr + offset); - } - else - { - ulong uvalue = ReverseBytes(*(ulong*)(ptr + offset)); - return *(double*)(&uvalue); - } - } - } -#else // !UNSAFE_BYTEBUFFER - // Slower versions of Get* for when unsafe code is not allowed. - public short GetShort(int index) - { - return (short)ReadLittleEndian(index, sizeof(short)); - } - - public ushort GetUshort(int index) - { - return (ushort)ReadLittleEndian(index, sizeof(ushort)); - } - - public int GetInt(int index) - { - return (int)ReadLittleEndian(index, sizeof(int)); - } - - public uint GetUint(int index) - { - return (uint)ReadLittleEndian(index, sizeof(uint)); - } - - public long GetLong(int index) - { - return (long)ReadLittleEndian(index, sizeof(long)); - } - - public ulong GetUlong(int index) - { - return ReadLittleEndian(index, sizeof(ulong)); - } - - public float GetFloat(int index) - { - int i = (int)ReadLittleEndian(index, sizeof(float)); - inthelper[0] = i; - Buffer.BlockCopy(inthelper, 0, floathelper, 0, sizeof(float)); - return floathelper[0]; - } - - public double GetDouble(int index) - { - ulong i = ReadLittleEndian(index, sizeof(double)); - // There's Int64BitsToDouble but it uses unsafe code internally. - ulonghelper[0] = i; - Buffer.BlockCopy(ulonghelper, 0, doublehelper, 0, sizeof(double)); - return doublehelper[0]; - } -#endif // UNSAFE_BYTEBUFFER - } -}
diff --git a/third_party/flatbuffers/net/FlatBuffers/FlatBufferBuilder.cs b/third_party/flatbuffers/net/FlatBuffers/FlatBufferBuilder.cs deleted file mode 100644 index b6701df..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/FlatBufferBuilder.cs +++ /dev/null
@@ -1,652 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -using System; -using System.Text; - -/// @file -/// @addtogroup flatbuffers_csharp_api -/// @{ - -namespace FlatBuffers -{ - /// <summary> - /// Responsible for building up and accessing a FlatBuffer formatted byte - /// array (via ByteBuffer). - /// </summary> - public class FlatBufferBuilder - { - private int _space; - private ByteBuffer _bb; - private int _minAlign = 1; - - // The vtable for the current table (if _vtableSize >= 0) - private int[] _vtable = new int[16]; - // The size of the vtable. -1 indicates no vtable - private int _vtableSize = -1; - // Starting offset of the current struct/table. - private int _objectStart; - // List of offsets of all vtables. - private int[] _vtables = new int[16]; - // Number of entries in `vtables` in use. - private int _numVtables = 0; - // For the current vector being built. - private int _vectorNumElems = 0; - - /// <summary> - /// Create a FlatBufferBuilder with a given initial size. - /// </summary> - /// <param name="initialSize"> - /// The initial size to use for the internal buffer. - /// </param> - public FlatBufferBuilder(int initialSize) - { - if (initialSize <= 0) - throw new ArgumentOutOfRangeException("initialSize", - initialSize, "Must be greater than zero"); - _space = initialSize; - _bb = new ByteBuffer(new byte[initialSize]); - } - - /// <summary> - /// Reset the FlatBufferBuilder by purging all data that it holds. - /// </summary> - public void Clear() - { - _space = _bb.Length; - _bb.Reset(); - _minAlign = 1; - while (_vtableSize > 0) _vtable[--_vtableSize] = 0; - _vtableSize = -1; - _objectStart = 0; - _numVtables = 0; - _vectorNumElems = 0; - } - - /// <summary> - /// Gets and sets a Boolean to disable the optimization when serializing - /// default values to a Table. - /// - /// In order to save space, fields that are set to their default value - /// don't get serialized into the buffer. - /// </summary> - public bool ForceDefaults { get; set; } - - /// @cond FLATBUFFERS_INTERNAL - - public int Offset { get { return _bb.Length - _space; } } - - public void Pad(int size) - { - _bb.PutByte(_space -= size, 0, size); - } - - // Doubles the size of the ByteBuffer, and copies the old data towards - // the end of the new buffer (since we build the buffer backwards). - void GrowBuffer() - { - var oldBuf = _bb.Data; - var oldBufSize = oldBuf.Length; - if ((oldBufSize & 0xC0000000) != 0) - throw new Exception( - "FlatBuffers: cannot grow buffer beyond 2 gigabytes."); - - var newBufSize = oldBufSize << 1; - var newBuf = new byte[newBufSize]; - - Buffer.BlockCopy(oldBuf, 0, newBuf, newBufSize - oldBufSize, - oldBufSize); - _bb = new ByteBuffer(newBuf, newBufSize); - } - - // Prepare to write an element of `size` after `additional_bytes` - // have been written, e.g. if you write a string, you need to align - // such the int length field is aligned to SIZEOF_INT, and the string - // data follows it directly. - // If all you need to do is align, `additional_bytes` will be 0. - public void Prep(int size, int additionalBytes) - { - // Track the biggest thing we've ever aligned to. - if (size > _minAlign) - _minAlign = size; - // Find the amount of alignment needed such that `size` is properly - // aligned after `additional_bytes` - var alignSize = - ((~((int)_bb.Length - _space + additionalBytes)) + 1) & - (size - 1); - // Reallocate the buffer if needed. - while (_space < alignSize + size + additionalBytes) - { - var oldBufSize = (int)_bb.Length; - GrowBuffer(); - _space += (int)_bb.Length - oldBufSize; - - } - if (alignSize > 0) - Pad(alignSize); - } - - public void PutBool(bool x) - { - _bb.PutByte(_space -= sizeof(byte), (byte)(x ? 1 : 0)); - } - - public void PutSbyte(sbyte x) - { - _bb.PutSbyte(_space -= sizeof(sbyte), x); - } - - public void PutByte(byte x) - { - _bb.PutByte(_space -= sizeof(byte), x); - } - - public void PutShort(short x) - { - _bb.PutShort(_space -= sizeof(short), x); - } - - public void PutUshort(ushort x) - { - _bb.PutUshort(_space -= sizeof(ushort), x); - } - - public void PutInt(int x) - { - _bb.PutInt(_space -= sizeof(int), x); - } - - public void PutUint(uint x) - { - _bb.PutUint(_space -= sizeof(uint), x); - } - - public void PutLong(long x) - { - _bb.PutLong(_space -= sizeof(long), x); - } - - public void PutUlong(ulong x) - { - _bb.PutUlong(_space -= sizeof(ulong), x); - } - - public void PutFloat(float x) - { - _bb.PutFloat(_space -= sizeof(float), x); - } - - public void PutDouble(double x) - { - _bb.PutDouble(_space -= sizeof(double), x); - } - /// @endcond - - /// <summary> - /// Add a `bool` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `bool` to add to the buffer.</param> - public void AddBool(bool x) { Prep(sizeof(byte), 0); PutBool(x); } - - /// <summary> - /// Add a `sbyte` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `sbyte` to add to the buffer.</param> - public void AddSbyte(sbyte x) { Prep(sizeof(sbyte), 0); PutSbyte(x); } - - /// <summary> - /// Add a `byte` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `byte` to add to the buffer.</param> - public void AddByte(byte x) { Prep(sizeof(byte), 0); PutByte(x); } - - /// <summary> - /// Add a `short` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `short` to add to the buffer.</param> - public void AddShort(short x) { Prep(sizeof(short), 0); PutShort(x); } - - /// <summary> - /// Add an `ushort` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `ushort` to add to the buffer.</param> - public void AddUshort(ushort x) { Prep(sizeof(ushort), 0); PutUshort(x); } - - /// <summary> - /// Add an `int` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `int` to add to the buffer.</param> - public void AddInt(int x) { Prep(sizeof(int), 0); PutInt(x); } - - /// <summary> - /// Add an `uint` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `uint` to add to the buffer.</param> - public void AddUint(uint x) { Prep(sizeof(uint), 0); PutUint(x); } - - /// <summary> - /// Add a `long` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `long` to add to the buffer.</param> - public void AddLong(long x) { Prep(sizeof(long), 0); PutLong(x); } - - /// <summary> - /// Add an `ulong` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `ulong` to add to the buffer.</param> - public void AddUlong(ulong x) { Prep(sizeof(ulong), 0); PutUlong(x); } - - /// <summary> - /// Add a `float` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `float` to add to the buffer.</param> - public void AddFloat(float x) { Prep(sizeof(float), 0); PutFloat(x); } - - /// <summary> - /// Add a `double` to the buffer (aligns the data and grows if necessary). - /// </summary> - /// <param name="x">The `double` to add to the buffer.</param> - public void AddDouble(double x) { Prep(sizeof(double), 0); - PutDouble(x); } - - /// <summary> - /// Adds an offset, relative to where it will be written. - /// </summary> - /// <param name="off">The offset to add to the buffer.</param> - public void AddOffset(int off) - { - Prep(sizeof(int), 0); // Ensure alignment is already done. - if (off > Offset) - throw new ArgumentException(); - - off = Offset - off + sizeof(int); - PutInt(off); - } - - /// @cond FLATBUFFERS_INTERNAL - public void StartVector(int elemSize, int count, int alignment) - { - NotNested(); - _vectorNumElems = count; - Prep(sizeof(int), elemSize * count); - Prep(alignment, elemSize * count); // Just in case alignment > int. - } - /// @endcond - - /// <summary> - /// Writes data necessary to finish a vector construction. - /// </summary> - public VectorOffset EndVector() - { - PutInt(_vectorNumElems); - return new VectorOffset(Offset); - } - - /// <summary> - /// Creates a vector of tables. - /// </summary> - /// <param name="offsets">Offsets of the tables.</param> - public VectorOffset CreateVectorOfTables<T>(Offset<T>[] offsets) where T : struct - { - NotNested(); - StartVector(sizeof(int), offsets.Length, sizeof(int)); - for (int i = offsets.Length - 1; i >= 0; i--) AddOffset(offsets[i].Value); - return EndVector(); - } - - /// @cond FLATBUFFERS_INTENRAL - public void Nested(int obj) - { - // Structs are always stored inline, so need to be created right - // where they are used. You'll get this assert if you created it - // elsewhere. - if (obj != Offset) - throw new Exception( - "FlatBuffers: struct must be serialized inline."); - } - - public void NotNested() - { - // You should not be creating any other objects or strings/vectors - // while an object is being constructed - if (_vtableSize >= 0) - throw new Exception( - "FlatBuffers: object serialization must not be nested."); - } - - public void StartObject(int numfields) - { - if (numfields < 0) - throw new ArgumentOutOfRangeException("Flatbuffers: invalid numfields"); - - NotNested(); - - if (_vtable.Length < numfields) - _vtable = new int[numfields]; - - _vtableSize = numfields; - _objectStart = Offset; - } - - - // Set the current vtable at `voffset` to the current location in the - // buffer. - public void Slot(int voffset) - { - if (voffset >= _vtableSize) - throw new IndexOutOfRangeException("Flatbuffers: invalid voffset"); - - _vtable[voffset] = Offset; - } - - /// <summary> - /// Adds a Boolean to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddBool(int o, bool x, bool d) { if (ForceDefaults || x != d) { AddBool(x); Slot(o); } } - - /// <summary> - /// Adds a SByte to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddSbyte(int o, sbyte x, sbyte d) { if (ForceDefaults || x != d) { AddSbyte(x); Slot(o); } } - - /// <summary> - /// Adds a Byte to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddByte(int o, byte x, byte d) { if (ForceDefaults || x != d) { AddByte(x); Slot(o); } } - - /// <summary> - /// Adds a Int16 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddShort(int o, short x, int d) { if (ForceDefaults || x != d) { AddShort(x); Slot(o); } } - - /// <summary> - /// Adds a UInt16 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddUshort(int o, ushort x, ushort d) { if (ForceDefaults || x != d) { AddUshort(x); Slot(o); } } - - /// <summary> - /// Adds an Int32 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddInt(int o, int x, int d) { if (ForceDefaults || x != d) { AddInt(x); Slot(o); } } - - /// <summary> - /// Adds a UInt32 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddUint(int o, uint x, uint d) { if (ForceDefaults || x != d) { AddUint(x); Slot(o); } } - - /// <summary> - /// Adds an Int64 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddLong(int o, long x, long d) { if (ForceDefaults || x != d) { AddLong(x); Slot(o); } } - - /// <summary> - /// Adds a UInt64 to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddUlong(int o, ulong x, ulong d) { if (ForceDefaults || x != d) { AddUlong(x); Slot(o); } } - - /// <summary> - /// Adds a Single to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddFloat(int o, float x, double d) { if (ForceDefaults || x != d) { AddFloat(x); Slot(o); } } - - /// <summary> - /// Adds a Double to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddDouble(int o, double x, double d) { if (ForceDefaults || x != d) { AddDouble(x); Slot(o); } } - - /// <summary> - /// Adds a buffer offset to the Table at index `o` in its vtable using the value `x` and default `d` - /// </summary> - /// <param name="o">The index into the vtable</param> - /// <param name="x">The value to put into the buffer. If the value is equal to the default - /// and <see cref="ForceDefaults"/> is false, the value will be skipped.</param> - /// <param name="d">The default value to compare the value against</param> - public void AddOffset(int o, int x, int d) { if (ForceDefaults || x != d) { AddOffset(x); Slot(o); } } - /// @endcond - - /// <summary> - /// Encode the string `s` in the buffer using UTF-8. - /// </summary> - /// <param name="s">The string to encode.</param> - /// <returns> - /// The offset in the buffer where the encoded string starts. - /// </returns> - public StringOffset CreateString(string s) - { - NotNested(); - AddByte(0); - var utf8StringLen = Encoding.UTF8.GetByteCount(s); - StartVector(1, utf8StringLen, 1); - Encoding.UTF8.GetBytes(s, 0, s.Length, _bb.Data, _space -= utf8StringLen); - return new StringOffset(EndVector().Value); - } - - /// @cond FLATBUFFERS_INTERNAL - // Structs are stored inline, so nothing additional is being added. - // `d` is always 0. - public void AddStruct(int voffset, int x, int d) - { - if (x != d) - { - Nested(x); - Slot(voffset); - } - } - - public int EndObject() - { - if (_vtableSize < 0) - throw new InvalidOperationException( - "Flatbuffers: calling endObject without a startObject"); - - AddInt((int)0); - var vtableloc = Offset; - // Write out the current vtable. - for (int i = _vtableSize - 1; i >= 0 ; i--) { - // Offset relative to the start of the table. - short off = (short)(_vtable[i] != 0 - ? vtableloc - _vtable[i] - : 0); - AddShort(off); - - // clear out written entry - _vtable[i] = 0; - } - - const int standardFields = 2; // The fields below: - AddShort((short)(vtableloc - _objectStart)); - AddShort((short)((_vtableSize + standardFields) * - sizeof(short))); - - // Search for an existing vtable that matches the current one. - int existingVtable = 0; - for (int i = 0; i < _numVtables; i++) { - int vt1 = _bb.Length - _vtables[i]; - int vt2 = _space; - short len = _bb.GetShort(vt1); - if (len == _bb.GetShort(vt2)) { - for (int j = sizeof(short); j < len; j += sizeof(short)) { - if (_bb.GetShort(vt1 + j) != _bb.GetShort(vt2 + j)) { - goto endLoop; - } - } - existingVtable = _vtables[i]; - break; - } - - endLoop: { } - } - - if (existingVtable != 0) { - // Found a match: - // Remove the current vtable. - _space = _bb.Length - vtableloc; - // Point table to existing vtable. - _bb.PutInt(_space, existingVtable - vtableloc); - } else { - // No match: - // Add the location of the current vtable to the list of - // vtables. - if (_numVtables == _vtables.Length) - { - // Arrays.CopyOf(vtables num_vtables * 2); - var newvtables = new int[ _numVtables * 2]; - Array.Copy(_vtables, newvtables, _vtables.Length); - - _vtables = newvtables; - }; - _vtables[_numVtables++] = Offset; - // Point table to current vtable. - _bb.PutInt(_bb.Length - vtableloc, Offset - vtableloc); - } - - _vtableSize = -1; - return vtableloc; - } - - // This checks a required field has been set in a given table that has - // just been constructed. - public void Required(int table, int field) - { - int table_start = _bb.Length - table; - int vtable_start = table_start - _bb.GetInt(table_start); - bool ok = _bb.GetShort(vtable_start + field) != 0; - // If this fails, the caller will show what field needs to be set. - if (!ok) - throw new InvalidOperationException("FlatBuffers: field " + field + - " must be set"); - } - /// @endcond - - /// <summary> - /// Finalize a buffer, pointing to the given `root_table`. - /// </summary> - /// <param name="rootTable"> - /// An offset to be added to the buffer. - /// </param> - public void Finish(int rootTable) - { - Prep(_minAlign, sizeof(int)); - AddOffset(rootTable); - _bb.Position = _space; - } - - /// <summary> - /// Get the ByteBuffer representing the FlatBuffer. - /// </summary> - /// <remarks> - /// This is typically only called after you call `Finish()`. - /// The actual data starts at the ByteBuffer's current position, - /// not necessarily at `0`. - /// </remarks> - /// <returns> - /// Returns the ByteBuffer for this FlatBuffer. - /// </returns> - public ByteBuffer DataBuffer { get { return _bb; } } - - /// <summary> - /// A utility function to copy and return the ByteBuffer data as a - /// `byte[]`. - /// </summary> - /// <returns> - /// A full copy of the FlatBuffer data. - /// </returns> - public byte[] SizedByteArray() - { - var newArray = new byte[_bb.Data.Length - _bb.Position]; - Buffer.BlockCopy(_bb.Data, _bb.Position, newArray, 0, - _bb.Data.Length - _bb.Position); - return newArray; - } - - /// <summary> - /// Finalize a buffer, pointing to the given `rootTable`. - /// </summary> - /// <param name="rootTable"> - /// An offset to be added to the buffer. - /// </param> - /// <param name="fileIdentifier"> - /// A FlatBuffer file identifier to be added to the buffer before - /// `root_table`. - /// </param> - public void Finish(int rootTable, string fileIdentifier) - { - Prep(_minAlign, sizeof(int) + - FlatBufferConstants.FileIdentifierLength); - if (fileIdentifier.Length != - FlatBufferConstants.FileIdentifierLength) - throw new ArgumentException( - "FlatBuffers: file identifier must be length " + - FlatBufferConstants.FileIdentifierLength, - "fileIdentifier"); - for (int i = FlatBufferConstants.FileIdentifierLength - 1; i >= 0; - i--) - { - AddByte((byte)fileIdentifier[i]); - } - Finish(rootTable); - } - - - } -} - -/// @}
diff --git a/third_party/flatbuffers/net/FlatBuffers/FlatBufferConstants.cs b/third_party/flatbuffers/net/FlatBuffers/FlatBufferConstants.cs deleted file mode 100644 index ab3092c..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/FlatBufferConstants.cs +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace FlatBuffers -{ - public static class FlatBufferConstants - { - public const int FileIdentifierLength = 4; - } -}
diff --git a/third_party/flatbuffers/net/FlatBuffers/FlatBuffers.csproj b/third_party/flatbuffers/net/FlatBuffers/FlatBuffers.csproj deleted file mode 100644 index 2a0cf99..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/FlatBuffers.csproj +++ /dev/null
@@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{28C00774-1E73-4A75-AD8F-844CD21A064D}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>FlatBuffers</RootNamespace> - <AssemblyName>FlatBuffers</AssemblyName> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core" /> - </ItemGroup> - <ItemGroup> - <Compile Include="ByteBuffer.cs" /> - <Compile Include="FlatBufferBuilder.cs" /> - <Compile Include="FlatBufferConstants.cs" /> - <Compile Include="IFlatbufferObject.cs" /> - <Compile Include="Offset.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Struct.cs" /> - <Compile Include="Table.cs" /> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> \ No newline at end of file
diff --git a/third_party/flatbuffers/net/FlatBuffers/IFlatbufferObject.cs b/third_party/flatbuffers/net/FlatBuffers/IFlatbufferObject.cs deleted file mode 100644 index 6a15aba..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/IFlatbufferObject.cs +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers -{ - /// <summary> - /// This is the base for both structs and tables. - /// </summary> - public interface IFlatbufferObject - { - void __init(int _i, ByteBuffer _bb); - - ByteBuffer ByteBuffer { get; } - } -}
diff --git a/third_party/flatbuffers/net/FlatBuffers/Offset.cs b/third_party/flatbuffers/net/FlatBuffers/Offset.cs deleted file mode 100644 index 2b17cec..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/Offset.cs +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers -{ - /// <summary> - /// Offset class for typesafe assignments. - /// </summary> - public struct Offset<T> where T : struct - { - public int Value; - public Offset(int value) - { - Value = value; - } - } - - public struct StringOffset - { - public int Value; - public StringOffset(int value) - { - Value = value; - } - } - - public struct VectorOffset - { - public int Value; - public VectorOffset(int value) - { - Value = value; - } - } -}
diff --git a/third_party/flatbuffers/net/FlatBuffers/Properties/AssemblyInfo.cs b/third_party/flatbuffers/net/FlatBuffers/Properties/AssemblyInfo.cs deleted file mode 100644 index 1edfac4..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/Properties/AssemblyInfo.cs +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("FlatBuffers")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FlatBuffers")] -[assembly: AssemblyCopyright("Copyright (c) 2015 Google Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("91c32e64-ef20-47df-9c9f-cec9207bc6df")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/third_party/flatbuffers/net/FlatBuffers/Struct.cs b/third_party/flatbuffers/net/FlatBuffers/Struct.cs deleted file mode 100644 index 61da32f..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/Struct.cs +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers -{ - /// <summary> - /// All structs in the generated code derive from this class, and add their own accessors. - /// </summary> - public struct Struct - { - public int bb_pos; - public ByteBuffer bb; - } -}
diff --git a/third_party/flatbuffers/net/FlatBuffers/Table.cs b/third_party/flatbuffers/net/FlatBuffers/Table.cs deleted file mode 100644 index 55182b3..0000000 --- a/third_party/flatbuffers/net/FlatBuffers/Table.cs +++ /dev/null
@@ -1,153 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Text; - -namespace FlatBuffers -{ - /// <summary> - /// All tables in the generated code derive from this struct, and add their own accessors. - /// </summary> - public struct Table - { - public int bb_pos; - public ByteBuffer bb; - - public ByteBuffer ByteBuffer { get { return bb; } } - - // Look up a field in the vtable, return an offset into the object, or 0 if the field is not - // present. - public int __offset(int vtableOffset) - { - int vtable = bb_pos - bb.GetInt(bb_pos); - return vtableOffset < bb.GetShort(vtable) ? (int)bb.GetShort(vtable + vtableOffset) : 0; - } - - public static int __offset(int vtableOffset, int offset, ByteBuffer bb) - { - int vtable = bb.Length - offset; - return (int)bb.GetShort(vtable + vtableOffset - bb.GetInt(vtable)) + vtable; - } - - // Retrieve the relative offset stored at "offset" - public int __indirect(int offset) - { - return offset + bb.GetInt(offset); - } - - public static int __indirect(int offset, ByteBuffer bb) - { - return offset + bb.GetInt(offset); - } - - // Create a .NET String from UTF-8 data stored inside the flatbuffer. - public string __string(int offset) - { - offset += bb.GetInt(offset); - var len = bb.GetInt(offset); - var startPos = offset + sizeof(int); - return Encoding.UTF8.GetString(bb.Data, startPos , len); - } - - // Get the length of a vector whose offset is stored at "offset" in this object. - public int __vector_len(int offset) - { - offset += bb_pos; - offset += bb.GetInt(offset); - return bb.GetInt(offset); - } - - // Get the start of data of a vector whose offset is stored at "offset" in this object. - public int __vector(int offset) - { - offset += bb_pos; - return offset + bb.GetInt(offset) + sizeof(int); // data starts after the length - } - - // Get the data of a vector whoses offset is stored at "offset" in this object as an - // ArraySegment<byte>. If the vector is not present in the ByteBuffer, - // then a null value will be returned. - public ArraySegment<byte>? __vector_as_arraysegment(int offset) - { - var o = this.__offset(offset); - if (0 == o) - { - return null; - } - - var pos = this.__vector(o); - var len = this.__vector_len(o); - return new ArraySegment<byte>(this.bb.Data, pos, len); - } - - // Initialize any Table-derived type to point to the union at the given offset. - public T __union<T>(int offset) where T : struct, IFlatbufferObject - { - offset += bb_pos; - T t = new T(); - t.__init(offset + bb.GetInt(offset), bb); - return t; - } - - public static bool __has_identifier(ByteBuffer bb, string ident) - { - if (ident.Length != FlatBufferConstants.FileIdentifierLength) - throw new ArgumentException("FlatBuffers: file identifier must be length " + FlatBufferConstants.FileIdentifierLength, "ident"); - - for (var i = 0; i < FlatBufferConstants.FileIdentifierLength; i++) - { - if (ident[i] != (char)bb.Get(bb.Position + sizeof(int) + i)) return false; - } - - return true; - } - - // Compare strings in the ByteBuffer. - public static int CompareStrings(int offset_1, int offset_2, ByteBuffer bb) - { - offset_1 += bb.GetInt(offset_1); - offset_2 += bb.GetInt(offset_2); - var len_1 = bb.GetInt(offset_1); - var len_2 = bb.GetInt(offset_2); - var startPos_1 = offset_1 + sizeof(int); - var startPos_2 = offset_2 + sizeof(int); - var len = Math.Min(len_1, len_2); - byte[] bbArray = bb.Data; - for(int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != bbArray[i + startPos_2]) - return bbArray[i + startPos_1] - bbArray[i + startPos_2]; - } - return len_1 - len_2; - } - - // Compare string from the ByteBuffer with the string object - public static int CompareStrings(int offset_1, byte[] key, ByteBuffer bb) - { - offset_1 += bb.GetInt(offset_1); - var len_1 = bb.GetInt(offset_1); - var len_2 = key.Length; - var startPos_1 = offset_1 + sizeof(int); - var len = Math.Min(len_1, len_2); - byte[] bbArray = bb.Data; - for (int i = 0; i < len; i++) { - if (bbArray[i + startPos_1] != key[i]) - return bbArray[i + startPos_1] - key[i]; - } - return len_1 - len_2; - } - } -}
diff --git a/third_party/flatbuffers/package.json b/third_party/flatbuffers/package.json deleted file mode 100644 index 070d907..0000000 --- a/third_party/flatbuffers/package.json +++ /dev/null
@@ -1,27 +0,0 @@ -{ - "name": "flatbuffers", - "version": "1.6.0", - "description": "Memory Efficient Serialization Library", - "files": ["js/flatbuffers.js"], - "main": "js/flatbuffers.js", - "directories": { - "doc": "docs", - "test": "tests" - }, - "scripts": { - "test": "tests/JavaScriptTest.sh" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/google/flatbuffers.git" - }, - "keywords": [ - "flatbuffers" - ], - "author": "The FlatBuffers project", - "license": "SEE LICENSE IN LICENSE.txt", - "bugs": { - "url": "https://github.com/google/flatbuffers/issues" - }, - "homepage": "https://google.github.io/flatbuffers/" -}
diff --git a/third_party/flatbuffers/php/ByteBuffer.php b/third_party/flatbuffers/php/ByteBuffer.php deleted file mode 100644 index 9929a7d..0000000 --- a/third_party/flatbuffers/php/ByteBuffer.php +++ /dev/null
@@ -1,493 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Google\FlatBuffers; - -class ByteBuffer -{ - /** - * @var string $_buffer; - */ - public $_buffer; - - /** - * @var int $_pos; - */ - private $_pos; - - /** - * @var bool $_is_little_endian - */ - private static $_is_little_endian = null; - - public static function wrap($bytes) - { - $bb = new ByteBuffer(0); - $bb->_buffer = $bytes; - - return $bb; - } - - /** - * @param $size - */ - public function __construct($size) - { - $this->_buffer = str_repeat("\0", $size); - } - - /** - * @return int - */ - public function capacity() - { - return strlen($this->_buffer); - } - - /** - * @return int - */ - public function getPosition() - { - return $this->_pos; - } - - /** - * @param $pos - */ - public function setPosition($pos) - { - $this->_pos = $pos; - } - - /** - * - */ - public function reset() - { - $this->_pos = 0; - } - - /** - * @return int - */ - public function length() - { - return strlen($this->_buffer); - } - - /** - * @return string - */ - public function data() - { - return substr($this->_buffer, $this->_pos); - } - - /** - * @return bool - */ - public static function isLittleEndian() - { - if (ByteBuffer::$_is_little_endian === null) { - ByteBuffer::$_is_little_endian = unpack('S', "\x01\x00")[1] === 1; - } - - return ByteBuffer::$_is_little_endian; - } - - /** - * write little endian value to the buffer. - * - * @param $offset - * @param $count byte length - * @param $data actual values - */ - public function writeLittleEndian($offset, $count, $data) - { - if (ByteBuffer::isLittleEndian()) { - for ($i = 0; $i < $count; $i++) { - $this->_buffer[$offset + $i] = chr($data >> $i * 8); - } - } else { - for ($i = 0; $i < $count; $i++) { - $this->_buffer[$offset + $count - 1 - $i] = chr($data >> $i * 8); - } - } - } - - /** - * read little endian value from the buffer - * - * @param $offset - * @param $count acutal size - * @return int - */ - public function readLittleEndian($offset, $count, $force_bigendian = false) - { - $this->assertOffsetAndLength($offset, $count); - $r = 0; - - if (ByteBuffer::isLittleEndian() && $force_bigendian == false) { - for ($i = 0; $i < $count; $i++) { - $r |= ord($this->_buffer[$offset + $i]) << $i * 8; - } - } else { - for ($i = 0; $i < $count; $i++) { - $r |= ord($this->_buffer[$offset + $count -1 - $i]) << $i * 8; - } - } - - return $r; - } - - /** - * @param $offset - * @param $length - */ - public function assertOffsetAndLength($offset, $length) - { - if ($offset < 0 || - $offset >= strlen($this->_buffer) || - $offset + $length > strlen($this->_buffer)) { - throw new \OutOfRangeException(sprintf("offset: %d, length: %d, buffer; %d", $offset, $length, strlen($this->_buffer))); - } - } - - /** - * @param $offset - * @param $value - * @return mixed - */ - public function putSbyte($offset, $value) - { - self::validateValue(-128, 127, $value, "sbyte"); - - $length = strlen($value); - $this->assertOffsetAndLength($offset, $length); - return $this->_buffer[$offset] = $value; - } - - /** - * @param $offset - * @param $value - * @return mixed - */ - public function putByte($offset, $value) - { - self::validateValue(0, 255, $value, "byte"); - - $length = strlen($value); - $this->assertOffsetAndLength($offset, $length); - return $this->_buffer[$offset] = $value; - } - - /** - * @param $offset - * @param $value - */ - public function put($offset, $value) - { - $length = strlen($value); - $this->assertOffsetAndLength($offset, $length); - for ($i = 0; $i < $length; $i++) { - $this->_buffer[$offset + $i] = $value[$i]; - } - } - - /** - * @param $offset - * @param $value - */ - public function putShort($offset, $value) - { - self::validateValue(-32768, 32767, $value, "short"); - - $this->assertOffsetAndLength($offset, 2); - $this->writeLittleEndian($offset, 2, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putUshort($offset, $value) - { - self::validateValue(0, 65535, $value, "short"); - - $this->assertOffsetAndLength($offset, 2); - $this->writeLittleEndian($offset, 2, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putInt($offset, $value) - { - // 2147483647 = (1 << 31) -1 = Maximum signed 32-bit int - // -2147483648 = -1 << 31 = Minimum signed 32-bit int - self::validateValue(-2147483648, 2147483647, $value, "int"); - - $this->assertOffsetAndLength($offset, 4); - $this->writeLittleEndian($offset, 4, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putUint($offset, $value) - { - // NOTE: We can't put big integer value. this is PHP limitation. - // 4294967295 = (1 << 32) -1 = Maximum unsigned 32-bin int - self::validateValue(0, 4294967295, $value, "uint", " php has big numbers limitation. check your PHP_INT_MAX"); - - $this->assertOffsetAndLength($offset, 4); - $this->writeLittleEndian($offset, 4, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putLong($offset, $value) - { - // NOTE: We can't put big integer value. this is PHP limitation. - self::validateValue(~PHP_INT_MAX, PHP_INT_MAX, $value, "long", " php has big numbers limitation. check your PHP_INT_MAX"); - - $this->assertOffsetAndLength($offset, 8); - $this->writeLittleEndian($offset, 8, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putUlong($offset, $value) - { - // NOTE: We can't put big integer value. this is PHP limitation. - self::validateValue(0, PHP_INT_MAX, $value, "long", " php has big numbers limitation. check your PHP_INT_MAX"); - - $this->assertOffsetAndLength($offset, 8); - $this->writeLittleEndian($offset, 8, $value); - } - - /** - * @param $offset - * @param $value - */ - public function putFloat($offset, $value) - { - $this->assertOffsetAndLength($offset, 4); - - $floathelper = pack("f", $value); - $v = unpack("V", $floathelper); - $this->writeLittleEndian($offset, 4, $v[1]); - } - - /** - * @param $offset - * @param $value - */ - public function putDouble($offset, $value) - { - $this->assertOffsetAndLength($offset, 8); - - $floathelper = pack("d", $value); - $v = unpack("V*", $floathelper); - - $this->writeLittleEndian($offset, 4, $v[1]); - $this->writeLittleEndian($offset + 4, 4, $v[2]); - } - - /** - * @param $index - * @return mixed - */ - public function getByte($index) - { - return ord($this->_buffer[$index]); - } - - /** - * @param $index - * @return mixed - */ - public function getSbyte($index) - { - $v = unpack("c", $this->_buffer[$index]); - return $v[1]; - } - - /** - * @param $buffer - */ - public function getX(&$buffer) - { - for ($i = $this->_pos, $j = 0; $j < strlen($buffer); $i++, $j++) { - $buffer[$j] = $this->_buffer[$i]; - } - } - - /** - * @param $index - * @return mixed - */ - public function get($index) - { - $this->assertOffsetAndLength($index, 1); - return $this->_buffer[$index]; - } - - - /** - * @param $index - * @return mixed - */ - public function getBool($index) - { - return (bool)ord($this->_buffer[$index]); - } - - /** - * @param $index - * @return int - */ - public function getShort($index) - { - $result = $this->readLittleEndian($index, 2); - - $sign = $index + (ByteBuffer::isLittleEndian() ? 1 : 0); - $issigned = isset($this->_buffer[$sign]) && ord($this->_buffer[$sign]) & 0x80; - - // 65536 = 1 << 16 = Maximum unsigned 16-bit int - return $issigned ? $result - 65536 : $result; - } - - /** - * @param $index - * @return int - */ - public function getUShort($index) - { - return $this->readLittleEndian($index, 2); - } - - /** - * @param $index - * @return int - */ - public function getInt($index) - { - $result = $this->readLittleEndian($index, 4); - - $sign = $index + (ByteBuffer::isLittleEndian() ? 3 : 0); - $issigned = isset($this->_buffer[$sign]) && ord($this->_buffer[$sign]) & 0x80; - - if (PHP_INT_SIZE > 4) { - // 4294967296 = 1 << 32 = Maximum unsigned 32-bit int - return $issigned ? $result - 4294967296 : $result; - } else { - // 32bit / Windows treated number as signed integer. - return $result; - } - } - - /** - * @param $index - * @return int - */ - public function getUint($index) - { - return $this->readLittleEndian($index, 4); - } - - /** - * @param $index - * @return int - */ - public function getLong($index) - { - return $this->readLittleEndian($index, 8); - } - - /** - * @param $index - * @return int - */ - public function getUlong($index) - { - return $this->readLittleEndian($index, 8); - } - - /** - * @param $index - * @return mixed - */ - public function getFloat($index) - { - $i = $this->readLittleEndian($index, 4); - - return self::convertHelper(self::__FLOAT, $i); - } - - /** - * @param $index - * @return float - */ - public function getDouble($index) - { - $i = $this->readLittleEndian($index, 4); - $i2 = $this->readLittleEndian($index + 4, 4); - - return self::convertHelper(self::__DOUBLE, $i, $i2); - } - - const __SHORT = 1; - const __INT = 2; - const __LONG = 3; - const __FLOAT = 4; - const __DOUBLE = 5; - private static function convertHelper($type, $value, $value2 = null) { - // readLittleEndian construct unsigned integer value from bytes. we have to encode this value to - // correct bytes, and decode as expected types with `unpack` function. - // then it returns correct type value. - // see also: http://php.net/manual/en/function.pack.php - - switch ($type) { - case self::__FLOAT: - $inthelper = pack("V", $value); - $v = unpack("f", $inthelper); - return $v[1]; - break; - case self::__DOUBLE: - $inthelper = pack("VV", $value, $value2); - $v = unpack("d", $inthelper); - return $v[1]; - break; - default: - throw new \Exception(sprintf("unexpected type %d specified", $type)); - } - } - - private static function validateValue($min, $max, $value, $type, $additional_notes = "") { - if(!($min <= $value && $value <= $max)) { - throw new \InvalidArgumentException(sprintf("bad number %s for type %s.%s", $value, $type, $additional_notes)); - } - } -}
diff --git a/third_party/flatbuffers/php/Constants.php b/third_party/flatbuffers/php/Constants.php deleted file mode 100644 index ef3730d..0000000 --- a/third_party/flatbuffers/php/Constants.php +++ /dev/null
@@ -1,25 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Google\FlatBuffers; - -class Constants -{ - const SIZEOF_SHORT = 2; - const SIZEOF_INT = 4; - const FILE_IDENTIFIER_LENGTH = 4; -}
diff --git a/third_party/flatbuffers/php/FlatbufferBuilder.php b/third_party/flatbuffers/php/FlatbufferBuilder.php deleted file mode 100644 index 5c18bf4..0000000 --- a/third_party/flatbuffers/php/FlatbufferBuilder.php +++ /dev/null
@@ -1,966 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// @file -/// @addtogroup flatbuffers_php_api -/// @{ - -namespace Google\FlatBuffers; - -class FlatbufferBuilder -{ - /** - * Internal ByteBuffer for the FlatBuffer data. - * @var ByteBuffer $bb - */ - public $bb; - - /// @cond FLATBUFFERS_INTERNAL - /** - * @var int $space - */ - protected $space; - - /** - * @var int $minalign - */ - protected $minalign = 1; - - /** - * @var array $vtable - */ - protected $vtable; - - /** - * @var int $vtable_in_use - */ - protected $vtable_in_use = 0; - - /** - * @var bool $nested - */ - protected $nested = false; - - /** - * @var int $object_start - */ - protected $object_start; - - /** - * @var array $vtables - */ - protected $vtables = array(); - - /** - * @var int $num_vtables - */ - protected $num_vtables = 0; - - /** - * @var int $vector_num_elems - */ - protected $vector_num_elems = 0; - - /** - * @var bool $force_defaults - */ - protected $force_defaults = false; - /// @endcond - - /** - * Create a FlatBufferBuilder with a given initial size. - * - * @param $initial_size initial byte buffer size. - */ - public function __construct($initial_size) - { - if ($initial_size <= 0) { - $initial_size = 1; - } - $this->space = $initial_size; - $this->bb = $this->newByteBuffer($initial_size); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * create new bytebuffer - * - * @param $size - * @return ByteBuffer - */ - private function newByteBuffer($size) - { - return new ByteBuffer($size); - } - - /** - * Returns the current ByteBuffer offset. - * - * @return int - */ - public function offset() - { - return $this->bb->capacity() - $this->space; - } - - /** - * padding buffer - * - * @param $byte_size - */ - public function pad($byte_size) - { - for ($i = 0; $i < $byte_size; $i++) { - $this->bb->putByte(--$this->space, "\0"); - } - } - - /** - * prepare bytebuffer - * - * @param $size - * @param $additional_bytes - * @throws \Exception - */ - public function prep($size, $additional_bytes) - { - if ($size > $this->minalign) { - $this->minalign = $size; - } - - $align_size = ((~($this->bb->capacity() - $this->space + $additional_bytes)) + 1) & ($size - 1); - while ($this->space < $align_size + $size + $additional_bytes) { - $old_buf_size = $this->bb->capacity(); - $this->bb = $this->growByteBuffer($this->bb); - $this->space += $this->bb->capacity() - $old_buf_size; - } - - $this->pad($align_size); - } - - /** - * @param ByteBuffer $bb - * @return ByteBuffer - * @throws \Exception - */ - private static function growByteBuffer(ByteBuffer $bb) - { - $old_buf_size = $bb->capacity(); - if (($old_buf_size & 0xC0000000) != 0) { - throw new \Exception("FlatBuffers: cannot grow buffer beyond 2 gigabytes"); - } - $new_buf_size = $old_buf_size << 1; - - $bb->setPosition(0); - $nbb = new ByteBuffer($new_buf_size); - - $nbb->setPosition($new_buf_size - $old_buf_size); - - // TODO(chobie): is this little bit faster? - //$nbb->_buffer = substr_replace($nbb->_buffer, $bb->_buffer, $new_buf_size - $old_buf_size, strlen($bb->_buffer)); - for ($i = $new_buf_size - $old_buf_size, $j = 0; $j < strlen($bb->_buffer); $i++, $j++) { - $nbb->_buffer[$i] = $bb->_buffer[$j]; - } - - return $nbb; - } - - /** - * @param $x - */ - public function putBool($x) - { - $this->bb->put($this->space -= 1, chr((int)(bool)($x))); - } - - /** - * @param $x - */ - public function putByte($x) - { - $this->bb->put($this->space -= 1, chr($x)); - } - - /** - * @param $x - */ - public function putSbyte($x) - { - $this->bb->put($this->space -= 1, chr($x)); - } - - /** - * @param $x - */ - public function putShort($x) - { - $this->bb->putShort($this->space -= 2, $x); - } - - /** - * @param $x - */ - public function putUshort($x) - { - $this->bb->putUshort($this->space -= 2, $x); - } - - /** - * @param $x - */ - public function putInt($x) - { - $this->bb->putInt($this->space -= 4, $x); - } - - /** - * @param $x - */ - public function putUint($x) - { - if ($x > PHP_INT_MAX) { - throw new \InvalidArgumentException("your platform can't handle uint correctly. use 64bit machine."); - } - - $this->bb->putUint($this->space -= 4, $x); - } - - /** - * @param $x - */ - public function putLong($x) - { - if ($x > PHP_INT_MAX) { - throw new \InvalidArgumentException("Your platform can't handle long correctly. Use a 64bit machine."); - } - - $this->bb->putLong($this->space -= 8, $x); - } - - /** - * @param $x - */ - public function putUlong($x) - { - if ($x > PHP_INT_MAX) { - throw new \InvalidArgumentException("Your platform can't handle ulong correctly. This is a php limitation. Please wait for the extension release."); - } - - $this->bb->putUlong($this->space -= 8, $x); - } - - /** - * @param $x - */ - public function putFloat($x) - { - $this->bb->putFloat($this->space -= 4, $x); - } - - /** - * @param $x - */ - public function putDouble($x) - { - $this->bb->putDouble($this->space -= 8, $x); - } - /// @endcond - - /** - * Add a `bool` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `bool` to add to the buffer. - */ - public function addBool($x) - { - $this->prep(1, 0); - $this->putBool($x); - } - - /** - * Add a `byte` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `byte` to add to the buffer. - */ - public function addByte($x) - { - $this->prep(1, 0); - $this->putByte($x); - } - - /** - * Add a `signed byte` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `signed byte` to add to the buffer. - */ - public function addSbyte($x) - { - $this->prep(1, 0); - $this->putSbyte($x); - } - - /** - * Add a `short` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `short` to add to the buffer. - */ - public function addShort($x) - { - $this->prep(2, 0); - $this->putShort($x); - } - - /** - * Add an `unsigned short` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `unsigned short` to add to the buffer. - */ - public function addUshort($x) - { - $this->prep(2, 0); - $this->putUshort($x); - } - - /** - * Add an `int` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `int` to add to the buffer. - */ - public function addInt($x) - { - $this->prep(4, 0); - $this->putInt($x); - } - - /** - * Add an `unsigned int` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `unsigned int` to add to the buffer. - */ - public function addUint($x) - { - $this->prep(4, 0); - $this->putUint($x); - } - - /** - * Add a `long` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `long` to add to the buffer. - */ - public function addLong($x) - { - $this->prep(8, 0); - $this->putLong($x); - } - - /** - * Add an `unsigned long` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `unsigned long` to add to the buffer. - */ - public function addUlong($x) - { - $this->prep(8, 0); - $this->putUlong($x); - } - - /** - * Add a `float` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `float` to add to the buffer. - */ - public function addFloat($x) - { - $this->prep(4, 0); - $this->putFloat($x); - } - - /** - * Add a `double` to the buffer, properly aligned, and grows the buffer (if necessary). - * @param $x The `double` to add to the buffer. - */ - public function addDouble($x) - { - $this->prep(8, 0); - $this->putDouble($x); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * @param $o - * @param $x - * @param $d - */ - public function addBoolX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addBool($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addByteX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addByte($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addSbyteX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addSbyte($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addShortX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addShort($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addUshortX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addUshort($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addIntX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addInt($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addUintX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addUint($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addLongX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addLong($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addUlongX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addUlong($x); - $this->slot($o); - } - } - - - /** - * @param $o - * @param $x - * @param $d - */ - public function addFloatX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addFloat($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - */ - public function addDoubleX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addDouble($x); - $this->slot($o); - } - } - - /** - * @param $o - * @param $x - * @param $d - * @throws \Exception - */ - public function addOffsetX($o, $x, $d) - { - if ($this->force_defaults || $x != $d) { - $this->addOffset($x); - $this->slot($o); - } - } - /// @endcond - - /** - * Adds on offset, relative to where it will be written. - * @param $off The offset to add to the buffer. - * @throws \Exception Throws an exception if `$off` is greater than the underlying ByteBuffer's - * offest. - */ - public function addOffset($off) - { - $this->prep(Constants::SIZEOF_INT, 0); // Ensure alignment is already done - if ($off > $this->offset()) { - throw new \Exception(""); - } - - $off = $this->offset() - $off + Constants::SIZEOF_INT; - $this->putInt($off); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * @param $elem_size - * @param $num_elems - * @param $alignment - * @throws \Exception - */ - public function startVector($elem_size, $num_elems, $alignment) - { - $this->notNested(); - $this->vector_num_elems = $num_elems; - $this->prep(Constants::SIZEOF_INT, $elem_size * $num_elems); - $this->prep($alignment, $elem_size * $num_elems); // Just in case alignemnt > int; - } - - /** - * @return int - */ - public function endVector() - { - $this->putUint($this->vector_num_elems); - return $this->offset(); - } - - protected function is_utf8($bytes) - { - if (function_exists('mb_detect_encoding')) { - return (bool) mb_detect_encoding($bytes, 'UTF-8', true); - } - - $len = strlen($bytes); - if ($len < 1) { - /* NOTE: always return 1 when passed string is null */ - return true; - } - - for ($j = 0, $i = 0; $i < $len; $i++) { - // check ACII - if ($bytes[$j] == "\x09" || - $bytes[$j] == "\x0A" || - $bytes[$j] == "\x0D" || - ($bytes[$j] >= "\x20" && $bytes[$j] <= "\x7E")) { - $j++; - continue; - } - - /* non-overlong 2-byte */ - if ((($i+1) <= $len) && - ($bytes[$j] >= "\xC2" && $bytes[$j] <= "\xDF" && - ($bytes[$j+1] >= "\x80" && $bytes[$j+1] <= "\xBF"))) { - $j += 2; - $i++; - continue; - } - - /* excluding overlongs */ - if ((($i + 2) <= $len) && - $bytes[$j] == "\xE0" && - ($bytes[$j+1] >= "\xA0" && $bytes[$j+1] <= "\xBF" && - ($bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF"))) { - $bytes += 3; - $i +=2; - continue; - } - - /* straight 3-byte */ - if ((($i+2) <= $len) && - (($bytes[$j] >= "\xE1" && $bytes[$j] <= "\xEC") || - $bytes[$j] == "\xEE" || - $bytes[$j] = "\xEF") && - ($bytes[$j+1] >= "\x80" && $bytes[$j+1] <= "\xBF") && - ($bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF")) { - $j += 3; - $i += 2; - continue; - } - - /* excluding surrogates */ - if ((($i+2) <= $len) && - $bytes[$j] == "\xED" && - ($bytes[$j+1] >= "\x80" && $bytes[$j+1] <= "\x9f" && - ($bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF"))) { - $j += 3; - $i += 2; - continue; - } - - /* planes 1-3 */ - if ((($i + 3) <= $len) && - $bytes[$j] == "\xF0" && - ($bytes[$j+1] >= "\x90" && $bytes[$j+1] <= "\xBF") && - ($bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF") && - ($bytes[$j+3] >= "\x80" && $bytes[$j+3] <= "\xBF")) { - $j += 4; - $i += 3; - continue; - } - - - /* planes 4-15 */ - if ((($i+3) <= $len) && - $bytes[$j] >= "\xF1" && $bytes[$j] <= "\xF3" && - $bytes[$j+1] >= "\x80" && $bytes[$j+1] <= "\xBF" && - $bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF" && - $bytes[$j+3] >= "\x80" && $bytes[$j+3] <= "\xBF" - ) { - $j += 4; - $i += 3; - continue; - } - - /* plane 16 */ - if ((($i+3) <= $len) && - $bytes[$j] == "\xF4" && - ($bytes[$j+1] >= "\x80" && $bytes[$j+1] <= "\x8F") && - ($bytes[$j+2] >= "\x80" && $bytes[$j+2] <= "\xBF") && - ($bytes[$j+3] >= "\x80" && $bytes[$j+3] <= "\xBF") - ) { - $bytes += 4; - $i += 3; - continue; - } - - - return false; - } - - return true; - } - /// @endcond - - /** - * Encode the string `$s` in the buffer using UTF-8. - * @param string $s The string to encode. - * @return int The offset in the buffer where the encoded string starts. - * @throws InvalidArgumentException Thrown if the input string `$s` is not - * UTF-8. - */ - public function createString($s) - { - if (!$this->is_utf8($s)) { - throw new \InvalidArgumentException("string must be utf-8 encoded value."); - } - - $this->notNested(); - $this->addByte(0); // null terminated - $this->startVector(1, strlen($s), 1); - $this->space -= strlen($s); - for ($i = $this->space, $j = 0 ; $j < strlen($s) ; $i++, $j++) { - $this->bb->_buffer[$i] = $s[$j]; - } - return $this->endVector(); - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * @throws \Exception - */ - public function notNested() - { - if ($this->nested) { - throw new \Exception("FlatBuffers; object serialization must not be nested"); - } - } - - /** - * @param $obj - * @throws \Exception - */ - public function nested($obj) - { - if ($obj != $this->offset()) { - throw new \Exception("FlatBuffers: struct must be serialized inline"); - } - } - - /** - * @param $numfields - * @throws \Exception - */ - public function startObject($numfields) - { - $this->notNested(); - if ($this->vtable == null || count($this->vtable) < $numfields) { - $this->vtable = array(); - } - - $this->vtable_in_use = $numfields; - for ($i = 0; $i < $numfields; $i++) { - $this->vtable[$i] = 0; - } - - $this->nested = true; - $this->object_start = $this->offset(); - } - - /** - * @param $voffset - * @param $x - * @param $d - * @throws \Exception - */ - public function addStructX($voffset, $x, $d) - { - if ($x != $d) { - $this->nested($x); - $this->slot($voffset); - } - } - - /** - * @param $voffset - * @param $x - * @param $d - * @throws \Exception - */ - public function addStruct($voffset, $x, $d) - { - if ($x != $d) { - $this->nested($x); - $this->slot($voffset); - } - } - - /** - * @param $voffset - */ - public function slot($voffset) - { - $this->vtable[$voffset] = $this->offset(); - } - - /** - * @return int - * @throws \Exception - */ - public function endObject() - { - if ($this->vtable == null || !$this->nested) { - throw new \Exception("FlatBuffers: endObject called without startObject"); - } - - $this->addInt(0); - $vtableloc = $this->offset(); - - for ($i = $this->vtable_in_use -1; $i >= 0; $i--) { - $off = ($this->vtable[$i] != 0) ? $vtableloc - $this->vtable[$i] : 0; - $this->addShort($off); - } - - $standard_fields = 2; // the fields below - $this->addShort($vtableloc - $this->object_start); - $this->addShort(($this->vtable_in_use + $standard_fields) * Constants::SIZEOF_SHORT); - - // search for an existing vtable that matches the current one. - $existing_vtable = 0; - - for ($i = 0; $i < $this->num_vtables; $i++) { - $vt1 = $this->bb->capacity() - $this->vtables[$i]; - $vt2 = $this->space; - - $len = $this->bb->getShort($vt1); - - if ($len == $this->bb->getShort($vt2)) { - for ($j = Constants::SIZEOF_SHORT; $j < $len; $j += Constants::SIZEOF_SHORT) { - if ($this->bb->getShort($vt1 + $j) != $this->bb->getShort($vt2 + $j)) { - continue 2; - } - } - $existing_vtable = $this->vtables[$i]; - break; - } - } - - if ($existing_vtable != 0) { - // Found a match: - // Remove the current vtable - $this->space = $this->bb->capacity() - $vtableloc; - $this->bb->putInt($this->space, $existing_vtable - $vtableloc); - } else { - // No Match: - // Add the location of the current vtable to the list of vtables - if ($this->num_vtables == count($this->vtables)) { - $vtables = $this->vtables; - $this->vtables = array(); - // copy of - for ($i = 0; $i < count($vtables) * 2; $i++) { - $this->vtables[$i] = ($i < count($vtables)) ? $vtables[$i] : 0; - } - } - $this->vtables[$this->num_vtables++] = $this->offset(); - $this->bb->putInt($this->bb->capacity() - $vtableloc, $this->offset() - $vtableloc); - } - - $this->nested = false; - $this->vtable = null; - return $vtableloc; - } - - /** - * @param $table - * @param $field - * @throws \Exception - */ - public function required($table, $field) - { - $table_start = $this->bb->capacity() - $table; - $vtable_start = $table_start - $this->bb->getInt($table_start); - $ok = $this->bb->getShort($vtable_start + $field) != 0; - - if (!$ok) { - throw new \Exception("FlatBuffers: field " . $field . " must be set"); - } - } - /// @endcond - - /** - * Finalize a buffer, pointing to the given `$root_table`. - * @param $root_table An offest to be added to the buffer. - * @param $file_identifier A FlatBuffer file identifier to be added to the - * buffer before `$root_table`. This defaults to `null`. - * @throws InvalidArgumentException Thrown if an invalid `$identifier` is - * given, where its length is not equal to - * `Constants::FILE_IDENTIFIER_LENGTH`. - */ - public function finish($root_table, $identifier = null) - { - if ($identifier == null) { - $this->prep($this->minalign, Constants::SIZEOF_INT); - $this->addOffset($root_table); - $this->bb->setPosition($this->space); - } else { - $this->prep($this->minalign, Constants::SIZEOF_INT + Constants::FILE_IDENTIFIER_LENGTH); - if (strlen($identifier) != Constants::FILE_IDENTIFIER_LENGTH) { - throw new \InvalidArgumentException( - sprintf("FlatBuffers: file identifier must be length %d", - Constants::FILE_IDENTIFIER_LENGTH)); - } - - for ($i = Constants::FILE_IDENTIFIER_LENGTH - 1; $i >= 0; - $i--) { - $this->addByte(ord($identifier[$i])); - } - $this->finish($root_table); - } - } - - /** - * In order to save space, fields that are set to their default value don't - * get serialized into the buffer. - * @param bool $forceDefaults When set to `true`, always serializes default - * values. - */ - public function forceDefaults($forceDefaults) - { - $this->force_defaults = $forceDefaults; - } - - /** - * Get the ByteBuffer representing the FlatBuffer. - * @return ByteBuffer The ByteBuffer containing the FlatBuffer data. - */ - public function dataBuffer() - { - return $this->bb; - } - - /// @cond FLATBUFFERS_INTERNAL - /** - * @return int - */ - public function dataStart() - { - return $this->space; - } - /// @endcond - - /** - * Utility function to copy and return the FlatBuffer data from the - * underlying ByteBuffer. - * @return string A string (representing a byte[]) that contains a copy - * of the FlatBuffer data. - */ - public function sizedByteArray() - { - $start = $this->space; - $length = $this->bb->capacity() - $this->space; - - $result = str_repeat("\0", $length); - $this->bb->setPosition($start); - $this->bb->getX($result); - - return $result; - } -} - -/// @}
diff --git a/third_party/flatbuffers/php/Struct.php b/third_party/flatbuffers/php/Struct.php deleted file mode 100644 index 94e712b..0000000 --- a/third_party/flatbuffers/php/Struct.php +++ /dev/null
@@ -1,31 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Google\FlatBuffers; - -abstract class Struct -{ - /** - * @var int $bb_pos - */ - protected $bb_pos; - - /** - * @var ByteBuffer $bb - */ - protected $bb; -}
diff --git a/third_party/flatbuffers/php/Table.php b/third_party/flatbuffers/php/Table.php deleted file mode 100644 index 6f917c1..0000000 --- a/third_party/flatbuffers/php/Table.php +++ /dev/null
@@ -1,135 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Google\FlatBuffers; - -abstract class Table -{ - /** - * @var int $bb_pos - */ - protected $bb_pos; - /** - * @var ByteBuffer $bb - */ - protected $bb; - - public function __construct() - { - } - - /** - * returns actual vtable offset - * - * @param $vtable_offset - * @return int offset > 0 means exist value. 0 means not exist - */ - protected function __offset($vtable_offset) - { - $vtable = $this->bb_pos - $this->bb->getInt($this->bb_pos); - return $vtable_offset < $this->bb->getShort($vtable) ? $this->bb->getShort($vtable + $vtable_offset) : 0; - } - - /** - * @param $offset - * @return mixed - */ - protected function __indirect($offset) - { - return $offset + $this->bb->getInt($offset); - } - - /** - * fetch utf8 encoded string. - * - * @param $offset - * @return string - */ - protected function __string($offset) - { - $offset += $this->bb->getInt($offset); - $len = $this->bb->getInt($offset); - $startPos = $offset + Constants::SIZEOF_INT; - return substr($this->bb->_buffer, $startPos, $len); - } - - /** - * @param $offset - * @return int - */ - protected function __vector_len($offset) - { - $offset += $this->bb_pos; - $offset += $this->bb->getInt($offset); - return $this->bb->getInt($offset); - } - - /** - * @param $offset - * @return int - */ - protected function __vector($offset) - { - $offset += $this->bb_pos; - // data starts after the length - return $offset + $this->bb->getInt($offset) + Constants::SIZEOF_INT; - } - - protected function __vector_as_bytes($vector_offset, $elem_size=1) - { - $o = $this->__offset($vector_offset); - if ($o == 0) { - return null; - } - - return substr($this->bb->_buffer, $this->__vector($o), $this->__vector_len($o) * $elem_size); - } - - /** - * @param Table $table - * @param int $offset - * @return Table - */ - protected function __union($table, $offset) - { - $offset += $this->bb_pos; - $table->bb_pos = $offset + $this->bb->getInt($offset); - $table->bb = $this->bb; - return $table; - } - - /** - * @param ByteBuffer $bb - * @param string $ident - * @return bool - * @throws \ArgumentException - */ - protected static function __has_identifier($bb, $ident) - { - if (strlen($ident) != Constants::FILE_IDENTIFIER_LENGTH) { - throw new \ArgumentException("FlatBuffers: file identifier must be length " . Constants::FILE_IDENTIFIER_LENGTH); - } - - for ($i = 0; $i < 4; $i++) { - if ($ident[$i] != $bb->get($bb->getPosition() + Constants::SIZEOF_INT + $i)) { - return false; - } - } - - return true; - } -}
diff --git a/third_party/flatbuffers/pom.xml b/third_party/flatbuffers/pom.xml deleted file mode 100644 index a4f74bf..0000000 --- a/third_party/flatbuffers/pom.xml +++ /dev/null
@@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>com.google.flatbuffers</groupId> - <artifactId>flatbuffers-java</artifactId> - <version>1.6.0-SNAPSHOT</version> - <packaging>bundle</packaging> - <name>FlatBuffers Java API</name> - <description> - Memory Efficient Serialization Library - </description> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <url>https://github.com/google/flatbuffers</url> - <licenses> - <license> - <name>Apache License V2.0</name> - <url>https://raw.githubusercontent.com/google/flatbuffers/master/LICENSE.txt</url> - <distribution>repo</distribution> - </license> - </licenses> - <scm> - <url>https://github.com/google/flatbuffers</url> - <connection> - scm:git:https://github.com/google/flatbuffers.git - </connection> - </scm> - <dependencies> - </dependencies> - <build> - <sourceDirectory>java</sourceDirectory> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - <version>3.2</version> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <includes> - <include>**/*Test.java</include> - </includes> - </configuration> - <version>2.18.1</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <version>2.9.1</version> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>3.0.1</version> - <extensions>true</extensions> - </plugin> - </plugins> - </build> -</project> -
diff --git a/third_party/flatbuffers/python/__init__.py b/third_party/flatbuffers/python/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/flatbuffers/python/__init__.py +++ /dev/null
diff --git a/third_party/flatbuffers/python/flatbuffers/__init__.py b/third_party/flatbuffers/python/flatbuffers/__init__.py deleted file mode 100644 index d14872a..0000000 --- a/third_party/flatbuffers/python/flatbuffers/__init__.py +++ /dev/null
@@ -1,17 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from .builder import Builder -from .table import Table -from .compat import range_func as compat_range
diff --git a/third_party/flatbuffers/python/flatbuffers/builder.py b/third_party/flatbuffers/python/flatbuffers/builder.py deleted file mode 100644 index 552d0e2..0000000 --- a/third_party/flatbuffers/python/flatbuffers/builder.py +++ /dev/null
@@ -1,677 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from . import number_types as N -from .number_types import (UOffsetTFlags, SOffsetTFlags, VOffsetTFlags) - -from . import encode -from . import packer - -from . import compat -from .compat import range_func -from .compat import memoryview_type - - -## @file -## @addtogroup flatbuffers_python_api -## @{ - -## @cond FLATBUFFERS_INTERNAL -class OffsetArithmeticError(RuntimeError): - """ - Error caused by an Offset arithmetic error. Probably caused by bad - writing of fields. This is considered an unreachable situation in - normal circumstances. - """ - pass - - -class IsNotNestedError(RuntimeError): - """ - Error caused by using a Builder to write Object data when not inside - an Object. - """ - pass - - -class IsNestedError(RuntimeError): - """ - Error caused by using a Builder to begin an Object when an Object is - already being built. - """ - pass - - -class StructIsNotInlineError(RuntimeError): - """ - Error caused by using a Builder to write a Struct at a location that - is not the current Offset. - """ - pass - - -class BuilderSizeError(RuntimeError): - """ - Error caused by causing a Builder to exceed the hardcoded limit of 2 - gigabytes. - """ - pass - -class BuilderNotFinishedError(RuntimeError): - """ - Error caused by not calling `Finish` before calling `Output`. - """ - pass - - -# VtableMetadataFields is the count of metadata fields in each vtable. -VtableMetadataFields = 2 -## @endcond - -class Builder(object): - """ A Builder is used to construct one or more FlatBuffers. - - Typically, Builder objects will be used from code generated by the `flatc` - compiler. - - A Builder constructs byte buffers in a last-first manner for simplicity and - performance during reading. - - Internally, a Builder is a state machine for creating FlatBuffer objects. - - It holds the following internal state: - - Bytes: an array of bytes. - - current_vtable: a list of integers. - - vtables: a list of vtable entries (i.e. a list of list of integers). - - Attributes: - Bytes: The internal `bytearray` for the Builder. - finished: A boolean determining if the Builder has been finalized. - """ - - ## @cond FLATBUFFERS_INTENRAL - __slots__ = ("Bytes", "current_vtable", "head", "minalign", "objectEnd", - "vtables", "nested", "finished") - - """Maximum buffer size constant, in bytes. - - Builder will never allow it's buffer grow over this size. - Currently equals 2Gb. - """ - MAX_BUFFER_SIZE = 2**31 - ## @endcond - - def __init__(self, initialSize): - """Initializes a Builder of size `initial_size`. - - The internal buffer is grown as needed. - """ - - if not (0 <= initialSize <= Builder.MAX_BUFFER_SIZE): - msg = "flatbuffers: Cannot create Builder larger than 2 gigabytes." - raise BuilderSizeError(msg) - - self.Bytes = bytearray(initialSize) - ## @cond FLATBUFFERS_INTERNAL - self.current_vtable = None - self.head = UOffsetTFlags.py_type(initialSize) - self.minalign = 1 - self.objectEnd = None - self.vtables = [] - self.nested = False - ## @endcond - self.finished = False - - - def Output(self): - """Return the portion of the buffer that has been used for writing data. - - This is the typical way to access the FlatBuffer data inside the - builder. If you try to access `Builder.Bytes` directly, you would need - to manually index it with `Head()`, since the buffer is constructed - backwards. - - It raises BuilderNotFinishedError if the buffer has not been finished - with `Finish`. - """ - - if not self.finished: - raise BuilderNotFinishedError() - - return self.Bytes[self.Head():] - - ## @cond FLATBUFFERS_INTERNAL - def StartObject(self, numfields): - """StartObject initializes bookkeeping for writing a new object.""" - - self.assertNotNested() - - # use 32-bit offsets so that arithmetic doesn't overflow. - self.current_vtable = [0 for _ in range_func(numfields)] - self.objectEnd = self.Offset() - self.minalign = 1 - self.nested = True - - def WriteVtable(self): - """ - WriteVtable serializes the vtable for the current object, if needed. - - Before writing out the vtable, this checks pre-existing vtables for - equality to this one. If an equal vtable is found, point the object to - the existing vtable and return. - - Because vtable values are sensitive to alignment of object data, not - all logically-equal vtables will be deduplicated. - - A vtable has the following format: - <VOffsetT: size of the vtable in bytes, including this value> - <VOffsetT: size of the object in bytes, including the vtable offset> - <VOffsetT: offset for a field> * N, where N is the number of fields - in the schema for this type. Includes deprecated fields. - Thus, a vtable is made of 2 + N elements, each VOffsetT bytes wide. - - An object has the following format: - <SOffsetT: offset to this object's vtable (may be negative)> - <byte: data>+ - """ - - # Prepend a zero scalar to the object. Later in this function we'll - # write an offset here that points to the object's vtable: - self.PrependSOffsetTRelative(0) - - objectOffset = self.Offset() - existingVtable = None - - # Search backwards through existing vtables, because similar vtables - # are likely to have been recently appended. See - # BenchmarkVtableDeduplication for a case in which this heuristic - # saves about 30% of the time used in writing objects with duplicate - # tables. - - i = len(self.vtables) - 1 - while i >= 0: - # Find the other vtable, which is associated with `i`: - vt2Offset = self.vtables[i] - vt2Start = len(self.Bytes) - vt2Offset - vt2Len = encode.Get(packer.voffset, self.Bytes, vt2Start) - - metadata = VtableMetadataFields * N.VOffsetTFlags.bytewidth - vt2End = vt2Start + vt2Len - vt2 = self.Bytes[vt2Start+metadata:vt2End] - - # Compare the other vtable to the one under consideration. - # If they are equal, store the offset and break: - if vtableEqual(self.current_vtable, objectOffset, vt2): - existingVtable = vt2Offset - break - - i -= 1 - - if existingVtable is None: - # Did not find a vtable, so write this one to the buffer. - - # Write out the current vtable in reverse , because - # serialization occurs in last-first order: - i = len(self.current_vtable) - 1 - while i >= 0: - off = 0 - if self.current_vtable[i] != 0: - # Forward reference to field; - # use 32bit number to ensure no overflow: - off = objectOffset - self.current_vtable[i] - - self.PrependVOffsetT(off) - i -= 1 - - # The two metadata fields are written last. - - # First, store the object bytesize: - objectSize = UOffsetTFlags.py_type(objectOffset - self.objectEnd) - self.PrependVOffsetT(VOffsetTFlags.py_type(objectSize)) - - # Second, store the vtable bytesize: - vBytes = len(self.current_vtable) + VtableMetadataFields - vBytes *= N.VOffsetTFlags.bytewidth - self.PrependVOffsetT(VOffsetTFlags.py_type(vBytes)) - - # Next, write the offset to the new vtable in the - # already-allocated SOffsetT at the beginning of this object: - objectStart = SOffsetTFlags.py_type(len(self.Bytes) - objectOffset) - encode.Write(packer.soffset, self.Bytes, objectStart, - SOffsetTFlags.py_type(self.Offset() - objectOffset)) - - # Finally, store this vtable in memory for future - # deduplication: - self.vtables.append(self.Offset()) - else: - # Found a duplicate vtable. - - objectStart = SOffsetTFlags.py_type(len(self.Bytes) - objectOffset) - self.head = UOffsetTFlags.py_type(objectStart) - - # Write the offset to the found vtable in the - # already-allocated SOffsetT at the beginning of this object: - encode.Write(packer.soffset, self.Bytes, self.Head(), - SOffsetTFlags.py_type(existingVtable - objectOffset)) - - self.current_vtable = None - return objectOffset - - def EndObject(self): - """EndObject writes data necessary to finish object construction.""" - self.assertNested() - self.nested = False - return self.WriteVtable() - - def growByteBuffer(self): - """Doubles the size of the byteslice, and copies the old data towards - the end of the new buffer (since we build the buffer backwards).""" - if len(self.Bytes) == Builder.MAX_BUFFER_SIZE: - msg = "flatbuffers: cannot grow buffer beyond 2 gigabytes" - raise BuilderSizeError(msg) - - newSize = min(len(self.Bytes) * 2, Builder.MAX_BUFFER_SIZE) - if newSize == 0: - newSize = 1 - bytes2 = bytearray(newSize) - bytes2[newSize-len(self.Bytes):] = self.Bytes - self.Bytes = bytes2 - ## @endcond - - def Head(self): - """Get the start of useful data in the underlying byte buffer. - - Note: unlike other functions, this value is interpreted as from the - left. - """ - ## @cond FLATBUFFERS_INTERNAL - return self.head - ## @endcond - - ## @cond FLATBUFFERS_INTERNAL - def Offset(self): - """Offset relative to the end of the buffer.""" - return UOffsetTFlags.py_type(len(self.Bytes) - self.Head()) - - def Pad(self, n): - """Pad places zeros at the current offset.""" - for i in range_func(n): - self.Place(0, N.Uint8Flags) - - def Prep(self, size, additionalBytes): - """ - Prep prepares to write an element of `size` after `additional_bytes` - have been written, e.g. if you write a string, you need to align - such the int length field is aligned to SizeInt32, and the string - data follows it directly. - If all you need to do is align, `additionalBytes` will be 0. - """ - - # Track the biggest thing we've ever aligned to. - if size > self.minalign: - self.minalign = size - - # Find the amount of alignment needed such that `size` is properly - # aligned after `additionalBytes`: - alignSize = (~(len(self.Bytes) - self.Head() + additionalBytes)) + 1 - alignSize &= (size - 1) - - # Reallocate the buffer if needed: - while self.Head() < alignSize+size+additionalBytes: - oldBufSize = len(self.Bytes) - self.growByteBuffer() - updated_head = self.head + len(self.Bytes) - oldBufSize - self.head = UOffsetTFlags.py_type(updated_head) - self.Pad(alignSize) - - def PrependSOffsetTRelative(self, off): - """ - PrependSOffsetTRelative prepends an SOffsetT, relative to where it - will be written. - """ - - # Ensure alignment is already done: - self.Prep(N.SOffsetTFlags.bytewidth, 0) - if not (off <= self.Offset()): - msg = "flatbuffers: Offset arithmetic error." - raise OffsetArithmeticError(msg) - off2 = self.Offset() - off + N.SOffsetTFlags.bytewidth - self.PlaceSOffsetT(off2) - ## @endcond - - def PrependUOffsetTRelative(self, off): - """Prepends an unsigned offset into vector data, relative to where it - will be written. - """ - - # Ensure alignment is already done: - self.Prep(N.UOffsetTFlags.bytewidth, 0) - if not (off <= self.Offset()): - msg = "flatbuffers: Offset arithmetic error." - raise OffsetArithmeticError(msg) - off2 = self.Offset() - off + N.UOffsetTFlags.bytewidth - self.PlaceUOffsetT(off2) - - ## @cond FLATBUFFERS_INTERNAL - def StartVector(self, elemSize, numElems, alignment): - """ - StartVector initializes bookkeeping for writing a new vector. - - A vector has the following format: - - <UOffsetT: number of elements in this vector> - - <T: data>+, where T is the type of elements of this vector. - """ - - self.assertNotNested() - self.nested = True - self.Prep(N.Uint32Flags.bytewidth, elemSize*numElems) - self.Prep(alignment, elemSize*numElems) # In case alignment > int. - return self.Offset() - ## @endcond - - def EndVector(self, vectorNumElems): - """EndVector writes data necessary to finish vector construction.""" - - self.assertNested() - ## @cond FLATBUFFERS_INTERNAL - self.nested = False - ## @endcond - # we already made space for this, so write without PrependUint32 - self.PlaceUOffsetT(vectorNumElems) - return self.Offset() - - def CreateString(self, s, encoding='utf-8', errors='strict'): - """CreateString writes a null-terminated byte string as a vector.""" - - self.assertNotNested() - ## @cond FLATBUFFERS_INTERNAL - self.nested = True - ## @endcond - - if isinstance(s, compat.string_types): - x = s.encode(encoding, errors) - elif isinstance(s, compat.binary_types): - x = s - else: - raise TypeError("non-string passed to CreateString") - - self.Prep(N.UOffsetTFlags.bytewidth, (len(x)+1)*N.Uint8Flags.bytewidth) - self.Place(0, N.Uint8Flags) - - l = UOffsetTFlags.py_type(len(s)) - ## @cond FLATBUFFERS_INTERNAL - self.head = UOffsetTFlags.py_type(self.Head() - l) - ## @endcond - self.Bytes[self.Head():self.Head()+l] = x - - return self.EndVector(len(x)) - - ## @cond FLATBUFFERS_INTERNAL - def assertNested(self): - """ - Check that we are in the process of building an object. - """ - - if not self.nested: - raise IsNotNestedError() - - def assertNotNested(self): - """ - Check that no other objects are being built while making this - object. If not, raise an exception. - """ - - if self.nested: - raise IsNestedError() - - def assertStructIsInline(self, obj): - """ - Structs are always stored inline, so need to be created right - where they are used. You'll get this error if you created it - elsewhere. - """ - - N.enforce_number(obj, N.UOffsetTFlags) - if obj != self.Offset(): - msg = ("flatbuffers: Tried to write a Struct at an Offset that " - "is different from the current Offset of the Builder.") - raise StructIsNotInlineError(msg) - - def Slot(self, slotnum): - """ - Slot sets the vtable key `voffset` to the current location in the - buffer. - - """ - self.assertNested() - self.current_vtable[slotnum] = self.Offset() - ## @endcond - - def Finish(self, rootTable): - """Finish finalizes a buffer, pointing to the given `rootTable`.""" - N.enforce_number(rootTable, N.UOffsetTFlags) - self.Prep(self.minalign, N.UOffsetTFlags.bytewidth) - self.PrependUOffsetTRelative(rootTable) - self.finished = True - return self.Head() - - ## @cond FLATBUFFERS_INTERNAL - def Prepend(self, flags, off): - self.Prep(flags.bytewidth, 0) - self.Place(off, flags) - - def PrependSlot(self, flags, o, x, d): - N.enforce_number(x, flags) - N.enforce_number(d, flags) - if x != d: - self.Prepend(flags, x) - self.Slot(o) - - def PrependBoolSlot(self, *args): self.PrependSlot(N.BoolFlags, *args) - - def PrependByteSlot(self, *args): self.PrependSlot(N.Uint8Flags, *args) - - def PrependUint8Slot(self, *args): self.PrependSlot(N.Uint8Flags, *args) - - def PrependUint16Slot(self, *args): self.PrependSlot(N.Uint16Flags, *args) - - def PrependUint32Slot(self, *args): self.PrependSlot(N.Uint32Flags, *args) - - def PrependUint64Slot(self, *args): self.PrependSlot(N.Uint64Flags, *args) - - def PrependInt8Slot(self, *args): self.PrependSlot(N.Int8Flags, *args) - - def PrependInt16Slot(self, *args): self.PrependSlot(N.Int16Flags, *args) - - def PrependInt32Slot(self, *args): self.PrependSlot(N.Int32Flags, *args) - - def PrependInt64Slot(self, *args): self.PrependSlot(N.Int64Flags, *args) - - def PrependFloat32Slot(self, *args): self.PrependSlot(N.Float32Flags, - *args) - - def PrependFloat64Slot(self, *args): self.PrependSlot(N.Float64Flags, - *args) - - def PrependUOffsetTRelativeSlot(self, o, x, d): - """ - PrependUOffsetTRelativeSlot prepends an UOffsetT onto the object at - vtable slot `o`. If value `x` equals default `d`, then the slot will - be set to zero and no other data will be written. - """ - - if x != d: - self.PrependUOffsetTRelative(x) - self.Slot(o) - - def PrependStructSlot(self, v, x, d): - """ - PrependStructSlot prepends a struct onto the object at vtable slot `o`. - Structs are stored inline, so nothing additional is being added. - In generated code, `d` is always 0. - """ - - N.enforce_number(d, N.UOffsetTFlags) - if x != d: - self.assertStructIsInline(x) - self.Slot(v) - - ## @endcond - - def PrependBool(self, x): - """Prepend a `bool` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.BoolFlags, x) - - def PrependByte(self, x): - """Prepend a `byte` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Uint8Flags, x) - - def PrependUint8(self, x): - """Prepend an `uint8` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Uint8Flags, x) - - def PrependUint16(self, x): - """Prepend an `uint16` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Uint16Flags, x) - - def PrependUint32(self, x): - """Prepend an `uint32` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Uint32Flags, x) - - def PrependUint64(self, x): - """Prepend an `uint64` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Uint64Flags, x) - - def PrependInt8(self, x): - """Prepend an `int8` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Int8Flags, x) - - def PrependInt16(self, x): - """Prepend an `int16` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Int16Flags, x) - - def PrependInt32(self, x): - """Prepend an `int32` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Int32Flags, x) - - def PrependInt64(self, x): - """Prepend an `int64` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Int64Flags, x) - - def PrependFloat32(self, x): - """Prepend a `float32` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Float32Flags, x) - - def PrependFloat64(self, x): - """Prepend a `float64` to the Builder buffer. - - Note: aligns and checks for space. - """ - self.Prepend(N.Float64Flags, x) - -############################################################## - - ## @cond FLATBUFFERS_INTERNAL - def PrependVOffsetT(self, x): self.Prepend(N.VOffsetTFlags, x) - - def Place(self, x, flags): - """ - Place prepends a value specified by `flags` to the Builder, - without checking for available space. - """ - - N.enforce_number(x, flags) - self.head = self.head - flags.bytewidth - encode.Write(flags.packer_type, self.Bytes, self.Head(), x) - - def PlaceVOffsetT(self, x): - """PlaceVOffsetT prepends a VOffsetT to the Builder, without checking - for space. - """ - N.enforce_number(x, N.VOffsetTFlags) - self.head = self.head - N.VOffsetTFlags.bytewidth - encode.Write(packer.voffset, self.Bytes, self.Head(), x) - - def PlaceSOffsetT(self, x): - """PlaceSOffsetT prepends a SOffsetT to the Builder, without checking - for space. - """ - N.enforce_number(x, N.SOffsetTFlags) - self.head = self.head - N.SOffsetTFlags.bytewidth - encode.Write(packer.soffset, self.Bytes, self.Head(), x) - - def PlaceUOffsetT(self, x): - """PlaceUOffsetT prepends a UOffsetT to the Builder, without checking - for space. - """ - N.enforce_number(x, N.UOffsetTFlags) - self.head = self.head - N.UOffsetTFlags.bytewidth - encode.Write(packer.uoffset, self.Bytes, self.Head(), x) - ## @endcond - -## @cond FLATBUFFERS_INTERNAL -def vtableEqual(a, objectStart, b): - """vtableEqual compares an unwritten vtable to a written vtable.""" - - N.enforce_number(objectStart, N.UOffsetTFlags) - - if len(a) * N.VOffsetTFlags.bytewidth != len(b): - return False - - for i, elem in enumerate(a): - x = encode.Get(packer.voffset, b, i * N.VOffsetTFlags.bytewidth) - - # Skip vtable entries that indicate a default value. - if x == 0 and elem == 0: - pass - else: - y = objectStart - elem - if x != y: - return False - return True -## @endcond -## @}
diff --git a/third_party/flatbuffers/python/flatbuffers/compat.py b/third_party/flatbuffers/python/flatbuffers/compat.py deleted file mode 100644 index e031535..0000000 --- a/third_party/flatbuffers/python/flatbuffers/compat.py +++ /dev/null
@@ -1,46 +0,0 @@ -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" A tiny version of `six` to help with backwards compability. """ - -import sys - -PY2 = sys.version_info[0] == 2 -PY26 = sys.version_info[0:2] == (2, 6) -PY27 = sys.version_info[0:2] == (2, 7) -PY275 = sys.version_info[0:3] >= (2, 7, 5) -PY3 = sys.version_info[0] == 3 -PY34 = sys.version_info[0:2] >= (3, 4) - -if PY3: - string_types = (str,) - binary_types = (bytes,bytearray) - range_func = range - memoryview_type = memoryview - struct_bool_decl = "?" -else: - string_types = (unicode,) - if PY26 or PY27: - binary_types = (str,bytearray) - else: - binary_types = (str,) - range_func = xrange - if PY26 or (PY27 and not PY275): - memoryview_type = buffer - struct_bool_decl = "<b" - else: - memoryview_type = memoryview - struct_bool_decl = "?" - -# NOTE: Future Jython support may require code here (look at `six`).
diff --git a/third_party/flatbuffers/python/flatbuffers/encode.py b/third_party/flatbuffers/python/flatbuffers/encode.py deleted file mode 100644 index 1aa9230..0000000 --- a/third_party/flatbuffers/python/flatbuffers/encode.py +++ /dev/null
@@ -1,27 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from . import number_types as N -from . import packer -from .compat import memoryview_type - - -def Get(packer_type, buf, head): - """ Get decodes a value at buf[head:] using `packer_type`. """ - return packer_type.unpack_from(memoryview_type(buf), head)[0] - - -def Write(packer_type, buf, head, n): - """ Write encodes `n` at buf[head:] using `packer_type`. """ - packer_type.pack_into(buf, head, n)
diff --git a/third_party/flatbuffers/python/flatbuffers/number_types.py b/third_party/flatbuffers/python/flatbuffers/number_types.py deleted file mode 100644 index a9605de..0000000 --- a/third_party/flatbuffers/python/flatbuffers/number_types.py +++ /dev/null
@@ -1,172 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import collections -import struct - -from . import packer - - -# For reference, see: -# https://docs.python.org/2/library/ctypes.html#ctypes-fundamental-data-types-2 - -# These classes could be collections.namedtuple instances, but those are new -# in 2.6 and we want to work towards 2.5 compatability. - -class BoolFlags(object): - bytewidth = 1 - min_val = False - max_val = True - py_type = bool - name = "bool" - packer_type = packer.boolean - - -class Uint8Flags(object): - bytewidth = 1 - min_val = 0 - max_val = (2**8) - 1 - py_type = int - name = "uint8" - packer_type = packer.uint8 - - -class Uint16Flags(object): - bytewidth = 2 - min_val = 0 - max_val = (2**16) - 1 - py_type = int - name = "uint16" - packer_type = packer.uint16 - - -class Uint32Flags(object): - bytewidth = 4 - min_val = 0 - max_val = (2**32) - 1 - py_type = int - name = "uint32" - packer_type = packer.uint32 - - -class Uint64Flags(object): - bytewidth = 8 - min_val = 0 - max_val = (2**64) - 1 - py_type = int - name = "uint64" - packer_type = packer.uint64 - - -class Int8Flags(object): - bytewidth = 1 - min_val = -(2**7) - max_val = (2**7) - 1 - py_type = int - name = "int8" - packer_type = packer.int8 - - -class Int16Flags(object): - bytewidth = 2 - min_val = -(2**15) - max_val = (2**15) - 1 - py_type = int - name = "int16" - packer_type = packer.int16 - - -class Int32Flags(object): - bytewidth = 4 - min_val = -(2**31) - max_val = (2**31) - 1 - py_type = int - name = "int32" - packer_type = packer.int32 - - -class Int64Flags(object): - bytewidth = 8 - min_val = -(2**63) - max_val = (2**63) - 1 - py_type = int - name = "int64" - packer_type = packer.int64 - - -class Float32Flags(object): - bytewidth = 4 - min_val = None - max_val = None - py_type = float - name = "float32" - packer_type = packer.float32 - - -class Float64Flags(object): - bytewidth = 8 - min_val = None - max_val = None - py_type = float - name = "float64" - packer_type = packer.float64 - - -class SOffsetTFlags(Int32Flags): - pass - - -class UOffsetTFlags(Uint32Flags): - pass - - -class VOffsetTFlags(Uint16Flags): - pass - - -def valid_number(n, flags): - if flags.min_val is None and flags.max_val is None: - return True - return flags.min_val <= n <= flags.max_val - - -def enforce_number(n, flags): - if flags.min_val is None and flags.max_val is None: - return - if not flags.min_val <= n <= flags.max_val: - raise TypeError("bad number %s for type %s" % (str(n), flags.name)) - - -def float32_to_uint32(n): - packed = struct.pack("<1f", n) - (converted,) = struct.unpack("<1L", packed) - return converted - - -def uint32_to_float32(n): - packed = struct.pack("<1L", n) - (unpacked,) = struct.unpack("<1f", packed) - return unpacked - - -def float64_to_uint64(n): - packed = struct.pack("<1d", n) - (converted,) = struct.unpack("<1Q", packed) - return converted - - -def uint64_to_float64(n): - packed = struct.pack("<1Q", n) - (unpacked,) = struct.unpack("<1d", packed) - return unpacked
diff --git a/third_party/flatbuffers/python/flatbuffers/packer.py b/third_party/flatbuffers/python/flatbuffers/packer.py deleted file mode 100644 index 20ee9f1..0000000 --- a/third_party/flatbuffers/python/flatbuffers/packer.py +++ /dev/null
@@ -1,42 +0,0 @@ -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -Provide pre-compiled struct packers for encoding and decoding. - -See: https://docs.python.org/2/library/struct.html#format-characters -""" - -import struct -from . import compat - - -boolean = struct.Struct(compat.struct_bool_decl) - -uint8 = struct.Struct("<B") -uint16 = struct.Struct("<H") -uint32 = struct.Struct("<I") -uint64 = struct.Struct("<Q") - -int8 = struct.Struct("<b") -int16 = struct.Struct("<h") -int32 = struct.Struct("<i") -int64 = struct.Struct("<q") - -float32 = struct.Struct("<f") -float64 = struct.Struct("<d") - -uoffset = uint32 -soffset = int32 -voffset = uint16
diff --git a/third_party/flatbuffers/python/flatbuffers/table.py b/third_party/flatbuffers/python/flatbuffers/table.py deleted file mode 100644 index 6cffe4c..0000000 --- a/third_party/flatbuffers/python/flatbuffers/table.py +++ /dev/null
@@ -1,117 +0,0 @@ -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from . import encode -from . import number_types as N - - -class Table(object): - """Table wraps a byte slice and provides read access to its data. - - The variable `Pos` indicates the root of the FlatBuffers object therein.""" - - __slots__ = ("Bytes", "Pos") - - def __init__(self, buf, pos): - N.enforce_number(pos, N.UOffsetTFlags) - - self.Bytes = buf - self.Pos = pos - - def Offset(self, vtableOffset): - """Offset provides access into the Table's vtable. - - Deprecated fields are ignored by checking the vtable's length.""" - - vtable = self.Pos - self.Get(N.SOffsetTFlags, self.Pos) - vtableEnd = self.Get(N.VOffsetTFlags, vtable) - if vtableOffset < vtableEnd: - return self.Get(N.VOffsetTFlags, vtable + vtableOffset) - return 0 - - def Indirect(self, off): - """Indirect retrieves the relative offset stored at `offset`.""" - N.enforce_number(off, N.UOffsetTFlags) - return off + encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) - - def String(self, off): - """String gets a string from data stored inside the flatbuffer.""" - N.enforce_number(off, N.UOffsetTFlags) - off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) - start = off + N.UOffsetTFlags.bytewidth - length = encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) - return bytes(self.Bytes[start:start+length]) - - def VectorLen(self, off): - """VectorLen retrieves the length of the vector whose offset is stored - at "off" in this object.""" - N.enforce_number(off, N.UOffsetTFlags) - - off += self.Pos - off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) - ret = encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) - return ret - - def Vector(self, off): - """Vector retrieves the start of data of the vector whose offset is - stored at "off" in this object.""" - N.enforce_number(off, N.UOffsetTFlags) - - off += self.Pos - x = off + self.Get(N.UOffsetTFlags, off) - # data starts after metadata containing the vector length - x += N.UOffsetTFlags.bytewidth - return x - - def Union(self, t2, off): - """Union initializes any Table-derived type to point to the union at - the given offset.""" - assert type(t2) is Table - N.enforce_number(off, N.UOffsetTFlags) - - off += self.Pos - t2.Pos = off + self.Get(N.UOffsetTFlags, off) - t2.Bytes = self.Bytes - - def Get(self, flags, off): - """ - Get retrieves a value of the type specified by `flags` at the - given offset. - """ - N.enforce_number(off, N.UOffsetTFlags) - return flags.py_type(encode.Get(flags.packer_type, self.Bytes, off)) - - def GetSlot(self, slot, d, validator_flags): - N.enforce_number(slot, N.VOffsetTFlags) - if validator_flags is not None: - N.enforce_number(d, validator_flags) - off = self.Offset(slot) - if off == 0: - return d - return self.Get(validator_flags, self.Pos + off) - - def GetVOffsetTSlot(self, slot, d): - """ - GetVOffsetTSlot retrieves the VOffsetT that the given vtable location - points to. If the vtable value is zero, the default value `d` - will be returned. - """ - - N.enforce_number(slot, N.VOffsetTFlags) - N.enforce_number(d, N.VOffsetTFlags) - - off = self.Offset(slot) - if off == 0: - return d - return off
diff --git a/third_party/flatbuffers/python/setup.py b/third_party/flatbuffers/python/setup.py deleted file mode 100644 index 39afef3..0000000 --- a/third_party/flatbuffers/python/setup.py +++ /dev/null
@@ -1,30 +0,0 @@ -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from setuptools import setup - -setup( - name='flatbuffers', - version='2015.05.14.0', - license='Apache 2.0', - author='FlatBuffers Contributors', - author_email='me@rwinslow.com', - url='https://github.com/google/flatbuffers', - long_description=('Python runtime library for use with the Flatbuffers' - 'serialization format.'), - packages=['flatbuffers'], - include_package_data=True, - requires=[], - description='The FlatBuffers serialization format for Python', -)
diff --git a/third_party/flatbuffers/readme.md b/third_party/flatbuffers/readme.md deleted file mode 100755 index a7c0e93..0000000 --- a/third_party/flatbuffers/readme.md +++ /dev/null
@@ -1,59 +0,0 @@ - FlatBuffers -=========== - -[](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[](https://travis-ci.org/google/flatbuffers) [](https://ci.appveyor.com/project/gwvo/flatbuffers) - -**FlatBuffers** is an efficient cross platform serialization library for games and -other memory constrained apps. It allows you to directly access serialized data without -unpacking/parsing it first, while still having great forwards/backwards compatibility. - -**Go to our [landing page][] to browse our documentation.** - -## Supported operating systems -* Android -* Windows -* MacOS X -* Linux - -## Supported programming languages -* C++ -* C# -* C -* Go -* Java -* JavaScript -* PHP -* Python - -*and many more in progress...* - -## Contribution -* [FlatBuffers Google Group][] to discuss FlatBuffers with other developers and users. -* [FlatBuffers Issues Tracker][] to submit an issue. -* [stackoverflow.com][] with [`flatbuffers` tag][] for any questions regarding FlatBuffers. - -*To contribute to this project,* see [CONTRIBUTING][]. - -## Integration -For applications on Google Play that integrate this tool, usage is tracked. -This tracking is done automatically using the embedded version string -(**`flatbuffer_version_string`**), and helps us continue to optimize it. Aside from -consuming a few extra bytes in your application binary, it shouldn't affect -your application at all. We use this information to let us know if FlatBuffers -is useful and if we should continue to invest in it. Since this is open -source, you are free to remove the version string but we would appreciate if -you would leave it in. - -## Licensing -*Flatbuffers* is licensed under the Apache License, Version 2.0. See [LICENSE][] for the full license text. - -<br> - - [CONTRIBUTING]: http://github.com/google/flatbuffers/blob/master/CONTRIBUTING.md - [`flatbuffers` tag]: https://stackoverflow.com/questions/tagged/flatbuffers - [FlatBuffers Google Group]: https://groups.google.com/forum/#!forum/flatbuffers - [FlatBuffers Issues Tracker]: http://github.com/google/flatbuffers/issues - [stackoverflow.com]: http://stackoverflow.com/search?q=flatbuffers - [landing page]: http://google.github.io/flatbuffers - [LICENSE]: https://github.com/google/flatbuffers/blob/master/LICENSE.txt
diff --git a/third_party/flatbuffers/reflection/generate_code.sh b/third_party/flatbuffers/reflection/generate_code.sh deleted file mode 100644 index da8a181..0000000 --- a/third_party/flatbuffers/reflection/generate_code.sh +++ /dev/null
@@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -../flatc -c --no-prefix -o ../include/flatbuffers reflection.fbs
diff --git a/third_party/flatbuffers/reflection/reflection.fbs b/third_party/flatbuffers/reflection/reflection.fbs deleted file mode 100644 index ea41891..0000000 --- a/third_party/flatbuffers/reflection/reflection.fbs +++ /dev/null
@@ -1,93 +0,0 @@ -// This schema defines objects that represent a parsed schema, like -// the binary version of a .fbs file. -// This could be used to operate on unknown FlatBuffers at runtime. -// It can even ... represent itself (!) - -namespace reflection; - -// These must correspond to the enum in idl.h. -enum BaseType : byte { - None, - UType, - Bool, - Byte, - UByte, - Short, - UShort, - Int, - UInt, - Long, - ULong, - Float, - Double, - String, - Vector, - Obj, // Used for tables & structs. - Union -} - -table Type { - base_type:BaseType; - element:BaseType = None; // Only if base_type == Vector. - index:int = -1; // If base_type == Object, index into "objects" below. - // If base_type == Union, UnionType, or integral derived - // from an enum, index into "enums" below. -} - -table KeyValue { - key:string (required, key); - value:string; -} - -table EnumVal { - name:string (required); - value:long (key); - object:Object; // Will be deprecated in favor of union_type in the future. - union_type:Type; -} - -table Enum { - name:string (required, key); - values:[EnumVal] (required); // In order of their values. - is_union:bool = false; - underlying_type:Type (required); - attributes:[KeyValue]; - documentation:[string]; -} - -table Field { - name:string (required, key); - type:Type (required); - id:ushort; - offset:ushort; // Offset into the vtable for tables, or into the struct. - default_integer:long = 0; - default_real:double = 0.0; - deprecated:bool = false; - required:bool = false; - key:bool = false; - attributes:[KeyValue]; - documentation:[string]; -} - -table Object { // Used for both tables and structs. - name:string (required, key); - fields:[Field] (required); // Sorted. - is_struct:bool = false; - minalign:int; - bytesize:int; // For structs. - attributes:[KeyValue]; - documentation:[string]; -} - -table Schema { - objects:[Object] (required); // Sorted. - enums:[Enum] (required); // Sorted. - file_ident:string; - file_ext:string; - root_table:Object; -} - -root_type Schema; - -file_identifier "BFBS"; -file_extension "bfbs";
diff --git a/third_party/flatbuffers/samples/SampleBinary.cs b/third_party/flatbuffers/samples/SampleBinary.cs deleted file mode 100644 index 16128c4..0000000 --- a/third_party/flatbuffers/samples/SampleBinary.cs +++ /dev/null
@@ -1,137 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// To run, use the `csharp_sample.sh` script. - -using System; -using FlatBuffers; -using MyGame.Sample; - -class SampleBinary -{ - // Example how to use FlatBuffers to create and read binary buffers. - static void Main() - { - var builder = new FlatBufferBuilder(1); - - // Create some weapons for our Monster ('Sword' and 'Axe'). - var weapon1Name = builder.CreateString("Sword"); - var weapon1Damage = 3; - var weapon2Name = builder.CreateString("Axe"); - var weapon2Damage = 5; - - // Use the `CreateWeapon()` helper function to create the weapons, since we set every field. - var weaps = new Offset<Weapon>[2]; - weaps[0] = Weapon.CreateWeapon(builder, weapon1Name, (short)weapon1Damage); - weaps[1] = Weapon.CreateWeapon(builder, weapon2Name, (short)weapon2Damage); - - // Serialize the FlatBuffer data. - var name = builder.CreateString("Orc"); - var treasure = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - var inv = Monster.CreateInventoryVector(builder, treasure); - var weapons = Monster.CreateWeaponsVector(builder, weaps); - var pos = Vec3.CreateVec3(builder, 1.0f, 2.0f, 3.0f); - - Monster.StartMonster(builder); - Monster.AddPos(builder, pos); - Monster.AddHp(builder, (short)300); - Monster.AddName(builder, name); - Monster.AddInventory(builder, inv); - Monster.AddColor(builder, Color.Red); - Monster.AddWeapons(builder, weapons); - Monster.AddEquippedType(builder, Equipment.Weapon); - Monster.AddEquipped(builder, weaps[1].Value); - var orc = Monster.EndMonster(builder); - - builder.Finish(orc.Value); // You could also call `Monster.FinishMonsterBuffer(builder, orc);`. - - // We now have a FlatBuffer that we could store on disk or send over a network. - - // ...Code to store to disk or send over a network goes here... - - // Instead, we are going to access it right away, as if we just received it. - - var buf = builder.DataBuffer; - - // Get access to the root: - var monster = Monster.GetRootAsMonster(buf); - - // For C#, unlike other languages, most values (except for vectors and unions) are available as - // properties instead of accessor methods. - - // Note: We did not set the `Mana` field explicitly, so we get back the default value. - Assert(monster.Mana == 150, "monster.Mana", Convert.ToString(monster.Mana), - Convert.ToString(150)); - Assert(monster.Hp == 300, "monster.Hp", Convert.ToString(monster.Hp), Convert.ToString(30)); - Assert(monster.Name.Equals("Orc", StringComparison.Ordinal), "monster.Name", monster.Name, - "Orc"); - Assert(monster.Color == Color.Red, "monster.Color", Convert.ToString(monster.Color), - Convert.ToString(Color.Red)); - - // C# also allows you to use performance-enhanced methods to fill an object that has already - // been created. These functions are prefixed with "Get". For example: `monster.GetPos()`. - var myAlreadyCreatedVector = new Vec3(); - monster.GetPos(myAlreadyCreatedVector); // Instead of `var myNewVec3 = monster.Pos`. - Assert(myAlreadyCreatedVector.X == 1.0f, "myAlreadyCreatedVector.X", - Convert.ToString(myAlreadyCreatedVector.X), Convert.ToString(1.0f)); - Assert(myAlreadyCreatedVector.Y == 2.0f, "myAlreadyCreatedVector.Y", - Convert.ToString(myAlreadyCreatedVector.Y), Convert.ToString(2.0f)); - Assert(myAlreadyCreatedVector.Z == 3.0f, "myAlreadyCreatedVector.Z", - Convert.ToString(myAlreadyCreatedVector.Z), Convert.ToString(3.0f)); - - // Get and test the `Inventory` FlatBuffer `vector`. - for (int i = 0; i < monster.InventoryLength; i++) - { - Assert(monster.GetInventory(i) == i, "monster.GetInventory", - Convert.ToString(monster.GetInventory(i)), Convert.ToString(i)); - } - - // Get and test the `Weapons` FlatBuffer `vector` of `table`s. - var expectedWeaponNames = new string[] {"Sword", "Axe"}; - var expectedWeaponDamages = new short[] {3, 5}; - for (int i = 0; i < monster.WeaponsLength; i++) - { - Assert(monster.GetWeapons(i).Name.Equals(expectedWeaponNames[i], StringComparison.Ordinal), - "monster.GetWeapons", monster.GetWeapons(i).Name, expectedWeaponNames[i]); - Assert(monster.GetWeapons(i).Damage == expectedWeaponDamages[i], "monster.GetWeapons", - Convert.ToString(monster.GetWeapons(i).Damage), - Convert.ToString(expectedWeaponDamages[i])); - } - - // Get and test the `Equipped` FlatBuffer `union`. - Assert(monster.EquippedType == Equipment.Weapon, "monster.EquippedType", - Convert.ToString(monster.EquippedType), Convert.ToString(Equipment.Weapon)); - var equipped = (Weapon)monster.GetEquipped(new Weapon()); - Assert(equipped.Name.Equals("Axe", StringComparison.Ordinal), "equipped.Name", equipped.Name, - "Axe"); - Assert(equipped.Damage == 5, "equipped.Damage", Convert.ToString(equipped.Damage), - Convert.ToString(5)); - - Console.WriteLine("The FlatBuffer was successfully created and verified!"); - } - - // A helper function to handle assertions. - static void Assert(bool assertPassed, string codeExecuted, string actualValue, - string expectedValue) - { - if (assertPassed == false) - { - Console.WriteLine("Assert failed! " + codeExecuted + " (" + actualValue + - ") was not equal to " + expectedValue + "."); - System.Environment.Exit(1); - } - } -}
diff --git a/third_party/flatbuffers/samples/SampleBinary.java b/third_party/flatbuffers/samples/SampleBinary.java deleted file mode 100644 index 555194f..0000000 --- a/third_party/flatbuffers/samples/SampleBinary.java +++ /dev/null
@@ -1,106 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Run this file with the `java_sample.sh` script. - -import MyGame.Sample.Color; -import MyGame.Sample.Equipment; -import MyGame.Sample.Monster; -import MyGame.Sample.Vec3; -import MyGame.Sample.Weapon; - -import com.google.flatbuffers.FlatBufferBuilder; - -import java.nio.ByteBuffer; - -class SampleBinary { - // Example how to use FlatBuffers to create and read binary buffers. - public static void main(String[] args) { - FlatBufferBuilder builder = new FlatBufferBuilder(0); - - // Create some weapons for our Monster ('Sword' and 'Axe'). - int weaponOneName = builder.createString("Sword"); - short weaponOneDamage = 3; - int weaponTwoName = builder.createString("Axe"); - short weaponTwoDamage = 5; - - // Use the `createWeapon()` helper function to create the weapons, since we set every field. - int[] weaps = new int[2]; - weaps[0] = Weapon.createWeapon(builder, weaponOneName, weaponOneDamage); - weaps[1] = Weapon.createWeapon(builder, weaponTwoName, weaponTwoDamage); - - // Serialize the FlatBuffer data. - int name = builder.createString("Orc"); - byte[] treasure = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - int inv = Monster.createInventoryVector(builder, treasure); - int weapons = Monster.createWeaponsVector(builder, weaps); - int pos = Vec3.createVec3(builder, 1.0f, 2.0f, 3.0f); - - Monster.startMonster(builder); - Monster.addPos(builder, pos); - Monster.addName(builder, name); - Monster.addColor(builder, Color.Red); - Monster.addHp(builder, (short)300); - Monster.addInventory(builder, inv); - Monster.addWeapons(builder, weapons); - Monster.addEquippedType(builder, Equipment.Weapon); - Monster.addEquipped(builder, weaps[1]); - int orc = Monster.endMonster(builder); - - builder.finish(orc); // You could also call `Monster.finishMonsterBuffer(builder, orc);`. - - // We now have a FlatBuffer that can be stored on disk or sent over a network. - - // ...Code to store to disk or send over a network goes here... - - // Instead, we are going to access it right away, as if we just received it. - - ByteBuffer buf = builder.dataBuffer(); - - // Get access to the root: - Monster monster = Monster.getRootAsMonster(buf); - - // Note: We did not set the `mana` field explicitly, so we get back the default value. - assert monster.mana() == (short)150; - assert monster.hp() == (short)300; - assert monster.name().equals("Orc"); - assert monster.color() == Color.Red; - assert monster.pos().x() == 1.0f; - assert monster.pos().y() == 2.0f; - assert monster.pos().z() == 3.0f; - - // Get and test the `inventory` FlatBuffer `vector`. - for (int i = 0; i < monster.inventoryLength(); i++) { - assert monster.inventory(i) == (byte)i; - } - - // Get and test the `weapons` FlatBuffer `vector` of `table`s. - String[] expectedWeaponNames = {"Sword", "Axe"}; - int[] expectedWeaponDamages = {3, 5}; - for (int i = 0; i < monster.weaponsLength(); i++) { - assert monster.weapons(i).name().equals(expectedWeaponNames[i]); - assert monster.weapons(i).damage() == expectedWeaponDamages[i]; - } - - // Get and test the `equipped` FlatBuffer `union`. - assert monster.equippedType() == Equipment.Weapon; - Weapon equipped = (Weapon)monster.equipped(new Weapon()); - assert equipped.name().equals("Axe"); - assert equipped.damage() == 5; - - System.out.println("The FlatBuffer was successfully created and verified!"); - } -}
diff --git a/third_party/flatbuffers/samples/SampleBinary.php b/third_party/flatbuffers/samples/SampleBinary.php deleted file mode 100644 index d28ffa3..0000000 --- a/third_party/flatbuffers/samples/SampleBinary.php +++ /dev/null
@@ -1,115 +0,0 @@ -<?php -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// To run, use the `php_sample.sh` script. - -// It is recommended that you use PSR autoload when using FlatBuffers. -function __autoload($class_name) { - $class = substr($class_name, strrpos($class_name, "\\") + 1); - $root_dir = join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)))); // `flatbuffers` root. - $paths = array(join(DIRECTORY_SEPARATOR, array($root_dir, "php")), - join(DIRECTORY_SEPARATOR, array($root_dir, "samples", "MyGame", "Sample"))); - foreach ($paths as $path) { - $file = join(DIRECTORY_SEPARATOR, array($path, $class . ".php")); - if (file_exists($file)) { - require($file); - break; - } - } -} - -// Example how to use FlatBuffers to create and read binary buffers. -function main() { - $builder = new Google\FlatBuffers\FlatbufferBuilder(0); - - // Create some weapons for our Monster using the `createWeapon()` helper function. - $weapon_one = $builder->createString("Sword"); - $sword = \MyGame\Sample\Weapon::CreateWeapon($builder, $weapon_one, 3); - $weapon_two = $builder->createString("Axe"); - $axe = \MyGame\Sample\Weapon::CreateWeapon($builder, $weapon_two, 5); - - // Serialize the FlatBuffer data. - $name = $builder->createString("Orc"); - - $treasure = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); - $inv = \MyGame\Sample\Monster::CreateInventoryVector($builder, $treasure); - - $weaps = array($sword, $axe); - $weapons = \MyGame\Sample\Monster::CreateWeaponsVector($builder, $weaps); - - $pos = \MyGame\Sample\Vec3::CreateVec3($builder, 1.0, 2.0, 3.0); - - \MyGame\Sample\Monster::StartMonster($builder); - \MyGame\Sample\Monster::AddPos($builder, $pos); - \MyGame\Sample\Monster::AddHp($builder, 300); - \MyGame\Sample\Monster::AddName($builder, $name); - \MyGame\Sample\Monster::AddInventory($builder, $inv); - \MyGame\Sample\Monster::AddColor($builder, \MyGame\Sample\Color::Red); - \MyGame\Sample\Monster::AddWeapons($builder, $weapons); - \MyGame\Sample\Monster::AddEquippedType($builder, \MyGame\Sample\Equipment::Weapon); - \MyGame\Sample\Monster::AddEquipped($builder, $weaps[1]); - $orc = \MyGame\Sample\Monster::EndMonster($builder); - - $builder->finish($orc); // You may also call `\MyGame\Sample\Monster::FinishMonsterBuffer($builder, $orc);`. - - // We now have a FlatBuffer that can be stored on disk or sent over a network. - - // ...Code to store to disk or send over a network goes here... - - // Instead, we are going to access it right away, as if we just received it. - - $buf = $builder->dataBuffer(); - - // Get access to the root: - $monster = \MyGame\Sample\Monster::GetRootAsMonster($buf); - - $success = true; // Tracks if an assert occurred. - - // Note: We did not set the `mana` field explicitly, so we get back the default value. - $success &= assert($monster->getMana() == 150); - $success &= assert($monster->getHp() == 300); - $success &= assert($monster->getName() == "Orc"); - $success &= assert($monster->getColor() == \MyGame\Sample\Color::Red); - $success &= assert($monster->getPos()->getX() == 1.0); - $success &= assert($monster->getPos()->getY() == 2.0); - $success &= assert($monster->getPos()->getZ() == 3.0); - - // Get and test the `inventory` FlatBuffer `vector`. - for ($i = 0; $i < $monster->getInventoryLength(); $i++) { - $success &= assert($monster->getInventory($i) == $i); - } - - // Get and test the `weapons` FlatBuffer `vector` of `table`s. - $expected_weapon_names = array("Sword", "Axe"); - $expected_weapon_damages = array(3, 5); - for ($i = 0; $i < $monster->getWeaponsLength(); $i++) { - $success &= assert($monster->getWeapons($i)->getName() == $expected_weapon_names[$i]); - $success &= assert($monster->getWeapons($i)->getDamage() == $expected_weapon_damages[$i]); - } - - // Get and test the `equipped` FlatBuffer `union`. - $success &= assert($monster->getEquippedType() == \MyGame\Sample\Equipment::Weapon); - $success &= assert($monster->getEquipped(new \MyGame\Sample\Weapon())->getName() == "Axe"); - $success &= assert($monster->getEquipped(new \MyGame\Sample\Weapon())->getDamage() == 5); - - if ($success) { - print("The FlatBuffer was successfully created and verified!\n"); - } -} - -main(); -?>
diff --git a/third_party/flatbuffers/samples/android/AndroidManifest.xml b/third_party/flatbuffers/samples/android/AndroidManifest.xml deleted file mode 100755 index 0fa3dcf..0000000 --- a/third_party/flatbuffers/samples/android/AndroidManifest.xml +++ /dev/null
@@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (c) 2015 Google, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - --> -<!-- BEGIN_INCLUDE(manifest) --> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.samples.FlatBufferSample" - android:versionCode="1" - android:versionName="1.0"> - - <uses-feature android:glEsVersion="0x00020000"></uses-feature> - <!-- This is the platform API where NativeActivity was introduced. --> - <uses-sdk android:minSdkVersion="9" /> - - <!-- This .apk has no Java code itself, so set hasCode to false. --> - <application android:label="@string/app_name" android:hasCode="false"> - - <!-- Our activity is the built-in NativeActivity framework class. - This will take care of integrating with our NDK code. --> - <activity android:name="android.app.NativeActivity" - android:label="@string/app_name" - android:configChanges="orientation|keyboardHidden" - android:screenOrientation="landscape"> - <!-- Tell NativeActivity the name of or .so --> - <meta-data android:name="android.app.lib_name" - android:value="FlatBufferSample" /> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> -<!-- END_INCLUDE(manifest) -->
diff --git a/third_party/flatbuffers/samples/android/build_apk.sh b/third_party/flatbuffers/samples/android/build_apk.sh deleted file mode 100755 index 1b9f4a4..0000000 --- a/third_party/flatbuffers/samples/android/build_apk.sh +++ /dev/null
@@ -1,511 +0,0 @@ -#!/bin/bash -eu -# -# Copyright (c) 2013 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. -# -# Build, deploy, debug / execute a native Android package based upon -# NativeActivity. - -declare -r script_directory=$(dirname $0) -declare -r android_root=${script_directory}/../../../../../../ -declare -r script_name=$(basename $0) -declare -r android_manifest=AndroidManifest.xml -declare -r os_name=$(uname -s) - -# Minimum Android target version supported by this project. -: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10} -# Directory containing the Android SDK -# (http://developer.android.com/sdk/index.html). -: ${ANDROID_SDK_HOME:=} -# Directory containing the Android NDK -# (http://developer.android.com/tools/sdk/ndk/index.html). -: ${NDK_HOME:=} - -# Display script help and exit. -usage() { - echo " -Build the Android package in the current directory and deploy it to a -connected device. - -Usage: ${script_name} \\ - [ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \ - [LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...] - -ADB_DEVICE=serial_number: - serial_number specifies the device to deploy the built apk to if multiple - Android devices are connected to the host. -BUILD=0: - Disables the build of the package. -DEPLOY=0: - Disables the deployment of the built apk to the Android device. -RUN_DEBUGGER=1: - Launches the application in gdb after it has been deployed. To debug in - gdb, NDK_DEBUG=1 must also be specified on the command line to build a - debug apk. -LAUNCH=0: - Disable the launch of the apk on the Android device. -SWIG_BIN=swig_binary_directory: - The directory where the SWIG binary lives. No need to set this if SWIG is - installed and point to from your PATH variable. -SWIG_LIB=swig_include_directory: - The directory where SWIG shared include files are, usually obtainable from - commandline with \"swig -swiglib\". No need to set this if SWIG is installed - and point to from your PATH variable. -ndk-build arguments...: - Additional arguments for ndk-build. See ndk-build -h for more information. -" >&2 - exit 1 -} - -# Get the number of CPU cores present on the host. -get_number_of_cores() { - case ${os_name} in - Darwin) - sysctl hw.ncpu | awk '{ print $2 }' - ;; - CYGWIN*|Linux) - awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo - ;; - *) - echo 1 - ;; - esac -} - -# Get the package name from an AndroidManifest.xml file. -get_package_name_from_manifest() { - xmllint --xpath 'string(/manifest/@package)' "${1}" -} - -# Get the library name from an AndroidManifest.xml file. -get_library_name_from_manifest() { - echo "\ -setns android=http://schemas.android.com/apk/res/android -xpath string(/manifest/application/activity\ -[@android:name=\"android.app.NativeActivity\"]/meta-data\ -[@android:name=\"android.app.lib_name\"]/@android:value)" | - xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }' -} - -# Get the number of Android devices connected to the system. -get_number_of_devices_connected() { - adb devices -l | \ - awk '/^..*$/ { if (p) { print $0 } } - /List of devices attached/ { p = 1 }' | \ - wc -l - return ${PIPESTATUS[0]} -} - -# Kill a process and its' children. This is provided for cygwin which -# doesn't ship with pkill. -kill_process_group() { - local parent_pid="${1}" - local child_pid= - for child_pid in $(ps -f | \ - awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do - kill_process_group "${child_pid}" - done - kill "${parent_pid}" 2>/dev/null -} - -# Find and run "adb". -adb() { - local adb_path= - for path in "$(which adb 2>/dev/null)" \ - "${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \ - "${android_root}/prebuilts/sdk/platform-tools/adb"; do - if [[ -e "${path}" ]]; then - adb_path="${path}" - break - fi - done - if [[ "${adb_path}" == "" ]]; then - echo -e "Unable to find adb." \ - "\nAdd the Android ADT sdk/platform-tools directory to the" \ - "PATH." >&2 - exit 1 - fi - "${adb_path}" "$@" -} - -# Find and run "android". -android() { - local android_executable=android - if echo "${os_name}" | grep -q CYGWIN; then - android_executable=android.bat - fi - local android_path= - for path in "$(which ${android_executable})" \ - "${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \ - "${android_root}/prebuilts/sdk/tools/${android_executable}"; do - if [[ -e "${path}" ]]; then - android_path="${path}" - break - fi - done - if [[ "${android_path}" == "" ]]; then - echo -e "Unable to find android tool." \ - "\nAdd the Android ADT sdk/tools directory to the PATH." >&2 - exit 1 - fi - # Make sure ant is installed. - if [[ "$(which ant)" == "" ]]; then - echo -e "Unable to find ant." \ - "\nPlease install ant and add to the PATH." >&2 - exit 1 - fi - - "${android_path}" "$@" -} - -# Find and run "ndk-build" -ndkbuild() { - local ndkbuild_path= - for path in "$(which ndk-build 2>/dev/null)" \ - "${NDK_HOME}/ndk-build" \ - "${android_root}/prebuilts/ndk/current/ndk-build"; do - if [[ -e "${path}" ]]; then - ndkbuild_path="${path}" - break - fi - done - if [[ "${ndkbuild_path}" == "" ]]; then - echo -e "Unable to find ndk-build." \ - "\nAdd the Android NDK directory to the PATH." >&2 - exit 1 - fi - "${ndkbuild_path}" "$@" -} - -# Get file modification time of $1 in seconds since the epoch. -stat_mtime() { - local filename="${1}" - case ${os_name} in - Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;; - *) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;; - esac -} - -# Build the native (C/C++) build targets in the current directory. -build_native_targets() { - # Save the list of output modules in the install directory so that it's - # possible to restore their timestamps after the build is complete. This - # works around a bug in ndk/build/core/setup-app.mk which results in the - # unconditional execution of the clean-installed-binaries rule. - restore_libraries="$(find libs -type f 2>/dev/null | \ - sed -E 's@^libs/(.*)@\1@')" - - # Build native code. - ndkbuild -j$(get_number_of_cores) "$@" - - # Restore installed libraries. - # Obviously this is a nasty hack (along with ${restore_libraries} above) as - # it assumes it knows where the NDK will be placing output files. - ( - IFS=$'\n' - for libpath in ${restore_libraries}; do - source_library="obj/local/${libpath}" - target_library="libs/${libpath}" - if [[ -e "${source_library}" ]]; then - cp -a "${source_library}" "${target_library}" - fi - done - ) -} - -# Select the oldest installed android build target that is at least as new as -# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found, -# this function prints an error message and exits with an error. -select_android_build_target() { - local -r android_targets_installed=$( \ - android list targets | \ - awk -F'"' '/^id:.*android/ { print $2 }') - local android_build_target= - for android_target in $(echo "${android_targets_installed}" | \ - awk -F- '{ print $2 }' | sort -n); do - local isNumber='^[0-9]+$' - # skip preview API releases e.g. 'android-L' - if [[ $android_target =~ $isNumber ]]; then - if [[ $((android_target)) -ge \ - $((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then - android_build_target="android-${android_target}" - break - fi - # else - # The API version is a letter, so skip it. - fi - done - if [[ "${android_build_target}" == "" ]]; then - echo -e \ - "Found installed Android targets:" \ - "$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \ - "\nAndroid SDK platform" \ - "android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \ - "must be installed to build this project." \ - "\nUse the \"android\" application to install API" \ - "$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2 - exit 1 - fi - echo "${android_build_target}" -} - -# Sign unsigned apk $1 and write the result to $2 with key store file $3 and -# password $4. -# If a key store file $3 and password $4 aren't specified, a temporary -# (60 day) key is generated and used to sign the package. -sign_apk() { - local unsigned_apk="${1}" - local signed_apk="${2}" - if [[ $(stat_mtime "${unsigned_apk}") -gt \ - $(stat_mtime "${signed_apk}") ]]; then - local -r key_alias=$(basename ${signed_apk} .apk) - local keystore="${3}" - local key_password="${4}" - [[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore" - [[ "${key_password}" == "" ]] && \ - key_password="${key_alias}123456" - if [[ ! -e ${keystore} ]]; then - keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \ - -storepass ${key_password} \ - -keypass ${key_password} -keystore ${keystore} \ - -alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60 - fi - cp "${unsigned_apk}" "${signed_apk}" - jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \ - -keystore ${keystore} -storepass ${key_password} \ - -keypass ${key_password} "${signed_apk}" ${key_alias} - fi -} - -# Build the apk $1 for package filename $2 in the current directory using the -# ant build target $3. -build_apk() { - local -r output_apk="${1}" - local -r package_filename="${2}" - local -r ant_target="${3}" - # Get the list of installed android targets and select the oldest target - # that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION. - local -r android_build_target=$(select_android_build_target) - [[ "${android_build_target}" == "" ]] && exit 1 - echo "Building ${output_apk} for target ${android_build_target}" >&2 - - # Create / update build.xml and local.properties files. - if [[ $(stat_mtime "${android_manifest}") -gt \ - $(stat_mtime build.xml) ]]; then - android update project --target "${android_build_target}" \ - -n ${package_filename} --path . - fi - - # Use ant to build the apk. - ant -quiet ${ant_target} - - # Sign release apks with a temporary key as these packages will not be - # redistributed. - local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk" - if [[ "${ant_target}" == "release" ]]; then - sign_apk "${unsigned_apk}" "${output_apk}" "" "" - fi -} - -# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device" -# or an empty string. If $3 is an empty string adb will fail when multiple -# devices are connected to the host system. -install_apk() { - local -r uninstall_package_name="${1}" - local -r install_apk="${2}" - local -r adb_device="${3}" - # Uninstall the package if it's already installed. - adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \ - true # no error check - - # Install the apk. - # NOTE: The following works around adb not returning an error code when - # it fails to install an apk. - echo "Install ${install_apk}" >&2 - local -r adb_install_result=$(adb ${adb_device} install "${install_apk}") - echo "${adb_install_result}" - if echo "${adb_install_result}" | grep -qF 'Failure ['; then - exit 1 - fi -} - -# Launch previously installed package $1 on device $2. -# If $2 is an empty string adb will fail when multiple devices are connected -# to the host system. -launch_package() { - ( - # Determine the SDK version of Android on the device. - local -r android_sdk_version=$( - adb ${adb_device} shell cat system/build.prop | \ - awk -F= '/ro.build.version.sdk/ { - v=$2; sub(/[ \r\n]/, "", v); print v - }') - - # Clear logs from previous runs. - # Note that logcat does not just 'tail' the logs, it dumps the entire log - # history. - adb ${adb_device} logcat -c - - local finished_msg='Displayed '"${package_name}" - local timeout_msg='Activity destroy timeout.*'"${package_name}" - # Maximum time to wait before stopping log monitoring. 0 = infinity. - local launch_timeout=0 - # If this is a Gingerbread device, kill log monitoring after 10 seconds. - if [[ $((android_sdk_version)) -le 10 ]]; then - launch_timeout=10 - fi - # Display logcat in the background. - # Stop displaying the log when the app launch / execution completes or the - # logcat - ( - adb ${adb_device} logcat | \ - awk " - { - print \$0 - } - - /ActivityManager.*: ${finished_msg}/ { - exit 0 - } - - /ActivityManager.*: ${timeout_msg}/ { - exit 0 - }" & - adb_logcat_pid=$!; - if [[ $((launch_timeout)) -gt 0 ]]; then - sleep $((launch_timeout)); - kill ${adb_logcat_pid}; - else - wait ${adb_logcat_pid}; - fi - ) & - logcat_pid=$! - # Kill adb logcat if this shell exits. - trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT - - # If the SDK is newer than 10, "am" supports stopping an activity. - adb_stop_activity= - if [[ $((android_sdk_version)) -gt 10 ]]; then - adb_stop_activity=-S - fi - - # Launch the activity and wait for it to complete. - adb ${adb_device} shell am start ${adb_stop_activity} -n \ - ${package_name}/android.app.NativeActivity - - wait "${logcat_pid}" - ) -} - -# See usage(). -main() { - # Parse arguments for this script. - local adb_device= - local ant_target=release - local disable_deploy=0 - local disable_build=0 - local run_debugger=0 - local launch=1 - local build_package=1 - for opt; do - case ${opt} in - # NDK_DEBUG=0 tells ndk-build to build this as debuggable but to not - # modify the underlying code whereas NDK_DEBUG=1 also builds as debuggable - # but does modify the code - NDK_DEBUG=1) ant_target=debug ;; - NDK_DEBUG=0) ant_target=debug ;; - ADB_DEVICE*) adb_device="$(\ - echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;; - BUILD=0) disable_build=1 ;; - DEPLOY=0) disable_deploy=1 ;; - RUN_DEBUGGER=1) run_debugger=1 ;; - LAUNCH=0) launch=0 ;; - clean) build_package=0 disable_deploy=1 launch=0 ;; - -h|--help|help) usage ;; - esac - done - - # If a target device hasn't been specified and multiple devices are connected - # to the host machine, display an error. - local -r devices_connected=$(get_number_of_devices_connected) - if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \ - ($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \ - $((run_debugger)) -ne 0) ]]; then - if [[ $((disable_deploy)) -ne 0 ]]; then - echo "Deployment enabled, disable using DEPLOY=0" >&2 - fi - if [[ $((launch)) -ne 0 ]]; then - echo "Launch enabled." >&2 - fi - if [[ $((disable_deploy)) -eq 0 ]]; then - echo "Deployment enabled." >&2 - fi - if [[ $((run_debugger)) -ne 0 ]]; then - echo "Debugger launch enabled." >&2 - fi - echo " -Multiple Android devices are connected to this host. Either disable deployment -and execution of the built .apk using: - \"${script_name} DEPLOY=0 LAUNCH=0\" - -or specify a device to deploy to using: - \"${script_name} ADB_DEVICE=\${device_serial}\". - -The Android devices connected to this machine are: -$(adb devices -l) -" >&2 - exit 1 - fi - - if [[ $((disable_build)) -eq 0 ]]; then - # Build the native target. - build_native_targets "$@" - fi - - # Get the package name from the manifest. - local -r package_name=$(get_package_name_from_manifest "${android_manifest}") - if [[ "${package_name}" == "" ]]; then - echo -e "No package name specified in ${android_manifest},"\ - "skipping apk build, deploy" - "\nand launch steps." >&2 - exit 0 - fi - local -r package_basename=${package_name/*./} - local package_filename=$(get_library_name_from_manifest ${android_manifest}) - [[ "${package_filename}" == "" ]] && package_filename="${package_basename}" - - # Output apk name. - local -r output_apk="bin/${package_filename}-${ant_target}.apk" - - if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then - # Build the apk. - build_apk "${output_apk}" "${package_filename}" "${ant_target}" - fi - - # Deploy to the device. - if [[ $((disable_deploy)) -eq 0 ]]; then - install_apk "${package_name}" "${output_apk}" "${adb_device}" - fi - - if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then - # Start debugging. - ndk-gdb ${adb_device} --start - elif [[ $((launch)) -eq 1 ]]; then - launch_package "${package_name}" "${adb_device}" - fi -} - -main "$@"
diff --git a/third_party/flatbuffers/samples/android/jni/Android.mk b/third_party/flatbuffers/samples/android/jni/Android.mk deleted file mode 100755 index 6f22d28..0000000 --- a/third_party/flatbuffers/samples/android/jni/Android.mk +++ /dev/null
@@ -1,56 +0,0 @@ -# Copyright (c) 2013 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. - -LOCAL_PATH := $(call my-dir) -FLATBUFFERS_ROOT_DIR := $(LOCAL_PATH)/../../.. - -# FlatBuffers test -include $(CLEAR_VARS) - -# Include the FlatBuffer utility function to generate header files from schemas. -include $(FLATBUFFERS_ROOT_DIR)/android/jni/include.mk - -LOCAL_MODULE := FlatBufferSample - -# Set up some useful variables to identify schema and output directories and -# schema files. -ANDROID_SAMPLE_GENERATED_OUTPUT_DIR := $(LOCAL_PATH)/gen/include -ANDROID_SAMPLE_SCHEMA_DIR := $(LOCAL_PATH)/schemas -ANDROID_SAMPLE_SCHEMA_FILES := $(ANDROID_SAMPLE_SCHEMA_DIR)/animal.fbs - -LOCAL_C_INCLUDES := $(ANDROID_SAMPLE_GENERATED_OUTPUT_DIR) - -$(info $(LOCAL_C_INCLUDES)) - -LOCAL_SRC_FILES := main.cpp - -LOCAL_CPPFLAGS := -std=c++11 -fexceptions -Wall -Wno-literal-suffix -LOCAL_LDLIBS := -llog -landroid -LOCAL_ARM_MODE := arm -LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers - -ifeq (,$(ANDROID_SAMPLE_RUN_ONCE)) -ANDROID_SAMPLE_RUN_ONCE := 1 -$(call flatbuffers_header_build_rules,$(ANDROID_SAMPLE_SCHEMA_FILES),$(ANDROID_SAMPLE_SCHEMA_DIR),$(ANDROID_SAMPLE_GENERATED_OUTPUT_DIR),,$(LOCAL_SRC_FILES)) -endif - -include $(BUILD_SHARED_LIBRARY) - -# Path to Flatbuffers root directory. -$(call import-add-path,$(FLATBUFFERS_ROOT_DIR)/..) - -$(call import-module,flatbuffers/android/jni) -$(call import-module,android/native_app_glue)
diff --git a/third_party/flatbuffers/samples/android/jni/Application.mk b/third_party/flatbuffers/samples/android/jni/Application.mk deleted file mode 100755 index 2fc9c73..0000000 --- a/third_party/flatbuffers/samples/android/jni/Application.mk +++ /dev/null
@@ -1,22 +0,0 @@ -# Copyright (c) 2014 Google, Inc. -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. -APP_PLATFORM := android-10 -APP_PROJECT_PATH := $(call my-dir)/.. -APP_STL := gnustl_static - -APP_ABI := armeabi-v7a - -APP_CPPFLAGS += -std=c++11
diff --git a/third_party/flatbuffers/samples/android/jni/main.cpp b/third_party/flatbuffers/samples/android/jni/main.cpp deleted file mode 100644 index 8758027..0000000 --- a/third_party/flatbuffers/samples/android/jni/main.cpp +++ /dev/null
@@ -1,43 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include <android/log.h> - -#include "android_native_app_glue.h" -#include "animal_generated.h" // Includes "flatbuffers/flatbuffers.h". - -void android_main(android_app *app) { - app_dummy(); - - flatbuffers::FlatBufferBuilder builder; - auto name = builder.CreateString("Dog"); - auto sound = builder.CreateString("Bark"); - auto animal_buffer = sample::CreateAnimal(builder, name, sound); - builder.Finish(animal_buffer); - - // We now have a FlatBuffer that can be stored on disk or sent over a network. - - // ...Code to store on disk or send over a network goes here... - - // Instead, we're going to access it immediately, as if we just recieved this. - - auto animal = sample::GetAnimal(builder.GetBufferPointer()); - - assert(animal->name()->str() == "Dog"); - assert(animal->sound()->str() == "Bark"); - (void)animal; // To silence "Unused Variable" warnings. - - __android_log_print(ANDROID_LOG_INFO, "FlatBufferSample", - "FlatBuffer successfully created and verified."); -}
diff --git a/third_party/flatbuffers/samples/android/jni/schemas/animal.fbs b/third_party/flatbuffers/samples/android/jni/schemas/animal.fbs deleted file mode 100644 index d1bd38d..0000000 --- a/third_party/flatbuffers/samples/android/jni/schemas/animal.fbs +++ /dev/null
@@ -1,22 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace sample; - -table Animal { - name:string; - sound:string; -} - -root_type Animal;
diff --git a/third_party/flatbuffers/samples/android/res/values/strings.xml b/third_party/flatbuffers/samples/android/res/values/strings.xml deleted file mode 100755 index 57ddaf4..0000000 --- a/third_party/flatbuffers/samples/android/res/values/strings.xml +++ /dev/null
@@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (c) 2015 Google, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - --> -<resources> - <string name="app_name">FlatBufferSample</string> -</resources>
diff --git a/third_party/flatbuffers/samples/android_sample.sh b/third_party/flatbuffers/samples/android_sample.sh deleted file mode 100755 index ead8fd8..0000000 --- a/third_party/flatbuffers/samples/android_sample.sh +++ /dev/null
@@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script requires the Android NDK and Android SDK to be installed. -# It also requires an Android device to be connected for installing and -# running the applicaton. - -sampledir=$(readlink -fn `dirname $0`) -currentdir=$(readlink -fn `pwd`) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Execute `build_apk.sh` to build and run the android app. -cd android -./build_apk.sh - -# Cleanup the temporary files. -rm build.xml local.properties proguard-project.txt project.properties -rm -rf bin libs obj
diff --git a/third_party/flatbuffers/samples/csharp_sample.sh b/third_party/flatbuffers/samples/csharp_sample.sh deleted file mode 100755 index ea472ed..0000000 --- a/third_party/flatbuffers/samples/csharp_sample.sh +++ /dev/null
@@ -1,50 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `mono` to be installed -# and `flatc` to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootidr=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --csharp --gen-mutable monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --csharp --gen-mutable monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Compiling and running the C# sample. - -# Compile and execute the sample. -mcs SampleBinary.cs MyGame/Sample/*.cs ../net/FlatBuffers/*.cs -mono SampleBinary.exe - -# Cleanup temporary files. -rm SampleBinary.exe -rm -rf MyGame/
diff --git a/third_party/flatbuffers/samples/go_sample.sh b/third_party/flatbuffers/samples/go_sample.sh deleted file mode 100755 index 13a96c1..0000000 --- a/third_party/flatbuffers/samples/go_sample.sh +++ /dev/null
@@ -1,63 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `go` to be installed -# and 'flatc' to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootdir=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --go monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --go monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Compiling and running the Go sample. - -# Go requires a particular layout of files in order to link the necessary -# packages. Copy these files to the respective directores to compile the -# sample. -mkdir -p ${sampledir}/go_gen/src/MyGame/Sample -mkdir -p ${sampledir}/go_gen/src/github.com/google/flatbuffers/go -cp MyGame/Sample/*.go ${sampledir}/go_gen/src/MyGame/Sample/ -cp ${sampledir}/../go/* ${sampledir}/go_gen/src/github.com/google/flatbuffers/go - -# Export the `GOPATH`, so that `go` will know which directories to search for -# the libraries. -export GOPATH=${sampledir}/go_gen/ - -# Compile and execute the sample. -go build -o go_sample sample_binary.go -./go_sample - -# Clean up the temporary files. -rm -rf MyGame/ -rm -rf ${sampledir}/go_gen/ -rm go_sample
diff --git a/third_party/flatbuffers/samples/java_sample.sh b/third_party/flatbuffers/samples/java_sample.sh deleted file mode 100755 index bd1315f..0000000 --- a/third_party/flatbuffers/samples/java_sample.sh +++ /dev/null
@@ -1,51 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `java` to be installed -# and `flatc` to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootdir=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --java --gen-mutable monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --java --gen-mutable monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Compiling and running the Java sample. - -# Compile and execute the sample. -javac -classpath ${sampledir}/../java:${sampledir} SampleBinary.java -java -classpath ${sampledir}/../java:${sampledir} SampleBinary - -# Cleanup temporary files. -rm -rf MyGame/ -rm ${sampledir}/../java/com/google/flatbuffers/*.class -rm *.class
diff --git a/third_party/flatbuffers/samples/javascript_sample.sh b/third_party/flatbuffers/samples/javascript_sample.sh deleted file mode 100755 index 4bbc478..0000000 --- a/third_party/flatbuffers/samples/javascript_sample.sh +++ /dev/null
@@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `Node.js` to be installed -# and `flatc` to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootdir=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --js monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --js monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Running the JavaScript sample. - -# Execute the sample. -node samplebinary.js - -# Cleanup temporary files. -rm monster_generated.js
diff --git a/third_party/flatbuffers/samples/monster.fbs b/third_party/flatbuffers/samples/monster.fbs deleted file mode 100755 index 247b817..0000000 --- a/third_party/flatbuffers/samples/monster.fbs +++ /dev/null
@@ -1,32 +0,0 @@ -// Example IDL file for our monster's schema. - -namespace MyGame.Sample; - -enum Color:byte { Red = 0, Green, Blue = 2 } - -union Equipment { Weapon } // Optionally add more tables. - -struct Vec3 { - x:float; - y:float; - z:float; -} - -table Monster { - pos:Vec3; - mana:short = 150; - hp:short = 100; - name:string; - friendly:bool = false (deprecated); - inventory:[ubyte]; - color:Color = Blue; - weapons:[Weapon]; - equipped:Equipment; -} - -table Weapon { - name:string; - damage:short; -} - -root_type Monster;
diff --git a/third_party/flatbuffers/samples/monsterdata.json b/third_party/flatbuffers/samples/monsterdata.json deleted file mode 100755 index 0db1d29..0000000 --- a/third_party/flatbuffers/samples/monsterdata.json +++ /dev/null
@@ -1,25 +0,0 @@ -{ - pos: { - x: 1, - y: 2, - z: 3 - }, - hp: 300, - name: "Orc", - weapons:[ - { - name: "axe", - damage:100 - }, - { - name: "bow", - damage:90 - } - ], - equipped_type: "Weapon", - equipped: - { - name: "bow", - damage:90 - } -}
diff --git a/third_party/flatbuffers/samples/php_sample.sh b/third_party/flatbuffers/samples/php_sample.sh deleted file mode 100755 index c23edc3..0000000 --- a/third_party/flatbuffers/samples/php_sample.sh +++ /dev/null
@@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `php` to be installed -# and `flatc` to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootdir=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --php monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --php monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Running the PHP sample. - -# Execute the sample. -php SampleBinary.php - -# Clean up temporary files. -rm -rf MyGame/
diff --git a/third_party/flatbuffers/samples/python_sample.sh b/third_party/flatbuffers/samples/python_sample.sh deleted file mode 100755 index ca5de2b..0000000 --- a/third_party/flatbuffers/samples/python_sample.sh +++ /dev/null
@@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Note: This script runs on Mac and Linux. It requires `python` to be installed -# and `flatc` to be built (using `cmake` in the root directory). - -sampledir=$(cd $(dirname $BASH_SOURCE) && pwd) -rootdir=$(cd $sampledir/.. && pwd) -currentdir=$(pwd) - -if [[ "$sampledir" != "$currentdir" ]]; then - echo Error: This script must be run from inside the $sampledir directory. - echo You executed it from the $currentdir directory. - exit 1 -fi - -# Run `flatc`. Note: This requires you to compile using `cmake` from the -# root `/flatbuffers` directory. -if [ -e ../flatc ]; then - ../flatc --python monster.fbs -elif [ -e ../Debug/flatc ]; then - ../Debug/flatc --python monster.fbs -else - echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ - $rootdir directory. - exit 1 -fi - -echo Running the Python sample. - -# Execute the sample. -python sample_binary.py - -# Clean up the temporary files. -rm -rf MyGame
diff --git a/third_party/flatbuffers/samples/sample_binary.cpp b/third_party/flatbuffers/samples/sample_binary.cpp deleted file mode 100644 index 4c5f017..0000000 --- a/third_party/flatbuffers/samples/sample_binary.cpp +++ /dev/null
@@ -1,105 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "monster_generated.h" // Already includes "flatbuffers/flatbuffers.h". - -using namespace MyGame::Sample; - -// Example how to use FlatBuffers to create and read binary buffers. - -int main(int /*argc*/, const char * /*argv*/[]) { - // Build up a serialized buffer algorithmically: - flatbuffers::FlatBufferBuilder builder; - - // First, lets serialize some weapons for the Monster: A 'sword' and an 'axe'. - auto weapon_one_name = builder.CreateString("Sword"); - short weapon_one_damage = 3; - - auto weapon_two_name = builder.CreateString("Axe"); - short weapon_two_damage = 5; - - // Use the `CreateWeapon` shortcut to create Weapons with all fields set. - auto sword = CreateWeapon(builder, weapon_one_name, weapon_one_damage); - auto axe = CreateWeapon(builder, weapon_two_name, weapon_two_damage); - - // Create a FlatBuffer's `vector` from the `std::vector`. - std::vector<flatbuffers::Offset<Weapon>> weapons_vector; - weapons_vector.push_back(sword); - weapons_vector.push_back(axe); - auto weapons = builder.CreateVector(weapons_vector); - - // Second, serialize the rest of the objects needed by the Monster. - auto position = Vec3(1.0f, 2.0f, 3.0f); - - auto name = builder.CreateString("MyMonster"); - - unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - auto inventory = builder.CreateVector(inv_data, 10); - - // Shortcut for creating monster with all fields set: - auto orc = CreateMonster(builder, &position, 150, 80, name, inventory, - Color_Red, weapons, Equipment_Weapon, axe.Union()); - - builder.Finish(orc); // Serialize the root of the object. - - // We now have a FlatBuffer we can store on disk or send over a network. - - // ** file/network code goes here :) ** - // access builder.GetBufferPointer() for builder.GetSize() bytes - - // Instead, we're going to access it right away (as if we just received it). - - // Get access to the root: - auto monster = GetMonster(builder.GetBufferPointer()); - - // Get and test some scalar types from the FlatBuffer. - assert(monster->hp() == 80); - assert(monster->mana() == 150); // default - assert(monster->name()->str() == "MyMonster"); - - // Get and test a field of the FlatBuffer's `struct`. - auto pos = monster->pos(); - assert(pos); - assert(pos->z() == 3.0f); - (void)pos; - - // Get a test an element from the `inventory` FlatBuffer's `vector`. - auto inv = monster->inventory(); - assert(inv); - assert(inv->Get(9) == 9); - (void)inv; - - // Get and test the `weapons` FlatBuffers's `vector`. - std::string expected_weapon_names[] = {"Sword", "Axe"}; - short expected_weapon_damages[] = {3, 5}; - auto weps = monster->weapons(); - for (unsigned int i = 0; i < weps->size(); i++) { - assert(weps->Get(i)->name()->str() == expected_weapon_names[i]); - assert(weps->Get(i)->damage() == expected_weapon_damages[i]); - } - (void)expected_weapon_names; - (void)expected_weapon_damages; - - // Get and test the `Equipment` union (`equipped` field). - assert(monster->equipped_type() == Equipment_Weapon); - auto equipped = static_cast<const Weapon*>(monster->equipped()); - assert(equipped->name()->str() == "Axe"); - assert(equipped->damage() == 5); - (void)equipped; - - printf("The FlatBuffer was successfully created and verified!\n"); -} -
diff --git a/third_party/flatbuffers/samples/sample_binary.go b/third_party/flatbuffers/samples/sample_binary.go deleted file mode 100644 index e04650b..0000000 --- a/third_party/flatbuffers/samples/sample_binary.go +++ /dev/null
@@ -1,165 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// To run, use the `go_sample.sh` script. - -package main - -import ( - sample "MyGame/Sample" - "fmt" - flatbuffers "github.com/google/flatbuffers/go" - "strconv" -) - -// Example how to use Flatbuffers to create and read binary buffers. -func main() { - builder := flatbuffers.NewBuilder(0) - - // Create some weapons for our Monster ("Sword" and "Axe"). - weaponOne := builder.CreateString("Sword") - weaponTwo := builder.CreateString("Axe") - - sample.WeaponStart(builder) - sample.WeaponAddName(builder, weaponOne) - sample.WeaponAddDamage(builder, 3) - sword := sample.WeaponEnd(builder) - - sample.WeaponStart(builder) - sample.WeaponAddName(builder, weaponTwo) - sample.WeaponAddDamage(builder, 5) - axe := sample.WeaponEnd(builder) - - // Serialize the FlatBuffer data. - name := builder.CreateString("Orc") - - sample.MonsterStartInventoryVector(builder, 10) - // Note: Since we prepend the bytes, this loop iterates in reverse. - for i := 9; i >= 0; i-- { - builder.PrependByte(byte(i)) - } - inv := builder.EndVector(10) - - sample.MonsterStartWeaponsVector(builder, 2) - // Note: Since we prepend the weapons, prepend in reverse order. - builder.PrependUOffsetT(axe) - builder.PrependUOffsetT(sword) - weapons := builder.EndVector(2) - - pos := sample.CreateVec3(builder, 1.0, 2.0, 3.0) - - sample.MonsterStart(builder) - sample.MonsterAddPos(builder, pos) - sample.MonsterAddHp(builder, 300) - sample.MonsterAddName(builder, name) - sample.MonsterAddInventory(builder, inv) - sample.MonsterAddColor(builder, sample.ColorRed) - sample.MonsterAddWeapons(builder, weapons) - sample.MonsterAddEquippedType(builder, sample.EquipmentWeapon) - sample.MonsterAddEquipped(builder, axe) - orc := sample.MonsterEnd(builder) - - builder.Finish(orc) - - // We now have a FlatBuffer that we could store on disk or send over a network. - - // ...Saving to file or sending over a network code goes here... - - // Instead, we are going to access this buffer right away (as if we just received it). - - buf := builder.FinishedBytes() - - // Note: We use `0` for the offset here, since we got the data using the - // `builder.FinishedBytes()` method. This simulates the data you would store/receive in your - // FlatBuffer. If you wanted to read from the `builder.Bytes` directly, you would need to - // pass in the offset of `builder.Head()`, as the builder actually constructs the buffer - // backwards. - monster := sample.GetRootAsMonster(buf, 0) - - // Note: We did not set the `mana` field explicitly, so we get the - // default value. - assert(monster.Mana() == 150, "`monster.Mana()`", strconv.Itoa(int(monster.Mana())), "150") - assert(monster.Hp() == 300, "`monster.Hp()`", strconv.Itoa(int(monster.Hp())), "300") - assert(string(monster.Name()) == "Orc", "`string(monster.Name())`", string(monster.Name()), - "\"Orc\"") - assert(monster.Color() == sample.ColorRed, "`monster.Color()`", - strconv.Itoa(int(monster.Color())), strconv.Itoa(int(sample.ColorRed))) - - // Note: Whenever you access a new object, like in `Pos()`, a new temporary accessor object - // gets created. If your code is very performance sensitive, you can pass in a pointer to an - // existing `Vec3` instead of `nil`. This allows you to reuse it across many calls to reduce - // the amount of object allocation/garbage collection. - assert(monster.Pos(nil).X() == 1.0, "`monster.Pos(nil).X()`", - strconv.FormatFloat(float64(monster.Pos(nil).X()), 'f', 1, 32), "1.0") - assert(monster.Pos(nil).Y() == 2.0, "`monster.Pos(nil).Y()`", - strconv.FormatFloat(float64(monster.Pos(nil).Y()), 'f', 1, 32), "2.0") - assert(monster.Pos(nil).Z() == 3.0, "`monster.Pos(nil).Z()`", - strconv.FormatFloat(float64(monster.Pos(nil).Z()), 'f', 1, 32), "3.0") - - // For vectors, like `Inventory`, they have a method suffixed with 'Length' that can be used - // to query the length of the vector. You can index the vector by passing an index value - // into the accessor. - for i := 0; i < monster.InventoryLength(); i++ { - assert(monster.Inventory(i) == byte(i), "`monster.Inventory(i)`", - strconv.Itoa(int(monster.Inventory(i))), strconv.Itoa(int(byte(i)))) - } - - expectedWeaponNames := []string{"Sword", "Axe"} - expectedWeaponDamages := []int{3, 5} - weapon := new(sample.Weapon) // We need a `sample.Weapon` to pass into `monster.Weapons()` - // to capture the output of that function. - for i := 0; i < monster.WeaponsLength(); i++ { - if monster.Weapons(weapon, i) { - assert(string(weapon.Name()) == expectedWeaponNames[i], "`weapon.Name()`", - string(weapon.Name()), expectedWeaponNames[i]) - assert(int(weapon.Damage()) == expectedWeaponDamages[i], - "`weapon.Damage()`", strconv.Itoa(int(weapon.Damage())), - strconv.Itoa(expectedWeaponDamages[i])) - } - } - - // For FlatBuffer `union`s, you can get the type of the union, as well as the union - // data itself. - assert(monster.EquippedType() == sample.EquipmentWeapon, "`monster.EquippedType()`", - strconv.Itoa(int(monster.EquippedType())), strconv.Itoa(int(sample.EquipmentWeapon))) - - unionTable := new(flatbuffers.Table) - if monster.Equipped(unionTable) { - // An example of how you can appropriately convert the table depending on the - // FlatBuffer `union` type. You could add `else if` and `else` clauses to handle - // other FlatBuffer `union` types for this field. (Similarly, this could be - // done in a switch statement.) - if monster.EquippedType() == sample.EquipmentWeapon { - unionWeapon := new(sample.Weapon) - unionWeapon.Init(unionTable.Bytes, unionTable.Pos) - - assert(string(unionWeapon.Name()) == "Axe", "`unionWeapon.Name()`", - string(unionWeapon.Name()), "Axe") - assert(int(unionWeapon.Damage()) == 5, "`unionWeapon.Damage()`", - strconv.Itoa(int(unionWeapon.Damage())), strconv.Itoa(5)) - } - } - - fmt.Printf("The FlatBuffer was successfully created and verified!\n") -} - -// A helper function to print out if an assertion failed. -func assert(assertPassed bool, codeExecuted string, actualValue string, expectedValue string) { - if assertPassed == false { - panic("Assert failed! " + codeExecuted + " (" + actualValue + - ") was not equal to " + expectedValue + ".") - } -}
diff --git a/third_party/flatbuffers/samples/sample_binary.py b/third_party/flatbuffers/samples/sample_binary.py deleted file mode 100644 index 96711fb..0000000 --- a/third_party/flatbuffers/samples/sample_binary.py +++ /dev/null
@@ -1,137 +0,0 @@ -#!/usr/bin/python -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# To run this file, use `python_sample.sh`. - -# Append paths to the `flatbuffers` and `MyGame` modules. This is necessary -# to facilitate executing this script in the `samples` folder, and to root -# folder (where it gets placed when using `cmake`). -import os -import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../python')) - -import flatbuffers -import MyGame.Sample.Color -import MyGame.Sample.Equipment -import MyGame.Sample.Monster -import MyGame.Sample.Vec3 -import MyGame.Sample.Weapon - -# Example of how to use FlatBuffers to create and read binary buffers. - -def main(): - builder = flatbuffers.Builder(0) - - # Create some weapons for our Monster ('Sword' and 'Axe'). - weapon_one = builder.CreateString('Sword') - weapon_two = builder.CreateString('Axe') - - MyGame.Sample.Weapon.WeaponStart(builder) - MyGame.Sample.Weapon.WeaponAddName(builder, weapon_one) - MyGame.Sample.Weapon.WeaponAddDamage(builder, 3) - sword = MyGame.Sample.Weapon.WeaponEnd(builder) - - MyGame.Sample.Weapon.WeaponStart(builder) - MyGame.Sample.Weapon.WeaponAddName(builder, weapon_two) - MyGame.Sample.Weapon.WeaponAddDamage(builder, 5) - axe = MyGame.Sample.Weapon.WeaponEnd(builder) - - # Serialize the FlatBuffer data. - name = builder.CreateString('Orc') - - MyGame.Sample.Monster.MonsterStartInventoryVector(builder, 10) - # Note: Since we prepend the bytes, this loop iterates in reverse order. - for i in reversed(range(0, 10)): - builder.PrependByte(i) - inv = builder.EndVector(10) - - MyGame.Sample.Monster.MonsterStartWeaponsVector(builder, 2) - # Note: Since we prepend the data, prepend the weapons in reverse order. - builder.PrependUOffsetTRelative(axe) - builder.PrependUOffsetTRelative(sword) - weapons = builder.EndVector(2) - - pos = MyGame.Sample.Vec3.CreateVec3(builder, 1.0, 2.0, 3.0) - - MyGame.Sample.Monster.MonsterStart(builder) - MyGame.Sample.Monster.MonsterAddPos(builder, pos) - MyGame.Sample.Monster.MonsterAddHp(builder, 300) - MyGame.Sample.Monster.MonsterAddName(builder, name) - MyGame.Sample.Monster.MonsterAddInventory(builder, inv) - MyGame.Sample.Monster.MonsterAddColor(builder, - MyGame.Sample.Color.Color().Red) - MyGame.Sample.Monster.MonsterAddWeapons(builder, weapons) - MyGame.Sample.Monster.MonsterAddEquippedType( - builder, MyGame.Sample.Equipment.Equipment().Weapon) - MyGame.Sample.Monster.MonsterAddEquipped(builder, axe) - orc = MyGame.Sample.Monster.MonsterEnd(builder) - - builder.Finish(orc) - - # We now have a FlatBuffer that we could store on disk or send over a network. - - # ...Saving to file or sending over a network code goes here... - - # Instead, we are going to access this buffer right away (as if we just - # received it). - - buf = builder.Output() - - # Note: We use `0` for the offset here, since we got the data using the - # `builder.Output()` method. This simulates the data you would store/receive - # in your FlatBuffer. If you wanted to read from the `builder.Bytes` directly, - # you would need to pass in the offset of `builder.Head()`, as the builder - # actually constructs the buffer backwards. - monster = MyGame.Sample.Monster.Monster.GetRootAsMonster(buf, 0) - - # Note: We did not set the `Mana` field explicitly, so we get a default value. - assert monster.Mana() == 150 - assert monster.Hp() == 300 - assert monster.Name() == 'Orc' - assert monster.Color() == MyGame.Sample.Color.Color().Red - assert monster.Pos().X() == 1.0 - assert monster.Pos().Y() == 2.0 - assert monster.Pos().Z() == 3.0 - - # Get and test the `inventory` FlatBuffer `vector`. - for i in xrange(monster.InventoryLength()): - assert monster.Inventory(i) == i - - # Get and test the `weapons` FlatBuffer `vector` of `table`s. - expected_weapon_names = ['Sword', 'Axe'] - expected_weapon_damages = [3, 5] - for i in xrange(monster.WeaponsLength()): - assert monster.Weapons(i).Name() == expected_weapon_names[i] - assert monster.Weapons(i).Damage() == expected_weapon_damages[i] - - # Get and test the `equipped` FlatBuffer `union`. - assert monster.EquippedType() == MyGame.Sample.Equipment.Equipment().Weapon - - # An example of how you can appropriately convert the table depending on the - # FlatBuffer `union` type. You could add `elif` and `else` clauses to handle - # the other FlatBuffer `union` types for this field. - if monster.EquippedType() == MyGame.Sample.Equipment.Equipment().Weapon: - # `monster.Equipped()` returns a `flatbuffers.Table`, which can be used - # to initialize a `MyGame.Sample.Weapon.Weapon()`, in this case. - union_weapon = MyGame.Sample.Weapon.Weapon() - union_weapon.Init(monster.Equipped().Bytes, monster.Equipped().Pos) - - assert union_weapon.Name() == "Axe" - assert union_weapon.Damage() == 5 - - print 'The FlatBuffer was successfully created and verified!' - -if __name__ == '__main__': - main()
diff --git a/third_party/flatbuffers/samples/sample_text.cpp b/third_party/flatbuffers/samples/sample_text.cpp deleted file mode 100644 index d851120..0000000 --- a/third_party/flatbuffers/samples/sample_text.cpp +++ /dev/null
@@ -1,59 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -#include "monster_generated.h" // Already includes "flatbuffers/flatbuffers.h". - -using namespace MyGame::Sample; - -// This is an example of parsing text straight into a buffer and then -// generating flatbuffer (JSON) text from the buffer. -int main(int /*argc*/, const char * /*argv*/[]) { - // load FlatBuffer schema (.fbs) and JSON from disk - std::string schemafile; - std::string jsonfile; - bool ok = flatbuffers::LoadFile("samples/monster.fbs", false, &schemafile) && - flatbuffers::LoadFile("samples/monsterdata.json", false, &jsonfile); - if (!ok) { - printf("couldn't load files!\n"); - return 1; - } - - // parse schema first, so we can use it to parse the data after - flatbuffers::Parser parser; - const char *include_directories[] = { "samples", nullptr }; - ok = parser.Parse(schemafile.c_str(), include_directories) && - parser.Parse(jsonfile.c_str(), include_directories); - assert(ok); - - // here, parser.builder_ contains a binary buffer that is the parsed data. - - // to ensure it is correct, we now generate text back from the binary, - // and compare the two: - std::string jsongen; - if (!GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen)) { - printf("Couldn't serialize parsed data to JSON!\n"); - return 1; - } - - if (jsongen != jsonfile) { - printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str()); - } - - printf("The FlatBuffer has been parsed from JSON successfully.\n"); -}
diff --git a/third_party/flatbuffers/samples/samplebinary.js b/third_party/flatbuffers/samples/samplebinary.js deleted file mode 100644 index 9c8c908..0000000 --- a/third_party/flatbuffers/samples/samplebinary.js +++ /dev/null
@@ -1,106 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// To run, use the `javascript_sample.sh` script. - -var assert = require('assert'); -var flatbuffers = require('../js/flatbuffers').flatbuffers; -var MyGame = require('./monster_generated').MyGame; - -// Example how to use FlatBuffers to create and read binary buffers. -function main() { - var builder = new flatbuffers.Builder(0); - - // Create some weapons for our Monster ('Sword' and 'Axe'). - var weaponOne = builder.createString('Sword'); - var weaponTwo = builder.createString('Axe'); - - MyGame.Sample.Weapon.startWeapon(builder); - MyGame.Sample.Weapon.addName(builder, weaponOne); - MyGame.Sample.Weapon.addDamage(builder, 3); - var sword = MyGame.Sample.Weapon.endWeapon(builder); - - MyGame.Sample.Weapon.startWeapon(builder); - MyGame.Sample.Weapon.addName(builder, weaponTwo); - MyGame.Sample.Weapon.addDamage(builder, 5); - var axe = MyGame.Sample.Weapon.endWeapon(builder); - - // Serialize the FlatBuffer data. - var name = builder.createString('Orc'); - - var treasure = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - var inv = MyGame.Sample.Monster.createInventoryVector(builder, treasure); - - var weaps = [sword, axe]; - var weapons = MyGame.Sample.Monster.createWeaponsVector(builder, weaps); - - var pos = MyGame.Sample.Vec3.createVec3(builder, 1.0, 2.0, 3.0); - - MyGame.Sample.Monster.startMonster(builder); - MyGame.Sample.Monster.addPos(builder, pos); - MyGame.Sample.Monster.addHp(builder, 300); - MyGame.Sample.Monster.addColor(builder, MyGame.Sample.Color.Red) - MyGame.Sample.Monster.addName(builder, name); - MyGame.Sample.Monster.addInventory(builder, inv); - MyGame.Sample.Monster.addWeapons(builder, weapons); - MyGame.Sample.Monster.addEquippedType(builder, MyGame.Sample.Equipment.Weapon); - MyGame.Sample.Monster.addEquipped(builder, weaps[1]); - var orc = MyGame.Sample.Monster.endMonster(builder); - - builder.finish(orc); // You may also call 'MyGame.Example.Monster.finishMonsterBuffer(builder, orc);'. - - // We now have a FlatBuffer that can be stored on disk or sent over a network. - - // ...Code to store to disk or send over a network goes here... - - // Instead, we are going to access it right away, as if we just received it. - - var buf = builder.dataBuffer(); - - // Get access to the root: - var monster = MyGame.Sample.Monster.getRootAsMonster(buf); - - // Note: We did not set the `mana` field explicitly, so we get back the default value. - assert.equal(monster.mana(), 150); - assert.equal(monster.hp(), 300); - assert.equal(monster.name(), 'Orc'); - assert.equal(monster.color(), MyGame.Sample.Color.Red); - assert.equal(monster.pos().x(), 1.0); - assert.equal(monster.pos().y(), 2.0); - assert.equal(monster.pos().z(), 3.0); - - // Get and test the `inventory` FlatBuffer `vector`. - for (var i = 0; i < monster.inventoryLength(); i++) { - assert.equal(monster.inventory(i), i); - } - - // Get and test the `weapons` FlatBuffer `vector` of `table`s. - var expectedWeaponNames = ['Sword', 'Axe']; - var expectedWeaponDamages = [3, 5]; - for (var i = 0; i < monster.weaponsLength(); i++) { - assert.equal(monster.weapons(i).name(), expectedWeaponNames[i]); - assert.equal(monster.weapons(i).damage(), expectedWeaponDamages[i]); - } - - // Get and test the `equipped` FlatBuffer `union`. - assert.equal(monster.equippedType(), MyGame.Sample.Equipment.Weapon); - assert.equal(monster.equipped(new MyGame.Sample.Weapon()).name(), 'Axe'); - assert.equal(monster.equipped(new MyGame.Sample.Weapon()).damage(), 5); - - console.log('The FlatBuffer was successfully created and verified!'); -} - -main();
diff --git a/third_party/flatbuffers/src/code_generators.cpp b/third_party/flatbuffers/src/code_generators.cpp deleted file mode 100644 index b9e73c6..0000000 --- a/third_party/flatbuffers/src/code_generators.cpp +++ /dev/null
@@ -1,182 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/code_generators.h" -#include <assert.h> -#include "flatbuffers/util.h" - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4127) // C4127: conditional expression is constant -#endif - -namespace flatbuffers { - -void CodeWriter::operator+=(std::string text) { - - while (true) { - auto begin = text.find("{{"); - if (begin == std::string::npos) { - break; - } - - auto end = text.find("}}"); - if (end == std::string::npos || end < begin) { - break; - } - - // Write all the text before the first {{ into the stream. - stream_.write(text.c_str(), begin); - - // The key is between the {{ and }}. - const std::string key = text.substr(begin + 2, end - begin - 2); - - // Find the value associated with the key. If it exists, write the - // value into the stream, otherwise write the key itself into the stream. - auto iter = value_map_.find(key); - if (iter != value_map_.end()) { - const std::string &value = iter->second; - stream_ << value; - } else { - assert(false && "could not find key"); - stream_ << key; - } - - // Update the text to everything after the }}. - text = text.substr(end + 2); - } - if (!text.empty() && text.back() == '\\') { - text.pop_back(); - stream_ << text; - } else { - stream_ << text << std::endl; - } -} - -const char *BaseGenerator::FlatBuffersGeneratedWarning() { - return "automatically generated by the FlatBuffers compiler," - " do not modify\n\n"; -} - -std::string BaseGenerator::NamespaceDir(const Parser &parser, - const std::string &path, - const Namespace &ns) { - EnsureDirExists(path.c_str()); - if (parser.opts.one_file) return path; - std::string namespace_dir = path; // Either empty or ends in separator. - auto &namespaces = ns.components; - for (auto it = namespaces.begin(); it != namespaces.end(); ++it) { - namespace_dir += *it + kPathSeparator; - EnsureDirExists(namespace_dir.c_str()); - } - return namespace_dir; -} - -std::string BaseGenerator::NamespaceDir(const Namespace &ns) const { - return BaseGenerator::NamespaceDir(parser_, path_, ns); -} - -bool BaseGenerator::IsEverythingGenerated() const { - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - if (!(*it)->generated) return false; - } - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - if (!(*it)->generated) return false; - } - return true; - } - -std::string BaseGenerator::FullNamespace(const char *separator, - const Namespace &ns) { - std::string namespace_name; - auto &namespaces = ns.components; - for (auto it = namespaces.begin(); it != namespaces.end(); ++it) { - if (namespace_name.length()) namespace_name += separator; - namespace_name += *it; - } - return namespace_name; -} - -std::string BaseGenerator::LastNamespacePart(const Namespace &ns) { - if (!ns.components.empty()) - return ns.components.back(); - else - return std::string(""); -} - -// Ensure that a type is prefixed with its namespace whenever it is used -// outside of its namespace. -std::string BaseGenerator::WrapInNameSpace(const Namespace *ns, - const std::string &name) const { - if (CurrentNameSpace() == ns) return name; - std::string qualified_name = qualifying_start_; - for (auto it = ns->components.begin(); it != ns->components.end(); ++it) - qualified_name += *it + qualifying_separator_; - return qualified_name + name; -} - - -std::string BaseGenerator::WrapInNameSpace(const Definition &def) const { - return WrapInNameSpace(def.defined_namespace, def.name); -} - -std::string BaseGenerator::GetNameSpace(const Definition &def) const { - const Namespace *ns = def.defined_namespace; - if (CurrentNameSpace() == ns) return ""; - std::string qualified_name = qualifying_start_; - for (auto it = ns->components.begin(); it != ns->components.end(); ++it) { - qualified_name += *it; - if (std::next(it) != ns->components.end()) { - qualified_name += qualifying_separator_; - } - } - - return qualified_name; -} - -// Generate a documentation comment, if available. -void GenComment(const std::vector<std::string> &dc, std::string *code_ptr, - const CommentConfig *config, const char *prefix) { - if (dc.begin() == dc.end()) { - // Don't output empty comment blocks with 0 lines of comment content. - return; - } - - std::string &code = *code_ptr; - if (config != nullptr && config->first_line != nullptr) { - code += std::string(prefix) + std::string(config->first_line) + "\n"; - } - std::string line_prefix = std::string(prefix) + - ((config != nullptr && config->content_line_prefix != nullptr) ? - config->content_line_prefix : "///"); - for (auto it = dc.begin(); - it != dc.end(); - ++it) { - code += line_prefix + *it + "\n"; - } - if (config != nullptr && config->last_line != nullptr) { - code += std::string(prefix) + std::string(config->last_line) + "\n"; - } -} - -} // namespace flatbuffers - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif -
diff --git a/third_party/flatbuffers/src/flatc.cpp b/third_party/flatbuffers/src/flatc.cpp deleted file mode 100644 index 7e324eb..0000000 --- a/third_party/flatbuffers/src/flatc.cpp +++ /dev/null
@@ -1,366 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/flatc.h" - -#define FLATC_VERSION "1.6.0 (" __DATE__ ")" - -namespace flatbuffers { - -void FlatCompiler::ParseFile( - flatbuffers::Parser &parser, - const std::string &filename, - const std::string &contents, - std::vector<const char *> &include_directories) const { - auto local_include_directory = flatbuffers::StripFileName(filename); - include_directories.push_back(local_include_directory.c_str()); - include_directories.push_back(nullptr); - if (!parser.Parse(contents.c_str(), &include_directories[0], - filename.c_str())) - Error(parser.error_, false, false); - include_directories.pop_back(); - include_directories.pop_back(); -} - -void FlatCompiler::Warn(const std::string &warn, bool show_exe_name) const { - params_.warn_fn(this, warn, show_exe_name); -} - -void FlatCompiler::Error(const std::string &err, bool usage, - bool show_exe_name) const { - params_.error_fn(this, err, usage, show_exe_name); -} - -std::string FlatCompiler::GetUsageString(const char* program_name) const { - std::stringstream ss; - ss << "Usage: " << program_name << " [OPTION]... FILE... [-- FILE...]\n"; - for (size_t i = 0; i < params_.num_generators; ++i) { - const Generator& g = params_.generators[i]; - - std::stringstream full_name; - full_name << std::setw(12) << std::left << g.generator_opt_long; - const char *name = g.generator_opt_short ? g.generator_opt_short : " "; - const char *help = g.generator_help; - - ss << " " << full_name.str() << " " << name << " " << help << ".\n"; - } - ss << - " -o PATH Prefix PATH to all generated files.\n" - " -I PATH Search for includes in the specified path.\n" - " -M Print make rules for generated files.\n" - " --version Print the version number of flatc and exit.\n" - " --strict-json Strict JSON: field names must be / will be quoted,\n" - " no trailing commas in tables/vectors.\n" - " --allow-non-utf8 Pass non-UTF-8 input through parser and emit nonstandard\n" - " \\x escapes in JSON. (Default is to raise parse error on\n" - " non-UTF-8 input.)\n" - " --defaults-json Output fields whose value is the default when\n" - " writing JSON\n" - " --unknown-json Allow fields in JSON that are not defined in the\n" - " schema. These fields will be discared when generating\n" - " binaries.\n" - " --no-prefix Don\'t prefix enum values with the enum type in C++.\n" - " --scoped-enums Use C++11 style scoped and strongly typed enums.\n" - " also implies --no-prefix.\n" - " --gen-includes (deprecated), this is the default behavior.\n" - " If the original behavior is required (no include\n" - " statements) use --no-includes.\n" - " --no-includes Don\'t generate include statements for included\n" - " schemas the generated file depends on (C++).\n" - " --gen-mutable Generate accessors that can mutate buffers in-place.\n" - " --gen-onefile Generate single output file for C#.\n" - " --gen-name-strings Generate type name functions for C++.\n" - " --escape-proto-ids Disable appending '_' in namespaces names.\n" - " --gen-object-api Generate an additional object-based API.\n" - " --cpp-ptr-type T Set object API pointer type (default std::unique_ptr)\n" - " --cpp-str-type T Set object API string type (default std::string)\n" - " T::c_str() and T::length() must be supported\n" - " --no-js-exports Removes Node.js style export lines in JS.\n" - " --goog-js-export Uses goog.exports* for closure compiler exporting in JS.\n" - " --go-namespace Generate the overrided namespace in Golang.\n" - " --raw-binary Allow binaries without file_indentifier to be read.\n" - " This may crash flatc given a mismatched schema.\n" - " --proto Input is a .proto, translate to .fbs.\n" - " --grpc Generate GRPC interfaces for the specified languages\n" - " --schema Serialize schemas instead of JSON (use with -b)\n" - " --bfbs-comments Add doc comments to the binary schema files.\n" - " --conform FILE Specify a schema the following schemas should be\n" - " an evolution of. Gives errors if not.\n" - " --conform-includes Include path for the schema given with --conform\n" - " PATH \n" - " --include-prefix Prefix this path to any generated include statements.\n" - " PATH\n" - " --no-fb-import Don't include flatbuffers import statement for TypeScript.\n" - " --no-ts-reexport Don't re-export imported dependencies for TypeScript.\n" - "FILEs may be schemas, or JSON files (conforming to preceding schema)\n" - "FILEs after the -- must be binary flatbuffer format files.\n" - "Output files are named using the base file name of the input,\n" - "and written to the current directory or the path given by -o.\n" - "example: " << program_name << " -c -b schema1.fbs schema2.fbs data.json\n"; - return ss.str(); -} - -int FlatCompiler::Compile(int argc, const char** argv) { - if (params_.generators == nullptr || params_.num_generators == 0) { - return 0; - } - - flatbuffers::IDLOptions opts; - std::string output_path; - - bool any_generator = false; - bool print_make_rules = false; - bool raw_binary = false; - bool schema_binary = false; - bool grpc_enabled = false; - std::vector<std::string> filenames; - std::vector<const char *> include_directories; - std::vector<const char *> conform_include_directories; - std::vector<bool> generator_enabled(params_.num_generators, false); - size_t binary_files_from = std::numeric_limits<size_t>::max(); - std::string conform_to_schema; - - for (int argi = 0; argi < argc; argi++) { - std::string arg = argv[argi]; - if (arg[0] == '-') { - if (filenames.size() && arg[1] != '-') - Error("invalid option location: " + arg, true); - if (arg == "-o") { - if (++argi >= argc) Error("missing path following: " + arg, true); - output_path = flatbuffers::ConCatPathFileName(argv[argi], ""); - } else if(arg == "-I") { - if (++argi >= argc) Error("missing path following" + arg, true); - include_directories.push_back(argv[argi]); - } else if(arg == "--conform") { - if (++argi >= argc) Error("missing path following" + arg, true); - conform_to_schema = argv[argi]; - } else if (arg == "--conform-includes") { - if (++argi >= argc) Error("missing path following" + arg, true); - conform_include_directories.push_back(argv[argi]); - } else if (arg == "--include-prefix") { - if (++argi >= argc) Error("missing path following" + arg, true); - opts.include_prefix = argv[argi]; - if (opts.include_prefix.back() != '/' && - opts.include_prefix.back() != '\\') opts.include_prefix += "/"; - } else if(arg == "--strict-json") { - opts.strict_json = true; - } else if(arg == "--allow-non-utf8") { - opts.allow_non_utf8 = true; - } else if(arg == "--no-js-exports") { - opts.skip_js_exports = true; - } else if(arg == "--goog-js-export") { - opts.use_goog_js_export_format = true; - } else if(arg == "--go-namespace") { - if (++argi >= argc) Error("missing golang namespace" + arg, true); - opts.go_namespace = argv[argi]; - } else if(arg == "--defaults-json") { - opts.output_default_scalars_in_json = true; - } else if (arg == "--unknown-json") { - opts.skip_unexpected_fields_in_json = true; - } else if(arg == "--no-prefix") { - opts.prefixed_enums = false; - } else if(arg == "--scoped-enums") { - opts.prefixed_enums = false; - opts.scoped_enums = true; - } else if (arg == "--no-union-value-namespacing") { - opts.union_value_namespacing = false; - } else if(arg == "--gen-mutable") { - opts.mutable_buffer = true; - } else if(arg == "--gen-name-strings") { - opts.generate_name_strings = true; - } else if(arg == "--gen-object-api") { - opts.generate_object_based_api = true; - } else if (arg == "--cpp-ptr-type") { - if (++argi >= argc) Error("missing type following" + arg, true); - opts.cpp_object_api_pointer_type = argv[argi]; - } else if (arg == "--cpp-str-type") { - if (++argi >= argc) Error("missing type following" + arg, true); - opts.cpp_object_api_string_type = argv[argi]; - } else if(arg == "--gen-all") { - opts.generate_all = true; - opts.include_dependence_headers = false; - } else if(arg == "--gen-includes") { - // Deprecated, remove this option some time in the future. - printf("warning: --gen-includes is deprecated (it is now default)\n"); - } else if(arg == "--no-includes") { - opts.include_dependence_headers = false; - } else if (arg == "--gen-onefile") { - opts.one_file = true; - } else if (arg == "--raw-binary") { - raw_binary = true; - } else if(arg == "--") { // Separator between text and binary inputs. - binary_files_from = filenames.size(); - } else if(arg == "--proto") { - opts.proto_mode = true; - } else if(arg == "--escape-proto-ids") { - opts.escape_proto_identifiers = true; - } else if(arg == "--schema") { - schema_binary = true; - } else if(arg == "-M") { - print_make_rules = true; - } else if(arg == "--version") { - printf("flatc version %s\n", FLATC_VERSION); - exit(0); - } else if(arg == "--grpc") { - grpc_enabled = true; - } else if(arg == "--bfbs-comments") { - opts.binary_schema_comments = true; - } else if(arg == "--no-fb-import") { - opts.skip_flatbuffers_import = true; - } else if(arg == "--no-ts-reexport") { - opts.reexport_ts_modules = false; - } else { - for (size_t i = 0; i < params_.num_generators; ++i) { - if (arg == params_.generators[i].generator_opt_long || - (params_.generators[i].generator_opt_short && - arg == params_.generators[i].generator_opt_short)) { - generator_enabled[i] = true; - any_generator = true; - opts.lang_to_generate |= params_.generators[i].lang; - goto found; - } - } - Error("unknown commandline argument: " + arg, true); - found:; - } - } else { - filenames.push_back(argv[argi]); - } - } - - if (!filenames.size()) Error("missing input files", false, true); - - if (opts.proto_mode) { - if (any_generator) - Error("cannot generate code directly from .proto files", true); - } else if (!any_generator && conform_to_schema.empty()) { - Error("no options: specify at least one generator.", true); - } - - flatbuffers::Parser conform_parser; - if (!conform_to_schema.empty()) { - std::string contents; - if (!flatbuffers::LoadFile(conform_to_schema.c_str(), true, &contents)) - Error("unable to load schema: " + conform_to_schema); - ParseFile(conform_parser, conform_to_schema, contents, - conform_include_directories); - } - - std::unique_ptr<flatbuffers::Parser> parser(new flatbuffers::Parser(opts)); - - for (auto file_it = filenames.begin(); - file_it != filenames.end(); - ++file_it) { - std::string contents; - if (!flatbuffers::LoadFile(file_it->c_str(), true, &contents)) - Error("unable to load file: " + *file_it); - - bool is_binary = static_cast<size_t>(file_it - filenames.begin()) >= - binary_files_from; - if (is_binary) { - parser->builder_.Clear(); - parser->builder_.PushFlatBuffer( - reinterpret_cast<const uint8_t *>(contents.c_str()), - contents.length()); - if (!raw_binary) { - // Generally reading binaries that do not correspond to the schema - // will crash, and sadly there's no way around that when the binary - // does not contain a file identifier. - // We'd expect that typically any binary used as a file would have - // such an identifier, so by default we require them to match. - if (!parser->file_identifier_.length()) { - Error("current schema has no file_identifier: cannot test if \"" + - *file_it + - "\" matches the schema, use --raw-binary to read this file" - " anyway."); - } else if (!flatbuffers::BufferHasIdentifier(contents.c_str(), - parser->file_identifier_.c_str())) { - Error("binary \"" + - *file_it + - "\" does not have expected file_identifier \"" + - parser->file_identifier_ + - "\", use --raw-binary to read this file anyway."); - } - } - } else { - // Check if file contains 0 bytes. - if (contents.length() != strlen(contents.c_str())) { - Error("input file appears to be binary: " + *file_it, true); - } - auto is_schema = flatbuffers::GetExtension(*file_it) == "fbs"; - if (is_schema) { - // If we're processing multiple schemas, make sure to start each - // one from scratch. If it depends on previous schemas it must do - // so explicitly using an include. - parser.reset(new flatbuffers::Parser(opts)); - } - ParseFile(*parser.get(), *file_it, contents, include_directories); - if (is_schema && !conform_to_schema.empty()) { - auto err = parser->ConformTo(conform_parser); - if (!err.empty()) Error("schemas don\'t conform: " + err); - } - if (schema_binary) { - parser->Serialize(); - parser->file_extension_ = reflection::SchemaExtension(); - } - } - - std::string filebase = flatbuffers::StripPath( - flatbuffers::StripExtension(*file_it)); - - for (size_t i = 0; i < params_.num_generators; ++i) { - parser->opts.lang = params_.generators[i].lang; - if (generator_enabled[i]) { - if (!print_make_rules) { - flatbuffers::EnsureDirExists(output_path); - if (!params_.generators[i].generate(*parser.get(), output_path, filebase)) { - Error(std::string("Unable to generate ") + - params_.generators[i].lang_name + - " for " + - filebase); - } - } else { - std::string make_rule = params_.generators[i].make_rule( - *parser.get(), output_path, *file_it); - if (!make_rule.empty()) - printf("%s\n", flatbuffers::WordWrap( - make_rule, 80, " ", " \\").c_str()); - } - if (grpc_enabled) { - if (params_.generators[i].generateGRPC != nullptr) { - if (!params_.generators[i].generateGRPC(*parser.get(), output_path, - filebase)) { - Error(std::string("Unable to generate GRPC interface for") + - params_.generators[i].lang_name); - } - } else { - Warn(std::string("GRPC interface generator not implemented for ") - + params_.generators[i].lang_name); - } - } - } - } - - if (opts.proto_mode) GenerateFBS(*parser.get(), output_path, filebase); - - // We do not want to generate code for the definitions in this file - // in any files coming up next. - parser->MarkGenerated(); - } - return 0; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/flatc_main.cpp b/third_party/flatbuffers/src/flatc_main.cpp deleted file mode 100644 index d838bac..0000000 --- a/third_party/flatbuffers/src/flatc_main.cpp +++ /dev/null
@@ -1,109 +0,0 @@ -/* - * Copyright 2017 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/flatc.h" - -static const char *g_program_name = nullptr; - -static void Warn(const flatbuffers::FlatCompiler *flatc, - const std::string &warn, - bool show_exe_name) { - (void)flatc; - if (show_exe_name) { - printf("%s: ", g_program_name); - } - printf("warning: %s\n", warn.c_str()); -} - -static void Error(const flatbuffers::FlatCompiler *flatc, - const std::string &err, - bool usage, - bool show_exe_name) { - if (show_exe_name) { - printf("%s: ", g_program_name); - } - printf("error: %s\n", err.c_str()); - if (usage) { - printf("%s", flatc->GetUsageString(g_program_name).c_str()); - } - exit(1); -} - -int main(int argc, const char *argv[]) { - g_program_name = argv[0]; - - const flatbuffers::FlatCompiler::Generator generators[] = { - { flatbuffers::GenerateBinary, "-b", "--binary", "binary", - nullptr, - flatbuffers::IDLOptions::kBinary, - "Generate wire format binaries for any data definitions", - flatbuffers::BinaryMakeRule }, - { flatbuffers::GenerateTextFile, "-t", "--json", "text", - nullptr, - flatbuffers::IDLOptions::kJson, - "Generate text output for any data definitions", - flatbuffers::TextMakeRule }, - { flatbuffers::GenerateCPP, "-c", "--cpp", "C++", - flatbuffers::GenerateCppGRPC, - flatbuffers::IDLOptions::kCpp, - "Generate C++ headers for tables/structs", - flatbuffers::CPPMakeRule }, - { flatbuffers::GenerateGo, "-g", "--go", "Go", - flatbuffers::GenerateGoGRPC, - flatbuffers::IDLOptions::kGo, - "Generate Go files for tables/structs", - flatbuffers::GeneralMakeRule }, - { flatbuffers::GenerateGeneral, "-j", "--java", "Java", - nullptr, - flatbuffers::IDLOptions::kJava, - "Generate Java classes for tables/structs", - flatbuffers::GeneralMakeRule }, - { flatbuffers::GenerateJS, "-s", "--js", "JavaScript", - nullptr, - flatbuffers::IDLOptions::kJs, - "Generate JavaScript code for tables/structs", - flatbuffers::JSMakeRule }, - { flatbuffers::GenerateJS, "-T", "--ts", "TypeScript", - nullptr, - flatbuffers::IDLOptions::kTs, - "Generate TypeScript code for tables/structs", - flatbuffers::JSMakeRule }, - { flatbuffers::GenerateGeneral, "-n", "--csharp", "C#", - nullptr, - flatbuffers::IDLOptions::kCSharp, - "Generate C# classes for tables/structs", - flatbuffers::GeneralMakeRule }, - { flatbuffers::GeneratePython, "-p", "--python", "Python", - nullptr, - flatbuffers::IDLOptions::kPython, - "Generate Python files for tables/structs", - flatbuffers::GeneralMakeRule }, - { flatbuffers::GeneratePhp, nullptr, "--php", "PHP", - nullptr, - flatbuffers::IDLOptions::kPhp, - "Generate PHP files for tables/structs", - flatbuffers::GeneralMakeRule }, - }; - - flatbuffers::FlatCompiler::InitParams params; - params.generators = generators; - params.num_generators = sizeof(generators) / sizeof(generators[0]); - params.warn_fn = Warn; - params.error_fn = Error; - - flatbuffers::FlatCompiler flatc(params); - return flatc.Compile(argc - 1, argv + 1); -}
diff --git a/third_party/flatbuffers/src/flathash.cpp b/third_party/flatbuffers/src/flathash.cpp deleted file mode 100644 index 1a033f8..0000000 --- a/third_party/flatbuffers/src/flathash.cpp +++ /dev/null
@@ -1,103 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <iostream> -#include <sstream> -#include <string> -#include "flatbuffers/hash.h" -#include <stdio.h> - -enum OutputFormat { - kDecimal, - kHexadecimal, - kHexadecimal0x -}; - -int main(int argc, char* argv[]) { - const char* name = argv[0]; - if (argc <= 1) { - printf("%s HASH [OPTION]... STRING... [-- STRING...]\n", name); - printf("Available hashing algorithms:\n 32 bit:\n"); - size_t size = sizeof(flatbuffers::kHashFunctions32) / - sizeof(flatbuffers::kHashFunctions32[0]); - for (size_t i = 0; i < size; ++i) { - printf(" * %s\n", flatbuffers::kHashFunctions32[i].name); - } - printf(" 64 bit:\n"); - size = sizeof(flatbuffers::kHashFunctions64) / - sizeof(flatbuffers::kHashFunctions64[0]); - for (size_t i = 0; i < size; ++i) { - printf(" * %s\n", flatbuffers::kHashFunctions64[i].name); - } - printf( - " -d Output hash in decimal.\n" - " -x Output hash in hexadecimal.\n" - " -0x Output hash in hexadecimal and prefix with 0x.\n" - " -c Append the string to the output in a c-style comment.\n"); - return 0; - } - - const char* hash_algorithm = argv[1]; - - flatbuffers::NamedHashFunction<uint32_t>::HashFunction hash_function32 = - flatbuffers::FindHashFunction32(hash_algorithm); - flatbuffers::NamedHashFunction<uint64_t>::HashFunction hash_function64 = - flatbuffers::FindHashFunction64(hash_algorithm); - - if (!hash_function32 && !hash_function64) { - printf("\"%s\" is not a known hash algorithm.\n", hash_algorithm); - return 0; - } - - OutputFormat output_format = kHexadecimal; - bool annotate = false; - bool escape_dash = false; - for (int i = 2; i < argc; i++) { - const char* arg = argv[i]; - if (!escape_dash && arg[0] == '-') { - std::string opt = arg; - if (opt == "-d") output_format = kDecimal; - else if (opt == "-x") output_format = kHexadecimal; - else if (opt == "-0x") output_format = kHexadecimal0x; - else if (opt == "-c") annotate = true; - else if (opt == "--") escape_dash = true; - else printf("Unrecognized argument: \"%s\"\n", arg); - } else { - std::stringstream ss; - if (output_format == kDecimal) { - ss << std::dec; - } else if (output_format == kHexadecimal) { - ss << std::hex; - } else if (output_format == kHexadecimal0x) { - ss << std::hex; - ss << "0x"; - } - if (hash_function32) - ss << hash_function32(arg); - else if (hash_function64) - ss << hash_function64(arg); - - if (annotate) - ss << " /* \"" << arg << "\" */"; - - ss << "\n"; - - std::cout << ss.str(); - } - } - return 0; -} -
diff --git a/third_party/flatbuffers/src/idl_gen_cpp.cpp b/third_party/flatbuffers/src/idl_gen_cpp.cpp deleted file mode 100644 index b0fd11d..0000000 --- a/third_party/flatbuffers/src/idl_gen_cpp.cpp +++ /dev/null
@@ -1,2201 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -namespace flatbuffers { - -// Pedantic warning free version of toupper(). -inline char ToUpper(char c) { - return static_cast<char>(::toupper(c)); -} - -static std::string GeneratedFileName(const std::string &path, - const std::string &file_name) { - return path + file_name + "_generated.h"; -} - -namespace cpp { -class CppGenerator : public BaseGenerator { - public: - CppGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "", "::"), - cur_name_space_(nullptr) {} - - std::string GenIncludeGuard() const { - // Generate include guard. - std::string guard = file_name_; - // Remove any non-alpha-numeric characters that may appear in a filename. - struct IsAlnum { - bool operator()(char c) { return !isalnum(c); } - }; - guard.erase(std::remove_if(guard.begin(), guard.end(), IsAlnum()), - guard.end()); - guard = "FLATBUFFERS_GENERATED_" + guard; - guard += "_"; - // For further uniqueness, also add the namespace. - auto name_space = parser_.namespaces_.back(); - for (auto it = name_space->components.begin(); - it != name_space->components.end(); ++it) { - guard += *it + "_"; - } - guard += "H_"; - std::transform(guard.begin(), guard.end(), guard.begin(), ToUpper); - return guard; - } - - void GenIncludeDependencies() { - int num_includes = 0; - for (auto it = parser_.native_included_files_.begin(); - it != parser_.native_included_files_.end(); ++it) { - code_ += "#include \"" + *it + "\""; - num_includes++; - } - for (auto it = parser_.included_files_.begin(); - it != parser_.included_files_.end(); ++it) { - const auto basename = - flatbuffers::StripPath(flatbuffers::StripExtension(it->first)); - if (basename != file_name_) { - code_ += "#include \"" + parser_.opts.include_prefix + basename + - "_generated.h\""; - num_includes++; - } - } - if (num_includes) code_ += ""; - } - - // Iterate through all definitions we haven't generate code for (enums, - // structs, and tables) and output them to a single file. - bool generate() { - if (IsEverythingGenerated()) return true; - - code_.Clear(); - code_ += "// " + std::string(FlatBuffersGeneratedWarning()); - - const auto include_guard = GenIncludeGuard(); - code_ += "#ifndef " + include_guard; - code_ += "#define " + include_guard; - code_ += ""; - - code_ += "#include \"flatbuffers/flatbuffers.h\""; - code_ += ""; - - if (parser_.opts.include_dependence_headers) { - GenIncludeDependencies(); - } - - assert(!cur_name_space_); - - // Generate forward declarations for all structs/tables, since they may - // have circular references. - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - const auto &struct_def = **it; - if (!struct_def.generated) { - SetNameSpace(struct_def.defined_namespace); - code_ += "struct " + struct_def.name + ";"; - if (parser_.opts.generate_object_based_api && !struct_def.fixed) { - code_ += "struct " + NativeName(struct_def.name, &struct_def) + ";"; - } - code_ += ""; - } - } - - // Generate code for all the enum declarations. - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - const auto &enum_def = **it; - if (!enum_def.generated) { - SetNameSpace(enum_def.defined_namespace); - GenEnum(enum_def); - } - } - - // Generate code for all structs, then all tables. - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - const auto &struct_def = **it; - if (struct_def.fixed && !struct_def.generated) { - SetNameSpace(struct_def.defined_namespace); - GenStruct(struct_def); - } - } - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - const auto &struct_def = **it; - if (!struct_def.fixed && !struct_def.generated) { - SetNameSpace(struct_def.defined_namespace); - GenTable(struct_def); - } - } - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - const auto &struct_def = **it; - if (!struct_def.fixed && !struct_def.generated) { - SetNameSpace(struct_def.defined_namespace); - GenTablePost(struct_def); - } - } - - // Generate code for union verifiers. - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - const auto &enum_def = **it; - if (enum_def.is_union && !enum_def.generated) { - SetNameSpace(enum_def.defined_namespace); - GenUnionPost(enum_def); - } - } - - // Generate convenient global helper functions: - if (parser_.root_struct_def_) { - auto &struct_def = *parser_.root_struct_def_; - SetNameSpace(struct_def.defined_namespace); - const auto &name = struct_def.name; - const auto qualified_name = - parser_.namespaces_.back()->GetFullyQualifiedName(name); - const auto cpp_name = TranslateNameSpace(qualified_name); - - code_.SetValue("STRUCT_NAME", name); - code_.SetValue("CPP_NAME", cpp_name); - - // The root datatype accessor: - code_ += "inline \\"; - code_ += "const {{CPP_NAME}} *Get{{STRUCT_NAME}}(const void *buf) {"; - code_ += " return flatbuffers::GetRoot<{{CPP_NAME}}>(buf);"; - code_ += "}"; - code_ += ""; - - if (parser_.opts.mutable_buffer) { - code_ += "inline \\"; - code_ += "{{STRUCT_NAME}} *GetMutable{{STRUCT_NAME}}(void *buf) {"; - code_ += " return flatbuffers::GetMutableRoot<{{STRUCT_NAME}}>(buf);"; - code_ += "}"; - code_ += ""; - } - - if (parser_.file_identifier_.length()) { - // Return the identifier - code_ += "inline const char *{{STRUCT_NAME}}Identifier() {"; - code_ += " return \"" + parser_.file_identifier_ + "\";"; - code_ += "}"; - code_ += ""; - - // Check if a buffer has the identifier. - code_ += "inline \\"; - code_ += "bool {{STRUCT_NAME}}BufferHasIdentifier(const void *buf) {"; - code_ += " return flatbuffers::BufferHasIdentifier("; - code_ += " buf, {{STRUCT_NAME}}Identifier());"; - code_ += "}"; - code_ += ""; - } - - // The root verifier. - if (parser_.file_identifier_.length()) { - code_.SetValue("ID", name + "Identifier()"); - } else { - code_.SetValue("ID", "nullptr"); - } - - code_ += "inline bool Verify{{STRUCT_NAME}}Buffer("; - code_ += " flatbuffers::Verifier &verifier) {"; - code_ += " return verifier.VerifyBuffer<{{CPP_NAME}}>({{ID}});"; - code_ += "}"; - code_ += ""; - - if (parser_.file_extension_.length()) { - // Return the extension - code_ += "inline const char *{{STRUCT_NAME}}Extension() {"; - code_ += " return \"" + parser_.file_extension_ + "\";"; - code_ += "}"; - code_ += ""; - } - - // Finish a buffer with a given root object: - code_ += "inline void Finish{{STRUCT_NAME}}Buffer("; - code_ += " flatbuffers::FlatBufferBuilder &fbb,"; - code_ += " flatbuffers::Offset<{{CPP_NAME}}> root) {"; - if (parser_.file_identifier_.length()) - code_ += " fbb.Finish(root, {{STRUCT_NAME}}Identifier());"; - else - code_ += " fbb.Finish(root);"; - code_ += "}"; - code_ += ""; - - if (parser_.opts.generate_object_based_api) { - // A convenient root unpack function. - auto native_name = - NativeName(WrapInNameSpace(struct_def), &struct_def); - code_.SetValue("UNPACK_RETURN", - GenTypeNativePtr(native_name, nullptr, false)); - code_.SetValue("UNPACK_TYPE", - GenTypeNativePtr(native_name, nullptr, true)); - - code_ += "inline {{UNPACK_RETURN}} UnPack{{STRUCT_NAME}}("; - code_ += " const void *buf,"; - code_ += " const flatbuffers::resolver_function_t *res = nullptr) {"; - code_ += " return {{UNPACK_TYPE}}\\"; - code_ += "(Get{{STRUCT_NAME}}(buf)->UnPack(res));"; - code_ += "}"; - code_ += ""; - } - } - - assert(cur_name_space_); - SetNameSpace(nullptr); - - // Close the include guard. - code_ += "#endif // " + include_guard; - - const auto file_path = GeneratedFileName(path_, file_name_); - const auto final_code = code_.ToString(); - return SaveFile(file_path.c_str(), final_code, false); - } - - private: - CodeWriter code_; - - // This tracks the current namespace so we can insert namespace declarations. - const Namespace *cur_name_space_; - - const Namespace *CurrentNameSpace() const { return cur_name_space_; } - - // Translates a qualified name in flatbuffer text format to the same name in - // the equivalent C++ namespace. - static std::string TranslateNameSpace(const std::string &qualified_name) { - std::string cpp_qualified_name = qualified_name; - size_t start_pos = 0; - while ((start_pos = cpp_qualified_name.find(".", start_pos)) != - std::string::npos) { - cpp_qualified_name.replace(start_pos, 1, "::"); - } - return cpp_qualified_name; - } - - void GenComment(const std::vector<std::string> &dc, const char *prefix = "") { - std::string text; - ::flatbuffers::GenComment(dc, &text, nullptr, prefix); - code_ += text + "\\"; - } - - // Return a C++ type from the table in idl.h - std::string GenTypeBasic(const Type &type, bool user_facing_type) const { - static const char *ctypename[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #CTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - if (user_facing_type) { - if (type.enum_def) return WrapInNameSpace(*type.enum_def); - if (type.base_type == BASE_TYPE_BOOL) return "bool"; - } - return ctypename[type.base_type]; - } - - // Return a C++ pointer type, specialized to the actual struct/table types, - // and vector element types. - std::string GenTypePointer(const Type &type) const { - switch (type.base_type) { - case BASE_TYPE_STRING: { - return "flatbuffers::String"; - } - case BASE_TYPE_VECTOR: { - const auto type_name = GenTypeWire(type.VectorType(), "", false); - return "flatbuffers::Vector<" + type_name + ">"; - } - case BASE_TYPE_STRUCT: { - return WrapInNameSpace(*type.struct_def); - } - case BASE_TYPE_UNION: - // fall through - default: { - return "void"; - } - } - } - - // Return a C++ type for any type (scalar/pointer) specifically for - // building a flatbuffer. - std::string GenTypeWire(const Type &type, const char *postfix, - bool user_facing_type) const { - if (IsScalar(type.base_type)) { - return GenTypeBasic(type, user_facing_type) + postfix; - } else if (IsStruct(type)) { - return "const " + GenTypePointer(type) + " *"; - } else { - return "flatbuffers::Offset<" + GenTypePointer(type) + ">" + postfix; - } - } - - // Return a C++ type for any type (scalar/pointer) that reflects its - // serialized size. - std::string GenTypeSize(const Type &type) const { - if (IsScalar(type.base_type)) { - return GenTypeBasic(type, false); - } else if (IsStruct(type)) { - return GenTypePointer(type); - } else { - return "flatbuffers::uoffset_t"; - } - } - - // TODO(wvo): make this configurable. - static std::string NativeName(const std::string &name, const StructDef *sd) { - return sd && !sd->fixed ? name + "T" : name; - } - - const std::string &PtrType(const FieldDef *field) { - auto attr = field ? field->attributes.Lookup("cpp_ptr_type") : nullptr; - return attr ? attr->constant : parser_.opts.cpp_object_api_pointer_type; - } - - const std::string NativeString(const FieldDef *field) { - auto attr = field ? field->attributes.Lookup("cpp_str_type") : nullptr; - auto &ret = attr ? attr->constant : parser_.opts.cpp_object_api_string_type; - if (ret.empty()) { - return "std::string"; - } - return ret; - } - - std::string GenTypeNativePtr(const std::string &type, const FieldDef *field, - bool is_constructor) { - auto &ptr_type = PtrType(field); - if (ptr_type != "naked") { - return ptr_type + "<" + type + ">"; - } else if (is_constructor) { - return ""; - } else { - return type + " *"; - } - } - - std::string GenPtrGet(const FieldDef &field) { - auto &ptr_type = PtrType(&field); - return ptr_type == "naked" ? "" : ".get()"; - } - - std::string GenTypeNative(const Type &type, bool invector, - const FieldDef &field) { - switch (type.base_type) { - case BASE_TYPE_STRING: { - return NativeString(&field); - } - case BASE_TYPE_VECTOR: { - const auto type_name = GenTypeNative(type.VectorType(), true, field); - return "std::vector<" + type_name + ">"; - } - case BASE_TYPE_STRUCT: { - auto type_name = WrapInNameSpace(*type.struct_def); - if (IsStruct(type)) { - auto native_type = type.struct_def->attributes.Lookup("native_type"); - if (native_type) { - type_name = native_type->constant; - } - if (invector || field.native_inline) { - return type_name; - } else { - return GenTypeNativePtr(type_name, &field, false); - } - } else { - return GenTypeNativePtr(NativeName(type_name, type.struct_def), - &field, false); - } - } - case BASE_TYPE_UNION: { - return type.enum_def->name + "Union"; - } - default: { - return GenTypeBasic(type, true); - } - } - } - - // Return a C++ type for any type (scalar/pointer) specifically for - // using a flatbuffer. - std::string GenTypeGet(const Type &type, const char *afterbasic, - const char *beforeptr, const char *afterptr, - bool user_facing_type) { - if (IsScalar(type.base_type)) { - return GenTypeBasic(type, user_facing_type) + afterbasic; - } else { - return beforeptr + GenTypePointer(type) + afterptr; - } - } - - std::string GenEnumDecl(const EnumDef &enum_def) const { - const IDLOptions &opts = parser_.opts; - return (opts.scoped_enums ? "enum class " : "enum ") + enum_def.name; - } - - std::string GenEnumValDecl(const EnumDef &enum_def, - const std::string &enum_val) const { - const IDLOptions &opts = parser_.opts; - return opts.prefixed_enums ? enum_def.name + "_" + enum_val : enum_val; - } - - std::string GetEnumValUse(const EnumDef &enum_def, - const EnumVal &enum_val) const { - const IDLOptions &opts = parser_.opts; - if (opts.scoped_enums) { - return enum_def.name + "::" + enum_val.name; - } else if (opts.prefixed_enums) { - return enum_def.name + "_" + enum_val.name; - } else { - return enum_val.name; - } - } - - std::string StripUnionType(const std::string &name) { - return name.substr(0, name.size() - strlen(UnionTypeFieldSuffix())); - } - - std::string GetUnionElement(const EnumVal &ev, bool wrap, bool actual_type, - bool native_type = false) { - if (ev.union_type.base_type == BASE_TYPE_STRUCT) { - auto name = actual_type ? ev.union_type.struct_def->name : ev.name; - return wrap - ? WrapInNameSpace(ev.union_type.struct_def->defined_namespace, name) - : name; - } else if (ev.union_type.base_type == BASE_TYPE_STRING) { - return actual_type - ? (native_type ? "std::string" : "flatbuffers::String") - : ev.name; - } else { - assert(false); - return ev.name; - } - } - - static std::string UnionVerifySignature(const EnumDef &enum_def) { - return "bool Verify" + enum_def.name + - "(flatbuffers::Verifier &verifier, const void *obj, " + - enum_def.name + " type)"; - } - - static std::string UnionVectorVerifySignature(const EnumDef &enum_def) { - return "bool Verify" + enum_def.name + "Vector" + - "(flatbuffers::Verifier &verifier, " + - "const flatbuffers::Vector<flatbuffers::Offset<void>> *values, " + - "const flatbuffers::Vector<uint8_t> *types)"; - } - - static std::string UnionUnPackSignature(const EnumDef &enum_def, - bool inclass) { - return (inclass ? "static " : "") + - std::string("void *") + - (inclass ? "" : enum_def.name + "Union::") + - "UnPack(const void *obj, " + enum_def.name + - " type, const flatbuffers::resolver_function_t *resolver)"; - } - - static std::string UnionPackSignature(const EnumDef &enum_def, bool inclass) { - return "flatbuffers::Offset<void> " + - (inclass ? "" : enum_def.name + "Union::") + - "Pack(flatbuffers::FlatBufferBuilder &_fbb, " + - "const flatbuffers::rehasher_function_t *_rehasher" + - (inclass ? " = nullptr" : "") + ") const"; - } - - static std::string TableCreateSignature(const StructDef &struct_def, - bool predecl) { - return "flatbuffers::Offset<" + struct_def.name + "> Create" + - struct_def.name + - "(flatbuffers::FlatBufferBuilder &_fbb, const " + - NativeName(struct_def.name, &struct_def) + - " *_o, const flatbuffers::rehasher_function_t *_rehasher" + - (predecl ? " = nullptr" : "") + ")"; - } - - static std::string TablePackSignature(const StructDef &struct_def, - bool inclass) { - return std::string(inclass ? "static " : "") + - "flatbuffers::Offset<" + struct_def.name + "> " + - (inclass ? "" : struct_def.name + "::") + - "Pack(flatbuffers::FlatBufferBuilder &_fbb, " + - "const " + NativeName(struct_def.name, &struct_def) + "* _o, " + - "const flatbuffers::rehasher_function_t *_rehasher" + - (inclass ? " = nullptr" : "") + ")"; - } - - static std::string TableUnPackSignature(const StructDef &struct_def, - bool inclass) { - return NativeName(struct_def.name, &struct_def) + " *" + - (inclass ? "" : struct_def.name + "::") + - "UnPack(const flatbuffers::resolver_function_t *_resolver" + - (inclass ? " = nullptr" : "") + ") const"; - } - - static std::string TableUnPackToSignature(const StructDef &struct_def, - bool inclass) { - return "void " + (inclass ? "" : struct_def.name + "::") + - "UnPackTo(" + NativeName(struct_def.name, &struct_def) + " *" + - "_o, const flatbuffers::resolver_function_t *_resolver" + - (inclass ? " = nullptr" : "") + ") const"; - } - - // Generate an enum declaration and an enum string lookup table. - void GenEnum(const EnumDef &enum_def) { - code_.SetValue("ENUM_NAME", enum_def.name); - code_.SetValue("BASE_TYPE", GenTypeBasic(enum_def.underlying_type, false)); - code_.SetValue("SEP", ""); - - GenComment(enum_def.doc_comment); - code_ += GenEnumDecl(enum_def) + "\\"; - if (parser_.opts.scoped_enums) - code_ += " : {{BASE_TYPE}}\\"; - code_ += " {"; - - int64_t anyv = 0; - const EnumVal *minv = nullptr, *maxv = nullptr; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - - GenComment(ev.doc_comment, " "); - code_.SetValue("KEY", GenEnumValDecl(enum_def, ev.name)); - code_.SetValue("VALUE", NumToString(ev.value)); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - code_.SetValue("SEP", ",\n"); - - minv = !minv || minv->value > ev.value ? &ev : minv; - maxv = !maxv || maxv->value < ev.value ? &ev : maxv; - anyv |= ev.value; - } - - if (parser_.opts.scoped_enums || parser_.opts.prefixed_enums) { - assert(minv && maxv); - - code_.SetValue("SEP", ",\n"); - if (enum_def.attributes.Lookup("bit_flags")) { - code_.SetValue("KEY", GenEnumValDecl(enum_def, "NONE")); - code_.SetValue("VALUE", "0"); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - - code_.SetValue("KEY", GenEnumValDecl(enum_def, "ANY")); - code_.SetValue("VALUE", NumToString(anyv)); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - } else { // MIN & MAX are useless for bit_flags - code_.SetValue("KEY",GenEnumValDecl(enum_def, "MIN")); - code_.SetValue("VALUE", GenEnumValDecl(enum_def, minv->name)); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - - code_.SetValue("KEY",GenEnumValDecl(enum_def, "MAX")); - code_.SetValue("VALUE", GenEnumValDecl(enum_def, maxv->name)); - code_ += "{{SEP}} {{KEY}} = {{VALUE}}\\"; - } - } - code_ += ""; - code_ += "};"; - - if (parser_.opts.scoped_enums && enum_def.attributes.Lookup("bit_flags")) { - code_ += "DEFINE_BITMASK_OPERATORS({{ENUM_NAME}}, {{BASE_TYPE}})"; - } - code_ += ""; - - // Generate a generate string table for enum values. - // Problem is, if values are very sparse that could generate really big - // tables. Ideally in that case we generate a map lookup instead, but for - // the moment we simply don't output a table at all. - auto range = - enum_def.vals.vec.back()->value - enum_def.vals.vec.front()->value + 1; - // Average distance between values above which we consider a table - // "too sparse". Change at will. - static const int kMaxSparseness = 5; - if (range / static_cast<int64_t>(enum_def.vals.vec.size()) < - kMaxSparseness) { - code_ += "inline const char **EnumNames{{ENUM_NAME}}() {"; - code_ += " static const char *names[] = {"; - - auto val = enum_def.vals.vec.front()->value; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - while (val++ != ev.value) { - code_ += " \"\","; - } - code_ += " \"" + ev.name + "\","; - } - code_ += " nullptr"; - code_ += " };"; - - code_ += " return names;"; - code_ += "}"; - code_ += ""; - - code_ += "inline const char *EnumName{{ENUM_NAME}}({{ENUM_NAME}} e) {"; - - code_ += " const size_t index = static_cast<int>(e)\\"; - if (enum_def.vals.vec.front()->value) { - auto vals = GetEnumValUse(enum_def, *enum_def.vals.vec.front()); - code_ += " - static_cast<int>(" + vals + ")\\"; - } - code_ += ";"; - - code_ += " return EnumNames{{ENUM_NAME}}()[index];"; - code_ += "}"; - code_ += ""; - } - - // Generate type traits for unions to map from a type to union enum value. - if (enum_def.is_union && !enum_def.uses_type_aliases) { - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - - if (it == enum_def.vals.vec.begin()) { - code_ += "template<typename T> struct {{ENUM_NAME}}Traits {"; - } - else { - auto name = GetUnionElement(ev, true, true); - code_ += "template<> struct {{ENUM_NAME}}Traits<" + name + "> {"; - } - - auto value = GetEnumValUse(enum_def, ev); - code_ += " static const {{ENUM_NAME}} enum_value = " + value + ";"; - code_ += "};"; - code_ += ""; - } - } - - if (parser_.opts.generate_object_based_api && enum_def.is_union) { - // Generate a union type - code_.SetValue("NAME", enum_def.name); - code_.SetValue("NONE", - GetEnumValUse(enum_def, *enum_def.vals.Lookup("NONE"))); - - code_ += "struct {{NAME}}Union {"; - code_ += " {{NAME}} type;"; - code_ += " void *value;"; - code_ += ""; - code_ += " {{NAME}}Union() : type({{NONE}}), value(nullptr) {}"; - code_ += " {{NAME}}Union({{NAME}}Union&& u) FLATBUFFERS_NOEXCEPT :"; - code_ += " type({{NONE}}), value(nullptr)"; - code_ += " { std::swap(type, u.type); std::swap(value, u.value); }"; - code_ += " {{NAME}}Union(const {{NAME}}Union &) FLATBUFFERS_NOEXCEPT;"; - code_ += " {{NAME}}Union &operator=(const {{NAME}}Union &u) FLATBUFFERS_NOEXCEPT"; - code_ += " { {{NAME}}Union t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; }"; - code_ += " {{NAME}}Union &operator=({{NAME}}Union &&u) FLATBUFFERS_NOEXCEPT"; - code_ += " { std::swap(type, u.type); std::swap(value, u.value); return *this; }"; - code_ += " ~{{NAME}}Union() { Reset(); }"; - code_ += ""; - code_ += " void Reset();"; - code_ += ""; - if (!enum_def.uses_type_aliases) { - code_ += " template <typename T>"; - code_ += " void Set(T&& val) {"; - code_ += " Reset();"; - code_ += " type = {{NAME}}Traits<typename T::TableType>::enum_value;"; - code_ += " if (type != {{NONE}}) {"; - code_ += " value = new T(std::forward<T>(val));"; - code_ += " }"; - code_ += " }"; - code_ += ""; - } - code_ += " " + UnionUnPackSignature(enum_def, true) + ";"; - code_ += " " + UnionPackSignature(enum_def, true) + ";"; - code_ += ""; - - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - if (!ev.value) { - continue; - } - - const auto native_type = - NativeName(GetUnionElement(ev, true, true, true), - ev.union_type.struct_def); - code_.SetValue("NATIVE_TYPE", native_type); - code_.SetValue("NATIVE_NAME", ev.name); - code_.SetValue("NATIVE_ID", GetEnumValUse(enum_def, ev)); - - code_ += " {{NATIVE_TYPE}} *As{{NATIVE_NAME}}() {"; - code_ += " return type == {{NATIVE_ID}} ?"; - code_ += " reinterpret_cast<{{NATIVE_TYPE}} *>(value) : nullptr;"; - code_ += " }"; - } - code_ += "};"; - code_ += ""; - } - - if (enum_def.is_union) { - code_ += UnionVerifySignature(enum_def) + ";"; - code_ += UnionVectorVerifySignature(enum_def) + ";"; - code_ += ""; - } - } - - void GenUnionPost(const EnumDef &enum_def) { - // Generate a verifier function for this union that can be called by the - // table verifier functions. It uses a switch case to select a specific - // verifier function to call, this should be safe even if the union type - // has been corrupted, since the verifiers will simply fail when called - // on the wrong type. - code_.SetValue("ENUM_NAME", enum_def.name); - - code_ += "inline " + UnionVerifySignature(enum_def) + " {"; - code_ += " switch (type) {"; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); - - if (ev.value) { - code_.SetValue("TYPE", GetUnionElement(ev, true, true)); - code_ += " case {{LABEL}}: {"; - auto getptr = - " auto ptr = reinterpret_cast<const {{TYPE}} *>(obj);"; - if (ev.union_type.base_type == BASE_TYPE_STRUCT) { - if (ev.union_type.struct_def->fixed) { - code_ += " return true;"; - } else { - code_ += getptr; - code_ += " return verifier.VerifyTable(ptr);"; - } - } else if (ev.union_type.base_type == BASE_TYPE_STRING) { - code_ += getptr; - code_ += " return verifier.Verify(ptr);"; - } else { - assert(false); - } - code_ += " }"; - } else { - code_ += " case {{LABEL}}: {"; - code_ += " return true;"; // "NONE" enum value. - code_ += " }"; - } - } - code_ += " default: return false;"; - code_ += " }"; - code_ += "}"; - code_ += ""; - - code_ += "inline " + UnionVectorVerifySignature(enum_def) + " {"; - code_ += " if (values->size() != types->size()) return false;"; - code_ += " for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {"; - code_ += " if (!Verify" + enum_def.name + "("; - code_ += " verifier, values->Get(i), types->GetEnum<" + enum_def.name + ">(i))) {"; - code_ += " return false;"; - code_ += " }"; - code_ += " }"; - code_ += " return true;"; - code_ += "}"; - code_ += ""; - - if (parser_.opts.generate_object_based_api) { - // Generate union Unpack() and Pack() functions. - code_ += "inline " + UnionUnPackSignature(enum_def, false) + " {"; - code_ += " switch (type) {"; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - if (!ev.value) { - continue; - } - - code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); - code_.SetValue("TYPE", GetUnionElement(ev, true, true)); - code_ += " case {{LABEL}}: {"; - code_ += " auto ptr = reinterpret_cast<const {{TYPE}} *>(obj);"; - if (ev.union_type.base_type == BASE_TYPE_STRUCT) { - if (ev.union_type.struct_def->fixed) { - code_ += " return new " + - WrapInNameSpace(*ev.union_type.struct_def) + "(*ptr);"; - } else { - code_ += " return ptr->UnPack(resolver);"; - } - } else if (ev.union_type.base_type == BASE_TYPE_STRING) { - code_ += " return new std::string(ptr->c_str(), ptr->size());"; - } else { - assert(false); - } - code_ += " }"; - } - code_ += " default: return nullptr;"; - code_ += " }"; - code_ += "}"; - code_ += ""; - - code_ += "inline " + UnionPackSignature(enum_def, false) + " {"; - code_ += " switch (type) {"; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - if (!ev.value) { - continue; - } - - code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); - code_.SetValue("TYPE", NativeName(GetUnionElement(ev, true, true, true), - ev.union_type.struct_def)); - code_.SetValue("NAME", GetUnionElement(ev, false, true)); - code_ += " case {{LABEL}}: {"; - code_ += " auto ptr = reinterpret_cast<const {{TYPE}} *>(value);"; - if (ev.union_type.base_type == BASE_TYPE_STRUCT) { - if (ev.union_type.struct_def->fixed) { - code_ += " return _fbb.CreateStruct(*ptr).Union();"; - } else { - code_ += - " return Create{{NAME}}(_fbb, ptr, _rehasher).Union();"; - } - } else if (ev.union_type.base_type == BASE_TYPE_STRING) { - code_ += " return _fbb.CreateString(*ptr).Union();"; - } else { - assert(false); - } - code_ += " }"; - } - code_ += " default: return 0;"; - code_ += " }"; - code_ += "}"; - code_ += ""; - - // Union copy constructor - code_ += "inline {{ENUM_NAME}}Union::{{ENUM_NAME}}Union(const " - "{{ENUM_NAME}}Union &u) FLATBUFFERS_NOEXCEPT : type(u.type), " - "value(nullptr) {"; - code_ += " switch (type) {"; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - if (!ev.value) { - continue; - } - code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); - code_.SetValue("TYPE", NativeName(GetUnionElement(ev, true, true, true), - ev.union_type.struct_def)); - code_ += " case {{LABEL}}: {"; - bool copyable = true; - if (ev.union_type.base_type == BASE_TYPE_STRUCT) { - // Don't generate code to copy if table is not copyable. - // TODO(wvo): make tables copyable instead. - for (auto fit = ev.union_type.struct_def->fields.vec.begin(); - fit != ev.union_type.struct_def->fields.vec.end(); ++fit) { - const auto &field = **fit; - if (!field.deprecated && field.value.type.struct_def) { - copyable = false; - break; - } - } - } - if (copyable) { - code_ += " value = new {{TYPE}}(*reinterpret_cast<{{TYPE}} *>" - "(u.value));"; - } else { - code_ += " assert(false); // {{TYPE}} not copyable."; - } - code_ += " break;"; - code_ += " }"; - } - code_ += " default:"; - code_ += " break;"; - code_ += " }"; - code_ += "}"; - code_ += ""; - - // Union Reset() function. - code_.SetValue("NONE", - GetEnumValUse(enum_def, *enum_def.vals.Lookup("NONE"))); - - code_ += "inline void {{ENUM_NAME}}Union::Reset() {"; - code_ += " switch (type) {"; - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - const auto &ev = **it; - if (!ev.value) { - continue; - } - code_.SetValue("LABEL", GetEnumValUse(enum_def, ev)); - code_.SetValue("TYPE", NativeName(GetUnionElement(ev, true, true, true), - ev.union_type.struct_def)); - code_ += " case {{LABEL}}: {"; - code_ += " auto ptr = reinterpret_cast<{{TYPE}} *>(value);"; - code_ += " delete ptr;"; - code_ += " break;"; - code_ += " }"; - } - code_ += " default: break;"; - code_ += " }"; - code_ += " value = nullptr;"; - code_ += " type = {{NONE}};"; - code_ += "}"; - code_ += ""; - } - } - - // Generates a value with optionally a cast applied if the field has a - // different underlying type from its interface type (currently only the - // case for enums. "from" specify the direction, true meaning from the - // underlying type to the interface type. - std::string GenUnderlyingCast(const FieldDef &field, bool from, - const std::string &val) { - if (from && field.value.type.base_type == BASE_TYPE_BOOL) { - return val + " != 0"; - } else if ((field.value.type.enum_def && - IsScalar(field.value.type.base_type)) || - field.value.type.base_type == BASE_TYPE_BOOL) { - return "static_cast<" + GenTypeBasic(field.value.type, from) + ">(" + - val + ")"; - } else { - return val; - } - } - - std::string GenFieldOffsetName(const FieldDef &field) { - std::string uname = field.name; - std::transform(uname.begin(), uname.end(), uname.begin(), ToUpper); - return "VT_" + uname; - } - - void GenFullyQualifiedNameGetter(const std::string &name) { - if (!parser_.opts.generate_name_strings) { - return; - } - - auto fullname = parser_.namespaces_.back()->GetFullyQualifiedName(name); - code_.SetValue("NAME", fullname); - code_.SetValue("CONSTEXPR", "FLATBUFFERS_CONSTEXPR"); - - code_ += " static {{CONSTEXPR}} const char *GetFullyQualifiedName() {"; - code_ += " return \"{{NAME}}\";"; - code_ += " }"; - } - - std::string GenDefaultConstant(const FieldDef &field) { - return field.value.type.base_type == BASE_TYPE_FLOAT - ? field.value.constant + "f" - : field.value.constant; - } - - std::string GetDefaultScalarValue(const FieldDef &field) { - if (field.value.type.enum_def && IsScalar(field.value.type.base_type)) { - auto ev = field.value.type.enum_def->ReverseLookup( - static_cast<int>(StringToInt(field.value.constant.c_str())), false); - if (ev) { - return WrapInNameSpace( - field.value.type.enum_def->defined_namespace, - GetEnumValUse(*field.value.type.enum_def, *ev)); - } else { - return GenUnderlyingCast(field, true, field.value.constant); - } - } else if (field.value.type.base_type == BASE_TYPE_BOOL) { - return field.value.constant == "0" ? "false" : "true"; - } else { - return GenDefaultConstant(field); - } - } - - void GenParam(const FieldDef &field, bool direct, const char *prefix) { - code_.SetValue("PRE", prefix); - code_.SetValue("PARAM_NAME", field.name); - if (direct && field.value.type.base_type == BASE_TYPE_STRING) { - code_.SetValue("PARAM_TYPE", "const char *"); - code_.SetValue("PARAM_VALUE", "nullptr"); - } else if (direct && field.value.type.base_type == BASE_TYPE_VECTOR) { - auto type = GenTypeWire(field.value.type.VectorType(), "", false); - code_.SetValue("PARAM_TYPE", "const std::vector<" + type + "> *"); - code_.SetValue("PARAM_VALUE", "nullptr"); - } else { - code_.SetValue("PARAM_TYPE", GenTypeWire(field.value.type, " ", true)); - code_.SetValue("PARAM_VALUE", GetDefaultScalarValue(field)); - } - code_ += "{{PRE}}{{PARAM_TYPE}}{{PARAM_NAME}} = {{PARAM_VALUE}}\\"; - } - - // Generate a member, including a default value for scalars and raw pointers. - void GenMember(const FieldDef &field) { - if (!field.deprecated && // Deprecated fields won't be accessible. - field.value.type.base_type != BASE_TYPE_UTYPE && - (field.value.type.base_type != BASE_TYPE_VECTOR || - field.value.type.element != BASE_TYPE_UTYPE)) { - auto type = GenTypeNative(field.value.type, false, field); - auto cpp_type = field.attributes.Lookup("cpp_type"); - auto full_type = (cpp_type ? cpp_type->constant + " *" : type + " "); - code_.SetValue("FIELD_TYPE", full_type); - code_.SetValue("FIELD_NAME", field.name); - code_ += " {{FIELD_TYPE}}{{FIELD_NAME}};"; - } - } - - // Generate the default constructor for this struct. Properly initialize all - // scalar members with default values. - void GenDefaultConstructor(const StructDef& struct_def) { - std::string initializer_list; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated && // Deprecated fields won't be accessible. - field.value.type.base_type != BASE_TYPE_UTYPE) { - auto cpp_type = field.attributes.Lookup("cpp_type"); - // Scalar types get parsed defaults, raw pointers get nullptrs. - if (IsScalar(field.value.type.base_type)) { - if (!initializer_list.empty()) { - initializer_list += ",\n "; - } - initializer_list += field.name; - initializer_list += "(" + GetDefaultScalarValue(field) + ")"; - } else if (field.value.type.base_type == BASE_TYPE_STRUCT) { - if (IsStruct(field.value.type)) { - auto native_default = field.attributes.Lookup("native_default"); - if (native_default) { - if (!initializer_list.empty()) { - initializer_list += ",\n "; - } - initializer_list += - field.name + "(" + native_default->constant + ")"; - } - } - } else if (cpp_type) { - if (!initializer_list.empty()) { - initializer_list += ",\n "; - } - initializer_list += field.name + "(0)"; - } - } - } - if (!initializer_list.empty()) { - initializer_list = "\n : " + initializer_list; - } - - code_.SetValue("NATIVE_NAME", NativeName(struct_def.name, &struct_def)); - code_.SetValue("INIT_LIST", initializer_list); - - code_ += " {{NATIVE_NAME}}(){{INIT_LIST}} {"; - code_ += " }"; - } - - void GenNativeTable(const StructDef &struct_def) { - const auto native_name = NativeName(struct_def.name, &struct_def); - code_.SetValue("STRUCT_NAME", struct_def.name); - code_.SetValue("NATIVE_NAME", native_name); - - // Generate a C++ object that can hold an unpacked version of this table. - code_ += "struct {{NATIVE_NAME}} : public flatbuffers::NativeTable {"; - code_ += " typedef {{STRUCT_NAME}} TableType;"; - GenFullyQualifiedNameGetter(native_name); - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - GenMember(**it); - } - GenDefaultConstructor(struct_def); - code_ += "};"; - code_ += ""; - } - - // Generate the code to call the appropriate Verify function(s) for a field. - void GenVerifyCall(const FieldDef &field, const char* prefix) { - code_.SetValue("PRE", prefix); - code_.SetValue("NAME", field.name); - code_.SetValue("REQUIRED", field.required ? "Required" : ""); - code_.SetValue("SIZE", GenTypeSize(field.value.type)); - code_.SetValue("OFFSET", GenFieldOffsetName(field)); - code_ += "{{PRE}}VerifyField{{REQUIRED}}<{{SIZE}}>(verifier, {{OFFSET}})\\"; - - switch (field.value.type.base_type) { - case BASE_TYPE_UNION: { - code_.SetValue("ENUM_NAME", field.value.type.enum_def->name); - code_.SetValue("SUFFIX", UnionTypeFieldSuffix()); - code_ += "{{PRE}}Verify{{ENUM_NAME}}(verifier, {{NAME}}(), " - "{{NAME}}{{SUFFIX}}())\\"; - break; - } - case BASE_TYPE_STRUCT: { - if (!field.value.type.struct_def->fixed) { - code_ += "{{PRE}}verifier.VerifyTable({{NAME}}())\\"; - } - break; - } - case BASE_TYPE_STRING: { - code_ += "{{PRE}}verifier.Verify({{NAME}}())\\"; - break; - } - case BASE_TYPE_VECTOR: { - code_ += "{{PRE}}verifier.Verify({{NAME}}())\\"; - - switch (field.value.type.element) { - case BASE_TYPE_STRING: { - code_ += "{{PRE}}verifier.VerifyVectorOfStrings({{NAME}}())\\"; - break; - } - case BASE_TYPE_STRUCT: { - if (!field.value.type.struct_def->fixed) { - code_ += "{{PRE}}verifier.VerifyVectorOfTables({{NAME}}())\\"; - } - break; - } - case BASE_TYPE_UNION: { - code_.SetValue("ENUM_NAME", field.value.type.enum_def->name); - code_ += "{{PRE}}Verify{{ENUM_NAME}}Vector(verifier, {{NAME}}(), {{NAME}}_type())\\"; - break; - } - default: - break; - } - break; - } - default: { - break; - } - } - } - - // Generate an accessor struct, builder structs & function for a table. - void GenTable(const StructDef &struct_def) { - if (parser_.opts.generate_object_based_api) { - GenNativeTable(struct_def); - } - - // Generate an accessor struct, with methods of the form: - // type name() const { return GetField<type>(offset, defaultval); } - GenComment(struct_def.doc_comment); - - code_.SetValue("STRUCT_NAME", struct_def.name); - code_ += "struct {{STRUCT_NAME}} FLATBUFFERS_FINAL_CLASS" - " : private flatbuffers::Table {"; - if (parser_.opts.generate_object_based_api) { - code_ += " typedef {{NATIVE_NAME}} NativeTableType;"; - } - - GenFullyQualifiedNameGetter(struct_def.name); - - // Generate field id constants. - if (struct_def.fields.vec.size() > 0) { - // We need to add a trailing comma to all elements except the last one as - // older versions of gcc complain about this. - code_.SetValue("SEP", ""); - code_ += " enum {"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.deprecated) { - // Deprecated fields won't be accessible. - continue; - } - - code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field)); - code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset)); - code_ += "{{SEP}} {{OFFSET_NAME}} = {{OFFSET_VALUE}}\\"; - code_.SetValue("SEP", ",\n"); - } - code_ += ""; - code_ += " };"; - } - - // Generate the accessors. - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.deprecated) { - // Deprecated fields won't be accessible. - continue; - } - - const bool is_struct = IsStruct(field.value.type); - const bool is_scalar = IsScalar(field.value.type.base_type); - code_.SetValue("FIELD_NAME", field.name); - - // Call a different accessor for pointers, that indirects. - std::string accessor = ""; - if (is_scalar) { - accessor = "GetField<"; - } else if (is_struct) { - accessor = "GetStruct<"; - } else { - accessor = "GetPointer<"; - } - auto offset_str = GenFieldOffsetName(field); - auto offset_type = - GenTypeGet(field.value.type, "", "const ", " *", false); - - auto call = accessor + offset_type + ">(" + offset_str; - // Default value as second arg for non-pointer types. - if (is_scalar) { - call += ", " + GenDefaultConstant(field); - } - call += ")"; - - GenComment(field.doc_comment, " "); - code_.SetValue("FIELD_TYPE", - GenTypeGet(field.value.type, " ", "const ", " *", true)); - code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, call)); - - code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {"; - code_ += " return {{FIELD_VALUE}};"; - code_ += " }"; - - if (field.value.type.base_type == BASE_TYPE_UNION) { - auto u = field.value.type.enum_def; - - code_ += " template<typename T> " - "const T *{{FIELD_NAME}}_as() const;"; - - for (auto u_it = u->vals.vec.begin(); - u_it != u->vals.vec.end(); ++u_it) { - auto &ev = **u_it; - if (ev.union_type.base_type == BASE_TYPE_NONE) { - continue; - } - auto full_struct_name = GetUnionElement(ev, true, true); - - // @TODO: Mby make this decisions more universal? How? - code_.SetValue("U_GET_TYPE", field.name + UnionTypeFieldSuffix()); - code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace( - u->defined_namespace, GetEnumValUse(*u, ev))); - code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *"); - code_.SetValue("U_FIELD_NAME", - field.name + "_as_" + ev.name); - - // `const Type *union_name_asType() const` accessor. - code_ += " {{U_FIELD_TYPE}}{{U_FIELD_NAME}}() const {"; - code_ += " return {{U_GET_TYPE}}() == {{U_ELEMENT_TYPE}} ? " - "static_cast<{{U_FIELD_TYPE}}>({{FIELD_NAME}}()) " - ": nullptr;"; - code_ += " }"; - } - } - - if (parser_.opts.mutable_buffer) { - if (is_scalar) { - const auto type = GenTypeWire(field.value.type, "", false); - code_.SetValue("SET_FN", "SetField<" + type + ">"); - code_.SetValue("OFFSET_NAME", offset_str); - code_.SetValue("FIELD_TYPE", GenTypeBasic(field.value.type, true)); - code_.SetValue("FIELD_VALUE", - GenUnderlyingCast(field, false, "_" + field.name)); - code_.SetValue("DEFAULT_VALUE", GenDefaultConstant(field)); - - code_ += " bool mutate_{{FIELD_NAME}}({{FIELD_TYPE}} " - "_{{FIELD_NAME}}) {"; - code_ += " return {{SET_FN}}({{OFFSET_NAME}}, {{FIELD_VALUE}}, {{DEFAULT_VALUE}});"; - code_ += " }"; - } else { - auto type = GenTypeGet(field.value.type, " ", "", " *", true); - auto underlying = accessor + type + ">(" + offset_str + ")"; - code_.SetValue("FIELD_TYPE", type); - code_.SetValue("FIELD_VALUE", - GenUnderlyingCast(field, true, underlying)); - - code_ += " {{FIELD_TYPE}}mutable_{{FIELD_NAME}}() {"; - code_ += " return {{FIELD_VALUE}};"; - code_ += " }"; - } - } - - auto nested = field.attributes.Lookup("nested_flatbuffer"); - if (nested) { - std::string qualified_name = - parser_.namespaces_.back()->GetFullyQualifiedName( - nested->constant); - auto nested_root = parser_.structs_.Lookup(qualified_name); - assert(nested_root); // Guaranteed to exist by parser. - (void)nested_root; - code_.SetValue("CPP_NAME", TranslateNameSpace(qualified_name)); - - code_ += " const {{CPP_NAME}} *{{FIELD_NAME}}_nested_root() const {"; - code_ += " const uint8_t* data = {{FIELD_NAME}}()->Data();"; - code_ += " return flatbuffers::GetRoot<{{CPP_NAME}}>(data);"; - code_ += " }"; - } - - // Generate a comparison function for this field if it is a key. - if (field.key) { - const bool is_string = (field.value.type.base_type == BASE_TYPE_STRING); - - code_ += " bool KeyCompareLessThan(const {{STRUCT_NAME}} *o) const {"; - if (is_string) { - code_ += " return *{{FIELD_NAME}}() < *o->{{FIELD_NAME}}();"; - } else { - code_ += " return {{FIELD_NAME}}() < o->{{FIELD_NAME}}();"; - } - code_ += " }"; - - if (is_string) { - code_ += " int KeyCompareWithValue(const char *val) const {"; - code_ += " return strcmp({{FIELD_NAME}}()->c_str(), val);"; - code_ += " }"; - } else { - auto type = GenTypeBasic(field.value.type, false); - if (parser_.opts.scoped_enums && field.value.type.enum_def && - IsScalar(field.value.type.base_type)) { - type = GenTypeGet(field.value.type, " ", "const ", " *", true); - } - - code_.SetValue("KEY_TYPE", type); - code_ += " int KeyCompareWithValue({{KEY_TYPE}} val) const {"; - code_ += " const auto key = {{FIELD_NAME}}();"; - code_ += " if (key < val) {"; - code_ += " return -1;"; - code_ += " } else if (key > val) {"; - code_ += " return 1;"; - code_ += " } else {"; - code_ += " return 0;"; - code_ += " }"; - code_ += " }"; - } - } - } - - // Generate a verifier function that can check a buffer from an untrusted - // source will never cause reads outside the buffer. - code_ += " bool Verify(flatbuffers::Verifier &verifier) const {"; - code_ += " return VerifyTableStart(verifier)\\"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.deprecated) { - continue; - } - GenVerifyCall(field, " &&\n "); - } - - code_ += " &&\n verifier.EndTable();"; - code_ += " }"; - - if (parser_.opts.generate_object_based_api) { - // Generate the UnPack() pre declaration. - code_ += " " + TableUnPackSignature(struct_def, true) + ";"; - code_ += " " + TableUnPackToSignature(struct_def, true) + ";"; - code_ += " " + TablePackSignature(struct_def, true) + ";"; - } - - code_ += "};"; // End of table. - code_ += ""; - - // Explicit specializations for union accessors - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.deprecated || - field.value.type.base_type != BASE_TYPE_UNION) { - continue; - } - - auto u = field.value.type.enum_def; - if (u->uses_type_aliases) continue; - - code_.SetValue("FIELD_NAME", field.name); - - for (auto u_it = u->vals.vec.begin(); - u_it != u->vals.vec.end(); ++u_it) { - auto &ev = **u_it; - if (ev.union_type.base_type == BASE_TYPE_NONE) { - continue; - } - - auto full_struct_name = GetUnionElement(ev, true, true); - - code_.SetValue("U_ELEMENT_TYPE", WrapInNameSpace( - u->defined_namespace, GetEnumValUse(*u, ev))); - code_.SetValue("U_FIELD_TYPE", "const " + full_struct_name + " *"); - code_.SetValue("U_ELEMENT_NAME", full_struct_name); - code_.SetValue("U_FIELD_NAME", - field.name + "_as_" + ev.name); - - // `template<> const T *union_name_as<T>() const` accessor. - code_ += "template<> " - "inline {{U_FIELD_TYPE}}{{STRUCT_NAME}}::{{FIELD_NAME}}_as" - "<{{U_ELEMENT_NAME}}>() const {"; - code_ += " return {{U_FIELD_NAME}}();"; - code_ += "}"; - code_ += ""; - } - } - - GenBuilders(struct_def); - - if (parser_.opts.generate_object_based_api) { - // Generate a pre-declaration for a CreateX method that works with an - // unpacked C++ object. - code_ += TableCreateSignature(struct_def, true) + ";"; - code_ += ""; - } - } - - void GenBuilders(const StructDef &struct_def) { - code_.SetValue("STRUCT_NAME", struct_def.name); - - // Generate a builder struct: - code_ += "struct {{STRUCT_NAME}}Builder {"; - code_ += " flatbuffers::FlatBufferBuilder &fbb_;"; - code_ += " flatbuffers::uoffset_t start_;"; - - bool has_string_or_vector_fields = false; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated) { - const bool is_scalar = IsScalar(field.value.type.base_type); - const bool is_string = field.value.type.base_type == BASE_TYPE_STRING; - const bool is_vector = field.value.type.base_type == BASE_TYPE_VECTOR; - if (is_string || is_vector) { - has_string_or_vector_fields = true; - } - - std::string offset = GenFieldOffsetName(field); - std::string name = GenUnderlyingCast(field, false, field.name); - std::string value = is_scalar ? GenDefaultConstant(field) : ""; - - // Generate accessor functions of the form: - // void add_name(type name) { - // fbb_.AddElement<type>(offset, name, default); - // } - code_.SetValue("FIELD_NAME", field.name); - code_.SetValue("FIELD_TYPE", GenTypeWire(field.value.type, " ", true)); - code_.SetValue("ADD_OFFSET", struct_def.name + "::" + offset); - code_.SetValue("ADD_NAME", name); - code_.SetValue("ADD_VALUE", value); - if (is_scalar) { - const auto type = GenTypeWire(field.value.type, "", false); - code_.SetValue("ADD_FN", "AddElement<" + type + ">"); - } else if (IsStruct(field.value.type)) { - code_.SetValue("ADD_FN", "AddStruct"); - } else { - code_.SetValue("ADD_FN", "AddOffset"); - } - - code_ += " void add_{{FIELD_NAME}}({{FIELD_TYPE}}{{FIELD_NAME}}) {"; - code_ += " fbb_.{{ADD_FN}}(\\"; - if (is_scalar) { - code_ += "{{ADD_OFFSET}}, {{ADD_NAME}}, {{ADD_VALUE}});"; - } else { - code_ += "{{ADD_OFFSET}}, {{ADD_NAME}});"; - } - code_ += " }"; - } - } - - // Builder constructor - code_ += " {{STRUCT_NAME}}Builder(flatbuffers::FlatBufferBuilder &_fbb)"; - code_ += " : fbb_(_fbb) {"; - code_ += " start_ = fbb_.StartTable();"; - code_ += " }"; - - // Assignment operator; - code_ += " {{STRUCT_NAME}}Builder &operator=" - "(const {{STRUCT_NAME}}Builder &);"; - - // Finish() function. - auto num_fields = NumToString(struct_def.fields.vec.size()); - code_ += " flatbuffers::Offset<{{STRUCT_NAME}}> Finish() {"; - code_ += " const auto end = fbb_.EndTable(start_, " + num_fields + ");"; - code_ += " auto o = flatbuffers::Offset<{{STRUCT_NAME}}>(end);"; - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated && field.required) { - code_.SetValue("FIELD_NAME", field.name); - code_.SetValue("OFFSET_NAME", GenFieldOffsetName(field)); - code_ += " fbb_.Required(o, {{STRUCT_NAME}}::{{OFFSET_NAME}});"; - } - } - code_ += " return o;"; - code_ += " }"; - code_ += "};"; - code_ += ""; - - // Generate a convenient CreateX function that uses the above builder - // to create a table in one go. - code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> " - "Create{{STRUCT_NAME}}("; - code_ += " flatbuffers::FlatBufferBuilder &_fbb\\"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated) { - GenParam(field, false, ",\n "); - } - } - code_ += ") {"; - - code_ += " {{STRUCT_NAME}}Builder builder_(_fbb);"; - for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; - size; size /= 2) { - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); ++it) { - const auto &field = **it; - if (!field.deprecated && (!struct_def.sortbysize || - size == SizeOf(field.value.type.base_type))) { - code_.SetValue("FIELD_NAME", field.name); - code_ += " builder_.add_{{FIELD_NAME}}({{FIELD_NAME}});"; - } - } - } - code_ += " return builder_.Finish();"; - code_ += "}"; - code_ += ""; - - // Generate a CreateXDirect function with vector types as parameters - if (has_string_or_vector_fields) { - code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> " - "Create{{STRUCT_NAME}}Direct("; - code_ += " flatbuffers::FlatBufferBuilder &_fbb\\"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated) { - GenParam(field, true, ",\n "); - } - } - - // Need to call "Create" with the struct namespace. - const auto qualified_create_name = struct_def.defined_namespace->GetFullyQualifiedName("Create"); - code_.SetValue("CREATE_NAME", TranslateNameSpace(qualified_create_name)); - - code_ += ") {"; - code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}("; - code_ += " _fbb\\"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (!field.deprecated) { - code_.SetValue("FIELD_NAME", field.name); - - if (field.value.type.base_type == BASE_TYPE_STRING) { - code_ += ",\n {{FIELD_NAME}} ? " - "_fbb.CreateString({{FIELD_NAME}}) : 0\\"; - } else if (field.value.type.base_type == BASE_TYPE_VECTOR) { - auto type = GenTypeWire(field.value.type.VectorType(), "", false); - code_ += ",\n {{FIELD_NAME}} ? " - "_fbb.CreateVector<" + type + ">(*{{FIELD_NAME}}) : 0\\"; - } else { - code_ += ",\n {{FIELD_NAME}}\\"; - } - } - } - code_ += ");"; - code_ += "}"; - code_ += ""; - } - } - - std::string GenUnionUnpackVal(const FieldDef &afield, - const char *vec_elem_access, - const char *vec_type_access) { - return afield.value.type.enum_def->name + "Union::UnPack(" + "_e" + - vec_elem_access + ", " + afield.name + UnionTypeFieldSuffix() + - "()" + vec_type_access + ", _resolver)"; - } - - std::string GenUnpackVal(const Type &type, const std::string &val, - bool invector, const FieldDef &afield) { - switch (type.base_type) { - case BASE_TYPE_STRING: { - return val + "->str()"; - } - case BASE_TYPE_STRUCT: { - const auto name = WrapInNameSpace(*type.struct_def); - if (IsStruct(type)) { - auto native_type = type.struct_def->attributes.Lookup("native_type"); - if (native_type) { - return "flatbuffers::UnPack(*" + val + ")"; - } else if (invector || afield.native_inline) { - return "*" + val; - } else { - const auto ptype = GenTypeNativePtr(name, &afield, true); - return ptype + "(new " + name + "(*" + val + "))"; - } - } else { - const auto ptype = GenTypeNativePtr(NativeName(name, type.struct_def), - &afield, true); - return ptype + "(" + val + "->UnPack(_resolver))"; - } - } - case BASE_TYPE_UNION: { - return GenUnionUnpackVal(afield, - invector ? "->Get(_i)" : "", - invector ? ("->GetEnum<" + - type.enum_def->name + - ">(_i)").c_str() : ""); - } - default: { - return val; - break; - } - } - }; - - std::string GenUnpackFieldStatement(const FieldDef &field, - const FieldDef *union_field) { - std::string code; - switch (field.value.type.base_type) { - case BASE_TYPE_VECTOR: { - std::string indexing; - if (field.value.type.enum_def) { - indexing += "(" + field.value.type.enum_def->name + ")"; - } - indexing += "_e->Get(_i)"; - if (field.value.type.element == BASE_TYPE_BOOL) { - indexing += " != 0"; - } - - // Generate code that pushes data from _e to _o in the form: - // for (uoffset_t i = 0; i < _e->size(); ++i) { - // _o->field.push_back(_e->Get(_i)); - // } - auto name = field.name; - if (field.value.type.element == BASE_TYPE_UTYPE) { - name = StripUnionType(field.name); - } - auto access = field.value.type.element == BASE_TYPE_UTYPE - ? ".type" - : (field.value.type.element == BASE_TYPE_UNION - ? ".value" - : ""); - code += "{ _o->" + name + ".resize(_e->size()); "; - code += "for (flatbuffers::uoffset_t _i = 0;"; - code += " _i < _e->size(); _i++) { "; - code += "_o->" + name + "[_i]" + access + " = "; - code += GenUnpackVal(field.value.type.VectorType(), - indexing, true, field); - code += "; } }"; - break; - } - case BASE_TYPE_UTYPE: { - assert(union_field->value.type.base_type == BASE_TYPE_UNION); - // Generate code that sets the union type, of the form: - // _o->field.type = _e; - code += "_o->" + union_field->name + ".type = _e;"; - break; - } - case BASE_TYPE_UNION: { - // Generate code that sets the union value, of the form: - // _o->field.value = Union::Unpack(_e, field_type(), resolver); - code += "_o->" + field.name + ".value = "; - code += GenUnionUnpackVal(field, "", ""); - code += ";"; - break; - } - default: { - auto cpp_type = field.attributes.Lookup("cpp_type"); - if (cpp_type) { - // Generate code that resolves the cpp pointer type, of the form: - // if (resolver) - // (*resolver)(&_o->field, (hash_value_t)(_e)); - // else - // _o->field = nullptr; - code += "if (_resolver) "; - code += "(*_resolver)"; - code += "(reinterpret_cast<void **>(&_o->" + field.name + "), "; - code += "static_cast<flatbuffers::hash_value_t>(_e));"; - code += " else "; - code += "_o->" + field.name + " = nullptr;"; - } else { - // Generate code for assigning the value, of the form: - // _o->field = value; - code += "_o->" + field.name + " = "; - code += GenUnpackVal(field.value.type, "_e", false, field) + ";"; - } - break; - } - } - return code; - } - - std::string GenCreateParam(const FieldDef &field) { - std::string value = "_o->"; - if (field.value.type.base_type == BASE_TYPE_UTYPE) { - value += StripUnionType(field.name); - value += ".type"; - } else { - value += field.name; - } - if (field.attributes.Lookup("cpp_type")) { - auto type = GenTypeBasic(field.value.type, false); - value = "_rehasher ? " - "static_cast<" + type + ">((*_rehasher)(" + value + ")) : 0"; - } - - std::string code; - switch (field.value.type.base_type) { - // String fields are of the form: - // _fbb.CreateString(_o->field) - case BASE_TYPE_STRING: { - code += "_fbb.CreateString(" + value + ")"; - - // For optional fields, check to see if there actually is any data - // in _o->field before attempting to access it. - if (!field.required) { - code = value + ".size() ? " + code + " : 0"; - } - break; - } - // Vector fields come in several flavours, of the forms: - // _fbb.CreateVector(_o->field); - // _fbb.CreateVector((const utype*)_o->field.data(), _o->field.size()); - // _fbb.CreateVectorOfStrings(_o->field) - // _fbb.CreateVectorOfStructs(_o->field) - // _fbb.CreateVector<Offset<T>>(_o->field.size() [&](size_t i) { - // return CreateT(_fbb, _o->Get(i), rehasher); - // }); - case BASE_TYPE_VECTOR: { - auto vector_type = field.value.type.VectorType(); - switch (vector_type.base_type) { - case BASE_TYPE_STRING: { - code += "_fbb.CreateVectorOfStrings(" + value + ")"; - break; - } - case BASE_TYPE_STRUCT: { - if (IsStruct(vector_type)) { - auto native_type = - field.value.type.struct_def->attributes.Lookup("native_type"); - if (native_type) { - code += "_fbb.CreateVectorOfNativeStructs<"; - code += WrapInNameSpace(*vector_type.struct_def) + ">"; - } else { - code += "_fbb.CreateVectorOfStructs"; - } - code += "(" + value + ")"; - } else { - code += "_fbb.CreateVector<flatbuffers::Offset<"; - code += WrapInNameSpace(*vector_type.struct_def) + ">>"; - code += "(" + value + ".size(), [&](size_t i) {"; - code += " return Create" + vector_type.struct_def->name; - code += "(_fbb, " + value + "[i]" + GenPtrGet(field) + ", "; - code += "_rehasher); })"; - } - break; - } - case BASE_TYPE_BOOL: { - code += "_fbb.CreateVector(" + value + ")"; - break; - } - case BASE_TYPE_UNION: { - code += "_fbb.CreateVector<flatbuffers::Offset<void>>(" + value + - ".size(), [&](size_t i) { return " + value + - "[i].Pack(_fbb, _rehasher); })"; - break; - } - case BASE_TYPE_UTYPE: { - value = StripUnionType(value); - code += "_fbb.CreateVector<uint8_t>(" + value + - ".size(), [&](size_t i) { return static_cast<uint8_t>(" + value + - "[i].type); })"; - break; - } - default: { - if (field.value.type.enum_def) { - // For enumerations, we need to get access to the array data for - // the underlying storage type (eg. uint8_t). - const auto basetype = GenTypeBasic( - field.value.type.enum_def->underlying_type, false); - code += "_fbb.CreateVector((const " + basetype + "*)" + value + - ".data(), " + value + ".size())"; - } else { - code += "_fbb.CreateVector(" + value + ")"; - } - break; - } - } - - // For optional fields, check to see if there actually is any data - // in _o->field before attempting to access it. - if (!field.required) { - code = value + ".size() ? " + code + " : 0"; - } - break; - } - case BASE_TYPE_UNION: { - // _o->field.Pack(_fbb); - code += value + ".Pack(_fbb)"; - break; - } - case BASE_TYPE_STRUCT: { - if (IsStruct(field.value.type)) { - auto native_type = - field.value.type.struct_def->attributes.Lookup("native_type"); - if (native_type) { - code += "flatbuffers::Pack(" + value + ")"; - } else if (field.native_inline) { - code += "&" + value; - } else { - code += value + " ? " + value + GenPtrGet(field) + " : 0"; - } - } else { - // _o->field ? CreateT(_fbb, _o->field.get(), _rehasher); - const auto type = field.value.type.struct_def->name; - code += value + " ? Create" + type; - code += "(_fbb, " + value + GenPtrGet(field) + ", _rehasher)"; - code += " : 0"; - } - break; - } - default: { - code += value; - break; - } - } - return code; - } - - // Generate code for tables that needs to come after the regular definition. - void GenTablePost(const StructDef &struct_def) { - code_.SetValue("STRUCT_NAME", struct_def.name); - code_.SetValue("NATIVE_NAME", NativeName(struct_def.name, &struct_def)); - - if (parser_.opts.generate_object_based_api) { - // Generate the X::UnPack() method. - code_ += "inline " + TableUnPackSignature(struct_def, false) + " {"; - code_ += " auto _o = new {{NATIVE_NAME}}();"; - code_ += " UnPackTo(_o, _resolver);"; - code_ += " return _o;"; - code_ += "}"; - code_ += ""; - - code_ += "inline " + TableUnPackToSignature(struct_def, false) + " {"; - code_ += " (void)_o;"; - code_ += " (void)_resolver;"; - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.deprecated) { - continue; - } - - // Assign a value from |this| to |_o|. Values from |this| are stored - // in a variable |_e| by calling this->field_type(). The value is then - // assigned to |_o| using the GenUnpackFieldStatement. - const bool is_union = field.value.type.base_type == BASE_TYPE_UTYPE; - const auto statement = - GenUnpackFieldStatement(field, is_union ? *(it + 1) : nullptr); - - code_.SetValue("FIELD_NAME", field.name); - auto prefix = " { auto _e = {{FIELD_NAME}}(); "; - auto check = IsScalar(field.value.type.base_type) ? "" : "if (_e) "; - auto postfix = " };"; - code_ += std::string(prefix) + check + statement + postfix; - } - code_ += "}"; - code_ += ""; - - // Generate the X::Pack member function that simply calls the global - // CreateX function. - code_ += "inline " + TablePackSignature(struct_def, false) + " {"; - code_ += " return Create{{STRUCT_NAME}}(_fbb, _o, _rehasher);"; - code_ += "}"; - code_ += ""; - - // Generate a CreateX method that works with an unpacked C++ object. - code_ += "inline " + TableCreateSignature(struct_def, false) + " {"; - code_ += " (void)_rehasher;"; - code_ += " (void)_o;"; - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) { - continue; - } - code_ += " auto _" + field.name + " = " + GenCreateParam(field) + ";"; - } - // Need to call "Create" with the struct namespace. - const auto qualified_create_name = struct_def.defined_namespace->GetFullyQualifiedName("Create"); - code_.SetValue("CREATE_NAME", TranslateNameSpace(qualified_create_name)); - - code_ += " return {{CREATE_NAME}}{{STRUCT_NAME}}("; - code_ += " _fbb\\"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) { - continue; - } - - bool pass_by_address = false; - if (field.value.type.base_type == BASE_TYPE_STRUCT) { - if (IsStruct(field.value.type)) { - auto native_type = - field.value.type.struct_def->attributes.Lookup("native_type"); - if (native_type) { - pass_by_address = true; - } - } - } - - // Call the CreateX function using values from |_o|. - if (pass_by_address) { - code_ += ",\n &_" + field.name + "\\"; - } else { - code_ += ",\n _" + field.name + "\\"; - } - } - code_ += ");"; - code_ += "}"; - code_ += ""; - } - } - - static void GenPadding( - const FieldDef &field, std::string *code_ptr, int *id, - const std::function<void(int bits, std::string *code_ptr, int *id)> &f) { - if (field.padding) { - for (int i = 0; i < 4; i++) { - if (static_cast<int>(field.padding) & (1 << i)) { - f((1 << i) * 8, code_ptr, id); - } - } - assert(!(field.padding & ~0xF)); - } - } - - static void PaddingDefinition(int bits, std::string *code_ptr, int *id) { - *code_ptr += " int" + NumToString(bits) + "_t padding" + - NumToString((*id)++) + "__;"; - } - - static void PaddingInitializer(int bits, std::string *code_ptr, int *id) { - (void)bits; - *code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)"; - } - - static void PaddingNoop(int bits, std::string *code_ptr, int *id) { - (void)bits; - *code_ptr += " (void)padding" + NumToString((*id)++) + "__;"; - } - - // Generate an accessor struct with constructor for a flatbuffers struct. - void GenStruct(const StructDef &struct_def) { - // Generate an accessor struct, with private variables of the form: - // type name_; - // Generates manual padding and alignment. - // Variables are private because they contain little endian data on all - // platforms. - GenComment(struct_def.doc_comment); - code_.SetValue("ALIGN", NumToString(struct_def.minalign)); - code_.SetValue("STRUCT_NAME", struct_def.name); - - code_ += "MANUALLY_ALIGNED_STRUCT({{ALIGN}}) " - "{{STRUCT_NAME}} FLATBUFFERS_FINAL_CLASS {"; - code_ += " private:"; - - int padding_id = 0; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - code_.SetValue("FIELD_TYPE", - GenTypeGet(field.value.type, " ", "", " ", false)); - code_.SetValue("FIELD_NAME", field.name); - code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}_;"; - - if (field.padding) { - std::string padding; - GenPadding(field, &padding, &padding_id, PaddingDefinition); - code_ += padding; - } - } - - // Generate GetFullyQualifiedName - code_ += ""; - code_ += " public:"; - GenFullyQualifiedNameGetter(struct_def.name); - - // Generate a default constructor. - code_ += " {{STRUCT_NAME}}() {"; - code_ += " memset(this, 0, sizeof({{STRUCT_NAME}}));"; - code_ += " }"; - - // Generate a copy constructor. - code_ += " {{STRUCT_NAME}}(const {{STRUCT_NAME}} &_o) {"; - code_ += " memcpy(this, &_o, sizeof({{STRUCT_NAME}}));"; - code_ += " }"; - - // Generate a constructor that takes all fields as arguments. - std::string arg_list; - std::string init_list; - padding_id = 0; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - const auto member_name = field.name + "_"; - const auto arg_name = "_" + field.name; - const auto arg_type = - GenTypeGet(field.value.type, " ", "const ", " &", true); - - if (it != struct_def.fields.vec.begin()) { - arg_list += ", "; - init_list += ",\n "; - } - arg_list += arg_type; - arg_list += arg_name; - init_list += member_name; - if (IsScalar(field.value.type.base_type)) { - auto type = GenUnderlyingCast(field, false, arg_name); - init_list += "(flatbuffers::EndianScalar(" + type + "))"; - } else { - init_list += "(" + arg_name + ")"; - } - if (field.padding) { - GenPadding(field, &init_list, &padding_id, PaddingInitializer); - } - } - - code_.SetValue("ARG_LIST", arg_list); - code_.SetValue("INIT_LIST", init_list); - code_ += " {{STRUCT_NAME}}({{ARG_LIST}})"; - code_ += " : {{INIT_LIST}} {"; - padding_id = 0; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - if (field.padding) { - std::string padding; - GenPadding(field, &padding, &padding_id, PaddingNoop); - code_ += padding; - } - } - code_ += " }"; - - // Generate accessor methods of the form: - // type name() const { return flatbuffers::EndianScalar(name_); } - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - const auto &field = **it; - - auto field_type = GenTypeGet(field.value.type, " ", "const ", " &", true); - auto is_scalar = IsScalar(field.value.type.base_type); - auto member = field.name + "_"; - auto value = is_scalar ? "flatbuffers::EndianScalar(" + member + ")" - : member; - - code_.SetValue("FIELD_NAME", field.name); - code_.SetValue("FIELD_TYPE", field_type); - code_.SetValue("FIELD_VALUE", GenUnderlyingCast(field, true, value)); - - GenComment(field.doc_comment, " "); - code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {"; - code_ += " return {{FIELD_VALUE}};"; - code_ += " }"; - - if (parser_.opts.mutable_buffer) { - auto mut_field_type = GenTypeGet(field.value.type, " ", "", " &", true); - code_.SetValue("FIELD_TYPE", mut_field_type); - if (is_scalar) { - code_.SetValue("ARG", GenTypeBasic(field.value.type, true)); - code_.SetValue("FIELD_VALUE", - GenUnderlyingCast(field, false, "_" + field.name)); - - code_ += " void mutate_{{FIELD_NAME}}({{ARG}} _{{FIELD_NAME}}) {"; - code_ += " flatbuffers::WriteScalar(&{{FIELD_NAME}}_, " - "{{FIELD_VALUE}});"; - code_ += " }"; - } else { - code_ += " {{FIELD_TYPE}}mutable_{{FIELD_NAME}}() {"; - code_ += " return {{FIELD_NAME}}_;"; - code_ += " }"; - } - } - - // Generate a comparison function for this field if it is a key. - if (field.key) { - code_ += " bool KeyCompareLessThan(const {{STRUCT_NAME}} *o) const {"; - code_ += " return {{FIELD_NAME}}() < o->{{FIELD_NAME}}();"; - code_ += " }"; - auto type = GenTypeBasic(field.value.type, false); - if (parser_.opts.scoped_enums && field.value.type.enum_def && - IsScalar(field.value.type.base_type)) { - type = GenTypeGet(field.value.type, " ", "const ", " *", true); - } - - code_.SetValue("KEY_TYPE", type); - code_ += " int KeyCompareWithValue({{KEY_TYPE}} val) const {"; - code_ += " const auto key = {{FIELD_NAME}}();"; - code_ += " return static_cast<int>(key > val) - static_cast<int>(key < val);"; - code_ += " }"; - } - } - code_ += "};"; - - code_.SetValue("STRUCT_BYTE_SIZE", NumToString(struct_def.bytesize)); - code_ += "STRUCT_END({{STRUCT_NAME}}, {{STRUCT_BYTE_SIZE}});"; - code_ += ""; - } - - // Set up the correct namespace. Only open a namespace if the existing one is - // different (closing/opening only what is necessary). - // - // The file must start and end with an empty (or null) namespace so that - // namespaces are properly opened and closed. - void SetNameSpace(const Namespace *ns) { - if (cur_name_space_ == ns) { - return; - } - - // Compute the size of the longest common namespace prefix. - // If cur_name_space is A::B::C::D and ns is A::B::E::F::G, - // the common prefix is A::B:: and we have old_size = 4, new_size = 5 - // and common_prefix_size = 2 - size_t old_size = cur_name_space_ ? cur_name_space_->components.size() : 0; - size_t new_size = ns ? ns->components.size() : 0; - - size_t common_prefix_size = 0; - while (common_prefix_size < old_size && common_prefix_size < new_size && - ns->components[common_prefix_size] == - cur_name_space_->components[common_prefix_size]) { - common_prefix_size++; - } - - // Close cur_name_space in reverse order to reach the common prefix. - // In the previous example, D then C are closed. - for (size_t j = old_size; j > common_prefix_size; --j) { - code_ += "} // namespace " + cur_name_space_->components[j - 1]; - } - if (old_size != common_prefix_size) { - code_ += ""; - } - - // open namespace parts to reach the ns namespace - // in the previous example, E, then F, then G are opened - for (auto j = common_prefix_size; j != new_size; ++j) { - code_ += "namespace " + ns->components[j] + " {"; - } - if (new_size != common_prefix_size) { - code_ += ""; - } - - cur_name_space_ = ns; - } -}; - -} // namespace cpp - -bool GenerateCPP(const Parser &parser, const std::string &path, - const std::string &file_name) { - cpp::CppGenerator generator(parser, path, file_name); - return generator.generate(); -} - -std::string CPPMakeRule(const Parser &parser, const std::string &path, - const std::string &file_name) { - const auto filebase = - flatbuffers::StripPath(flatbuffers::StripExtension(file_name)); - const auto included_files = parser.GetIncludedFilesRecursive(file_name); - std::string make_rule = GeneratedFileName(path, filebase) + ": "; - for (auto it = included_files.begin(); it != included_files.end(); ++it) { - make_rule += " " + *it; - } - return make_rule; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_fbs.cpp b/third_party/flatbuffers/src/idl_gen_fbs.cpp deleted file mode 100644 index 7752369..0000000 --- a/third_party/flatbuffers/src/idl_gen_fbs.cpp +++ /dev/null
@@ -1,131 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -namespace flatbuffers { - -static std::string GenType(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRUCT: - return type.struct_def->defined_namespace->GetFullyQualifiedName( - type.struct_def->name); - case BASE_TYPE_UNION: - return type.enum_def->defined_namespace->GetFullyQualifiedName( - type.enum_def->name); - case BASE_TYPE_VECTOR: - return "[" + GenType(type.VectorType()) + "]"; - default: - return kTypeNames[type.base_type]; - } -} - -static void GenNameSpace(const Namespace &name_space, std::string *_schema, - const Namespace **last_namespace) { - if (*last_namespace == &name_space) return; - *last_namespace = &name_space; - auto &schema = *_schema; - schema += "namespace "; - for (auto it = name_space.components.begin(); - it != name_space.components.end(); ++it) { - if (it != name_space.components.begin()) schema += "."; - schema += *it; - } - schema += ";\n\n"; -} - -// Generate a flatbuffer schema from the Parser's internal representation. -std::string GenerateFBS(const Parser &parser, const std::string &file_name) { - // Proto namespaces may clash with table names, so we have to prefix all: - if (!parser.opts.escape_proto_identifiers) { - for (auto it = parser.namespaces_.begin(); it != parser.namespaces_.end(); - ++it) { - for (auto comp = (*it)->components.begin(); comp != (*it)->components.end(); - ++comp) { - (*comp) = "_" + (*comp); - } - } - } - - std::string schema; - schema += "// Generated from " + file_name + ".proto\n\n"; - if (parser.opts.include_dependence_headers) { - #ifdef FBS_GEN_INCLUDES // TODO: currently all in one file. - int num_includes = 0; - for (auto it = parser.included_files_.begin(); - it != parser.included_files_.end(); ++it) { - auto basename = flatbuffers::StripPath( - flatbuffers::StripExtension(it->first)); - if (basename != file_name) { - schema += "include \"" + basename + ".fbs\";\n"; - num_includes++; - } - } - if (num_includes) schema += "\n"; - #endif - } - // Generate code for all the enum declarations. - const Namespace *last_namespace = nullptr; - for (auto enum_def_it = parser.enums_.vec.begin(); - enum_def_it != parser.enums_.vec.end(); ++enum_def_it) { - EnumDef &enum_def = **enum_def_it; - GenNameSpace(*enum_def.defined_namespace, &schema, &last_namespace); - GenComment(enum_def.doc_comment, &schema, nullptr); - schema += "enum " + enum_def.name + " : "; - schema += GenType(enum_def.underlying_type) + " {\n"; - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); ++it) { - auto &ev = **it; - GenComment(ev.doc_comment, &schema, nullptr, " "); - schema += " " + ev.name + " = " + NumToString(ev.value) + ",\n"; - } - schema += "}\n\n"; - } - // Generate code for all structs/tables. - for (auto it = parser.structs_.vec.begin(); - it != parser.structs_.vec.end(); ++it) { - StructDef &struct_def = **it; - GenNameSpace(*struct_def.defined_namespace, &schema, &last_namespace); - GenComment(struct_def.doc_comment, &schema, nullptr); - schema += "table " + struct_def.name + " {\n"; - for (auto field_it = struct_def.fields.vec.begin(); - field_it != struct_def.fields.vec.end(); ++field_it) { - auto &field = **field_it; - GenComment(field.doc_comment, &schema, nullptr, " "); - schema += " " + field.name + ":" + GenType(field.value.type); - if (field.value.constant != "0") schema += " = " + field.value.constant; - if (field.required) schema += " (required)"; - schema += ";\n"; - } - schema += "}\n\n"; - } - return schema; -} - -bool GenerateFBS(const Parser &parser, - const std::string &path, - const std::string &file_name) { - return SaveFile((path + file_name + ".fbs").c_str(), - GenerateFBS(parser, file_name), false); -} - -} // namespace flatbuffers -
diff --git a/third_party/flatbuffers/src/idl_gen_general.cpp b/third_party/flatbuffers/src/idl_gen_general.cpp deleted file mode 100644 index 1e9f3b6..0000000 --- a/third_party/flatbuffers/src/idl_gen_general.cpp +++ /dev/null
@@ -1,1434 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" -#include <algorithm> - -namespace flatbuffers { - -// Convert an underscore_based_indentifier in to camelCase. -// Also uppercases the first character if first is true. -std::string MakeCamel(const std::string &in, bool first) { - std::string s; - for (size_t i = 0; i < in.length(); i++) { - if (!i && first) - s += static_cast<char>(toupper(in[0])); - else if (in[i] == '_' && i + 1 < in.length()) - s += static_cast<char>(toupper(in[++i])); - else - s += in[i]; - } - return s; -} - -// These arrays need to correspond to the IDLOptions::k enum. - -struct LanguageParameters { - IDLOptions::Language language; - // Whether function names in the language typically start with uppercase. - bool first_camel_upper; - std::string file_extension; - std::string string_type; - std::string bool_type; - std::string open_curly; - std::string accessor_type; - std::string const_decl; - std::string unsubclassable_decl; - std::string enum_decl; - std::string enum_separator; - std::string getter_prefix; - std::string getter_suffix; - std::string inheritance_marker; - std::string namespace_ident; - std::string namespace_begin; - std::string namespace_end; - std::string set_bb_byteorder; - std::string get_bb_position; - std::string get_fbb_offset; - std::string accessor_prefix; - std::string accessor_prefix_static; - std::string optional_suffix; - std::string includes; - CommentConfig comment_config; -}; - -const LanguageParameters& GetLangParams(IDLOptions::Language lang) { - static LanguageParameters language_parameters[] = { - { - IDLOptions::kJava, - false, - ".java", - "String", - "boolean ", - " {\n", - "class ", - " final ", - "final ", - "final class ", - ";\n", - "()", - "", - " extends ", - "package ", - ";", - "", - "_bb.order(ByteOrder.LITTLE_ENDIAN); ", - "position()", - "offset()", - "", - "", - "", - "import java.nio.*;\nimport java.lang.*;\nimport java.util.*;\n" - "import com.google.flatbuffers.*;\n\n@SuppressWarnings(\"unused\")\n", - { - "/**", - " *", - " */", - }, - }, - { - IDLOptions::kCSharp, - true, - ".cs", - "string", - "bool ", - "\n{\n", - "struct ", - " readonly ", - "", - "enum ", - ",\n", - " { get", - "} ", - " : ", - "namespace ", - "\n{", - "\n}\n", - "", - "Position", - "Offset", - "__p.", - "Table.", - "?", - "using global::System;\nusing global::FlatBuffers;\n\n", - { - nullptr, - "///", - nullptr, - }, - }, - }; - - if (lang == IDLOptions::kJava) { - return language_parameters[0]; - } else { - assert(lang == IDLOptions::kCSharp); - return language_parameters[1]; - } -} - -namespace general { -class GeneralGenerator : public BaseGenerator { - public: - GeneralGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "", "."), - lang_(GetLangParams(parser_.opts.lang)), - cur_name_space_( nullptr ) { - } - - GeneralGenerator &operator=(const GeneralGenerator &); - bool generate() { - std::string one_file_code; - cur_name_space_ = parser_.namespaces_.back(); - - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - std::string enumcode; - auto &enum_def = **it; - if (!parser_.opts.one_file) - cur_name_space_ = enum_def.defined_namespace; - GenEnum(enum_def, &enumcode); - if (parser_.opts.one_file) { - one_file_code += enumcode; - } else { - if (!SaveType(enum_def.name, *enum_def.defined_namespace, - enumcode, false)) return false; - } - } - - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - std::string declcode; - auto &struct_def = **it; - if (!parser_.opts.one_file) - cur_name_space_ = struct_def.defined_namespace; - GenStruct(struct_def, &declcode); - if (parser_.opts.one_file) { - one_file_code += declcode; - } else { - if (!SaveType(struct_def.name, *struct_def.defined_namespace, - declcode, true)) return false; - } - } - - if (parser_.opts.one_file) { - return SaveType(file_name_, *parser_.namespaces_.back(), - one_file_code, true); - } - return true; - } - - // Save out the generated code for a single class while adding - // declaration boilerplate. - bool SaveType(const std::string &defname, const Namespace &ns, - const std::string &classcode, bool needs_includes) { - if (!classcode.length()) return true; - - std::string code; - code = code + "// " + FlatBuffersGeneratedWarning(); - std::string namespace_name = FullNamespace(".", ns); - if (!namespace_name.empty()) { - code += lang_.namespace_ident + namespace_name + lang_.namespace_begin; - code += "\n\n"; - } - if (needs_includes) code += lang_.includes; - code += classcode; - if (!namespace_name.empty()) code += lang_.namespace_end; - auto filename = NamespaceDir(ns) + defname + lang_.file_extension; - return SaveFile(filename.c_str(), code, false); - } - - const Namespace *CurrentNameSpace() const { return cur_name_space_; } - - std::string FunctionStart(char upper) { - return std::string() + (lang_.language == IDLOptions::kJava - ? static_cast<char>(tolower(upper)) - : upper); -} - -static bool IsEnum(const Type& type) { - return type.enum_def != nullptr && IsInteger(type.base_type); -} - -std::string GenTypeBasic(const Type &type, bool enableLangOverrides) { - static const char *java_typename[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #JTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - - static const char *csharp_typename[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #NTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - - if (enableLangOverrides) { - if (lang_.language == IDLOptions::kCSharp) { - if (IsEnum(type)) return WrapInNameSpace(*type.enum_def); - if (type.base_type == BASE_TYPE_STRUCT) { - return "Offset<" + WrapInNameSpace(*type.struct_def) + ">"; - } - } - } - - if (lang_.language == IDLOptions::kJava) { - return java_typename[type.base_type]; - } else { - assert(lang_.language == IDLOptions::kCSharp); - return csharp_typename[type.base_type]; - } -} - -std::string GenTypeBasic(const Type &type) { - return GenTypeBasic(type, true); -} - -std::string GenTypePointer(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: - return lang_.string_type; - case BASE_TYPE_VECTOR: - return GenTypeGet(type.VectorType()); - case BASE_TYPE_STRUCT: - return WrapInNameSpace(*type.struct_def); - case BASE_TYPE_UNION: - // Unions in C# use a generic Table-derived type for better type safety - if (lang_.language == IDLOptions::kCSharp) return "TTable"; - // fall through - default: - return "Table"; - } -} - -std::string GenTypeGet(const Type &type) { - return IsScalar(type.base_type) - ? GenTypeBasic(type) - : GenTypePointer(type); -} - -// Find the destination type the user wants to receive the value in (e.g. -// one size higher signed types for unsigned serialized values in Java). -Type DestinationType(const Type &type, bool vectorelem) { - if (lang_.language != IDLOptions::kJava) return type; - switch (type.base_type) { - // We use int for both uchar/ushort, since that generally means less casting - // than using short for uchar. - case BASE_TYPE_UCHAR: return Type(BASE_TYPE_INT); - case BASE_TYPE_USHORT: return Type(BASE_TYPE_INT); - case BASE_TYPE_UINT: return Type(BASE_TYPE_LONG); - case BASE_TYPE_VECTOR: - if (vectorelem) - return DestinationType(type.VectorType(), vectorelem); - // else fall thru: - default: return type; - } -} - -std::string GenOffsetType(const StructDef &struct_def) { - if(lang_.language == IDLOptions::kCSharp) { - return "Offset<" + WrapInNameSpace(struct_def) + ">"; - } else { - return "int"; - } -} - -std::string GenOffsetConstruct(const StructDef &struct_def, - const std::string &variable_name) -{ - if(lang_.language == IDLOptions::kCSharp) { - return "new Offset<" + WrapInNameSpace(struct_def) + ">(" + variable_name + - ")"; - } - return variable_name; -} - -std::string GenVectorOffsetType() { - if(lang_.language == IDLOptions::kCSharp) { - return "VectorOffset"; - } else { - return "int"; - } -} - -// Generate destination type name -std::string GenTypeNameDest(const Type &type) -{ - return GenTypeGet(DestinationType(type, true)); -} - -// Mask to turn serialized value into destination type value. -std::string DestinationMask(const Type &type, bool vectorelem) { - if (lang_.language != IDLOptions::kJava) return ""; - switch (type.base_type) { - case BASE_TYPE_UCHAR: return " & 0xFF"; - case BASE_TYPE_USHORT: return " & 0xFFFF"; - case BASE_TYPE_UINT: return " & 0xFFFFFFFFL"; - case BASE_TYPE_VECTOR: - if (vectorelem) - return DestinationMask(type.VectorType(), vectorelem); - // else fall thru: - default: return ""; - } -} - -// Casts necessary to correctly read serialized data -std::string DestinationCast(const Type &type) { - if (type.base_type == BASE_TYPE_VECTOR) { - return DestinationCast(type.VectorType()); - } else { - switch (lang_.language) { - case IDLOptions::kJava: - // Cast necessary to correctly read serialized unsigned values. - if (type.base_type == BASE_TYPE_UINT) return "(long)"; - break; - - case IDLOptions::kCSharp: - // Cast from raw integral types to enum. - if (IsEnum(type)) return "(" + WrapInNameSpace(*type.enum_def) + ")"; - break; - - default: - break; - } - } - return ""; -} - -// Cast statements for mutator method parameters. -// In Java, parameters representing unsigned numbers need to be cast down to -// their respective type. For example, a long holding an unsigned int value -// would be cast down to int before being put onto the buffer. In C#, one cast -// directly cast an Enum to its underlying type, which is essential before -// putting it onto the buffer. -std::string SourceCast(const Type &type, bool castFromDest) { - if (type.base_type == BASE_TYPE_VECTOR) { - return SourceCast(type.VectorType(), castFromDest); - } else { - switch (lang_.language) { - case IDLOptions::kJava: - if (castFromDest) { - if (type.base_type == BASE_TYPE_UINT) return "(int)"; - else if (type.base_type == BASE_TYPE_USHORT) return "(short)"; - else if (type.base_type == BASE_TYPE_UCHAR) return "(byte)"; - } - break; - case IDLOptions::kCSharp: - if (IsEnum(type)) return "(" + GenTypeBasic(type, false) + ")"; - break; - default: - break; - } - } - return ""; -} - -std::string SourceCast(const Type &type) { - return SourceCast(type, true); -} - -std::string SourceCastBasic(const Type &type, bool castFromDest) { - return IsScalar(type.base_type) ? SourceCast(type, castFromDest) : ""; -} - -std::string SourceCastBasic(const Type &type) { - return SourceCastBasic(type, true); -} - - -std::string GenEnumDefaultValue(const Value &value) { - auto enum_def = value.type.enum_def; - auto vec = enum_def->vals.vec; - auto default_value = StringToInt(value.constant.c_str()); - - auto result = value.constant; - for (auto it = vec.begin(); it != vec.end(); ++it) { - auto enum_val = **it; - if (enum_val.value == default_value) { - result = WrapInNameSpace(*enum_def) + "." + enum_val.name; - break; - } - } - - return result; -} - -std::string GenDefaultValue(const Value &value, bool enableLangOverrides) { - if (enableLangOverrides) { - // handles both enum case and vector of enum case - if (lang_.language == IDLOptions::kCSharp && - value.type.enum_def != nullptr && - value.type.base_type != BASE_TYPE_UNION) { - return GenEnumDefaultValue(value); - } - } - - auto longSuffix = lang_.language == IDLOptions::kJava ? "L" : ""; - switch (value.type.base_type) { - case BASE_TYPE_FLOAT: return value.constant + "f"; - case BASE_TYPE_BOOL: return value.constant == "0" ? "false" : "true"; - case BASE_TYPE_ULONG: - { - if (lang_.language != IDLOptions::kJava) - return value.constant; - // Converts the ulong into its bits signed equivalent - uint64_t defaultValue = StringToUInt(value.constant.c_str()); - return NumToString(static_cast<int64_t>(defaultValue)) + longSuffix; - } - case BASE_TYPE_UINT: - case BASE_TYPE_LONG: return value.constant + longSuffix; - default: return value.constant; - } -} - -std::string GenDefaultValue(const Value &value) { - return GenDefaultValue(value, true); -} - -std::string GenDefaultValueBasic(const Value &value, bool enableLangOverrides) { - if (!IsScalar(value.type.base_type)) { - if (enableLangOverrides) { - if (lang_.language == IDLOptions::kCSharp) { - switch (value.type.base_type) { - case BASE_TYPE_STRING: - return "default(StringOffset)"; - case BASE_TYPE_STRUCT: - return "default(Offset<" + WrapInNameSpace(*value.type.struct_def) + - ">)"; - case BASE_TYPE_VECTOR: - return "default(VectorOffset)"; - default: - break; - } - } - } - return "0"; - } - return GenDefaultValue(value, enableLangOverrides); -} - -std::string GenDefaultValueBasic(const Value &value) { - return GenDefaultValueBasic(value, true); -} - -void GenEnum(EnumDef &enum_def, std::string *code_ptr) { - std::string &code = *code_ptr; - if (enum_def.generated) return; - - // Generate enum definitions of the form: - // public static (final) int name = value; - // In Java, we use ints rather than the Enum feature, because we want them - // to map directly to how they're used in C/C++ and file formats. - // That, and Java Enums are expensive, and not universally liked. - GenComment(enum_def.doc_comment, code_ptr, &lang_.comment_config); - code += std::string("public ") + lang_.enum_decl + enum_def.name; - if (lang_.language == IDLOptions::kCSharp) { - code += lang_.inheritance_marker + - GenTypeBasic(enum_def.underlying_type, false); - } - code += lang_.open_curly; - if (lang_.language == IDLOptions::kJava) { - code += " private " + enum_def.name + "() { }\n"; - } - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - GenComment(ev.doc_comment, code_ptr, &lang_.comment_config, " "); - if (lang_.language != IDLOptions::kCSharp) { - code += " public static"; - code += lang_.const_decl; - code += GenTypeBasic(enum_def.underlying_type, false); - } - code += " " + ev.name + " = "; - code += NumToString(ev.value); - code += lang_.enum_separator; - } - - // Generate a generate string table for enum values. - // We do not do that for C# where this functionality is native. - if (lang_.language != IDLOptions::kCSharp) { - // Problem is, if values are very sparse that could generate really big - // tables. Ideally in that case we generate a map lookup instead, but for - // the moment we simply don't output a table at all. - auto range = enum_def.vals.vec.back()->value - - enum_def.vals.vec.front()->value + 1; - // Average distance between values above which we consider a table - // "too sparse". Change at will. - static const int kMaxSparseness = 5; - if (range / static_cast<int64_t>(enum_def.vals.vec.size()) < kMaxSparseness) { - code += "\n public static"; - code += lang_.const_decl; - code += lang_.string_type; - code += "[] names = { "; - auto val = enum_def.vals.vec.front()->value; - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - while (val++ != (*it)->value) code += "\"\", "; - code += "\"" + (*it)->name + "\", "; - } - code += "};\n\n"; - code += " public static "; - code += lang_.string_type; - code += " " + MakeCamel("name", lang_.first_camel_upper); - code += "(int e) { return names[e"; - if (enum_def.vals.vec.front()->value) - code += " - " + enum_def.vals.vec.front()->name; - code += "]; }\n"; - } - } - - // Close the class - code += "}"; - // Java does not need the closing semi-colon on class definitions. - code += (lang_.language != IDLOptions::kJava) ? ";" : ""; - code += "\n\n"; -} - -// Returns the function name that is able to read a value of the given type. -std::string GenGetter(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: return lang_.accessor_prefix + "__string"; - case BASE_TYPE_STRUCT: return lang_.accessor_prefix + "__struct"; - case BASE_TYPE_UNION: return lang_.accessor_prefix + "__union"; - case BASE_TYPE_VECTOR: return GenGetter(type.VectorType()); - default: { - std::string getter = - lang_.accessor_prefix + "bb." + FunctionStart('G') + "et"; - if (type.base_type == BASE_TYPE_BOOL) { - getter = "0!=" + getter; - } else if (GenTypeBasic(type, false) != "byte") { - getter += MakeCamel(GenTypeBasic(type, false)); - } - return getter; - } - } -} - -// Returns the function name that is able to read a value of the given type. -std::string GenGetterForLookupByKey(flatbuffers::FieldDef *key_field, - const std::string &data_buffer, - const char *num = nullptr) { - auto type = key_field->value.type; - auto dest_mask = DestinationMask(type, true); - auto dest_cast = DestinationCast(type); - auto getter = data_buffer + "." + FunctionStart('G') + "et"; - if (GenTypeBasic(type, false) != "byte") { - getter += MakeCamel(GenTypeBasic(type, false)); - } - getter = dest_cast + getter + "(" + GenOffsetGetter(key_field, num) + ")" - + dest_mask; - return getter; -} - -// Direct mutation is only allowed for scalar fields. -// Hence a setter method will only be generated for such fields. -std::string GenSetter(const Type &type) { - if (IsScalar(type.base_type)) { - std::string setter = - lang_.accessor_prefix + "bb." + FunctionStart('P') + "ut"; - if (GenTypeBasic(type, false) != "byte" && - type.base_type != BASE_TYPE_BOOL) { - setter += MakeCamel(GenTypeBasic(type, false)); - } - return setter; - } else { - return ""; - } -} - -// Returns the method name for use with add/put calls. -std::string GenMethod(const Type &type) { - return IsScalar(type.base_type) - ? MakeCamel(GenTypeBasic(type, false)) - : (IsStruct(type) ? "Struct" : "Offset"); -} - -// Recursively generate arguments for a constructor, to deal with nested -// structs. -void GenStructArgs(const StructDef &struct_def, std::string *code_ptr, - const char *nameprefix) { - std::string &code = *code_ptr; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious these arguments are constructing - // a nested struct, prefix the name with the field name. - GenStructArgs(*field.value.type.struct_def, code_ptr, - (nameprefix + (field.name + "_")).c_str()); - } else { - code += ", "; - code += GenTypeBasic(DestinationType(field.value.type, false)); - code += " "; - code += nameprefix; - code += MakeCamel(field.name, lang_.first_camel_upper); - } - } -} - -// Recusively generate struct construction statements of the form: -// builder.putType(name); -// and insert manual padding. -void GenStructBody(const StructDef &struct_def, std::string *code_ptr, - const char *nameprefix) { - std::string &code = *code_ptr; - code += " builder." + FunctionStart('P') + "rep("; - code += NumToString(struct_def.minalign) + ", "; - code += NumToString(struct_def.bytesize) + ");\n"; - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); ++it) { - auto &field = **it; - if (field.padding) { - code += " builder." + FunctionStart('P') + "ad("; - code += NumToString(field.padding) + ");\n"; - } - if (IsStruct(field.value.type)) { - GenStructBody(*field.value.type.struct_def, code_ptr, - (nameprefix + (field.name + "_")).c_str()); - } else { - code += " builder." + FunctionStart('P') + "ut"; - code += GenMethod(field.value.type) + "("; - code += SourceCast(field.value.type); - auto argname = nameprefix + MakeCamel(field.name, lang_.first_camel_upper); - code += argname; - code += ");\n"; - } - } -} - -std::string GenByteBufferLength(const char *bb_name) { - std::string bb_len = bb_name; - if (lang_.language == IDLOptions::kCSharp) bb_len += ".Length"; - else bb_len += ".array().length"; - return bb_len; -} - -std::string GenOffsetGetter(flatbuffers::FieldDef *key_field, - const char *num = nullptr) { - std::string key_offset = ""; - key_offset += lang_.accessor_prefix_static + "__offset(" + - NumToString(key_field->value.offset) + ", "; - if (num) { - key_offset += num; - key_offset += (lang_.language == IDLOptions::kCSharp ? - ".Value, builder.DataBuffer)" : ", _bb)"); - } else { - key_offset += GenByteBufferLength("bb"); - key_offset += " - tableOffset, bb)"; - } - return key_offset; -} - -std::string GenLookupKeyGetter(flatbuffers::FieldDef *key_field) { - std::string key_getter = " "; - key_getter += "int tableOffset = " + lang_.accessor_prefix_static; - key_getter += "__indirect(vectorLocation + 4 * (start + middle)"; - key_getter += ", bb);\n "; - if (key_field->value.type.base_type == BASE_TYPE_STRING) { - key_getter += "int comp = " + lang_.accessor_prefix_static; - key_getter += FunctionStart('C') + "ompareStrings("; - key_getter += GenOffsetGetter(key_field); - key_getter += ", byteKey, bb);\n"; - } else { - auto get_val = GenGetterForLookupByKey(key_field, "bb"); - if (lang_.language == IDLOptions::kCSharp) { - key_getter += "int comp = " + get_val + ".CompareTo(key);\n"; - } else { - key_getter += GenTypeNameDest(key_field->value.type) + " val = "; - key_getter += get_val + ";\n"; - key_getter += " int comp = val > key ? 1 : val < key ? -1 : 0;\n"; - } - } - return key_getter; -} - - -std::string GenKeyGetter(flatbuffers::FieldDef *key_field) { - std::string key_getter = ""; - auto data_buffer = (lang_.language == IDLOptions::kCSharp) ? - "builder.DataBuffer" : "_bb"; - if (key_field->value.type.base_type == BASE_TYPE_STRING) { - if (lang_.language == IDLOptions::kJava) - key_getter += " return "; - key_getter += lang_.accessor_prefix_static; - key_getter += FunctionStart('C') + "ompareStrings("; - key_getter += GenOffsetGetter(key_field, "o1") + ", "; - key_getter += GenOffsetGetter(key_field, "o2") + ", " + data_buffer + ")"; - if (lang_.language == IDLOptions::kJava) - key_getter += ";"; - } - else { - auto field_getter = GenGetterForLookupByKey(key_field, data_buffer, "o1"); - if (lang_.language == IDLOptions::kCSharp) { - key_getter += field_getter; - field_getter = GenGetterForLookupByKey(key_field, data_buffer, "o2"); - key_getter += ".CompareTo(" + field_getter + ")"; - } - else { - key_getter += "\n " + GenTypeNameDest(key_field->value.type) + " val_1 = "; - key_getter += field_getter + ";\n " + GenTypeNameDest(key_field->value.type); - key_getter += " val_2 = "; - field_getter = GenGetterForLookupByKey(key_field, data_buffer, "o2"); - key_getter += field_getter + ";\n"; - key_getter += " return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;\n "; - } - } - return key_getter; -} - -void GenStruct(StructDef &struct_def, std::string *code_ptr) { - if (struct_def.generated) return; - std::string &code = *code_ptr; - - // Generate a struct accessor class, with methods of the form: - // public type name() { return bb.getType(i + offset); } - // or for tables of the form: - // public type name() { - // int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default; - // } - GenComment(struct_def.doc_comment, code_ptr, &lang_.comment_config); - code += "public "; - if (lang_.language == IDLOptions::kCSharp && - struct_def.attributes.Lookup("csharp_partial")) { - // generate a partial class for this C# struct/table - code += "partial "; - } else { - code += lang_.unsubclassable_decl; - } - code += lang_.accessor_type + struct_def.name; - if (lang_.language == IDLOptions::kCSharp) { - code += " : IFlatbufferObject"; - code += lang_.open_curly; - code += " private "; - code += struct_def.fixed ? "Struct" : "Table"; - code += " __p;\n"; - - if (lang_.language == IDLOptions::kCSharp) { - code += " public ByteBuffer ByteBuffer { get { return __p.bb; } }\n"; - } - - } else { - code += lang_.inheritance_marker; - code += struct_def.fixed ? "Struct" : "Table"; - code += lang_.open_curly; - } - if (!struct_def.fixed) { - // Generate a special accessor for the table that when used as the root - // of a FlatBuffer - std::string method_name = FunctionStart('G') + "etRootAs" + struct_def.name; - std::string method_signature = " public static " + struct_def.name + " " + - method_name; - - // create convenience method that doesn't require an existing object - code += method_signature + "(ByteBuffer _bb) "; - code += "{ return " + method_name + "(_bb, new " + struct_def.name+ "()); }\n"; - - // create method that allows object reuse - code += method_signature + "(ByteBuffer _bb, " + struct_def.name + " obj) { "; - code += lang_.set_bb_byteorder; - code += "return (obj.__assign(_bb." + FunctionStart('G') + "etInt(_bb."; - code += lang_.get_bb_position; - code += ") + _bb."; - code += lang_.get_bb_position; - code += ", _bb)); }\n"; - if (parser_.root_struct_def_ == &struct_def) { - if (parser_.file_identifier_.length()) { - // Check if a buffer has the identifier. - code += " public static "; - code += lang_.bool_type + struct_def.name; - code += "BufferHasIdentifier(ByteBuffer _bb) { return "; - code += lang_.accessor_prefix_static + "__has_identifier(_bb, \""; - code += parser_.file_identifier_; - code += "\"); }\n"; - } - } - } - // Generate the __init method that sets the field in a pre-existing - // accessor object. This is to allow object reuse. - code += " public void __init(int _i, ByteBuffer _bb) "; - code += "{ " + lang_.accessor_prefix + "bb_pos = _i; "; - code += lang_.accessor_prefix + "bb = _bb; }\n"; - code += " public " + struct_def.name + " __assign(int _i, ByteBuffer _bb) "; - code += "{ __init(_i, _bb); return this; }\n\n"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - GenComment(field.doc_comment, code_ptr, &lang_.comment_config, " "); - std::string type_name = GenTypeGet(field.value.type); - std::string type_name_dest = GenTypeNameDest(field.value.type); - std::string conditional_cast = ""; - std::string optional = ""; - if (lang_.language == IDLOptions::kCSharp && - !struct_def.fixed && - (field.value.type.base_type == BASE_TYPE_STRUCT || - field.value.type.base_type == BASE_TYPE_UNION || - (field.value.type.base_type == BASE_TYPE_VECTOR && - field.value.type.element == BASE_TYPE_STRUCT))) { - optional = lang_.optional_suffix; - conditional_cast = "(" + type_name_dest + optional + ")"; - } - std::string dest_mask = DestinationMask(field.value.type, true); - std::string dest_cast = DestinationCast(field.value.type); - std::string src_cast = SourceCast(field.value.type); - std::string method_start = " public " + type_name_dest + optional + " " + - MakeCamel(field.name, lang_.first_camel_upper); - std::string obj = lang_.language == IDLOptions::kCSharp - ? "(new " + type_name + "())" - : "obj"; - - // Most field accessors need to retrieve and test the field offset first, - // this is the prefix code for that: - auto offset_prefix = " { int o = " + lang_.accessor_prefix + "__offset(" + - NumToString(field.value.offset) + - "); return o != 0 ? "; - // Generate the accessors that don't do object reuse. - if (field.value.type.base_type == BASE_TYPE_STRUCT) { - // Calls the accessor that takes an accessor object with a new object. - if (lang_.language != IDLOptions::kCSharp) { - code += method_start + "() { return "; - code += MakeCamel(field.name, lang_.first_camel_upper); - code += "(new "; - code += type_name + "()); }\n"; - } - } else if (field.value.type.base_type == BASE_TYPE_VECTOR && - field.value.type.element == BASE_TYPE_STRUCT) { - // Accessors for vectors of structs also take accessor objects, this - // generates a variant without that argument. - if (lang_.language != IDLOptions::kCSharp) { - code += method_start + "(int j) { return "; - code += MakeCamel(field.name, lang_.first_camel_upper); - code += "(new " + type_name + "(), j); }\n"; - } - } else if (field.value.type.base_type == BASE_TYPE_UNION) { - if (lang_.language == IDLOptions::kCSharp) { - // Union types in C# use generic Table-derived type for better type - // safety. - method_start += "<TTable>"; - type_name = type_name_dest; - } - } - std::string getter = dest_cast + GenGetter(field.value.type); - code += method_start; - std::string default_cast = ""; - // only create default casts for c# scalars or vectors of scalars - if (lang_.language == IDLOptions::kCSharp && - (IsScalar(field.value.type.base_type) || - (field.value.type.base_type == BASE_TYPE_VECTOR && - IsScalar(field.value.type.element)))) { - // For scalars, default value will be returned by GetDefaultValue(). - // If the scalar is an enum, GetDefaultValue() returns an actual c# enum - // that doesn't need to be casted. However, default values for enum - // elements of vectors are integer literals ("0") and are still casted - // for clarity. - if (field.value.type.enum_def == nullptr || - field.value.type.base_type == BASE_TYPE_VECTOR) { - default_cast = "(" + type_name_dest + ")"; - } - } - std::string member_suffix = "; "; - if (IsScalar(field.value.type.base_type)) { - code += lang_.getter_prefix; - member_suffix += lang_.getter_suffix; - if (struct_def.fixed) { - code += " { return " + getter; - code += "(" + lang_.accessor_prefix + "bb_pos + "; - code += NumToString(field.value.offset) + ")"; - code += dest_mask; - } else { - code += offset_prefix + getter; - code += "(o + " + lang_.accessor_prefix + "bb_pos)" + dest_mask; - code += " : " + default_cast; - code += GenDefaultValue(field.value); - } - } else { - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: - if (lang_.language != IDLOptions::kCSharp) { - code += "(" + type_name + " obj" + ")"; - } else { - code += lang_.getter_prefix; - member_suffix += lang_.getter_suffix; - } - if (struct_def.fixed) { - code += " { return " + obj + ".__assign(" + lang_.accessor_prefix; - code += "bb_pos + " + NumToString(field.value.offset) + ", "; - code += lang_.accessor_prefix + "bb)"; - } else { - code += offset_prefix + conditional_cast; - code += obj + ".__assign("; - code += field.value.type.struct_def->fixed - ? "o + " + lang_.accessor_prefix + "bb_pos" - : lang_.accessor_prefix + "__indirect(o + " + - lang_.accessor_prefix + "bb_pos)"; - code += ", " + lang_.accessor_prefix + "bb) : null"; - } - break; - case BASE_TYPE_STRING: - code += lang_.getter_prefix; - member_suffix += lang_.getter_suffix; - code += offset_prefix + getter + "(o + " + lang_.accessor_prefix; - code += "bb_pos) : null"; - break; - case BASE_TYPE_VECTOR: { - auto vectortype = field.value.type.VectorType(); - code += "("; - if (vectortype.base_type == BASE_TYPE_STRUCT) { - if (lang_.language != IDLOptions::kCSharp) - code += type_name + " obj, "; - getter = obj + ".__assign"; - } - code += "int j)" + offset_prefix + conditional_cast + getter +"("; - auto index = lang_.accessor_prefix + "__vector(o) + j * " + - NumToString(InlineSize(vectortype)); - if (vectortype.base_type == BASE_TYPE_STRUCT) { - code += vectortype.struct_def->fixed - ? index - : lang_.accessor_prefix + "__indirect(" + index + ")"; - code += ", " + lang_.accessor_prefix + "bb"; - } else { - code += index; - } - code += ")" + dest_mask + " : "; - - code += field.value.type.element == BASE_TYPE_BOOL ? "false" : - (IsScalar(field.value.type.element) ? default_cast + "0" : "null"); - break; - } - case BASE_TYPE_UNION: - if (lang_.language == IDLOptions::kCSharp) { - code += "() where TTable : struct, IFlatbufferObject"; - code += offset_prefix + "(TTable?)" + getter; - code += "<TTable>(o) : null"; - } else { - code += "(" + type_name + " obj)" + offset_prefix + getter; - code += "(obj, o) : null"; - } - break; - default: - assert(0); - } - } - code += member_suffix; - code += "}\n"; - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - code += " public int " + MakeCamel(field.name, lang_.first_camel_upper); - code += "Length"; - code += lang_.getter_prefix; - code += offset_prefix; - code += lang_.accessor_prefix + "__vector_len(o) : 0; "; - code += lang_.getter_suffix; - code += "}\n"; - } - // Generate a ByteBuffer accessor for strings & vectors of scalars. - if ((field.value.type.base_type == BASE_TYPE_VECTOR && - IsScalar(field.value.type.VectorType().base_type)) || - field.value.type.base_type == BASE_TYPE_STRING) { - switch (lang_.language) { - case IDLOptions::kJava: - code += " public ByteBuffer "; - code += MakeCamel(field.name, lang_.first_camel_upper); - code += "AsByteBuffer() { return "; - code += lang_.accessor_prefix + "__vector_as_bytebuffer("; - code += NumToString(field.value.offset) + ", "; - code += NumToString(field.value.type.base_type == BASE_TYPE_STRING - ? 1 - : InlineSize(field.value.type.VectorType())); - code += "); }\n"; - break; - case IDLOptions::kCSharp: - code += " public ArraySegment<byte>? Get"; - code += MakeCamel(field.name, lang_.first_camel_upper); - code += "Bytes() { return "; - code += lang_.accessor_prefix + "__vector_as_arraysegment("; - code += NumToString(field.value.offset); - code += "); }\n"; - break; - default: - break; - } - } - // generate object accessors if is nested_flatbuffer - auto nested = field.attributes.Lookup("nested_flatbuffer"); - if (nested) { - auto nested_qualified_name = - parser_.namespaces_.back()->GetFullyQualifiedName(nested->constant); - auto nested_type = parser_.structs_.Lookup(nested_qualified_name); - auto nested_type_name = WrapInNameSpace(*nested_type); - auto nestedMethodName = MakeCamel(field.name, lang_.first_camel_upper) - + "As" + nested_type_name; - auto getNestedMethodName = nestedMethodName; - if (lang_.language == IDLOptions::kCSharp) { - getNestedMethodName = "Get" + nestedMethodName; - conditional_cast = "(" + nested_type_name + lang_.optional_suffix + ")"; - } - if (lang_.language != IDLOptions::kCSharp) { - code += " public " + nested_type_name + lang_.optional_suffix + " "; - code += nestedMethodName + "() { return "; - code += getNestedMethodName + "(new " + nested_type_name + "()); }\n"; - } else { - obj = "(new " + nested_type_name + "())"; - } - code += " public " + nested_type_name + lang_.optional_suffix + " "; - code += getNestedMethodName + "("; - if (lang_.language != IDLOptions::kCSharp) - code += nested_type_name + " obj"; - code += ") { int o = " + lang_.accessor_prefix + "__offset("; - code += NumToString(field.value.offset) +"); "; - code += "return o != 0 ? " + conditional_cast + obj + ".__assign("; - code += lang_.accessor_prefix; - code += "__indirect(" + lang_.accessor_prefix + "__vector(o)), "; - code += lang_.accessor_prefix + "bb) : null; }\n"; - } - // Generate mutators for scalar fields or vectors of scalars. - if (parser_.opts.mutable_buffer) { - auto underlying_type = field.value.type.base_type == BASE_TYPE_VECTOR - ? field.value.type.VectorType() - : field.value.type; - // Boolean parameters have to be explicitly converted to byte - // representation. - auto setter_parameter = underlying_type.base_type == BASE_TYPE_BOOL - ? "(byte)(" + field.name + " ? 1 : 0)" - : field.name; - auto mutator_prefix = MakeCamel("mutate", lang_.first_camel_upper); - // A vector mutator also needs the index of the vector element it should - // mutate. - auto mutator_params = (field.value.type.base_type == BASE_TYPE_VECTOR - ? "(int j, " - : "(") + GenTypeNameDest(underlying_type) + " " + field.name + ") { "; - auto setter_index = field.value.type.base_type == BASE_TYPE_VECTOR - ? lang_.accessor_prefix + "__vector(o) + j * " + - NumToString(InlineSize(underlying_type)) - : (struct_def.fixed - ? lang_.accessor_prefix + "bb_pos + " + - NumToString(field.value.offset) - : "o + " + lang_.accessor_prefix + "bb_pos"); - if (IsScalar(field.value.type.base_type) || - (field.value.type.base_type == BASE_TYPE_VECTOR && - IsScalar(field.value.type.VectorType().base_type))) { - code += " public "; - code += struct_def.fixed ? "void " : lang_.bool_type; - code += mutator_prefix + MakeCamel(field.name, true); - code += mutator_params; - if (struct_def.fixed) { - code += GenSetter(underlying_type) + "(" + setter_index + ", "; - code += src_cast + setter_parameter + "); }\n"; - } else { - code += "int o = " + lang_.accessor_prefix + "__offset("; - code += NumToString(field.value.offset) + ");"; - code += " if (o != 0) { " + GenSetter(underlying_type); - code += "(" + setter_index + ", " + src_cast + setter_parameter + - "); return true; } else { return false; } }\n"; - } - } - } - } - code += "\n"; - flatbuffers::FieldDef *key_field = nullptr; - if (struct_def.fixed) { - // create a struct constructor function - code += " public static " + GenOffsetType(struct_def) + " "; - code += FunctionStart('C') + "reate"; - code += struct_def.name + "(FlatBufferBuilder builder"; - GenStructArgs(struct_def, code_ptr, ""); - code += ") {\n"; - GenStructBody(struct_def, code_ptr, ""); - code += " return "; - code += GenOffsetConstruct(struct_def, - "builder." + std::string(lang_.get_fbb_offset)); - code += ";\n }\n"; - } else { - // Generate a method that creates a table in one go. This is only possible - // when the table has no struct fields, since those have to be created - // inline, and there's no way to do so in Java. - bool has_no_struct_fields = true; - int num_fields = 0; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) continue; - if (IsStruct(field.value.type)) { - has_no_struct_fields = false; - } else { - num_fields++; - } - } - if (has_no_struct_fields && num_fields) { - // Generate a table constructor of the form: - // public static int createName(FlatBufferBuilder builder, args...) - code += " public static " + GenOffsetType(struct_def) + " "; - code += FunctionStart('C') + "reate" + struct_def.name; - code += "(FlatBufferBuilder builder"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) continue; - code += ",\n "; - code += GenTypeBasic(DestinationType(field.value.type, false)); - code += " "; - code += field.name; - if (!IsScalar(field.value.type.base_type)) code += "Offset"; - - // Java doesn't have defaults, which means this method must always - // supply all arguments, and thus won't compile when fields are added. - if (lang_.language != IDLOptions::kJava) { - code += " = "; - code += GenDefaultValueBasic(field.value); - } - } - code += ") {\n builder."; - code += FunctionStart('S') + "tartObject("; - code += NumToString(struct_def.fields.vec.size()) + ");\n"; - for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; - size; - size /= 2) { - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); ++it) { - auto &field = **it; - if (!field.deprecated && - (!struct_def.sortbysize || - size == SizeOf(field.value.type.base_type))) { - code += " " + struct_def.name + "."; - code += FunctionStart('A') + "dd"; - code += MakeCamel(field.name) + "(builder, " + field.name; - if (!IsScalar(field.value.type.base_type)) code += "Offset"; - code += ");\n"; - } - } - } - code += " return " + struct_def.name + "."; - code += FunctionStart('E') + "nd" + struct_def.name; - code += "(builder);\n }\n\n"; - } - // Generate a set of static methods that allow table construction, - // of the form: - // public static void addName(FlatBufferBuilder builder, short name) - // { builder.addShort(id, name, default); } - // Unlike the Create function, these always work. - code += " public static void " + FunctionStart('S') + "tart"; - code += struct_def.name; - code += "(FlatBufferBuilder builder) { builder."; - code += FunctionStart('S') + "tartObject("; - code += NumToString(struct_def.fields.vec.size()) + "); }\n"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) continue; - if (field.key) key_field = &field; - code += " public static void " + FunctionStart('A') + "dd"; - code += MakeCamel(field.name); - code += "(FlatBufferBuilder builder, "; - code += GenTypeBasic(DestinationType(field.value.type, false)); - auto argname = MakeCamel(field.name, false); - if (!IsScalar(field.value.type.base_type)) argname += "Offset"; - code += " " + argname + ") { builder." + FunctionStart('A') + "dd"; - code += GenMethod(field.value.type) + "("; - code += NumToString(it - struct_def.fields.vec.begin()) + ", "; - code += SourceCastBasic(field.value.type); - code += argname; - if (!IsScalar(field.value.type.base_type) && - field.value.type.base_type != BASE_TYPE_UNION && - lang_.language == IDLOptions::kCSharp) { - code += ".Value"; - } - code += ", "; - if (lang_.language == IDLOptions::kJava) - code += SourceCastBasic( field.value.type ); - code += GenDefaultValue(field.value, false); - code += "); }\n"; - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - auto vector_type = field.value.type.VectorType(); - auto alignment = InlineAlignment(vector_type); - auto elem_size = InlineSize(vector_type); - if (!IsStruct(vector_type)) { - // Generate a method to create a vector from a Java array. - code += " public static " + GenVectorOffsetType() + " "; - code += FunctionStart('C') + "reate"; - code += MakeCamel(field.name); - code += "Vector(FlatBufferBuilder builder, "; - code += GenTypeBasic(vector_type) + "[] data) "; - code += "{ builder." + FunctionStart('S') + "tartVector("; - code += NumToString(elem_size); - code += ", data." + FunctionStart('L') + "ength, "; - code += NumToString(alignment); - code += "); for (int i = data."; - code += FunctionStart('L') + "ength - 1; i >= 0; i--) builder."; - code += FunctionStart('A') + "dd"; - code += GenMethod(vector_type); - code += "("; - code += SourceCastBasic(vector_type, false); - code += "data[i]"; - if (lang_.language == IDLOptions::kCSharp && - (vector_type.base_type == BASE_TYPE_STRUCT || - vector_type.base_type == BASE_TYPE_STRING)) - code += ".Value"; - code += "); return "; - code += "builder." + FunctionStart('E') + "ndVector(); }\n"; - } - // Generate a method to start a vector, data to be added manually after. - code += " public static void " + FunctionStart('S') + "tart"; - code += MakeCamel(field.name); - code += "Vector(FlatBufferBuilder builder, int numElems) "; - code += "{ builder." + FunctionStart('S') + "tartVector("; - code += NumToString(elem_size); - code += ", numElems, " + NumToString(alignment); - code += "); }\n"; - } - } - code += " public static " + GenOffsetType(struct_def) + " "; - code += FunctionStart('E') + "nd" + struct_def.name; - code += "(FlatBufferBuilder builder) {\n int o = builder."; - code += FunctionStart('E') + "ndObject();\n"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (!field.deprecated && field.required) { - code += " builder." + FunctionStart('R') + "equired(o, "; - code += NumToString(field.value.offset); - code += "); // " + field.name + "\n"; - } - } - code += " return " + GenOffsetConstruct(struct_def, "o") + ";\n }\n"; - if (parser_.root_struct_def_ == &struct_def) { - code += " public static void "; - code += FunctionStart('F') + "inish" + struct_def.name; - code += "Buffer(FlatBufferBuilder builder, " + GenOffsetType(struct_def); - code += " offset) {"; - code += " builder." + FunctionStart('F') + "inish(offset"; - if (lang_.language == IDLOptions::kCSharp) { - code += ".Value"; - } - - if (parser_.file_identifier_.length()) - code += ", \"" + parser_.file_identifier_ + "\""; - code += "); }\n"; - } - } - // Only generate key compare function for table, - // because `key_field` is not set for struct - if (struct_def.has_key && !struct_def.fixed) { - if (lang_.language == IDLOptions::kJava) { - code += "\n @Override\n protected int keysCompare("; - code += "Integer o1, Integer o2, ByteBuffer _bb) {"; - code += GenKeyGetter(key_field); - code += " }\n"; - } - else { - code += "\n public static VectorOffset "; - code += "CreateMySortedVectorOfTables(FlatBufferBuilder builder, "; - code += "Offset<" + struct_def.name + ">"; - code += "[] offsets) {\n"; - code += " Array.Sort(offsets, (Offset<" + struct_def.name + - "> o1, Offset<" + struct_def.name + "> o2) => " + GenKeyGetter(key_field); - code += ");\n"; - code += " return builder.CreateVectorOfTables(offsets);\n }\n"; - } - - code += "\n public static " + struct_def.name + lang_.optional_suffix; - code += " " + FunctionStart('L') + "ookupByKey(" + GenVectorOffsetType(); - code += " vectorOffset, " + GenTypeNameDest(key_field->value.type); - code += " key, ByteBuffer bb) {\n"; - if (key_field->value.type.base_type == BASE_TYPE_STRING) { - code += " byte[] byteKey = "; - if (lang_.language == IDLOptions::kJava) - code += "key.getBytes(Table.UTF8_CHARSET.get());\n"; - else - code += "System.Text.Encoding.UTF8.GetBytes(key);\n"; - } - code += " int vectorLocation = " + GenByteBufferLength("bb"); - code += " - vectorOffset"; - if (lang_.language == IDLOptions::kCSharp) code += ".Value"; - code += ";\n int span = "; - code += "bb." + FunctionStart('G') + "etInt(vectorLocation);\n"; - code += " int start = 0;\n"; - code += " vectorLocation += 4;\n"; - code += " while (span != 0) {\n"; - code += " int middle = span / 2;\n"; - code += GenLookupKeyGetter(key_field); - code += " if (comp > 0) {\n"; - code += " span = middle;\n"; - code += " } else if (comp < 0) {\n"; - code += " middle++;\n"; - code += " start += middle;\n"; - code += " span -= middle;\n"; - code += " } else {\n"; - code += " return new " + struct_def.name; - code += "().__assign(tableOffset, bb);\n"; - code += " }\n }\n"; - code += " return null;\n"; - code += " }\n"; - } - code += "}"; - // Java does not need the closing semi-colon on class definitions. - code += (lang_.language != IDLOptions::kJava) ? ";" : ""; - code += "\n\n"; -} - const LanguageParameters& lang_; - // This tracks the current namespace used to determine if a type need to be prefixed by its namespace - const Namespace *cur_name_space_; -}; -} // namespace general - -bool GenerateGeneral(const Parser &parser, const std::string &path, - const std::string &file_name) { - general::GeneralGenerator generator(parser, path, file_name); - return generator.generate(); -} - -std::string GeneralMakeRule(const Parser &parser, const std::string &path, - const std::string &file_name) { - assert(parser.opts.lang <= IDLOptions::kMAX); - const auto &lang = GetLangParams(parser.opts.lang); - - std::string make_rule; - - for (auto it = parser.enums_.vec.begin(); it != parser.enums_.vec.end(); - ++it) { - auto &enum_def = **it; - if (make_rule != "") make_rule += " "; - std::string directory = - BaseGenerator::NamespaceDir(parser, path, *enum_def.defined_namespace); - make_rule += directory + enum_def.name + lang.file_extension; - } - - for (auto it = parser.structs_.vec.begin(); it != parser.structs_.vec.end(); - ++it) { - auto &struct_def = **it; - if (make_rule != "") make_rule += " "; - std::string directory = - BaseGenerator::NamespaceDir(parser, path, - *struct_def.defined_namespace); - make_rule += directory + struct_def.name + lang.file_extension; - } - - make_rule += ": "; - auto included_files = parser.GetIncludedFilesRecursive(file_name); - for (auto it = included_files.begin(); it != included_files.end(); ++it) { - make_rule += " " + *it; - } - return make_rule; -} - -std::string BinaryFileName(const Parser &parser, - const std::string &path, - const std::string &file_name) { - auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin"; - return path + file_name + "." + ext; -} - -bool GenerateBinary(const Parser &parser, - const std::string &path, - const std::string &file_name) { - return !parser.builder_.GetSize() || - flatbuffers::SaveFile( - BinaryFileName(parser, path, file_name).c_str(), - reinterpret_cast<char *>(parser.builder_.GetBufferPointer()), - parser.builder_.GetSize(), - true); -} - -std::string BinaryMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name) { - if (!parser.builder_.GetSize()) return ""; - std::string filebase = flatbuffers::StripPath( - flatbuffers::StripExtension(file_name)); - std::string make_rule = BinaryFileName(parser, path, filebase) + ": " + - file_name; - auto included_files = parser.GetIncludedFilesRecursive( - parser.root_struct_def_->file); - for (auto it = included_files.begin(); - it != included_files.end(); ++it) { - make_rule += " " + *it; - } - return make_rule; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_go.cpp b/third_party/flatbuffers/src/idl_gen_go.cpp deleted file mode 100644 index 58a60aa..0000000 --- a/third_party/flatbuffers/src/idl_gen_go.cpp +++ /dev/null
@@ -1,809 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include <string> -#include <sstream> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -#ifdef _WIN32 -#include <direct.h> -#define PATH_SEPARATOR "\\" -#define mkdir(n, m) _mkdir(n) -#else -#include <sys/stat.h> -#define PATH_SEPARATOR "/" -#endif - -namespace flatbuffers { -namespace go { - -// see https://golang.org/ref/spec#Keywords -static const char *g_golang_keywords[] = { - "break", "default", "func", "interface", "select", "case", "defer", "go", - "map", "struct", "chan", "else", "goto", "package", "switch", "const", - "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", -}; - -static std::string GenGetter(const Type &type); -static std::string GenMethod(const FieldDef &field); -static void GenStructBuilder(const StructDef &struct_def, - std::string *code_ptr); -static void GenReceiver(const StructDef &struct_def, std::string *code_ptr); -static std::string GenTypeBasic(const Type &type); -static std::string GenTypeGet(const Type &type); -static std::string TypeName(const FieldDef &field); -static std::string GoIdentity(const std::string& name) { - for (size_t i=0; i<sizeof(g_golang_keywords)/sizeof(g_golang_keywords[0]); i++) { - if (name == g_golang_keywords[i]) { - return MakeCamel(name + "_", false); - } - } - - return MakeCamel(name, false); -} - - -// Most field accessors need to retrieve and test the field offset first, -// this is the prefix code for that. -std::string OffsetPrefix(const FieldDef &field) { - return "{\n\to := flatbuffers.UOffsetT(rcv._tab.Offset(" + - NumToString(field.value.offset) + - "))\n\tif o != 0 {\n"; -} - -// Begin a class declaration. -static void BeginClass(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - - code += "type " + struct_def.name + " struct {\n\t"; - - // _ is reserved in flatbuffers field names, so no chance of name conflict: - code += "_tab "; - code += struct_def.fixed ? "flatbuffers.Struct" : "flatbuffers.Table"; - code += "\n}\n\n"; -} - -// Begin enum code with a class declaration. -static void BeginEnum(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "const (\n"; -} - -// A single enum member. -static void EnumMember(const EnumDef &enum_def, const EnumVal ev, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\t"; - code += enum_def.name; - code += ev.name; - code += " = "; - code += NumToString(ev.value) + "\n"; -} - -// End enum code. -static void EndEnum(std::string *code_ptr) { - std::string &code = *code_ptr; - code += ")\n\n"; -} - -// Begin enum name code. -static void BeginEnumNames(const EnumDef &enum_def, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "var EnumNames"; - code += enum_def.name; - code += " = map[int]string{\n"; -} - -// A single enum name member. -static void EnumNameMember(const EnumDef &enum_def, const EnumVal ev, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\t"; - code += enum_def.name; - code += ev.name; - code += ":\""; - code += ev.name; - code += "\",\n"; -} - -// End enum name code. -static void EndEnumNames(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "}\n\n"; -} - -// Initialize a new struct or table from existing data. -static void NewRootTypeFromBuffer(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += "func GetRootAs"; - code += struct_def.name; - code += "(buf []byte, offset flatbuffers.UOffsetT) "; - code += "*" + struct_def.name + ""; - code += " {\n"; - code += "\tn := flatbuffers.GetUOffsetT(buf[offset:])\n"; - code += "\tx := &" + struct_def.name + "{}\n"; - code += "\tx.Init(buf, n+offset)\n"; - code += "\treturn x\n"; - code += "}\n\n"; -} - -// Initialize an existing object with other data, to avoid an allocation. -static void InitializeExisting(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += " Init(buf []byte, i flatbuffers.UOffsetT) "; - code += "{\n"; - code += "\trcv._tab.Bytes = buf\n"; - code += "\trcv._tab.Pos = i\n"; - code += "}\n\n"; -} - -// Implement the table accessor -static void GenTableAccessor(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += " Table() flatbuffers.Table "; - code += "{\n"; - - if (struct_def.fixed) { - code += "\treturn rcv._tab.Table\n"; - } else { - code += "\treturn rcv._tab\n"; - } - code += "}\n\n"; -} - -// Get the length of a vector. -static void GetVectorLen(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name) + "Length("; - code += ") int " + OffsetPrefix(field); - code += "\t\treturn rcv._tab.VectorLen(o)\n\t}\n"; - code += "\treturn 0\n}\n\n"; -} - -// Get a [ubyte] vector as a byte slice. -static void GetUByteSlice(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name) + "Bytes("; - code += ") []byte " + OffsetPrefix(field); - code += "\t\treturn rcv._tab.ByteVector(o + rcv._tab.Pos)\n\t}\n"; - code += "\treturn nil\n}\n\n"; -} - -// Get the value of a struct's scalar. -static void GetScalarFieldOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "() " + TypeName(field) + " {\n"; - code +="\treturn " + getter; - code += "(rcv._tab.Pos + flatbuffers.UOffsetT("; - code += NumToString(field.value.offset) + "))\n}\n"; -} - -// Get the value of a table's scalar. -static void GetScalarFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "() " + TypeName(field) + " "; - code += OffsetPrefix(field) + "\t\treturn " + getter; - code += "(o + rcv._tab.Pos)\n\t}\n"; - code += "\treturn " + field.value.constant + "\n"; - code += "}\n\n"; -} - -// Get a struct by initializing an existing struct. -// Specific to Struct. -static void GetStructFieldOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "(obj *" + TypeName(field); - code += ") *" + TypeName(field); - code += " {\n"; - code += "\tif obj == nil {\n"; - code += "\t\tobj = new(" + TypeName(field) + ")\n"; - code += "\t}\n"; - code += "\tobj.Init(rcv._tab.Bytes, rcv._tab.Pos+"; - code += NumToString(field.value.offset) + ")"; - code += "\n\treturn obj\n"; - code += "}\n"; -} - -// Get a struct by initializing an existing struct. -// Specific to Table. -static void GetStructFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "(obj *"; - code += TypeName(field); - code += ") *" + TypeName(field) + " " + OffsetPrefix(field); - if (field.value.type.struct_def->fixed) { - code += "\t\tx := o + rcv._tab.Pos\n"; - } else { - code += "\t\tx := rcv._tab.Indirect(o + rcv._tab.Pos)\n"; - } - code += "\t\tif obj == nil {\n"; - code += "\t\t\tobj = new(" + TypeName(field) + ")\n"; - code += "\t\t}\n"; - code += "\t\tobj.Init(rcv._tab.Bytes, x)\n"; - code += "\t\treturn obj\n\t}\n\treturn nil\n"; - code += "}\n\n"; -} - -// Get the value of a string. -static void GetStringField(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "() " + TypeName(field) + " "; - code += OffsetPrefix(field) + "\t\treturn " + GenGetter(field.value.type); - code += "(o + rcv._tab.Pos)\n\t}\n\treturn nil\n"; - code += "}\n\n"; -} - -// Get the value of a union from an object. -static void GetUnionField(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name) + "("; - code += "obj " + TypeName(field) + ") bool "; - code += OffsetPrefix(field); - code += "\t\t" + GenGetter(field.value.type); - code += "(obj, o)\n\t\treturn true\n\t}\n"; - code += "\treturn false\n"; - code += "}\n\n"; -} - -// Get the value of a vector's struct member. -static void GetMemberOfVectorOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "(obj *" + TypeName(field); - code += ", j int) bool " + OffsetPrefix(field); - code += "\t\tx := rcv._tab.Vector(o)\n"; - code += "\t\tx += flatbuffers.UOffsetT(j) * "; - code += NumToString(InlineSize(vectortype)) + "\n"; - if (!(vectortype.struct_def->fixed)) { - code += "\t\tx = rcv._tab.Indirect(x)\n"; - } - code += "\t\tobj.Init(rcv._tab.Bytes, x)\n"; - code += "\t\treturn true\n\t}\n"; - code += "\treturn false\n"; - code += "}\n\n"; -} - -// Get the value of a vector's non-struct member. Uses a named return -// argument to conveniently set the zero value for the result. -static void GetMemberOfVectorOfNonStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - GenReceiver(struct_def, code_ptr); - code += " " + MakeCamel(field.name); - code += "(j int) " + TypeName(field) + " "; - code += OffsetPrefix(field); - code += "\t\ta := rcv._tab.Vector(o)\n"; - code += "\t\treturn " + GenGetter(field.value.type) + "("; - code += "a + flatbuffers.UOffsetT(j*"; - code += NumToString(InlineSize(vectortype)) + "))\n"; - code += "\t}\n"; - if (vectortype.base_type == BASE_TYPE_STRING) { - code += "\treturn nil\n"; - } else { - code += "\treturn 0\n"; - } - code += "}\n\n"; -} - -// Begin the creator function signature. -static void BeginBuilderArgs(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - if (code.substr(code.length() - 2) != "\n\n") { - // a previous mutate has not put an extra new line - code += "\n"; - } - code += "func Create" + struct_def.name; - code += "(builder *flatbuffers.Builder"; -} - -// Recursively generate arguments for a constructor, to deal with nested -// structs. -static void StructBuilderArgs(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious these arguments are constructing - // a nested struct, prefix the name with the field name. - StructBuilderArgs(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - std::string &code = *code_ptr; - code += (std::string)", " + nameprefix; - code += GoIdentity(field.name); - code += " " + GenTypeBasic(field.value.type); - } - } -} - -// End the creator function signature. -static void EndBuilderArgs(std::string *code_ptr) { - std::string &code = *code_ptr; - code += ") flatbuffers.UOffsetT {\n"; -} - -// Recursively generate struct construction statements and instert manual -// padding. -static void StructBuilderBody(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\tbuilder.Prep(" + NumToString(struct_def.minalign) + ", "; - code += NumToString(struct_def.bytesize) + ")\n"; - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); - ++it) { - auto &field = **it; - if (field.padding) - code += "\tbuilder.Pad(" + NumToString(field.padding) + ")\n"; - if (IsStruct(field.value.type)) { - StructBuilderBody(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - code += "\tbuilder.Prepend" + GenMethod(field) + "("; - code += nameprefix + GoIdentity(field.name) + ")\n"; - } - } -} - -static void EndBuilderBody(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\treturn builder.Offset()\n"; - code += "}\n"; -} - -// Get the value of a table's starting offset. -static void GetStartOfTable(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "func " + struct_def.name + "Start"; - code += "(builder *flatbuffers.Builder) {\n"; - code += "\tbuilder.StartObject("; - code += NumToString(struct_def.fields.vec.size()); - code += ")\n}\n"; -} - -// Set the value of a table's field. -static void BuildFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - const size_t offset, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "func " + struct_def.name + "Add" + MakeCamel(field.name); - code += "(builder *flatbuffers.Builder, "; - code += GoIdentity(field.name) + " "; - if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) { - code += "flatbuffers.UOffsetT"; - } else { - code += GenTypeBasic(field.value.type); - } - code += ") {\n"; - code += "\tbuilder.Prepend"; - code += GenMethod(field) + "Slot("; - code += NumToString(offset) + ", "; - if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) { - code += "flatbuffers.UOffsetT"; - code += "("; - code += GoIdentity(field.name) + ")"; - } else { - code += GoIdentity(field.name); - } - code += ", " + field.value.constant; - code += ")\n}\n"; -} - -// Set the value of one of the members of a table's vector. -static void BuildVectorOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "func " + struct_def.name + "Start"; - code += MakeCamel(field.name); - code += "Vector(builder *flatbuffers.Builder, numElems int) "; - code += "flatbuffers.UOffsetT {\n\treturn builder.StartVector("; - auto vector_type = field.value.type.VectorType(); - auto alignment = InlineAlignment(vector_type); - auto elem_size = InlineSize(vector_type); - code += NumToString(elem_size); - code += ", numElems, " + NumToString(alignment); - code += ")\n}\n"; -} - -// Get the offset of the end of a table. -static void GetEndOffsetOnTable(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "func " + struct_def.name + "End"; - code += "(builder *flatbuffers.Builder) flatbuffers.UOffsetT "; - code += "{\n\treturn builder.EndObject()\n}\n"; -} - -// Generate the receiver for function signatures. -static void GenReceiver(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "func (rcv *" + struct_def.name + ")"; -} - -// Generate a struct field getter, conditioned on its child type(s). -static void GenStructAccessor(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - GenComment(field.doc_comment, code_ptr, nullptr, ""); - if (IsScalar(field.value.type.base_type)) { - if (struct_def.fixed) { - GetScalarFieldOfStruct(struct_def, field, code_ptr); - } else { - GetScalarFieldOfTable(struct_def, field, code_ptr); - } - } else { - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: - if (struct_def.fixed) { - GetStructFieldOfStruct(struct_def, field, code_ptr); - } else { - GetStructFieldOfTable(struct_def, field, code_ptr); - } - break; - case BASE_TYPE_STRING: - GetStringField(struct_def, field, code_ptr); - break; - case BASE_TYPE_VECTOR: { - auto vectortype = field.value.type.VectorType(); - if (vectortype.base_type == BASE_TYPE_STRUCT) { - GetMemberOfVectorOfStruct(struct_def, field, code_ptr); - } else { - GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr); - } - break; - } - case BASE_TYPE_UNION: - GetUnionField(struct_def, field, code_ptr); - break; - default: - assert(0); - } - } - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - GetVectorLen(struct_def, field, code_ptr); - if (field.value.type.element == BASE_TYPE_UCHAR) { - GetUByteSlice(struct_def, field, code_ptr); - } - } -} - -// Mutate the value of a struct's scalar. -static void MutateScalarFieldOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string type = MakeCamel(GenTypeBasic(field.value.type)); - std::string setter = "rcv._tab.Mutate" + type; - GenReceiver(struct_def, code_ptr); - code += " Mutate" + MakeCamel(field.name); - code += "(n " + TypeName(field) + ") bool {\n\treturn " + setter; - code += "(rcv._tab.Pos+flatbuffers.UOffsetT("; - code += NumToString(field.value.offset) + "), n)\n}\n\n"; -} - -// Mutate the value of a table's scalar. -static void MutateScalarFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string type = MakeCamel(GenTypeBasic(field.value.type)); - std::string setter = "rcv._tab.Mutate" + type + "Slot"; - GenReceiver(struct_def, code_ptr); - code += " Mutate" + MakeCamel(field.name); - code += "(n " + TypeName(field) + ") bool {\n\treturn "; - code += setter + "(" + NumToString(field.value.offset) + ", n)\n"; - code += "}\n\n"; -} - -// Generate a struct field setter, conditioned on its child type(s). -static void GenStructMutator(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - GenComment(field.doc_comment, code_ptr, nullptr, ""); - if (IsScalar(field.value.type.base_type)) { - if (struct_def.fixed) { - MutateScalarFieldOfStruct(struct_def, field, code_ptr); - } else { - MutateScalarFieldOfTable(struct_def, field, code_ptr); - } - } -} - -// Generate table constructors, conditioned on its members' types. -static void GenTableBuilders(const StructDef &struct_def, - std::string *code_ptr) { - GetStartOfTable(struct_def, code_ptr); - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - auto offset = it - struct_def.fields.vec.begin(); - BuildFieldOfTable(struct_def, field, offset, code_ptr); - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - BuildVectorOfTable(struct_def, field, code_ptr); - } - } - - GetEndOffsetOnTable(struct_def, code_ptr); -} - -// Generate struct or table methods. -static void GenStruct(const StructDef &struct_def, - std::string *code_ptr) { - if (struct_def.generated) return; - - GenComment(struct_def.doc_comment, code_ptr, nullptr); - BeginClass(struct_def, code_ptr); - if (!struct_def.fixed) { - // Generate a special accessor for the table that has been declared as - // the root type. - NewRootTypeFromBuffer(struct_def, code_ptr); - } - // Generate the Init method that sets the field in a pre-existing - // accessor object. This is to allow object reuse. - InitializeExisting(struct_def, code_ptr); - // Generate _tab accessor - GenTableAccessor(struct_def, code_ptr); - - // Generate struct fields accessors - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - GenStructAccessor(struct_def, field, code_ptr); - GenStructMutator(struct_def, field, code_ptr); - } - - // Generate builders - if (struct_def.fixed) { - // create a struct constructor function - GenStructBuilder(struct_def, code_ptr); - } else { - // Create a set of functions that allow table construction. - GenTableBuilders(struct_def, code_ptr); - } -} - -// Generate enum declarations. -static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) { - if (enum_def.generated) return; - - GenComment(enum_def.doc_comment, code_ptr, nullptr); - BeginEnum(code_ptr); - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - GenComment(ev.doc_comment, code_ptr, nullptr, "\t"); - EnumMember(enum_def, ev, code_ptr); - } - EndEnum(code_ptr); - - BeginEnumNames(enum_def, code_ptr); - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - EnumNameMember(enum_def, ev, code_ptr); - } - EndEnumNames(code_ptr); -} - -// Returns the function name that is able to read a value of the given type. -static std::string GenGetter(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: return "rcv._tab.ByteVector"; - case BASE_TYPE_UNION: return "rcv._tab.Union"; - case BASE_TYPE_VECTOR: return GenGetter(type.VectorType()); - default: - return "rcv._tab.Get" + MakeCamel(GenTypeGet(type)); - } -} - -// Returns the method name for use with add/put calls. -static std::string GenMethod(const FieldDef &field) { - return IsScalar(field.value.type.base_type) - ? MakeCamel(GenTypeBasic(field.value.type)) - : (IsStruct(field.value.type) ? "Struct" : "UOffsetT"); -} - -static std::string GenTypeBasic(const Type &type) { - static const char *ctypename[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #GTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - return ctypename[type.base_type]; -} - -static std::string GenTypePointer(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: - return "[]byte"; - case BASE_TYPE_VECTOR: - return GenTypeGet(type.VectorType()); - case BASE_TYPE_STRUCT: - return type.struct_def->name; - case BASE_TYPE_UNION: - // fall through - default: - return "*flatbuffers.Table"; - } -} - -static std::string GenTypeGet(const Type &type) { - return IsScalar(type.base_type) - ? GenTypeBasic(type) - : GenTypePointer(type); -} - -static std::string TypeName(const FieldDef &field) { - return GenTypeGet(field.value.type); -} - -// Create a struct with a builder and the struct's arguments. -static void GenStructBuilder(const StructDef &struct_def, - std::string *code_ptr) { - BeginBuilderArgs(struct_def, code_ptr); - StructBuilderArgs(struct_def, "", code_ptr); - EndBuilderArgs(code_ptr); - - StructBuilderBody(struct_def, "", code_ptr); - EndBuilderBody(code_ptr); -} - -class GoGenerator : public BaseGenerator { - public: - GoGenerator(const Parser &parser, const std::string &path, - const std::string &file_name, const std::string &go_namespace) - : BaseGenerator(parser, path, file_name, "" /* not used*/, "" /* not used */) { - std::istringstream iss(go_namespace); - std::string component; - while (std::getline(iss, component, '.')) { - go_namespace_.components.push_back(component); - } - } - - bool generate() { - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - std::string enumcode; - go::GenEnum(**it, &enumcode); - if (!SaveType(**it, enumcode, false)) return false; - } - - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - std::string declcode; - go::GenStruct(**it, &declcode); - if (!SaveType(**it, declcode, true)) return false; - } - - return true; - } - - private: - // Begin by declaring namespace and imports. - void BeginFile(const std::string name_space_name, const bool needs_imports, - std::string *code_ptr) { - std::string &code = *code_ptr; - code = code + "// " + FlatBuffersGeneratedWarning(); - code += "package " + name_space_name + "\n\n"; - if (needs_imports) { - code += "import (\n"; - code += "\tflatbuffers \"github.com/google/flatbuffers/go\"\n"; - code += ")\n\n"; - } - } - - // Save out the generated code for a Go Table type. - bool SaveType(const Definition &def, const std::string &classcode, - bool needs_imports) { - if (!classcode.length()) return true; - - Namespace& ns = go_namespace_.components.empty() ? *def.defined_namespace : go_namespace_; - std::string code = ""; - BeginFile(LastNamespacePart(ns), needs_imports, &code); - code += classcode; - std::string filename = - NamespaceDir(ns) + def.name + ".go"; - return SaveFile(filename.c_str(), code, false); - } - - Namespace go_namespace_; -}; -} // namespace go - -bool GenerateGo(const Parser &parser, const std::string &path, - const std::string &file_name) { - go::GoGenerator generator(parser, path, file_name, parser.opts.go_namespace); - return generator.generate(); -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_grpc.cpp b/third_party/flatbuffers/src/idl_gen_grpc.cpp deleted file mode 100644 index 2daeac9..0000000 --- a/third_party/flatbuffers/src/idl_gen_grpc.cpp +++ /dev/null
@@ -1,280 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -#include "src/compiler/cpp_generator.h" -#include "src/compiler/go_generator.h" - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4512) // C4512: 'class' : assignment operator could not be generated -#endif - -namespace flatbuffers { - -class FlatBufMethod : public grpc_generator::Method { - public: - enum Streaming { kNone, kClient, kServer, kBiDi }; - - FlatBufMethod(const RPCCall *method) - : method_(method) { - streaming_ = kNone; - auto val = method_->attributes.Lookup("streaming"); - if (val) { - if (val->constant == "client") streaming_ = kClient; - if (val->constant == "server") streaming_ = kServer; - if (val->constant == "bidi") streaming_ = kBiDi; - } - } - - std::string name() const { return method_->name; } - - std::string GRPCType(const StructDef &sd) const { - return "flatbuffers::BufferRef<" + sd.name + ">"; - } - - std::string input_type_name() const { - return GRPCType(*method_->request); - } - std::string output_type_name() const { - return GRPCType(*method_->response); - } - - std::string input_name() const { - return (*method_->request).name; - } - - std::string output_name() const { - return (*method_->response).name; - } - - bool NoStreaming() const { return streaming_ == kNone; } - bool ClientOnlyStreaming() const { return streaming_ == kClient; } - bool ServerOnlyStreaming() const { return streaming_ == kServer; } - bool BidiStreaming() const { return streaming_ == kBiDi; } - - private: - const RPCCall *method_; - Streaming streaming_; -}; - -class FlatBufService : public grpc_generator::Service { - public: - FlatBufService(const ServiceDef *service) : service_(service) {} - - std::string name() const { return service_->name; } - - int method_count() const { - return static_cast<int>(service_->calls.vec.size()); - }; - - std::unique_ptr<const grpc_generator::Method> method(int i) const { - return std::unique_ptr<const grpc_generator::Method>( - new FlatBufMethod(service_->calls.vec[i])); - }; - - private: - const ServiceDef *service_; -}; - -class FlatBufPrinter : public grpc_generator::Printer { - public: - FlatBufPrinter(std::string *str) - : str_(str), escape_char_('$'), indent_(0) {} - - void Print(const std::map<std::string, std::string> &vars, - const char *string_template) { - std::string s = string_template; - // Replace any occurrences of strings in "vars" that are surrounded - // by the escape character by what they're mapped to. - size_t pos; - while ((pos = s.find(escape_char_)) != std::string::npos) { - // Found an escape char, must also find the closing one. - size_t pos2 = s.find(escape_char_, pos + 1); - // If placeholder not closed, ignore. - if (pos2 == std::string::npos) break; - auto it = vars.find(s.substr(pos + 1, pos2 - pos - 1)); - // If unknown placeholder, ignore. - if (it == vars.end()) break; - // Subtitute placeholder. - s.replace(pos, pos2 - pos + 1, it->second); - } - Print(s.c_str()); - } - - void Print(const char *s) { - // Add this string, but for each part separated by \n, add indentation. - for (;;) { - // Current indentation. - str_->insert(str_->end(), indent_ * 2, ' '); - // See if this contains more than one line. - const char * lf = strchr(s, '\n'); - if (lf) { - (*str_) += std::string(s, lf + 1); - s = lf + 1; - if (!*s) break; // Only continue if there's more lines. - } else { - (*str_) += s; - break; - } - } - } - - void Indent() { indent_++; } - void Outdent() { indent_--; assert(indent_ >= 0); } - - private: - std::string *str_; - char escape_char_; - int indent_; -}; - -class FlatBufFile : public grpc_generator::File { - public: - FlatBufFile(const Parser &parser, const std::string &file_name) - : parser_(parser), file_name_(file_name) {} - FlatBufFile &operator=(const FlatBufFile &); - - std::string filename() const { return file_name_; } - std::string filename_without_ext() const { - return StripExtension(file_name_); - } - - std::string message_header_ext() const { return "_generated.h"; } - std::string service_header_ext() const { return ".grpc.fb.h"; } - - std::string package() const { - return parser_.namespaces_.back()->GetFullyQualifiedName(""); - } - - std::vector<std::string> package_parts() const { - return parser_.namespaces_.back()->components; - } - - std::string additional_headers() const { - return "#include \"flatbuffers/grpc.h\"\n"; - } - - std::string additional_imports() const { - return "import \"github.com/google/flatbuffers/go\""; - } - - int service_count() const { - return static_cast<int>(parser_.services_.vec.size()); - }; - - std::unique_ptr<const grpc_generator::Service> service(int i) const { - return std::unique_ptr<const grpc_generator::Service> ( - new FlatBufService(parser_.services_.vec[i])); - } - - std::unique_ptr<grpc_generator::Printer> CreatePrinter(std::string *str) const { - return std::unique_ptr<grpc_generator::Printer>( - new FlatBufPrinter(str)); - } - - private: - const Parser &parser_; - const std::string &file_name_; -}; - -class GoGRPCGenerator : public flatbuffers::BaseGenerator { - public: - GoGRPCGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "", "" /*Unused*/), - parser_(parser), path_(path), file_name_(file_name) {} - - bool generate() { - FlatBufFile file(parser_, file_name_); - grpc_go_generator::Parameters p; - p.custom_method_io_type = "flatbuffers.Builder"; - for (int i = 0; i < file.service_count(); i++) { - auto service = file.service(i); - const Definition *def = parser_.services_.vec[i]; - p.package_name = LastNamespacePart(*(def->defined_namespace)); - std::string output = grpc_go_generator::GenerateServiceSource(&file, service.get(), &p); - std::string filename = NamespaceDir(*def->defined_namespace) + def->name + "_grpc.go"; - if (!flatbuffers::SaveFile(filename.c_str(), output, false)) - return false; - } - return true; - } - - protected: - const Parser &parser_; - const std::string &path_, &file_name_; -}; - -bool GenerateGoGRPC(const Parser &parser, - const std::string &path, - const std::string &file_name) { - int nservices = 0; - for (auto it = parser.services_.vec.begin(); - it != parser.services_.vec.end(); ++it) { - if (!(*it)->generated) nservices++; - } - if (!nservices) return true; - return GoGRPCGenerator(parser, path, file_name).generate(); -} - -bool GenerateCppGRPC(const Parser &parser, - const std::string &path, - const std::string &file_name) { - - int nservices = 0; - for (auto it = parser.services_.vec.begin(); - it != parser.services_.vec.end(); ++it) { - if (!(*it)->generated) nservices++; - } - if (!nservices) return true; - - grpc_cpp_generator::Parameters generator_parameters; - // TODO(wvo): make the other parameters in this struct configurable. - generator_parameters.use_system_headers = true; - - FlatBufFile fbfile(parser, file_name); - - std::string header_code = - grpc_cpp_generator::GetHeaderPrologue(&fbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderIncludes(&fbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderServices(&fbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderEpilogue(&fbfile, generator_parameters); - - std::string source_code = - grpc_cpp_generator::GetSourcePrologue(&fbfile, generator_parameters) + - grpc_cpp_generator::GetSourceIncludes(&fbfile, generator_parameters) + - grpc_cpp_generator::GetSourceServices(&fbfile, generator_parameters) + - grpc_cpp_generator::GetSourceEpilogue(&fbfile, generator_parameters); - - return flatbuffers::SaveFile((path + file_name + ".grpc.fb.h").c_str(), - header_code, false) && - flatbuffers::SaveFile((path + file_name + ".grpc.fb.cc").c_str(), - source_code, false); -} - -} // namespace flatbuffers - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif -
diff --git a/third_party/flatbuffers/src/idl_gen_js.cpp b/third_party/flatbuffers/src/idl_gen_js.cpp deleted file mode 100644 index b2839e1..0000000 --- a/third_party/flatbuffers/src/idl_gen_js.cpp +++ /dev/null
@@ -1,1170 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients -#include <unordered_set> -#include <unordered_map> -#include <cassert> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -namespace flatbuffers { - -const std::string kGeneratedFileNamePostfix = "_generated"; - -struct JsLanguageParameters { - IDLOptions::Language language; - std::string file_extension; -}; - -struct ReexportDescription { - std::string symbol; - std::string source_namespace; - std::string target_namespace; -}; - -const JsLanguageParameters& GetJsLangParams(IDLOptions::Language lang) { - static JsLanguageParameters js_language_parameters[] = { - { - IDLOptions::kJs, - ".js", - }, - { - IDLOptions::kTs, - ".ts", - }, - }; - - if (lang == IDLOptions::kJs) { - return js_language_parameters[0]; - } else { - assert(lang == IDLOptions::kTs); - return js_language_parameters[1]; - } -} - -static std::string GeneratedFileName(const std::string &path, - const std::string &file_name, - const JsLanguageParameters &lang) { - return path + file_name + kGeneratedFileNamePostfix + lang.file_extension; -} - -namespace js { -// Iterate through all definitions we haven't generate code for (enums, structs, -// and tables) and output them to a single file. -class JsGenerator : public BaseGenerator { - public: - typedef std::unordered_set<std::string> imported_fileset; - typedef std::unordered_multimap<std::string, ReexportDescription> - reexport_map; - - JsGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "", "."), - lang_(GetJsLangParams(parser_.opts.lang)) - { - }; - // Iterate through all definitions we haven't generate code for (enums, - // structs, and tables) and output them to a single file. - bool generate() { - if (IsEverythingGenerated()) return true; - - imported_fileset imported_files; - reexport_map reexports; - - std::string enum_code, struct_code, import_code, exports_code, code; - generateEnums(&enum_code, &exports_code, reexports); - generateStructs(&struct_code, &exports_code, imported_files); - generateImportDependencies(&import_code, imported_files); - generateReexports(&import_code, reexports, imported_files); - - code = code + "// " + FlatBuffersGeneratedWarning(); - - // Generate code for all the namespace declarations. - GenNamespaces(&code, &exports_code); - - // Output the main declaration code from above. - code += import_code; - - code += enum_code; - code += struct_code; - - if (lang_.language == IDLOptions::kJs && !exports_code.empty() && - !parser_.opts.skip_js_exports) { - code += "// Exports for Node.js and RequireJS\n"; - code += exports_code; - } - - return SaveFile(GeneratedFileName(path_, file_name_, lang_).c_str(), code, - false); - } - - private: - JsLanguageParameters lang_; - - // Generate code for imports - void generateImportDependencies(std::string *code_ptr, - const imported_fileset &imported_files) { - std::string &code = *code_ptr; - for (auto it = imported_files.begin(); it != imported_files.end(); ++it) { - const auto &file = *it; - const auto basename = - flatbuffers::StripPath(flatbuffers::StripExtension(file)); - if (basename != file_name_) { - const auto file_name = basename + kGeneratedFileNamePostfix; - code += GenPrefixedImport(file, file_name); - } - } - } - - // Generate reexports, which might not have been explicitly imported using the - // "export import" trick - void generateReexports(std::string *code_ptr, - const reexport_map &reexports, - imported_fileset imported_files) { - if (!parser_.opts.reexport_ts_modules || - lang_.language != IDLOptions::kTs) { - return; - } - - std::string &code = *code_ptr; - for (auto it = reexports.begin(); it != reexports.end(); ++it) { - const auto &file = *it; - const auto basename = - flatbuffers::StripPath(flatbuffers::StripExtension(file.first)); - if (basename != file_name_) { - const auto file_name = basename + kGeneratedFileNamePostfix; - - if (imported_files.find(file.first) == imported_files.end()) { - code += GenPrefixedImport(file.first, file_name); - imported_files.emplace(file.first); - } - - code += "export namespace " + file.second.target_namespace + " { \n"; - code += "export import " + file.second.symbol + " = "; - code += GenFileNamespacePrefix(file.first) + "." + - file.second.source_namespace + "." + file.second.symbol + - "; }\n"; - } - } - } - - // Generate code for all enums. - void generateEnums(std::string *enum_code_ptr, - std::string *exports_code_ptr, - reexport_map &reexports) { - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - auto &enum_def = **it; - GenEnum(enum_def, enum_code_ptr, exports_code_ptr, reexports); - } - } - - // Generate code for all structs. - void generateStructs(std::string *decl_code_ptr, - std::string *exports_code_ptr, - imported_fileset &imported_files) { - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - auto &struct_def = **it; - GenStruct(parser_, struct_def, decl_code_ptr, exports_code_ptr, - imported_files); - } - } - void GenNamespaces(std::string *code_ptr, std::string *exports_ptr) { - if (lang_.language == IDLOptions::kTs && - parser_.opts.skip_flatbuffers_import) { - return; - } - - std::set<std::string> namespaces; - - for (auto it = parser_.namespaces_.begin(); - it != parser_.namespaces_.end(); ++it) { - std::string namespace_so_far; - - // Gather all parent namespaces for this namespace - for (auto component = (*it)->components.begin(); - component != (*it)->components.end(); ++component) { - if (!namespace_so_far.empty()) { - namespace_so_far += '.'; - } - namespace_so_far += *component; - namespaces.insert(namespace_so_far); - } - } - - // Make sure parent namespaces come before child namespaces - std::vector<std::string> sorted_namespaces( - namespaces.begin(), namespaces.end()); - std::sort(sorted_namespaces.begin(), sorted_namespaces.end()); - - // Emit namespaces in a form that Closure Compiler can optimize - std::string &code = *code_ptr; - std::string &exports = *exports_ptr; - for (auto it = sorted_namespaces.begin(); - it != sorted_namespaces.end(); it++) { - if (lang_.language == IDLOptions::kTs) { - if (it->find('.') == std::string::npos) { - code += "import { flatbuffers } from \"./flatbuffers\"\n"; - break; - } - } else { - code += "/**\n * @const\n * @namespace\n */\n"; - if (it->find('.') == std::string::npos) { - code += "var "; - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportSymbol('" + *it + "', " + *it + ");\n"; - } else { - exports += "this." + *it + " = " + *it + ";\n"; - } - } - code += *it + " = " + *it + " || {};\n\n"; - } - } -} - -// Generate a documentation comment, if available. -static void GenDocComment(const std::vector<std::string> &dc, - std::string *code_ptr, - const std::string &extra_lines, - const char *indent = nullptr) { - if (dc.empty() && extra_lines.empty()) { - // Don't output empty comment blocks with 0 lines of comment content. - return; - } - - std::string &code = *code_ptr; - if (indent) code += indent; - code += "/**\n"; - for (auto it = dc.begin(); it != dc.end(); ++it) { - if (indent) code += indent; - code += " *" + *it + "\n"; - } - if (!extra_lines.empty()) { - if (!dc.empty()) { - if (indent) code += indent; - code += " *\n"; - } - if (indent) code += indent; - std::string::size_type start = 0; - for (;;) { - auto end = extra_lines.find('\n', start); - if (end != std::string::npos) { - code += " * " + extra_lines.substr(start, end - start) + "\n"; - start = end + 1; - } else { - code += " * " + extra_lines.substr(start) + "\n"; - break; - } - } - } - if (indent) code += indent; - code += " */\n"; -} - -static void GenDocComment(std::string *code_ptr, - const std::string &extra_lines) { - GenDocComment(std::vector<std::string>(), code_ptr, extra_lines); -} - -// Generate an enum declaration and an enum string lookup table. -void GenEnum(EnumDef &enum_def, std::string *code_ptr, - std::string *exports_ptr, reexport_map &reexports) { - if (enum_def.generated) return; - std::string &code = *code_ptr; - std::string &exports = *exports_ptr; - GenDocComment(enum_def.doc_comment, code_ptr, "@enum"); - if (lang_.language == IDLOptions::kTs) { - code += "export namespace " + GetNameSpace(enum_def) + "{\n" + - "export enum " + enum_def.name + "{\n"; - } else { - if (enum_def.defined_namespace->components.empty()) { - code += "var "; - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportSymbol('" + enum_def.name + "', " + - enum_def.name + ");\n"; - } else { - exports += "this." + enum_def.name + " = " + enum_def.name + ";\n"; - } - } - code += WrapInNameSpace(enum_def) + " = {\n"; - } - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); ++it) { - auto &ev = **it; - if (!ev.doc_comment.empty()) { - if (it != enum_def.vals.vec.begin()) { - code += '\n'; - } - GenDocComment(ev.doc_comment, code_ptr, "", " "); - } - code += " " + ev.name; - code += lang_.language == IDLOptions::kTs ? "= " : ": "; - code += NumToString(ev.value); - code += (it + 1) != enum_def.vals.vec.end() ? ",\n" : "\n"; - - if (ev.union_type.struct_def) { - ReexportDescription desc = { - ev.name, - GetNameSpace(*ev.union_type.struct_def), - GetNameSpace(enum_def) - }; - reexports.insert(std::make_pair(ev.union_type.struct_def->file, - std::move(desc))); - } - } - - if (lang_.language == IDLOptions::kTs) { - code += "}};\n\n"; - } else { - code += "};\n\n"; - } -} - -static std::string GenType(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_BOOL: - case BASE_TYPE_CHAR: return "Int8"; - case BASE_TYPE_UTYPE: - case BASE_TYPE_UCHAR: return "Uint8"; - case BASE_TYPE_SHORT: return "Int16"; - case BASE_TYPE_USHORT: return "Uint16"; - case BASE_TYPE_INT: return "Int32"; - case BASE_TYPE_UINT: return "Uint32"; - case BASE_TYPE_LONG: return "Int64"; - case BASE_TYPE_ULONG: return "Uint64"; - case BASE_TYPE_FLOAT: return "Float32"; - case BASE_TYPE_DOUBLE: return "Float64"; - case BASE_TYPE_STRING: return "String"; - case BASE_TYPE_VECTOR: return GenType(type.VectorType()); - case BASE_TYPE_STRUCT: return type.struct_def->name; - default: return "Table"; - } -} - -std::string GenGetter(const Type &type, const std::string &arguments) { - switch (type.base_type) { - case BASE_TYPE_STRING: return "this.bb.__string" + arguments; - case BASE_TYPE_STRUCT: return "this.bb.__struct" + arguments; - case BASE_TYPE_UNION: return "this.bb.__union" + arguments; - case BASE_TYPE_VECTOR: return GenGetter(type.VectorType(), arguments); - default: { - auto getter = "this.bb.read" + MakeCamel(GenType(type)) + arguments; - if (type.base_type == BASE_TYPE_BOOL) { - getter = "!!" + getter; - } - if (type.enum_def) { - getter = "/** @type {" + WrapInNameSpace(*type.enum_def) + "} */ (" + - getter + ")"; - } - return getter; - } - } -} - -std::string GenDefaultValue(const Value &value, const std::string &context) { - if (value.type.enum_def) { - if (auto val = value.type.enum_def->ReverseLookup( - atoi(value.constant.c_str()), false)) { - if (lang_.language == IDLOptions::kTs) { - return GenPrefixedTypeName(WrapInNameSpace(*value.type.enum_def), - value.type.enum_def->file) + "." + val->name; - } else { - return WrapInNameSpace(*value.type.enum_def) + "." + val->name; - } - } else { - return "/** @type {" + WrapInNameSpace(*value.type.enum_def) + "} */ (" - + value.constant + ")"; - } - } - - switch (value.type.base_type) { - case BASE_TYPE_BOOL: - return value.constant == "0" ? "false" : "true"; - - case BASE_TYPE_STRING: - return "null"; - - case BASE_TYPE_LONG: - case BASE_TYPE_ULONG: { - int64_t constant = StringToInt(value.constant.c_str()); - return context + ".createLong(" + NumToString((int32_t)constant) + - ", " + NumToString((int32_t)(constant >> 32)) + ")"; - } - - default: - return value.constant; - } -} - -std::string GenTypeName(const Type &type, bool input) { - if (!input) { - if (type.base_type == BASE_TYPE_STRING) { - return "string|Uint8Array"; - } - if (type.base_type == BASE_TYPE_STRUCT) { - return WrapInNameSpace(*type.struct_def); - } - } - - switch (type.base_type) { - case BASE_TYPE_BOOL: return "boolean"; - case BASE_TYPE_LONG: - case BASE_TYPE_ULONG: return "flatbuffers.Long"; - default: - if (IsScalar(type.base_type)) { - if (type.enum_def) { - return WrapInNameSpace(*type.enum_def); - } - return "number"; - } - return "flatbuffers.Offset"; - } -} - -// Returns the method name for use with add/put calls. -static std::string GenWriteMethod(const Type &type) { - // Forward to signed versions since unsigned versions don't exist - switch (type.base_type) { - case BASE_TYPE_UTYPE: - case BASE_TYPE_UCHAR: return GenWriteMethod(Type(BASE_TYPE_CHAR)); - case BASE_TYPE_USHORT: return GenWriteMethod(Type(BASE_TYPE_SHORT)); - case BASE_TYPE_UINT: return GenWriteMethod(Type(BASE_TYPE_INT)); - case BASE_TYPE_ULONG: return GenWriteMethod(Type(BASE_TYPE_LONG)); - default: break; - } - - return IsScalar(type.base_type) - ? MakeCamel(GenType(type)) - : (IsStruct(type) ? "Struct" : "Offset"); -} - -template <typename T> -static std::string MaybeAdd(T value) { - return value != 0 ? " + " + NumToString(value) : ""; -} - -template <typename T> -static std::string MaybeScale(T value) { - return value != 1 ? " * " + NumToString(value) : ""; -} - -static std::string GenFileNamespacePrefix(const std::string &file) { - return "NS" + std::to_string( - static_cast<unsigned long long>(std::hash<std::string>()(file))); -} - -static std::string GenPrefixedImport(const std::string &full_file_name, - const std::string &base_file_name) { - return "import * as "+ GenFileNamespacePrefix(full_file_name) + - " from \"./" + base_file_name + "\";\n"; -} - -// Adds a source-dependent prefix, for of import * statements. -std::string GenPrefixedTypeName(const std::string &typeName, - const std::string &file) { - const auto basename = - flatbuffers::StripPath(flatbuffers::StripExtension(file)); - if (basename == file_name_) { - return typeName; - } - return GenFileNamespacePrefix(file) + "." + typeName; -} - -void GenStructArgs(const StructDef &struct_def, - std::string *annotations, - std::string *arguments, - const std::string &nameprefix) { - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious these arguments are constructing - // a nested struct, prefix the name with the field name. - GenStructArgs(*field.value.type.struct_def, annotations, arguments, - nameprefix + field.name + "_"); - } else { - *annotations += "@param {" + GenTypeName(field.value.type, true); - *annotations += "} " + nameprefix + field.name + "\n"; - - if (lang_.language == IDLOptions::kTs) { - *arguments += ", " + nameprefix + field.name + ": " + - GenTypeName(field.value.type, true); - } else { - *arguments += ", " + nameprefix + field.name; - } - } - } -} - -static void GenStructBody(const StructDef &struct_def, - std::string *body, - const std::string &nameprefix) { - *body += " builder.prep("; - *body += NumToString(struct_def.minalign) + ", "; - *body += NumToString(struct_def.bytesize) + ");\n"; - - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); ++it) { - auto &field = **it; - if (field.padding) { - *body += " builder.pad(" + NumToString(field.padding) + ");\n"; - } - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious these arguments are constructing - // a nested struct, prefix the name with the field name. - GenStructBody(*field.value.type.struct_def, body, - nameprefix + field.name + "_"); - } else { - *body += " builder.write" + GenWriteMethod(field.value.type) + "("; - if (field.value.type.base_type == BASE_TYPE_BOOL) { - *body += "+"; - } - *body += nameprefix + field.name + ");\n"; - } - } -} - -// Generate an accessor struct with constructor for a flatbuffers struct. -void GenStruct(const Parser &parser, StructDef &struct_def, - std::string *code_ptr, std::string *exports_ptr, - imported_fileset &imported_files) { - if (struct_def.generated) return; - std::string &code = *code_ptr; - std::string &exports = *exports_ptr; - - std::string object_name; - - // Emit constructor - if (lang_.language == IDLOptions::kTs) { - object_name = struct_def.name; - std::string object_namespace = GetNameSpace(struct_def); - GenDocComment(struct_def.doc_comment, code_ptr, "@constructor"); - code += "export namespace " + object_namespace + "{\n"; - code += "export class " + struct_def.name; - code += " {\n"; - code += " /**\n"; - code += " * @type {flatbuffers.ByteBuffer}\n"; - code += " */\n"; - code += " bb: flatbuffers.ByteBuffer= null;\n"; - code += "\n"; - code += " /**\n"; - code += " * @type {number}\n"; - code += " */\n"; - code += " bb_pos:number = 0;\n"; - } else { - bool isStatement = struct_def.defined_namespace->components.empty(); - object_name = WrapInNameSpace(struct_def); - GenDocComment(struct_def.doc_comment, code_ptr, "@constructor"); - if (isStatement) { - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportSymbol('" + struct_def.name + "', " + - struct_def.name + ");\n"; - } else { - exports += "this." + struct_def.name + " = " + struct_def.name + ";\n"; - } - code += "function " + object_name; - } else { - code += object_name + " = function"; - } - code += "() {\n"; - code += " /**\n"; - code += " * @type {flatbuffers.ByteBuffer}\n"; - code += " */\n"; - code += " this.bb = null;\n"; - code += "\n"; - code += " /**\n"; - code += " * @type {number}\n"; - code += " */\n"; - code += " this.bb_pos = 0;\n"; - code += isStatement ? "}\n\n" : "};\n\n"; - } - - // Generate the __init method that sets the field in a pre-existing - // accessor object. This is to allow object reuse. - code += "/**\n"; - code += " * @param {number} i\n"; - code += " * @param {flatbuffers.ByteBuffer} bb\n"; - code += " * @returns {" + object_name + "}\n"; - code += " */\n"; - - if (lang_.language == IDLOptions::kTs) { - code += "__init(i:number, bb:flatbuffers.ByteBuffer):" + object_name + - " {\n"; - } else { - code += object_name + ".prototype.__init = function(i, bb) {\n"; - } - - code += " this.bb_pos = i;\n"; - code += " this.bb = bb;\n"; - code += " return this;\n"; - code += "};\n\n"; - - // Generate a special accessor for the table that when used as the root of a - // FlatBuffer - if (!struct_def.fixed) { - GenDocComment(code_ptr, - "@param {flatbuffers.ByteBuffer} bb\n" - "@param {" + object_name + "=} obj\n" - "@returns {" + object_name + "}"); - if (lang_.language == IDLOptions::kTs) { - code += "static getRootAs" + struct_def.name; - code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name + "):" + - object_name + " {\n"; - } else { - code += object_name + ".getRootAs" + struct_def.name; - code += " = function(bb, obj) {\n"; - } - code += " return (obj || new " + object_name; - code += ").__init(bb.readInt32(bb.position()) + bb.position(), bb);\n"; - code += "};\n\n"; - - // Generate the identifier check method - if (parser_.root_struct_def_ == &struct_def && - !parser_.file_identifier_.empty()) { - GenDocComment(code_ptr, - "@param {flatbuffers.ByteBuffer} bb\n" - "@returns {boolean}"); - if (lang_.language == IDLOptions::kTs) { - code += - "static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {\n"; - } else { - code += object_name + ".bufferHasIdentifier = function(bb) {\n"; - } - - code += " return bb.__has_identifier('" + parser_.file_identifier_; - code += "');\n};\n\n"; - } - } - - // Emit field accessors - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) continue; - auto offset_prefix = " var offset = this.bb.__offset(this.bb_pos, " + - NumToString(field.value.offset) + ");\n return offset ? "; - - // Emit a scalar field - if (IsScalar(field.value.type.base_type) || - field.value.type.base_type == BASE_TYPE_STRING) { - GenDocComment(field.doc_comment, code_ptr, - std::string(field.value.type.base_type == BASE_TYPE_STRING ? - "@param {flatbuffers.Encoding=} optionalEncoding\n" : "") + - "@returns {" + GenTypeName(field.value.type, false) + "}"); - if (lang_.language == IDLOptions::kTs) { - std::string prefix = MakeCamel(field.name, false) + "("; - if (field.value.type.base_type == BASE_TYPE_STRING) { - code += prefix + "):string\n"; - code += prefix + "optionalEncoding:flatbuffers.Encoding"+"):" + - GenTypeName(field.value.type, false)+"\n"; - code += prefix + "optionalEncoding?:any"; - } else { - code += prefix; - } - if (field.value.type.enum_def) { - code += "):" + - GenPrefixedTypeName(GenTypeName(field.value.type, false), - field.value.type.enum_def->file) + " {\n"; - } else { - code += "):" + GenTypeName(field.value.type, false) + " {\n"; - } - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += " = function("; - if (field.value.type.base_type == BASE_TYPE_STRING) { - code += "optionalEncoding"; - } - code += ") {\n"; - } - - if (struct_def.fixed) { - code += " return " + GenGetter(field.value.type, "(this.bb_pos" + - MaybeAdd(field.value.offset) + ")") + ";\n"; - } else { - std::string index = "this.bb_pos + offset"; - if (field.value.type.base_type == BASE_TYPE_STRING) { - index += ", optionalEncoding"; - } - code += offset_prefix + GenGetter(field.value.type, - "(" + index + ")") + " : " + GenDefaultValue(field.value, "this.bb"); - code += ";\n"; - } - } - - // Emit an object field - else { - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: { - auto type = WrapInNameSpace(*field.value.type.struct_def); - GenDocComment(field.doc_comment, code_ptr, - "@param {" + type + "=} obj\n@returns {" + type + "}"); - if (lang_.language == IDLOptions::kTs) { - type = GenPrefixedTypeName(type, field.value.type.struct_def->file); - code += MakeCamel(field.name, false); - code += "(obj?:" + type + "):" + type + " {\n"; - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += " = function(obj) {\n"; - } - - if (struct_def.fixed) { - code += " return (obj || new " + type; - code += ").__init(this.bb_pos"; - code += MaybeAdd(field.value.offset) + ", this.bb);\n"; - } else { - code += offset_prefix + "(obj || new " + type + ").__init("; - code += field.value.type.struct_def->fixed - ? "this.bb_pos + offset" - : "this.bb.__indirect(this.bb_pos + offset)"; - code += ", this.bb) : null;\n"; - } - - if (lang_.language == IDLOptions::kTs) { - imported_files.insert(field.value.type.struct_def->file); - } - - break; - } - - case BASE_TYPE_VECTOR: { - auto vectortype = field.value.type.VectorType(); - auto vectortypename = GenTypeName(vectortype, false); - auto inline_size = InlineSize(vectortype); - auto index = "this.bb.__vector(this.bb_pos + offset) + index" + - MaybeScale(inline_size); - std::string args = "@param {number} index\n"; - if (vectortype.base_type == BASE_TYPE_STRUCT) { - args += "@param {" + vectortypename + "=} obj\n"; - } else if (vectortype.base_type == BASE_TYPE_STRING) { - args += "@param {flatbuffers.Encoding=} optionalEncoding\n"; - } - GenDocComment(field.doc_comment, code_ptr, args + - "@returns {" + vectortypename + "}"); - if (lang_.language == IDLOptions::kTs) { - std::string prefix = MakeCamel(field.name, false); - prefix += "(index: number"; - if (vectortype.base_type == BASE_TYPE_STRUCT) { - vectortypename = GenPrefixedTypeName(vectortypename, - vectortype.struct_def->file); - code += prefix + ", obj?:" + vectortypename; - imported_files.insert(vectortype.struct_def->file); - } else if (vectortype.base_type == BASE_TYPE_STRING) { - code += prefix + "):string\n"; - code += prefix + ",optionalEncoding:flatbuffers.Encoding" + "):" + - vectortypename + "\n"; - code += prefix + ",optionalEncoding?:any"; - } else { - code += prefix; - } - code += "):" + vectortypename + " {\n"; - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += " = function(index"; - if (vectortype.base_type == BASE_TYPE_STRUCT) { - code += ", obj"; - } else if (vectortype.base_type == BASE_TYPE_STRING) { - code += ", optionalEncoding"; - } - code += ") {\n"; - } - - if (vectortype.base_type == BASE_TYPE_STRUCT) { - code += offset_prefix + "(obj || new " + vectortypename; - code += ").__init("; - code += vectortype.struct_def->fixed - ? index - : "this.bb.__indirect(" + index + ")"; - code += ", this.bb)"; - } else { - if (vectortype.base_type == BASE_TYPE_STRING) { - index += ", optionalEncoding"; - } - code += offset_prefix + GenGetter(vectortype, "(" + index + ")"); - } - code += " : "; - if (field.value.type.element == BASE_TYPE_BOOL) { - code += "false"; - } else if (field.value.type.element == BASE_TYPE_LONG || - field.value.type.element == BASE_TYPE_ULONG) { - code += "this.bb.createLong(0, 0)"; - } else if (IsScalar(field.value.type.element)) { - if (field.value.type.enum_def) { - code += "/** @type {" + - WrapInNameSpace(*field.value.type.enum_def) + "} */ (" + - field.value.constant + ")"; - } else { - code += "0"; - } - } else { - code += "null"; - } - code += ";\n"; - break; - } - - case BASE_TYPE_UNION: - GenDocComment(field.doc_comment, code_ptr, - "@param {flatbuffers.Table} obj\n" - "@returns {?flatbuffers.Table}"); - if (lang_.language == IDLOptions::kTs) { - code += MakeCamel(field.name, false); - code += "<T extends flatbuffers.Table>(obj:T):T {\n"; - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += " = function(obj) {\n"; - } - - code += offset_prefix + GenGetter(field.value.type, - "(obj, this.bb_pos + offset)") + " : null;\n"; - break; - - default: - assert(0); - } - } - code += "};\n\n"; - - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportProperty(" + object_name + ".prototype, '" + - MakeCamel(field.name, false) + "', " + object_name + ".prototype." + - MakeCamel(field.name, false) + ");\n"; - } - - // Adds the mutable scalar value to the output - if (IsScalar(field.value.type.base_type) && parser.opts.mutable_buffer) { - std::string annotations = - "@param {" + GenTypeName(field.value.type, true) + "} value\n"; - GenDocComment(code_ptr, annotations + - "@returns {boolean}"); - - if (lang_.language == IDLOptions::kTs) { - std::string type; - if (field.value.type.enum_def) { - type = GenPrefixedTypeName(GenTypeName(field.value.type, true), - field.value.type.enum_def->file); - } else { - type = GenTypeName(field.value.type, true); - } - - code += "mutate_" + field.name + "(value:" + type + "):boolean {\n"; - } else { - code += object_name + ".prototype.mutate_" + field.name + - " = function(value) {\n"; - } - - code += " var offset = this.bb.__offset(this.bb_pos, " + - NumToString(field.value.offset) + ");\n\n"; - code += " if (offset === 0) {\n"; - code += " return false;\n"; - code += " }\n\n"; - - // special case for bools, which are treated as uint8 - code += " this.bb.write" + MakeCamel(GenType(field.value.type)) + - "(this.bb_pos + offset, "; - if (field.value.type.base_type == BASE_TYPE_BOOL && - lang_.language == IDLOptions::kTs) { - code += "+"; - } - - code += "value);\n"; - code += " return true;\n"; - code += "};\n\n"; - - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportProperty(" + object_name + - ".prototype, 'mutate_" + field.name + "', " + object_name + - ".prototype.mutate_" + field.name + ");\n"; - } - } - - // Emit vector helpers - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - // Emit a length helper - GenDocComment(code_ptr, "@returns {number}"); - if (lang_.language == IDLOptions::kTs) { - code += MakeCamel(field.name, false); - code += "Length():number {\n" + offset_prefix; - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += "Length = function() {\n" + offset_prefix; - } - - code += "this.bb.__vector_len(this.bb_pos + offset) : 0;\n};\n\n"; - - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportProperty(" + object_name + ".prototype, '" + - MakeCamel(field.name, false) + "Length', " + object_name + - ".prototype." + MakeCamel(field.name, false) + "Length);\n"; - } - - // For scalar types, emit a typed array helper - auto vectorType = field.value.type.VectorType(); - if (IsScalar(vectorType.base_type) && !IsLong(vectorType.base_type)) { - GenDocComment(code_ptr, "@returns {" + GenType(vectorType) + "Array}"); - - if (lang_.language == IDLOptions::kTs) { - code += MakeCamel(field.name, false); - code += "Array():" + GenType(vectorType) + "Array {\n" + - offset_prefix; - } else { - code += object_name + ".prototype." + MakeCamel(field.name, false); - code += "Array = function() {\n" + offset_prefix; - } - - code += "new " + GenType(vectorType) + "Array(this.bb.bytes().buffer, " - "this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), " - "this.bb.__vector_len(this.bb_pos + offset)) : null;\n};\n\n"; - - if(parser_.opts.use_goog_js_export_format) { - exports += "goog.exportProperty(" + object_name + ".prototype, '" + - MakeCamel(field.name, false) + "Array', " + object_name + - ".prototype." + MakeCamel(field.name, false) + "Array);\n"; - } - } - } - } - - // Emit a factory constructor - if (struct_def.fixed) { - std::string annotations = "@param {flatbuffers.Builder} builder\n"; - std::string arguments; - GenStructArgs(struct_def, &annotations, &arguments, ""); - GenDocComment(code_ptr, annotations + - "@returns {flatbuffers.Offset}"); - - if (lang_.language == IDLOptions::kTs) { - code += "static create" + struct_def.name + "(builder:flatbuffers.Builder"; - code += arguments + "):flatbuffers.Offset {\n"; - } else { - code += object_name + ".create" + struct_def.name + " = function(builder"; - code += arguments + ") {\n"; - } - - GenStructBody(struct_def, &code, ""); - code += " return builder.offset();\n};\n\n"; - } else { - // Generate a method to start building a new object - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder"); - - if (lang_.language == IDLOptions::kTs) { - code += "static start" + struct_def.name; - code += "(builder:flatbuffers.Builder) {\n"; - } else { - code += object_name + ".start" + struct_def.name; - code += " = function(builder) {\n"; - } - - code += " builder.startObject(" + NumToString( - struct_def.fields.vec.size()) + ");\n"; - code += "};\n\n"; - - // Generate a set of static methods that allow table construction - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (field.deprecated) continue; - auto argname = MakeCamel(field.name, false); - if (!IsScalar(field.value.type.base_type)) { - argname += "Offset"; - } - - // Generate the field insertion method - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder\n" - "@param {" + GenTypeName(field.value.type, true) + "} " + - argname); - - if (lang_.language == IDLOptions::kTs) { - std::string argType; - if (field.value.type.enum_def) { - argType = GenPrefixedTypeName(GenTypeName(field.value.type, true), - field.value.type.enum_def->file); - } else { - argType = GenTypeName(field.value.type, true); - } - - code += "static add" + MakeCamel(field.name); - code += "(builder:flatbuffers.Builder, " + argname + ":" + argType + - ") {\n"; - } else { - code += object_name + ".add" + MakeCamel(field.name); - code += " = function(builder, " + argname + ") {\n"; - } - - code += " builder.addField" + GenWriteMethod(field.value.type) + "("; - code += NumToString(it - struct_def.fields.vec.begin()) + ", "; - if (field.value.type.base_type == BASE_TYPE_BOOL) { - code += "+"; - } - code += argname + ", "; - if (!IsScalar(field.value.type.base_type)) { - code += "0"; - } else { - if (field.value.type.base_type == BASE_TYPE_BOOL) { - code += "+"; - } - code += GenDefaultValue(field.value, "builder"); - } - code += ");\n};\n\n"; - - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - auto vector_type = field.value.type.VectorType(); - auto alignment = InlineAlignment(vector_type); - auto elem_size = InlineSize(vector_type); - - // Generate a method to create a vector from a JavaScript array - if (!IsStruct(vector_type)) { - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder\n" - "@param {Array.<" + GenTypeName(vector_type, true) + - ">} data\n" - "@returns {flatbuffers.Offset}"); - - if (lang_.language == IDLOptions::kTs) { - code += "static create" + MakeCamel(field.name); - std::string type = GenTypeName(vector_type, true) + "[]"; - if (type == "number[]") { - type += " | Uint8Array"; - } - code += "Vector(builder:flatbuffers.Builder, data:" + type + - "):flatbuffers.Offset {\n"; - code += "if(!data){\n return null\n}\n"; - } else { - code += object_name + ".create" + MakeCamel(field.name); - code += "Vector = function(builder, data) {\n"; - } - - code += " builder.startVector(" + NumToString(elem_size); - code += ", data.length, " + NumToString(alignment) + ");\n"; - code += " for (var i = data.length - 1; i >= 0; i--) {\n"; - code += " builder.add" + GenWriteMethod(vector_type) + "("; - if (vector_type.base_type == BASE_TYPE_BOOL) { - code += "+"; - } - code += "data[i]);\n"; - code += " }\n"; - code += " return builder.endVector();\n"; - code += "};\n\n"; - } - - // Generate a method to start a vector, data to be added manually after - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder\n" - "@param {number} numElems"); - - if (lang_.language == IDLOptions::kTs) { - code += "static start" + MakeCamel(field.name); - code += "Vector(builder:flatbuffers.Builder, numElems:number) {\n"; - } else { - code += object_name + ".start" + MakeCamel(field.name); - code += "Vector = function(builder, numElems) {\n"; - } - - code += " builder.startVector(" + NumToString(elem_size); - code += ", numElems, " + NumToString(alignment) + ");\n"; - code += "};\n\n"; - } - } - - // Generate a method to stop building a new object - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder\n" - "@returns {flatbuffers.Offset}"); - - if (lang_.language == IDLOptions::kTs) { - code += "static end" + struct_def.name; - code += "(builder:flatbuffers.Builder):flatbuffers.Offset {\n"; - } else { - code += object_name + ".end" + struct_def.name; - code += " = function(builder) {\n"; - } - - code += " var offset = builder.endObject();\n"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); ++it) { - auto &field = **it; - if (!field.deprecated && field.required) { - code += " builder.requiredField(offset, "; - code += NumToString(field.value.offset); - code += "); // " + field.name + "\n"; - } - } - code += " return offset;\n"; - code += "};\n\n"; - - // Generate the method to complete buffer construction - if (parser_.root_struct_def_ == &struct_def) { - GenDocComment(code_ptr, - "@param {flatbuffers.Builder} builder\n" - "@param {flatbuffers.Offset} offset"); - - if (lang_.language == IDLOptions::kTs) { - code += "static finish" + struct_def.name + "Buffer"; - code += "(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n"; - } else { - code += object_name + ".finish" + struct_def.name + "Buffer"; - code += " = function(builder, offset) {\n"; - } - - code += " builder.finish(offset"; - if (!parser_.file_identifier_.empty()) { - code += ", '" + parser_.file_identifier_ + "'"; - } - code += ");\n"; - code += "};\n\n"; - } - } - - if (lang_.language == IDLOptions::kTs) { - code += "}\n}\n"; - } -} -}; -} // namespace js - -bool GenerateJS(const Parser &parser, const std::string &path, - const std::string &file_name) { - js::JsGenerator generator(parser, path, file_name); - return generator.generate(); -} - -std::string JSMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name) { - assert(parser.opts.lang <= IDLOptions::kMAX); - const auto &lang = GetJsLangParams(parser.opts.lang); - - std::string filebase = flatbuffers::StripPath( - flatbuffers::StripExtension(file_name)); - std::string make_rule = GeneratedFileName(path, filebase, lang) + ": "; - - auto included_files = parser.GetIncludedFilesRecursive(file_name); - for (auto it = included_files.begin(); - it != included_files.end(); ++it) { - make_rule += " " + *it; - } -return make_rule; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_php.cpp b/third_party/flatbuffers/src/idl_gen_php.cpp deleted file mode 100644 index a893f98..0000000 --- a/third_party/flatbuffers/src/idl_gen_php.cpp +++ /dev/null
@@ -1,967 +0,0 @@ -/* -* Copyright 2014 Google Inc. All rights reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// independent from idl_parser, since this code is not needed for most clients - -#include <string> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -namespace flatbuffers { -namespace php { - // Hardcode spaces per indentation. - const std::string Indent = " "; - class PhpGenerator : public BaseGenerator { - public: - PhpGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "\\", "\\"){}; - bool generate() { - if (!generateEnums()) return false; - if (!generateStructs()) return false; - return true; - } - - private: - bool generateEnums() { - for (auto it = parser_.enums_.vec.begin(); - it != parser_.enums_.vec.end(); ++it) { - auto &enum_def = **it; - std::string enumcode; - GenEnum(enum_def, &enumcode); - if (!SaveType(enum_def, enumcode, false)) return false; - } - return true; - } - - bool generateStructs() { - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - auto &struct_def = **it; - std::string declcode; - GenStruct(struct_def, &declcode); - if (!SaveType(struct_def, declcode, true)) return false; - } - return true; - } - - // Begin by declaring namespace and imports. - void BeginFile(const std::string name_space_name, - const bool needs_imports, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "<?php\n"; - code = code + "// " + FlatBuffersGeneratedWarning(); - code += "namespace " + name_space_name + ";\n\n"; - - if (needs_imports) { - code += "use \\Google\\FlatBuffers\\Struct;\n"; - code += "use \\Google\\FlatBuffers\\Table;\n"; - code += "use \\Google\\FlatBuffers\\ByteBuffer;\n"; - code += "use \\Google\\FlatBuffers\\FlatBufferBuilder;\n"; - code += "\n"; - } - } - - // Save out the generated code for a Php Table type. - bool SaveType(const Definition &def, const std::string &classcode, - bool needs_imports) { - if (!classcode.length()) return true; - - std::string code = ""; - BeginFile(FullNamespace("\\", *def.defined_namespace), - needs_imports, &code); - code += classcode; - - std::string filename = NamespaceDir(*def.defined_namespace) + - def.name + ".php"; - return SaveFile(filename.c_str(), code, false); - } - - // Begin a class declaration. - static void BeginClass(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - if (struct_def.fixed) { - code += "class " + struct_def.name + " extends Struct\n"; - } else { - code += "class " + struct_def.name + " extends Table\n"; - } - code += "{\n"; - } - - static void EndClass(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "}\n"; - } - - // Begin enum code with a class declaration. - static void BeginEnum(const std::string class_name, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "class " + class_name + "\n{\n"; - } - - // A single enum member. - static void EnumMember(const EnumVal ev, std::string *code_ptr) { - std::string &code = *code_ptr; - code += Indent + "const "; - code += ev.name; - code += " = "; - code += NumToString(ev.value) + ";\n"; - } - - // End enum code. - static void EndEnum(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "}\n"; - } - - // Initialize a new struct or table from existing data. - static void NewRootTypeFromBuffer(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @param ByteBuffer $bb\n"; - code += Indent + " * @return " + struct_def.name + "\n"; - code += Indent + " */\n"; - code += Indent + "public static function getRootAs"; - code += struct_def.name; - code += "(ByteBuffer $bb)\n"; - code += Indent + "{\n"; - - code += Indent + Indent + "$obj = new " + struct_def.name + "();\n"; - code += Indent + Indent; - code += "return ($obj->init($bb->getInt($bb->getPosition())"; - code += " + $bb->getPosition(), $bb));\n"; - code += Indent + "}\n\n"; - } - - // Initialize an existing object with other data, to avoid an allocation. - static void InitializeExisting(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @param int $_i offset\n"; - code += Indent + " * @param ByteBuffer $_bb\n"; - code += Indent + " * @return " + struct_def.name + "\n"; - code += Indent + " **/\n"; - code += Indent + "public function init($_i, ByteBuffer $_bb)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$this->bb_pos = $_i;\n"; - code += Indent + Indent + "$this->bb = $_bb;\n"; - code += Indent + Indent + "return $this;\n"; - code += Indent + "}\n\n"; - } - - // Get the length of a vector. - static void GetVectorLen(const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @return int\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name) + "Length()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$o = $this->__offset("; - code += NumToString(field.value.offset) + ");\n"; - code += Indent + Indent; - code += "return $o != 0 ? $this->__vector_len($o) : 0;\n"; - code += Indent + "}\n\n"; - } - - // Get a [ubyte] vector as a byte array. - static void GetUByte(const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @return string\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name) + "Bytes()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "return $this->__vector_as_bytes("; - code += NumToString(field.value.offset) + ");\n"; - code += Indent + "}\n\n"; - } - - // Get the value of a struct's scalar. - static void GetScalarFieldOfStruct(const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - - code += Indent + "/**\n"; - code += Indent + " * @return "; - code += GenTypeGet(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function " + getter; - code += MakeCamel(field.name) + "()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "return "; - - code += "$this->bb->get"; - code += MakeCamel(GenTypeGet(field.value.type)); - code += "($this->bb_pos + "; - code += NumToString(field.value.offset) + ")"; - code += ";\n"; - - code += Indent + "}\n\n"; - } - - // Get the value of a table's scalar. - void GetScalarFieldOfTable(const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - - code += Indent + "/**\n"; - code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name); - code += "()\n"; - code += Indent + "{\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n" + Indent + Indent + "return $o != 0 ? "; - code += "$this->bb->get"; - code += MakeCamel(GenTypeGet(field.value.type)) + "($o + $this->bb_pos)"; - code += " : " + GenDefaultValue(field.value) + ";\n"; - code += Indent + "}\n\n"; - } - - // Get a struct by initializing an existing struct. - // Specific to Struct. - void GetStructFieldOfStruct(const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name) + "()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$obj = new "; - code += GenTypeGet(field.value.type) + "();\n"; - code += Indent + Indent + "$obj->init($this->bb_pos + "; - code += NumToString(field.value.offset) + ", $this->bb);"; - code += "\n" + Indent + Indent + "return $obj;\n"; - code += Indent + "}\n\n"; - } - - // Get a struct by initializing an existing struct. - // Specific to Table. - void GetStructFieldOfTable(const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "public function get"; - code += MakeCamel(field.name); - code += "()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$obj = new "; - code += MakeCamel(GenTypeGet(field.value.type)) + "();\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n"; - code += Indent + Indent; - code += "return $o != 0 ? $obj->init("; - if (field.value.type.struct_def->fixed) - { - code += "$o + $this->bb_pos, $this->bb) : "; - } else { - code += "$this->__indirect($o + $this->bb_pos), $this->bb) : "; - } - code += GenDefaultValue(field.value) + ";\n"; - code += Indent + "}\n\n"; - } - - // Get the value of a string. - void GetStringField(const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - code += Indent + "public function get"; - code += MakeCamel(field.name); - code += "()\n"; - code += Indent + "{\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n"; - code += Indent + Indent; - code += "return $o != 0 ? $this->__string($o + $this->bb_pos) : "; - code += GenDefaultValue(field.value) + ";\n"; - code += Indent + "}\n\n"; - } - - // Get the value of a union from an object. - void GetUnionField(const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @return" + GenTypeBasic(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name) + "($obj)\n"; - code += Indent + "{\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n"; - code += Indent + Indent; - code += "return $o != 0 ? $this->__union($obj, $o) : null;\n"; - code += Indent + "}\n\n"; - } - - // Get the value of a vector's struct member. - void GetMemberOfVectorOfStruct(const StructDef &struct_def, - const FieldDef &field, std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - code += Indent + "/**\n"; - code += Indent + " * @return" + GenTypeBasic(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name); - code += "($j)\n"; - code += Indent + "{\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n"; - code += Indent + Indent + "$obj = new "; - code += MakeCamel(GenTypeGet(field.value.type)) + "();\n"; - - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: - if (struct_def.fixed) { - code += Indent + Indent; - code += "return $o != 0 ? $obj->init($this->bb_pos +" - + NumToString(field.value.offset) + ", $this->bb) : null;\n"; - } else { - code += Indent + Indent + "return $o != 0 ? $obj->init("; - code += field.value.type.struct_def->fixed - ? "$o + $this->bb_pos" - : "$this->__indirect($o + $this->bb_pos)"; - code += ", $this->bb) : null;\n"; - } - break; - case BASE_TYPE_STRING: - code += "// base_type_string\n"; - // TODO(chobie): do we need this? - break; - case BASE_TYPE_VECTOR: - if (vectortype.base_type == BASE_TYPE_STRUCT) { - code += Indent + Indent + "return $o != 0 ? $obj->init("; - if (vectortype.struct_def->fixed) { - code += "$this->__vector($o) + $j *"; - code += NumToString(InlineSize(vectortype)); - } else { - code += "$this->__indirect($this->__vector($o) + $j * "; - code += NumToString(InlineSize(vectortype)) + ")"; - } - code += ", $this->bb) : null;\n"; - } - break; - case BASE_TYPE_UNION: - code += Indent + Indent + "return $o != 0 ? $this->"; - code += GenGetter(field.value.type) + "($obj, $o); null;\n"; - break; - default: - break; - } - - code += Indent + "}\n\n"; - } - - // Get the value of a vector's non-struct member. Uses a named return - // argument to conveniently set the zero value for the result. - void GetMemberOfVectorOfNonStruct(const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - code += Indent + "/**\n"; - code += Indent + " * @param int offset\n"; - code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; - code += Indent + " */\n"; - code += Indent + "public function get"; - code += MakeCamel(field.name); - code += "($j)\n"; - code += Indent + "{\n"; - code += Indent + Indent + - "$o = $this->__offset(" + - NumToString(field.value.offset) + - ");\n"; - - if (field.value.type.VectorType().base_type == BASE_TYPE_STRING) { - code += Indent + Indent; - code += "return $o != 0 ? $this->__string($this->__vector($o) + $j * "; - code += NumToString(InlineSize(vectortype)) + ") : "; - code += GenDefaultValue(field.value) + ";\n"; - } else { - code += Indent + Indent + "return $o != 0 ? $this->bb->get"; - code += MakeCamel(GenTypeGet(field.value.type)); - code += "($this->__vector($o) + $j * "; - code += NumToString(InlineSize(vectortype)) + ") : "; - code += GenDefaultValue(field.value) + ";\n"; - } - code += Indent + "}\n\n"; - } - - // Recursively generate arguments for a constructor, to deal with nested - // structs. - static void StructBuilderArgs(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious - // these arguments are constructing - // a nested struct, prefix the name with the field name. - StructBuilderArgs(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - std::string &code = *code_ptr; - code += (std::string)", $" + nameprefix; - code += MakeCamel(field.name, false); - } - } - } - - // Recursively generate struct construction statements and instert manual - // padding. - static void StructBuilderBody(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += Indent + Indent + "$builder->prep("; - code += NumToString(struct_def.minalign) + ", "; - code += NumToString(struct_def.bytesize) + ");\n"; - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); - ++it) { - auto &field = **it; - if (field.padding) { - code += Indent + Indent + "$builder->pad("; - code += NumToString(field.padding) + ");\n"; - } - if (IsStruct(field.value.type)) { - StructBuilderBody(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - code += Indent + Indent + "$builder->put" + GenMethod(field) + "($"; - code += nameprefix + MakeCamel(field.name, false) + ");\n"; - } - } - } - - // Get the value of a table's starting offset. - static void GetStartOfTable(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @return void\n"; - code += Indent + " */\n"; - code += Indent + "public static function start" + struct_def.name; - code += "(FlatBufferBuilder $builder)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->StartObject("; - code += NumToString(struct_def.fields.vec.size()); - code += ");\n"; - code += Indent + "}\n\n"; - - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @return " + struct_def.name + "\n"; - code += Indent + " */\n"; - code += Indent + "public static function create" + struct_def.name; - code += "(FlatBufferBuilder $builder, "; - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - - if (field.deprecated) continue; - code += "$" + field.name; - if (!(it == (--struct_def.fields.vec.end()))) { - code += ", "; - } - } - code += ")\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->startObject("; - code += NumToString(struct_def.fields.vec.size()); - code += ");\n"; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - code += Indent + Indent + "self::add"; - code += MakeCamel(field.name) + "($builder, $" + field.name + ");\n"; - } - - code += Indent + Indent + "$o = $builder->endObject();\n"; - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (!field.deprecated && field.required) { - code += Indent + Indent + "$builder->required($o, "; - code += NumToString(field.value.offset); - code += "); // " + field.name + "\n"; - } - } - code += Indent + Indent + "return $o;\n"; - code += Indent + "}\n\n"; - } - - // Set the value of a table's field. - static void BuildFieldOfTable(const FieldDef &field, - const size_t offset, - std::string *code_ptr) { - std::string &code = *code_ptr; - - - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @param " + GenTypeBasic(field.value.type) + "\n"; - code += Indent + " * @return void\n"; - code += Indent + " */\n"; - code += Indent + "public static function "; - code += "add" + MakeCamel(field.name); - code += "(FlatBufferBuilder $builder, "; - code += "$" + MakeCamel(field.name, false); - code += ")\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->add"; - code += GenMethod(field) + "X("; - code += NumToString(offset) + ", "; - - - code += "$" + MakeCamel(field.name, false); - code += ", "; - - if (field.value.type.base_type == BASE_TYPE_BOOL) { - code += "false"; - } else { - code += field.value.constant; - } - code += ");\n"; - code += Indent + "}\n\n"; - } - - // Set the value of one of the members of a table's vector. - static void BuildVectorOfTable(const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - auto vector_type = field.value.type.VectorType(); - auto alignment = InlineAlignment(vector_type); - auto elem_size = InlineSize(vector_type); - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @param array offset array\n"; - code += Indent + " * @return int vector offset\n"; - code += Indent + " */\n"; - code += Indent + "public static function create"; - code += MakeCamel(field.name); - code += "Vector(FlatBufferBuilder $builder, array $data)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->startVector("; - code += NumToString(elem_size); - code += ", count($data), " + NumToString(alignment); - code += ");\n"; - code += Indent + Indent; - code += "for ($i = count($data) - 1; $i >= 0; $i--) {\n"; - if (IsScalar(field.value.type.VectorType().base_type)) { - code += Indent + Indent + Indent; - code += "$builder->add"; - code += MakeCamel(GenTypeBasic(field.value.type.VectorType())); - code += "($data[$i]);\n"; - } else { - code += Indent + Indent + Indent; - code += "$builder->addOffset($data[$i]);\n"; - } - code += Indent + Indent + "}\n"; - code += Indent + Indent + "return $builder->endVector();\n"; - code += Indent + "}\n\n"; - - - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @param int $numElems\n"; - code += Indent + " * @return void\n"; - code += Indent + " */\n"; - code += Indent + "public static function start"; - code += MakeCamel(field.name); - code += "Vector(FlatBufferBuilder $builder, $numElems)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->startVector("; - code += NumToString(elem_size); - code += ", $numElems, " + NumToString(alignment); - code += ");\n"; - code += Indent + "}\n\n"; - } - - // Get the offset of the end of a table. - void GetEndOffsetOnTable(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - - - code += Indent + "/**\n"; - code += Indent + " * @param FlatBufferBuilder $builder\n"; - code += Indent + " * @return int table offset\n"; - code += Indent + " */\n"; - code += Indent + "public static function end" + struct_def.name; - code += "(FlatBufferBuilder $builder)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$o = $builder->endObject();\n"; - - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (!field.deprecated && field.required) { - code += Indent + Indent + "$builder->required($o, "; - code += NumToString(field.value.offset); - code += "); // " + field.name + "\n"; - } - } - code += Indent + Indent + "return $o;\n"; - code += Indent + "}\n"; - - if (parser_.root_struct_def_ == &struct_def) { - code += "\n"; - code += Indent + "public static function finish"; - code += struct_def.name; - code += "Buffer(FlatBufferBuilder $builder, $offset)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->finish($offset"; - - if (parser_.file_identifier_.length()) - code += ", \"" + parser_.file_identifier_ + "\""; - code += ");\n"; - code += Indent + "}\n"; - } - } - - // Generate a struct field, conditioned on its child type(s). - void GenStructAccessor(const StructDef &struct_def, const FieldDef &field, - std::string *code_ptr) { - GenComment(field.doc_comment, code_ptr, nullptr); - - if (IsScalar(field.value.type.base_type)) { - if (struct_def.fixed) { - GetScalarFieldOfStruct(field, code_ptr); - } else { - GetScalarFieldOfTable(field, code_ptr); - } - } else { - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: - if (struct_def.fixed) { - GetStructFieldOfStruct(field, code_ptr); - } else { - GetStructFieldOfTable(field, code_ptr); - } - break; - case BASE_TYPE_STRING: - GetStringField(field, code_ptr); - break; - case BASE_TYPE_VECTOR: { - auto vectortype = field.value.type.VectorType(); - if (vectortype.base_type == BASE_TYPE_STRUCT) { - GetMemberOfVectorOfStruct(struct_def, field, code_ptr); - } else { - GetMemberOfVectorOfNonStruct(field, code_ptr); - } - break; - } - case BASE_TYPE_UNION: - GetUnionField(field, code_ptr); - break; - default: - assert(0); - } - } - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - GetVectorLen(field, code_ptr); - if (field.value.type.element == BASE_TYPE_UCHAR) { - GetUByte(field, code_ptr); - } - } - } - - // Generate table constructors, conditioned on its members' types. - void GenTableBuilders(const StructDef &struct_def, std::string *code_ptr) { - GetStartOfTable(struct_def, code_ptr); - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - auto offset = it - struct_def.fields.vec.begin(); - if (field.value.type.base_type == BASE_TYPE_UNION) { - std::string &code = *code_ptr; - code += Indent + "public static function add"; - code += MakeCamel(field.name); - code += "(FlatBufferBuilder $builder, $offset)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "$builder->addOffsetX("; - code += NumToString(offset) + ", $offset, 0);\n"; - code += Indent + "}\n\n"; - } else { - BuildFieldOfTable(field, offset, code_ptr); - } - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - BuildVectorOfTable(field, code_ptr); - } - } - - GetEndOffsetOnTable(struct_def, code_ptr); - } - - // Generate struct or table methods. - void GenStruct(const StructDef &struct_def, - std::string *code_ptr) { - if (struct_def.generated) return; - - GenComment(struct_def.doc_comment, code_ptr, nullptr); - BeginClass(struct_def, code_ptr); - - if (!struct_def.fixed) { - // Generate a special accessor for the table that has been declared as - // the root type. - NewRootTypeFromBuffer(struct_def, code_ptr); - } - - std::string &code = *code_ptr; - if (!struct_def.fixed) { - if (parser_.file_identifier_.length()) { - // Return the identifier - code += Indent + "public static function " + struct_def.name; - code += "Identifier()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "return \""; - code += parser_.file_identifier_ + "\";\n"; - code += Indent + "}\n\n"; - - // Check if a buffer has the identifier. - code += Indent + "public static function " + struct_def.name; - code += "BufferHasIdentifier(ByteBuffer $buf)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "return self::"; - code += "__has_identifier($buf, self::"; - code += struct_def.name + "Identifier());\n"; - code += Indent + "}\n\n"; - } - - if (parser_.file_extension_.length()) { - // Return the extension - code += Indent + "public static function " + struct_def.name; - code += "Extension()\n"; - code += Indent + "{\n"; - code += Indent + Indent + "return \"" + parser_.file_extension_; - code += "\";\n"; - code += Indent + "}\n\n"; - } - } - - // Generate the Init method that sets the field in a pre-existing - // accessor object. This is to allow object reuse. - InitializeExisting(struct_def, code_ptr); - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - GenStructAccessor(struct_def, field, code_ptr); - } - - if (struct_def.fixed) { - // create a struct constructor function - GenStructBuilder(struct_def, code_ptr); - } else { - // Create a set of functions that allow table construction. - GenTableBuilders(struct_def, code_ptr); - } - EndClass(code_ptr); - } - - // Generate enum declarations. - static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) { - if (enum_def.generated) return; - - GenComment(enum_def.doc_comment, code_ptr, nullptr); - BeginEnum(enum_def.name, code_ptr); - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - GenComment(ev.doc_comment, code_ptr, nullptr); - EnumMember(ev, code_ptr); - } - - std::string &code = *code_ptr; - code += "\n"; - code += Indent + "private static $names = array(\n"; - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); ++it) { - auto &ev = **it; - code += Indent + Indent + "\"" + ev.name + "\",\n"; - } - - code += Indent + ");\n\n"; - code += Indent + "public static function Name($e)\n"; - code += Indent + "{\n"; - code += Indent + Indent + "if (!isset(self::$names[$e])) {\n"; - code += Indent + Indent + Indent + "throw new \\Exception();\n"; - code += Indent + Indent + "}\n"; - code += Indent + Indent + "return self::$names[$e];\n"; - code += Indent + "}\n"; - EndEnum(code_ptr); - } - - // Returns the function name that is able to read a value of the given type. - static std::string GenGetter(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: return "__string"; - case BASE_TYPE_STRUCT: return "__struct"; - case BASE_TYPE_UNION: return "__union"; - case BASE_TYPE_VECTOR: return GenGetter(type.VectorType()); - default: - return "Get"; - } - } - - // Returns the method name for use with add/put calls. - static std::string GenMethod(const FieldDef &field) { - return IsScalar(field.value.type.base_type) - ? MakeCamel(GenTypeBasic(field.value.type)) - : (IsStruct(field.value.type) ? "Struct" : "Offset"); - } - - static std::string GenTypeBasic(const Type &type) { - static const char *ctypename[] = { -#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #NTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) -#undef FLATBUFFERS_TD - }; - return ctypename[type.base_type]; - } - - std::string GenDefaultValue(const Value &value) { - if (value.type.enum_def) { - if (auto val = value.type.enum_def->ReverseLookup( - atoi(value.constant.c_str()), false)) { - return WrapInNameSpace(*value.type.enum_def) + "::" + val->name; - } - } - - switch (value.type.base_type) { - case BASE_TYPE_BOOL: - return value.constant == "0" ? "false" : "true"; - - case BASE_TYPE_STRING: - return "null"; - - case BASE_TYPE_LONG: - case BASE_TYPE_ULONG: - if (value.constant != "0") { - int64_t constant = StringToInt(value.constant.c_str()); - return NumToString(constant); - } - return "0"; - - default: - return value.constant; - } - } - - static std::string GenTypePointer(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: - return "string"; - case BASE_TYPE_VECTOR: - return GenTypeGet(type.VectorType()); - case BASE_TYPE_STRUCT: - return type.struct_def->name; - case BASE_TYPE_UNION: - // fall through - default: - return "Table"; - } - } - - static std::string GenTypeGet(const Type &type) { - return IsScalar(type.base_type) - ? GenTypeBasic(type) - : GenTypePointer(type); - } - - // Create a struct with a builder and the struct's arguments. - static void GenStructBuilder(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\n"; - code += Indent + "/**\n"; - code += Indent + " * @return int offset\n"; - code += Indent + " */\n"; - code += Indent + "public static function create" + struct_def.name; - code += "(FlatBufferBuilder $builder"; - StructBuilderArgs(struct_def, "", code_ptr); - code += ")\n"; - code += Indent + "{\n"; - - StructBuilderBody(struct_def, "", code_ptr); - - code += Indent + Indent + "return $builder->offset();\n"; - code += Indent + "}\n"; - } - - }; - } // namespace php - - bool GeneratePhp(const Parser &parser, const std::string &path, - const std::string &file_name) { - php::PhpGenerator generator(parser, path, file_name); - return generator.generate(); - } - } // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_python.cpp b/third_party/flatbuffers/src/idl_gen_python.cpp deleted file mode 100644 index 76fea3e..0000000 --- a/third_party/flatbuffers/src/idl_gen_python.cpp +++ /dev/null
@@ -1,671 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include <string> - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" -#include "flatbuffers/code_generators.h" - -namespace flatbuffers { -namespace python { - -static std::string GenGetter(const Type &type); -static std::string GenMethod(const FieldDef &field); -static void GenStructBuilder(const StructDef &struct_def, - std::string *code_ptr); -static void GenReceiver(const StructDef &struct_def, std::string *code_ptr); -static std::string GenTypeBasic(const Type &type); -static std::string GenTypeGet(const Type &type); -static std::string TypeName(const FieldDef &field); - - -// Hardcode spaces per indentation. -const std::string Indent = " "; - -// Most field accessors need to retrieve and test the field offset first, -// this is the prefix code for that. -std::string OffsetPrefix(const FieldDef &field) { - return "\n" + Indent + Indent + - "o = flatbuffers.number_types.UOffsetTFlags.py_type" + - "(self._tab.Offset(" + - NumToString(field.value.offset) + - "))\n" + Indent + Indent + "if o != 0:\n"; -} - -// Begin a class declaration. -static void BeginClass(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "class " + struct_def.name + "(object):\n"; - code += Indent + "__slots__ = ['_tab']"; - code += "\n\n"; -} - -// Begin enum code with a class declaration. -static void BeginEnum(const std::string class_name, std::string *code_ptr) { - std::string &code = *code_ptr; - code += "class " + class_name + "(object):\n"; -} - -// A single enum member. -static void EnumMember(const EnumVal ev, std::string *code_ptr) { - std::string &code = *code_ptr; - code += Indent; - code += ev.name; - code += " = "; - code += NumToString(ev.value) + "\n"; -} - -// End enum code. -static void EndEnum(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "\n"; -} - -// Initialize a new struct or table from existing data. -static void NewRootTypeFromBuffer(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += Indent + "@classmethod\n"; - code += Indent + "def GetRootAs"; - code += struct_def.name; - code += "(cls, buf, offset):"; - code += "\n"; - code += Indent + Indent; - code += "n = flatbuffers.encode.Get"; - code += "(flatbuffers.packer.uoffset, buf, offset)\n"; - code += Indent + Indent + "x = " + struct_def.name + "()\n"; - code += Indent + Indent + "x.Init(buf, n + offset)\n"; - code += Indent + Indent + "return x\n"; - code += "\n"; -} - -// Initialize an existing object with other data, to avoid an allocation. -static void InitializeExisting(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += "Init(self, buf, pos):\n"; - code += Indent + Indent + "self._tab = flatbuffers.table.Table(buf, pos)\n"; - code += "\n"; -} - -// Get the length of a vector. -static void GetVectorLen(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name) + "Length(self"; - code += "):" + OffsetPrefix(field); - code += Indent + Indent + Indent + "return self._tab.VectorLen(o)\n"; - code += Indent + Indent + "return 0\n\n"; -} - -// Get the value of a struct's scalar. -static void GetScalarFieldOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self): return " + getter; - code += "self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type("; - code += NumToString(field.value.offset) + "))\n"; -} - -// Get the value of a table's scalar. -static void GetScalarFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - std::string getter = GenGetter(field.value.type); - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self):"; - code += OffsetPrefix(field); - code += Indent + Indent + Indent + "return " + getter; - code += "o + self._tab.Pos)\n"; - code += Indent + Indent + "return " + field.value.constant + "\n\n"; -} - -// Get a struct by initializing an existing struct. -// Specific to Struct. -static void GetStructFieldOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self, obj):\n"; - code += Indent + Indent + "obj.Init(self._tab.Bytes, self._tab.Pos + "; - code += NumToString(field.value.offset) + ")"; - code += "\n" + Indent + Indent + "return obj\n\n"; -} - -// Get a struct by initializing an existing struct. -// Specific to Table. -static void GetStructFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self):"; - code += OffsetPrefix(field); - if (field.value.type.struct_def->fixed) { - code += Indent + Indent + Indent + "x = o + self._tab.Pos\n"; - } else { - code += Indent + Indent + Indent; - code += "x = self._tab.Indirect(o + self._tab.Pos)\n"; - } - code += Indent + Indent + Indent; - code += "from ." + TypeName(field) + " import " + TypeName(field) + "\n"; - code += Indent + Indent + Indent + "obj = " + TypeName(field) + "()\n"; - code += Indent + Indent + Indent + "obj.Init(self._tab.Bytes, x)\n"; - code += Indent + Indent + Indent + "return obj\n"; - code += Indent + Indent + "return None\n\n"; -} - -// Get the value of a string. -static void GetStringField(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self):"; - code += OffsetPrefix(field); - code += Indent + Indent + Indent + "return " + GenGetter(field.value.type); - code += "o + self._tab.Pos)\n"; - code += Indent + Indent + "return \"\"\n\n"; -} - -// Get the value of a union from an object. -static void GetUnionField(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name) + "(self):"; - code += OffsetPrefix(field); - - // TODO(rw): this works and is not the good way to it: - bool is_native_table = TypeName(field) == "*flatbuffers.Table"; - if (is_native_table) { - code += Indent + Indent + Indent + "from flatbuffers.table import Table\n"; - } else { - code += Indent + Indent + Indent; - code += "from ." + TypeName(field) + " import " + TypeName(field) + "\n"; - } - code += Indent + Indent + Indent + "obj = Table(bytearray(), 0)\n"; - code += Indent + Indent + Indent + GenGetter(field.value.type); - code += "obj, o)\n" + Indent + Indent + Indent + "return obj\n"; - code += Indent + Indent + "return None\n\n"; -} - -// Get the value of a vector's struct member. -static void GetMemberOfVectorOfStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self, j):" + OffsetPrefix(field); - code += Indent + Indent + Indent + "x = self._tab.Vector(o)\n"; - code += Indent + Indent + Indent; - code += "x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * "; - code += NumToString(InlineSize(vectortype)) + "\n"; - if (!(vectortype.struct_def->fixed)) { - code += Indent + Indent + Indent + "x = self._tab.Indirect(x)\n"; - } - code += Indent + Indent + Indent; - code += "from ." + TypeName(field) + " import " + TypeName(field) + "\n"; - code += Indent + Indent + Indent + "obj = " + TypeName(field) + "()\n"; - code += Indent + Indent + Indent + "obj.Init(self._tab.Bytes, x)\n"; - code += Indent + Indent + Indent + "return obj\n"; - code += Indent + Indent + "return None\n\n"; -} - -// Get the value of a vector's non-struct member. Uses a named return -// argument to conveniently set the zero value for the result. -static void GetMemberOfVectorOfNonStruct(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - auto vectortype = field.value.type.VectorType(); - - GenReceiver(struct_def, code_ptr); - code += MakeCamel(field.name); - code += "(self, j):"; - code += OffsetPrefix(field); - code += Indent + Indent + Indent + "a = self._tab.Vector(o)\n"; - code += Indent + Indent + Indent; - code += "return " + GenGetter(field.value.type); - code += "a + flatbuffers.number_types.UOffsetTFlags.py_type(j * "; - code += NumToString(InlineSize(vectortype)) + "))\n"; - if (vectortype.base_type == BASE_TYPE_STRING) { - code += Indent + Indent + "return \"\"\n"; - } else { - code += Indent + Indent + "return 0\n"; - } - code += "\n"; -} - -// Begin the creator function signature. -static void BeginBuilderArgs(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - - code += "\n"; - code += "def Create" + struct_def.name; - code += "(builder"; -} - -// Recursively generate arguments for a constructor, to deal with nested -// structs. -static void StructBuilderArgs(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (IsStruct(field.value.type)) { - // Generate arguments for a struct inside a struct. To ensure names - // don't clash, and to make it obvious these arguments are constructing - // a nested struct, prefix the name with the field name. - StructBuilderArgs(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - std::string &code = *code_ptr; - code += (std::string)", " + nameprefix; - code += MakeCamel(field.name, false); - } - } -} - -// End the creator function signature. -static void EndBuilderArgs(std::string *code_ptr) { - std::string &code = *code_ptr; - code += "):\n"; -} - -// Recursively generate struct construction statements and instert manual -// padding. -static void StructBuilderBody(const StructDef &struct_def, - const char *nameprefix, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += " builder.Prep(" + NumToString(struct_def.minalign) + ", "; - code += NumToString(struct_def.bytesize) + ")\n"; - for (auto it = struct_def.fields.vec.rbegin(); - it != struct_def.fields.vec.rend(); - ++it) { - auto &field = **it; - if (field.padding) - code += " builder.Pad(" + NumToString(field.padding) + ")\n"; - if (IsStruct(field.value.type)) { - StructBuilderBody(*field.value.type.struct_def, - (nameprefix + (field.name + "_")).c_str(), - code_ptr); - } else { - code += " builder.Prepend" + GenMethod(field) + "("; - code += nameprefix + MakeCamel(field.name, false) + ")\n"; - } - } -} - -static void EndBuilderBody(std::string *code_ptr) { - std::string &code = *code_ptr; - code += " return builder.Offset()\n"; -} - -// Get the value of a table's starting offset. -static void GetStartOfTable(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "def " + struct_def.name + "Start"; - code += "(builder): "; - code += "builder.StartObject("; - code += NumToString(struct_def.fields.vec.size()); - code += ")\n"; -} - -// Set the value of a table's field. -static void BuildFieldOfTable(const StructDef &struct_def, - const FieldDef &field, - const size_t offset, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "def " + struct_def.name + "Add" + MakeCamel(field.name); - code += "(builder, "; - code += MakeCamel(field.name, false); - code += "): "; - code += "builder.Prepend"; - code += GenMethod(field) + "Slot("; - code += NumToString(offset) + ", "; - if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) { - code += "flatbuffers.number_types.UOffsetTFlags.py_type"; - code += "("; - code += MakeCamel(field.name, false) + ")"; - } else { - code += MakeCamel(field.name, false); - } - code += ", " + field.value.constant; - code += ")\n"; -} - -// Set the value of one of the members of a table's vector. -static void BuildVectorOfTable(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "def " + struct_def.name + "Start"; - code += MakeCamel(field.name); - code += "Vector(builder, numElems): return builder.StartVector("; - auto vector_type = field.value.type.VectorType(); - auto alignment = InlineAlignment(vector_type); - auto elem_size = InlineSize(vector_type); - code += NumToString(elem_size); - code += ", numElems, " + NumToString(alignment); - code += ")\n"; -} - -// Get the offset of the end of a table. -static void GetEndOffsetOnTable(const StructDef &struct_def, - std::string *code_ptr) { - std::string &code = *code_ptr; - code += "def " + struct_def.name + "End"; - code += "(builder): "; - code += "return builder.EndObject()\n"; -} - -// Generate the receiver for function signatures. -static void GenReceiver(const StructDef &struct_def, std::string *code_ptr) { - std::string &code = *code_ptr; - code += Indent + "# " + struct_def.name + "\n"; - code += Indent + "def "; -} - -// Generate a struct field, conditioned on its child type(s). -static void GenStructAccessor(const StructDef &struct_def, - const FieldDef &field, - std::string *code_ptr) { - GenComment(field.doc_comment, code_ptr, nullptr, "# "); - if (IsScalar(field.value.type.base_type)) { - if (struct_def.fixed) { - GetScalarFieldOfStruct(struct_def, field, code_ptr); - } else { - GetScalarFieldOfTable(struct_def, field, code_ptr); - } - } else { - switch (field.value.type.base_type) { - case BASE_TYPE_STRUCT: - if (struct_def.fixed) { - GetStructFieldOfStruct(struct_def, field, code_ptr); - } else { - GetStructFieldOfTable(struct_def, field, code_ptr); - } - break; - case BASE_TYPE_STRING: - GetStringField(struct_def, field, code_ptr); - break; - case BASE_TYPE_VECTOR: { - auto vectortype = field.value.type.VectorType(); - if (vectortype.base_type == BASE_TYPE_STRUCT) { - GetMemberOfVectorOfStruct(struct_def, field, code_ptr); - } else { - GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr); - } - break; - } - case BASE_TYPE_UNION: - GetUnionField(struct_def, field, code_ptr); - break; - default: - assert(0); - } - } - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - GetVectorLen(struct_def, field, code_ptr); - } -} - -// Generate table constructors, conditioned on its members' types. -static void GenTableBuilders(const StructDef &struct_def, - std::string *code_ptr) { - GetStartOfTable(struct_def, code_ptr); - - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - auto offset = it - struct_def.fields.vec.begin(); - BuildFieldOfTable(struct_def, field, offset, code_ptr); - if (field.value.type.base_type == BASE_TYPE_VECTOR) { - BuildVectorOfTable(struct_def, field, code_ptr); - } - } - - GetEndOffsetOnTable(struct_def, code_ptr); -} - -// Generate struct or table methods. -static void GenStruct(const StructDef &struct_def, - std::string *code_ptr) { - if (struct_def.generated) return; - - GenComment(struct_def.doc_comment, code_ptr, nullptr, "# "); - BeginClass(struct_def, code_ptr); - if (!struct_def.fixed) { - // Generate a special accessor for the table that has been declared as - // the root type. - NewRootTypeFromBuffer(struct_def, code_ptr); - } - // Generate the Init method that sets the field in a pre-existing - // accessor object. This is to allow object reuse. - InitializeExisting(struct_def, code_ptr); - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - auto &field = **it; - if (field.deprecated) continue; - - GenStructAccessor(struct_def, field, code_ptr); - } - - if (struct_def.fixed) { - // create a struct constructor function - GenStructBuilder(struct_def, code_ptr); - } else { - // Create a set of functions that allow table construction. - GenTableBuilders(struct_def, code_ptr); - } -} - -// Generate enum declarations. -static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) { - if (enum_def.generated) return; - - GenComment(enum_def.doc_comment, code_ptr, nullptr, "# "); - BeginEnum(enum_def.name, code_ptr); - for (auto it = enum_def.vals.vec.begin(); - it != enum_def.vals.vec.end(); - ++it) { - auto &ev = **it; - GenComment(ev.doc_comment, code_ptr, nullptr, "# "); - EnumMember(ev, code_ptr); - } - EndEnum(code_ptr); -} - -// Returns the function name that is able to read a value of the given type. -static std::string GenGetter(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: return "self._tab.String("; - case BASE_TYPE_UNION: return "self._tab.Union("; - case BASE_TYPE_VECTOR: return GenGetter(type.VectorType()); - default: - return "self._tab.Get(flatbuffers.number_types." + \ - MakeCamel(GenTypeGet(type)) + \ - "Flags, "; - } -} - -// Returns the method name for use with add/put calls. -static std::string GenMethod(const FieldDef &field) { - return IsScalar(field.value.type.base_type) - ? MakeCamel(GenTypeBasic(field.value.type)) - : (IsStruct(field.value.type) ? "Struct" : "UOffsetTRelative"); -} - -static std::string GenTypeBasic(const Type &type) { - static const char *ctypename[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - #PTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - return ctypename[type.base_type]; -} - -static std::string GenTypePointer(const Type &type) { - switch (type.base_type) { - case BASE_TYPE_STRING: - return "string"; - case BASE_TYPE_VECTOR: - return GenTypeGet(type.VectorType()); - case BASE_TYPE_STRUCT: - return type.struct_def->name; - case BASE_TYPE_UNION: - // fall through - default: - return "*flatbuffers.Table"; - } -} - -static std::string GenTypeGet(const Type &type) { - return IsScalar(type.base_type) - ? GenTypeBasic(type) - : GenTypePointer(type); -} - -static std::string TypeName(const FieldDef &field) { - return GenTypeGet(field.value.type); -} - -// Create a struct with a builder and the struct's arguments. -static void GenStructBuilder(const StructDef &struct_def, - std::string *code_ptr) { - BeginBuilderArgs(struct_def, code_ptr); - StructBuilderArgs(struct_def, "", code_ptr); - EndBuilderArgs(code_ptr); - - StructBuilderBody(struct_def, "", code_ptr); - EndBuilderBody(code_ptr); -} - -class PythonGenerator : public BaseGenerator { - public: - PythonGenerator(const Parser &parser, const std::string &path, - const std::string &file_name) - : BaseGenerator(parser, path, file_name, "" /* not used */, - "" /* not used */){}; - bool generate() { - if (!generateEnums()) return false; - if (!generateStructs()) return false; - return true; - } - - private: - bool generateEnums() { - for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end(); - ++it) { - auto &enum_def = **it; - std::string enumcode; - GenEnum(enum_def, &enumcode); - if (!SaveType(enum_def, enumcode, false)) return false; - } - return true; - } - - bool generateStructs() { - for (auto it = parser_.structs_.vec.begin(); - it != parser_.structs_.vec.end(); ++it) { - auto &struct_def = **it; - std::string declcode; - GenStruct(struct_def, &declcode); - if (!SaveType(struct_def, declcode, true)) return false; - } - return true; - } - - // Begin by declaring namespace and imports. - void BeginFile(const std::string name_space_name, const bool needs_imports, - std::string *code_ptr) { - std::string &code = *code_ptr; - code = code + "# " + FlatBuffersGeneratedWarning(); - code += "# namespace: " + name_space_name + "\n\n"; - if (needs_imports) { - code += "import flatbuffers\n\n"; - } - } - - // Save out the generated code for a Python Table type. - bool SaveType(const Definition &def, const std::string &classcode, - bool needs_imports) { - if (!classcode.length()) return true; - - std::string namespace_dir = path_; - auto &namespaces = parser_.namespaces_.back()->components; - for (auto it = namespaces.begin(); it != namespaces.end(); ++it) { - if (it != namespaces.begin()) namespace_dir += kPathSeparator; - namespace_dir += *it; - std::string init_py_filename = namespace_dir + "/__init__.py"; - SaveFile(init_py_filename.c_str(), "", false); - } - - std::string code = ""; - BeginFile(LastNamespacePart(*def.defined_namespace), needs_imports, &code); - code += classcode; - std::string filename = NamespaceDir(*def.defined_namespace) + - def.name + ".py"; - return SaveFile(filename.c_str(), code, false); - } -}; - -} // namespace python - -bool GeneratePython(const Parser &parser, const std::string &path, - const std::string &file_name) { - python::PythonGenerator generator(parser, path, file_name); - return generator.generate(); -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/idl_gen_text.cpp b/third_party/flatbuffers/src/idl_gen_text.cpp deleted file mode 100644 index dc445e5..0000000 --- a/third_party/flatbuffers/src/idl_gen_text.cpp +++ /dev/null
@@ -1,369 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// independent from idl_parser, since this code is not needed for most clients - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -namespace flatbuffers { - -static bool GenStruct(const StructDef &struct_def, const Table *table, - int indent, const IDLOptions &opts, - std::string *_text); - -// If indentation is less than 0, that indicates we don't want any newlines -// either. -const char *NewLine(const IDLOptions &opts) { - return opts.indent_step >= 0 ? "\n" : ""; -} - -int Indent(const IDLOptions &opts) { - return std::max(opts.indent_step, 0); -} - -// Output an identifier with or without quotes depending on strictness. -void OutputIdentifier(const std::string &name, const IDLOptions &opts, - std::string *_text) { - std::string &text = *_text; - if (opts.strict_json) text += "\""; - text += name; - if (opts.strict_json) text += "\""; -} - -// Print (and its template specialization below for pointers) generate text -// for a single FlatBuffer value into JSON format. -// The general case for scalars: -template<typename T> bool Print(T val, Type type, int /*indent*/, - Type * /*union_type*/, - const IDLOptions &opts, - std::string *_text) { - std::string &text = *_text; - if (type.enum_def && opts.output_enum_identifiers) { - auto enum_val = type.enum_def->ReverseLookup(static_cast<int>(val)); - if (enum_val) { - OutputIdentifier(enum_val->name, opts, _text); - return true; - } - } - - if (type.base_type == BASE_TYPE_BOOL) { - text += val != 0 ? "true" : "false"; - } else { - text += NumToString(val); - } - - return true; -} - -// Print a vector a sequence of JSON values, comma separated, wrapped in "[]". -template<typename T> bool PrintVector(const Vector<T> &v, Type type, - int indent, const IDLOptions &opts, - std::string *_text) { - std::string &text = *_text; - text += "["; - text += NewLine(opts); - for (uoffset_t i = 0; i < v.size(); i++) { - if (i) { - text += ","; - text += NewLine(opts); - } - text.append(indent + Indent(opts), ' '); - if (IsStruct(type)) { - if (!Print(v.GetStructFromOffset(i * type.struct_def->bytesize), type, - indent + Indent(opts), nullptr, opts, _text)) { - return false; - } - } else { - if (!Print(v[i], type, indent + Indent(opts), nullptr, - opts, _text)) { - return false; - } - } - } - text += NewLine(opts); - text.append(indent, ' '); - text += "]"; - return true; -} - -static bool EscapeString(const String &s, std::string *_text, const IDLOptions& opts) { - std::string &text = *_text; - text += "\""; - for (uoffset_t i = 0; i < s.size(); i++) { - char c = s[i]; - switch (c) { - case '\n': text += "\\n"; break; - case '\t': text += "\\t"; break; - case '\r': text += "\\r"; break; - case '\b': text += "\\b"; break; - case '\f': text += "\\f"; break; - case '\"': text += "\\\""; break; - case '\\': text += "\\\\"; break; - default: - if (c >= ' ' && c <= '~') { - text += c; - } else { - // Not printable ASCII data. Let's see if it's valid UTF-8 first: - const char *utf8 = s.c_str() + i; - int ucc = FromUTF8(&utf8); - if (ucc < 0) { - if (opts.allow_non_utf8) { - text += "\\x"; - text += IntToStringHex(static_cast<uint8_t>(c), 2); - } else { - // There are two cases here: - // - // 1) We reached here by parsing an IDL file. In that case, - // we previously checked for non-UTF-8, so we shouldn't reach - // here. - // - // 2) We reached here by someone calling GenerateText() - // on a previously-serialized flatbuffer. The data might have - // non-UTF-8 Strings, or might be corrupt. - // - // In both cases, we have to give up and inform the caller - // they have no JSON. - return false; - } - } else { - if (ucc <= 0xFFFF) { - // Parses as Unicode within JSON's \uXXXX range, so use that. - text += "\\u"; - text += IntToStringHex(ucc, 4); - } else if (ucc <= 0x10FFFF) { - // Encode Unicode SMP values to a surrogate pair using two \u escapes. - uint32_t base = ucc - 0x10000; - auto high_surrogate = (base >> 10) + 0xD800; - auto low_surrogate = (base & 0x03FF) + 0xDC00; - text += "\\u"; - text += IntToStringHex(high_surrogate, 4); - text += "\\u"; - text += IntToStringHex(low_surrogate, 4); - } - // Skip past characters recognized. - i = static_cast<uoffset_t>(utf8 - s.c_str() - 1); - } - } - break; - } - } - text += "\""; - return true; -} - -// Specialization of Print above for pointer types. -template<> bool Print<const void *>(const void *val, - Type type, int indent, - Type *union_type, - const IDLOptions &opts, - std::string *_text) { - switch (type.base_type) { - case BASE_TYPE_UNION: - // If this assert hits, you have an corrupt buffer, a union type field - // was not present or was out of range. - assert(union_type); - return Print<const void *>(val, *union_type, indent, nullptr, opts, - _text); - case BASE_TYPE_STRUCT: - if (!GenStruct(*type.struct_def, - reinterpret_cast<const Table *>(val), - indent, - opts, - _text)) { - return false; - } - break; - case BASE_TYPE_STRING: { - if (!EscapeString(*reinterpret_cast<const String *>(val), _text, opts)) { - return false; - } - break; - } - case BASE_TYPE_VECTOR: - type = type.VectorType(); - // Call PrintVector above specifically for each element type: - switch (type.base_type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - if (!PrintVector<CTYPE>( \ - *reinterpret_cast<const Vector<CTYPE> *>(val), \ - type, indent, opts, _text)) { \ - return false; \ - } \ - break; - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - } - break; - default: assert(0); - } - return true; -} - -// Generate text for a scalar field. -template<typename T> static bool GenField(const FieldDef &fd, - const Table *table, bool fixed, - const IDLOptions &opts, - int indent, - std::string *_text) { - return Print(fixed ? - reinterpret_cast<const Struct *>(table)->GetField<T>(fd.value.offset) : - table->GetField<T>(fd.value.offset, 0), fd.value.type, indent, nullptr, - opts, _text); -} - -// Generate text for non-scalar field. -static bool GenFieldOffset(const FieldDef &fd, const Table *table, bool fixed, - int indent, Type *union_type, - const IDLOptions &opts, std::string *_text) { - const void *val = nullptr; - if (fixed) { - // The only non-scalar fields in structs are structs. - assert(IsStruct(fd.value.type)); - val = reinterpret_cast<const Struct *>(table)-> - GetStruct<const void *>(fd.value.offset); - } else { - val = IsStruct(fd.value.type) - ? table->GetStruct<const void *>(fd.value.offset) - : table->GetPointer<const void *>(fd.value.offset); - } - return Print(val, fd.value.type, indent, union_type, opts, _text); -} - -// Generate text for a struct or table, values separated by commas, indented, -// and bracketed by "{}" -static bool GenStruct(const StructDef &struct_def, const Table *table, - int indent, const IDLOptions &opts, - std::string *_text) { - std::string &text = *_text; - text += "{"; - int fieldout = 0; - Type *union_type = nullptr; - for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { - FieldDef &fd = **it; - auto is_present = struct_def.fixed || table->CheckField(fd.value.offset); - auto output_anyway = opts.output_default_scalars_in_json && - IsScalar(fd.value.type.base_type) && - !fd.deprecated; - if (is_present || output_anyway) { - if (fieldout++) { - text += ","; - } - text += NewLine(opts); - text.append(indent + Indent(opts), ' '); - OutputIdentifier(fd.name, opts, _text); - text += ": "; - if (is_present) { - switch (fd.value.type.base_type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - if (!GenField<CTYPE>(fd, table, struct_def.fixed, \ - opts, indent + Indent(opts), _text)) { \ - return false; \ - } \ - break; - FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - // Generate drop-thru case statements for all pointer types: - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - case BASE_TYPE_ ## ENUM: - FLATBUFFERS_GEN_TYPES_POINTER(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - if (!GenFieldOffset(fd, table, struct_def.fixed, indent + Indent(opts), - union_type, opts, _text)) { - return false; - } - break; - } - if (fd.value.type.base_type == BASE_TYPE_UTYPE) { - auto enum_val = fd.value.type.enum_def->ReverseLookup( - table->GetField<uint8_t>(fd.value.offset, 0)); - assert(enum_val); - union_type = &enum_val->union_type; - } - } - else - { - text += fd.value.constant; - } - } - } - text += NewLine(opts); - text.append(indent, ' '); - text += "}"; - return true; -} - -// Generate a text representation of a flatbuffer in JSON format. -bool GenerateText(const Parser &parser, const void *flatbuffer, - std::string *_text) { - std::string &text = *_text; - assert(parser.root_struct_def_); // call SetRootType() - text.reserve(1024); // Reduce amount of inevitable reallocs. - if (!GenStruct(*parser.root_struct_def_, - GetRoot<Table>(flatbuffer), - 0, - parser.opts, - _text)) { - return false; - } - text += NewLine(parser.opts); - return true; -} - -std::string TextFileName(const std::string &path, - const std::string &file_name) { - return path + file_name + ".json"; -} - -bool GenerateTextFile(const Parser &parser, - const std::string &path, - const std::string &file_name) { - if (!parser.builder_.GetSize() || !parser.root_struct_def_) return true; - std::string text; - if (!GenerateText(parser, parser.builder_.GetBufferPointer(), &text)) { - return false; - } - return flatbuffers::SaveFile(TextFileName(path, file_name).c_str(), - text, - false); -} - -std::string TextMakeRule(const Parser &parser, - const std::string &path, - const std::string &file_name) { - if (!parser.builder_.GetSize() || !parser.root_struct_def_) return ""; - std::string filebase = flatbuffers::StripPath( - flatbuffers::StripExtension(file_name)); - std::string make_rule = TextFileName(path, filebase) + ": " + file_name; - auto included_files = parser.GetIncludedFilesRecursive( - parser.root_struct_def_->file); - for (auto it = included_files.begin(); - it != included_files.end(); ++it) { - make_rule += " " + *it; - } - return make_rule; -} - -} // namespace flatbuffers -
diff --git a/third_party/flatbuffers/src/idl_parser.cpp b/third_party/flatbuffers/src/idl_parser.cpp deleted file mode 100644 index e20c275..0000000 --- a/third_party/flatbuffers/src/idl_parser.cpp +++ /dev/null
@@ -1,2283 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> -#include <list> - -#ifdef _WIN32 -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES // For M_PI. -#endif // !defined(_USE_MATH_DEFINES) -#endif // _WIN32 - -#include <math.h> - -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -namespace flatbuffers { - -const char *const kTypeNames[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - IDLTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - nullptr -}; - -const char kTypeSizes[] = { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - sizeof(CTYPE), - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD -}; - -// The enums in the reflection schema should match the ones we use internally. -// Compare the last element to check if these go out of sync. -static_assert(BASE_TYPE_UNION == - static_cast<BaseType>(reflection::Union), - "enums don't match"); - -// Any parsing calls have to be wrapped in this macro, which automates -// handling of recursive error checking a bit. It will check the received -// CheckedError object, and return straight away on error. -#define ECHECK(call) { auto ce = (call); if (ce.Check()) return ce; } - -// These two functions are called hundreds of times below, so define a short -// form: -#define NEXT() ECHECK(Next()) -#define EXPECT(tok) ECHECK(Expect(tok)) - -static bool ValidateUTF8(const std::string &str) { - const char *s = &str[0]; - const char * const sEnd = s + str.length(); - while (s < sEnd) { - if (FromUTF8(&s) < 0) { - return false; - } - } - return true; -} - -CheckedError Parser::Error(const std::string &msg) { - error_ = file_being_parsed_.length() ? AbsolutePath(file_being_parsed_) : ""; - #ifdef _WIN32 - error_ += "(" + NumToString(line_) + ")"; // MSVC alike - #else - if (file_being_parsed_.length()) error_ += ":"; - error_ += NumToString(line_) + ":0"; // gcc alike - #endif - error_ += ": error: " + msg; - return CheckedError(true); -} - -inline CheckedError NoError() { return CheckedError(false); } - -inline std::string OutOfRangeErrorMsg(int64_t val, const std::string &op, - int64_t limit) { - const std::string cause = NumToString(val) + op + NumToString(limit); - return "constant does not fit (" + cause + ")"; -} - -// Ensure that integer values we parse fit inside the declared integer type. -CheckedError Parser::CheckInRange(int64_t val, int64_t min, int64_t max) { - if (val < min) - return Error(OutOfRangeErrorMsg(val, " < ", min)); - else if (val > max) - return Error(OutOfRangeErrorMsg(val, " > ", max)); - else - return NoError(); -} - -// atot: templated version of atoi/atof: convert a string to an instance of T. -template<typename T> inline CheckedError atot(const char *s, Parser &parser, - T *val) { - int64_t i = StringToInt(s); - const int64_t min = std::numeric_limits<T>::min(); - const int64_t max = std::numeric_limits<T>::max(); - ECHECK(parser.CheckInRange(i, min, max)); - *val = (T)i; - return NoError(); -} -template<> inline CheckedError atot<uint64_t>(const char *s, Parser &parser, - uint64_t *val) { - (void)parser; - *val = StringToUInt(s); - return NoError(); -} -template<> inline CheckedError atot<bool>(const char *s, Parser &parser, - bool *val) { - (void)parser; - *val = 0 != atoi(s); - return NoError(); -} -template<> inline CheckedError atot<float>(const char *s, Parser &parser, - float *val) { - (void)parser; - *val = static_cast<float>(strtod(s, nullptr)); - return NoError(); -} -template<> inline CheckedError atot<double>(const char *s, Parser &parser, - double *val) { - (void)parser; - *val = strtod(s, nullptr); - return NoError(); -} - -template<> inline CheckedError atot<Offset<void>>(const char *s, Parser &parser, - Offset<void> *val) { - (void)parser; - *val = Offset<void>(atoi(s)); - return NoError(); -} - -std::string Namespace::GetFullyQualifiedName(const std::string &name, - size_t max_components) const { - // Early exit if we don't have a defined namespace. - if (components.size() == 0 || !max_components) { - return name; - } - std::stringstream stream; - for (size_t i = 0; i < std::min(components.size(), max_components); - i++) { - if (i) { - stream << "."; - } - stream << components[i]; - } - if (name.length()) stream << "." << name; - return stream.str(); -} - - - -// Declare tokens we'll use. Single character tokens are represented by their -// ascii character code (e.g. '{'), others above 256. -#define FLATBUFFERS_GEN_TOKENS(TD) \ - TD(Eof, 256, "end of file") \ - TD(StringConstant, 257, "string constant") \ - TD(IntegerConstant, 258, "integer constant") \ - TD(FloatConstant, 259, "float constant") \ - TD(Identifier, 260, "identifier") \ - TD(Table, 261, "table") \ - TD(Struct, 262, "struct") \ - TD(Enum, 263, "enum") \ - TD(Union, 264, "union") \ - TD(NameSpace, 265, "namespace") \ - TD(RootType, 266, "root_type") \ - TD(FileIdentifier, 267, "file_identifier") \ - TD(FileExtension, 268, "file_extension") \ - TD(Include, 269, "include") \ - TD(Attribute, 270, "attribute") \ - TD(Null, 271, "null") \ - TD(Service, 272, "rpc_service") \ - TD(NativeInclude, 273, "native_include") -#ifdef __GNUC__ -__extension__ // Stop GCC complaining about trailing comma with -Wpendantic. -#endif -enum { - #define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) kToken ## NAME = VALUE, - FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN) - #undef FLATBUFFERS_TOKEN - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - kToken ## ENUM, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD -}; - -static std::string TokenToString(int t) { - static const char *tokens[] = { - #define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) STRING, - FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN) - #undef FLATBUFFERS_TOKEN - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - IDLTYPE, - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - }; - if (t < 256) { // A single ascii char token. - std::string s; - s.append(1, static_cast<char>(t)); - return s; - } else { // Other tokens. - return tokens[t - 256]; - } -} - -std::string Parser::TokenToStringId(int t) { - return TokenToString(t) + (t == kTokenIdentifier ? ": " + attribute_ : ""); -} - -// Parses exactly nibbles worth of hex digits into a number, or error. -CheckedError Parser::ParseHexNum(int nibbles, uint64_t *val) { - for (int i = 0; i < nibbles; i++) - if (!isxdigit(static_cast<const unsigned char>(cursor_[i]))) - return Error("escape code must be followed by " + NumToString(nibbles) + - " hex digits"); - std::string target(cursor_, cursor_ + nibbles); - *val = StringToUInt(target.c_str(), nullptr, 16); - cursor_ += nibbles; - return NoError(); -} - -CheckedError Parser::SkipByteOrderMark() { - if (static_cast<unsigned char>(*cursor_) != 0xef) return NoError(); - cursor_++; - if (static_cast<unsigned char>(*cursor_) != 0xbb) return Error("invalid utf-8 byte order mark"); - cursor_++; - if (static_cast<unsigned char>(*cursor_) != 0xbf) return Error("invalid utf-8 byte order mark"); - cursor_++; - return NoError(); -} - -bool IsIdentifierStart(char c) { - return isalpha(static_cast<unsigned char>(c)) || c == '_'; -} - -CheckedError Parser::Next() { - doc_comment_.clear(); - bool seen_newline = false; - attribute_.clear(); - for (;;) { - char c = *cursor_++; - token_ = c; - switch (c) { - case '\0': cursor_--; token_ = kTokenEof; return NoError(); - case ' ': case '\r': case '\t': break; - case '\n': line_++; seen_newline = true; break; - case '{': case '}': case '(': case ')': case '[': case ']': - case ',': case ':': case ';': case '=': return NoError(); - case '.': - if(!isdigit(static_cast<const unsigned char>(*cursor_))) return NoError(); - return Error("floating point constant can\'t start with \".\""); - case '\"': - case '\'': { - int unicode_high_surrogate = -1; - - while (*cursor_ != c) { - if (*cursor_ < ' ' && *cursor_ >= 0) - return Error("illegal character in string constant"); - if (*cursor_ == '\\') { - cursor_++; - if (unicode_high_surrogate != -1 && - *cursor_ != 'u') { - return Error( - "illegal Unicode sequence (unpaired high surrogate)"); - } - switch (*cursor_) { - case 'n': attribute_ += '\n'; cursor_++; break; - case 't': attribute_ += '\t'; cursor_++; break; - case 'r': attribute_ += '\r'; cursor_++; break; - case 'b': attribute_ += '\b'; cursor_++; break; - case 'f': attribute_ += '\f'; cursor_++; break; - case '\"': attribute_ += '\"'; cursor_++; break; - case '\'': attribute_ += '\''; cursor_++; break; - case '\\': attribute_ += '\\'; cursor_++; break; - case '/': attribute_ += '/'; cursor_++; break; - case 'x': { // Not in the JSON standard - cursor_++; - uint64_t val; - ECHECK(ParseHexNum(2, &val)); - attribute_ += static_cast<char>(val); - break; - } - case 'u': { - cursor_++; - uint64_t val; - ECHECK(ParseHexNum(4, &val)); - if (val >= 0xD800 && val <= 0xDBFF) { - if (unicode_high_surrogate != -1) { - return Error( - "illegal Unicode sequence (multiple high surrogates)"); - } else { - unicode_high_surrogate = static_cast<int>(val); - } - } else if (val >= 0xDC00 && val <= 0xDFFF) { - if (unicode_high_surrogate == -1) { - return Error( - "illegal Unicode sequence (unpaired low surrogate)"); - } else { - int code_point = 0x10000 + - ((unicode_high_surrogate & 0x03FF) << 10) + - (val & 0x03FF); - ToUTF8(code_point, &attribute_); - unicode_high_surrogate = -1; - } - } else { - if (unicode_high_surrogate != -1) { - return Error( - "illegal Unicode sequence (unpaired high surrogate)"); - } - ToUTF8(static_cast<int>(val), &attribute_); - } - break; - } - default: return Error("unknown escape code in string constant"); - } - } else { // printable chars + UTF-8 bytes - if (unicode_high_surrogate != -1) { - return Error( - "illegal Unicode sequence (unpaired high surrogate)"); - } - attribute_ += *cursor_++; - } - } - if (unicode_high_surrogate != -1) { - return Error( - "illegal Unicode sequence (unpaired high surrogate)"); - } - cursor_++; - if (!opts.allow_non_utf8 && !ValidateUTF8(attribute_)) { - return Error("illegal UTF-8 sequence"); - } - token_ = kTokenStringConstant; - return NoError(); - } - case '/': - if (*cursor_ == '/') { - const char *start = ++cursor_; - while (*cursor_ && *cursor_ != '\n' && *cursor_ != '\r') cursor_++; - if (*start == '/') { // documentation comment - if (cursor_ != source_ && !seen_newline) - return Error( - "a documentation comment should be on a line on its own"); - doc_comment_.push_back(std::string(start + 1, cursor_)); - } - break; - } else if (*cursor_ == '*') { - cursor_++; - // TODO: make nested. - while (*cursor_ != '*' || cursor_[1] != '/') { - if (*cursor_ == '\n') line_++; - if (!*cursor_) return Error("end of file in comment"); - cursor_++; - } - cursor_ += 2; - break; - } - // fall thru - default: - if (IsIdentifierStart(c)) { - // Collect all chars of an identifier: - const char *start = cursor_ - 1; - while (isalnum(static_cast<unsigned char>(*cursor_)) || - *cursor_ == '_') - cursor_++; - attribute_.append(start, cursor_); - // First, see if it is a type keyword from the table of types: - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - if (attribute_ == IDLTYPE) { \ - token_ = kToken ## ENUM; \ - return NoError(); \ - } - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - // If it's a boolean constant keyword, turn those into integers, - // which simplifies our logic downstream. - if (attribute_ == "true" || attribute_ == "false") { - attribute_ = NumToString(attribute_ == "true"); - token_ = kTokenIntegerConstant; - return NoError(); - } - // Check for declaration keywords: - if (attribute_ == "table") { - token_ = kTokenTable; - return NoError(); - } - if (attribute_ == "struct") { - token_ = kTokenStruct; - return NoError(); - } - if (attribute_ == "enum") { - token_ = kTokenEnum; - return NoError(); - } - if (attribute_ == "union") { - token_ = kTokenUnion; - return NoError(); - } - if (attribute_ == "namespace") { - token_ = kTokenNameSpace; - return NoError(); - } - if (attribute_ == "root_type") { - token_ = kTokenRootType; - return NoError(); - } - if (attribute_ == "include") { - token_ = kTokenInclude; - return NoError(); - } - if (attribute_ == "attribute") { - token_ = kTokenAttribute; - return NoError(); - } - if (attribute_ == "file_identifier") { - token_ = kTokenFileIdentifier; - return NoError(); - } - if (attribute_ == "file_extension") { - token_ = kTokenFileExtension; - return NoError(); - } - if (attribute_ == "null") { - token_ = kTokenNull; - return NoError(); - } - if (attribute_ == "rpc_service") { - token_ = kTokenService; - return NoError(); - } - if (attribute_ == "native_include") { - token_ = kTokenNativeInclude; - return NoError(); - } - // If not, it is a user-defined identifier: - token_ = kTokenIdentifier; - return NoError(); - } else if (isdigit(static_cast<unsigned char>(c)) || c == '-') { - const char *start = cursor_ - 1; - if (c == '-' && *cursor_ == '0' && - (cursor_[1] == 'x' || cursor_[1] == 'X')) { - ++start; - ++cursor_; - attribute_.append(&c, &c + 1); - c = '0'; - } - if (c == '0' && (*cursor_ == 'x' || *cursor_ == 'X')) { - cursor_++; - while (isxdigit(static_cast<unsigned char>(*cursor_))) cursor_++; - attribute_.append(start + 2, cursor_); - attribute_ = NumToString(static_cast<int64_t>( - StringToUInt(attribute_.c_str(), nullptr, 16))); - token_ = kTokenIntegerConstant; - return NoError(); - } - while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++; - if (*cursor_ == '.' || *cursor_ == 'e' || *cursor_ == 'E') { - if (*cursor_ == '.') { - cursor_++; - while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++; - } - // See if this float has a scientific notation suffix. Both JSON - // and C++ (through strtod() we use) have the same format: - if (*cursor_ == 'e' || *cursor_ == 'E') { - cursor_++; - if (*cursor_ == '+' || *cursor_ == '-') cursor_++; - while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++; - } - token_ = kTokenFloatConstant; - } else { - token_ = kTokenIntegerConstant; - } - attribute_.append(start, cursor_); - return NoError(); - } - std::string ch; - ch = c; - if (c < ' ' || c > '~') ch = "code: " + NumToString(c); - return Error("illegal character: " + ch); - } - } -} - -// Check if a given token is next. -bool Parser::Is(int t) { - return t == token_; -} - -// Expect a given token to be next, consume it, or error if not present. -CheckedError Parser::Expect(int t) { - if (t != token_) { - return Error("expecting: " + TokenToString(t) + " instead got: " + - TokenToStringId(token_)); - } - NEXT(); - return NoError(); -} - -CheckedError Parser::ParseNamespacing(std::string *id, std::string *last) { - while (Is('.')) { - NEXT(); - *id += "."; - *id += attribute_; - if (last) *last = attribute_; - EXPECT(kTokenIdentifier); - } - return NoError(); -} - -EnumDef *Parser::LookupEnum(const std::string &id) { - // Search thru parent namespaces. - for (int components = static_cast<int>(namespaces_.back()->components.size()); - components >= 0; components--) { - auto ed = enums_.Lookup( - namespaces_.back()->GetFullyQualifiedName(id, components)); - if (ed) return ed; - } - return nullptr; -} - -CheckedError Parser::ParseTypeIdent(Type &type) { - std::string id = attribute_; - EXPECT(kTokenIdentifier); - ECHECK(ParseNamespacing(&id, nullptr)); - auto enum_def = LookupEnum(id); - if (enum_def) { - type = enum_def->underlying_type; - if (enum_def->is_union) type.base_type = BASE_TYPE_UNION; - } else { - type.base_type = BASE_TYPE_STRUCT; - type.struct_def = LookupCreateStruct(id); - } - return NoError(); -} - -// Parse any IDL type. -CheckedError Parser::ParseType(Type &type) { - if (token_ >= kTokenBOOL && token_ <= kTokenSTRING) { - type.base_type = static_cast<BaseType>(token_ - kTokenNONE); - NEXT(); - } else { - if (token_ == kTokenIdentifier) { - ECHECK(ParseTypeIdent(type)); - } else if (token_ == '[') { - NEXT(); - Type subtype; - ECHECK(ParseType(subtype)); - if (subtype.base_type == BASE_TYPE_VECTOR) { - // We could support this, but it will complicate things, and it's - // easier to work around with a struct around the inner vector. - return Error( - "nested vector types not supported (wrap in table first)."); - } - type = Type(BASE_TYPE_VECTOR, subtype.struct_def, subtype.enum_def); - type.element = subtype.base_type; - EXPECT(']'); - } else { - return Error("illegal type syntax"); - } - } - return NoError(); -} - -CheckedError Parser::AddField(StructDef &struct_def, const std::string &name, - const Type &type, FieldDef **dest) { - auto &field = *new FieldDef(); - field.value.offset = - FieldIndexToOffset(static_cast<voffset_t>(struct_def.fields.vec.size())); - field.name = name; - field.file = struct_def.file; - field.value.type = type; - if (struct_def.fixed) { // statically compute the field offset - auto size = InlineSize(type); - auto alignment = InlineAlignment(type); - // structs_ need to have a predictable format, so we need to align to - // the largest scalar - struct_def.minalign = std::max(struct_def.minalign, alignment); - struct_def.PadLastField(alignment); - field.value.offset = static_cast<voffset_t>(struct_def.bytesize); - struct_def.bytesize += size; - } - if (struct_def.fields.Add(name, &field)) - return Error("field already exists: " + name); - *dest = &field; - return NoError(); -} - -CheckedError Parser::ParseField(StructDef &struct_def) { - std::string name = attribute_; - std::vector<std::string> dc = doc_comment_; - EXPECT(kTokenIdentifier); - EXPECT(':'); - Type type; - ECHECK(ParseType(type)); - - if (struct_def.fixed && !IsScalar(type.base_type) && !IsStruct(type)) - return Error("structs_ may contain only scalar or struct fields"); - - FieldDef *typefield = nullptr; - if (type.base_type == BASE_TYPE_UNION) { - // For union fields, add a second auto-generated field to hold the type, - // with a special suffix. - ECHECK(AddField(struct_def, name + UnionTypeFieldSuffix(), - type.enum_def->underlying_type, &typefield)); - } else if (type.base_type == BASE_TYPE_VECTOR && - type.element == BASE_TYPE_UNION) { - // Only cpp supports the union vector feature so far. - if (opts.lang_to_generate != IDLOptions::kCpp) { - return Error("Vectors of unions are not yet supported in all " - "the specified programming languages."); - } - // For vector of union fields, add a second auto-generated vector field to - // hold the types, with a special suffix. - Type union_vector(BASE_TYPE_VECTOR, nullptr, type.enum_def); - union_vector.element = BASE_TYPE_UTYPE; - ECHECK(AddField(struct_def, name + UnionTypeFieldSuffix(), - union_vector, &typefield)); - } - - FieldDef *field; - ECHECK(AddField(struct_def, name, type, &field)); - - if (token_ == '=') { - NEXT(); - if (!IsScalar(type.base_type)) - return Error("default values currently only supported for scalars"); - ECHECK(ParseSingleValue(field->value)); - } - if (IsFloat(field->value.type.base_type)) { - if (!strpbrk(field->value.constant.c_str(), ".eE")) - field->value.constant += ".0"; - } - - if (type.enum_def && - IsScalar(type.base_type) && - !struct_def.fixed && - !type.enum_def->attributes.Lookup("bit_flags") && - !type.enum_def->ReverseLookup(static_cast<int>( - StringToInt(field->value.constant.c_str())))) - return Error("enum " + type.enum_def->name + - " does not have a declaration for this field\'s default of " + - field->value.constant); - - field->doc_comment = dc; - ECHECK(ParseMetaData(&field->attributes)); - field->deprecated = field->attributes.Lookup("deprecated") != nullptr; - auto hash_name = field->attributes.Lookup("hash"); - if (hash_name) { - switch (type.base_type) { - case BASE_TYPE_INT: - case BASE_TYPE_UINT: { - if (FindHashFunction32(hash_name->constant.c_str()) == nullptr) - return Error("Unknown hashing algorithm for 32 bit types: " + - hash_name->constant); - break; - } - case BASE_TYPE_LONG: - case BASE_TYPE_ULONG: { - if (FindHashFunction64(hash_name->constant.c_str()) == nullptr) - return Error("Unknown hashing algorithm for 64 bit types: " + - hash_name->constant); - break; - } - default: - return Error( - "only int, uint, long and ulong data types support hashing."); - } - } - auto cpp_type = field->attributes.Lookup("cpp_type"); - if (cpp_type) { - if (!hash_name) - return Error("cpp_type can only be used with a hashed field"); - } - if (field->deprecated && struct_def.fixed) - return Error("can't deprecate fields in a struct"); - field->required = field->attributes.Lookup("required") != nullptr; - if (field->required && (struct_def.fixed || - IsScalar(field->value.type.base_type))) - return Error("only non-scalar fields in tables may be 'required'"); - field->key = field->attributes.Lookup("key") != nullptr; - if (field->key) { - if (struct_def.has_key) - return Error("only one field may be set as 'key'"); - struct_def.has_key = true; - if (!IsScalar(field->value.type.base_type)) { - field->required = true; - if (field->value.type.base_type != BASE_TYPE_STRING) - return Error("'key' field must be string or scalar type"); - } - } - - field->native_inline = field->attributes.Lookup("native_inline") != nullptr; - if (field->native_inline && !IsStruct(field->value.type)) - return Error("native_inline can only be defined on structs'"); - - auto nested = field->attributes.Lookup("nested_flatbuffer"); - if (nested) { - if (nested->type.base_type != BASE_TYPE_STRING) - return Error( - "nested_flatbuffer attribute must be a string (the root type)"); - if (field->value.type.base_type != BASE_TYPE_VECTOR || - field->value.type.element != BASE_TYPE_UCHAR) - return Error( - "nested_flatbuffer attribute may only apply to a vector of ubyte"); - // This will cause an error if the root type of the nested flatbuffer - // wasn't defined elsewhere. - LookupCreateStruct(nested->constant); - } - - if (typefield) { - // If this field is a union, and it has a manually assigned id, - // the automatically added type field should have an id as well (of N - 1). - auto attr = field->attributes.Lookup("id"); - if (attr) { - auto id = atoi(attr->constant.c_str()); - auto val = new Value(); - val->type = attr->type; - val->constant = NumToString(id - 1); - typefield->attributes.Add("id", val); - } - } - - EXPECT(';'); - return NoError(); -} - -CheckedError Parser::ParseString(Value &val) { - auto s = attribute_; - EXPECT(kTokenStringConstant); - val.constant = NumToString(builder_.CreateString(s).o); - return NoError(); -} - -CheckedError Parser::ParseAnyValue(Value &val, FieldDef *field, - size_t parent_fieldn, - const StructDef *parent_struct_def) { - switch (val.type.base_type) { - case BASE_TYPE_UNION: { - assert(field); - std::string constant; - // Find corresponding type field we may have already parsed. - for (auto elem = field_stack_.rbegin(); - elem != field_stack_.rbegin() + parent_fieldn; ++elem) { - auto &type = elem->second->value.type; - if (type.base_type == BASE_TYPE_UTYPE && - type.enum_def == val.type.enum_def) { - constant = elem->first.constant; - break; - } - } - if (constant.empty()) { - // We haven't seen the type field yet. Sadly a lot of JSON writers - // output these in alphabetical order, meaning it comes after this - // value. So we scan past the value to find it, then come back here. - auto type_name = field->name + UnionTypeFieldSuffix(); - assert(parent_struct_def); - auto type_field = parent_struct_def->fields.Lookup(type_name); - assert(type_field); // Guaranteed by ParseField(). - // Remember where we are in the source file, so we can come back here. - auto backup = *static_cast<ParserState *>(this); - ECHECK(SkipAnyJsonValue()); // The table. - EXPECT(','); - auto next_name = attribute_; - if (Is(kTokenStringConstant)) { - NEXT(); - } else { - EXPECT(kTokenIdentifier); - } - if (next_name != type_name) - return Error("missing type field after this union value: " + - type_name); - EXPECT(':'); - Value type_val = type_field->value; - ECHECK(ParseAnyValue(type_val, type_field, 0, nullptr)); - constant = type_val.constant; - // Got the information we needed, now rewind: - *static_cast<ParserState *>(this) = backup; - } - uint8_t enum_idx; - ECHECK(atot(constant.c_str(), *this, &enum_idx)); - auto enum_val = val.type.enum_def->ReverseLookup(enum_idx); - if (!enum_val) return Error("illegal type id for: " + field->name); - if (enum_val->union_type.base_type == BASE_TYPE_STRUCT) { - ECHECK(ParseTable(*enum_val->union_type.struct_def, &val.constant, - nullptr)); - if (enum_val->union_type.struct_def->fixed) { - // All BASE_TYPE_UNION values are offsets, so turn this into one. - SerializeStruct(*enum_val->union_type.struct_def, val); - builder_.ClearOffsets(); - val.constant = NumToString(builder_.GetSize()); - } - } else if (enum_val->union_type.base_type == BASE_TYPE_STRING) { - ECHECK(ParseString(val)); - } else { - assert(false); - } - break; - } - case BASE_TYPE_STRUCT: - ECHECK(ParseTable(*val.type.struct_def, &val.constant, nullptr)); - break; - case BASE_TYPE_STRING: { - ECHECK(ParseString(val)); - break; - } - case BASE_TYPE_VECTOR: { - EXPECT('['); - uoffset_t off; - ECHECK(ParseVector(val.type.VectorType(), &off)); - val.constant = NumToString(off); - break; - } - case BASE_TYPE_INT: - case BASE_TYPE_UINT: - case BASE_TYPE_LONG: - case BASE_TYPE_ULONG: { - if (field && field->attributes.Lookup("hash") && - (token_ == kTokenIdentifier || token_ == kTokenStringConstant)) { - ECHECK(ParseHash(val, field)); - } else { - ECHECK(ParseSingleValue(val)); - } - break; - } - default: - ECHECK(ParseSingleValue(val)); - break; - } - return NoError(); -} - -void Parser::SerializeStruct(const StructDef &struct_def, const Value &val) { - assert(val.constant.length() == struct_def.bytesize); - builder_.Align(struct_def.minalign); - builder_.PushBytes(reinterpret_cast<const uint8_t *>(val.constant.c_str()), - struct_def.bytesize); - builder_.AddStructOffset(val.offset, builder_.GetSize()); -} - -CheckedError Parser::ParseTable(const StructDef &struct_def, std::string *value, - uoffset_t *ovalue) { - EXPECT('{'); - size_t fieldn = 0; - for (;;) { - if ((!opts.strict_json || !fieldn) && Is('}')) { NEXT(); break; } - std::string name = attribute_; - if (Is(kTokenStringConstant)) { - NEXT(); - } else { - EXPECT(opts.strict_json ? kTokenStringConstant : kTokenIdentifier); - } - auto field = struct_def.fields.Lookup(name); - if (!field) { - if (!opts.skip_unexpected_fields_in_json) { - return Error("unknown field: " + name); - } else { - EXPECT(':'); - ECHECK(SkipAnyJsonValue()); - } - } else { - EXPECT(':'); - if (Is(kTokenNull)) { - NEXT(); // Ignore this field. - } else { - Value val = field->value; - ECHECK(ParseAnyValue(val, field, fieldn, &struct_def)); - // Hardcoded insertion-sort with error-check. - // If fields are specified in order, then this loop exits immediately. - auto elem = field_stack_.rbegin(); - for (; elem != field_stack_.rbegin() + fieldn; ++elem) { - auto existing_field = elem->second; - if (existing_field == field) - return Error("field set more than once: " + field->name); - if (existing_field->value.offset < field->value.offset) break; - } - // Note: elem points to before the insertion point, thus .base() points - // to the correct spot. - field_stack_.insert(elem.base(), std::make_pair(val, field)); - fieldn++; - } - } - if (Is('}')) { NEXT(); break; } - EXPECT(','); - } - - if (struct_def.fixed && fieldn != struct_def.fields.vec.size()) - return Error("struct: wrong number of initializers: " + struct_def.name); - - auto start = struct_def.fixed - ? builder_.StartStruct(struct_def.minalign) - : builder_.StartTable(); - - for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; - size; - size /= 2) { - // Go through elements in reverse, since we're building the data backwards. - for (auto it = field_stack_.rbegin(); - it != field_stack_.rbegin() + fieldn; ++it) { - auto &field_value = it->first; - auto field = it->second; - if (!struct_def.sortbysize || - size == SizeOf(field_value.type.base_type)) { - switch (field_value.type.base_type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - builder_.Pad(field->padding); \ - if (struct_def.fixed) { \ - CTYPE val; \ - ECHECK(atot(field_value.constant.c_str(), *this, &val)); \ - builder_.PushElement(val); \ - } else { \ - CTYPE val, valdef; \ - ECHECK(atot(field_value.constant.c_str(), *this, &val)); \ - ECHECK(atot(field->value.constant.c_str(), *this, &valdef)); \ - builder_.AddElement(field_value.offset, val, valdef); \ - } \ - break; - FLATBUFFERS_GEN_TYPES_SCALAR(FLATBUFFERS_TD); - #undef FLATBUFFERS_TD - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \ - PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - builder_.Pad(field->padding); \ - if (IsStruct(field->value.type)) { \ - SerializeStruct(*field->value.type.struct_def, field_value); \ - } else { \ - CTYPE val; \ - ECHECK(atot(field_value.constant.c_str(), *this, &val)); \ - builder_.AddOffset(field_value.offset, val); \ - } \ - break; - FLATBUFFERS_GEN_TYPES_POINTER(FLATBUFFERS_TD); - #undef FLATBUFFERS_TD - } - } - } - } - for (size_t i = 0; i < fieldn; i++) field_stack_.pop_back(); - - if (struct_def.fixed) { - builder_.ClearOffsets(); - builder_.EndStruct(); - assert(value); - // Temporarily store this struct in the value string, since it is to - // be serialized in-place elsewhere. - value->assign( - reinterpret_cast<const char *>(builder_.GetCurrentBufferPointer()), - struct_def.bytesize); - builder_.PopBytes(struct_def.bytesize); - assert(!ovalue); - } else { - auto val = builder_.EndTable(start, - static_cast<voffset_t>(struct_def.fields.vec.size())); - if (ovalue) *ovalue = val; - if (value) *value = NumToString(val); - } - return NoError(); -} - -CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue) { - int count = 0; - for (;;) { - if ((!opts.strict_json || !count) && Is(']')) { NEXT(); break; } - Value val; - val.type = type; - ECHECK(ParseAnyValue(val, nullptr, 0, nullptr)); - field_stack_.push_back(std::make_pair(val, nullptr)); - count++; - if (Is(']')) { NEXT(); break; } - EXPECT(','); - } - - builder_.StartVector(count * InlineSize(type) / InlineAlignment(type), - InlineAlignment(type)); - for (int i = 0; i < count; i++) { - // start at the back, since we're building the data backwards. - auto &val = field_stack_.back().first; - switch (val.type.base_type) { - #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ - case BASE_TYPE_ ## ENUM: \ - if (IsStruct(val.type)) SerializeStruct(*val.type.struct_def, val); \ - else { \ - CTYPE elem; \ - ECHECK(atot(val.constant.c_str(), *this, &elem)); \ - builder_.PushElement(elem); \ - } \ - break; - FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD) - #undef FLATBUFFERS_TD - } - field_stack_.pop_back(); - } - - builder_.ClearOffsets(); - *ovalue = builder_.EndVector(count); - return NoError(); -} - -CheckedError Parser::ParseMetaData(SymbolTable<Value> *attributes) { - if (Is('(')) { - NEXT(); - for (;;) { - auto name = attribute_; - EXPECT(kTokenIdentifier); - if (known_attributes_.find(name) == known_attributes_.end()) - return Error("user define attributes must be declared before use: " + - name); - auto e = new Value(); - attributes->Add(name, e); - if (Is(':')) { - NEXT(); - ECHECK(ParseSingleValue(*e)); - } - if (Is(')')) { NEXT(); break; } - EXPECT(','); - } - } - return NoError(); -} - -CheckedError Parser::TryTypedValue(int dtoken, bool check, Value &e, - BaseType req, bool *destmatch) { - bool match = dtoken == token_; - if (match) { - *destmatch = true; - e.constant = attribute_; - if (!check) { - if (e.type.base_type == BASE_TYPE_NONE) { - e.type.base_type = req; - } else { - return Error(std::string("type mismatch: expecting: ") + - kTypeNames[e.type.base_type] + - ", found: " + - kTypeNames[req]); - } - } - NEXT(); - } - return NoError(); -} - -CheckedError Parser::ParseEnumFromString(Type &type, int64_t *result) { - *result = 0; - // Parse one or more enum identifiers, separated by spaces. - const char *next = attribute_.c_str(); - do { - const char *divider = strchr(next, ' '); - std::string word; - if (divider) { - word = std::string(next, divider); - next = divider + strspn(divider, " "); - } else { - word = next; - next += word.length(); - } - if (type.enum_def) { // The field has an enum type - auto enum_val = type.enum_def->vals.Lookup(word); - if (!enum_val) - return Error("unknown enum value: " + word + - ", for enum: " + type.enum_def->name); - *result |= enum_val->value; - } else { // No enum type, probably integral field. - if (!IsInteger(type.base_type)) - return Error("not a valid value for this field: " + word); - // TODO: could check if its a valid number constant here. - const char *dot = strrchr(word.c_str(), '.'); - if (!dot) - return Error("enum values need to be qualified by an enum type"); - std::string enum_def_str(word.c_str(), dot); - std::string enum_val_str(dot + 1, word.c_str() + word.length()); - auto enum_def = LookupEnum(enum_def_str); - if (!enum_def) return Error("unknown enum: " + enum_def_str); - auto enum_val = enum_def->vals.Lookup(enum_val_str); - if (!enum_val) return Error("unknown enum value: " + enum_val_str); - *result |= enum_val->value; - } - } while(*next); - return NoError(); -} - - -CheckedError Parser::ParseHash(Value &e, FieldDef* field) { - assert(field); - Value *hash_name = field->attributes.Lookup("hash"); - switch (e.type.base_type) { - case BASE_TYPE_INT: { - auto hash = FindHashFunction32(hash_name->constant.c_str()); - int32_t hashed_value = static_cast<int32_t>(hash(attribute_.c_str())); - e.constant = NumToString(hashed_value); - break; - } - case BASE_TYPE_UINT: { - auto hash = FindHashFunction32(hash_name->constant.c_str()); - uint32_t hashed_value = hash(attribute_.c_str()); - e.constant = NumToString(hashed_value); - break; - } - case BASE_TYPE_LONG: { - auto hash = FindHashFunction64(hash_name->constant.c_str()); - int64_t hashed_value = static_cast<int64_t>(hash(attribute_.c_str())); - e.constant = NumToString(hashed_value); - break; - } - case BASE_TYPE_ULONG: { - auto hash = FindHashFunction64(hash_name->constant.c_str()); - uint64_t hashed_value = hash(attribute_.c_str()); - e.constant = NumToString(hashed_value); - break; - } - default: - assert(0); - } - NEXT(); - return NoError(); -} - -CheckedError Parser::ParseSingleValue(Value &e) { - // First see if this could be a conversion function: - if (token_ == kTokenIdentifier && *cursor_ == '(') { - auto functionname = attribute_; - NEXT(); - EXPECT('('); - ECHECK(ParseSingleValue(e)); - EXPECT(')'); - #define FLATBUFFERS_FN_DOUBLE(name, op) \ - if (functionname == name) { \ - auto x = strtod(e.constant.c_str(), nullptr); \ - e.constant = NumToString(op); \ - } - FLATBUFFERS_FN_DOUBLE("deg", x / M_PI * 180); - FLATBUFFERS_FN_DOUBLE("rad", x * M_PI / 180); - FLATBUFFERS_FN_DOUBLE("sin", sin(x)); - FLATBUFFERS_FN_DOUBLE("cos", cos(x)); - FLATBUFFERS_FN_DOUBLE("tan", tan(x)); - FLATBUFFERS_FN_DOUBLE("asin", asin(x)); - FLATBUFFERS_FN_DOUBLE("acos", acos(x)); - FLATBUFFERS_FN_DOUBLE("atan", atan(x)); - // TODO(wvo): add more useful conversion functions here. - #undef FLATBUFFERS_FN_DOUBLE - // Then check if this could be a string/identifier enum value: - } else if (e.type.base_type != BASE_TYPE_STRING && - e.type.base_type != BASE_TYPE_NONE && - (token_ == kTokenIdentifier || token_ == kTokenStringConstant)) { - if (IsIdentifierStart(attribute_[0])) { // Enum value. - int64_t val; - ECHECK(ParseEnumFromString(e.type, &val)); - e.constant = NumToString(val); - NEXT(); - } else { // Numeric constant in string. - if (IsInteger(e.type.base_type)) { - char *end; - e.constant = NumToString(StringToInt(attribute_.c_str(), &end)); - if (*end) - return Error("invalid integer: " + attribute_); - } else if (IsFloat(e.type.base_type)) { - char *end; - e.constant = NumToString(strtod(attribute_.c_str(), &end)); - if (*end) - return Error("invalid float: " + attribute_); - } else { - assert(0); // Shouldn't happen, we covered all types. - e.constant = "0"; - } - NEXT(); - } - } else { - bool match = false; - ECHECK(TryTypedValue(kTokenIntegerConstant, - IsScalar(e.type.base_type), - e, - BASE_TYPE_INT, - &match)); - ECHECK(TryTypedValue(kTokenFloatConstant, - IsFloat(e.type.base_type), - e, - BASE_TYPE_FLOAT, - &match)); - ECHECK(TryTypedValue(kTokenStringConstant, - e.type.base_type == BASE_TYPE_STRING, - e, - BASE_TYPE_STRING, - &match)); - if (!match) - return Error("cannot parse value starting with: " + - TokenToStringId(token_)); - } - return NoError(); -} - -StructDef *Parser::LookupCreateStruct(const std::string &name, - bool create_if_new, bool definition) { - std::string qualified_name = namespaces_.back()->GetFullyQualifiedName(name); - // See if it exists pre-declared by an unqualified use. - auto struct_def = structs_.Lookup(name); - if (struct_def && struct_def->predecl) { - if (definition) { - // Make sure it has the current namespace, and is registered under its - // qualified name. - struct_def->defined_namespace = namespaces_.back(); - structs_.Move(name, qualified_name); - } - return struct_def; - } - // See if it exists pre-declared by an qualified use. - struct_def = structs_.Lookup(qualified_name); - if (struct_def && struct_def->predecl) { - if (definition) { - // Make sure it has the current namespace. - struct_def->defined_namespace = namespaces_.back(); - } - return struct_def; - } - if (!definition) { - // Search thru parent namespaces. - for (size_t components = namespaces_.back()->components.size(); - components && !struct_def; components--) { - struct_def = structs_.Lookup( - namespaces_.back()->GetFullyQualifiedName(name, components - 1)); - } - } - if (!struct_def && create_if_new) { - struct_def = new StructDef(); - if (definition) { - structs_.Add(qualified_name, struct_def); - struct_def->name = name; - struct_def->defined_namespace = namespaces_.back(); - } else { - // Not a definition. - // Rather than failing, we create a "pre declared" StructDef, due to - // circular references, and check for errors at the end of parsing. - // It is defined in the root namespace, since we don't know what the - // final namespace will be. - // TODO: maybe safer to use special namespace? - structs_.Add(name, struct_def); - struct_def->name = name; - struct_def->defined_namespace = new Namespace(); - namespaces_.insert(namespaces_.begin(), struct_def->defined_namespace); - } - } - return struct_def; -} - -CheckedError Parser::ParseEnum(bool is_union, EnumDef **dest) { - std::vector<std::string> enum_comment = doc_comment_; - NEXT(); - std::string enum_name = attribute_; - EXPECT(kTokenIdentifier); - auto &enum_def = *new EnumDef(); - enum_def.name = enum_name; - enum_def.file = file_being_parsed_; - enum_def.doc_comment = enum_comment; - enum_def.is_union = is_union; - enum_def.defined_namespace = namespaces_.back(); - if (enums_.Add(namespaces_.back()->GetFullyQualifiedName(enum_name), - &enum_def)) - return Error("enum already exists: " + enum_name); - if (is_union) { - enum_def.underlying_type.base_type = BASE_TYPE_UTYPE; - enum_def.underlying_type.enum_def = &enum_def; - } else { - if (opts.proto_mode) { - enum_def.underlying_type.base_type = BASE_TYPE_INT; - } else { - // Give specialized error message, since this type spec used to - // be optional in the first FlatBuffers release. - if (!Is(':')) { - return Error("must specify the underlying integer type for this" - " enum (e.g. \': short\', which was the default)."); - } else { - NEXT(); - } - // Specify the integer type underlying this enum. - ECHECK(ParseType(enum_def.underlying_type)); - if (!IsInteger(enum_def.underlying_type.base_type)) - return Error("underlying enum type must be integral"); - } - // Make this type refer back to the enum it was derived from. - enum_def.underlying_type.enum_def = &enum_def; - } - ECHECK(ParseMetaData(&enum_def.attributes)); - EXPECT('{'); - if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0)); - for (;;) { - if (opts.proto_mode && attribute_ == "option") { - ECHECK(ParseProtoOption()); - } else { - auto value_name = attribute_; - auto full_name = value_name; - std::vector<std::string> value_comment = doc_comment_; - EXPECT(kTokenIdentifier); - if (is_union) { - ECHECK(ParseNamespacing(&full_name, &value_name)); - if (opts.union_value_namespacing) { - // Since we can't namespace the actual enum identifiers, turn - // namespace parts into part of the identifier. - value_name = full_name; - std::replace(value_name.begin(), value_name.end(), '.', '_'); - } - } - auto prevsize = enum_def.vals.vec.size(); - auto value = enum_def.vals.vec.size() - ? enum_def.vals.vec.back()->value + 1 - : 0; - auto &ev = *new EnumVal(value_name, value); - if (enum_def.vals.Add(value_name, &ev)) - return Error("enum value already exists: " + value_name); - ev.doc_comment = value_comment; - if (is_union) { - if (Is(':')) { - NEXT(); - ECHECK(ParseType(ev.union_type)); - if (ev.union_type.base_type != BASE_TYPE_STRUCT && - ev.union_type.base_type != BASE_TYPE_STRING) - return Error("union value type may only be table/struct/string"); - enum_def.uses_type_aliases = true; - } else { - ev.union_type = Type(BASE_TYPE_STRUCT, LookupCreateStruct(full_name)); - } - } - if (Is('=')) { - NEXT(); - ev.value = StringToInt(attribute_.c_str()); - EXPECT(kTokenIntegerConstant); - if (!opts.proto_mode && prevsize && - enum_def.vals.vec[prevsize - 1]->value >= ev.value) - return Error("enum values must be specified in ascending order"); - } - if (opts.proto_mode && Is('[')) { - NEXT(); - // ignore attributes on enums. - while (token_ != ']') NEXT(); - NEXT(); - } - } - if (!Is(opts.proto_mode ? ';' : ',')) break; - NEXT(); - if (Is('}')) break; - } - EXPECT('}'); - if (enum_def.attributes.Lookup("bit_flags")) { - for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); - ++it) { - if (static_cast<size_t>((*it)->value) >= - SizeOf(enum_def.underlying_type.base_type) * 8) - return Error("bit flag out of range of underlying integral type"); - (*it)->value = 1LL << (*it)->value; - } - } - if (dest) *dest = &enum_def; - types_.Add(namespaces_.back()->GetFullyQualifiedName(enum_def.name), - new Type(BASE_TYPE_UNION, nullptr, &enum_def)); - return NoError(); -} - -CheckedError Parser::StartStruct(const std::string &name, StructDef **dest) { - auto &struct_def = *LookupCreateStruct(name, true, true); - if (!struct_def.predecl) return Error("datatype already exists: " + name); - struct_def.predecl = false; - struct_def.name = name; - struct_def.file = file_being_parsed_; - // Move this struct to the back of the vector just in case it was predeclared, - // to preserve declaration order. - *std::remove(structs_.vec.begin(), structs_.vec.end(), &struct_def) = &struct_def; - *dest = &struct_def; - return NoError(); -} - -CheckedError Parser::CheckClash(std::vector<FieldDef*> &fields, - StructDef *struct_def, - const char *suffix, - BaseType basetype) { - auto len = strlen(suffix); - for (auto it = fields.begin(); it != fields.end(); ++it) { - auto &fname = (*it)->name; - if (fname.length() > len && - fname.compare(fname.length() - len, len, suffix) == 0 && - (*it)->value.type.base_type != BASE_TYPE_UTYPE) { - auto field = struct_def->fields.Lookup( - fname.substr(0, fname.length() - len)); - if (field && field->value.type.base_type == basetype) - return Error("Field " + fname + - " would clash with generated functions for field " + - field->name); - } - } - return NoError(); -} - -static bool compareFieldDefs(const FieldDef *a, const FieldDef *b) { - auto a_id = atoi(a->attributes.Lookup("id")->constant.c_str()); - auto b_id = atoi(b->attributes.Lookup("id")->constant.c_str()); - return a_id < b_id; -} - -CheckedError Parser::ParseDecl() { - std::vector<std::string> dc = doc_comment_; - bool fixed = Is(kTokenStruct); - if (fixed) NEXT() else EXPECT(kTokenTable); - std::string name = attribute_; - EXPECT(kTokenIdentifier); - StructDef *struct_def; - ECHECK(StartStruct(name, &struct_def)); - struct_def->doc_comment = dc; - struct_def->fixed = fixed; - ECHECK(ParseMetaData(&struct_def->attributes)); - struct_def->sortbysize = - struct_def->attributes.Lookup("original_order") == nullptr && !fixed; - EXPECT('{'); - while (token_ != '}') ECHECK(ParseField(*struct_def)); - auto force_align = struct_def->attributes.Lookup("force_align"); - if (fixed && force_align) { - auto align = static_cast<size_t>(atoi(force_align->constant.c_str())); - if (force_align->type.base_type != BASE_TYPE_INT || - align < struct_def->minalign || - align > FLATBUFFERS_MAX_ALIGNMENT || - align & (align - 1)) - return Error("force_align must be a power of two integer ranging from the" - "struct\'s natural alignment to " + - NumToString(FLATBUFFERS_MAX_ALIGNMENT)); - struct_def->minalign = align; - } - struct_def->PadLastField(struct_def->minalign); - // Check if this is a table that has manual id assignments - auto &fields = struct_def->fields.vec; - if (!struct_def->fixed && fields.size()) { - size_t num_id_fields = 0; - for (auto it = fields.begin(); it != fields.end(); ++it) { - if ((*it)->attributes.Lookup("id")) num_id_fields++; - } - // If any fields have ids.. - if (num_id_fields) { - // Then all fields must have them. - if (num_id_fields != fields.size()) - return Error( - "either all fields or no fields must have an 'id' attribute"); - // Simply sort by id, then the fields are the same as if no ids had - // been specified. - std::sort(fields.begin(), fields.end(), compareFieldDefs); - // Verify we have a contiguous set, and reassign vtable offsets. - for (int i = 0; i < static_cast<int>(fields.size()); i++) { - if (i != atoi(fields[i]->attributes.Lookup("id")->constant.c_str())) - return Error("field id\'s must be consecutive from 0, id " + - NumToString(i) + " missing or set twice"); - fields[i]->value.offset = FieldIndexToOffset(static_cast<voffset_t>(i)); - } - } - } - - ECHECK(CheckClash(fields, struct_def, UnionTypeFieldSuffix(), - BASE_TYPE_UNION)); - ECHECK(CheckClash(fields, struct_def, "Type", BASE_TYPE_UNION)); - ECHECK(CheckClash(fields, struct_def, "_length", BASE_TYPE_VECTOR)); - ECHECK(CheckClash(fields, struct_def, "Length", BASE_TYPE_VECTOR)); - ECHECK(CheckClash(fields, struct_def, "_byte_vector", BASE_TYPE_STRING)); - ECHECK(CheckClash(fields, struct_def, "ByteVector", BASE_TYPE_STRING)); - EXPECT('}'); - types_.Add(namespaces_.back()->GetFullyQualifiedName(struct_def->name), - new Type(BASE_TYPE_STRUCT, struct_def, nullptr)); - return NoError(); -} - -CheckedError Parser::ParseService() { - std::vector<std::string> service_comment = doc_comment_; - NEXT(); - auto service_name = attribute_; - EXPECT(kTokenIdentifier); - auto &service_def = *new ServiceDef(); - service_def.name = service_name; - service_def.file = file_being_parsed_; - service_def.doc_comment = service_comment; - service_def.defined_namespace = namespaces_.back(); - if (services_.Add(namespaces_.back()->GetFullyQualifiedName(service_name), - &service_def)) - return Error("service already exists: " + service_name); - ECHECK(ParseMetaData(&service_def.attributes)); - EXPECT('{'); - do { - auto rpc_name = attribute_; - EXPECT(kTokenIdentifier); - EXPECT('('); - Type reqtype, resptype; - ECHECK(ParseTypeIdent(reqtype)); - EXPECT(')'); - EXPECT(':'); - ECHECK(ParseTypeIdent(resptype)); - if (reqtype.base_type != BASE_TYPE_STRUCT || reqtype.struct_def->fixed || - resptype.base_type != BASE_TYPE_STRUCT || resptype.struct_def->fixed) - return Error("rpc request and response types must be tables"); - auto &rpc = *new RPCCall(); - rpc.name = rpc_name; - rpc.request = reqtype.struct_def; - rpc.response = resptype.struct_def; - if (service_def.calls.Add(rpc_name, &rpc)) - return Error("rpc already exists: " + rpc_name); - ECHECK(ParseMetaData(&rpc.attributes)); - EXPECT(';'); - } while (token_ != '}'); - NEXT(); - return NoError(); -} - -bool Parser::SetRootType(const char *name) { - root_struct_def_ = structs_.Lookup(name); - if (!root_struct_def_) - root_struct_def_ = structs_.Lookup( - namespaces_.back()->GetFullyQualifiedName(name)); - return root_struct_def_ != nullptr; -} - -void Parser::MarkGenerated() { - // This function marks all existing definitions as having already - // been generated, which signals no code for included files should be - // generated. - for (auto it = enums_.vec.begin(); - it != enums_.vec.end(); ++it) { - (*it)->generated = true; - } - for (auto it = structs_.vec.begin(); - it != structs_.vec.end(); ++it) { - (*it)->generated = true; - } - for (auto it = services_.vec.begin(); - it != services_.vec.end(); ++it) { - (*it)->generated = true; - } -} - -CheckedError Parser::ParseNamespace() { - NEXT(); - auto ns = new Namespace(); - namespaces_.push_back(ns); - if (token_ != ';') { - for (;;) { - ns->components.push_back(attribute_); - EXPECT(kTokenIdentifier); - if (Is('.')) NEXT() else break; - } - } - EXPECT(';'); - return NoError(); -} - -static bool compareEnumVals(const EnumVal *a, const EnumVal* b) { - return a->value < b->value; -} - -// Best effort parsing of .proto declarations, with the aim to turn them -// in the closest corresponding FlatBuffer equivalent. -// We parse everything as identifiers instead of keywords, since we don't -// want protobuf keywords to become invalid identifiers in FlatBuffers. -CheckedError Parser::ParseProtoDecl() { - bool isextend = attribute_ == "extend"; - if (attribute_ == "package") { - // These are identical in syntax to FlatBuffer's namespace decl. - ECHECK(ParseNamespace()); - } else if (attribute_ == "message" || isextend) { - std::vector<std::string> struct_comment = doc_comment_; - NEXT(); - StructDef *struct_def = nullptr; - if (isextend) { - if (Is('.')) NEXT(); // qualified names may start with a . ? - auto id = attribute_; - EXPECT(kTokenIdentifier); - ECHECK(ParseNamespacing(&id, nullptr)); - struct_def = LookupCreateStruct(id, false); - if (!struct_def) - return Error("cannot extend unknown message type: " + id); - } else { - std::string name = attribute_; - EXPECT(kTokenIdentifier); - ECHECK(StartStruct(name, &struct_def)); - // Since message definitions can be nested, we create a new namespace. - auto ns = new Namespace(); - // Copy of current namespace. - *ns = *namespaces_.back(); - // But with current message name. - ns->components.push_back(name); - namespaces_.push_back(ns); - } - struct_def->doc_comment = struct_comment; - ECHECK(ParseProtoFields(struct_def, isextend, false)); - if (!isextend) { - // We have to remove the nested namespace, but we can't just throw it - // away, so put it at the beginning of the vector. - auto ns = namespaces_.back(); - namespaces_.pop_back(); - namespaces_.insert(namespaces_.begin(), ns); - } - if (Is(';')) NEXT(); - } else if (attribute_ == "enum") { - // These are almost the same, just with different terminator: - EnumDef *enum_def; - ECHECK(ParseEnum(false, &enum_def)); - if (Is(';')) NEXT(); - // Protobuf allows them to be specified in any order, so sort afterwards. - auto &v = enum_def->vals.vec; - std::sort(v.begin(), v.end(), compareEnumVals); - - // Temp: remove any duplicates, as .fbs files can't handle them. - for (auto it = v.begin(); it != v.end(); ) { - if (it != v.begin() && it[0]->value == it[-1]->value) it = v.erase(it); - else ++it; - } - } else if (attribute_ == "syntax") { // Skip these. - NEXT(); - EXPECT('='); - EXPECT(kTokenStringConstant); - EXPECT(';'); - } else if (attribute_ == "option") { // Skip these. - ECHECK(ParseProtoOption()); - EXPECT(';'); - } else if (attribute_ == "service") { // Skip these. - NEXT(); - EXPECT(kTokenIdentifier); - ECHECK(ParseProtoCurliesOrIdent()); - } else { - return Error("don\'t know how to parse .proto declaration starting with " + - TokenToStringId(token_)); - } - return NoError(); -} - -CheckedError Parser::ParseProtoFields(StructDef *struct_def, bool isextend, - bool inside_oneof) { - EXPECT('{'); - while (token_ != '}') { - if (attribute_ == "message" || attribute_ == "extend" || - attribute_ == "enum") { - // Nested declarations. - ECHECK(ParseProtoDecl()); - } else if (attribute_ == "extensions") { // Skip these. - NEXT(); - EXPECT(kTokenIntegerConstant); - if (Is(kTokenIdentifier)) { - NEXT(); // to - NEXT(); // num - } - EXPECT(';'); - } else if (attribute_ == "option") { // Skip these. - ECHECK(ParseProtoOption()); - EXPECT(';'); - } else if (attribute_ == "reserved") { // Skip these. - NEXT(); - EXPECT(kTokenIntegerConstant); - while (Is(',')) { NEXT(); EXPECT(kTokenIntegerConstant); } - EXPECT(';'); - } else { - std::vector<std::string> field_comment = doc_comment_; - // Parse the qualifier. - bool required = false; - bool repeated = false; - bool oneof = false; - if (!inside_oneof) { - if (attribute_ == "optional") { - // This is the default. - EXPECT(kTokenIdentifier); - } else if (attribute_ == "required") { - required = true; - EXPECT(kTokenIdentifier); - } else if (attribute_ == "repeated") { - repeated = true; - EXPECT(kTokenIdentifier); - } else if (attribute_ == "oneof") { - oneof = true; - EXPECT(kTokenIdentifier); - } else { - // can't error, proto3 allows decls without any of the above. - } - } - StructDef *anonymous_struct = nullptr; - Type type; - if (attribute_ == "group" || oneof) { - if (!oneof) EXPECT(kTokenIdentifier); - auto name = "Anonymous" + NumToString(anonymous_counter++); - ECHECK(StartStruct(name, &anonymous_struct)); - type = Type(BASE_TYPE_STRUCT, anonymous_struct); - } else { - ECHECK(ParseTypeFromProtoType(&type)); - } - // Repeated elements get mapped to a vector. - if (repeated) { - type.element = type.base_type; - type.base_type = BASE_TYPE_VECTOR; - } - std::string name = attribute_; - // Protos may use our keywords "attribute" & "namespace" as an identifier. - if (Is(kTokenAttribute) || Is(kTokenNameSpace)) { - NEXT(); - // TODO: simpler to just not make these keywords? - name += "_"; // Have to make it not a keyword. - } else { - EXPECT(kTokenIdentifier); - } - if (!oneof) { - // Parse the field id. Since we're just translating schemas, not - // any kind of binary compatibility, we can safely ignore these, and - // assign our own. - EXPECT('='); - EXPECT(kTokenIntegerConstant); - } - FieldDef *field = nullptr; - if (isextend) { - // We allow a field to be re-defined when extending. - // TODO: are there situations where that is problematic? - field = struct_def->fields.Lookup(name); - } - if (!field) ECHECK(AddField(*struct_def, name, type, &field)); - field->doc_comment = field_comment; - if (!IsScalar(type.base_type)) field->required = required; - // See if there's a default specified. - if (Is('[')) { - NEXT(); - for (;;) { - auto key = attribute_; - ECHECK(ParseProtoKey()); - EXPECT('='); - auto val = attribute_; - ECHECK(ParseProtoCurliesOrIdent()); - if (key == "default") { - // Temp: skip non-numeric defaults (enums). - auto numeric = strpbrk(val.c_str(), "0123456789-+."); - if (IsScalar(type.base_type) && numeric == val.c_str()) - field->value.constant = val; - } else if (key == "deprecated") { - field->deprecated = val == "true"; - } - if (!Is(',')) break; - NEXT(); - } - EXPECT(']'); - } - if (anonymous_struct) { - ECHECK(ParseProtoFields(anonymous_struct, false, oneof)); - if (Is(';')) NEXT(); - } else { - EXPECT(';'); - } - } - } - NEXT(); - return NoError(); -} - -CheckedError Parser::ParseProtoKey() { - if (token_ == '(') { - NEXT(); - // Skip "(a.b)" style custom attributes. - while (token_ == '.' || token_ == kTokenIdentifier) NEXT(); - EXPECT(')'); - while (Is('.')) { NEXT(); EXPECT(kTokenIdentifier); } - } else { - EXPECT(kTokenIdentifier); - } - return NoError(); -} - -CheckedError Parser::ParseProtoCurliesOrIdent() { - if (Is('{')) { - NEXT(); - for (int nesting = 1; nesting; ) { - if (token_ == '{') nesting++; - else if (token_ == '}') nesting--; - NEXT(); - } - } else { - NEXT(); // Any single token. - } - return NoError(); -} - -CheckedError Parser::ParseProtoOption() { - NEXT(); - ECHECK(ParseProtoKey()); - EXPECT('='); - ECHECK(ParseProtoCurliesOrIdent()); - return NoError(); -} - -// Parse a protobuf type, and map it to the corresponding FlatBuffer one. -CheckedError Parser::ParseTypeFromProtoType(Type *type) { - struct type_lookup { const char *proto_type; BaseType fb_type; }; - static type_lookup lookup[] = { - { "float", BASE_TYPE_FLOAT }, { "double", BASE_TYPE_DOUBLE }, - { "int32", BASE_TYPE_INT }, { "int64", BASE_TYPE_LONG }, - { "uint32", BASE_TYPE_UINT }, { "uint64", BASE_TYPE_ULONG }, - { "sint32", BASE_TYPE_INT }, { "sint64", BASE_TYPE_LONG }, - { "fixed32", BASE_TYPE_UINT }, { "fixed64", BASE_TYPE_ULONG }, - { "sfixed32", BASE_TYPE_INT }, { "sfixed64", BASE_TYPE_LONG }, - { "bool", BASE_TYPE_BOOL }, - { "string", BASE_TYPE_STRING }, - { "bytes", BASE_TYPE_STRING }, - { nullptr, BASE_TYPE_NONE } - }; - for (auto tl = lookup; tl->proto_type; tl++) { - if (attribute_ == tl->proto_type) { - type->base_type = tl->fb_type; - NEXT(); - return NoError(); - } - } - if (Is('.')) NEXT(); // qualified names may start with a . ? - ECHECK(ParseTypeIdent(*type)); - return NoError(); -} - -CheckedError Parser::SkipAnyJsonValue() { - switch (token_) { - case '{': - ECHECK(SkipJsonObject()); - break; - case kTokenStringConstant: - ECHECK(SkipJsonString()); - break; - case '[': - ECHECK(SkipJsonArray()); - break; - case kTokenIntegerConstant: - EXPECT(kTokenIntegerConstant); - break; - case kTokenFloatConstant: - EXPECT(kTokenFloatConstant); - break; - default: - return Error(std::string("Unexpected token:") + std::string(1, static_cast<char>(token_))); - } - return NoError(); -} - -CheckedError Parser::SkipJsonObject() { - EXPECT('{'); - size_t fieldn = 0; - - for (;;) { - if ((!opts.strict_json || !fieldn) && Is('}')) break; - - if (!Is(kTokenStringConstant)) { - EXPECT(opts.strict_json ? kTokenStringConstant : kTokenIdentifier); - } - else { - NEXT(); - } - - EXPECT(':'); - ECHECK(SkipAnyJsonValue()); - fieldn++; - - if (Is('}')) break; - EXPECT(','); - } - - NEXT(); - return NoError(); -} - -CheckedError Parser::SkipJsonArray() { - EXPECT('['); - - for (;;) { - if (Is(']')) break; - - ECHECK(SkipAnyJsonValue()); - - if (Is(']')) break; - EXPECT(','); - } - - NEXT(); - return NoError(); -} - -CheckedError Parser::SkipJsonString() { - EXPECT(kTokenStringConstant); - return NoError(); -} - -bool Parser::Parse(const char *source, const char **include_paths, - const char *source_filename) { - return !DoParse(source, include_paths, source_filename).Check(); -} - -CheckedError Parser::DoParse(const char *source, const char **include_paths, - const char *source_filename) { - file_being_parsed_ = source_filename ? source_filename : ""; - if (source_filename && - included_files_.find(source_filename) == included_files_.end()) { - included_files_[source_filename] = true; - files_included_per_file_[source_filename] = std::set<std::string>(); - } - if (!include_paths) { - static const char *current_directory[] = { "", nullptr }; - include_paths = current_directory; - } - source_ = cursor_ = source; - line_ = 1; - error_.clear(); - field_stack_.clear(); - builder_.Clear(); - // Start with a blank namespace just in case this file doesn't have one. - namespaces_.push_back(new Namespace()); - ECHECK(SkipByteOrderMark()); - NEXT(); - - if (Is(kTokenEof)) - return Error("input file is empty"); - - // Includes must come before type declarations: - for (;;) { - // Parse pre-include proto statements if any: - if (opts.proto_mode && - (attribute_ == "option" || attribute_ == "syntax" || - attribute_ == "package")) { - ECHECK(ParseProtoDecl()); - } else if (Is(kTokenNativeInclude)) { - NEXT(); - native_included_files_.emplace_back(attribute_); - EXPECT(kTokenStringConstant); - } else if (Is(kTokenInclude) || - (opts.proto_mode && - attribute_ == "import" && - Is(kTokenIdentifier))) { - NEXT(); - if (opts.proto_mode && attribute_ == "public") NEXT(); - auto name = attribute_; - EXPECT(kTokenStringConstant); - // Look for the file in include_paths. - std::string filepath; - for (auto paths = include_paths; paths && *paths; paths++) { - filepath = flatbuffers::ConCatPathFileName(*paths, name); - if(FileExists(filepath.c_str())) break; - } - if (filepath.empty()) - return Error("unable to locate include file: " + name); - if (source_filename) - files_included_per_file_[source_filename].insert(filepath); - if (included_files_.find(filepath) == included_files_.end()) { - // We found an include file that we have not parsed yet. - // Load it and parse it. - std::string contents; - if (!LoadFile(filepath.c_str(), true, &contents)) - return Error("unable to load include file: " + name); - ECHECK(DoParse(contents.c_str(), include_paths, filepath.c_str())); - // We generally do not want to output code for any included files: - if (!opts.generate_all) MarkGenerated(); - // This is the easiest way to continue this file after an include: - // instead of saving and restoring all the state, we simply start the - // file anew. This will cause it to encounter the same include - // statement again, but this time it will skip it, because it was - // entered into included_files_. - // This is recursive, but only go as deep as the number of include - // statements. - return DoParse(source, include_paths, source_filename); - } - EXPECT(';'); - } else { - break; - } - } - // Now parse all other kinds of declarations: - while (token_ != kTokenEof) { - if (opts.proto_mode) { - ECHECK(ParseProtoDecl()); - } else if (token_ == kTokenNameSpace) { - ECHECK(ParseNamespace()); - } else if (token_ == '{') { - if (!root_struct_def_) - return Error("no root type set to parse json with"); - if (builder_.GetSize()) { - return Error("cannot have more than one json object in a file"); - } - uoffset_t toff; - ECHECK(ParseTable(*root_struct_def_, nullptr, &toff)); - builder_.Finish(Offset<Table>(toff), - file_identifier_.length() ? file_identifier_.c_str() : nullptr); - } else if (token_ == kTokenEnum) { - ECHECK(ParseEnum(false, nullptr)); - } else if (token_ == kTokenUnion) { - ECHECK(ParseEnum(true, nullptr)); - } else if (token_ == kTokenRootType) { - NEXT(); - auto root_type = attribute_; - EXPECT(kTokenIdentifier); - ECHECK(ParseNamespacing(&root_type, nullptr)); - if (!SetRootType(root_type.c_str())) - return Error("unknown root type: " + root_type); - if (root_struct_def_->fixed) - return Error("root type must be a table"); - EXPECT(';'); - } else if (token_ == kTokenFileIdentifier) { - NEXT(); - file_identifier_ = attribute_; - EXPECT(kTokenStringConstant); - if (file_identifier_.length() != - FlatBufferBuilder::kFileIdentifierLength) - return Error("file_identifier must be exactly " + - NumToString(FlatBufferBuilder::kFileIdentifierLength) + - " characters"); - EXPECT(';'); - } else if (token_ == kTokenFileExtension) { - NEXT(); - file_extension_ = attribute_; - EXPECT(kTokenStringConstant); - EXPECT(';'); - } else if(token_ == kTokenInclude) { - return Error("includes must come before declarations"); - } else if(token_ == kTokenAttribute) { - NEXT(); - auto name = attribute_; - EXPECT(kTokenStringConstant); - EXPECT(';'); - known_attributes_[name] = false; - } else if (token_ == kTokenService) { - ECHECK(ParseService()); - } else { - ECHECK(ParseDecl()); - } - } - for (auto it = structs_.vec.begin(); it != structs_.vec.end(); ++it) { - if ((*it)->predecl) { - return Error("type referenced but not defined: " + (*it)->name); - } - } - // This check has to happen here and not earlier, because only now do we - // know for sure what the type of these are. - for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { - auto &enum_def = **it; - if (enum_def.is_union) { - for (auto val_it = enum_def.vals.vec.begin(); - val_it != enum_def.vals.vec.end(); - ++val_it) { - auto &val = **val_it; - if (opts.lang_to_generate != IDLOptions::kCpp && - val.union_type.struct_def && val.union_type.struct_def->fixed) - return Error( - "only tables can be union elements in the generated language: " - + val.name); - } - } - } - return NoError(); -} - -std::set<std::string> Parser::GetIncludedFilesRecursive( - const std::string &file_name) const { - std::set<std::string> included_files; - std::list<std::string> to_process; - - if (file_name.empty()) return included_files; - to_process.push_back(file_name); - - while (!to_process.empty()) { - std::string current = to_process.front(); - to_process.pop_front(); - included_files.insert(current); - - auto new_files = files_included_per_file_.at(current); - for (auto it = new_files.begin(); it != new_files.end(); ++it) { - if (included_files.find(*it) == included_files.end()) - to_process.push_back(*it); - } - } - - return included_files; -} - -// Schema serialization functionality: - -template<typename T> bool compareName(const T* a, const T* b) { - return a->defined_namespace->GetFullyQualifiedName(a->name) - < b->defined_namespace->GetFullyQualifiedName(b->name); -} - -template<typename T> void AssignIndices(const std::vector<T *> &defvec) { - // Pre-sort these vectors, such that we can set the correct indices for them. - auto vec = defvec; - std::sort(vec.begin(), vec.end(), compareName<T>); - for (int i = 0; i < static_cast<int>(vec.size()); i++) vec[i]->index = i; -} - -void Parser::Serialize() { - builder_.Clear(); - AssignIndices(structs_.vec); - AssignIndices(enums_.vec); - std::vector<Offset<reflection::Object>> object_offsets; - for (auto it = structs_.vec.begin(); it != structs_.vec.end(); ++it) { - auto offset = (*it)->Serialize(&builder_, *this); - object_offsets.push_back(offset); - (*it)->serialized_location = offset.o; - } - std::vector<Offset<reflection::Enum>> enum_offsets; - for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { - auto offset = (*it)->Serialize(&builder_, *this); - enum_offsets.push_back(offset); - (*it)->serialized_location = offset.o; - } - auto schema_offset = reflection::CreateSchema( - builder_, - builder_.CreateVectorOfSortedTables(&object_offsets), - builder_.CreateVectorOfSortedTables(&enum_offsets), - builder_.CreateString(file_identifier_), - builder_.CreateString(file_extension_), - root_struct_def_ - ? root_struct_def_->serialized_location - : 0); - builder_.Finish(schema_offset, reflection::SchemaIdentifier()); -} - -Offset<reflection::Object> StructDef::Serialize(FlatBufferBuilder *builder, - const Parser &parser) const { - std::vector<Offset<reflection::Field>> field_offsets; - for (auto it = fields.vec.begin(); it != fields.vec.end(); ++it) { - field_offsets.push_back( - (*it)->Serialize(builder, - static_cast<uint16_t>(it - fields.vec.begin()), parser)); - } - auto qualified_name = defined_namespace->GetFullyQualifiedName(name); - return reflection::CreateObject(*builder, - builder->CreateString(qualified_name), - builder->CreateVectorOfSortedTables( - &field_offsets), - fixed, - static_cast<int>(minalign), - static_cast<int>(bytesize), - SerializeAttributes(builder, parser), - parser.opts.binary_schema_comments - ? builder->CreateVectorOfStrings( - doc_comment) - : 0); -} - -Offset<reflection::Field> FieldDef::Serialize(FlatBufferBuilder *builder, - uint16_t id, - const Parser &parser) const { - return reflection::CreateField(*builder, - builder->CreateString(name), - value.type.Serialize(builder), - id, - value.offset, - IsInteger(value.type.base_type) - ? StringToInt(value.constant.c_str()) - : 0, - IsFloat(value.type.base_type) - ? strtod(value.constant.c_str(), nullptr) - : 0.0, - deprecated, - required, - key, - SerializeAttributes(builder, parser), - parser.opts.binary_schema_comments - ? builder->CreateVectorOfStrings(doc_comment) - : 0); - // TODO: value.constant is almost always "0", we could save quite a bit of - // space by sharing it. Same for common values of value.type. -} - -Offset<reflection::Enum> EnumDef::Serialize(FlatBufferBuilder *builder, - const Parser &parser) const { - std::vector<Offset<reflection::EnumVal>> enumval_offsets; - for (auto it = vals.vec.begin(); it != vals.vec.end(); ++it) { - enumval_offsets.push_back((*it)->Serialize(builder)); - } - auto qualified_name = defined_namespace->GetFullyQualifiedName(name); - return reflection::CreateEnum(*builder, - builder->CreateString(qualified_name), - builder->CreateVector(enumval_offsets), - is_union, - underlying_type.Serialize(builder), - SerializeAttributes(builder, parser), - parser.opts.binary_schema_comments - ? builder->CreateVectorOfStrings(doc_comment) - : 0); -} - -Offset<reflection::EnumVal> EnumVal::Serialize(FlatBufferBuilder *builder) const - { - return reflection::CreateEnumVal(*builder, - builder->CreateString(name), - value, - union_type.struct_def - ? union_type.struct_def-> - serialized_location - : 0, - union_type.Serialize(builder)); -} - -Offset<reflection::Type> Type::Serialize(FlatBufferBuilder *builder) const { - return reflection::CreateType(*builder, - static_cast<reflection::BaseType>(base_type), - static_cast<reflection::BaseType>(element), - struct_def ? struct_def->index : - (enum_def ? enum_def->index : -1)); -} - -flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset< - reflection::KeyValue>>> - Definition::SerializeAttributes(FlatBufferBuilder *builder, - const Parser &parser) const { - std::vector<flatbuffers::Offset<reflection::KeyValue>> attrs; - for (auto kv = attributes.dict.begin(); kv != attributes.dict.end(); ++kv) { - auto it = parser.known_attributes_.find(kv->first); - assert(it != parser.known_attributes_.end()); - if (!it->second) { // Custom attribute. - attrs.push_back( - reflection::CreateKeyValue(*builder, builder->CreateString(kv->first), - builder->CreateString( - kv->second->constant))); - } - } - if (attrs.size()) { - return builder->CreateVectorOfSortedTables(&attrs); - } else { - return 0; - } -} - -std::string Parser::ConformTo(const Parser &base) { - for (auto sit = structs_.vec.begin(); sit != structs_.vec.end(); ++sit) { - auto &struct_def = **sit; - auto qualified_name = - struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name); - auto struct_def_base = base.structs_.Lookup(qualified_name); - if (!struct_def_base) continue; - for (auto fit = struct_def.fields.vec.begin(); - fit != struct_def.fields.vec.end(); ++fit) { - auto &field = **fit; - auto field_base = struct_def_base->fields.Lookup(field.name); - if (field_base) { - if (field.value.offset != field_base->value.offset) - return "offsets differ for field: " + field.name; - if (field.value.constant != field_base->value.constant) - return "defaults differ for field: " + field.name; - if (!EqualByName(field.value.type, field_base->value.type)) - return "types differ for field: " + field.name; - } else { - // Doesn't have to exist, deleting fields is fine. - // But we should check if there is a field that has the same offset - // but is incompatible (in the case of field renaming). - for (auto fbit = struct_def_base->fields.vec.begin(); - fbit != struct_def_base->fields.vec.end(); ++fbit) { - field_base = *fbit; - if (field.value.offset == field_base->value.offset) { - if (!EqualByName(field.value.type, field_base->value.type)) - return "field renamed to different type: " + field.name; - break; - } - } - } - } - } - for (auto eit = enums_.vec.begin(); eit != enums_.vec.end(); ++eit) { - auto &enum_def = **eit; - auto qualified_name = - enum_def.defined_namespace->GetFullyQualifiedName(enum_def.name); - auto enum_def_base = base.enums_.Lookup(qualified_name); - if (!enum_def_base) continue; - for (auto evit = enum_def.vals.vec.begin(); - evit != enum_def.vals.vec.end(); ++evit) { - auto &enum_val = **evit; - auto enum_val_base = enum_def_base->vals.Lookup(enum_val.name); - if (enum_val_base) { - if (enum_val.value != enum_val_base->value) - return "values differ for enum: " + enum_val.name; - } - } - } - return ""; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/reflection.cpp b/third_party/flatbuffers/src/reflection.cpp deleted file mode 100644 index cb30c7f..0000000 --- a/third_party/flatbuffers/src/reflection.cpp +++ /dev/null
@@ -1,710 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/reflection.h" -#include "flatbuffers/util.h" - -// Helper functionality for reflection. - -namespace flatbuffers { - -int64_t GetAnyValueI(reflection::BaseType type, const uint8_t *data) { -# define FLATBUFFERS_GET(T) static_cast<int64_t>(ReadScalar<T>(data)) - switch (type) { - case reflection::UType: - case reflection::Bool: - case reflection::UByte: return FLATBUFFERS_GET(uint8_t); - case reflection::Byte: return FLATBUFFERS_GET(int8_t); - case reflection::Short: return FLATBUFFERS_GET(int16_t); - case reflection::UShort: return FLATBUFFERS_GET(uint16_t); - case reflection::Int: return FLATBUFFERS_GET(int32_t); - case reflection::UInt: return FLATBUFFERS_GET(uint32_t); - case reflection::Long: return FLATBUFFERS_GET(int64_t); - case reflection::ULong: return FLATBUFFERS_GET(uint64_t); - case reflection::Float: return FLATBUFFERS_GET(float); - case reflection::Double: return FLATBUFFERS_GET(double); - case reflection::String: { - auto s = reinterpret_cast<const String *>(ReadScalar<uoffset_t>(data) + - data); - return s ? StringToInt(s->c_str()) : 0; - } - default: return 0; // Tables & vectors do not make sense. - } -# undef FLATBUFFERS_GET -} - -double GetAnyValueF(reflection::BaseType type, const uint8_t *data) { - switch (type) { - case reflection::Float: return static_cast<double>(ReadScalar<float>(data)); - case reflection::Double: return ReadScalar<double>(data); - case reflection::String: { - auto s = reinterpret_cast<const String *>(ReadScalar<uoffset_t>(data) + - data); - return s ? strtod(s->c_str(), nullptr) : 0.0; - } - default: return static_cast<double>(GetAnyValueI(type, data)); - } -} - -std::string GetAnyValueS(reflection::BaseType type, const uint8_t *data, - const reflection::Schema *schema, int type_index) { - switch (type) { - case reflection::Float: - case reflection::Double: return NumToString(GetAnyValueF(type, data)); - case reflection::String: { - auto s = reinterpret_cast<const String *>(ReadScalar<uoffset_t>(data) + - data); - return s ? s->c_str() : ""; - } - case reflection::Obj: - if (schema) { - // Convert the table to a string. This is mostly for debugging purposes, - // and does NOT promise to be JSON compliant. - // Also prefixes the type. - auto &objectdef = *schema->objects()->Get(type_index); - auto s = objectdef.name()->str(); - if (objectdef.is_struct()) { - s += "(struct)"; // TODO: implement this as well. - } else { - auto table_field = reinterpret_cast<const Table *>( - ReadScalar<uoffset_t>(data) + data); - s += " { "; - auto fielddefs = objectdef.fields(); - for (auto it = fielddefs->begin(); it != fielddefs->end(); ++it) { - auto &fielddef = **it; - if (!table_field->CheckField(fielddef.offset())) continue; - auto val = GetAnyFieldS(*table_field, fielddef, schema); - if (fielddef.type()->base_type() == reflection::String) - val = "\"" + val + "\""; // Doesn't deal with escape codes etc. - s += fielddef.name()->str(); - s += ": "; - s += val; - s += ", "; - } - s += "}"; - } - return s; - } else { - return "(table)"; - } - case reflection::Vector: - return "[(elements)]"; // TODO: implement this as well. - case reflection::Union: - return "(union)"; // TODO: implement this as well. - default: return NumToString(GetAnyValueI(type, data)); - } -} - -void SetAnyValueI(reflection::BaseType type, uint8_t *data, int64_t val) { -# define FLATBUFFERS_SET(T) WriteScalar(data, static_cast<T>(val)) - switch (type) { - case reflection::UType: - case reflection::Bool: - case reflection::UByte: FLATBUFFERS_SET(uint8_t ); break; - case reflection::Byte: FLATBUFFERS_SET(int8_t ); break; - case reflection::Short: FLATBUFFERS_SET(int16_t ); break; - case reflection::UShort: FLATBUFFERS_SET(uint16_t); break; - case reflection::Int: FLATBUFFERS_SET(int32_t ); break; - case reflection::UInt: FLATBUFFERS_SET(uint32_t); break; - case reflection::Long: FLATBUFFERS_SET(int64_t ); break; - case reflection::ULong: FLATBUFFERS_SET(uint64_t); break; - case reflection::Float: FLATBUFFERS_SET(float ); break; - case reflection::Double: FLATBUFFERS_SET(double ); break; - // TODO: support strings - default: break; - } -# undef FLATBUFFERS_SET -} - -void SetAnyValueF(reflection::BaseType type, uint8_t *data, double val) { - switch (type) { - case reflection::Float: WriteScalar(data, static_cast<float>(val)); break; - case reflection::Double: WriteScalar(data, val); break; - // TODO: support strings. - default: SetAnyValueI(type, data, static_cast<int64_t>(val)); break; - } -} - -void SetAnyValueS(reflection::BaseType type, uint8_t *data, const char *val) { - switch (type) { - case reflection::Float: - case reflection::Double: - SetAnyValueF(type, data, strtod(val, nullptr)); - break; - // TODO: support strings. - default: SetAnyValueI(type, data, StringToInt(val)); break; - } -} - -// Resize a FlatBuffer in-place by iterating through all offsets in the buffer -// and adjusting them by "delta" if they straddle the start offset. -// Once that is done, bytes can now be inserted/deleted safely. -// "delta" may be negative (shrinking). -// Unless "delta" is a multiple of the largest alignment, you'll create a small -// amount of garbage space in the buffer (usually 0..7 bytes). -// If your FlatBuffer's root table is not the schema's root table, you should -// pass in your root_table type as well. -class ResizeContext { - public: - ResizeContext(const reflection::Schema &schema, uoffset_t start, int delta, - std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table = nullptr) - : schema_(schema), startptr_(flatbuf->data() + start), - delta_(delta), buf_(*flatbuf), - dag_check_(flatbuf->size() / sizeof(uoffset_t), false) { - auto mask = static_cast<int>(sizeof(largest_scalar_t) - 1); - delta_ = (delta_ + mask) & ~mask; - if (!delta_) return; // We can't shrink by less than largest_scalar_t. - // Now change all the offsets by delta_. - auto root = GetAnyRoot(buf_.data()); - Straddle<uoffset_t, 1>(buf_.data(), root, buf_.data()); - ResizeTable(root_table ? *root_table : *schema.root_table(), root); - // We can now add or remove bytes at start. - if (delta_ > 0) buf_.insert(buf_.begin() + start, delta_, 0); - else buf_.erase(buf_.begin() + start, buf_.begin() + start - delta_); - } - - // Check if the range between first (lower address) and second straddles - // the insertion point. If it does, change the offset at offsetloc (of - // type T, with direction D). - template<typename T, int D> void Straddle(const void *first, - const void *second, - void *offsetloc) { - if (first <= startptr_ && second >= startptr_) { - WriteScalar<T>(offsetloc, ReadScalar<T>(offsetloc) + delta_ * D); - DagCheck(offsetloc) = true; - } - } - - // This returns a boolean that records if the corresponding offset location - // has been modified already. If so, we can't even read the corresponding - // offset, since it is pointing to a location that is illegal until the - // resize actually happens. - // This must be checked for every offset, since we can't know which offsets - // will straddle and which won't. - uint8_t &DagCheck(const void *offsetloc) { - auto dag_idx = reinterpret_cast<const uoffset_t *>(offsetloc) - - reinterpret_cast<const uoffset_t *>(buf_.data()); - return dag_check_[dag_idx]; - } - - void ResizeTable(const reflection::Object &objectdef, Table *table) { - if (DagCheck(table)) - return; // Table already visited. - auto vtable = table->GetVTable(); - // Early out: since all fields inside the table must point forwards in - // memory, if the insertion point is before the table we can stop here. - auto tableloc = reinterpret_cast<uint8_t *>(table); - if (startptr_ <= tableloc) { - // Check if insertion point is between the table and a vtable that - // precedes it. This can't happen in current construction code, but check - // just in case we ever change the way flatbuffers are built. - Straddle<soffset_t, -1>(vtable, table, table); - } else { - // Check each field. - auto fielddefs = objectdef.fields(); - for (auto it = fielddefs->begin(); it != fielddefs->end(); ++it) { - auto &fielddef = **it; - auto base_type = fielddef.type()->base_type(); - // Ignore scalars. - if (base_type <= reflection::Double) continue; - // Ignore fields that are not stored. - auto offset = table->GetOptionalFieldOffset(fielddef.offset()); - if (!offset) continue; - // Ignore structs. - auto subobjectdef = base_type == reflection::Obj ? - schema_.objects()->Get(fielddef.type()->index()) : nullptr; - if (subobjectdef && subobjectdef->is_struct()) continue; - // Get this fields' offset, and read it if safe. - auto offsetloc = tableloc + offset; - if (DagCheck(offsetloc)) - continue; // This offset already visited. - auto ref = offsetloc + ReadScalar<uoffset_t>(offsetloc); - Straddle<uoffset_t, 1>(offsetloc, ref, offsetloc); - // Recurse. - switch (base_type) { - case reflection::Obj: { - ResizeTable(*subobjectdef, reinterpret_cast<Table *>(ref)); - break; - } - case reflection::Vector: { - auto elem_type = fielddef.type()->element(); - if (elem_type != reflection::Obj && elem_type != reflection::String) - break; - auto vec = reinterpret_cast<Vector<uoffset_t> *>(ref); - auto elemobjectdef = elem_type == reflection::Obj - ? schema_.objects()->Get(fielddef.type()->index()) - : nullptr; - if (elemobjectdef && elemobjectdef->is_struct()) break; - for (uoffset_t i = 0; i < vec->size(); i++) { - auto loc = vec->Data() + i * sizeof(uoffset_t); - if (DagCheck(loc)) - continue; // This offset already visited. - auto dest = loc + vec->Get(i); - Straddle<uoffset_t, 1>(loc, dest ,loc); - if (elemobjectdef) - ResizeTable(*elemobjectdef, reinterpret_cast<Table *>(dest)); - } - break; - } - case reflection::Union: { - ResizeTable(GetUnionType(schema_, objectdef, fielddef, *table), - reinterpret_cast<Table *>(ref)); - break; - } - case reflection::String: - break; - default: - assert(false); - } - } - // Check if the vtable offset points beyond the insertion point. - // Must do this last, since GetOptionalFieldOffset above still reads - // this value. - Straddle<soffset_t, -1>(table, vtable, table); - } - } - - void operator=(const ResizeContext &rc); - - private: - const reflection::Schema &schema_; - uint8_t *startptr_; - int delta_; - std::vector<uint8_t> &buf_; - std::vector<uint8_t> dag_check_; -}; - -void SetString(const reflection::Schema &schema, const std::string &val, - const String *str, std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table) { - auto delta = static_cast<int>(val.size()) - static_cast<int>(str->Length()); - auto str_start = static_cast<uoffset_t>( - reinterpret_cast<const uint8_t *>(str) - flatbuf->data()); - auto start = str_start + static_cast<uoffset_t>(sizeof(uoffset_t)); - if (delta) { - // Clear the old string, since we don't want parts of it remaining. - memset(flatbuf->data() + start, 0, str->Length()); - // Different size, we must expand (or contract). - ResizeContext(schema, start, delta, flatbuf, root_table); - // Set the new length. - WriteScalar(flatbuf->data() + str_start, - static_cast<uoffset_t>(val.size())); - } - // Copy new data. Safe because we created the right amount of space. - memcpy(flatbuf->data() + start, val.c_str(), val.size() + 1); -} - -uint8_t *ResizeAnyVector(const reflection::Schema &schema, uoffset_t newsize, - const VectorOfAny *vec, uoffset_t num_elems, - uoffset_t elem_size, std::vector<uint8_t> *flatbuf, - const reflection::Object *root_table) { - auto delta_elem = static_cast<int>(newsize) - static_cast<int>(num_elems); - auto delta_bytes = delta_elem * static_cast<int>(elem_size); - auto vec_start = reinterpret_cast<const uint8_t *>(vec) - flatbuf->data(); - auto start = static_cast<uoffset_t>(vec_start + sizeof(uoffset_t) + - elem_size * num_elems); - if (delta_bytes) { - if (delta_elem < 0) { - // Clear elements we're throwing away, since some might remain in the - // buffer. - auto size_clear = -delta_elem * elem_size; - memset(flatbuf->data() + start - size_clear, 0, size_clear); - } - ResizeContext(schema, start, delta_bytes, flatbuf, root_table); - WriteScalar(flatbuf->data() + vec_start, newsize); // Length field. - // Set new elements to 0.. this can be overwritten by the caller. - if (delta_elem > 0) { - memset(flatbuf->data() + start, 0, delta_elem * elem_size); - } - } - return flatbuf->data() + start; -} - -const uint8_t *AddFlatBuffer(std::vector<uint8_t> &flatbuf, - const uint8_t *newbuf, size_t newlen) { - // Align to sizeof(uoffset_t) past sizeof(largest_scalar_t) since we're - // going to chop off the root offset. - while ((flatbuf.size() & (sizeof(uoffset_t) - 1)) || - !(flatbuf.size() & (sizeof(largest_scalar_t) - 1))) { - flatbuf.push_back(0); - } - auto insertion_point = static_cast<uoffset_t>(flatbuf.size()); - // Insert the entire FlatBuffer minus the root pointer. - flatbuf.insert(flatbuf.end(), newbuf + sizeof(uoffset_t), newbuf + newlen); - auto root_offset = ReadScalar<uoffset_t>(newbuf) - sizeof(uoffset_t); - return flatbuf.data() + insertion_point + root_offset; -} - -void CopyInline(FlatBufferBuilder &fbb, const reflection::Field &fielddef, - const Table &table, size_t align, size_t size) { - fbb.Align(align); - fbb.PushBytes(table.GetStruct<const uint8_t *>(fielddef.offset()), size); - fbb.TrackField(fielddef.offset(), fbb.GetSize()); -} - -Offset<const Table *> CopyTable(FlatBufferBuilder &fbb, - const reflection::Schema &schema, - const reflection::Object &objectdef, - const Table &table, - bool use_string_pooling) { - // Before we can construct the table, we have to first generate any - // subobjects, and collect their offsets. - std::vector<uoffset_t> offsets; - auto fielddefs = objectdef.fields(); - for (auto it = fielddefs->begin(); it != fielddefs->end(); ++it) { - auto &fielddef = **it; - // Skip if field is not present in the source. - if (!table.CheckField(fielddef.offset())) continue; - uoffset_t offset = 0; - switch (fielddef.type()->base_type()) { - case reflection::String: { - offset = use_string_pooling - ? fbb.CreateSharedString(GetFieldS(table, fielddef)).o - : fbb.CreateString(GetFieldS(table, fielddef)).o; - break; - } - case reflection::Obj: { - auto &subobjectdef = *schema.objects()->Get(fielddef.type()->index()); - if (!subobjectdef.is_struct()) { - offset = CopyTable(fbb, schema, subobjectdef, - *GetFieldT(table, fielddef)).o; - } - break; - } - case reflection::Union: { - auto &subobjectdef = GetUnionType(schema, objectdef, fielddef, table); - offset = CopyTable(fbb, schema, subobjectdef, - *GetFieldT(table, fielddef)).o; - break; - } - case reflection::Vector: { - auto vec = table.GetPointer<const Vector<Offset<Table>> *>( - fielddef.offset()); - auto element_base_type = fielddef.type()->element(); - auto elemobjectdef = element_base_type == reflection::Obj - ? schema.objects()->Get(fielddef.type()->index()) - : nullptr; - switch (element_base_type) { - case reflection::String: { - std::vector<Offset<const String *>> elements(vec->size()); - auto vec_s = reinterpret_cast<const Vector<Offset<String>> *>(vec); - for (uoffset_t i = 0; i < vec_s->size(); i++) { - elements[i] = use_string_pooling - ? fbb.CreateSharedString(vec_s->Get(i)).o - : fbb.CreateString(vec_s->Get(i)).o; - } - offset = fbb.CreateVector(elements).o; - break; - } - case reflection::Obj: { - if (!elemobjectdef->is_struct()) { - std::vector<Offset<const Table *>> elements(vec->size()); - for (uoffset_t i = 0; i < vec->size(); i++) { - elements[i] = - CopyTable(fbb, schema, *elemobjectdef, *vec->Get(i)); - } - offset = fbb.CreateVector(elements).o; - break; - } - // FALL-THRU: - } - default: { // Scalars and structs. - auto element_size = GetTypeSize(element_base_type); - if (elemobjectdef && elemobjectdef->is_struct()) - element_size = elemobjectdef->bytesize(); - fbb.StartVector(element_size, vec->size()); - fbb.PushBytes(vec->Data(), element_size * vec->size()); - offset = fbb.EndVector(vec->size()); - break; - } - } - break; - } - default: // Scalars. - break; - } - if (offset) { - offsets.push_back(offset); - } - } - // Now we can build the actual table from either offsets or scalar data. - auto start = objectdef.is_struct() - ? fbb.StartStruct(objectdef.minalign()) - : fbb.StartTable(); - size_t offset_idx = 0; - for (auto it = fielddefs->begin(); it != fielddefs->end(); ++it) { - auto &fielddef = **it; - if (!table.CheckField(fielddef.offset())) continue; - auto base_type = fielddef.type()->base_type(); - switch (base_type) { - case reflection::Obj: { - auto &subobjectdef = *schema.objects()->Get(fielddef.type()->index()); - if (subobjectdef.is_struct()) { - CopyInline(fbb, fielddef, table, subobjectdef.minalign(), - subobjectdef.bytesize()); - break; - } - // else: FALL-THRU: - } - case reflection::Union: - case reflection::String: - case reflection::Vector: - fbb.AddOffset(fielddef.offset(), Offset<void>(offsets[offset_idx++])); - break; - default: { // Scalars. - auto size = GetTypeSize(base_type); - CopyInline(fbb, fielddef, table, size, size); - break; - } - } - } - assert(offset_idx == offsets.size()); - if (objectdef.is_struct()) { - fbb.ClearOffsets(); - return fbb.EndStruct(); - } else { - return fbb.EndTable(start, static_cast<voffset_t>(fielddefs->size())); - } -} - -bool VerifyStruct(flatbuffers::Verifier &v, - const flatbuffers::Table &parent_table, - voffset_t field_offset, - const reflection::Object &obj, - bool required) { - auto offset = parent_table.GetOptionalFieldOffset(field_offset); - if (required && !offset) { - return false; - } - - return !offset || v.Verify(reinterpret_cast<const uint8_t*>(&parent_table) - + offset, obj.bytesize()); -} - -bool VerifyVectorOfStructs(flatbuffers::Verifier &v, - const flatbuffers::Table &parent_table, - voffset_t field_offset, - const reflection::Object &obj, - bool required) { - auto p = parent_table.GetPointer<const uint8_t*>(field_offset); - const uint8_t* end; - if (required && !p) { - return false; - } - - return !p || v.VerifyVector(p, obj.bytesize(), &end); -} - -// forward declare to resolve cyclic deps between VerifyObject and VerifyVector -bool VerifyObject(flatbuffers::Verifier &v, - const reflection::Schema &schema, - const reflection::Object &obj, - const flatbuffers::Table *table, - bool isRequired); - -bool VerifyVector(flatbuffers::Verifier &v, - const reflection::Schema &schema, - const flatbuffers::Table &table, - const reflection::Field &vec_field) { - assert(vec_field.type()->base_type() == reflection::Vector); - if (!table.VerifyField<uoffset_t>(v, vec_field.offset())) - return false; - - switch (vec_field.type()->element()) { - case reflection::None: - assert(false); - break; - case reflection::UType: - return v.Verify(flatbuffers::GetFieldV<uint8_t>(table, vec_field)); - case reflection::Bool: - case reflection::Byte: - case reflection::UByte: - return v.Verify(flatbuffers::GetFieldV<int8_t>(table, vec_field)); - case reflection::Short: - case reflection::UShort: - return v.Verify(flatbuffers::GetFieldV<int16_t>(table, vec_field)); - case reflection::Int: - case reflection::UInt: - return v.Verify(flatbuffers::GetFieldV<int32_t>(table, vec_field)); - case reflection::Long: - case reflection::ULong: - return v.Verify(flatbuffers::GetFieldV<int64_t>(table, vec_field)); - case reflection::Float: - return v.Verify(flatbuffers::GetFieldV<float>(table, vec_field)); - case reflection::Double: - return v.Verify(flatbuffers::GetFieldV<double>(table, vec_field)); - case reflection::String: { - auto vecString = - flatbuffers::GetFieldV<flatbuffers:: - Offset<flatbuffers::String>>(table, vec_field); - if (v.Verify(vecString) && v.VerifyVectorOfStrings(vecString)) { - return true; - } else { - return false; - } - } - case reflection::Vector: - assert(false); - break; - case reflection::Obj: { - auto obj = schema.objects()->Get(vec_field.type()->index()); - if (obj->is_struct()) { - if (!VerifyVectorOfStructs(v, table, vec_field.offset(), *obj, - vec_field.required())) { - return false; - } - } else { - auto vec = - flatbuffers::GetFieldV<flatbuffers:: - Offset<flatbuffers::Table>>(table, vec_field); - if (!v.Verify(vec)) - return false; - if (vec) { - for (uoffset_t j = 0; j < vec->size(); j++) { - if (!VerifyObject(v, schema, *obj, vec->Get(j), true)) { - return false; - } - } - } - } - return true; - } - case reflection::Union: - assert(false); - break; - default: - assert(false); - break; - } - - return false; -} - -bool VerifyObject(flatbuffers::Verifier &v, - const reflection::Schema &schema, - const reflection::Object &obj, - const flatbuffers::Table *table, - bool required) { - if (!table) { - if (!required) - return true; - else - return false; - } - - if (!table->VerifyTableStart(v)) - return false; - - for (uoffset_t i = 0; i < obj.fields()->size(); i++) { - auto field_def = obj.fields()->Get(i); - switch (field_def->type()->base_type()) { - case reflection::None: - assert(false); - break; - case reflection::UType: - if (!table->VerifyField<uint8_t>(v, field_def->offset())) - return false; - break; - case reflection::Bool: - case reflection::Byte: - case reflection::UByte: - if (!table->VerifyField<int8_t>(v, field_def->offset())) - return false; - break; - case reflection::Short: - case reflection::UShort: - if (!table->VerifyField<int16_t>(v, field_def->offset())) - return false; - break; - case reflection::Int: - case reflection::UInt: - if (!table->VerifyField<int32_t>(v, field_def->offset())) - return false; - break; - case reflection::Long: - case reflection::ULong: - if (!table->VerifyField<int64_t>(v, field_def->offset())) - return false; - break; - case reflection::Float: - if (!table->VerifyField<float>(v, field_def->offset())) - return false; - break; - case reflection::Double: - if (!table->VerifyField<double>(v, field_def->offset())) - return false; - break; - case reflection::String: - if (!table->VerifyField<uoffset_t>(v, field_def->offset()) || - !v.Verify(flatbuffers::GetFieldS(*table, *field_def))) { - return false; - } - break; - case reflection::Vector: - if (!VerifyVector(v, schema, *table, *field_def)) - return false; - break; - case reflection::Obj: { - auto child_obj = schema.objects()->Get(field_def->type()->index()); - if (child_obj->is_struct()) { - if (!VerifyStruct(v, *table, field_def->offset(), *child_obj, - field_def->required())) { - return false; - } - } else { - if (!VerifyObject(v, schema, *child_obj, - flatbuffers::GetFieldT(*table, *field_def), - field_def->required())) { - return false; - } - } - break; - } - case reflection::Union: { - // get union type from the prev field - voffset_t utype_offset = field_def->offset() - sizeof(voffset_t); - auto utype = table->GetField<uint8_t>(utype_offset, 0); - if (utype != 0) { - // Means we have this union field present - auto fb_enum = schema.enums()->Get(field_def->type()->index()); - auto child_obj = fb_enum->values()->Get(utype)->object(); - if (!VerifyObject(v, schema, *child_obj, - flatbuffers::GetFieldT(*table, *field_def), - field_def->required())) { - return false; - } - } - break; - } - default: - assert(false); - break; - } - } - - return true; -} - -bool Verify(const reflection::Schema &schema, - const reflection::Object &root, - const uint8_t *buf, - size_t length) { - Verifier v(buf, length); - return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf), true); -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/src/util.cpp b/third_party/flatbuffers/src/util.cpp deleted file mode 100644 index f4aecb5..0000000 --- a/third_party/flatbuffers/src/util.cpp +++ /dev/null
@@ -1,86 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/util.h" - -namespace flatbuffers { - -bool FileExistsRaw(const char *name) { - std::ifstream ifs(name); - return ifs.good(); -} - -bool LoadFileRaw(const char *name, bool binary, std::string *buf) { - if (DirExists(name)) return false; - std::ifstream ifs(name, binary ? std::ifstream::binary : std::ifstream::in); - if (!ifs.is_open()) return false; - if (binary) { - // The fastest way to read a file into a string. - ifs.seekg(0, std::ios::end); - auto size = ifs.tellg(); - (*buf).resize(static_cast<size_t>(size)); - ifs.seekg(0, std::ios::beg); - ifs.read(&(*buf)[0], (*buf).size()); - } else { - // This is slower, but works correctly on all platforms for text files. - std::ostringstream oss; - oss << ifs.rdbuf(); - *buf = oss.str(); - } - return !ifs.bad(); -} - -static LoadFileFunction g_load_file_function = LoadFileRaw; -static FileExistsFunction g_file_exists_function = FileExistsRaw; - -bool LoadFile(const char *name, bool binary, std::string *buf) { - assert(g_load_file_function); - return g_load_file_function(name, binary, buf); -} - -bool FileExists(const char *name) { - assert(g_file_exists_function); - return g_file_exists_function(name); -} - -bool DirExists(const char *name) { - #ifdef _WIN32 - #define flatbuffers_stat _stat - #define FLATBUFFERS_S_IFDIR _S_IFDIR - #else - #define flatbuffers_stat stat - #define FLATBUFFERS_S_IFDIR S_IFDIR - #endif - struct flatbuffers_stat file_info; - if (flatbuffers_stat(name, &file_info) != 0) return false; - return (file_info.st_mode & FLATBUFFERS_S_IFDIR) != 0; -} - -LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function) { - LoadFileFunction previous_function = g_load_file_function; - g_load_file_function = load_file_function ? load_file_function : LoadFileRaw; - return previous_function; -} - -FileExistsFunction SetFileExistsFunction( - FileExistsFunction file_exists_function) { - FileExistsFunction previous_function = g_file_exists_function; - g_file_exists_function = file_exists_function ? - file_exists_function : FileExistsRaw; - return previous_function; -} - -} // namespace flatbuffers
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/Assert.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/Assert.cs deleted file mode 100644 index 488c338..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/Assert.cs +++ /dev/null
@@ -1,136 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace FlatBuffers.Test -{ - - public class AssertFailedException : Exception - { - private readonly object _expected; - private readonly object _actual; - - public AssertFailedException(object expected, object actual) - { - _expected = expected; - _actual = actual; - } - - public override string Message - { - get { return string.Format("Expected {0} but saw {1}", _expected, _actual); } - } - } - - public class AssertArrayFailedException : Exception - { - private readonly int _index; - private readonly object _expected; - private readonly object _actual; - - public AssertArrayFailedException(int index, object expected, object actual) - { - _index = index; - _expected = expected; - _actual = actual; - } - - public override string Message - { - get { return string.Format("Expected {0} at index {1} but saw {2}", _expected, _index, _actual); } - } - } - - public class AssertUnexpectedThrowException : Exception - { - private readonly object _expected; - - public AssertUnexpectedThrowException(object expected) - { - _expected = expected; - } - - public override string Message - { - get { return string.Format("Expected exception of type {0}", _expected); } - } - } - - public static class Assert - { - public static void AreEqual<T>(T expected, T actual) - { - if (!expected.Equals(actual)) - { - throw new AssertFailedException(expected, actual); - } - } - - public static void ArrayEqual<T>(T[] expected, T[] actual) - { - if (expected.Length != actual.Length) - { - throw new AssertFailedException(expected, actual); - } - - for(var i = 0; i < expected.Length; ++i) - { - if (!expected[i].Equals(actual[i])) - { - throw new AssertArrayFailedException(i, expected, actual); - } - } - } - - public static void IsTrue(bool value) - { - if (!value) - { - throw new AssertFailedException(true, value); - } - } - - public static void IsFalse(bool value) - { - if (value) - { - throw new AssertFailedException(false, value); - } - } - - public static void Throws<T>(Action action) where T : Exception - { - var caught = false; - try - { - action(); - } - catch (T) - { - caught = true; - } - - if (!caught) - { - throw new AssertUnexpectedThrowException(typeof (T)); - } - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/ByteBufferTests.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/ByteBufferTests.cs deleted file mode 100644 index 3324f12..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/ByteBufferTests.cs +++ /dev/null
@@ -1,321 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace FlatBuffers.Test -{ - [FlatBuffersTestClass] - public class ByteBufferTests - { - - [FlatBuffersTestMethod] - public void ByteBuffer_Length_MatchesBufferLength() - { - var buffer = new byte[1000]; - var uut = new ByteBuffer(buffer); - Assert.AreEqual(buffer.Length, uut.Length); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutBytePopulatesBufferAtZeroOffset() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - uut.PutByte(0, (byte)99); - - Assert.AreEqual((byte)99, buffer[0]); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_PutByteCannotPutAtOffsetPastLength() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutByte(1, 99)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_PutShortPopulatesBufferCorrectly() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - uut.PutShort(0, (short)1); - - // Ensure Endianness was written correctly - Assert.AreEqual((byte)1, buffer[0]); - Assert.AreEqual((byte)0, buffer[1]); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_PutShortCannotPutAtOffsetPastLength() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutShort(2, 99)); - } -#endif - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_PutShortChecksLength() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutShort(0, 99)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutShortChecksLengthAndOffset() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutShort(1, 99)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_PutIntPopulatesBufferCorrectly() - { - var buffer = new byte[4]; - var uut = new ByteBuffer(buffer); - uut.PutInt(0, 0x0A0B0C0D); - - // Ensure Endianness was written correctly - Assert.AreEqual(0x0D, buffer[0]); - Assert.AreEqual(0x0C, buffer[1]); - Assert.AreEqual(0x0B, buffer[2]); - Assert.AreEqual(0x0A, buffer[3]); - } - - #if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_PutIntCannotPutAtOffsetPastLength() - { - var buffer = new byte[4]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutInt(2, 0x0A0B0C0D)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutIntChecksLength() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutInt(0, 0x0A0B0C0D)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutIntChecksLengthAndOffset() - { - var buffer = new byte[4]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutInt(2, 0x0A0B0C0D)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_PutLongPopulatesBufferCorrectly() - { - var buffer = new byte[8]; - var uut = new ByteBuffer(buffer); - uut.PutLong(0, 0x010203040A0B0C0D); - - // Ensure Endianness was written correctly - Assert.AreEqual(0x0D, buffer[0]); - Assert.AreEqual(0x0C, buffer[1]); - Assert.AreEqual(0x0B, buffer[2]); - Assert.AreEqual(0x0A, buffer[3]); - Assert.AreEqual(0x04, buffer[4]); - Assert.AreEqual(0x03, buffer[5]); - Assert.AreEqual(0x02, buffer[6]); - Assert.AreEqual(0x01, buffer[7]); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_PutLongCannotPutAtOffsetPastLength() - { - var buffer = new byte[8]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutLong(2, 0x010203040A0B0C0D)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutLongChecksLength() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutLong(0, 0x010203040A0B0C0D)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_PutLongChecksLengthAndOffset() - { - var buffer = new byte[8]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutLong(2, 0x010203040A0B0C0D)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_GetByteReturnsCorrectData() - { - var buffer = new byte[1]; - buffer[0] = 99; - var uut = new ByteBuffer(buffer); - Assert.AreEqual((byte)99, uut.Get(0)); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_GetByteChecksOffset() - { - var buffer = new byte[1]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(()=>uut.Get(1)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_GetShortReturnsCorrectData() - { - var buffer = new byte[2]; - buffer[0] = 1; - buffer[1] = 0; - var uut = new ByteBuffer(buffer); - Assert.AreEqual(1, uut.GetShort(0)); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_GetShortChecksOffset() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetShort(2)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_GetShortChecksLength() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetShort(1)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_GetIntReturnsCorrectData() - { - var buffer = new byte[4]; - buffer[0] = 0x0D; - buffer[1] = 0x0C; - buffer[2] = 0x0B; - buffer[3] = 0x0A; - var uut = new ByteBuffer(buffer); - Assert.AreEqual(0x0A0B0C0D, uut.GetInt(0)); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_GetIntChecksOffset() - { - var buffer = new byte[4]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetInt(4)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_GetIntChecksLength() - { - var buffer = new byte[2]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetInt(0)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_GetLongReturnsCorrectData() - { - var buffer = new byte[8]; - buffer[0] = 0x0D; - buffer[1] = 0x0C; - buffer[2] = 0x0B; - buffer[3] = 0x0A; - buffer[4] = 0x04; - buffer[5] = 0x03; - buffer[6] = 0x02; - buffer[7] = 0x01; - var uut = new ByteBuffer(buffer); - Assert.AreEqual(0x010203040A0B0C0D, uut.GetLong(0)); - } - -#if !BYTEBUFFER_NO_BOUNDS_CHECK - [FlatBuffersTestMethod] - public void ByteBuffer_GetLongChecksOffset() - { - var buffer = new byte[8]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetLong(8)); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_GetLongChecksLength() - { - var buffer = new byte[7]; - var uut = new ByteBuffer(buffer); - Assert.Throws<ArgumentOutOfRangeException>(() => uut.GetLong(0)); - } -#endif - - [FlatBuffersTestMethod] - public void ByteBuffer_ReverseBytesUshort() - { - const ushort original = (ushort)0x1234U; - var reverse = ByteBuffer.ReverseBytes(original); - Assert.AreEqual(0x3412U, reverse); - - var rereverse = ByteBuffer.ReverseBytes(reverse); - Assert.AreEqual(original, rereverse); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_ReverseBytesUint() - { - const uint original = 0x12345678; - var reverse = ByteBuffer.ReverseBytes(original); - Assert.AreEqual(0x78563412U, reverse); - - var rereverse = ByteBuffer.ReverseBytes(reverse); - Assert.AreEqual(original, rereverse); - } - - [FlatBuffersTestMethod] - public void ByteBuffer_ReverseBytesUlong() - { - const ulong original = 0x1234567890ABCDEFUL; - var reverse = ByteBuffer.ReverseBytes(original); - Assert.AreEqual(0xEFCDAB9078563412UL, reverse); - - var rereverse = ByteBuffer.ReverseBytes(reverse); - Assert.AreEqual(original, rereverse); - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs deleted file mode 100644 index f02df44..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBufferBuilderTests.cs +++ /dev/null
@@ -1,249 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers.Test -{ - [FlatBuffersTestClass] - public class FlatBufferBuilderTests - { - private FlatBufferBuilder CreateBuffer(bool forceDefaults = true) - { - var fbb = new FlatBufferBuilder(16) {ForceDefaults = forceDefaults}; - fbb.StartObject(1); - return fbb; - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddBool_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddBool(0, false, false); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(bool), endOffset-storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddSByte_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddSbyte(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(sbyte), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddByte_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddByte(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(byte), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddShort_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddShort(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(short), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddUShort_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddUshort(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(ushort), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddInt_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddInt(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(int), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddUInt_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddUint(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(uint), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddLong_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddLong(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(long), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddULong_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddUlong(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(ulong), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddFloat_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddFloat(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(float), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WithForceDefaults_WhenAddDouble_AndDefaultValue_OffsetIncreasesBySize() - { - var fbb = CreateBuffer(); - var storedOffset = fbb.Offset; - fbb.AddDouble(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(sizeof(double), endOffset - storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddBool_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddBool(0, false, false); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddSByte_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddSbyte(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddByte_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddByte(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddShort_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddShort(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddUShort_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddUshort(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddInt_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddInt(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddUInt_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddUint(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddLong_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddLong(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddULong_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddUlong(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddFloat_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddFloat(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - - [FlatBuffersTestMethod] - public void FlatBufferBuilder_WhenAddDouble_AndDefaultValue_OffsetIsUnchanged() - { - var fbb = CreateBuffer(false); - var storedOffset = fbb.Offset; - fbb.AddDouble(0, 0, 0); - var endOffset = fbb.Offset; - Assert.AreEqual(endOffset, storedOffset); - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffers.Test.csproj b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffers.Test.csproj deleted file mode 100644 index eda44c7..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffers.Test.csproj +++ /dev/null
@@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{9DB0B5E7-757E-4BD1-A5F6-279390331254}</ProjectGuid> - <OutputType>Exe</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>FlatBuffers.Test</RootNamespace> - <AssemblyName>FlatBuffers.Test</AssemblyName> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup> - <StartupObject /> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - </ItemGroup> - <ItemGroup> - <Compile Include="..\..\net\FlatBuffers\ByteBuffer.cs"> - <Link>FlatBuffers\ByteBuffer.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\IFlatbufferObject.cs"> - <Link>FlatBuffers\IFlatbufferObject.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\Offset.cs"> - <Link>FlatBuffers\Offset.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\FlatBufferBuilder.cs"> - <Link>FlatBuffers\FlatBufferBuilder.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\FlatBufferConstants.cs"> - <Link>FlatBuffers\FlatBufferConstants.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\Struct.cs"> - <Link>FlatBuffers\Struct.cs</Link> - </Compile> - <Compile Include="..\..\net\FlatBuffers\Table.cs"> - <Link>FlatBuffers\Table.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Any.cs"> - <Link>MyGame\Example\Any.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Color.cs"> - <Link>MyGame\Example\Color.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Monster.cs"> - <Link>MyGame\Example\Monster.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Stat.cs"> - <Link>MyGame\Example\Stat.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Test.cs"> - <Link>MyGame\Example\Test.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\TestSimpleTableWithEnum.cs"> - <Link>MyGame\Example\TestSimpleTableWithEnum.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Vec3.cs"> - <Link>MyGame\Example\Vec3.cs</Link> - </Compile> - <Compile Include="..\MyGame\Example\Ability.cs"> - <Link>MyGame\Example\Ability.cs</Link> - </Compile> - <Compile Include="..\namespace_test\NamespaceA\NamespaceB\EnumInNestedNS.cs"> - <Link>NamespaceA\NamespaceB\EnumInNestedNS.cs</Link> - </Compile> - <Compile Include="..\namespace_test\NamespaceA\NamespaceB\StructInNestedNS.cs"> - <Link>NamespaceA\NamespaceB\StructInNestedNS.cs</Link> - </Compile> - <Compile Include="..\namespace_test\NamespaceA\NamespaceB\TableInNestedNS.cs"> - <Link>NamespaceA\NamespaceB\TableInNestedNS.cs</Link> - </Compile> - <Compile Include="..\namespace_test\NamespaceA\TableInFirstNS.cs"> - <Link>NamespaceA\TableInFirstNS.cs</Link> - </Compile> - <Compile Include="Assert.cs" /> - <Compile Include="ByteBufferTests.cs" /> - <Compile Include="FlatBufferBuilderTests.cs" /> - <Compile Include="FlatBuffersFuzzTests.cs" /> - <Compile Include="FlatBuffersTestClassAttribute.cs" /> - <Compile Include="FlatBuffersTestMethodAttribute.cs" /> - <Compile Include="FuzzTestData.cs" /> - <Compile Include="Lcg.cs" /> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="FlatBuffersExampleTests.cs" /> - <Compile Include="TestTable.cs" /> - </ItemGroup> - <ItemGroup> - <Content Include="..\monsterdata_test.mon"> - <Link>Resources\monsterdata_test.mon</Link> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </Content> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project>
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs deleted file mode 100644 index d032d7e..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs +++ /dev/null
@@ -1,281 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System.IO; -using System.Text; -using MyGame.Example; - -namespace FlatBuffers.Test -{ - [FlatBuffersTestClass] - public class FlatBuffersExampleTests - { - public void RunTests() - { - CanCreateNewFlatBufferFromScratch(); - CanReadCppGeneratedWireFile(); - TestEnums(); - } - - [FlatBuffersTestMethod] - public void CanCreateNewFlatBufferFromScratch() - { - // Second, let's create a FlatBuffer from scratch in C#, and test it also. - // We use an initial size of 1 to exercise the reallocation algorithm, - // normally a size larger than the typical FlatBuffer you generate would be - // better for performance. - var fbb = new FlatBufferBuilder(1); - - StringOffset[] names = { fbb.CreateString("Frodo"), fbb.CreateString("Barney"), fbb.CreateString("Wilma") }; - Offset<Monster>[] off = new Offset<Monster>[3]; - Monster.StartMonster(fbb); - Monster.AddName(fbb, names[0]); - off[0] = Monster.EndMonster(fbb); - Monster.StartMonster(fbb); - Monster.AddName(fbb, names[1]); - off[1] = Monster.EndMonster(fbb); - Monster.StartMonster(fbb); - Monster.AddName(fbb, names[2]); - off[2] = Monster.EndMonster(fbb); - var sortMons = Monster.CreateMySortedVectorOfTables(fbb, off); - - // We set up the same values as monsterdata.json: - - var str = fbb.CreateString("MyMonster"); - var test1 = fbb.CreateString("test1"); - var test2 = fbb.CreateString("test2"); - - - Monster.StartInventoryVector(fbb, 5); - for (int i = 4; i >= 0; i--) - { - fbb.AddByte((byte)i); - } - var inv = fbb.EndVector(); - - var fred = fbb.CreateString("Fred"); - Monster.StartMonster(fbb); - Monster.AddName(fbb, fred); - var mon2 = Monster.EndMonster(fbb); - - Monster.StartTest4Vector(fbb, 2); - MyGame.Example.Test.CreateTest(fbb, (short)10, (sbyte)20); - MyGame.Example.Test.CreateTest(fbb, (short)30, (sbyte)40); - var test4 = fbb.EndVector(); - - Monster.StartTestarrayofstringVector(fbb, 2); - fbb.AddOffset(test2.Value); - fbb.AddOffset(test1.Value); - var testArrayOfString = fbb.EndVector(); - - Monster.StartMonster(fbb); - Monster.AddPos(fbb, Vec3.CreateVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0, - Color.Green, (short)5, (sbyte)6)); - Monster.AddHp(fbb, (short)80); - Monster.AddName(fbb, str); - Monster.AddInventory(fbb, inv); - Monster.AddTestType(fbb, Any.Monster); - Monster.AddTest(fbb, mon2.Value); - Monster.AddTest4(fbb, test4); - Monster.AddTestarrayofstring(fbb, testArrayOfString); - Monster.AddTestbool(fbb, false); - Monster.AddTestarrayoftables(fbb, sortMons); - var mon = Monster.EndMonster(fbb); - - Monster.FinishMonsterBuffer(fbb, mon); - - - // Dump to output directory so we can inspect later, if needed - using (var ms = new MemoryStream(fbb.DataBuffer.Data, fbb.DataBuffer.Position, fbb.Offset)) - { - var data = ms.ToArray(); - File.WriteAllBytes(@"Resources/monsterdata_cstest.mon",data); - } - - // Now assert the buffer - TestBuffer(fbb.DataBuffer); - - //Attempt to mutate Monster fields and check whether the buffer has been mutated properly - // revert to original values after testing - Monster monster = Monster.GetRootAsMonster(fbb.DataBuffer); - - // mana is optional and does not exist in the buffer so the mutation should fail - // the mana field should retain its default value - Assert.AreEqual(monster.MutateMana((short)10), false); - Assert.AreEqual(monster.Mana, (short)150); - - // Accessing a vector of sorted by the key tables - Assert.AreEqual(monster.Testarrayoftables(0).Value.Name, "Barney"); - Assert.AreEqual(monster.Testarrayoftables(1).Value.Name, "Frodo"); - Assert.AreEqual(monster.Testarrayoftables(2).Value.Name, "Wilma"); - - // Example of searching for a table by the key - Assert.IsTrue(Monster.LookupByKey(sortMons, "Frodo", fbb.DataBuffer) != null); - Assert.IsTrue(Monster.LookupByKey(sortMons, "Barney", fbb.DataBuffer) != null); - Assert.IsTrue(Monster.LookupByKey(sortMons, "Wilma", fbb.DataBuffer)!= null); - - // testType is an existing field and mutating it should succeed - Assert.AreEqual(monster.TestType, Any.Monster); - Assert.AreEqual(monster.MutateTestType(Any.NONE), true); - Assert.AreEqual(monster.TestType, Any.NONE); - Assert.AreEqual(monster.MutateTestType(Any.Monster), true); - Assert.AreEqual(monster.TestType, Any.Monster); - - //mutate the inventory vector - Assert.AreEqual(monster.MutateInventory(0, 1), true); - Assert.AreEqual(monster.MutateInventory(1, 2), true); - Assert.AreEqual(monster.MutateInventory(2, 3), true); - Assert.AreEqual(monster.MutateInventory(3, 4), true); - Assert.AreEqual(monster.MutateInventory(4, 5), true); - - for (int i = 0; i < monster.InventoryLength; i++) - { - Assert.AreEqual(monster.Inventory(i), i + 1); - } - - //reverse mutation - Assert.AreEqual(monster.MutateInventory(0, 0), true); - Assert.AreEqual(monster.MutateInventory(1, 1), true); - Assert.AreEqual(monster.MutateInventory(2, 2), true); - Assert.AreEqual(monster.MutateInventory(3, 3), true); - Assert.AreEqual(monster.MutateInventory(4, 4), true); - - // get a struct field and edit one of its fields - Vec3 pos = (Vec3)monster.Pos; - Assert.AreEqual(pos.X, 1.0f); - pos.MutateX(55.0f); - Assert.AreEqual(pos.X, 55.0f); - pos.MutateX(1.0f); - Assert.AreEqual(pos.X, 1.0f); - - TestBuffer(fbb.DataBuffer); - } - - private void TestBuffer(ByteBuffer bb) - { - var monster = Monster.GetRootAsMonster(bb); - - Assert.AreEqual(80, monster.Hp); - Assert.AreEqual(150, monster.Mana); - Assert.AreEqual("MyMonster", monster.Name); - - var pos = monster.Pos.Value; - Assert.AreEqual(1.0f, pos.X); - Assert.AreEqual(2.0f, pos.Y); - Assert.AreEqual(3.0f, pos.Z); - - Assert.AreEqual(3.0f, pos.Test1); - Assert.AreEqual(Color.Green, pos.Test2); - var t = (MyGame.Example.Test)pos.Test3; - Assert.AreEqual((short)5, t.A); - Assert.AreEqual((sbyte)6, t.B); - - Assert.AreEqual(Any.Monster, monster.TestType); - - var monster2 = monster.Test<Monster>().Value; - Assert.AreEqual("Fred", monster2.Name); - - - Assert.AreEqual(5, monster.InventoryLength); - var invsum = 0; - for (var i = 0; i < monster.InventoryLength; i++) - { - invsum += monster.Inventory(i); - } - Assert.AreEqual(10, invsum); - - var test0 = monster.Test4(0).Value; - var test1 = monster.Test4(1).Value; - Assert.AreEqual(2, monster.Test4Length); - - Assert.AreEqual(100, test0.A + test0.B + test1.A + test1.B); - - Assert.AreEqual(2, monster.TestarrayofstringLength); - Assert.AreEqual("test1", monster.Testarrayofstring(0)); - Assert.AreEqual("test2", monster.Testarrayofstring(1)); - - Assert.AreEqual(false, monster.Testbool); - - var nameBytes = monster.GetNameBytes().Value; - Assert.AreEqual("MyMonster", Encoding.UTF8.GetString(nameBytes.Array, nameBytes.Offset, nameBytes.Count)); - - if (0 == monster.TestarrayofboolsLength) - { - Assert.IsFalse(monster.GetTestarrayofboolsBytes().HasValue); - } - else - { - Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue); - } - } - - [FlatBuffersTestMethod] - public void CanReadCppGeneratedWireFile() - { - var data = File.ReadAllBytes(@"Resources/monsterdata_test.mon"); - var bb = new ByteBuffer(data); - TestBuffer(bb); - } - - [FlatBuffersTestMethod] - public void TestEnums() - { - Assert.AreEqual("Red", Color.Red.ToString()); - Assert.AreEqual("Blue", Color.Blue.ToString()); - Assert.AreEqual("NONE", Any.NONE.ToString()); - Assert.AreEqual("Monster", Any.Monster.ToString()); - } - - [FlatBuffersTestMethod] - public void TestNestedFlatBuffer() - { - const string nestedMonsterName = "NestedMonsterName"; - const short nestedMonsterHp = 600; - const short nestedMonsterMana = 1024; - // Create nested buffer as a Monster type - var fbb1 = new FlatBufferBuilder(16); - var str1 = fbb1.CreateString(nestedMonsterName); - Monster.StartMonster(fbb1); - Monster.AddName(fbb1, str1); - Monster.AddHp(fbb1, nestedMonsterHp); - Monster.AddMana(fbb1, nestedMonsterMana); - var monster1 = Monster.EndMonster(fbb1); - Monster.FinishMonsterBuffer(fbb1, monster1); - var fbb1Bytes = fbb1.SizedByteArray(); - fbb1 = null; - - // Create a Monster which has the first buffer as a nested buffer - var fbb2 = new FlatBufferBuilder(16); - var str2 = fbb2.CreateString("My Monster"); - var nestedBuffer = Monster.CreateTestnestedflatbufferVector(fbb2, fbb1Bytes); - Monster.StartMonster(fbb2); - Monster.AddName(fbb2, str2); - Monster.AddHp(fbb2, 50); - Monster.AddMana(fbb2, 32); - Monster.AddTestnestedflatbuffer(fbb2, nestedBuffer); - var monster = Monster.EndMonster(fbb2); - Monster.FinishMonsterBuffer(fbb2, monster); - - // Now test the data extracted from the nested buffer - var mons = Monster.GetRootAsMonster(fbb2.DataBuffer); - var nestedMonster = mons.GetTestnestedflatbufferAsMonster().Value; - - Assert.AreEqual(nestedMonsterMana, nestedMonster.Mana); - Assert.AreEqual(nestedMonsterHp, nestedMonster.Hp); - Assert.AreEqual(nestedMonsterName, nestedMonster.Name); - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs deleted file mode 100644 index e8182d7..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersFuzzTests.cs +++ /dev/null
@@ -1,742 +0,0 @@ -/* - * Copyright 2015 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace FlatBuffers.Test -{ - [FlatBuffersTestClass] - public class FlatBuffersFuzzTests - { - private readonly Lcg _lcg = new Lcg(); - - [FlatBuffersTestMethod] - public void TestObjects() - { - CheckObjects(11, 100); - } - - [FlatBuffersTestMethod] - public void TestNumbers() - { - var builder = new FlatBufferBuilder(1); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddBool(true); - Assert.ArrayEqual(new byte[] { 1 }, builder.DataBuffer.Data); - builder.AddSbyte(-127); - Assert.ArrayEqual(new byte[] { 129, 1 }, builder.DataBuffer.Data); - builder.AddByte(255); - Assert.ArrayEqual(new byte[] { 0, 255, 129, 1 }, builder.DataBuffer.Data); // First pad - builder.AddShort(-32222); - Assert.ArrayEqual(new byte[] { 0, 0, 0x22, 0x82, 0, 255, 129, 1 }, builder.DataBuffer.Data); // Second pad - builder.AddUshort(0xFEEE); - Assert.ArrayEqual(new byte[] { 0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1 }, builder.DataBuffer.Data); // no pad - builder.AddInt(-53687092); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 204, 204, 204, 252, 0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1 }, builder.DataBuffer.Data); // third pad - builder.AddUint(0x98765432); - Assert.ArrayEqual(new byte[] { 0x32, 0x54, 0x76, 0x98, 204, 204, 204, 252, 0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1 }, builder.DataBuffer.Data); // no pad - } - - [FlatBuffersTestMethod] - public void TestNumbers64() - { - var builder = new FlatBufferBuilder(1); - builder.AddUlong(0x1122334455667788); - Assert.ArrayEqual(new byte[] { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 }, builder.DataBuffer.Data); - - builder = new FlatBufferBuilder(1); - builder.AddLong(0x1122334455667788); - Assert.ArrayEqual(new byte[] { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVector_1xUInt8() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(byte), 1, 1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, builder.DataBuffer.Data); - builder.AddByte(1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, builder.DataBuffer.Data); - builder.EndVector(); - Assert.ArrayEqual(new byte[] { 1, 0, 0, 0, 1, 0, 0, 0 }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVector_2xUint8() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(byte), 2, 1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, builder.DataBuffer.Data); - builder.AddByte(1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, builder.DataBuffer.Data); - builder.AddByte(2); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 2, 1, 0, 0 }, builder.DataBuffer.Data); - builder.EndVector(); - Assert.ArrayEqual(new byte[] { 2, 0, 0, 0, 2, 1, 0, 0 }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVector_1xUInt16() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(ushort), 1, 1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, builder.DataBuffer.Data); - builder.AddUshort(1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, builder.DataBuffer.Data); - builder.EndVector(); - Assert.ArrayEqual(new byte[] { 1, 0, 0, 0, 1, 0, 0, 0 }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVector_2xUInt16() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(ushort), 2, 1); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, builder.DataBuffer.Data); - builder.AddUshort(0xABCD); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0xCD, 0xAB }, builder.DataBuffer.Data); - builder.AddUshort(0xDCBA); - Assert.ArrayEqual(new byte[] { 0, 0, 0, 0, 0xBA, 0xDC, 0xCD, 0xAB }, builder.DataBuffer.Data); - builder.EndVector(); - Assert.ArrayEqual(new byte[] { 2, 0, 0, 0, 0xBA, 0xDC, 0xCD, 0xAB }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestCreateAsciiString() - { - var builder = new FlatBufferBuilder(1); - builder.CreateString("foo"); - Assert.ArrayEqual(new byte[] { 3, 0, 0, 0, (byte)'f', (byte)'o', (byte)'o', 0 }, builder.DataBuffer.Data); - - builder.CreateString("moop"); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, // Padding to 32 bytes - 4, 0, 0, 0, - (byte)'m', (byte)'o', (byte)'o', (byte)'p', - 0, 0, 0, 0, // zero terminator with 3 byte pad - 3, 0, 0, 0, - (byte)'f', (byte)'o', (byte)'o', 0 - }, builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestCreateArbitarytring() - { - var builder = new FlatBufferBuilder(1); - builder.CreateString("\x01\x02\x03"); - Assert.ArrayEqual(new byte[] - { - 3, 0, 0, 0, - 0x01, 0x02, 0x03, 0 - }, builder.DataBuffer.Data); // No padding - builder.CreateString("\x04\x05\x06\x07"); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, // Padding to 32 bytes - 4, 0, 0, 0, - 0x04, 0x05, 0x06, 0x07, - 0, 0, 0, 0, // zero terminator with 3 byte pad - 3, 0, 0, 0, - 0x01, 0x02, 0x03, 0 - }, builder.DataBuffer.Data); // No padding - } - - [FlatBuffersTestMethod] - public void TestEmptyVTable() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(0); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 4, 0, 4, 0, - 4, 0, 0, 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithOneBool() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(1); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddBool(0, true, false); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, // padding to 16 bytes - 6, 0, // vtable bytes - 8, 0, // object length inc vtable offset - 7, 0, // start of bool value - 6, 0, 0, 0, // int32 offset for start of vtable - 0, 0, 0, // padding - 1, // value 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithOneBool_DefaultValue() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(1); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddBool(0, false, false); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, 0, 0, // padding to 16 bytes - 6, 0, // vtable bytes - 4, 0, // end of object from here - 0, 0, // entry 0 is empty (default value) - 6, 0, 0, 0, // int32 offset for start of vtable - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithOneInt16() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(1); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddShort(0, 0x789A, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, // padding to 16 bytes - 6, 0, // vtable bytes - 8, 0, // object length inc vtable offset - 6, 0, // start of int16 value - 6, 0, 0, 0, // int32 offset for start of vtable - 0, 0, // padding - 0x9A, 0x78, //value 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithTwoInt16() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(2); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddShort(0, 0x3456, 0); - builder.AddShort(1, 0x789A, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 8, 0, // vtable bytes - 8, 0, // object length inc vtable offset - 6, 0, // start of int16 value 0 - 4, 0, // start of int16 value 1 - 8, 0, 0, 0, // int32 offset for start of vtable - 0x9A, 0x78, // value 1 - 0x56, 0x34, // value 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithInt16AndBool() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(2); - Assert.ArrayEqual(new byte[] { 0 }, builder.DataBuffer.Data); - builder.AddShort(0, 0x3456, 0); - builder.AddBool(1, true, false); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 8, 0, // vtable bytes - 8, 0, // object length inc vtable offset - 6, 0, // start of int16 value 0 - 5, 0, // start of bool value 1 - 8, 0, 0, 0, // int32 offset for start of vtable - 0, 1, // padding + value 1 - 0x56, 0x34, // value 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithEmptyVector() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(byte), 0, 1); - var vecEnd = builder.EndVector(); - - builder.StartObject(1); - - builder.AddOffset(0, vecEnd.Value, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, // Padding to 32 bytes - 6, 0, // vtable bytes - 8, 0, // object length inc vtable offset - 4, 0, // start of vector offset value 0 - 6, 0, 0, 0, // int32 offset for start of vtable - 4, 0, 0, 0, - 0, 0, 0, 0, - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithEmptyVectorAndScalars() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(byte), 0, 1); - var vecEnd = builder.EndVector(); - - builder.StartObject(2); - builder.AddShort(0, 55, 0); - builder.AddOffset(1, vecEnd.Value, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, // Padding to 32 bytes - 8, 0, // vtable bytes - 12, 0, // object length inc vtable offset - 10, 0, // offset to int16 value 0 - 4, 0, // start of vector offset value 1 - 8, 0, 0, 0, // int32 offset for start of vtable - 8, 0, 0, 0, // value 1 - 0, 0, 55, 0, // value 0 - 0, 0, 0, 0, // length of vector (not in sctruc) - }, - builder.DataBuffer.Data); - } - - - [FlatBuffersTestMethod] - public void TestVTableWith_1xInt16_and_Vector_or_2xInt16() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(short), 2, 1); - builder.AddShort(0x1234); - builder.AddShort(0x5678); - var vecEnd = builder.EndVector(); - - builder.StartObject(2); - builder.AddOffset(1, vecEnd.Value, 0); - builder.AddShort(0, 55, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, // Padding to 32 bytes - 8, 0, // vtable bytes - 12, 0, // object length - 6, 0, // start of value 0 from end of vtable - 8, 0, // start of value 1 from end of buffer - 8, 0, 0, 0, // int32 offset for start of vtable - 0, 0, 55, 0, // padding + value 0 - 4, 0, 0, 0, // position of vector from here - 2, 0, 0, 0, // length of vector - 0x78, 0x56, // vector value 0 - 0x34, 0x12, // vector value 1 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithAStruct_of_int8_int16_int32() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(1); - builder.Prep(4+4+4, 0); - builder.AddSbyte(55); - builder.Pad(3); - builder.AddShort(0x1234); - builder.Pad(2); - builder.AddInt(0x12345678); - var structStart = builder.Offset; - builder.AddStruct(0, structStart, 0); - builder.EndObject(); - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, // Padding to 32 bytes - 6, 0, // vtable bytes - 16, 0, // object length - 4, 0, // start of struct from here - 6, 0, 0, 0, // int32 offset for start of vtable - 0x78, 0x56, 0x34, 0x12, // struct value 2 - 0x00, 0x00, 0x34, 0x12, // struct value 1 - 0x00, 0x00, 0x00, 55, // struct value 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithAVectorOf_2xStructOf_2xInt8() - { - var builder = new FlatBufferBuilder(1); - builder.StartVector(sizeof(byte)*2, 2, 1); - builder.AddByte(33); - builder.AddByte(44); - builder.AddByte(55); - builder.AddByte(66); - var vecEnd = builder.EndVector(); - - builder.StartObject(1); - builder.AddOffset(0, vecEnd.Value, 0); - builder.EndObject(); - - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, // Padding to 32 bytes - 6, 0, // vtable bytes - 8, 0, // object length - 4, 0, // offset of vector offset - 6, 0, 0, 0, // int32 offset for start of vtable - 4, 0, 0, 0, // Vector start offset - 2, 0, 0, 0, // Vector len - 66, // vector 1, 1 - 55, // vector 1, 0 - 44, // vector 0, 1 - 33, // vector 0, 0 - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestVTableWithSomeElements() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(2); - builder.AddByte(0, 33, 0); - builder.AddShort(1, 66, 0); - var off = builder.EndObject(); - builder.Finish(off); - - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, //Padding to 32 bytes - 12, 0, 0, 0, // root of table, pointing to vtable offset - 8, 0, // vtable bytes - 8, 0, // object length - 7, 0, // start of value 0 - 4, 0, // start of value 1 - 8, 0, 0, 0, // int32 offset for start of vtable - 66, 0, // value 1 - 0, 33, // value 0 - - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestTwoFinishTable() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(2); - builder.AddByte(0, 33, 0); - builder.AddByte(1, 44, 0); - var off0 = builder.EndObject(); - builder.Finish(off0); - - builder.StartObject(3); - builder.AddByte(0, 55, 0); - builder.AddByte(1, 66, 0); - builder.AddByte(2, 77, 0); - var off1 = builder.EndObject(); - builder.Finish(off1); - - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, // padding to 64 bytes - 16, 0, 0, 0, // root of table, pointing to vtable offset (obj1) - 0, 0, // padding - - 10, 0, // vtable bytes - 8, 0, // object length - 7, 0, // start of value 0 - 6, 0, // start of value 1 - 5, 0, // start of value 2 - 10, 0, 0, 0, // int32 offset for start of vtable - 0, // pad - 77, // values 2, 1, 0 - 66, - 55, - - 12, 0, 0, 0, // root of table, pointing to vtable offset (obj0) - 8, 0, // vtable bytes - 8, 0, // object length - 7, 0, // start of value 0 - 6, 0, // start of value 1 - 8, 0, 0, 0, // int32 offset for start of vtable - 0, 0, // pad - 44, // value 1, 0 - 33, - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestBunchOfBools() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(8); - for (var i = 0; i < 8; i++) - { - builder.AddBool(i, true, false); - } - var off = builder.EndObject(); - builder.Finish(off); - - Assert.ArrayEqual(new byte[] - { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, // padding to 64 bytes - - 24, 0, 0, 0, // root of table, pointing to vtable offset (obj0) - 20, 0, // vtable bytes - 12, 0, // object length - 11, 0, // start of value 0 - 10, 0, // start of value 1 - 9, 0, // start of value 2 - 8, 0, // start of value 3 - 7, 0, // start of value 4 - 6, 0, // start of value 5 - 5, 0, // start of value 6 - 4, 0, // start of value 7 - - 20, 0, 0, 0, // int32 offset for start of vtable - - 1, 1, 1, 1, // values - 1, 1, 1, 1, - - }, - builder.DataBuffer.Data); - } - - [FlatBuffersTestMethod] - public void TestWithFloat() - { - var builder = new FlatBufferBuilder(1); - builder.StartObject(1); - builder.AddFloat(0, 1, 0); - builder.EndObject(); - - - Assert.ArrayEqual(new byte[] - { - 0, 0, - 6, 0, // vtable bytes - 8, 0, // object length - 4, 0, // start of value 0 - 6, 0, 0, 0, // int32 offset for start of vtable - 0, 0, 128, 63, // value - - }, - builder.DataBuffer.Data); - } - - private void CheckObjects(int fieldCount, int objectCount) - { - _lcg.Reset(); - - const int testValuesMax = 11; - - var builder = new FlatBufferBuilder(1); - - var objects = new int[objectCount]; - - for (var i = 0; i < objectCount; ++i) - { - builder.StartObject(fieldCount); - - for (var j = 0; j < fieldCount; ++j) - { - var fieldType = _lcg.Next()%testValuesMax; - - switch (fieldType) - { - case 0: - { - builder.AddBool(j, FuzzTestData.BoolValue, false); - break; - } - case 1: - { - builder.AddSbyte(j, FuzzTestData.Int8Value, 0); - break; - } - case 2: - { - builder.AddByte(j, FuzzTestData.UInt8Value, 0); - break; - } - case 3: - { - builder.AddShort(j, FuzzTestData.Int16Value, 0); - break; - } - case 4: - { - builder.AddUshort(j, FuzzTestData.UInt16Value, 0); - break; - } - case 5: - { - builder.AddInt(j, FuzzTestData.Int32Value, 0); - break; - } - case 6: - { - builder.AddUint(j, FuzzTestData.UInt32Value, 0); - break; - } - case 7: - { - builder.AddLong(j, FuzzTestData.Int64Value, 0); - break; - } - case 8: - { - builder.AddUlong(j, FuzzTestData.UInt64Value, 0); - break; - } - case 9: - { - builder.AddFloat(j, FuzzTestData.Float32Value, 0); - break; - } - case 10: - { - builder.AddDouble(j, FuzzTestData.Float64Value, 0); - break; - } - default: - throw new Exception("Unreachable"); - } - - } - - var offset = builder.EndObject(); - - // Store the object offset - objects[i] = offset; - } - - _lcg.Reset(); - - // Test all objects are readable and return expected values... - for (var i = 0; i < objectCount; ++i) - { - var table = new TestTable(builder.DataBuffer, builder.DataBuffer.Length - objects[i]); - - for (var j = 0; j < fieldCount; ++j) - { - var fieldType = _lcg.Next() % testValuesMax; - var fc = 2 + j; // 2 == VtableMetadataFields - var f = fc * 2; - - switch (fieldType) - { - case 0: - { - Assert.AreEqual(FuzzTestData.BoolValue, table.GetSlot(f, false)); - break; - } - case 1: - { - Assert.AreEqual(FuzzTestData.Int8Value, table.GetSlot(f, (sbyte)0)); - break; - } - case 2: - { - Assert.AreEqual(FuzzTestData.UInt8Value, table.GetSlot(f, (byte)0)); - break; - } - case 3: - { - Assert.AreEqual(FuzzTestData.Int16Value, table.GetSlot(f, (short)0)); - break; - } - case 4: - { - Assert.AreEqual(FuzzTestData.UInt16Value, table.GetSlot(f, (ushort)0)); - break; - } - case 5: - { - Assert.AreEqual(FuzzTestData.Int32Value, table.GetSlot(f, (int)0)); - break; - } - case 6: - { - Assert.AreEqual(FuzzTestData.UInt32Value, table.GetSlot(f, (uint)0)); - break; - } - case 7: - { - Assert.AreEqual(FuzzTestData.Int64Value, table.GetSlot(f, (long)0)); - break; - } - case 8: - { - Assert.AreEqual(FuzzTestData.UInt64Value, table.GetSlot(f, (ulong)0)); - break; - } - case 9: - { - Assert.AreEqual(FuzzTestData.Float32Value, table.GetSlot(f, (float)0)); - break; - } - case 10: - { - Assert.AreEqual(FuzzTestData.Float64Value, table.GetSlot(f, (double)0)); - break; - } - default: - throw new Exception("Unreachable"); - } - - } - - } - - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs deleted file mode 100644 index f31e38b..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestClassAttribute.cs +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace FlatBuffers.Test -{ - [AttributeUsage(AttributeTargets.Class)] - public class FlatBuffersTestClassAttribute : Attribute - { - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs deleted file mode 100644 index 989dae5..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FlatBuffersTestMethodAttribute.cs +++ /dev/null
@@ -1,25 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - using System; - -namespace FlatBuffers.Test -{ - [AttributeUsage(AttributeTargets.Method)] - public class FlatBuffersTestMethodAttribute : Attribute - { - } -} \ No newline at end of file
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/FuzzTestData.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/FuzzTestData.cs deleted file mode 100644 index 119e44e..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/FuzzTestData.cs +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace FlatBuffers.Test -{ - internal static class FuzzTestData - { - private static readonly byte[] _overflowInt32 = new byte[] {0x83, 0x33, 0x33, 0x33}; - private static readonly byte[] _overflowInt64 = new byte[] { 0x84, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; - - public static readonly bool BoolValue = true; - public static readonly sbyte Int8Value = -127; // 0x81 - public static readonly byte UInt8Value = 255; // 0xFF - public static readonly short Int16Value = -32222; // 0x8222; - public static readonly ushort UInt16Value = 65262; // 0xFEEE - public static readonly int Int32Value = BitConverter.ToInt32(_overflowInt32, 0); - public static readonly uint UInt32Value = 0xFDDDDDDD; - public static readonly long Int64Value = BitConverter.ToInt64(_overflowInt64, 0); - public static readonly ulong UInt64Value = 0xFCCCCCCCCCCCCCCC; - public static readonly float Float32Value = 3.14159f; - public static readonly double Float64Value = 3.14159265359; - } -} \ No newline at end of file
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/Lcg.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/Lcg.cs deleted file mode 100644 index c329ed8..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/Lcg.cs +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers.Test -{ - /// <summary> - /// Lcg Pseudo RNG - /// </summary> - internal sealed class Lcg - { - private const uint InitialValue = 10000; - private uint _state; - - public Lcg() - { - _state = InitialValue; - } - - public uint Next() - { - return (_state = 69069 * _state + 362437); - } - - public void Reset() - { - _state = InitialValue; - } - } -} \ No newline at end of file
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/Program.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/Program.cs deleted file mode 100644 index f8cec4e..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/Program.cs +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace FlatBuffers.Test -{ - static class Program - { - public static int Main(string[] args) - { - var testResults = new List<bool>(); - - var testClasses = Assembly.GetExecutingAssembly().GetExportedTypes() - .Where(t => t.IsClass && t.GetCustomAttributes(typeof (FlatBuffersTestClassAttribute), false).Length > 0); - - foreach (var testClass in testClasses) - { - var methods = testClass.GetMethods(BindingFlags.Public | - BindingFlags.Instance) - .Where(m => m.GetCustomAttributes(typeof(FlatBuffersTestMethodAttribute), false).Length > 0); - - var inst = Activator.CreateInstance(testClass); - - foreach (var method in methods) - { - try - { - method.Invoke(inst, new object[] { }); - testResults.Add(true); - } - catch (Exception ex) - { - Console.WriteLine("{0}: FAILED when invoking {1} with error {2}", - testClass.Name ,method.Name, ex.GetBaseException()); - testResults.Add(false); - } - } - } - - var failedCount = testResults.Count(i => i == false); - - Console.WriteLine("{0} tests run, {1} failed", testResults.Count, failedCount); - - if (failedCount > 0) - { - return -1; - } - return 0; - } - } -}
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/Properties/AssemblyInfo.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index 2e33f08..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/Properties/AssemblyInfo.cs +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("FlatBuffers.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FlatBuffers.Test")] -[assembly: AssemblyCopyright("Copyright (c) 2014 Google Inc")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a1d58a51-3e74-4ae9-aac7-5a399c9eed1a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/Resources/monsterdata_test.mon b/third_party/flatbuffers/tests/FlatBuffers.Test/Resources/monsterdata_test.mon deleted file mode 100644 index 2bf6d15..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/Resources/monsterdata_test.mon +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/tests/FlatBuffers.Test/TestTable.cs b/third_party/flatbuffers/tests/FlatBuffers.Test/TestTable.cs deleted file mode 100644 index 2b506b6..0000000 --- a/third_party/flatbuffers/tests/FlatBuffers.Test/TestTable.cs +++ /dev/null
@@ -1,153 +0,0 @@ -/* - * Copyright 2016 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace FlatBuffers.Test -{ - /// <summary> - /// A test Table object that gives easy access to the slot data - /// </summary> - internal struct TestTable - { - Table t; - - public TestTable(ByteBuffer bb, int pos) - { - t.bb = bb; - t.bb_pos = pos; - } - - public bool GetSlot(int slot, bool def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetSbyte(t.bb_pos + off) != 0; - } - - public sbyte GetSlot(int slot, sbyte def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetSbyte(t.bb_pos + off); - } - - public byte GetSlot(int slot, byte def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.Get(t.bb_pos + off); - } - - public short GetSlot(int slot, short def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetShort(t.bb_pos + off); - } - - public ushort GetSlot(int slot, ushort def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetUshort(t.bb_pos + off); - } - - public int GetSlot(int slot, int def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetInt(t.bb_pos + off); - } - - public uint GetSlot(int slot, uint def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetUint(t.bb_pos + off); - } - - public long GetSlot(int slot, long def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetLong(t.bb_pos + off); - } - - public ulong GetSlot(int slot, ulong def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetUlong(t.bb_pos + off); - } - - public float GetSlot(int slot, float def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetFloat(t.bb_pos + off); - } - - public double GetSlot(int slot, double def) - { - var off = t.__offset(slot); - - if (off == 0) - { - return def; - } - return t.bb.GetDouble(t.bb_pos + off); - } - } -}
diff --git a/third_party/flatbuffers/tests/GoTest.sh b/third_party/flatbuffers/tests/GoTest.sh deleted file mode 100755 index 7be4aff..0000000 --- a/third_party/flatbuffers/tests/GoTest.sh +++ /dev/null
@@ -1,67 +0,0 @@ -#!/bin/bash -eu -# -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -pushd "$(dirname $0)" >/dev/null -test_dir="$(pwd)" -go_path=${test_dir}/go_gen -go_src=${go_path}/src - -# Emit Go code for the example schema in the test dir: -../flatc -g monster_test.fbs - -# Go requires a particular layout of files in order to link multiple packages. -# Copy flatbuffer Go files to their own package directories to compile the -# test binary: -mkdir -p ${go_src}/MyGame/Example -mkdir -p ${go_src}/github.com/google/flatbuffers/go -mkdir -p ${go_src}/flatbuffers_test - -cp -a MyGame/Example/*.go ./go_gen/src/MyGame/Example/ -cp -a ../go/* ./go_gen/src/github.com/google/flatbuffers/go -cp -a ./go_test.go ./go_gen/src/flatbuffers_test/ - -# Run tests with necessary flags. -# Developers may wish to see more detail by appending the verbosity flag -# -test.v to arguments for this command, as in: -# go -test -test.v ... -# Developers may also wish to run benchmarks, which may be achieved with the -# flag -test.bench and the wildcard regexp ".": -# go -test -test.bench=. ... -GOPATH=${go_path} go test flatbuffers_test \ - --test.coverpkg=github.com/google/flatbuffers/go \ - --cpp_data=${test_dir}/monsterdata_test.mon \ - --out_data=${test_dir}/monsterdata_go_wire.mon \ - --test.bench=. \ - --test.benchtime=3s \ - --fuzz=true \ - --fuzz_fields=4 \ - --fuzz_objects=10000 - -GO_TEST_RESULT=$? -rm -rf ${go_path}/{pkg,src} -if [[ $GO_TEST_RESULT == 0 ]]; then - echo "OK: Go tests passed." -else - echo "KO: Go tests failed." - exit 1 -fi - -NOT_FMT_FILES=$(gofmt -l MyGame) -if [[ ${NOT_FMT_FILES} != "" ]]; then - echo "These files are not well gofmt'ed:\n\n${NOT_FMT_FILES}" - # enable this when enums are properly formated - # exit 1 -fi
diff --git a/third_party/flatbuffers/tests/JavaScriptTest.js b/third_party/flatbuffers/tests/JavaScriptTest.js deleted file mode 100644 index 7ed313a..0000000 --- a/third_party/flatbuffers/tests/JavaScriptTest.js +++ /dev/null
@@ -1,350 +0,0 @@ -// Run this using JavaScriptTest.sh -var assert = require('assert'); -var fs = require('fs'); - -var flatbuffers = require('../js/flatbuffers').flatbuffers; -var MyGame = require(process.argv[2]).MyGame; - -function main() { - - // First, let's test reading a FlatBuffer generated by C++ code: - // This file was generated from monsterdata_test.json - var data = new Uint8Array(fs.readFileSync('monsterdata_test.mon')); - - // Now test it: - - var bb = new flatbuffers.ByteBuffer(data); - testBuffer(bb); - - // Second, let's create a FlatBuffer from scratch in JavaScript, and test it also. - // We use an initial size of 1 to exercise the reallocation algorithm, - // normally a size larger than the typical FlatBuffer you generate would be - // better for performance. - var fbb = new flatbuffers.Builder(1); - - // We set up the same values as monsterdata.json: - - var str = fbb.createString('MyMonster'); - - var inv = MyGame.Example.Monster.createInventoryVector(fbb, [0, 1, 2, 3, 4]); - - var fred = fbb.createString('Fred'); - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addName(fbb, fred); - var mon2 = MyGame.Example.Monster.endMonster(fbb); - - MyGame.Example.Monster.startTest4Vector(fbb, 2); - MyGame.Example.Test.createTest(fbb, 10, 20); - MyGame.Example.Test.createTest(fbb, 30, 40); - var test4 = fbb.endVector(); - - var testArrayOfString = MyGame.Example.Monster.createTestarrayofstringVector(fbb, [ - fbb.createString('test1'), - fbb.createString('test2') - ]); - - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addPos(fbb, MyGame.Example.Vec3.createVec3(fbb, 1, 2, 3, 3, MyGame.Example.Color.Green, 5, 6)); - MyGame.Example.Monster.addHp(fbb, 80); - MyGame.Example.Monster.addName(fbb, str); - MyGame.Example.Monster.addInventory(fbb, inv); - MyGame.Example.Monster.addTestType(fbb, MyGame.Example.Any.Monster); - MyGame.Example.Monster.addTest(fbb, mon2); - MyGame.Example.Monster.addTest4(fbb, test4); - MyGame.Example.Monster.addTestarrayofstring(fbb, testArrayOfString); - MyGame.Example.Monster.addTestbool(fbb, false); - var mon = MyGame.Example.Monster.endMonster(fbb); - - MyGame.Example.Monster.finishMonsterBuffer(fbb, mon); - - // Write the result to a file for debugging purposes: - // Note that the binaries are not necessarily identical, since the JSON - // parser may serialize in a slightly different order than the above - // JavaScript code. They are functionally equivalent though. - - fs.writeFileSync('monsterdata_javascript_wire.mon', new Buffer(fbb.asUint8Array())); - - // Tests mutation first. This will verify that we did not trample any other - // part of the byte buffer. - testMutation(fbb.dataBuffer()); - - testBuffer(fbb.dataBuffer()); - - test64bit(); - testUnicode(); - fuzzTest1(); - - console.log('FlatBuffers test: completed successfully'); -} - -function testMutation(bb) { - var monster = MyGame.Example.Monster.getRootAsMonster(bb); - - monster.mutate_hp(120); - assert.strictEqual(monster.hp(), 120); - - monster.mutate_hp(80); - assert.strictEqual(monster.hp(), 80); - - var manaRes = monster.mutate_mana(10); - assert.strictEqual(manaRes, false); // Field was NOT present, because default value. - - // TODO: There is not the availability to mutate structs or vectors. -} - -function testBuffer(bb) { - assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb)); - - var monster = MyGame.Example.Monster.getRootAsMonster(bb); - - assert.strictEqual(monster.hp(), 80); - assert.strictEqual(monster.mana(), 150); // default - - assert.strictEqual(monster.name(), 'MyMonster'); - - var pos = monster.pos(); - assert.strictEqual(pos.x(), 1); - assert.strictEqual(pos.y(), 2); - assert.strictEqual(pos.z(), 3); - assert.strictEqual(pos.test1(), 3); - assert.strictEqual(pos.test2(), MyGame.Example.Color.Green); - var t = pos.test3(); - assert.strictEqual(t.a(), 5); - assert.strictEqual(t.b(), 6); - - assert.strictEqual(monster.testType(), MyGame.Example.Any.Monster); - var monster2 = new MyGame.Example.Monster(); - assert.strictEqual(monster.test(monster2) != null, true); - assert.strictEqual(monster2.name(), 'Fred'); - - assert.strictEqual(monster.inventoryLength(), 5); - var invsum = 0; - for (var i = 0; i < monster.inventoryLength(); i++) { - invsum += monster.inventory(i); - } - assert.strictEqual(invsum, 10); - - var invsum2 = 0; - var invArr = monster.inventoryArray(); - for (var i = 0; i < invArr.length; i++) { - invsum2 += invArr[i]; - } - assert.strictEqual(invsum2, 10); - - var test_0 = monster.test4(0); - var test_1 = monster.test4(1); - assert.strictEqual(monster.test4Length(), 2); - assert.strictEqual(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100); - - assert.strictEqual(monster.testarrayofstringLength(), 2); - assert.strictEqual(monster.testarrayofstring(0), 'test1'); - assert.strictEqual(monster.testarrayofstring(1), 'test2'); - - assert.strictEqual(monster.testbool(), false); -} - -function test64bit() { - var fbb = new flatbuffers.Builder(); - var required = fbb.createString('required'); - - MyGame.Example.Stat.startStat(fbb); - var stat2 = MyGame.Example.Stat.endStat(fbb); - - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addName(fbb, required); - MyGame.Example.Monster.addTestempty(fbb, stat2); - var mon2 = MyGame.Example.Monster.endMonster(fbb); - - MyGame.Example.Stat.startStat(fbb); - // 2541551405100253985 = 0x87654321(low part) + 0x23456789 * 0x100000000(high part); - MyGame.Example.Stat.addVal(fbb, new flatbuffers.Long(0x87654321, 0x23456789)); // the low part is Uint32 - var stat = MyGame.Example.Stat.endStat(fbb); - - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addName(fbb, required); - MyGame.Example.Monster.addEnemy(fbb, mon2); - MyGame.Example.Monster.addTestempty(fbb, stat); - var mon = MyGame.Example.Monster.endMonster(fbb); - - MyGame.Example.Monster.finishMonsterBuffer(fbb, mon); - var bytes = fbb.asUint8Array(); - - //////////////////////////////////////////////////////////////// - - var bb = new flatbuffers.ByteBuffer(bytes); - assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb)); - var mon = MyGame.Example.Monster.getRootAsMonster(bb); - - var stat = mon.testempty(); - assert.strictEqual(stat != null, true); - assert.strictEqual(stat.val() != null, true); - assert.strictEqual(stat.val().toFloat64(), 2541551405100253985); - - var mon2 = mon.enemy(); - assert.strictEqual(mon2 != null, true); - stat = mon2.testempty(); - assert.strictEqual(stat != null, true); - assert.strictEqual(stat.val() != null, true); - assert.strictEqual(stat.val().low, 0); // default value - assert.strictEqual(stat.val().high, 0); -} - -function testUnicode() { - var correct = fs.readFileSync('unicode_test.mon'); - var json = JSON.parse(fs.readFileSync('unicode_test.json', 'utf8')); - - // Test reading - function testReadingUnicode(bb) { - var monster = MyGame.Example.Monster.getRootAsMonster(bb); - assert.strictEqual(monster.name(), json.name); - assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name)); - assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length); - json.testarrayoftables.forEach(function(table, i) { - var value = monster.testarrayoftables(i); - assert.strictEqual(value.name(), table.name); - assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name)); - }); - assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length); - json.testarrayofstring.forEach(function(string, i) { - assert.strictEqual(monster.testarrayofstring(i), string); - assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string)); - }); - } - testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct))); - - // Test writing - var fbb = new flatbuffers.Builder(); - var name = fbb.createString(json.name); - var testarrayoftablesOffsets = json.testarrayoftables.map(function(table) { - var name = fbb.createString(new Uint8Array(new Buffer(table.name))); - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addName(fbb, name); - return MyGame.Example.Monster.endMonster(fbb); - }); - var testarrayoftablesOffset = MyGame.Example.Monster.createTestarrayoftablesVector(fbb, - testarrayoftablesOffsets); - var testarrayofstringOffset = MyGame.Example.Monster.createTestarrayofstringVector(fbb, - json.testarrayofstring.map(function(string) { return fbb.createString(string); })); - MyGame.Example.Monster.startMonster(fbb); - MyGame.Example.Monster.addTestarrayofstring(fbb, testarrayofstringOffset); - MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset); - MyGame.Example.Monster.addName(fbb, name); - MyGame.Example.Monster.finishMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb)); - testReadingUnicode(new flatbuffers.ByteBuffer(fbb.asUint8Array())); -} - -var __imul = Math.imul ? Math.imul : function(a, b) { - var ah = a >> 16 & 65535; - var bh = b >> 16 & 65535; - var al = a & 65535; - var bl = b & 65535; - return al * bl + (ah * bl + al * bh << 16) | 0; -}; - -// Include simple random number generator to ensure results will be the -// same cross platform. -// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator -var lcg_seed = 48271; - -function lcg_rand() { - return lcg_seed = (__imul(lcg_seed, 279470273) >>> 0) % 4294967291; -} - -function lcg_reset() { - lcg_seed = 48271; -} - -// Converts a Field ID to a virtual table offset. -function fieldIndexToOffset(field_id) { - // Should correspond to what EndTable() below builds up. - var fixed_fields = 2; // Vtable size and Object Size. - return (field_id + fixed_fields) * 2; -} - -// Low level stress/fuzz test: serialize/deserialize a variety of -// different kinds of data in different combinations -function fuzzTest1() { - - // Values we're testing against: chosen to ensure no bits get chopped - // off anywhere, and also be different from eachother. - var bool_val = true; - var char_val = -127; // 0x81 - var uchar_val = 0xFF; - var short_val = -32222; // 0x8222; - var ushort_val = 0xFEEE; - var int_val = 0x83333333 | 0; - var uint_val = 0xFDDDDDDD; - var long_val = new flatbuffers.Long(0x44444444, 0x84444444); - var ulong_val = new flatbuffers.Long(0xCCCCCCCC, 0xFCCCCCCC); - var float_val = new Float32Array([3.14159])[0]; - var double_val = 3.14159265359; - - var test_values_max = 11; - var fields_per_object = 4; - var num_fuzz_objects = 10000; // The higher, the more thorough :) - - var builder = new flatbuffers.Builder(); - - lcg_reset(); // Keep it deterministic. - - var objects = []; - - // Generate num_fuzz_objects random objects each consisting of - // fields_per_object fields, each of a random type. - for (var i = 0; i < num_fuzz_objects; i++) { - builder.startObject(fields_per_object); - for (var f = 0; f < fields_per_object; f++) { - var choice = lcg_rand() % test_values_max; - switch (choice) { - case 0: builder.addFieldInt8(f, bool_val, 0); break; - case 1: builder.addFieldInt8(f, char_val, 0); break; - case 2: builder.addFieldInt8(f, uchar_val, 0); break; - case 3: builder.addFieldInt16(f, short_val, 0); break; - case 4: builder.addFieldInt16(f, ushort_val, 0); break; - case 5: builder.addFieldInt32(f, int_val, 0); break; - case 6: builder.addFieldInt32(f, uint_val, 0); break; - case 7: builder.addFieldInt64(f, long_val, flatbuffers.Long.ZERO); break; - case 8: builder.addFieldInt64(f, ulong_val, flatbuffers.Long.ZERO); break; - case 9: builder.addFieldFloat32(f, float_val, 0); break; - case 10: builder.addFieldFloat64(f, double_val, 0); break; - } - } - objects.push(builder.endObject()); - } - builder.prep(8, 0); // Align whole buffer. - - lcg_reset(); // Reset. - - builder.finish(objects[objects.length - 1]); - var bytes = new Uint8Array(builder.asUint8Array()); - var view = new DataView(bytes.buffer); - - // Test that all objects we generated are readable and return the - // expected values. We generate random objects in the same order - // so this is deterministic. - for (var i = 0; i < num_fuzz_objects; i++) { - var offset = bytes.length - objects[i]; - for (var f = 0; f < fields_per_object; f++) { - var choice = lcg_rand() % test_values_max; - var vtable_offset = fieldIndexToOffset(f); - var vtable = offset - view.getInt32(offset, true); - assert.ok(vtable_offset < view.getInt16(vtable, true)); - var field_offset = offset + view.getInt16(vtable + vtable_offset, true); - switch (choice) { - case 0: assert.strictEqual(!!view.getInt8(field_offset), bool_val); break; - case 1: assert.strictEqual(view.getInt8(field_offset), char_val); break; - case 2: assert.strictEqual(view.getUint8(field_offset), uchar_val); break; - case 3: assert.strictEqual(view.getInt16(field_offset, true), short_val); break; - case 4: assert.strictEqual(view.getUint16(field_offset, true), ushort_val); break; - case 5: assert.strictEqual(view.getInt32(field_offset, true), int_val); break; - case 6: assert.strictEqual(view.getUint32(field_offset, true), uint_val); break; - case 7: assert.strictEqual(view.getInt32(field_offset, true), long_val.low); assert.strictEqual(view.getInt32(field_offset + 4, true), long_val.high); break; - case 8: assert.strictEqual(view.getInt32(field_offset, true), ulong_val.low); assert.strictEqual(view.getInt32(field_offset + 4, true), ulong_val.high); break; - case 9: assert.strictEqual(view.getFloat32(field_offset, true), float_val); break; - case 10: assert.strictEqual(view.getFloat64(field_offset, true), double_val); break; - } - } - } -} - -main();
diff --git a/third_party/flatbuffers/tests/JavaScriptTest.sh b/third_party/flatbuffers/tests/JavaScriptTest.sh deleted file mode 100755 index cdba5fa..0000000 --- a/third_party/flatbuffers/tests/JavaScriptTest.sh +++ /dev/null
@@ -1,19 +0,0 @@ -#!/bin/sh -# -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -pushd "$(dirname $0)" >/dev/null -../flatc -b monster_test.fbs unicode_test.json -node JavaScriptTest ./monster_test_generated
diff --git a/third_party/flatbuffers/tests/JavaTest.bat b/third_party/flatbuffers/tests/JavaTest.bat deleted file mode 100755 index aa72613..0000000 --- a/third_party/flatbuffers/tests/JavaTest.bat +++ /dev/null
@@ -1,21 +0,0 @@ -@echo off -rem Copyright 2014 Google Inc. All rights reserved. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -rem Compile then run the Java test. - -set batch_file_dir=%~d0%~p0 - -javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest.java -java -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest
diff --git a/third_party/flatbuffers/tests/JavaTest.java b/third_party/flatbuffers/tests/JavaTest.java deleted file mode 100755 index d53e973..0000000 --- a/third_party/flatbuffers/tests/JavaTest.java +++ /dev/null
@@ -1,358 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.*; -import java.nio.ByteBuffer; -import MyGame.Example.*; -import NamespaceA.*; -import NamespaceA.NamespaceB.*; -import com.google.flatbuffers.FlatBufferBuilder; - -class JavaTest { - public static void main(String[] args) { - - // First, let's test reading a FlatBuffer generated by C++ code: - // This file was generated from monsterdata_test.json - - byte[] data = null; - File file = new File("monsterdata_test.mon"); - RandomAccessFile f = null; - try { - f = new RandomAccessFile(file, "r"); - data = new byte[(int)f.length()]; - f.readFully(data); - f.close(); - } catch(java.io.IOException e) { - System.out.println("FlatBuffers test: couldn't read file"); - return; - } - - // Now test it: - - ByteBuffer bb = ByteBuffer.wrap(data); - TestBuffer(bb); - - // Second, let's create a FlatBuffer from scratch in Java, and test it also. - // We use an initial size of 1 to exercise the reallocation algorithm, - // normally a size larger than the typical FlatBuffer you generate would be - // better for performance. - FlatBufferBuilder fbb = new FlatBufferBuilder(1); - - int[] names = {fbb.createString("Frodo"), fbb.createString("Barney"), fbb.createString("Wilma")}; - int[] off = new int[3]; - Monster.startMonster(fbb); - Monster.addName(fbb, names[0]); - off[0] = Monster.endMonster(fbb); - Monster.startMonster(fbb); - Monster.addName(fbb, names[1]); - off[1] = Monster.endMonster(fbb); - Monster.startMonster(fbb); - Monster.addName(fbb, names[2]); - off[2] = Monster.endMonster(fbb); - int sortMons = fbb.createSortedVectorOfTables(new Monster(), off); - - // We set up the same values as monsterdata.json: - - int str = fbb.createString("MyMonster"); - - int inv = Monster.createInventoryVector(fbb, new byte[] { 0, 1, 2, 3, 4 }); - - int fred = fbb.createString("Fred"); - Monster.startMonster(fbb); - Monster.addName(fbb, fred); - int mon2 = Monster.endMonster(fbb); - - Monster.startTest4Vector(fbb, 2); - Test.createTest(fbb, (short)10, (byte)20); - Test.createTest(fbb, (short)30, (byte)40); - int test4 = fbb.endVector(); - - int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] { - fbb.createString("test1"), - fbb.createString("test2") - }); - - Monster.startMonster(fbb); - Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0, - Color.Green, (short)5, (byte)6)); - Monster.addHp(fbb, (short)80); - Monster.addName(fbb, str); - Monster.addInventory(fbb, inv); - Monster.addTestType(fbb, (byte)Any.Monster); - Monster.addTest(fbb, mon2); - Monster.addTest4(fbb, test4); - Monster.addTestarrayofstring(fbb, testArrayOfString); - Monster.addTestbool(fbb, false); - Monster.addTesthashu32Fnv1(fbb, Integer.MAX_VALUE + 1L); - Monster.addTestarrayoftables(fbb, sortMons); - int mon = Monster.endMonster(fbb); - - Monster.finishMonsterBuffer(fbb, mon); - - // Write the result to a file for debugging purposes: - // Note that the binaries are not necessarily identical, since the JSON - // parser may serialize in a slightly different order than the above - // Java code. They are functionally equivalent though. - - try { - DataOutputStream os = new DataOutputStream(new FileOutputStream( - "monsterdata_java_wire.mon")); - os.write(fbb.dataBuffer().array(), fbb.dataBuffer().position(), fbb.offset()); - os.close(); - } catch(java.io.IOException e) { - System.out.println("FlatBuffers test: couldn't write file"); - return; - } - - // Test it: - TestExtendedBuffer(fbb.dataBuffer()); - - // Make sure it also works with read only ByteBuffers. This is slower, - // since creating strings incurs an additional copy - // (see Table.__string). - TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer()); - - TestEnums(); - - //Attempt to mutate Monster fields and check whether the buffer has been mutated properly - // revert to original values after testing - Monster monster = Monster.getRootAsMonster(fbb.dataBuffer()); - - // mana is optional and does not exist in the buffer so the mutation should fail - // the mana field should retain its default value - TestEq(monster.mutateMana((short)10), false); - TestEq(monster.mana(), (short)150); - - // Accessing a vector of sorted by the key tables - TestEq(monster.testarrayoftables(0).name(), "Barney"); - TestEq(monster.testarrayoftables(1).name(), "Frodo"); - TestEq(monster.testarrayoftables(2).name(), "Wilma"); - - // Example of searching for a table by the key - TestEq(Monster.lookupByKey(sortMons, "Frodo", fbb.dataBuffer()).name(), "Frodo"); - TestEq(Monster.lookupByKey(sortMons, "Barney", fbb.dataBuffer()).name(), "Barney"); - TestEq(Monster.lookupByKey(sortMons, "Wilma", fbb.dataBuffer()).name(), "Wilma"); - - // testType is an existing field and mutating it should succeed - TestEq(monster.testType(), (byte)Any.Monster); - TestEq(monster.mutateTestType(Any.NONE), true); - TestEq(monster.testType(), (byte)Any.NONE); - TestEq(monster.mutateTestType(Any.Monster), true); - TestEq(monster.testType(), (byte)Any.Monster); - - //mutate the inventory vector - TestEq(monster.mutateInventory(0, 1), true); - TestEq(monster.mutateInventory(1, 2), true); - TestEq(monster.mutateInventory(2, 3), true); - TestEq(monster.mutateInventory(3, 4), true); - TestEq(monster.mutateInventory(4, 5), true); - - for (int i = 0; i < monster.inventoryLength(); i++) { - TestEq(monster.inventory(i), i + 1); - } - - //reverse mutation - TestEq(monster.mutateInventory(0, 0), true); - TestEq(monster.mutateInventory(1, 1), true); - TestEq(monster.mutateInventory(2, 2), true); - TestEq(monster.mutateInventory(3, 3), true); - TestEq(monster.mutateInventory(4, 4), true); - - // get a struct field and edit one of its fields - Vec3 pos = monster.pos(); - TestEq(pos.x(), 1.0f); - pos.mutateX(55.0f); - TestEq(pos.x(), 55.0f); - pos.mutateX(1.0f); - TestEq(pos.x(), 1.0f); - - TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer()); - - TestNamespaceNesting(); - - TestNestedFlatBuffer(); - - TestCreateByteVector(); - - TestCreateUninitializedVector(); - - System.out.println("FlatBuffers test: completed successfully"); - } - - static void TestEnums() { - TestEq(Color.name(Color.Red), "Red"); - TestEq(Color.name(Color.Blue), "Blue"); - TestEq(Any.name(Any.NONE), "NONE"); - TestEq(Any.name(Any.Monster), "Monster"); - } - - static void TestBuffer(ByteBuffer bb) { - TestEq(Monster.MonsterBufferHasIdentifier(bb), true); - - Monster monster = Monster.getRootAsMonster(bb); - - TestEq(monster.hp(), (short)80); - TestEq(monster.mana(), (short)150); // default - - TestEq(monster.name(), "MyMonster"); - // monster.friendly() // can't access, deprecated - - Vec3 pos = monster.pos(); - TestEq(pos.x(), 1.0f); - TestEq(pos.y(), 2.0f); - TestEq(pos.z(), 3.0f); - TestEq(pos.test1(), 3.0); - TestEq(pos.test2(), Color.Green); - Test t = pos.test3(); - TestEq(t.a(), (short)5); - TestEq(t.b(), (byte)6); - - TestEq(monster.testType(), (byte)Any.Monster); - Monster monster2 = new Monster(); - TestEq(monster.test(monster2) != null, true); - TestEq(monster2.name(), "Fred"); - - TestEq(monster.inventoryLength(), 5); - int invsum = 0; - for (int i = 0; i < monster.inventoryLength(); i++) - invsum += monster.inventory(i); - TestEq(invsum, 10); - - // Alternative way of accessing a vector: - ByteBuffer ibb = monster.inventoryAsByteBuffer(); - invsum = 0; - while (ibb.position() < ibb.limit()) - invsum += ibb.get(); - TestEq(invsum, 10); - - Test test_0 = monster.test4(0); - Test test_1 = monster.test4(1); - TestEq(monster.test4Length(), 2); - TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100); - - TestEq(monster.testarrayofstringLength(), 2); - TestEq(monster.testarrayofstring(0),"test1"); - TestEq(monster.testarrayofstring(1),"test2"); - - TestEq(monster.testbool(), false); - } - - // this method checks additional fields not present in the binary buffer read from file - // these new tests are performed on top of the regular tests - static void TestExtendedBuffer(ByteBuffer bb) { - TestBuffer(bb); - - Monster monster = Monster.getRootAsMonster(bb); - - TestEq(monster.testhashu32Fnv1(), Integer.MAX_VALUE + 1L); - } - - static void TestNamespaceNesting() { - // reference / manipulate these to verify compilation - FlatBufferBuilder fbb = new FlatBufferBuilder(1); - - TableInNestedNS.startTableInNestedNS(fbb); - TableInNestedNS.addFoo(fbb, 1234); - int nestedTableOff = TableInNestedNS.endTableInNestedNS(fbb); - - TableInFirstNS.startTableInFirstNS(fbb); - TableInFirstNS.addFooTable(fbb, nestedTableOff); - int off = TableInFirstNS.endTableInFirstNS(fbb); - } - - static void TestNestedFlatBuffer() { - final String nestedMonsterName = "NestedMonsterName"; - final short nestedMonsterHp = 600; - final short nestedMonsterMana = 1024; - - FlatBufferBuilder fbb1 = new FlatBufferBuilder(16); - int str1 = fbb1.createString(nestedMonsterName); - Monster.startMonster(fbb1); - Monster.addName(fbb1, str1); - Monster.addHp(fbb1, nestedMonsterHp); - Monster.addMana(fbb1, nestedMonsterMana); - int monster1 = Monster.endMonster(fbb1); - Monster.finishMonsterBuffer(fbb1, monster1); - byte[] fbb1Bytes = fbb1.sizedByteArray(); - fbb1 = null; - - FlatBufferBuilder fbb2 = new FlatBufferBuilder(16); - int str2 = fbb2.createString("My Monster"); - int nestedBuffer = Monster.createTestnestedflatbufferVector(fbb2, fbb1Bytes); - Monster.startMonster(fbb2); - Monster.addName(fbb2, str2); - Monster.addHp(fbb2, (short)50); - Monster.addMana(fbb2, (short)32); - Monster.addTestnestedflatbuffer(fbb2, nestedBuffer); - int monster = Monster.endMonster(fbb2); - Monster.finishMonsterBuffer(fbb2, monster); - - // Now test the data extracted from the nested buffer - Monster mons = Monster.getRootAsMonster(fbb2.dataBuffer()); - Monster nestedMonster = mons.testnestedflatbufferAsMonster(); - - TestEq(nestedMonsterMana, nestedMonster.mana()); - TestEq(nestedMonsterHp, nestedMonster.hp()); - TestEq(nestedMonsterName, nestedMonster.name()); - } - - static void TestCreateByteVector() { - FlatBufferBuilder fbb = new FlatBufferBuilder(16); - int str = fbb.createString("MyMonster"); - byte[] inventory = new byte[] { 0, 1, 2, 3, 4 }; - int vec = fbb.createByteVector(inventory); - Monster.startMonster(fbb); - Monster.addInventory(fbb, vec); - Monster.addName(fbb, str); - int monster1 = Monster.endMonster(fbb); - Monster.finishMonsterBuffer(fbb, monster1); - Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer()); - - TestEq(monsterObject.inventory(1), (int)inventory[1]); - TestEq(monsterObject.inventoryLength(), inventory.length); - TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer()); - } - - static void TestCreateUninitializedVector() { - FlatBufferBuilder fbb = new FlatBufferBuilder(16); - int str = fbb.createString("MyMonster"); - byte[] inventory = new byte[] { 0, 1, 2, 3, 4 }; - ByteBuffer bb = fbb.createUnintializedVector(1, inventory.length, 1); - for (byte i:inventory) { - bb.put(i); - } - int vec = fbb.endVector(); - Monster.startMonster(fbb); - Monster.addInventory(fbb, vec); - Monster.addName(fbb, str); - int monster1 = Monster.endMonster(fbb); - Monster.finishMonsterBuffer(fbb, monster1); - Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer()); - - TestEq(monsterObject.inventory(1), (int)inventory[1]); - TestEq(monsterObject.inventoryLength(), inventory.length); - TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer()); - } - - static <T> void TestEq(T a, T b) { - if (!a.equals(b)) { - System.out.println("" + a.getClass().getName() + " " + b.getClass().getName()); - System.out.println("FlatBuffers test FAILED: \'" + a + "\' != \'" + b + "\'"); - assert false; - System.exit(1); - } - } -}
diff --git a/third_party/flatbuffers/tests/JavaTest.sh b/third_party/flatbuffers/tests/JavaTest.sh deleted file mode 100755 index 40e854b..0000000 --- a/third_party/flatbuffers/tests/JavaTest.sh +++ /dev/null
@@ -1,44 +0,0 @@ -#!/bin/bash -# -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -echo Compile then run the Java test. - -java -version - -testdir=$(readlink -fn `dirname $0`) -thisdir=$(readlink -fn `pwd`) - -targetdir=${testdir}/target - -if [[ "$testdir" != "$thisdir" ]]; then - echo error: must be run from inside the ${testdir} directory - echo you ran it from ${thisdir} - exit 1 -fi - -find .. -type f -name "*.class" -exec rm {} \; - -if [[ -e "${targetdir}" ]]; then - echo "clean target" - rm -rf ${targetdir} -fi - -mkdir ${targetdir} - -javac -d ${targetdir} -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java -java -classpath ${targetdir} JavaTest - -rm -rf ${targetdir}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Ability.cs b/third_party/flatbuffers/tests/MyGame/Example/Ability.cs deleted file mode 100644 index ec08ed8..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Ability.cs +++ /dev/null
@@ -1,30 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -public struct Ability : IFlatbufferObject -{ - private Struct __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public uint Id { get { return __p.bb.GetUint(__p.bb_pos + 0); } } - public void MutateId(uint id) { __p.bb.PutUint(__p.bb_pos + 0, id); } - public uint Distance { get { return __p.bb.GetUint(__p.bb_pos + 4); } } - public void MutateDistance(uint distance) { __p.bb.PutUint(__p.bb_pos + 4, distance); } - - public static Offset<Ability> CreateAbility(FlatBufferBuilder builder, uint Id, uint Distance) { - builder.Prep(4, 8); - builder.PutUint(Distance); - builder.PutUint(Id); - return new Offset<Ability>(builder.Offset); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Ability.go b/third_party/flatbuffers/tests/MyGame/Example/Ability.go deleted file mode 100644 index 2ea8665..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Ability.go +++ /dev/null
@@ -1,41 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Ability struct { - _tab flatbuffers.Struct -} - -func (rcv *Ability) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Ability) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *Ability) Id() uint32 { - return rcv._tab.GetUint32(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *Ability) MutateId(n uint32) bool { - return rcv._tab.MutateUint32(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *Ability) Distance() uint32 { - return rcv._tab.GetUint32(rcv._tab.Pos + flatbuffers.UOffsetT(4)) -} -func (rcv *Ability) MutateDistance(n uint32) bool { - return rcv._tab.MutateUint32(rcv._tab.Pos+flatbuffers.UOffsetT(4), n) -} - -func CreateAbility(builder *flatbuffers.Builder, id uint32, distance uint32) flatbuffers.UOffsetT { - builder.Prep(4, 8) - builder.PrependUint32(distance) - builder.PrependUint32(id) - return builder.Offset() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Ability.java b/third_party/flatbuffers/tests/MyGame/Example/Ability.java deleted file mode 100644 index 5e1c90e..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Ability.java +++ /dev/null
@@ -1,27 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class Ability extends Struct { - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public long id() { return (long)bb.getInt(bb_pos + 0) & 0xFFFFFFFFL; } - public void mutateId(long id) { bb.putInt(bb_pos + 0, (int)id); } - public long distance() { return (long)bb.getInt(bb_pos + 4) & 0xFFFFFFFFL; } - public void mutateDistance(long distance) { bb.putInt(bb_pos + 4, (int)distance); } - - public static int createAbility(FlatBufferBuilder builder, long id, long distance) { - builder.prep(4, 8); - builder.putInt((int)distance); - builder.putInt((int)id); - return builder.offset(); - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Ability.php b/third_party/flatbuffers/tests/MyGame/Example/Ability.php deleted file mode 100644 index c09eca3..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Ability.php +++ /dev/null
@@ -1,52 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class Ability extends Struct -{ - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Ability - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return uint - */ - public function GetId() - { - return $this->bb->getUint($this->bb_pos + 0); - } - - /** - * @return uint - */ - public function GetDistance() - { - return $this->bb->getUint($this->bb_pos + 4); - } - - - /** - * @return int offset - */ - public static function createAbility(FlatBufferBuilder $builder, $id, $distance) - { - $builder->prep(4, 8); - $builder->putUint($distance); - $builder->putUint($id); - return $builder->offset(); - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Ability.py b/third_party/flatbuffers/tests/MyGame/Example/Ability.py deleted file mode 100644 index 3c4776e..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Ability.py +++ /dev/null
@@ -1,23 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -class Ability(object): - __slots__ = ['_tab'] - - # Ability - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Ability - def Id(self): return self._tab.Get(flatbuffers.number_types.Uint32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)) - # Ability - def Distance(self): return self._tab.Get(flatbuffers.number_types.Uint32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4)) - -def CreateAbility(builder, id, distance): - builder.Prep(4, 8) - builder.PrependUint32(distance) - builder.PrependUint32(id) - return builder.Offset()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Any.cs b/third_party/flatbuffers/tests/MyGame/Example/Any.cs deleted file mode 100644 index 8fdc2fc..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Any.cs +++ /dev/null
@@ -1,15 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -public enum Any : byte -{ - NONE = 0, - Monster = 1, - TestSimpleTableWithEnum = 2, - MyGame_Example2_Monster = 3, -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Any.go b/third_party/flatbuffers/tests/MyGame/Example/Any.go deleted file mode 100644 index d69b141..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Any.go +++ /dev/null
@@ -1,18 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -const ( - AnyNONE = 0 - AnyMonster = 1 - AnyTestSimpleTableWithEnum = 2 - AnyMyGame_Example2_Monster = 3 -) - -var EnumNamesAny = map[int]string{ - AnyNONE:"NONE", - AnyMonster:"Monster", - AnyTestSimpleTableWithEnum:"TestSimpleTableWithEnum", - AnyMyGame_Example2_Monster:"MyGame_Example2_Monster", -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Any.java b/third_party/flatbuffers/tests/MyGame/Example/Any.java deleted file mode 100644 index 6e4fb76..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Any.java +++ /dev/null
@@ -1,16 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -public final class Any { - private Any() { } - public static final byte NONE = 0; - public static final byte Monster = 1; - public static final byte TestSimpleTableWithEnum = 2; - public static final byte MyGame_Example2_Monster = 3; - - public static final String[] names = { "NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster", }; - - public static String name(int e) { return names[e]; } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Any.php b/third_party/flatbuffers/tests/MyGame/Example/Any.php deleted file mode 100644 index da69176..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Any.php +++ /dev/null
@@ -1,27 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -class Any -{ - const NONE = 0; - const Monster = 1; - const TestSimpleTableWithEnum = 2; - const MyGame_Example2_Monster = 3; - - private static $names = array( - "NONE", - "Monster", - "TestSimpleTableWithEnum", - "MyGame_Example2_Monster", - ); - - public static function Name($e) - { - if (!isset(self::$names[$e])) { - throw new \Exception(); - } - return self::$names[$e]; - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Any.py b/third_party/flatbuffers/tests/MyGame/Example/Any.py deleted file mode 100644 index f1b8d51..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Any.py +++ /dev/null
@@ -1,10 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -class Any(object): - NONE = 0 - Monster = 1 - TestSimpleTableWithEnum = 2 - MyGame_Example2_Monster = 3 -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Color.cs b/third_party/flatbuffers/tests/MyGame/Example/Color.cs deleted file mode 100644 index 625d040..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Color.cs +++ /dev/null
@@ -1,14 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -public enum Color : sbyte -{ - Red = 1, - Green = 2, - Blue = 8, -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Color.go b/third_party/flatbuffers/tests/MyGame/Example/Color.go deleted file mode 100644 index d1eac54..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Color.go +++ /dev/null
@@ -1,16 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -const ( - ColorRed = 1 - ColorGreen = 2 - ColorBlue = 8 -) - -var EnumNamesColor = map[int]string{ - ColorRed:"Red", - ColorGreen:"Green", - ColorBlue:"Blue", -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Color.java b/third_party/flatbuffers/tests/MyGame/Example/Color.java deleted file mode 100644 index 7c113b7..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Color.java +++ /dev/null
@@ -1,15 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -public final class Color { - private Color() { } - public static final byte Red = 1; - public static final byte Green = 2; - public static final byte Blue = 8; - - public static final String[] names = { "Red", "Green", "", "", "", "", "", "Blue", }; - - public static String name(int e) { return names[e - Red]; } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Color.php b/third_party/flatbuffers/tests/MyGame/Example/Color.php deleted file mode 100644 index 70c7bfd..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Color.php +++ /dev/null
@@ -1,25 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -class Color -{ - const Red = 1; - const Green = 2; - const Blue = 8; - - private static $names = array( - "Red", - "Green", - "Blue", - ); - - public static function Name($e) - { - if (!isset(self::$names[$e])) { - throw new \Exception(); - } - return self::$names[$e]; - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Color.py b/third_party/flatbuffers/tests/MyGame/Example/Color.py deleted file mode 100644 index 36e80a3..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Color.py +++ /dev/null
@@ -1,9 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -class Color(object): - Red = 1 - Green = 2 - Blue = 8 -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Monster.cs b/third_party/flatbuffers/tests/MyGame/Example/Monster.cs deleted file mode 100644 index 8f76cfd..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Monster.cs +++ /dev/null
@@ -1,165 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -/// an example documentation comment: monster object -public struct Monster : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); } - public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public static bool MonsterBufferHasIdentifier(ByteBuffer _bb) { return Table.__has_identifier(_bb, "MONS"); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public Vec3? Pos { get { int o = __p.__offset(4); return o != 0 ? (Vec3?)(new Vec3()).__assign(o + __p.bb_pos, __p.bb) : null; } } - public short Mana { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetShort(o + __p.bb_pos) : (short)150; } } - public bool MutateMana(short mana) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutShort(o + __p.bb_pos, mana); return true; } else { return false; } } - public short Hp { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetShort(o + __p.bb_pos) : (short)100; } } - public bool MutateHp(short hp) { int o = __p.__offset(8); if (o != 0) { __p.bb.PutShort(o + __p.bb_pos, hp); return true; } else { return false; } } - public string Name { get { int o = __p.__offset(10); return o != 0 ? __p.__string(o + __p.bb_pos) : null; } } - public ArraySegment<byte>? GetNameBytes() { return __p.__vector_as_arraysegment(10); } - public byte Inventory(int j) { int o = __p.__offset(14); return o != 0 ? __p.bb.Get(__p.__vector(o) + j * 1) : (byte)0; } - public int InventoryLength { get { int o = __p.__offset(14); return o != 0 ? __p.__vector_len(o) : 0; } } - public ArraySegment<byte>? GetInventoryBytes() { return __p.__vector_as_arraysegment(14); } - public bool MutateInventory(int j, byte inventory) { int o = __p.__offset(14); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, inventory); return true; } else { return false; } } - public Color Color { get { int o = __p.__offset(16); return o != 0 ? (Color)__p.bb.GetSbyte(o + __p.bb_pos) : Color.Blue; } } - public bool MutateColor(Color color) { int o = __p.__offset(16); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)color); return true; } else { return false; } } - public Any TestType { get { int o = __p.__offset(18); return o != 0 ? (Any)__p.bb.Get(o + __p.bb_pos) : Any.NONE; } } - public bool MutateTestType(Any test_type) { int o = __p.__offset(18); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)test_type); return true; } else { return false; } } - public TTable? Test<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(20); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; } - public Test? Test4(int j) { int o = __p.__offset(22); return o != 0 ? (Test?)(new Test()).__assign(__p.__vector(o) + j * 4, __p.bb) : null; } - public int Test4Length { get { int o = __p.__offset(22); return o != 0 ? __p.__vector_len(o) : 0; } } - public string Testarrayofstring(int j) { int o = __p.__offset(24); return o != 0 ? __p.__string(__p.__vector(o) + j * 4) : null; } - public int TestarrayofstringLength { get { int o = __p.__offset(24); return o != 0 ? __p.__vector_len(o) : 0; } } - /// an example documentation comment: this will end up in the generated code - /// multiline too - public Monster? Testarrayoftables(int j) { int o = __p.__offset(26); return o != 0 ? (Monster?)(new Monster()).__assign(__p.__indirect(__p.__vector(o) + j * 4), __p.bb) : null; } - public int TestarrayoftablesLength { get { int o = __p.__offset(26); return o != 0 ? __p.__vector_len(o) : 0; } } - public Monster? Enemy { get { int o = __p.__offset(28); return o != 0 ? (Monster?)(new Monster()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - public byte Testnestedflatbuffer(int j) { int o = __p.__offset(30); return o != 0 ? __p.bb.Get(__p.__vector(o) + j * 1) : (byte)0; } - public int TestnestedflatbufferLength { get { int o = __p.__offset(30); return o != 0 ? __p.__vector_len(o) : 0; } } - public ArraySegment<byte>? GetTestnestedflatbufferBytes() { return __p.__vector_as_arraysegment(30); } - public Monster? GetTestnestedflatbufferAsMonster() { int o = __p.__offset(30); return o != 0 ? (Monster?)(new Monster()).__assign(__p.__indirect(__p.__vector(o)), __p.bb) : null; } - public bool MutateTestnestedflatbuffer(int j, byte testnestedflatbuffer) { int o = __p.__offset(30); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, testnestedflatbuffer); return true; } else { return false; } } - public Stat? Testempty { get { int o = __p.__offset(32); return o != 0 ? (Stat?)(new Stat()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - public bool Testbool { get { int o = __p.__offset(34); return o != 0 ? 0!=__p.bb.Get(o + __p.bb_pos) : (bool)false; } } - public bool MutateTestbool(bool testbool) { int o = __p.__offset(34); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)(testbool ? 1 : 0)); return true; } else { return false; } } - public int Testhashs32Fnv1 { get { int o = __p.__offset(36); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } } - public bool MutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __p.__offset(36); if (o != 0) { __p.bb.PutInt(o + __p.bb_pos, testhashs32_fnv1); return true; } else { return false; } } - public uint Testhashu32Fnv1 { get { int o = __p.__offset(38); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } } - public bool MutateTesthashu32Fnv1(uint testhashu32_fnv1) { int o = __p.__offset(38); if (o != 0) { __p.bb.PutUint(o + __p.bb_pos, testhashu32_fnv1); return true; } else { return false; } } - public long Testhashs64Fnv1 { get { int o = __p.__offset(40); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } } - public bool MutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __p.__offset(40); if (o != 0) { __p.bb.PutLong(o + __p.bb_pos, testhashs64_fnv1); return true; } else { return false; } } - public ulong Testhashu64Fnv1 { get { int o = __p.__offset(42); return o != 0 ? __p.bb.GetUlong(o + __p.bb_pos) : (ulong)0; } } - public bool MutateTesthashu64Fnv1(ulong testhashu64_fnv1) { int o = __p.__offset(42); if (o != 0) { __p.bb.PutUlong(o + __p.bb_pos, testhashu64_fnv1); return true; } else { return false; } } - public int Testhashs32Fnv1a { get { int o = __p.__offset(44); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } } - public bool MutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __p.__offset(44); if (o != 0) { __p.bb.PutInt(o + __p.bb_pos, testhashs32_fnv1a); return true; } else { return false; } } - public uint Testhashu32Fnv1a { get { int o = __p.__offset(46); return o != 0 ? __p.bb.GetUint(o + __p.bb_pos) : (uint)0; } } - public bool MutateTesthashu32Fnv1a(uint testhashu32_fnv1a) { int o = __p.__offset(46); if (o != 0) { __p.bb.PutUint(o + __p.bb_pos, testhashu32_fnv1a); return true; } else { return false; } } - public long Testhashs64Fnv1a { get { int o = __p.__offset(48); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } } - public bool MutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __p.__offset(48); if (o != 0) { __p.bb.PutLong(o + __p.bb_pos, testhashs64_fnv1a); return true; } else { return false; } } - public ulong Testhashu64Fnv1a { get { int o = __p.__offset(50); return o != 0 ? __p.bb.GetUlong(o + __p.bb_pos) : (ulong)0; } } - public bool MutateTesthashu64Fnv1a(ulong testhashu64_fnv1a) { int o = __p.__offset(50); if (o != 0) { __p.bb.PutUlong(o + __p.bb_pos, testhashu64_fnv1a); return true; } else { return false; } } - public bool Testarrayofbools(int j) { int o = __p.__offset(52); return o != 0 ? 0!=__p.bb.Get(__p.__vector(o) + j * 1) : false; } - public int TestarrayofboolsLength { get { int o = __p.__offset(52); return o != 0 ? __p.__vector_len(o) : 0; } } - public ArraySegment<byte>? GetTestarrayofboolsBytes() { return __p.__vector_as_arraysegment(52); } - public bool MutateTestarrayofbools(int j, bool testarrayofbools) { int o = __p.__offset(52); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, (byte)(testarrayofbools ? 1 : 0)); return true; } else { return false; } } - public float Testf { get { int o = __p.__offset(54); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)3.14159f; } } - public bool MutateTestf(float testf) { int o = __p.__offset(54); if (o != 0) { __p.bb.PutFloat(o + __p.bb_pos, testf); return true; } else { return false; } } - public float Testf2 { get { int o = __p.__offset(56); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)3.0f; } } - public bool MutateTestf2(float testf2) { int o = __p.__offset(56); if (o != 0) { __p.bb.PutFloat(o + __p.bb_pos, testf2); return true; } else { return false; } } - public float Testf3 { get { int o = __p.__offset(58); return o != 0 ? __p.bb.GetFloat(o + __p.bb_pos) : (float)0.0f; } } - public bool MutateTestf3(float testf3) { int o = __p.__offset(58); if (o != 0) { __p.bb.PutFloat(o + __p.bb_pos, testf3); return true; } else { return false; } } - public string Testarrayofstring2(int j) { int o = __p.__offset(60); return o != 0 ? __p.__string(__p.__vector(o) + j * 4) : null; } - public int Testarrayofstring2Length { get { int o = __p.__offset(60); return o != 0 ? __p.__vector_len(o) : 0; } } - public Ability? Testarrayofsortedstruct(int j) { int o = __p.__offset(62); return o != 0 ? (Ability?)(new Ability()).__assign(__p.__vector(o) + j * 8, __p.bb) : null; } - public int TestarrayofsortedstructLength { get { int o = __p.__offset(62); return o != 0 ? __p.__vector_len(o) : 0; } } - - public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(30); } - public static void AddPos(FlatBufferBuilder builder, Offset<Vec3> posOffset) { builder.AddStruct(0, posOffset.Value, 0); } - public static void AddMana(FlatBufferBuilder builder, short mana) { builder.AddShort(1, mana, 150); } - public static void AddHp(FlatBufferBuilder builder, short hp) { builder.AddShort(2, hp, 100); } - public static void AddName(FlatBufferBuilder builder, StringOffset nameOffset) { builder.AddOffset(3, nameOffset.Value, 0); } - public static void AddInventory(FlatBufferBuilder builder, VectorOffset inventoryOffset) { builder.AddOffset(5, inventoryOffset.Value, 0); } - public static VectorOffset CreateInventoryVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); } - public static void StartInventoryVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); } - public static void AddColor(FlatBufferBuilder builder, Color color) { builder.AddSbyte(6, (sbyte)color, 8); } - public static void AddTestType(FlatBufferBuilder builder, Any testType) { builder.AddByte(7, (byte)testType, 0); } - public static void AddTest(FlatBufferBuilder builder, int testOffset) { builder.AddOffset(8, testOffset, 0); } - public static void AddTest4(FlatBufferBuilder builder, VectorOffset test4Offset) { builder.AddOffset(9, test4Offset.Value, 0); } - public static void StartTest4Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 2); } - public static void AddTestarrayofstring(FlatBufferBuilder builder, VectorOffset testarrayofstringOffset) { builder.AddOffset(10, testarrayofstringOffset.Value, 0); } - public static VectorOffset CreateTestarrayofstringVector(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); } - public static void StartTestarrayofstringVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); } - public static void AddTestarrayoftables(FlatBufferBuilder builder, VectorOffset testarrayoftablesOffset) { builder.AddOffset(11, testarrayoftablesOffset.Value, 0); } - public static VectorOffset CreateTestarrayoftablesVector(FlatBufferBuilder builder, Offset<Monster>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); } - public static void StartTestarrayoftablesVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); } - public static void AddEnemy(FlatBufferBuilder builder, Offset<Monster> enemyOffset) { builder.AddOffset(12, enemyOffset.Value, 0); } - public static void AddTestnestedflatbuffer(FlatBufferBuilder builder, VectorOffset testnestedflatbufferOffset) { builder.AddOffset(13, testnestedflatbufferOffset.Value, 0); } - public static VectorOffset CreateTestnestedflatbufferVector(FlatBufferBuilder builder, byte[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddByte(data[i]); return builder.EndVector(); } - public static void StartTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); } - public static void AddTestempty(FlatBufferBuilder builder, Offset<Stat> testemptyOffset) { builder.AddOffset(14, testemptyOffset.Value, 0); } - public static void AddTestbool(FlatBufferBuilder builder, bool testbool) { builder.AddBool(15, testbool, false); } - public static void AddTesthashs32Fnv1(FlatBufferBuilder builder, int testhashs32Fnv1) { builder.AddInt(16, testhashs32Fnv1, 0); } - public static void AddTesthashu32Fnv1(FlatBufferBuilder builder, uint testhashu32Fnv1) { builder.AddUint(17, testhashu32Fnv1, 0); } - public static void AddTesthashs64Fnv1(FlatBufferBuilder builder, long testhashs64Fnv1) { builder.AddLong(18, testhashs64Fnv1, 0); } - public static void AddTesthashu64Fnv1(FlatBufferBuilder builder, ulong testhashu64Fnv1) { builder.AddUlong(19, testhashu64Fnv1, 0); } - public static void AddTesthashs32Fnv1a(FlatBufferBuilder builder, int testhashs32Fnv1a) { builder.AddInt(20, testhashs32Fnv1a, 0); } - public static void AddTesthashu32Fnv1a(FlatBufferBuilder builder, uint testhashu32Fnv1a) { builder.AddUint(21, testhashu32Fnv1a, 0); } - public static void AddTesthashs64Fnv1a(FlatBufferBuilder builder, long testhashs64Fnv1a) { builder.AddLong(22, testhashs64Fnv1a, 0); } - public static void AddTesthashu64Fnv1a(FlatBufferBuilder builder, ulong testhashu64Fnv1a) { builder.AddUlong(23, testhashu64Fnv1a, 0); } - public static void AddTestarrayofbools(FlatBufferBuilder builder, VectorOffset testarrayofboolsOffset) { builder.AddOffset(24, testarrayofboolsOffset.Value, 0); } - public static VectorOffset CreateTestarrayofboolsVector(FlatBufferBuilder builder, bool[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddBool(data[i]); return builder.EndVector(); } - public static void StartTestarrayofboolsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); } - public static void AddTestf(FlatBufferBuilder builder, float testf) { builder.AddFloat(25, testf, 3.14159f); } - public static void AddTestf2(FlatBufferBuilder builder, float testf2) { builder.AddFloat(26, testf2, 3.0f); } - public static void AddTestf3(FlatBufferBuilder builder, float testf3) { builder.AddFloat(27, testf3, 0.0f); } - public static void AddTestarrayofstring2(FlatBufferBuilder builder, VectorOffset testarrayofstring2Offset) { builder.AddOffset(28, testarrayofstring2Offset.Value, 0); } - public static VectorOffset CreateTestarrayofstring2Vector(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); } - public static void StartTestarrayofstring2Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); } - public static void AddTestarrayofsortedstruct(FlatBufferBuilder builder, VectorOffset testarrayofsortedstructOffset) { builder.AddOffset(29, testarrayofsortedstructOffset.Value, 0); } - public static void StartTestarrayofsortedstructVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(8, numElems, 4); } - public static Offset<Monster> EndMonster(FlatBufferBuilder builder) { - int o = builder.EndObject(); - builder.Required(o, 10); // name - return new Offset<Monster>(o); - } - public static void FinishMonsterBuffer(FlatBufferBuilder builder, Offset<Monster> offset) { builder.Finish(offset.Value, "MONS"); } - - public static VectorOffset CreateMySortedVectorOfTables(FlatBufferBuilder builder, Offset<Monster>[] offsets) { - Array.Sort(offsets, (Offset<Monster> o1, Offset<Monster> o2) => Table.CompareStrings(Table.__offset(10, o1.Value, builder.DataBuffer), Table.__offset(10, o2.Value, builder.DataBuffer), builder.DataBuffer)); - return builder.CreateVectorOfTables(offsets); - } - - public static Monster? LookupByKey(VectorOffset vectorOffset, string key, ByteBuffer bb) { - byte[] byteKey = System.Text.Encoding.UTF8.GetBytes(key); - int vectorLocation = bb.Length - vectorOffset.Value; - int span = bb.GetInt(vectorLocation); - int start = 0; - vectorLocation += 4; - while (span != 0) { - int middle = span / 2; - int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb); - int comp = Table.CompareStrings(Table.__offset(10, bb.Length - tableOffset, bb), byteKey, bb); - if (comp > 0) { - span = middle; - } else if (comp < 0) { - middle++; - start += middle; - span -= middle; - } else { - return new Monster().__assign(tableOffset, bb); - } - } - return null; - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Monster.go b/third_party/flatbuffers/tests/MyGame/Example/Monster.go deleted file mode 100644 index ba2e60d..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Monster.go +++ /dev/null
@@ -1,557 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -/// an example documentation comment: monster object -type Monster struct { - _tab flatbuffers.Table -} - -func GetRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Monster{} - x.Init(buf, n+offset) - return x -} - -func (rcv *Monster) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Monster) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Monster) Pos(obj *Vec3) *Vec3 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := o + rcv._tab.Pos - if obj == nil { - obj = new(Vec3) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *Monster) Mana() int16 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) - } - return 150 -} - -func (rcv *Monster) MutateMana(n int16) bool { - return rcv._tab.MutateInt16Slot(6, n) -} - -func (rcv *Monster) Hp() int16 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.GetInt16(o + rcv._tab.Pos) - } - return 100 -} - -func (rcv *Monster) MutateHp(n int16) bool { - return rcv._tab.MutateInt16Slot(8, n) -} - -func (rcv *Monster) Name() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Monster) Inventory(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Monster) InventoryLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Monster) InventoryBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(14)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Monster) Color() int8 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(16)) - if o != 0 { - return rcv._tab.GetInt8(o + rcv._tab.Pos) - } - return 8 -} - -func (rcv *Monster) MutateColor(n int8) bool { - return rcv._tab.MutateInt8Slot(16, n) -} - -func (rcv *Monster) TestType() byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(18)) - if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTestType(n byte) bool { - return rcv._tab.MutateByteSlot(18, n) -} - -func (rcv *Monster) Test(obj *flatbuffers.Table) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(20)) - if o != 0 { - rcv._tab.Union(obj, o) - return true - } - return false -} - -func (rcv *Monster) Test4(obj *Test, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(22)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Monster) Test4Length() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(22)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Monster) Testarrayofstring(j int) []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(24)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.ByteVector(a + flatbuffers.UOffsetT(j*4)) - } - return nil -} - -func (rcv *Monster) TestarrayofstringLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(24)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -/// an example documentation comment: this will end up in the generated code -/// multiline too -func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(26)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Monster) TestarrayoftablesLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(26)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -/// an example documentation comment: this will end up in the generated code -/// multiline too -func (rcv *Monster) Enemy(obj *Monster) *Monster { - o := flatbuffers.UOffsetT(rcv._tab.Offset(28)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(Monster) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *Monster) Testnestedflatbuffer(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(30)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Monster) TestnestedflatbufferLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(30)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Monster) TestnestedflatbufferBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(30)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Monster) Testempty(obj *Stat) *Stat { - o := flatbuffers.UOffsetT(rcv._tab.Offset(32)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(Stat) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *Monster) Testbool() byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(34)) - if o != 0 { - return rcv._tab.GetByte(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTestbool(n byte) bool { - return rcv._tab.MutateByteSlot(34, n) -} - -func (rcv *Monster) Testhashs32Fnv1() int32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(36)) - if o != 0 { - return rcv._tab.GetInt32(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashs32Fnv1(n int32) bool { - return rcv._tab.MutateInt32Slot(36, n) -} - -func (rcv *Monster) Testhashu32Fnv1() uint32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(38)) - if o != 0 { - return rcv._tab.GetUint32(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashu32Fnv1(n uint32) bool { - return rcv._tab.MutateUint32Slot(38, n) -} - -func (rcv *Monster) Testhashs64Fnv1() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(40)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashs64Fnv1(n int64) bool { - return rcv._tab.MutateInt64Slot(40, n) -} - -func (rcv *Monster) Testhashu64Fnv1() uint64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(42)) - if o != 0 { - return rcv._tab.GetUint64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashu64Fnv1(n uint64) bool { - return rcv._tab.MutateUint64Slot(42, n) -} - -func (rcv *Monster) Testhashs32Fnv1a() int32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(44)) - if o != 0 { - return rcv._tab.GetInt32(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashs32Fnv1a(n int32) bool { - return rcv._tab.MutateInt32Slot(44, n) -} - -func (rcv *Monster) Testhashu32Fnv1a() uint32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(46)) - if o != 0 { - return rcv._tab.GetUint32(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashu32Fnv1a(n uint32) bool { - return rcv._tab.MutateUint32Slot(46, n) -} - -func (rcv *Monster) Testhashs64Fnv1a() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(48)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashs64Fnv1a(n int64) bool { - return rcv._tab.MutateInt64Slot(48, n) -} - -func (rcv *Monster) Testhashu64Fnv1a() uint64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(50)) - if o != 0 { - return rcv._tab.GetUint64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Monster) MutateTesthashu64Fnv1a(n uint64) bool { - return rcv._tab.MutateUint64Slot(50, n) -} - -func (rcv *Monster) Testarrayofbools(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(52)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Monster) TestarrayofboolsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(52)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Monster) Testf() float32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(54)) - if o != 0 { - return rcv._tab.GetFloat32(o + rcv._tab.Pos) - } - return 3.14159 -} - -func (rcv *Monster) MutateTestf(n float32) bool { - return rcv._tab.MutateFloat32Slot(54, n) -} - -func (rcv *Monster) Testf2() float32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(56)) - if o != 0 { - return rcv._tab.GetFloat32(o + rcv._tab.Pos) - } - return 3.0 -} - -func (rcv *Monster) MutateTestf2(n float32) bool { - return rcv._tab.MutateFloat32Slot(56, n) -} - -func (rcv *Monster) Testf3() float32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(58)) - if o != 0 { - return rcv._tab.GetFloat32(o + rcv._tab.Pos) - } - return 0.0 -} - -func (rcv *Monster) MutateTestf3(n float32) bool { - return rcv._tab.MutateFloat32Slot(58, n) -} - -func (rcv *Monster) Testarrayofstring2(j int) []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(60)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.ByteVector(a + flatbuffers.UOffsetT(j*4)) - } - return nil -} - -func (rcv *Monster) Testarrayofstring2Length() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(60)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Monster) Testarrayofsortedstruct(obj *Ability, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(62)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 8 - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Monster) TestarrayofsortedstructLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(62)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func MonsterStart(builder *flatbuffers.Builder) { - builder.StartObject(30) -} -func MonsterAddPos(builder *flatbuffers.Builder, pos flatbuffers.UOffsetT) { - builder.PrependStructSlot(0, flatbuffers.UOffsetT(pos), 0) -} -func MonsterAddMana(builder *flatbuffers.Builder, mana int16) { - builder.PrependInt16Slot(1, mana, 150) -} -func MonsterAddHp(builder *flatbuffers.Builder, hp int16) { - builder.PrependInt16Slot(2, hp, 100) -} -func MonsterAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(name), 0) -} -func MonsterAddInventory(builder *flatbuffers.Builder, inventory flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(5, flatbuffers.UOffsetT(inventory), 0) -} -func MonsterStartInventoryVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func MonsterAddColor(builder *flatbuffers.Builder, color int8) { - builder.PrependInt8Slot(6, color, 8) -} -func MonsterAddTestType(builder *flatbuffers.Builder, testType byte) { - builder.PrependByteSlot(7, testType, 0) -} -func MonsterAddTest(builder *flatbuffers.Builder, test flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(8, flatbuffers.UOffsetT(test), 0) -} -func MonsterAddTest4(builder *flatbuffers.Builder, test4 flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(9, flatbuffers.UOffsetT(test4), 0) -} -func MonsterStartTest4Vector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 2) -} -func MonsterAddTestarrayofstring(builder *flatbuffers.Builder, testarrayofstring flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(10, flatbuffers.UOffsetT(testarrayofstring), 0) -} -func MonsterStartTestarrayofstringVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func MonsterAddTestarrayoftables(builder *flatbuffers.Builder, testarrayoftables flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(11, flatbuffers.UOffsetT(testarrayoftables), 0) -} -func MonsterStartTestarrayoftablesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func MonsterAddEnemy(builder *flatbuffers.Builder, enemy flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(12, flatbuffers.UOffsetT(enemy), 0) -} -func MonsterAddTestnestedflatbuffer(builder *flatbuffers.Builder, testnestedflatbuffer flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(13, flatbuffers.UOffsetT(testnestedflatbuffer), 0) -} -func MonsterStartTestnestedflatbufferVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func MonsterAddTestempty(builder *flatbuffers.Builder, testempty flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(14, flatbuffers.UOffsetT(testempty), 0) -} -func MonsterAddTestbool(builder *flatbuffers.Builder, testbool byte) { - builder.PrependByteSlot(15, testbool, 0) -} -func MonsterAddTesthashs32Fnv1(builder *flatbuffers.Builder, testhashs32Fnv1 int32) { - builder.PrependInt32Slot(16, testhashs32Fnv1, 0) -} -func MonsterAddTesthashu32Fnv1(builder *flatbuffers.Builder, testhashu32Fnv1 uint32) { - builder.PrependUint32Slot(17, testhashu32Fnv1, 0) -} -func MonsterAddTesthashs64Fnv1(builder *flatbuffers.Builder, testhashs64Fnv1 int64) { - builder.PrependInt64Slot(18, testhashs64Fnv1, 0) -} -func MonsterAddTesthashu64Fnv1(builder *flatbuffers.Builder, testhashu64Fnv1 uint64) { - builder.PrependUint64Slot(19, testhashu64Fnv1, 0) -} -func MonsterAddTesthashs32Fnv1a(builder *flatbuffers.Builder, testhashs32Fnv1a int32) { - builder.PrependInt32Slot(20, testhashs32Fnv1a, 0) -} -func MonsterAddTesthashu32Fnv1a(builder *flatbuffers.Builder, testhashu32Fnv1a uint32) { - builder.PrependUint32Slot(21, testhashu32Fnv1a, 0) -} -func MonsterAddTesthashs64Fnv1a(builder *flatbuffers.Builder, testhashs64Fnv1a int64) { - builder.PrependInt64Slot(22, testhashs64Fnv1a, 0) -} -func MonsterAddTesthashu64Fnv1a(builder *flatbuffers.Builder, testhashu64Fnv1a uint64) { - builder.PrependUint64Slot(23, testhashu64Fnv1a, 0) -} -func MonsterAddTestarrayofbools(builder *flatbuffers.Builder, testarrayofbools flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(24, flatbuffers.UOffsetT(testarrayofbools), 0) -} -func MonsterStartTestarrayofboolsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func MonsterAddTestf(builder *flatbuffers.Builder, testf float32) { - builder.PrependFloat32Slot(25, testf, 3.14159) -} -func MonsterAddTestf2(builder *flatbuffers.Builder, testf2 float32) { - builder.PrependFloat32Slot(26, testf2, 3.0) -} -func MonsterAddTestf3(builder *flatbuffers.Builder, testf3 float32) { - builder.PrependFloat32Slot(27, testf3, 0.0) -} -func MonsterAddTestarrayofstring2(builder *flatbuffers.Builder, testarrayofstring2 flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(28, flatbuffers.UOffsetT(testarrayofstring2), 0) -} -func MonsterStartTestarrayofstring2Vector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func MonsterAddTestarrayofsortedstruct(builder *flatbuffers.Builder, testarrayofsortedstruct flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(29, flatbuffers.UOffsetT(testarrayofsortedstruct), 0) -} -func MonsterStartTestarrayofsortedstructVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(8, numElems, 4) -} -func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Monster.java b/third_party/flatbuffers/tests/MyGame/Example/Monster.java deleted file mode 100644 index 5bde80a..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Monster.java +++ /dev/null
@@ -1,171 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -/** - * an example documentation comment: monster object - */ -public final class Monster extends Table { - public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); } - public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public Vec3 pos() { return pos(new Vec3()); } - public Vec3 pos(Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; } - public short mana() { int o = __offset(6); return o != 0 ? bb.getShort(o + bb_pos) : 150; } - public boolean mutateMana(short mana) { int o = __offset(6); if (o != 0) { bb.putShort(o + bb_pos, mana); return true; } else { return false; } } - public short hp() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) : 100; } - public boolean mutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, hp); return true; } else { return false; } } - public String name() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); } - public int inventory(int j) { int o = __offset(14); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; } - public int inventoryLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; } - public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); } - public boolean mutateInventory(int j, int inventory) { int o = __offset(14); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)inventory); return true; } else { return false; } } - public byte color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) : 8; } - public boolean mutateColor(byte color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, color); return true; } else { return false; } } - public byte testType() { int o = __offset(18); return o != 0 ? bb.get(o + bb_pos) : 0; } - public boolean mutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.put(o + bb_pos, test_type); return true; } else { return false; } } - public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o) : null; } - public Test test4(int j) { return test4(new Test(), j); } - public Test test4(Test obj, int j) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o) + j * 4, bb) : null; } - public int test4Length() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; } - public String testarrayofstring(int j) { int o = __offset(24); return o != 0 ? __string(__vector(o) + j * 4) : null; } - public int testarrayofstringLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; } - /** - * an example documentation comment: this will end up in the generated code - * multiline too - */ - public Monster testarrayoftables(int j) { return testarrayoftables(new Monster(), j); } - public Monster testarrayoftables(Monster obj, int j) { int o = __offset(26); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; } - public int testarrayoftablesLength() { int o = __offset(26); return o != 0 ? __vector_len(o) : 0; } - public Monster enemy() { return enemy(new Monster()); } - public Monster enemy(Monster obj) { int o = __offset(28); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - public int testnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; } - public int testnestedflatbufferLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; } - public ByteBuffer testnestedflatbufferAsByteBuffer() { return __vector_as_bytebuffer(30, 1); } - public Monster testnestedflatbufferAsMonster() { return testnestedflatbufferAsMonster(new Monster()); } - public Monster testnestedflatbufferAsMonster(Monster obj) { int o = __offset(30); return o != 0 ? obj.__assign(__indirect(__vector(o)), bb) : null; } - public boolean mutateTestnestedflatbuffer(int j, int testnestedflatbuffer) { int o = __offset(30); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)testnestedflatbuffer); return true; } else { return false; } } - public Stat testempty() { return testempty(new Stat()); } - public Stat testempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - public boolean testbool() { int o = __offset(34); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } - public boolean mutateTestbool(boolean testbool) { int o = __offset(34); if (o != 0) { bb.put(o + bb_pos, (byte)(testbool ? 1 : 0)); return true; } else { return false; } } - public int testhashs32Fnv1() { int o = __offset(36); return o != 0 ? bb.getInt(o + bb_pos) : 0; } - public boolean mutateTesthashs32Fnv1(int testhashs32_fnv1) { int o = __offset(36); if (o != 0) { bb.putInt(o + bb_pos, testhashs32_fnv1); return true; } else { return false; } } - public long testhashu32Fnv1() { int o = __offset(38); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; } - public boolean mutateTesthashu32Fnv1(long testhashu32_fnv1) { int o = __offset(38); if (o != 0) { bb.putInt(o + bb_pos, (int)testhashu32_fnv1); return true; } else { return false; } } - public long testhashs64Fnv1() { int o = __offset(40); return o != 0 ? bb.getLong(o + bb_pos) : 0L; } - public boolean mutateTesthashs64Fnv1(long testhashs64_fnv1) { int o = __offset(40); if (o != 0) { bb.putLong(o + bb_pos, testhashs64_fnv1); return true; } else { return false; } } - public long testhashu64Fnv1() { int o = __offset(42); return o != 0 ? bb.getLong(o + bb_pos) : 0L; } - public boolean mutateTesthashu64Fnv1(long testhashu64_fnv1) { int o = __offset(42); if (o != 0) { bb.putLong(o + bb_pos, testhashu64_fnv1); return true; } else { return false; } } - public int testhashs32Fnv1a() { int o = __offset(44); return o != 0 ? bb.getInt(o + bb_pos) : 0; } - public boolean mutateTesthashs32Fnv1a(int testhashs32_fnv1a) { int o = __offset(44); if (o != 0) { bb.putInt(o + bb_pos, testhashs32_fnv1a); return true; } else { return false; } } - public long testhashu32Fnv1a() { int o = __offset(46); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; } - public boolean mutateTesthashu32Fnv1a(long testhashu32_fnv1a) { int o = __offset(46); if (o != 0) { bb.putInt(o + bb_pos, (int)testhashu32_fnv1a); return true; } else { return false; } } - public long testhashs64Fnv1a() { int o = __offset(48); return o != 0 ? bb.getLong(o + bb_pos) : 0L; } - public boolean mutateTesthashs64Fnv1a(long testhashs64_fnv1a) { int o = __offset(48); if (o != 0) { bb.putLong(o + bb_pos, testhashs64_fnv1a); return true; } else { return false; } } - public long testhashu64Fnv1a() { int o = __offset(50); return o != 0 ? bb.getLong(o + bb_pos) : 0L; } - public boolean mutateTesthashu64Fnv1a(long testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.putLong(o + bb_pos, testhashu64_fnv1a); return true; } else { return false; } } - public boolean testarrayofbools(int j) { int o = __offset(52); return o != 0 ? 0!=bb.get(__vector(o) + j * 1) : false; } - public int testarrayofboolsLength() { int o = __offset(52); return o != 0 ? __vector_len(o) : 0; } - public ByteBuffer testarrayofboolsAsByteBuffer() { return __vector_as_bytebuffer(52, 1); } - public boolean mutateTestarrayofbools(int j, boolean testarrayofbools) { int o = __offset(52); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)(testarrayofbools ? 1 : 0)); return true; } else { return false; } } - public float testf() { int o = __offset(54); return o != 0 ? bb.getFloat(o + bb_pos) : 3.14159f; } - public boolean mutateTestf(float testf) { int o = __offset(54); if (o != 0) { bb.putFloat(o + bb_pos, testf); return true; } else { return false; } } - public float testf2() { int o = __offset(56); return o != 0 ? bb.getFloat(o + bb_pos) : 3.0f; } - public boolean mutateTestf2(float testf2) { int o = __offset(56); if (o != 0) { bb.putFloat(o + bb_pos, testf2); return true; } else { return false; } } - public float testf3() { int o = __offset(58); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; } - public boolean mutateTestf3(float testf3) { int o = __offset(58); if (o != 0) { bb.putFloat(o + bb_pos, testf3); return true; } else { return false; } } - public String testarrayofstring2(int j) { int o = __offset(60); return o != 0 ? __string(__vector(o) + j * 4) : null; } - public int testarrayofstring2Length() { int o = __offset(60); return o != 0 ? __vector_len(o) : 0; } - public Ability testarrayofsortedstruct(int j) { return testarrayofsortedstruct(new Ability(), j); } - public Ability testarrayofsortedstruct(Ability obj, int j) { int o = __offset(62); return o != 0 ? obj.__assign(__vector(o) + j * 8, bb) : null; } - public int testarrayofsortedstructLength() { int o = __offset(62); return o != 0 ? __vector_len(o) : 0; } - - public static void startMonster(FlatBufferBuilder builder) { builder.startObject(30); } - public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); } - public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); } - public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); } - public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(3, nameOffset, 0); } - public static void addInventory(FlatBufferBuilder builder, int inventoryOffset) { builder.addOffset(5, inventoryOffset, 0); } - public static int createInventoryVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); } - public static void startInventoryVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } - public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(6, color, 8); } - public static void addTestType(FlatBufferBuilder builder, byte testType) { builder.addByte(7, testType, 0); } - public static void addTest(FlatBufferBuilder builder, int testOffset) { builder.addOffset(8, testOffset, 0); } - public static void addTest4(FlatBufferBuilder builder, int test4Offset) { builder.addOffset(9, test4Offset, 0); } - public static void startTest4Vector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 2); } - public static void addTestarrayofstring(FlatBufferBuilder builder, int testarrayofstringOffset) { builder.addOffset(10, testarrayofstringOffset, 0); } - public static int createTestarrayofstringVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } - public static void startTestarrayofstringVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } - public static void addTestarrayoftables(FlatBufferBuilder builder, int testarrayoftablesOffset) { builder.addOffset(11, testarrayoftablesOffset, 0); } - public static int createTestarrayoftablesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } - public static void startTestarrayoftablesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } - public static void addEnemy(FlatBufferBuilder builder, int enemyOffset) { builder.addOffset(12, enemyOffset, 0); } - public static void addTestnestedflatbuffer(FlatBufferBuilder builder, int testnestedflatbufferOffset) { builder.addOffset(13, testnestedflatbufferOffset, 0); } - public static int createTestnestedflatbufferVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); } - public static void startTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } - public static void addTestempty(FlatBufferBuilder builder, int testemptyOffset) { builder.addOffset(14, testemptyOffset, 0); } - public static void addTestbool(FlatBufferBuilder builder, boolean testbool) { builder.addBoolean(15, testbool, false); } - public static void addTesthashs32Fnv1(FlatBufferBuilder builder, int testhashs32Fnv1) { builder.addInt(16, testhashs32Fnv1, 0); } - public static void addTesthashu32Fnv1(FlatBufferBuilder builder, long testhashu32Fnv1) { builder.addInt(17, (int)testhashu32Fnv1, (int)0L); } - public static void addTesthashs64Fnv1(FlatBufferBuilder builder, long testhashs64Fnv1) { builder.addLong(18, testhashs64Fnv1, 0L); } - public static void addTesthashu64Fnv1(FlatBufferBuilder builder, long testhashu64Fnv1) { builder.addLong(19, testhashu64Fnv1, 0L); } - public static void addTesthashs32Fnv1a(FlatBufferBuilder builder, int testhashs32Fnv1a) { builder.addInt(20, testhashs32Fnv1a, 0); } - public static void addTesthashu32Fnv1a(FlatBufferBuilder builder, long testhashu32Fnv1a) { builder.addInt(21, (int)testhashu32Fnv1a, (int)0L); } - public static void addTesthashs64Fnv1a(FlatBufferBuilder builder, long testhashs64Fnv1a) { builder.addLong(22, testhashs64Fnv1a, 0L); } - public static void addTesthashu64Fnv1a(FlatBufferBuilder builder, long testhashu64Fnv1a) { builder.addLong(23, testhashu64Fnv1a, 0L); } - public static void addTestarrayofbools(FlatBufferBuilder builder, int testarrayofboolsOffset) { builder.addOffset(24, testarrayofboolsOffset, 0); } - public static int createTestarrayofboolsVector(FlatBufferBuilder builder, boolean[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addBoolean(data[i]); return builder.endVector(); } - public static void startTestarrayofboolsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } - public static void addTestf(FlatBufferBuilder builder, float testf) { builder.addFloat(25, testf, 3.14159f); } - public static void addTestf2(FlatBufferBuilder builder, float testf2) { builder.addFloat(26, testf2, 3.0f); } - public static void addTestf3(FlatBufferBuilder builder, float testf3) { builder.addFloat(27, testf3, 0.0f); } - public static void addTestarrayofstring2(FlatBufferBuilder builder, int testarrayofstring2Offset) { builder.addOffset(28, testarrayofstring2Offset, 0); } - public static int createTestarrayofstring2Vector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } - public static void startTestarrayofstring2Vector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } - public static void addTestarrayofsortedstruct(FlatBufferBuilder builder, int testarrayofsortedstructOffset) { builder.addOffset(29, testarrayofsortedstructOffset, 0); } - public static void startTestarrayofsortedstructVector(FlatBufferBuilder builder, int numElems) { builder.startVector(8, numElems, 4); } - public static int endMonster(FlatBufferBuilder builder) { - int o = builder.endObject(); - builder.required(o, 10); // name - return o; - } - public static void finishMonsterBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "MONS"); } - - @Override - protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(10, o1, _bb), __offset(10, o2, _bb), _bb); } - - public static Monster lookupByKey(int vectorOffset, String key, ByteBuffer bb) { - byte[] byteKey = key.getBytes(Table.UTF8_CHARSET.get()); - int vectorLocation = bb.array().length - vectorOffset; - int span = bb.getInt(vectorLocation); - int start = 0; - vectorLocation += 4; - while (span != 0) { - int middle = span / 2; - int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb); - int comp = compareStrings(__offset(10, bb.array().length - tableOffset, bb), byteKey, bb); - if (comp > 0) { - span = middle; - } else if (comp < 0) { - middle++; - start += middle; - span -= middle; - } else { - return new Monster().__assign(tableOffset, bb); - } - } - return null; - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Monster.php b/third_party/flatbuffers/tests/MyGame/Example/Monster.php deleted file mode 100644 index a866870..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Monster.php +++ /dev/null
@@ -1,943 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -/// an example documentation comment: monster object -class Monster extends Table -{ - /** - * @param ByteBuffer $bb - * @return Monster - */ - public static function getRootAsMonster(ByteBuffer $bb) - { - $obj = new Monster(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - public static function MonsterIdentifier() - { - return "MONS"; - } - - public static function MonsterBufferHasIdentifier(ByteBuffer $buf) - { - return self::__has_identifier($buf, self::MonsterIdentifier()); - } - - public static function MonsterExtension() - { - return "mon"; - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Monster - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getPos() - { - $obj = new Vec3(); - $o = $this->__offset(4); - return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0; - } - - /** - * @return short - */ - public function getMana() - { - $o = $this->__offset(6); - return $o != 0 ? $this->bb->getShort($o + $this->bb_pos) : 150; - } - - /** - * @return short - */ - public function getHp() - { - $o = $this->__offset(8); - return $o != 0 ? $this->bb->getShort($o + $this->bb_pos) : 100; - } - - public function getName() - { - $o = $this->__offset(10); - return $o != 0 ? $this->__string($o + $this->bb_pos) : null; - } - - /** - * @param int offset - * @return byte - */ - public function getInventory($j) - { - $o = $this->__offset(14); - return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0; - } - - /** - * @return int - */ - public function getInventoryLength() - { - $o = $this->__offset(14); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @return string - */ - public function getInventoryBytes() - { - return $this->__vector_as_bytes(14); - } - - /** - * @return sbyte - */ - public function getColor() - { - $o = $this->__offset(16); - return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \MyGame\Example\Color::Blue; - } - - /** - * @return byte - */ - public function getTestType() - { - $o = $this->__offset(18); - return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \MyGame\Example\Any::NONE; - } - - /** - * @returnint - */ - public function getTest($obj) - { - $o = $this->__offset(20); - return $o != 0 ? $this->__union($obj, $o) : null; - } - - /** - * @returnVectorOffset - */ - public function getTest4($j) - { - $o = $this->__offset(22); - $obj = new Test(); - return $o != 0 ? $obj->init($this->__vector($o) + $j *4, $this->bb) : null; - } - - /** - * @return int - */ - public function getTest4Length() - { - $o = $this->__offset(22); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @param int offset - * @return string - */ - public function getTestarrayofstring($j) - { - $o = $this->__offset(24); - return $o != 0 ? $this->__string($this->__vector($o) + $j * 4) : 0; - } - - /** - * @return int - */ - public function getTestarrayofstringLength() - { - $o = $this->__offset(24); - return $o != 0 ? $this->__vector_len($o) : 0; - } - -/// an example documentation comment: this will end up in the generated code -/// multiline too - /** - * @returnVectorOffset - */ - public function getTestarrayoftables($j) - { - $o = $this->__offset(26); - $obj = new Monster(); - return $o != 0 ? $obj->init($this->__indirect($this->__vector($o) + $j * 4), $this->bb) : null; - } - - /** - * @return int - */ - public function getTestarrayoftablesLength() - { - $o = $this->__offset(26); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - public function getEnemy() - { - $obj = new Monster(); - $o = $this->__offset(28); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @param int offset - * @return byte - */ - public function getTestnestedflatbuffer($j) - { - $o = $this->__offset(30); - return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0; - } - - /** - * @return int - */ - public function getTestnestedflatbufferLength() - { - $o = $this->__offset(30); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @return string - */ - public function getTestnestedflatbufferBytes() - { - return $this->__vector_as_bytes(30); - } - - public function getTestempty() - { - $obj = new Stat(); - $o = $this->__offset(32); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @return bool - */ - public function getTestbool() - { - $o = $this->__offset(34); - return $o != 0 ? $this->bb->getBool($o + $this->bb_pos) : false; - } - - /** - * @return int - */ - public function getTesthashs32Fnv1() - { - $o = $this->__offset(36); - return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0; - } - - /** - * @return uint - */ - public function getTesthashu32Fnv1() - { - $o = $this->__offset(38); - return $o != 0 ? $this->bb->getUint($o + $this->bb_pos) : 0; - } - - /** - * @return long - */ - public function getTesthashs64Fnv1() - { - $o = $this->__offset(40); - return $o != 0 ? $this->bb->getLong($o + $this->bb_pos) : 0; - } - - /** - * @return ulong - */ - public function getTesthashu64Fnv1() - { - $o = $this->__offset(42); - return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : 0; - } - - /** - * @return int - */ - public function getTesthashs32Fnv1a() - { - $o = $this->__offset(44); - return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0; - } - - /** - * @return uint - */ - public function getTesthashu32Fnv1a() - { - $o = $this->__offset(46); - return $o != 0 ? $this->bb->getUint($o + $this->bb_pos) : 0; - } - - /** - * @return long - */ - public function getTesthashs64Fnv1a() - { - $o = $this->__offset(48); - return $o != 0 ? $this->bb->getLong($o + $this->bb_pos) : 0; - } - - /** - * @return ulong - */ - public function getTesthashu64Fnv1a() - { - $o = $this->__offset(50); - return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : 0; - } - - /** - * @param int offset - * @return bool - */ - public function getTestarrayofbools($j) - { - $o = $this->__offset(52); - return $o != 0 ? $this->bb->getBool($this->__vector($o) + $j * 1) : 0; - } - - /** - * @return int - */ - public function getTestarrayofboolsLength() - { - $o = $this->__offset(52); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @return float - */ - public function getTestf() - { - $o = $this->__offset(54); - return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.14159; - } - - /** - * @return float - */ - public function getTestf2() - { - $o = $this->__offset(56); - return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.0; - } - - /** - * @return float - */ - public function getTestf3() - { - $o = $this->__offset(58); - return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 0.0; - } - - /** - * @param int offset - * @return string - */ - public function getTestarrayofstring2($j) - { - $o = $this->__offset(60); - return $o != 0 ? $this->__string($this->__vector($o) + $j * 4) : 0; - } - - /** - * @return int - */ - public function getTestarrayofstring2Length() - { - $o = $this->__offset(60); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @returnVectorOffset - */ - public function getTestarrayofsortedstruct($j) - { - $o = $this->__offset(62); - $obj = new Ability(); - return $o != 0 ? $obj->init($this->__vector($o) + $j *8, $this->bb) : null; - } - - /** - * @return int - */ - public function getTestarrayofsortedstructLength() - { - $o = $this->__offset(62); - return $o != 0 ? $this->__vector_len($o) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startMonster(FlatBufferBuilder $builder) - { - $builder->StartObject(30); - } - - /** - * @param FlatBufferBuilder $builder - * @return Monster - */ - public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2, $testarrayofsortedstruct) - { - $builder->startObject(30); - self::addPos($builder, $pos); - self::addMana($builder, $mana); - self::addHp($builder, $hp); - self::addName($builder, $name); - self::addInventory($builder, $inventory); - self::addColor($builder, $color); - self::addTestType($builder, $test_type); - self::addTest($builder, $test); - self::addTest4($builder, $test4); - self::addTestarrayofstring($builder, $testarrayofstring); - self::addTestarrayoftables($builder, $testarrayoftables); - self::addEnemy($builder, $enemy); - self::addTestnestedflatbuffer($builder, $testnestedflatbuffer); - self::addTestempty($builder, $testempty); - self::addTestbool($builder, $testbool); - self::addTesthashs32Fnv1($builder, $testhashs32_fnv1); - self::addTesthashu32Fnv1($builder, $testhashu32_fnv1); - self::addTesthashs64Fnv1($builder, $testhashs64_fnv1); - self::addTesthashu64Fnv1($builder, $testhashu64_fnv1); - self::addTesthashs32Fnv1a($builder, $testhashs32_fnv1a); - self::addTesthashu32Fnv1a($builder, $testhashu32_fnv1a); - self::addTesthashs64Fnv1a($builder, $testhashs64_fnv1a); - self::addTesthashu64Fnv1a($builder, $testhashu64_fnv1a); - self::addTestarrayofbools($builder, $testarrayofbools); - self::addTestf($builder, $testf); - self::addTestf2($builder, $testf2); - self::addTestf3($builder, $testf3); - self::addTestarrayofstring2($builder, $testarrayofstring2); - self::addTestarrayofsortedstruct($builder, $testarrayofsortedstruct); - $o = $builder->endObject(); - $builder->required($o, 10); // name - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addPos(FlatBufferBuilder $builder, $pos) - { - $builder->addStructX(0, $pos, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param short - * @return void - */ - public static function addMana(FlatBufferBuilder $builder, $mana) - { - $builder->addShortX(1, $mana, 150); - } - - /** - * @param FlatBufferBuilder $builder - * @param short - * @return void - */ - public static function addHp(FlatBufferBuilder $builder, $hp) - { - $builder->addShortX(2, $hp, 100); - } - - /** - * @param FlatBufferBuilder $builder - * @param StringOffset - * @return void - */ - public static function addName(FlatBufferBuilder $builder, $name) - { - $builder->addOffsetX(3, $name, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addInventory(FlatBufferBuilder $builder, $inventory) - { - $builder->addOffsetX(5, $inventory, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createInventoryVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(1, count($data), 1); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addByte($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startInventoryVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(1, $numElems, 1); - } - - /** - * @param FlatBufferBuilder $builder - * @param sbyte - * @return void - */ - public static function addColor(FlatBufferBuilder $builder, $color) - { - $builder->addSbyteX(6, $color, 8); - } - - /** - * @param FlatBufferBuilder $builder - * @param byte - * @return void - */ - public static function addTestType(FlatBufferBuilder $builder, $testType) - { - $builder->addByteX(7, $testType, 0); - } - - public static function addTest(FlatBufferBuilder $builder, $offset) - { - $builder->addOffsetX(8, $offset, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTest4(FlatBufferBuilder $builder, $test4) - { - $builder->addOffsetX(9, $test4, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTest4Vector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(4, count($data), 2); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addOffset($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTest4Vector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(4, $numElems, 2); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestarrayofstring(FlatBufferBuilder $builder, $testarrayofstring) - { - $builder->addOffsetX(10, $testarrayofstring, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestarrayofstringVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(4, count($data), 4); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addOffset($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestarrayofstringVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(4, $numElems, 4); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestarrayoftables(FlatBufferBuilder $builder, $testarrayoftables) - { - $builder->addOffsetX(11, $testarrayoftables, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestarrayoftablesVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(4, count($data), 4); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addOffset($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestarrayoftablesVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(4, $numElems, 4); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addEnemy(FlatBufferBuilder $builder, $enemy) - { - $builder->addOffsetX(12, $enemy, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestnestedflatbuffer(FlatBufferBuilder $builder, $testnestedflatbuffer) - { - $builder->addOffsetX(13, $testnestedflatbuffer, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestnestedflatbufferVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(1, count($data), 1); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addByte($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestnestedflatbufferVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(1, $numElems, 1); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addTestempty(FlatBufferBuilder $builder, $testempty) - { - $builder->addOffsetX(14, $testempty, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param bool - * @return void - */ - public static function addTestbool(FlatBufferBuilder $builder, $testbool) - { - $builder->addBoolX(15, $testbool, false); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addTesthashs32Fnv1(FlatBufferBuilder $builder, $testhashs32Fnv1) - { - $builder->addIntX(16, $testhashs32Fnv1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param uint - * @return void - */ - public static function addTesthashu32Fnv1(FlatBufferBuilder $builder, $testhashu32Fnv1) - { - $builder->addUintX(17, $testhashu32Fnv1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param long - * @return void - */ - public static function addTesthashs64Fnv1(FlatBufferBuilder $builder, $testhashs64Fnv1) - { - $builder->addLongX(18, $testhashs64Fnv1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param ulong - * @return void - */ - public static function addTesthashu64Fnv1(FlatBufferBuilder $builder, $testhashu64Fnv1) - { - $builder->addUlongX(19, $testhashu64Fnv1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addTesthashs32Fnv1a(FlatBufferBuilder $builder, $testhashs32Fnv1a) - { - $builder->addIntX(20, $testhashs32Fnv1a, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param uint - * @return void - */ - public static function addTesthashu32Fnv1a(FlatBufferBuilder $builder, $testhashu32Fnv1a) - { - $builder->addUintX(21, $testhashu32Fnv1a, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param long - * @return void - */ - public static function addTesthashs64Fnv1a(FlatBufferBuilder $builder, $testhashs64Fnv1a) - { - $builder->addLongX(22, $testhashs64Fnv1a, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param ulong - * @return void - */ - public static function addTesthashu64Fnv1a(FlatBufferBuilder $builder, $testhashu64Fnv1a) - { - $builder->addUlongX(23, $testhashu64Fnv1a, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestarrayofbools(FlatBufferBuilder $builder, $testarrayofbools) - { - $builder->addOffsetX(24, $testarrayofbools, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestarrayofboolsVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(1, count($data), 1); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addBool($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestarrayofboolsVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(1, $numElems, 1); - } - - /** - * @param FlatBufferBuilder $builder - * @param float - * @return void - */ - public static function addTestf(FlatBufferBuilder $builder, $testf) - { - $builder->addFloatX(25, $testf, 3.14159); - } - - /** - * @param FlatBufferBuilder $builder - * @param float - * @return void - */ - public static function addTestf2(FlatBufferBuilder $builder, $testf2) - { - $builder->addFloatX(26, $testf2, 3.0); - } - - /** - * @param FlatBufferBuilder $builder - * @param float - * @return void - */ - public static function addTestf3(FlatBufferBuilder $builder, $testf3) - { - $builder->addFloatX(27, $testf3, 0.0); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestarrayofstring2(FlatBufferBuilder $builder, $testarrayofstring2) - { - $builder->addOffsetX(28, $testarrayofstring2, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestarrayofstring2Vector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(4, count($data), 4); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addOffset($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestarrayofstring2Vector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(4, $numElems, 4); - } - - /** - * @param FlatBufferBuilder $builder - * @param VectorOffset - * @return void - */ - public static function addTestarrayofsortedstruct(FlatBufferBuilder $builder, $testarrayofsortedstruct) - { - $builder->addOffsetX(29, $testarrayofsortedstruct, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param array offset array - * @return int vector offset - */ - public static function createTestarrayofsortedstructVector(FlatBufferBuilder $builder, array $data) - { - $builder->startVector(8, count($data), 4); - for ($i = count($data) - 1; $i >= 0; $i--) { - $builder->addOffset($data[$i]); - } - return $builder->endVector(); - } - - /** - * @param FlatBufferBuilder $builder - * @param int $numElems - * @return void - */ - public static function startTestarrayofsortedstructVector(FlatBufferBuilder $builder, $numElems) - { - $builder->startVector(8, $numElems, 4); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endMonster(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - $builder->required($o, 10); // name - return $o; - } - - public static function finishMonsterBuffer(FlatBufferBuilder $builder, $offset) - { - $builder->finish($offset, "MONS"); - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Monster.py b/third_party/flatbuffers/tests/MyGame/Example/Monster.py deleted file mode 100644 index 75e54a1..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Monster.py +++ /dev/null
@@ -1,357 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -# /// an example documentation comment: monster object -class Monster(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsMonster(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Monster() - x.Init(buf, n + offset) - return x - - # Monster - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Monster - def Pos(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = o + self._tab.Pos - from .Vec3 import Vec3 - obj = Vec3() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def Mana(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos) - return 150 - - # Monster - def Hp(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos) - return 100 - - # Monster - def Name(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return "" - - # Monster - def Inventory(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Monster - def InventoryLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Color(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 8 - - # Monster - def TestType(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos) - return 0 - - # Monster - def Test(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) - if o != 0: - from flatbuffers.table import Table - obj = Table(bytearray(), 0) - self._tab.Union(obj, o) - return obj - return None - - # Monster - def Test4(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - from .Test import Test - obj = Test() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def Test4Length(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Testarrayofstring(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return "" - - # Monster - def TestarrayofstringLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - -# /// an example documentation comment: this will end up in the generated code -# /// multiline too - # Monster - def Testarrayoftables(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 - x = self._tab.Indirect(x) - from .Monster import Monster - obj = Monster() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def TestarrayoftablesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Enemy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .Monster import Monster - obj = Monster() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def Testnestedflatbuffer(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Monster - def TestnestedflatbufferLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Testempty(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .Stat import Stat - obj = Stat() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def Testbool(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashs32Fnv1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashu32Fnv1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashs64Fnv1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(40)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashu64Fnv1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(42)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashs32Fnv1a(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(44)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashu32Fnv1a(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(46)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashs64Fnv1a(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(48)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testhashu64Fnv1a(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(50)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) - return 0 - - # Monster - def Testarrayofbools(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(52)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.BoolFlags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) - return 0 - - # Monster - def TestarrayofboolsLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(52)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Testf(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(54)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 3.14159 - - # Monster - def Testf2(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(56)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 3.0 - - # Monster - def Testf3(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(58)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos) - return 0.0 - - # Monster - def Testarrayofstring2(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return "" - - # Monster - def Testarrayofstring2Length(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Monster - def Testarrayofsortedstruct(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(62)) - if o != 0: - x = self._tab.Vector(o) - x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 8 - from .Ability import Ability - obj = Ability() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # Monster - def TestarrayofsortedstructLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(62)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - -def MonsterStart(builder): builder.StartObject(30) -def MonsterAddPos(builder, pos): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pos), 0) -def MonsterAddMana(builder, mana): builder.PrependInt16Slot(1, mana, 150) -def MonsterAddHp(builder, hp): builder.PrependInt16Slot(2, hp, 100) -def MonsterAddName(builder, name): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0) -def MonsterAddInventory(builder, inventory): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(inventory), 0) -def MonsterStartInventoryVector(builder, numElems): return builder.StartVector(1, numElems, 1) -def MonsterAddColor(builder, color): builder.PrependInt8Slot(6, color, 8) -def MonsterAddTestType(builder, testType): builder.PrependUint8Slot(7, testType, 0) -def MonsterAddTest(builder, test): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(test), 0) -def MonsterAddTest4(builder, test4): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(test4), 0) -def MonsterStartTest4Vector(builder, numElems): return builder.StartVector(4, numElems, 2) -def MonsterAddTestarrayofstring(builder, testarrayofstring): builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring), 0) -def MonsterStartTestarrayofstringVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def MonsterAddTestarrayoftables(builder, testarrayoftables): builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayoftables), 0) -def MonsterStartTestarrayoftablesVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def MonsterAddEnemy(builder, enemy): builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(enemy), 0) -def MonsterAddTestnestedflatbuffer(builder, testnestedflatbuffer): builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(testnestedflatbuffer), 0) -def MonsterStartTestnestedflatbufferVector(builder, numElems): return builder.StartVector(1, numElems, 1) -def MonsterAddTestempty(builder, testempty): builder.PrependUOffsetTRelativeSlot(14, flatbuffers.number_types.UOffsetTFlags.py_type(testempty), 0) -def MonsterAddTestbool(builder, testbool): builder.PrependBoolSlot(15, testbool, 0) -def MonsterAddTesthashs32Fnv1(builder, testhashs32Fnv1): builder.PrependInt32Slot(16, testhashs32Fnv1, 0) -def MonsterAddTesthashu32Fnv1(builder, testhashu32Fnv1): builder.PrependUint32Slot(17, testhashu32Fnv1, 0) -def MonsterAddTesthashs64Fnv1(builder, testhashs64Fnv1): builder.PrependInt64Slot(18, testhashs64Fnv1, 0) -def MonsterAddTesthashu64Fnv1(builder, testhashu64Fnv1): builder.PrependUint64Slot(19, testhashu64Fnv1, 0) -def MonsterAddTesthashs32Fnv1a(builder, testhashs32Fnv1a): builder.PrependInt32Slot(20, testhashs32Fnv1a, 0) -def MonsterAddTesthashu32Fnv1a(builder, testhashu32Fnv1a): builder.PrependUint32Slot(21, testhashu32Fnv1a, 0) -def MonsterAddTesthashs64Fnv1a(builder, testhashs64Fnv1a): builder.PrependInt64Slot(22, testhashs64Fnv1a, 0) -def MonsterAddTesthashu64Fnv1a(builder, testhashu64Fnv1a): builder.PrependUint64Slot(23, testhashu64Fnv1a, 0) -def MonsterAddTestarrayofbools(builder, testarrayofbools): builder.PrependUOffsetTRelativeSlot(24, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofbools), 0) -def MonsterStartTestarrayofboolsVector(builder, numElems): return builder.StartVector(1, numElems, 1) -def MonsterAddTestf(builder, testf): builder.PrependFloat32Slot(25, testf, 3.14159) -def MonsterAddTestf2(builder, testf2): builder.PrependFloat32Slot(26, testf2, 3.0) -def MonsterAddTestf3(builder, testf3): builder.PrependFloat32Slot(27, testf3, 0.0) -def MonsterAddTestarrayofstring2(builder, testarrayofstring2): builder.PrependUOffsetTRelativeSlot(28, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring2), 0) -def MonsterStartTestarrayofstring2Vector(builder, numElems): return builder.StartVector(4, numElems, 4) -def MonsterAddTestarrayofsortedstruct(builder, testarrayofsortedstruct): builder.PrependUOffsetTRelativeSlot(29, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofsortedstruct), 0) -def MonsterStartTestarrayofsortedstructVector(builder, numElems): return builder.StartVector(8, numElems, 4) -def MonsterEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/MonsterStorage_grpc.go b/third_party/flatbuffers/tests/MyGame/Example/MonsterStorage_grpc.go deleted file mode 100644 index cc9a1ec..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/MonsterStorage_grpc.go +++ /dev/null
@@ -1,127 +0,0 @@ -//Generated by gRPC Go plugin -//If you make any local changes, they will be lost -//source: monster_test - -package Example - -import "github.com/google/flatbuffers/go" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Client API for MonsterStorage service -type MonsterStorageClient interface{ - Store(ctx context.Context, in *flatbuffers.Builder, - opts... grpc.CallOption) (* Stat, error) - Retrieve(ctx context.Context, in *flatbuffers.Builder, - opts... grpc.CallOption) (MonsterStorage_RetrieveClient, error) -} - -type monsterStorageClient struct { - cc *grpc.ClientConn -} - -func NewMonsterStorageClient(cc *grpc.ClientConn) MonsterStorageClient { - return &monsterStorageClient{cc} -} - -func (c *monsterStorageClient) Store(ctx context.Context, in *flatbuffers.Builder, - opts... grpc.CallOption) (* Stat, error) { - out := new(Stat) - err := grpc.Invoke(ctx, "/Example.MonsterStorage/Store", in, out, c.cc, opts...) - if err != nil { return nil, err } - return out, nil -} - -func (c *monsterStorageClient) Retrieve(ctx context.Context, in *flatbuffers.Builder, - opts... grpc.CallOption) (MonsterStorage_RetrieveClient, error) { - stream, err := grpc.NewClientStream(ctx, &_MonsterStorage_serviceDesc.Streams[0], c.cc, "/Example.MonsterStorage/Retrieve", opts...) - if err != nil { return nil, err } - x := &monsterStorageRetrieveClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } - if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - return x,nil -} - -type MonsterStorage_RetrieveClient interface { - Recv() (*Monster, error) - grpc.ClientStream -} - -type monsterStorageRetrieveClient struct{ - grpc.ClientStream -} - -func (x *monsterStorageRetrieveClient) Recv() (*Monster, error) { - m := new(Monster) - if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } - return m, nil -} - -// Server API for MonsterStorage service -type MonsterStorageServer interface { - Store(context.Context, *Monster) (*flatbuffers.Builder, error) - Retrieve(*Stat, MonsterStorage_RetrieveServer) error -} - -func RegisterMonsterStorageServer(s *grpc.Server, srv MonsterStorageServer) { - s.RegisterService(&_MonsterStorage_serviceDesc, srv) -} - -func _MonsterStorage_Store_Handler(srv interface{}, ctx context.Context, - dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Monster) - if err := dec(in); err != nil { return nil, err } - if interceptor == nil { return srv.(MonsterStorageServer).Store(ctx, in) } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Example.MonsterStorage/Store", - } - - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MonsterStorageServer).Store(ctx, req.(* Monster)) - } - return interceptor(ctx, in, info, handler) -} - - -func _MonsterStorage_Retrieve_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Stat) - if err := stream.RecvMsg(m); err != nil { return err } - return srv.(MonsterStorageServer).Retrieve(m, &monsterStorageRetrieveServer{stream}) -} - -type MonsterStorage_RetrieveServer interface { - Send(* flatbuffers.Builder) error - grpc.ServerStream -} - -type monsterStorageRetrieveServer struct { - grpc.ServerStream -} - -func (x *monsterStorageRetrieveServer) Send(m *flatbuffers.Builder) error { - return x.ServerStream.SendMsg(m) -} - - -var _MonsterStorage_serviceDesc = grpc.ServiceDesc{ - ServiceName: "Example.MonsterStorage", - HandlerType: (*MonsterStorageServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Store", - Handler: _MonsterStorage_Store_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Retrieve", - Handler: _MonsterStorage_Retrieve_Handler, - ServerStreams: true, - }, - }, -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Stat.cs b/third_party/flatbuffers/tests/MyGame/Example/Stat.cs deleted file mode 100644 index 1ea8050..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Stat.cs +++ /dev/null
@@ -1,47 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -public struct Stat : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static Stat GetRootAsStat(ByteBuffer _bb) { return GetRootAsStat(_bb, new Stat()); } - public static Stat GetRootAsStat(ByteBuffer _bb, Stat obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public string Id { get { int o = __p.__offset(4); return o != 0 ? __p.__string(o + __p.bb_pos) : null; } } - public ArraySegment<byte>? GetIdBytes() { return __p.__vector_as_arraysegment(4); } - public long Val { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } } - public bool MutateVal(long val) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutLong(o + __p.bb_pos, val); return true; } else { return false; } } - public ushort Count { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUshort(o + __p.bb_pos) : (ushort)0; } } - public bool MutateCount(ushort count) { int o = __p.__offset(8); if (o != 0) { __p.bb.PutUshort(o + __p.bb_pos, count); return true; } else { return false; } } - - public static Offset<Stat> CreateStat(FlatBufferBuilder builder, - StringOffset idOffset = default(StringOffset), - long val = 0, - ushort count = 0) { - builder.StartObject(3); - Stat.AddVal(builder, val); - Stat.AddId(builder, idOffset); - Stat.AddCount(builder, count); - return Stat.EndStat(builder); - } - - public static void StartStat(FlatBufferBuilder builder) { builder.StartObject(3); } - public static void AddId(FlatBufferBuilder builder, StringOffset idOffset) { builder.AddOffset(0, idOffset.Value, 0); } - public static void AddVal(FlatBufferBuilder builder, long val) { builder.AddLong(1, val, 0); } - public static void AddCount(FlatBufferBuilder builder, ushort count) { builder.AddUshort(2, count, 0); } - public static Offset<Stat> EndStat(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<Stat>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Stat.go b/third_party/flatbuffers/tests/MyGame/Example/Stat.go deleted file mode 100644 index 9abc558..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Stat.go +++ /dev/null
@@ -1,75 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Stat struct { - _tab flatbuffers.Table -} - -func GetRootAsStat(buf []byte, offset flatbuffers.UOffsetT) *Stat { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Stat{} - x.Init(buf, n+offset) - return x -} - -func (rcv *Stat) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Stat) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Stat) Id() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Stat) Val() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Stat) MutateVal(n int64) bool { - return rcv._tab.MutateInt64Slot(6, n) -} - -func (rcv *Stat) Count() uint16 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.GetUint16(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Stat) MutateCount(n uint16) bool { - return rcv._tab.MutateUint16Slot(8, n) -} - -func StatStart(builder *flatbuffers.Builder) { - builder.StartObject(3) -} -func StatAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0) -} -func StatAddVal(builder *flatbuffers.Builder, val int64) { - builder.PrependInt64Slot(1, val, 0) -} -func StatAddCount(builder *flatbuffers.Builder, count uint16) { - builder.PrependUint16Slot(2, count, 0) -} -func StatEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Stat.java b/third_party/flatbuffers/tests/MyGame/Example/Stat.java deleted file mode 100644 index 351e5b3..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Stat.java +++ /dev/null
@@ -1,44 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class Stat extends Table { - public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); } - public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public String id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer idAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } - public long val() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; } - public boolean mutateVal(long val) { int o = __offset(6); if (o != 0) { bb.putLong(o + bb_pos, val); return true; } else { return false; } } - public int count() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; } - public boolean mutateCount(int count) { int o = __offset(8); if (o != 0) { bb.putShort(o + bb_pos, (short)count); return true; } else { return false; } } - - public static int createStat(FlatBufferBuilder builder, - int idOffset, - long val, - int count) { - builder.startObject(3); - Stat.addVal(builder, val); - Stat.addId(builder, idOffset); - Stat.addCount(builder, count); - return Stat.endStat(builder); - } - - public static void startStat(FlatBufferBuilder builder) { builder.startObject(3); } - public static void addId(FlatBufferBuilder builder, int idOffset) { builder.addOffset(0, idOffset, 0); } - public static void addVal(FlatBufferBuilder builder, long val) { builder.addLong(1, val, 0L); } - public static void addCount(FlatBufferBuilder builder, int count) { builder.addShort(2, (short)count, (short)0); } - public static int endStat(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Stat.php b/third_party/flatbuffers/tests/MyGame/Example/Stat.php deleted file mode 100644 index 6ef7034..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Stat.php +++ /dev/null
@@ -1,136 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class Stat extends Table -{ - /** - * @param ByteBuffer $bb - * @return Stat - */ - public static function getRootAsStat(ByteBuffer $bb) - { - $obj = new Stat(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - public static function StatIdentifier() - { - return "MONS"; - } - - public static function StatBufferHasIdentifier(ByteBuffer $buf) - { - return self::__has_identifier($buf, self::StatIdentifier()); - } - - public static function StatExtension() - { - return "mon"; - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Stat - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getId() - { - $o = $this->__offset(4); - return $o != 0 ? $this->__string($o + $this->bb_pos) : null; - } - - /** - * @return long - */ - public function getVal() - { - $o = $this->__offset(6); - return $o != 0 ? $this->bb->getLong($o + $this->bb_pos) : 0; - } - - /** - * @return ushort - */ - public function getCount() - { - $o = $this->__offset(8); - return $o != 0 ? $this->bb->getUshort($o + $this->bb_pos) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startStat(FlatBufferBuilder $builder) - { - $builder->StartObject(3); - } - - /** - * @param FlatBufferBuilder $builder - * @return Stat - */ - public static function createStat(FlatBufferBuilder $builder, $id, $val, $count) - { - $builder->startObject(3); - self::addId($builder, $id); - self::addVal($builder, $val); - self::addCount($builder, $count); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param StringOffset - * @return void - */ - public static function addId(FlatBufferBuilder $builder, $id) - { - $builder->addOffsetX(0, $id, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param long - * @return void - */ - public static function addVal(FlatBufferBuilder $builder, $val) - { - $builder->addLongX(1, $val, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param ushort - * @return void - */ - public static function addCount(FlatBufferBuilder $builder, $count) - { - $builder->addUshortX(2, $count, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endStat(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Stat.py b/third_party/flatbuffers/tests/MyGame/Example/Stat.py deleted file mode 100644 index b0e251d..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Stat.py +++ /dev/null
@@ -1,46 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -class Stat(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsStat(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Stat() - x.Init(buf, n + offset) - return x - - # Stat - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Stat - def Id(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.String(o + self._tab.Pos) - return "" - - # Stat - def Val(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos) - return 0 - - # Stat - def Count(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos) - return 0 - -def StatStart(builder): builder.StartObject(3) -def StatAddId(builder, id): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(id), 0) -def StatAddVal(builder, val): builder.PrependInt64Slot(1, val, 0) -def StatAddCount(builder, count): builder.PrependUint16Slot(2, count, 0) -def StatEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Test.cs b/third_party/flatbuffers/tests/MyGame/Example/Test.cs deleted file mode 100644 index 406f5f1..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Test.cs +++ /dev/null
@@ -1,31 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -public struct Test : IFlatbufferObject -{ - private Struct __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Test __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public short A { get { return __p.bb.GetShort(__p.bb_pos + 0); } } - public void MutateA(short a) { __p.bb.PutShort(__p.bb_pos + 0, a); } - public sbyte B { get { return __p.bb.GetSbyte(__p.bb_pos + 2); } } - public void MutateB(sbyte b) { __p.bb.PutSbyte(__p.bb_pos + 2, b); } - - public static Offset<Test> CreateTest(FlatBufferBuilder builder, short A, sbyte B) { - builder.Prep(2, 4); - builder.Pad(1); - builder.PutSbyte(B); - builder.PutShort(A); - return new Offset<Test>(builder.Offset); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Test.go b/third_party/flatbuffers/tests/MyGame/Example/Test.go deleted file mode 100644 index cb283fb..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Test.go +++ /dev/null
@@ -1,42 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Test struct { - _tab flatbuffers.Struct -} - -func (rcv *Test) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Test) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *Test) A() int16 { - return rcv._tab.GetInt16(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *Test) MutateA(n int16) bool { - return rcv._tab.MutateInt16(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *Test) B() int8 { - return rcv._tab.GetInt8(rcv._tab.Pos + flatbuffers.UOffsetT(2)) -} -func (rcv *Test) MutateB(n int8) bool { - return rcv._tab.MutateInt8(rcv._tab.Pos+flatbuffers.UOffsetT(2), n) -} - -func CreateTest(builder *flatbuffers.Builder, a int16, b int8) flatbuffers.UOffsetT { - builder.Prep(2, 4) - builder.Pad(1) - builder.PrependInt8(b) - builder.PrependInt16(a) - return builder.Offset() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Test.java b/third_party/flatbuffers/tests/MyGame/Example/Test.java deleted file mode 100644 index f584c46..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Test.java +++ /dev/null
@@ -1,28 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class Test extends Struct { - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Test __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public short a() { return bb.getShort(bb_pos + 0); } - public void mutateA(short a) { bb.putShort(bb_pos + 0, a); } - public byte b() { return bb.get(bb_pos + 2); } - public void mutateB(byte b) { bb.put(bb_pos + 2, b); } - - public static int createTest(FlatBufferBuilder builder, short a, byte b) { - builder.prep(2, 4); - builder.pad(1); - builder.putByte(b); - builder.putShort(a); - return builder.offset(); - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Test.php b/third_party/flatbuffers/tests/MyGame/Example/Test.php deleted file mode 100644 index 13cced0..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Test.php +++ /dev/null
@@ -1,53 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class Test extends Struct -{ - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Test - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return short - */ - public function GetA() - { - return $this->bb->getShort($this->bb_pos + 0); - } - - /** - * @return sbyte - */ - public function GetB() - { - return $this->bb->getSbyte($this->bb_pos + 2); - } - - - /** - * @return int offset - */ - public static function createTest(FlatBufferBuilder $builder, $a, $b) - { - $builder->prep(2, 4); - $builder->pad(1); - $builder->putSbyte($b); - $builder->putShort($a); - return $builder->offset(); - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Test.py b/third_party/flatbuffers/tests/MyGame/Example/Test.py deleted file mode 100644 index 3b2fd45..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Test.py +++ /dev/null
@@ -1,24 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -class Test(object): - __slots__ = ['_tab'] - - # Test - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Test - def A(self): return self._tab.Get(flatbuffers.number_types.Int16Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)) - # Test - def B(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(2)) - -def CreateTest(builder, a, b): - builder.Prep(2, 4) - builder.Pad(1) - builder.PrependInt8(b) - builder.PrependInt16(a) - return builder.Offset()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.cs b/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.cs deleted file mode 100644 index 3d2a3f4..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.cs +++ /dev/null
@@ -1,37 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -public partial struct TestSimpleTableWithEnum : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return GetRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); } - public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public Color Color { get { int o = __p.__offset(4); return o != 0 ? (Color)__p.bb.GetSbyte(o + __p.bb_pos) : Color.Green; } } - public bool MutateColor(Color color) { int o = __p.__offset(4); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)color); return true; } else { return false; } } - - public static Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(FlatBufferBuilder builder, - Color color = Color.Green) { - builder.StartObject(1); - TestSimpleTableWithEnum.AddColor(builder, color); - return TestSimpleTableWithEnum.EndTestSimpleTableWithEnum(builder); - } - - public static void StartTestSimpleTableWithEnum(FlatBufferBuilder builder) { builder.StartObject(1); } - public static void AddColor(FlatBufferBuilder builder, Color color) { builder.AddSbyte(0, (sbyte)color, 2); } - public static Offset<TestSimpleTableWithEnum> EndTestSimpleTableWithEnum(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<TestSimpleTableWithEnum>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.go b/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.go deleted file mode 100644 index 0704b70..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.go +++ /dev/null
@@ -1,49 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type TestSimpleTableWithEnum struct { - _tab flatbuffers.Table -} - -func GetRootAsTestSimpleTableWithEnum(buf []byte, offset flatbuffers.UOffsetT) *TestSimpleTableWithEnum { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &TestSimpleTableWithEnum{} - x.Init(buf, n+offset) - return x -} - -func (rcv *TestSimpleTableWithEnum) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *TestSimpleTableWithEnum) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *TestSimpleTableWithEnum) Color() int8 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.GetInt8(o + rcv._tab.Pos) - } - return 2 -} - -func (rcv *TestSimpleTableWithEnum) MutateColor(n int8) bool { - return rcv._tab.MutateInt8Slot(4, n) -} - -func TestSimpleTableWithEnumStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color int8) { - builder.PrependInt8Slot(0, color, 2) -} -func TestSimpleTableWithEnumEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.java b/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.java deleted file mode 100644 index 9f77b39..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.java +++ /dev/null
@@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class TestSimpleTableWithEnum extends Table { - public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); } - public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public byte color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 2; } - public boolean mutateColor(byte color) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, color); return true; } else { return false; } } - - public static int createTestSimpleTableWithEnum(FlatBufferBuilder builder, - byte color) { - builder.startObject(1); - TestSimpleTableWithEnum.addColor(builder, color); - return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); - } - - public static void startTestSimpleTableWithEnum(FlatBufferBuilder builder) { builder.startObject(1); } - public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(0, color, 2); } - public static int endTestSimpleTableWithEnum(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.php b/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.php deleted file mode 100644 index d37481f..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.php +++ /dev/null
@@ -1,99 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class TestSimpleTableWithEnum extends Table -{ - /** - * @param ByteBuffer $bb - * @return TestSimpleTableWithEnum - */ - public static function getRootAsTestSimpleTableWithEnum(ByteBuffer $bb) - { - $obj = new TestSimpleTableWithEnum(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - public static function TestSimpleTableWithEnumIdentifier() - { - return "MONS"; - } - - public static function TestSimpleTableWithEnumBufferHasIdentifier(ByteBuffer $buf) - { - return self::__has_identifier($buf, self::TestSimpleTableWithEnumIdentifier()); - } - - public static function TestSimpleTableWithEnumExtension() - { - return "mon"; - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return TestSimpleTableWithEnum - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return sbyte - */ - public function getColor() - { - $o = $this->__offset(4); - return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \MyGame\Example\Color::Green; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startTestSimpleTableWithEnum(FlatBufferBuilder $builder) - { - $builder->StartObject(1); - } - - /** - * @param FlatBufferBuilder $builder - * @return TestSimpleTableWithEnum - */ - public static function createTestSimpleTableWithEnum(FlatBufferBuilder $builder, $color) - { - $builder->startObject(1); - self::addColor($builder, $color); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param sbyte - * @return void - */ - public static function addColor(FlatBufferBuilder $builder, $color) - { - $builder->addSbyteX(0, $color, 2); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endTestSimpleTableWithEnum(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.py b/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.py deleted file mode 100644 index 8d64e97..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.py +++ /dev/null
@@ -1,30 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -class TestSimpleTableWithEnum(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsTestSimpleTableWithEnum(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TestSimpleTableWithEnum() - x.Init(buf, n + offset) - return x - - # TestSimpleTableWithEnum - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TestSimpleTableWithEnum - def Color(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 2 - -def TestSimpleTableWithEnumStart(builder): builder.StartObject(1) -def TestSimpleTableWithEnumAddColor(builder, color): builder.PrependInt8Slot(0, color, 2) -def TestSimpleTableWithEnumEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Vec3.cs b/third_party/flatbuffers/tests/MyGame/Example/Vec3.cs deleted file mode 100644 index 6ea4b0e..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Vec3.cs +++ /dev/null
@@ -1,47 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example -{ - -using global::System; -using global::FlatBuffers; - -public struct Vec3 : IFlatbufferObject -{ - private Struct __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public float X { get { return __p.bb.GetFloat(__p.bb_pos + 0); } } - public void MutateX(float x) { __p.bb.PutFloat(__p.bb_pos + 0, x); } - public float Y { get { return __p.bb.GetFloat(__p.bb_pos + 4); } } - public void MutateY(float y) { __p.bb.PutFloat(__p.bb_pos + 4, y); } - public float Z { get { return __p.bb.GetFloat(__p.bb_pos + 8); } } - public void MutateZ(float z) { __p.bb.PutFloat(__p.bb_pos + 8, z); } - public double Test1 { get { return __p.bb.GetDouble(__p.bb_pos + 16); } } - public void MutateTest1(double test1) { __p.bb.PutDouble(__p.bb_pos + 16, test1); } - public Color Test2 { get { return (Color)__p.bb.GetSbyte(__p.bb_pos + 24); } } - public void MutateTest2(Color test2) { __p.bb.PutSbyte(__p.bb_pos + 24, (sbyte)test2); } - public Test Test3 { get { return (new Test()).__assign(__p.bb_pos + 26, __p.bb); } } - - public static Offset<Vec3> CreateVec3(FlatBufferBuilder builder, float X, float Y, float Z, double Test1, Color Test2, short test3_A, sbyte test3_B) { - builder.Prep(16, 32); - builder.Pad(2); - builder.Prep(2, 4); - builder.Pad(1); - builder.PutSbyte(test3_B); - builder.PutShort(test3_A); - builder.Pad(1); - builder.PutSbyte((sbyte)Test2); - builder.PutDouble(Test1); - builder.Pad(4); - builder.PutFloat(Z); - builder.PutFloat(Y); - builder.PutFloat(X); - return new Offset<Vec3>(builder.Offset); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Vec3.go b/third_party/flatbuffers/tests/MyGame/Example/Vec3.go deleted file mode 100644 index a880a40..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Vec3.go +++ /dev/null
@@ -1,80 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Vec3 struct { - _tab flatbuffers.Struct -} - -func (rcv *Vec3) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Vec3) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *Vec3) X() float32 { - return rcv._tab.GetFloat32(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *Vec3) MutateX(n float32) bool { - return rcv._tab.MutateFloat32(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *Vec3) Y() float32 { - return rcv._tab.GetFloat32(rcv._tab.Pos + flatbuffers.UOffsetT(4)) -} -func (rcv *Vec3) MutateY(n float32) bool { - return rcv._tab.MutateFloat32(rcv._tab.Pos+flatbuffers.UOffsetT(4), n) -} - -func (rcv *Vec3) Z() float32 { - return rcv._tab.GetFloat32(rcv._tab.Pos + flatbuffers.UOffsetT(8)) -} -func (rcv *Vec3) MutateZ(n float32) bool { - return rcv._tab.MutateFloat32(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) -} - -func (rcv *Vec3) Test1() float64 { - return rcv._tab.GetFloat64(rcv._tab.Pos + flatbuffers.UOffsetT(16)) -} -func (rcv *Vec3) MutateTest1(n float64) bool { - return rcv._tab.MutateFloat64(rcv._tab.Pos+flatbuffers.UOffsetT(16), n) -} - -func (rcv *Vec3) Test2() int8 { - return rcv._tab.GetInt8(rcv._tab.Pos + flatbuffers.UOffsetT(24)) -} -func (rcv *Vec3) MutateTest2(n int8) bool { - return rcv._tab.MutateInt8(rcv._tab.Pos+flatbuffers.UOffsetT(24), n) -} - -func (rcv *Vec3) Test3(obj *Test) *Test { - if obj == nil { - obj = new(Test) - } - obj.Init(rcv._tab.Bytes, rcv._tab.Pos+26) - return obj -} - -func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT { - builder.Prep(16, 32) - builder.Pad(2) - builder.Prep(2, 4) - builder.Pad(1) - builder.PrependInt8(test3_b) - builder.PrependInt16(test3_a) - builder.Pad(1) - builder.PrependInt8(test2) - builder.PrependFloat64(test1) - builder.Pad(4) - builder.PrependFloat32(z) - builder.PrependFloat32(y) - builder.PrependFloat32(x) - return builder.Offset() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Vec3.java b/third_party/flatbuffers/tests/MyGame/Example/Vec3.java deleted file mode 100644 index 6cb820b..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Vec3.java +++ /dev/null
@@ -1,45 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class Vec3 extends Struct { - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public float x() { return bb.getFloat(bb_pos + 0); } - public void mutateX(float x) { bb.putFloat(bb_pos + 0, x); } - public float y() { return bb.getFloat(bb_pos + 4); } - public void mutateY(float y) { bb.putFloat(bb_pos + 4, y); } - public float z() { return bb.getFloat(bb_pos + 8); } - public void mutateZ(float z) { bb.putFloat(bb_pos + 8, z); } - public double test1() { return bb.getDouble(bb_pos + 16); } - public void mutateTest1(double test1) { bb.putDouble(bb_pos + 16, test1); } - public byte test2() { return bb.get(bb_pos + 24); } - public void mutateTest2(byte test2) { bb.put(bb_pos + 24, test2); } - public Test test3() { return test3(new Test()); } - public Test test3(Test obj) { return obj.__assign(bb_pos + 26, bb); } - - public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short test3_a, byte test3_b) { - builder.prep(16, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.putByte(test3_b); - builder.putShort(test3_a); - builder.pad(1); - builder.putByte(test2); - builder.putDouble(test1); - builder.pad(4); - builder.putFloat(z); - builder.putFloat(y); - builder.putFloat(x); - return builder.offset(); - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Vec3.php b/third_party/flatbuffers/tests/MyGame/Example/Vec3.php deleted file mode 100644 index ab1a827..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Vec3.php +++ /dev/null
@@ -1,96 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class Vec3 extends Struct -{ - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Vec3 - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return float - */ - public function GetX() - { - return $this->bb->getFloat($this->bb_pos + 0); - } - - /** - * @return float - */ - public function GetY() - { - return $this->bb->getFloat($this->bb_pos + 4); - } - - /** - * @return float - */ - public function GetZ() - { - return $this->bb->getFloat($this->bb_pos + 8); - } - - /** - * @return double - */ - public function GetTest1() - { - return $this->bb->getDouble($this->bb_pos + 16); - } - - /** - * @return sbyte - */ - public function GetTest2() - { - return $this->bb->getSbyte($this->bb_pos + 24); - } - - /** - * @return Test - */ - public function getTest3() - { - $obj = new Test(); - $obj->init($this->bb_pos + 26, $this->bb); - return $obj; - } - - - /** - * @return int offset - */ - public static function createVec3(FlatBufferBuilder $builder, $x, $y, $z, $test1, $test2, $test3_a, $test3_b) - { - $builder->prep(16, 32); - $builder->pad(2); - $builder->prep(2, 4); - $builder->pad(1); - $builder->putSbyte($test3_b); - $builder->putShort($test3_a); - $builder->pad(1); - $builder->putSbyte($test2); - $builder->putDouble($test1); - $builder->pad(4); - $builder->putFloat($z); - $builder->putFloat($y); - $builder->putFloat($x); - return $builder->offset(); - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example/Vec3.py b/third_party/flatbuffers/tests/MyGame/Example/Vec3.py deleted file mode 100644 index a354773..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/Vec3.py +++ /dev/null
@@ -1,44 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example - -import flatbuffers - -class Vec3(object): - __slots__ = ['_tab'] - - # Vec3 - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Vec3 - def X(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)) - # Vec3 - def Y(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4)) - # Vec3 - def Z(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(8)) - # Vec3 - def Test1(self): return self._tab.Get(flatbuffers.number_types.Float64Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(16)) - # Vec3 - def Test2(self): return self._tab.Get(flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(24)) - # Vec3 - def Test3(self, obj): - obj.Init(self._tab.Bytes, self._tab.Pos + 26) - return obj - - -def CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b): - builder.Prep(16, 32) - builder.Pad(2) - builder.Prep(2, 4) - builder.Pad(1) - builder.PrependInt8(test3_b) - builder.PrependInt16(test3_a) - builder.Pad(1) - builder.PrependInt8(test2) - builder.PrependFloat64(test1) - builder.Pad(4) - builder.PrependFloat32(z) - builder.PrependFloat32(y) - builder.PrependFloat32(x) - return builder.Offset()
diff --git a/third_party/flatbuffers/tests/MyGame/Example/__init__.py b/third_party/flatbuffers/tests/MyGame/Example/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example/__init__.py +++ /dev/null
diff --git a/third_party/flatbuffers/tests/MyGame/Example2/Monster.cs b/third_party/flatbuffers/tests/MyGame/Example2/Monster.cs deleted file mode 100644 index 406c4bd..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example2/Monster.cs +++ /dev/null
@@ -1,27 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame.Example2 -{ - -using global::System; -using global::FlatBuffers; - -public struct Monster : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); } - public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - - public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(0); } - public static Offset<Monster> EndMonster(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<Monster>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example2/Monster.go b/third_party/flatbuffers/tests/MyGame/Example2/Monster.go deleted file mode 100644 index 79949b9..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example2/Monster.go +++ /dev/null
@@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package Example2 - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Monster struct { - _tab flatbuffers.Table -} - -func GetRootAsMonster(buf []byte, offset flatbuffers.UOffsetT) *Monster { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Monster{} - x.Init(buf, n+offset) - return x -} - -func (rcv *Monster) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Monster) Table() flatbuffers.Table { - return rcv._tab -} - -func MonsterStart(builder *flatbuffers.Builder) { - builder.StartObject(0) -} -func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example2/Monster.java b/third_party/flatbuffers/tests/MyGame/Example2/Monster.java deleted file mode 100644 index 69a1562..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example2/Monster.java +++ /dev/null
@@ -1,24 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package MyGame.Example2; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class Monster extends Table { - public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); } - public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - - public static void startMonster(FlatBufferBuilder builder) { builder.startObject(0); } - public static int endMonster(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/MyGame/Example2/Monster.php b/third_party/flatbuffers/tests/MyGame/Example2/Monster.php deleted file mode 100644 index b00f150..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example2/Monster.php +++ /dev/null
@@ -1,79 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace MyGame\Example2; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class Monster extends Table -{ - /** - * @param ByteBuffer $bb - * @return Monster - */ - public static function getRootAsMonster(ByteBuffer $bb) - { - $obj = new Monster(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - public static function MonsterIdentifier() - { - return "MONS"; - } - - public static function MonsterBufferHasIdentifier(ByteBuffer $buf) - { - return self::__has_identifier($buf, self::MonsterIdentifier()); - } - - public static function MonsterExtension() - { - return "mon"; - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return Monster - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startMonster(FlatBufferBuilder $builder) - { - $builder->StartObject(0); - } - - /** - * @param FlatBufferBuilder $builder - * @return Monster - */ - public static function createMonster(FlatBufferBuilder $builder, ) - { - $builder->startObject(0); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endMonster(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/MyGame/Example2/Monster.py b/third_party/flatbuffers/tests/MyGame/Example2/Monster.py deleted file mode 100644 index d334f8e..0000000 --- a/third_party/flatbuffers/tests/MyGame/Example2/Monster.py +++ /dev/null
@@ -1,22 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: Example2 - -import flatbuffers - -class Monster(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsMonster(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Monster() - x.Init(buf, n + offset) - return x - - # Monster - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - -def MonsterStart(builder): builder.StartObject(0) -def MonsterEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/MyGame/__init__.py b/third_party/flatbuffers/tests/MyGame/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/flatbuffers/tests/MyGame/__init__.py +++ /dev/null
diff --git a/third_party/flatbuffers/tests/PythonTest.sh b/third_party/flatbuffers/tests/PythonTest.sh deleted file mode 100755 index 00fee7c..0000000 --- a/third_party/flatbuffers/tests/PythonTest.sh +++ /dev/null
@@ -1,79 +0,0 @@ -#!/bin/bash -eu -# -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -pushd "$(dirname $0)" >/dev/null -test_dir="$(pwd)" -gen_code_path=${test_dir} -runtime_library_dir=${test_dir}/../python - -# Emit Python code for the example schema in the test dir: -${test_dir}/../flatc -p -o ${gen_code_path} monster_test.fbs - -# Syntax: run_tests <interpreter> <benchmark vtable dedupes> -# <benchmark read count> <benchmark build count> -interpreters_tested=() -function run_tests() { - if $(which ${1} >/dev/null); then - echo "Testing with interpreter: ${1}" - PYTHONDONTWRITEBYTECODE=1 \ - JYTHONDONTWRITEBYTECODE=1 \ - PYTHONPATH=${runtime_library_dir}:${gen_code_path} \ - JYTHONPATH=${runtime_library_dir}:${gen_code_path} \ - COMPARE_GENERATED_TO_GO=0 \ - COMPARE_GENERATED_TO_JAVA=0 \ - $1 py_test.py $2 $3 $4 - interpreters_tested+=(${1}) - echo - fi -} - -# Run test suite with these interpreters. The arguments are benchmark counts. -run_tests python2.6 100 100 100 -run_tests python2.7 100 100 100 -run_tests python3 100 100 100 -run_tests pypy 100 100 100 - -# NOTE: We'd like to support python2.5 in the future. - -# NOTE: Jython 2.7.0 fails due to a bug in the stdlib `struct` library: -# http://bugs.jython.org/issue2188 - -if [ ${#interpreters_tested[@]} -eq 0 ]; then - echo "No Python interpeters found on this system, could not run tests." - exit 1 -fi - -# Run test suite with default python intereter. -# (If the Python program `coverage` is available, it will be run, too. -# Install `coverage` with `pip install coverage`.) -if $(which coverage >/dev/null); then - echo 'Found coverage utility, running coverage with default Python:' - - PYTHONDONTWRITEBYTECODE=1 \ - PYTHONPATH=${runtime_library_dir}:${gen_code_path} \ - coverage run --source=flatbuffers,MyGame py_test.py 0 0 0 > /dev/null - - echo - cov_result=`coverage report --omit="*flatbuffers/vendor*,*py_test*" \ - | tail -n 1 | awk ' { print $4 } '` - echo "Code coverage: ${cov_result}" -else - echo -n "Did not find coverage utility for default Python, skipping. " - echo "Install with 'pip install coverage'." -fi - -echo -echo "OK: all tests passed for ${#interpreters_tested[@]} interpreters: ${interpreters_tested[@]}."
diff --git a/third_party/flatbuffers/tests/TypeScriptTest.sh b/third_party/flatbuffers/tests/TypeScriptTest.sh deleted file mode 100755 index a5d44d5..0000000 --- a/third_party/flatbuffers/tests/TypeScriptTest.sh +++ /dev/null
@@ -1,23 +0,0 @@ -#!/bin/sh -# -# Copyright 2016 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -pushd "$(dirname $0)" >/dev/null -../flatc --ts --no-fb-import --gen-mutable -o ts monster_test.fbs -../flatc -b monster_test.fbs unicode_test.json -npm install @types/flatbuffers -tsc ts/monster_test_generated.ts -npm uninstall @types/flatbuffers -node JavaScriptTest ./ts/monster_test_generated
diff --git a/third_party/flatbuffers/tests/fuzzer/build_fuzzer.sh b/third_party/flatbuffers/tests/fuzzer/build_fuzzer.sh deleted file mode 100644 index 48eb3b7..0000000 --- a/third_party/flatbuffers/tests/fuzzer/build_fuzzer.sh +++ /dev/null
@@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -git clone https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer -clang++ -c -g -O2 -std=c++11 Fuzzer/*.cpp -IFuzzer -ar ruv libFuzzer.a Fuzzer*.o -rm -rf Fuzzer *.o
diff --git a/third_party/flatbuffers/tests/fuzzer/build_run_parser_test.sh b/third_party/flatbuffers/tests/fuzzer/build_run_parser_test.sh deleted file mode 100644 index 3a053e7..0000000 --- a/third_party/flatbuffers/tests/fuzzer/build_run_parser_test.sh +++ /dev/null
@@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -clang++ -fsanitize-coverage=edge -fsanitize=address -std=c++11 -stdlib=libstdc++ -I.. -I../../include flatbuffers_parser_fuzzer.cc ../../src/idl_parser.cpp ../../src/util.cpp libFuzzer.a -o fuzz_parser -mkdir -p parser_corpus -cp ../*.json ../*.fbs parser_corpus -./fuzz_parser parser_corpus
diff --git a/third_party/flatbuffers/tests/fuzzer/build_run_verifier_test.sh b/third_party/flatbuffers/tests/fuzzer/build_run_verifier_test.sh deleted file mode 100644 index 6761649..0000000 --- a/third_party/flatbuffers/tests/fuzzer/build_run_verifier_test.sh +++ /dev/null
@@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -clang++ -fsanitize-coverage=edge -fsanitize=address -std=c++11 -stdlib=libstdc++ -I.. -I../../include flatbuffers_verifier_fuzzer.cc libFuzzer.a -o fuzz_verifier -mkdir -p verifier_corpus -cp ../*.mon verifier_corpus -./fuzz_verifier verifier_corpus
diff --git a/third_party/flatbuffers/tests/fuzzer/flatbuffers_parser_fuzzer.cc b/third_party/flatbuffers/tests/fuzzer/flatbuffers_parser_fuzzer.cc deleted file mode 100644 index 632b3b1..0000000 --- a/third_party/flatbuffers/tests/fuzzer/flatbuffers_parser_fuzzer.cc +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -#include <stddef.h> -#include <stdint.h> -#include <string> - -#include "flatbuffers/idl.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - flatbuffers::Parser parser; - // Guarantee 0-termination. - std::string s(reinterpret_cast<const char *>(data), size); - parser.Parse(s.c_str()); - return 0; -}
diff --git a/third_party/flatbuffers/tests/fuzzer/flatbuffers_verifier_fuzzer.cc b/third_party/flatbuffers/tests/fuzzer/flatbuffers_verifier_fuzzer.cc deleted file mode 100644 index d7d453c..0000000 --- a/third_party/flatbuffers/tests/fuzzer/flatbuffers_verifier_fuzzer.cc +++ /dev/null
@@ -1,14 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -#include <stddef.h> -#include <stdint.h> -#include <string> - -#include "monster_test_generated.h" - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - flatbuffers::Verifier verifier(data, size); - MyGame::Example::VerifyMonsterBuffer(verifier); - return 0; -}
diff --git a/third_party/flatbuffers/tests/generate_code.bat b/third_party/flatbuffers/tests/generate_code.bat deleted file mode 100644 index e7660a2..0000000 --- a/third_party/flatbuffers/tests/generate_code.bat +++ /dev/null
@@ -1,20 +0,0 @@ -:: Copyright 2015 Google Inc. All rights reserved. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. - -set buildtype=Release -if "%1"=="-b" set buildtype=%2 - -..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --js --php --grpc --gen-mutable --gen-object-api --no-includes monster_test.fbs monsterdata_test.json -..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --js --php --gen-mutable -o namespace_test namespace_test\namespace_test1.fbs namespace_test\namespace_test2.fbs -..\%buildtype%\flatc.exe --binary --schema monster_test.fbs
diff --git a/third_party/flatbuffers/tests/generate_code.sh b/third_party/flatbuffers/tests/generate_code.sh deleted file mode 100755 index bdce840..0000000 --- a/third_party/flatbuffers/tests/generate_code.sh +++ /dev/null
@@ -1,24 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -../flatc --cpp --java --csharp --go --binary --python --js --ts --php --grpc --gen-mutable --gen-object-api --no-includes --no-fb-import monster_test.fbs monsterdata_test.json -../flatc --cpp --java --csharp --go --binary --python --js --ts --php --gen-mutable --no-fb-import -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs -../flatc --cpp --gen-mutable --gen-object-api -o union_vector ./union_vector/union_vector.fbs -../flatc -b --schema --bfbs-comments monster_test.fbs -cd ../samples -../flatc --cpp --gen-mutable --gen-object-api monster.fbs -cd ../reflection -sh generate_code.sh
diff --git a/third_party/flatbuffers/tests/go_test.go b/third_party/flatbuffers/tests/go_test.go deleted file mode 100644 index 2aa375a..0000000 --- a/third_party/flatbuffers/tests/go_test.go +++ /dev/null
@@ -1,1766 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - example "MyGame/Example" // refers to generated code - "bytes" - "flag" - "fmt" - "io/ioutil" - "os" - "reflect" - "sort" - "testing" - - flatbuffers "github.com/google/flatbuffers/go" -) - -var ( - cppData, javaData, outData string - fuzz bool - fuzzFields, fuzzObjects int -) - -func init() { - flag.StringVar(&cppData, "cpp_data", "", - "location of monsterdata_test.mon to verify against (required)") - flag.StringVar(&javaData, "java_data", "", - "location of monsterdata_java_wire.mon to verify against (optional)") - flag.StringVar(&outData, "out_data", "", - "location to write generated Go data") - flag.BoolVar(&fuzz, "fuzz", false, "perform fuzzing") - flag.IntVar(&fuzzFields, "fuzz_fields", 4, "fields per fuzzer object") - flag.IntVar(&fuzzObjects, "fuzz_objects", 10000, - "number of fuzzer objects (higher is slower and more thorough") - flag.Parse() - - if cppData == "" { - fmt.Fprintf(os.Stderr, "cpp_data argument is required\n") - os.Exit(1) - } -} - -// Store specific byte patterns in these variables for the fuzzer. These -// values are taken verbatim from the C++ function FuzzTest1. -var ( - overflowingInt32Val = flatbuffers.GetInt32([]byte{0x83, 0x33, 0x33, 0x33}) - overflowingInt64Val = flatbuffers.GetInt64([]byte{0x84, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44}) -) - -// TestAll runs all checks, failing if any errors occur. -func TestAll(t *testing.T) { - // Verify that the Go FlatBuffers runtime library generates the - // expected bytes (does not use any schema): - CheckByteLayout(t.Fatalf) - CheckMutateMethods(t.Fatalf) - - // Verify that panics are raised during exceptional conditions: - CheckNotInObjectError(t.Fatalf) - CheckStringIsNestedError(t.Fatalf) - CheckByteStringIsNestedError(t.Fatalf) - CheckStructIsNotInlineError(t.Fatalf) - CheckFinishedBytesError(t.Fatalf) - - // Verify that GetRootAs works for non-root tables - CheckGetRootAsForNonRootTable(t.Fatalf) - CheckTableAccessors(t.Fatalf) - - // Verify that using the generated Go code builds a buffer without - // returning errors: - generated, off := CheckGeneratedBuild(t.Fatalf) - - // Verify that the buffer generated by Go code is readable by the - // generated Go code: - CheckReadBuffer(generated, off, t.Fatalf) - CheckMutateBuffer(generated, off, t.Fatalf) - - // Verify that the buffer generated by C++ code is readable by the - // generated Go code: - monsterDataCpp, err := ioutil.ReadFile(cppData) - if err != nil { - t.Fatal(err) - } - CheckReadBuffer(monsterDataCpp, 0, t.Fatalf) - CheckMutateBuffer(monsterDataCpp, 0, t.Fatalf) - - // Verify that vtables are deduplicated when written: - CheckVtableDeduplication(t.Fatalf) - - // Verify the enum names - CheckEnumNames(t.Fatalf) - - // Verify that the Go code used in FlatBuffers documentation passes - // some sanity checks: - CheckDocExample(generated, off, t.Fatalf) - - // Check Builder.CreateByteVector - CheckCreateByteVector(t.Fatalf) - - // If the filename of the FlatBuffers file generated by the Java test - // is given, check that Go code can read it, and that Go code - // generates an identical buffer when used to create the example data: - if javaData != "" { - monsterDataJava, err := ioutil.ReadFile(javaData) - if err != nil { - t.Fatal(err) - } - CheckReadBuffer(monsterDataJava, 0, t.Fatalf) - CheckByteEquality(generated[off:], monsterDataJava, t.Fatalf) - } - - // Verify that various fuzzing scenarios produce a valid FlatBuffer. - if fuzz { - checkFuzz(fuzzFields, fuzzObjects, t.Fatalf) - } - - // Write the generated buffer out to a file: - err = ioutil.WriteFile(outData, generated[off:], os.FileMode(0644)) - if err != nil { - t.Fatal(err) - } -} - -// CheckReadBuffer checks that the given buffer is evaluated correctly -// as the example Monster. -func CheckReadBuffer(buf []byte, offset flatbuffers.UOffsetT, fail func(string, ...interface{})) { - // try the two ways of generating a monster - monster1 := example.GetRootAsMonster(buf, offset) - monster2 := &example.Monster{} - flatbuffers.GetRootAs(buf, offset, monster2) - for _, monster := range []*example.Monster{monster1, monster2} { - if got := monster.Hp(); 80 != got { - fail(FailString("hp", 80, got)) - } - - // default - if got := monster.Mana(); 150 != got { - fail(FailString("mana", 150, got)) - } - - if got := monster.Name(); !bytes.Equal([]byte("MyMonster"), got) { - fail(FailString("name", "MyMonster", got)) - } - - // initialize a Vec3 from Pos() - vec := new(example.Vec3) - vec = monster.Pos(vec) - if vec == nil { - fail("vec3 initialization failed") - } - - // check that new allocs equal given ones: - vec2 := monster.Pos(nil) - if !reflect.DeepEqual(vec, vec2) { - fail("fresh allocation failed") - } - - // verify the properties of the Vec3 - if got := vec.X(); float32(1.0) != got { - fail(FailString("Pos.X", float32(1.0), got)) - } - - if got := vec.Y(); float32(2.0) != got { - fail(FailString("Pos.Y", float32(2.0), got)) - } - - if got := vec.Z(); float32(3.0) != got { - fail(FailString("Pos.Z", float32(3.0), got)) - } - - if got := vec.Test1(); float64(3.0) != got { - fail(FailString("Pos.Test1", float64(3.0), got)) - } - - if got := vec.Test2(); int8(2) != got { - fail(FailString("Pos.Test2", int8(2), got)) - } - - // initialize a Test from Test3(...) - t := new(example.Test) - t = vec.Test3(t) - if t == nil { - fail("vec.Test3(&t) failed") - } - - // check that new allocs equal given ones: - t2 := vec.Test3(nil) - if !reflect.DeepEqual(t, t2) { - fail("fresh allocation failed") - } - - // verify the properties of the Test - if got := t.A(); int16(5) != got { - fail(FailString("t.A()", int16(5), got)) - } - - if got := t.B(); int8(6) != got { - fail(FailString("t.B()", int8(6), got)) - } - - if got := monster.TestType(); example.AnyMonster != got { - fail(FailString("monster.TestType()", example.AnyMonster, got)) - } - - // initialize a Table from a union field Test(...) - var table2 flatbuffers.Table - if ok := monster.Test(&table2); !ok { - fail("monster.Test(&monster2) failed") - } - - // initialize a Monster from the Table from the union - var monster2 example.Monster - monster2.Init(table2.Bytes, table2.Pos) - - if got := monster2.Name(); !bytes.Equal([]byte("Fred"), got) { - fail(FailString("monster2.Name()", "Fred", got)) - } - - inventorySlice := monster.InventoryBytes() - if len(inventorySlice) != monster.InventoryLength() { - fail(FailString("len(monster.InventoryBytes) != monster.InventoryLength", len(inventorySlice), monster.InventoryLength())) - } - - if got := monster.InventoryLength(); 5 != got { - fail(FailString("monster.InventoryLength", 5, got)) - } - - invsum := 0 - l := monster.InventoryLength() - for i := 0; i < l; i++ { - v := monster.Inventory(i) - if v != inventorySlice[i] { - fail(FailString("monster inventory slice[i] != Inventory(i)", v, inventorySlice[i])) - } - invsum += int(v) - } - if invsum != 10 { - fail(FailString("monster inventory sum", 10, invsum)) - } - - if got := monster.Test4Length(); 2 != got { - fail(FailString("monster.Test4Length()", 2, got)) - } - - var test0 example.Test - ok := monster.Test4(&test0, 0) - if !ok { - fail(FailString("monster.Test4(&test0, 0)", true, ok)) - } - - var test1 example.Test - ok = monster.Test4(&test1, 1) - if !ok { - fail(FailString("monster.Test4(&test1, 1)", true, ok)) - } - - // the position of test0 and test1 are swapped in monsterdata_java_wire - // and monsterdata_test_wire, so ignore ordering - v0 := test0.A() - v1 := test0.B() - v2 := test1.A() - v3 := test1.B() - sum := int(v0) + int(v1) + int(v2) + int(v3) - - if 100 != sum { - fail(FailString("test0 and test1 sum", 100, sum)) - } - - if got := monster.TestarrayofstringLength(); 2 != got { - fail(FailString("Testarrayofstring length", 2, got)) - } - - if got := monster.Testarrayofstring(0); !bytes.Equal([]byte("test1"), got) { - fail(FailString("Testarrayofstring(0)", "test1", got)) - } - - if got := monster.Testarrayofstring(1); !bytes.Equal([]byte("test2"), got) { - fail(FailString("Testarrayofstring(1)", "test2", got)) - } - } -} - -// CheckMutateBuffer checks that the given buffer can be mutated correctly -// as the example Monster. Only available scalar values are mutated. -func CheckMutateBuffer(org []byte, offset flatbuffers.UOffsetT, fail func(string, ...interface{})) { - // make a copy to mutate - buf := make([]byte, len(org)) - copy(buf, org) - - // load monster data from the buffer - monster := example.GetRootAsMonster(buf, offset) - - // test case struct - type testcase struct { - field string - testfn func() bool - } - - testForOriginalValues := []testcase{ - testcase{"Hp", func() bool { return monster.Hp() == 80 }}, - testcase{"Mana", func() bool { return monster.Mana() == 150 }}, - testcase{"Pos.X'", func() bool { return monster.Pos(nil).X() == float32(1.0) }}, - testcase{"Pos.Y'", func() bool { return monster.Pos(nil).Y() == float32(2.0) }}, - testcase{"Pos.Z'", func() bool { return monster.Pos(nil).Z() == float32(3.0) }}, - testcase{"Pos.Test1'", func() bool { return monster.Pos(nil).Test1() == float64(3.0) }}, - testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == int8(2) }}, - testcase{"Pos.Test3.A", func() bool { return monster.Pos(nil).Test3(nil).A() == int16(5) }}, - testcase{"Pos.Test3.B", func() bool { return monster.Pos(nil).Test3(nil).B() == int8(6) }}, - } - - testMutability := []testcase{ - testcase{"Hp", func() bool { return monster.MutateHp(70) }}, - testcase{"Mana", func() bool { return !monster.MutateMana(140) }}, - testcase{"Pos.X", func() bool { return monster.Pos(nil).MutateX(10.0) }}, - testcase{"Pos.Y", func() bool { return monster.Pos(nil).MutateY(20.0) }}, - testcase{"Pos.Z", func() bool { return monster.Pos(nil).MutateZ(30.0) }}, - testcase{"Pos.Test1", func() bool { return monster.Pos(nil).MutateTest1(30.0) }}, - testcase{"Pos.Test2", func() bool { return monster.Pos(nil).MutateTest2(20) }}, - testcase{"Pos.Test3.A", func() bool { return monster.Pos(nil).Test3(nil).MutateA(50) }}, - testcase{"Pos.Test3.B", func() bool { return monster.Pos(nil).Test3(nil).MutateB(60) }}, - } - - testForMutatedValues := []testcase{ - testcase{"Hp", func() bool { return monster.Hp() == 70 }}, - testcase{"Mana", func() bool { return monster.Mana() == 150 }}, - testcase{"Pos.X'", func() bool { return monster.Pos(nil).X() == float32(10.0) }}, - testcase{"Pos.Y'", func() bool { return monster.Pos(nil).Y() == float32(20.0) }}, - testcase{"Pos.Z'", func() bool { return monster.Pos(nil).Z() == float32(30.0) }}, - testcase{"Pos.Test1'", func() bool { return monster.Pos(nil).Test1() == float64(30.0) }}, - testcase{"Pos.Test2'", func() bool { return monster.Pos(nil).Test2() == int8(20) }}, - testcase{"Pos.Test3.A", func() bool { return monster.Pos(nil).Test3(nil).A() == int16(50) }}, - testcase{"Pos.Test3.B", func() bool { return monster.Pos(nil).Test3(nil).B() == int8(60) }}, - } - - // make sure original values are okay - for _, t := range testForOriginalValues { - if !t.testfn() { - fail("field '" + t.field + "' doesn't have the expected original value") - } - } - - // try to mutate fields and check mutability - for _, t := range testMutability { - if !t.testfn() { - fail(FailString("field '"+t.field+"' failed mutability test", true, false)) - } - } - - // test whether values have changed - for _, t := range testForMutatedValues { - if !t.testfn() { - fail("field '" + t.field + "' doesn't have the expected mutated value") - } - } - - // make sure the buffer has changed - if reflect.DeepEqual(buf, org) { - fail("mutate buffer failed") - } - - // To make sure the buffer has changed accordingly - // Read data from the buffer and verify all fields - monster = example.GetRootAsMonster(buf, offset) - for _, t := range testForMutatedValues { - if !t.testfn() { - fail("field '" + t.field + "' doesn't have the expected mutated value") - } - } - - // reverting all fields to original values should - // re-create the original buffer. Mutate all fields - // back to their original values and compare buffers. - // This test is done to make sure mutations do not do - // any unnecessary changes to the buffer. - monster = example.GetRootAsMonster(buf, offset) - monster.MutateHp(80) - monster.Pos(nil).MutateX(1.0) - monster.Pos(nil).MutateY(2.0) - monster.Pos(nil).MutateZ(3.0) - monster.Pos(nil).MutateTest1(3.0) - monster.Pos(nil).MutateTest2(2) - monster.Pos(nil).Test3(nil).MutateA(5) - monster.Pos(nil).Test3(nil).MutateB(6) - - for _, t := range testForOriginalValues { - if !t.testfn() { - fail("field '" + t.field + "' doesn't have the expected original value") - } - } - - // buffer should have original values - if !reflect.DeepEqual(buf, org) { - fail("revert changes failed") - } -} - -// Low level stress/fuzz test: serialize/deserialize a variety of -// different kinds of data in different combinations -func checkFuzz(fuzzFields, fuzzObjects int, fail func(string, ...interface{})) { - - // Values we're testing against: chosen to ensure no bits get chopped - // off anywhere, and also be different from eachother. - boolVal := true - int8Val := int8(-127) // 0x81 - uint8Val := uint8(0xFF) - int16Val := int16(-32222) // 0x8222 - uint16Val := uint16(0xFEEE) - int32Val := int32(overflowingInt32Val) - uint32Val := uint32(0xFDDDDDDD) - int64Val := int64(overflowingInt64Val) - uint64Val := uint64(0xFCCCCCCCCCCCCCCC) - float32Val := float32(3.14159) - float64Val := float64(3.14159265359) - - testValuesMax := 11 // hardcoded to the number of scalar types - - builder := flatbuffers.NewBuilder(0) - l := NewLCG() - - objects := make([]flatbuffers.UOffsetT, fuzzObjects) - - // Generate fuzzObjects random objects each consisting of - // fuzzFields fields, each of a random type. - for i := 0; i < fuzzObjects; i++ { - builder.StartObject(fuzzFields) - - for f := 0; f < fuzzFields; f++ { - choice := l.Next() % uint32(testValuesMax) - switch choice { - case 0: - builder.PrependBoolSlot(int(f), boolVal, false) - case 1: - builder.PrependInt8Slot(int(f), int8Val, 0) - case 2: - builder.PrependUint8Slot(int(f), uint8Val, 0) - case 3: - builder.PrependInt16Slot(int(f), int16Val, 0) - case 4: - builder.PrependUint16Slot(int(f), uint16Val, 0) - case 5: - builder.PrependInt32Slot(int(f), int32Val, 0) - case 6: - builder.PrependUint32Slot(int(f), uint32Val, 0) - case 7: - builder.PrependInt64Slot(int(f), int64Val, 0) - case 8: - builder.PrependUint64Slot(int(f), uint64Val, 0) - case 9: - builder.PrependFloat32Slot(int(f), float32Val, 0) - case 10: - builder.PrependFloat64Slot(int(f), float64Val, 0) - } - } - - off := builder.EndObject() - - // store the offset from the end of the builder buffer, - // since it will keep growing: - objects[i] = off - } - - // Do some bookkeeping to generate stats on fuzzes: - stats := map[string]int{} - check := func(desc string, want, got interface{}) { - stats[desc]++ - if want != got { - fail("%s want %v got %v", desc, want, got) - } - } - - l = NewLCG() // Reset. - - // Test that all objects we generated are readable and return the - // expected values. We generate random objects in the same order - // so this is deterministic. - for i := 0; i < fuzzObjects; i++ { - - table := &flatbuffers.Table{ - Bytes: builder.Bytes, - Pos: flatbuffers.UOffsetT(len(builder.Bytes)) - objects[i], - } - - for j := 0; j < fuzzFields; j++ { - f := flatbuffers.VOffsetT((flatbuffers.VtableMetadataFields + j) * flatbuffers.SizeVOffsetT) - choice := l.Next() % uint32(testValuesMax) - - switch choice { - case 0: - check("bool", boolVal, table.GetBoolSlot(f, false)) - case 1: - check("int8", int8Val, table.GetInt8Slot(f, 0)) - case 2: - check("uint8", uint8Val, table.GetUint8Slot(f, 0)) - case 3: - check("int16", int16Val, table.GetInt16Slot(f, 0)) - case 4: - check("uint16", uint16Val, table.GetUint16Slot(f, 0)) - case 5: - check("int32", int32Val, table.GetInt32Slot(f, 0)) - case 6: - check("uint32", uint32Val, table.GetUint32Slot(f, 0)) - case 7: - check("int64", int64Val, table.GetInt64Slot(f, 0)) - case 8: - check("uint64", uint64Val, table.GetUint64Slot(f, 0)) - case 9: - check("float32", float32Val, table.GetFloat32Slot(f, 0)) - case 10: - check("float64", float64Val, table.GetFloat64Slot(f, 0)) - } - } - } - - // If enough checks were made, verify that all scalar types were used: - if fuzzFields*fuzzObjects >= testValuesMax { - if len(stats) != testValuesMax { - fail("fuzzing failed to test all scalar types") - } - } - - // Print some counts, if needed: - if testing.Verbose() { - if fuzzFields == 0 || fuzzObjects == 0 { - fmt.Printf("fuzz\tfields: %d\tobjects: %d\t[none]\t%d\n", - fuzzFields, fuzzObjects, 0) - } else { - keys := make([]string, 0, len(stats)) - for k := range stats { - keys = append(keys, k) - } - sort.Strings(keys) - for _, k := range keys { - fmt.Printf("fuzz\tfields: %d\tobjects: %d\t%s\t%d\n", - fuzzFields, fuzzObjects, k, stats[k]) - } - } - } - - return -} - -// FailString makes a message for when expectations differ from reality. -func FailString(name string, want, got interface{}) string { - return fmt.Sprintf("bad %s: want %#v got %#v", name, want, got) -} - -// CheckByteLayout verifies the bytes of a Builder in various scenarios. -func CheckByteLayout(fail func(string, ...interface{})) { - var b *flatbuffers.Builder - - var i int - check := func(want []byte) { - i++ - got := b.Bytes[b.Head():] - if !bytes.Equal(want, got) { - fail("case %d: want\n%v\nbut got\n%v\n", i, want, got) - } - } - - // test 1: numbers - - b = flatbuffers.NewBuilder(0) - check([]byte{}) - b.PrependBool(true) - check([]byte{1}) - b.PrependInt8(-127) - check([]byte{129, 1}) - b.PrependUint8(255) - check([]byte{255, 129, 1}) - b.PrependInt16(-32222) - check([]byte{0x22, 0x82, 0, 255, 129, 1}) // first pad - b.PrependUint16(0xFEEE) - check([]byte{0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1}) // no pad this time - b.PrependInt32(-53687092) - check([]byte{204, 204, 204, 252, 0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1}) - b.PrependUint32(0x98765432) - check([]byte{0x32, 0x54, 0x76, 0x98, 204, 204, 204, 252, 0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1}) - - // test 1b: numbers 2 - - b = flatbuffers.NewBuilder(0) - b.PrependUint64(0x1122334455667788) - check([]byte{0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11}) - - // test 2: 1xbyte vector - - b = flatbuffers.NewBuilder(0) - check([]byte{}) - b.StartVector(flatbuffers.SizeByte, 1, 1) - check([]byte{0, 0, 0}) // align to 4bytes - b.PrependByte(1) - check([]byte{1, 0, 0, 0}) - b.EndVector(1) - check([]byte{1, 0, 0, 0, 1, 0, 0, 0}) // padding - - // test 3: 2xbyte vector - - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeByte, 2, 1) - check([]byte{0, 0}) // align to 4bytes - b.PrependByte(1) - check([]byte{1, 0, 0}) - b.PrependByte(2) - check([]byte{2, 1, 0, 0}) - b.EndVector(2) - check([]byte{2, 0, 0, 0, 2, 1, 0, 0}) // padding - - // test 3b: 11xbyte vector matches builder size - - b = flatbuffers.NewBuilder(12) - b.StartVector(flatbuffers.SizeByte, 8, 1) - start := []byte{} - check(start) - for i := 1; i < 12; i++ { - b.PrependByte(byte(i)) - start = append([]byte{byte(i)}, start...) - check(start) - } - b.EndVector(8) - check(append([]byte{8, 0, 0, 0}, start...)) - - // test 4: 1xuint16 vector - - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeUint16, 1, 1) - check([]byte{0, 0}) // align to 4bytes - b.PrependUint16(1) - check([]byte{1, 0, 0, 0}) - b.EndVector(1) - check([]byte{1, 0, 0, 0, 1, 0, 0, 0}) // padding - - // test 5: 2xuint16 vector - - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeUint16, 2, 1) - check([]byte{}) // align to 4bytes - b.PrependUint16(0xABCD) - check([]byte{0xCD, 0xAB}) - b.PrependUint16(0xDCBA) - check([]byte{0xBA, 0xDC, 0xCD, 0xAB}) - b.EndVector(2) - check([]byte{2, 0, 0, 0, 0xBA, 0xDC, 0xCD, 0xAB}) - - // test 6: CreateString - - b = flatbuffers.NewBuilder(0) - b.CreateString("foo") - check([]byte{3, 0, 0, 0, 'f', 'o', 'o', 0}) // 0-terminated, no pad - b.CreateString("moop") - check([]byte{4, 0, 0, 0, 'm', 'o', 'o', 'p', 0, 0, 0, 0, // 0-terminated, 3-byte pad - 3, 0, 0, 0, 'f', 'o', 'o', 0}) - - // test 6b: CreateString unicode - - b = flatbuffers.NewBuilder(0) - // These characters are chinese from blog.golang.org/strings - // We use escape codes here so that editors without unicode support - // aren't bothered: - uni_str := "\u65e5\u672c\u8a9e" - b.CreateString(uni_str) - check([]byte{9, 0, 0, 0, 230, 151, 165, 230, 156, 172, 232, 170, 158, 0, // null-terminated, 2-byte pad - 0, 0}) - - // test 6c: CreateByteString - - b = flatbuffers.NewBuilder(0) - b.CreateByteString([]byte("foo")) - check([]byte{3, 0, 0, 0, 'f', 'o', 'o', 0}) // 0-terminated, no pad - b.CreateByteString([]byte("moop")) - check([]byte{4, 0, 0, 0, 'm', 'o', 'o', 'p', 0, 0, 0, 0, // 0-terminated, 3-byte pad - 3, 0, 0, 0, 'f', 'o', 'o', 0}) - - // test 7: empty vtable - b = flatbuffers.NewBuilder(0) - b.StartObject(0) - check([]byte{}) - b.EndObject() - check([]byte{4, 0, 4, 0, 4, 0, 0, 0}) - - // test 8: vtable with one true bool - b = flatbuffers.NewBuilder(0) - check([]byte{}) - b.StartObject(1) - check([]byte{}) - b.PrependBoolSlot(0, true, false) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 8, 0, // length of object including vtable offset - 7, 0, // start of bool value - 6, 0, 0, 0, // offset for start of vtable (int32) - 0, 0, 0, // padded to 4 bytes - 1, // bool value - }) - - // test 9: vtable with one default bool - b = flatbuffers.NewBuilder(0) - check([]byte{}) - b.StartObject(1) - check([]byte{}) - b.PrependBoolSlot(0, false, false) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 4, 0, // end of object from here - 0, 0, // entry 1 is zero - 6, 0, 0, 0, // offset for start of vtable (int32) - }) - - // test 10: vtable with one int16 - b = flatbuffers.NewBuilder(0) - b.StartObject(1) - b.PrependInt16Slot(0, 0x789A, 0) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 8, 0, // end of object from here - 6, 0, // offset to value - 6, 0, 0, 0, // offset for start of vtable (int32) - 0, 0, // padding to 4 bytes - 0x9A, 0x78, - }) - - // test 11: vtable with two int16 - b = flatbuffers.NewBuilder(0) - b.StartObject(2) - b.PrependInt16Slot(0, 0x3456, 0) - b.PrependInt16Slot(1, 0x789A, 0) - b.EndObject() - check([]byte{ - 8, 0, // vtable bytes - 8, 0, // end of object from here - 6, 0, // offset to value 0 - 4, 0, // offset to value 1 - 8, 0, 0, 0, // offset for start of vtable (int32) - 0x9A, 0x78, // value 1 - 0x56, 0x34, // value 0 - }) - - // test 12: vtable with int16 and bool - b = flatbuffers.NewBuilder(0) - b.StartObject(2) - b.PrependInt16Slot(0, 0x3456, 0) - b.PrependBoolSlot(1, true, false) - b.EndObject() - check([]byte{ - 8, 0, // vtable bytes - 8, 0, // end of object from here - 6, 0, // offset to value 0 - 5, 0, // offset to value 1 - 8, 0, 0, 0, // offset for start of vtable (int32) - 0, // padding - 1, // value 1 - 0x56, 0x34, // value 0 - }) - - // test 12: vtable with empty vector - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeByte, 0, 1) - vecend := b.EndVector(0) - b.StartObject(1) - b.PrependUOffsetTSlot(0, vecend, 0) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 8, 0, - 4, 0, // offset to vector offset - 6, 0, 0, 0, // offset for start of vtable (int32) - 4, 0, 0, 0, - 0, 0, 0, 0, // length of vector (not in struct) - }) - - // test 12b: vtable with empty vector of byte and some scalars - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeByte, 0, 1) - vecend = b.EndVector(0) - b.StartObject(2) - b.PrependInt16Slot(0, 55, 0) - b.PrependUOffsetTSlot(1, vecend, 0) - b.EndObject() - check([]byte{ - 8, 0, // vtable bytes - 12, 0, - 10, 0, // offset to value 0 - 4, 0, // offset to vector offset - 8, 0, 0, 0, // vtable loc - 8, 0, 0, 0, // value 1 - 0, 0, 55, 0, // value 0 - - 0, 0, 0, 0, // length of vector (not in struct) - }) - - // test 13: vtable with 1 int16 and 2-vector of int16 - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeInt16, 2, 1) - b.PrependInt16(0x1234) - b.PrependInt16(0x5678) - vecend = b.EndVector(2) - b.StartObject(2) - b.PrependUOffsetTSlot(1, vecend, 0) - b.PrependInt16Slot(0, 55, 0) - b.EndObject() - check([]byte{ - 8, 0, // vtable bytes - 12, 0, // length of object - 6, 0, // start of value 0 from end of vtable - 8, 0, // start of value 1 from end of buffer - 8, 0, 0, 0, // offset for start of vtable (int32) - 0, 0, // padding - 55, 0, // value 0 - 4, 0, 0, 0, // vector position from here - 2, 0, 0, 0, // length of vector (uint32) - 0x78, 0x56, // vector value 1 - 0x34, 0x12, // vector value 0 - }) - - // test 14: vtable with 1 struct of 1 int8, 1 int16, 1 int32 - b = flatbuffers.NewBuilder(0) - b.StartObject(1) - b.Prep(4+4+4, 0) - b.PrependInt8(55) - b.Pad(3) - b.PrependInt16(0x1234) - b.Pad(2) - b.PrependInt32(0x12345678) - structStart := b.Offset() - b.PrependStructSlot(0, structStart, 0) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 16, 0, // end of object from here - 4, 0, // start of struct from here - 6, 0, 0, 0, // offset for start of vtable (int32) - 0x78, 0x56, 0x34, 0x12, // value 2 - 0, 0, // padding - 0x34, 0x12, // value 1 - 0, 0, 0, // padding - 55, // value 0 - }) - - // test 15: vtable with 1 vector of 2 struct of 2 int8 - b = flatbuffers.NewBuilder(0) - b.StartVector(flatbuffers.SizeInt8*2, 2, 1) - b.PrependInt8(33) - b.PrependInt8(44) - b.PrependInt8(55) - b.PrependInt8(66) - vecend = b.EndVector(2) - b.StartObject(1) - b.PrependUOffsetTSlot(0, vecend, 0) - b.EndObject() - check([]byte{ - 6, 0, // vtable bytes - 8, 0, - 4, 0, // offset of vector offset - 6, 0, 0, 0, // offset for start of vtable (int32) - 4, 0, 0, 0, // vector start offset - - 2, 0, 0, 0, // vector length - 66, // vector value 1,1 - 55, // vector value 1,0 - 44, // vector value 0,1 - 33, // vector value 0,0 - }) - - // test 16: table with some elements - b = flatbuffers.NewBuilder(0) - b.StartObject(2) - b.PrependInt8Slot(0, 33, 0) - b.PrependInt16Slot(1, 66, 0) - off := b.EndObject() - b.Finish(off) - - check([]byte{ - 12, 0, 0, 0, // root of table: points to vtable offset - - 8, 0, // vtable bytes - 8, 0, // end of object from here - 7, 0, // start of value 0 - 4, 0, // start of value 1 - - 8, 0, 0, 0, // offset for start of vtable (int32) - - 66, 0, // value 1 - 0, // padding - 33, // value 0 - }) - - // test 17: one unfinished table and one finished table - b = flatbuffers.NewBuilder(0) - b.StartObject(2) - b.PrependInt8Slot(0, 33, 0) - b.PrependInt8Slot(1, 44, 0) - off = b.EndObject() - b.Finish(off) - - b.StartObject(3) - b.PrependInt8Slot(0, 55, 0) - b.PrependInt8Slot(1, 66, 0) - b.PrependInt8Slot(2, 77, 0) - off = b.EndObject() - b.Finish(off) - - check([]byte{ - 16, 0, 0, 0, // root of table: points to object - 0, 0, // padding - - 10, 0, // vtable bytes - 8, 0, // size of object - 7, 0, // start of value 0 - 6, 0, // start of value 1 - 5, 0, // start of value 2 - 10, 0, 0, 0, // offset for start of vtable (int32) - 0, // padding - 77, // value 2 - 66, // value 1 - 55, // value 0 - - 12, 0, 0, 0, // root of table: points to object - - 8, 0, // vtable bytes - 8, 0, // size of object - 7, 0, // start of value 0 - 6, 0, // start of value 1 - 8, 0, 0, 0, // offset for start of vtable (int32) - 0, 0, // padding - 44, // value 1 - 33, // value 0 - }) - - // test 18: a bunch of bools - b = flatbuffers.NewBuilder(0) - b.StartObject(8) - b.PrependBoolSlot(0, true, false) - b.PrependBoolSlot(1, true, false) - b.PrependBoolSlot(2, true, false) - b.PrependBoolSlot(3, true, false) - b.PrependBoolSlot(4, true, false) - b.PrependBoolSlot(5, true, false) - b.PrependBoolSlot(6, true, false) - b.PrependBoolSlot(7, true, false) - off = b.EndObject() - b.Finish(off) - - check([]byte{ - 24, 0, 0, 0, // root of table: points to vtable offset - - 20, 0, // vtable bytes - 12, 0, // size of object - 11, 0, // start of value 0 - 10, 0, // start of value 1 - 9, 0, // start of value 2 - 8, 0, // start of value 3 - 7, 0, // start of value 4 - 6, 0, // start of value 5 - 5, 0, // start of value 6 - 4, 0, // start of value 7 - 20, 0, 0, 0, // vtable offset - - 1, // value 7 - 1, // value 6 - 1, // value 5 - 1, // value 4 - 1, // value 3 - 1, // value 2 - 1, // value 1 - 1, // value 0 - }) - - // test 19: three bools - b = flatbuffers.NewBuilder(0) - b.StartObject(3) - b.PrependBoolSlot(0, true, false) - b.PrependBoolSlot(1, true, false) - b.PrependBoolSlot(2, true, false) - off = b.EndObject() - b.Finish(off) - - check([]byte{ - 16, 0, 0, 0, // root of table: points to vtable offset - - 0, 0, // padding - - 10, 0, // vtable bytes - 8, 0, // size of object - 7, 0, // start of value 0 - 6, 0, // start of value 1 - 5, 0, // start of value 2 - 10, 0, 0, 0, // vtable offset from here - - 0, // padding - 1, // value 2 - 1, // value 1 - 1, // value 0 - }) - - // test 20: some floats - b = flatbuffers.NewBuilder(0) - b.StartObject(1) - b.PrependFloat32Slot(0, 1.0, 0.0) - off = b.EndObject() - - check([]byte{ - 6, 0, // vtable bytes - 8, 0, // size of object - 4, 0, // start of value 0 - 6, 0, 0, 0, // vtable offset - - 0, 0, 128, 63, // value 0 - }) -} - -// CheckManualBuild builds a Monster manually. -func CheckManualBuild(fail func(string, ...interface{})) ([]byte, flatbuffers.UOffsetT) { - b := flatbuffers.NewBuilder(0) - str := b.CreateString("MyMonster") - - b.StartVector(1, 5, 1) - b.PrependByte(4) - b.PrependByte(3) - b.PrependByte(2) - b.PrependByte(1) - b.PrependByte(0) - inv := b.EndVector(5) - - b.StartObject(13) - b.PrependInt16Slot(2, 20, 100) - mon2 := b.EndObject() - - // Test4Vector - b.StartVector(4, 2, 1) - - // Test 0 - b.Prep(2, 4) - b.Pad(1) - b.PlaceInt8(20) - b.PlaceInt16(10) - - // Test 1 - b.Prep(2, 4) - b.Pad(1) - b.PlaceInt8(40) - b.PlaceInt16(30) - - // end testvector - test4 := b.EndVector(2) - - b.StartObject(13) - - // a vec3 - b.Prep(16, 32) - b.Pad(2) - b.Prep(2, 4) - b.Pad(1) - b.PlaceByte(6) - b.PlaceInt16(5) - b.Pad(1) - b.PlaceByte(4) - b.PlaceFloat64(3.0) - b.Pad(4) - b.PlaceFloat32(3.0) - b.PlaceFloat32(2.0) - b.PlaceFloat32(1.0) - vec3Loc := b.Offset() - // end vec3 - - b.PrependStructSlot(0, vec3Loc, 0) // vec3. noop - b.PrependInt16Slot(2, 80, 100) // hp - b.PrependUOffsetTSlot(3, str, 0) - b.PrependUOffsetTSlot(5, inv, 0) // inventory - b.PrependByteSlot(7, 1, 0) - b.PrependUOffsetTSlot(8, mon2, 0) - b.PrependUOffsetTSlot(9, test4, 0) - mon := b.EndObject() - - b.Finish(mon) - - return b.Bytes, b.Head() -} - -func CheckGetRootAsForNonRootTable(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - str := b.CreateString("MyStat") - example.StatStart(b) - example.StatAddId(b, str) - example.StatAddVal(b, 12345678) - example.StatAddCount(b, 12345) - stat_end := example.StatEnd(b) - b.Finish(stat_end) - - stat := example.GetRootAsStat(b.Bytes, b.Head()) - - if got := stat.Id(); !bytes.Equal([]byte("MyStat"), got) { - fail(FailString("stat.Id()", "MyStat", got)) - } - - if got := stat.Val(); 12345678 != got { - fail(FailString("stat.Val()", 12345678, got)) - } - - if got := stat.Count(); 12345 != got { - fail(FailString("stat.Count()", 12345, got)) - } -} - -// CheckGeneratedBuild uses generated code to build the example Monster. -func CheckGeneratedBuild(fail func(string, ...interface{})) ([]byte, flatbuffers.UOffsetT) { - b := flatbuffers.NewBuilder(0) - str := b.CreateString("MyMonster") - test1 := b.CreateString("test1") - test2 := b.CreateString("test2") - fred := b.CreateString("Fred") - - example.MonsterStartInventoryVector(b, 5) - b.PrependByte(4) - b.PrependByte(3) - b.PrependByte(2) - b.PrependByte(1) - b.PrependByte(0) - inv := b.EndVector(5) - - example.MonsterStart(b) - example.MonsterAddName(b, fred) - mon2 := example.MonsterEnd(b) - - example.MonsterStartTest4Vector(b, 2) - example.CreateTest(b, 10, 20) - example.CreateTest(b, 30, 40) - test4 := b.EndVector(2) - - example.MonsterStartTestarrayofstringVector(b, 2) - b.PrependUOffsetT(test2) - b.PrependUOffsetT(test1) - testArrayOfString := b.EndVector(2) - - example.MonsterStart(b) - - pos := example.CreateVec3(b, 1.0, 2.0, 3.0, 3.0, 2, 5, 6) - example.MonsterAddPos(b, pos) - - example.MonsterAddHp(b, 80) - example.MonsterAddName(b, str) - example.MonsterAddInventory(b, inv) - example.MonsterAddTestType(b, 1) - example.MonsterAddTest(b, mon2) - example.MonsterAddTest4(b, test4) - example.MonsterAddTestarrayofstring(b, testArrayOfString) - mon := example.MonsterEnd(b) - - b.Finish(mon) - - return b.Bytes, b.Head() -} - -// CheckTableAccessors checks that the table accessors work as expected. -func CheckTableAccessors(fail func(string, ...interface{})) { - // test struct accessor - b := flatbuffers.NewBuilder(0) - pos := example.CreateVec3(b, 1.0, 2.0, 3.0, 3.0, 4, 5, 6) - b.Finish(pos) - vec3Bytes := b.FinishedBytes() - vec3 := &example.Vec3{} - flatbuffers.GetRootAs(vec3Bytes, 0, vec3) - - if bytes.Compare(vec3Bytes, vec3.Table().Bytes) != 0 { - fail("invalid vec3 table") - } - - // test table accessor - b = flatbuffers.NewBuilder(0) - str := b.CreateString("MyStat") - example.StatStart(b) - example.StatAddId(b, str) - example.StatAddVal(b, 12345678) - example.StatAddCount(b, 12345) - pos = example.StatEnd(b) - b.Finish(pos) - statBytes := b.FinishedBytes() - stat := &example.Stat{} - flatbuffers.GetRootAs(statBytes, 0, stat) - - if bytes.Compare(statBytes, stat.Table().Bytes) != 0 { - fail("invalid stat table") - } -} - -// CheckVtableDeduplication verifies that vtables are deduplicated. -func CheckVtableDeduplication(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 11, 0) - b.PrependByteSlot(2, 22, 0) - b.PrependInt16Slot(3, 33, 0) - obj0 := b.EndObject() - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 44, 0) - b.PrependByteSlot(2, 55, 0) - b.PrependInt16Slot(3, 66, 0) - obj1 := b.EndObject() - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 77, 0) - b.PrependByteSlot(2, 88, 0) - b.PrependInt16Slot(3, 99, 0) - obj2 := b.EndObject() - - got := b.Bytes[b.Head():] - - want := []byte{ - 240, 255, 255, 255, // == -12. offset to dedupped vtable. - 99, 0, - 88, - 77, - 248, 255, 255, 255, // == -8. offset to dedupped vtable. - 66, 0, - 55, - 44, - 12, 0, - 8, 0, - 0, 0, - 7, 0, - 6, 0, - 4, 0, - 12, 0, 0, 0, - 33, 0, - 22, - 11, - } - - if !bytes.Equal(want, got) { - fail("testVtableDeduplication want:\n%d %v\nbut got:\n%d %v\n", - len(want), want, len(got), got) - } - - table0 := &flatbuffers.Table{Bytes: b.Bytes, Pos: flatbuffers.UOffsetT(len(b.Bytes)) - obj0} - table1 := &flatbuffers.Table{Bytes: b.Bytes, Pos: flatbuffers.UOffsetT(len(b.Bytes)) - obj1} - table2 := &flatbuffers.Table{Bytes: b.Bytes, Pos: flatbuffers.UOffsetT(len(b.Bytes)) - obj2} - - testTable := func(tab *flatbuffers.Table, a flatbuffers.VOffsetT, b, c, d byte) { - // vtable size - if got := tab.GetVOffsetTSlot(0, 0); 12 != got { - fail("failed 0, 0: %d", got) - } - // object size - if got := tab.GetVOffsetTSlot(2, 0); 8 != got { - fail("failed 2, 0: %d", got) - } - // default value - if got := tab.GetVOffsetTSlot(4, 0); a != got { - fail("failed 4, 0: %d", got) - } - if got := tab.GetByteSlot(6, 0); b != got { - fail("failed 6, 0: %d", got) - } - if val := tab.GetByteSlot(8, 0); c != val { - fail("failed 8, 0: %d", got) - } - if got := tab.GetByteSlot(10, 0); d != got { - fail("failed 10, 0: %d", got) - } - } - - testTable(table0, 0, 11, 22, 33) - testTable(table1, 0, 44, 55, 66) - testTable(table2, 0, 77, 88, 99) -} - -// CheckNotInObjectError verifies that `EndObject` fails if not inside an -// object. -func CheckNotInObjectError(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - - defer func() { - r := recover() - if r == nil { - fail("expected panic in CheckNotInObjectError") - } - }() - b.EndObject() -} - -// CheckStringIsNestedError verifies that a string can not be created inside -// another object. -func CheckStringIsNestedError(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - b.StartObject(0) - defer func() { - r := recover() - if r == nil { - fail("expected panic in CheckStringIsNestedError") - } - }() - b.CreateString("foo") -} - -// CheckByteStringIsNestedError verifies that a bytestring can not be created -// inside another object. -func CheckByteStringIsNestedError(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - b.StartObject(0) - defer func() { - r := recover() - if r == nil { - fail("expected panic in CheckByteStringIsNestedError") - } - }() - b.CreateByteString([]byte("foo")) -} - -// CheckStructIsNotInlineError verifies that writing a struct in a location -// away from where it is used will cause a panic. -func CheckStructIsNotInlineError(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - b.StartObject(0) - defer func() { - r := recover() - if r == nil { - fail("expected panic in CheckStructIsNotInlineError") - } - }() - b.PrependStructSlot(0, 1, 0) -} - -// CheckFinishedBytesError verifies that `FinishedBytes` panics if the table -// is not finished. -func CheckFinishedBytesError(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - - defer func() { - r := recover() - if r == nil { - fail("expected panic in CheckFinishedBytesError") - } - }() - b.FinishedBytes() -} - -// CheckEnumNames checks that the generated enum names are correct. -func CheckEnumNames(fail func(string, ...interface{})) { - type testEnumNames struct { - EnumNames map[int]string - Expected map[int]string - } - data := [...]testEnumNames{ - {example.EnumNamesAny, - map[int]string{ - example.AnyNONE: "NONE", - example.AnyMonster: "Monster", - example.AnyTestSimpleTableWithEnum: "TestSimpleTableWithEnum", - }, - }, - {example.EnumNamesColor, - map[int]string{ - example.ColorRed: "Red", - example.ColorGreen: "Green", - example.ColorBlue: "Blue", - }, - }, - } - for _, t := range data { - for val, name := range t.Expected { - if name != t.EnumNames[val] { - fail("enum name is not equal") - } - } - } -} - -// CheckDocExample checks that the code given in FlatBuffers documentation -// is syntactically correct. -func CheckDocExample(buf []byte, off flatbuffers.UOffsetT, fail func(string, ...interface{})) { - monster := example.GetRootAsMonster(buf, off) - _ = monster.Hp() - _ = monster.Pos(nil) - for i := 0; i < monster.InventoryLength(); i++ { - _ = monster.Inventory(i) // do something here - } - - builder := flatbuffers.NewBuilder(0) - - example.MonsterStartInventoryVector(builder, 5) - for i := 4; i >= 0; i-- { - builder.PrependByte(byte(i)) - } - inv := builder.EndVector(5) - - str := builder.CreateString("MyMonster") - example.MonsterStart(builder) - example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0, 3.0, 4, 5, 6)) - example.MonsterAddHp(builder, 80) - example.MonsterAddName(builder, str) - example.MonsterAddInventory(builder, inv) - example.MonsterAddTestType(builder, 1) - // example.MonsterAddTest(builder, mon2) - // example.MonsterAddTest4(builder, test4s) - _ = example.MonsterEnd(builder) -} - -func CheckCreateByteVector(fail func(string, ...interface{})) { - raw := [30]byte{} - for i := 0; i < len(raw); i++ { - raw[i] = byte(i) - } - - for size := 0; size < len(raw); size++ { - b1 := flatbuffers.NewBuilder(0) - b2 := flatbuffers.NewBuilder(0) - b1.StartVector(1, size, 1) - for i := size - 1; i >= 0; i-- { - b1.PrependByte(raw[i]) - } - b1.EndVector(size) - b2.CreateByteVector(raw[:size]) - CheckByteEquality(b1.Bytes, b2.Bytes, fail) - } -} - -// Include simple random number generator to ensure results will be the -// same cross platform. -// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator -type LCG uint32 - -const InitialLCGSeed = 48271 - -func NewLCG() *LCG { - n := uint32(InitialLCGSeed) - l := LCG(n) - return &l -} - -func (lcg *LCG) Reset() { - *lcg = InitialLCGSeed -} - -func (lcg *LCG) Next() uint32 { - n := uint32((uint64(*lcg) * uint64(279470273)) % uint64(4294967291)) - *lcg = LCG(n) - return n -} - -// CheckByteEquality verifies that two byte buffers are the same. -func CheckByteEquality(a, b []byte, fail func(string, ...interface{})) { - if !bytes.Equal(a, b) { - fail("objects are not byte-wise equal") - } -} - -// CheckMutateMethods checks all mutate methods one by one -func CheckMutateMethods(fail func(string, ...interface{})) { - b := flatbuffers.NewBuilder(0) - b.StartObject(15) - b.PrependBoolSlot(0, true, false) - b.PrependByteSlot(1, 1, 0) - b.PrependUint8Slot(2, 2, 0) - b.PrependUint16Slot(3, 3, 0) - b.PrependUint32Slot(4, 4, 0) - b.PrependUint64Slot(5, 5, 0) - b.PrependInt8Slot(6, 6, 0) - b.PrependInt16Slot(7, 7, 0) - b.PrependInt32Slot(8, 8, 0) - b.PrependInt64Slot(9, 9, 0) - b.PrependFloat32Slot(10, 10, 0) - b.PrependFloat64Slot(11, 11, 0) - - b.PrependUOffsetTSlot(12, 12, 0) - uoVal := b.Offset() - 12 - - b.PrependVOffsetT(13) - b.Slot(13) - - b.PrependSOffsetT(14) - b.Slot(14) - soVal := flatbuffers.SOffsetT(b.Offset() - 14) - - offset := b.EndObject() - - t := &flatbuffers.Table{ - Bytes: b.Bytes, - Pos: flatbuffers.UOffsetT(len(b.Bytes)) - offset, - } - - calcVOffsetT := func(slot int) (vtableOffset flatbuffers.VOffsetT) { - return flatbuffers.VOffsetT((flatbuffers.VtableMetadataFields + slot) * flatbuffers.SizeVOffsetT) - } - calcUOffsetT := func(vtableOffset flatbuffers.VOffsetT) (valueOffset flatbuffers.UOffsetT) { - return t.Pos + flatbuffers.UOffsetT(t.Offset(vtableOffset)) - } - - type testcase struct { - field string - testfn func() bool - } - - testForOriginalValues := []testcase{ - testcase{"BoolSlot", func() bool { return t.GetBoolSlot(calcVOffsetT(0), true) == true }}, - testcase{"ByteSlot", func() bool { return t.GetByteSlot(calcVOffsetT(1), 1) == 1 }}, - testcase{"Uint8Slot", func() bool { return t.GetUint8Slot(calcVOffsetT(2), 2) == 2 }}, - testcase{"Uint16Slot", func() bool { return t.GetUint16Slot(calcVOffsetT(3), 3) == 3 }}, - testcase{"Uint32Slot", func() bool { return t.GetUint32Slot(calcVOffsetT(4), 4) == 4 }}, - testcase{"Uint64Slot", func() bool { return t.GetUint64Slot(calcVOffsetT(5), 5) == 5 }}, - testcase{"Int8Slot", func() bool { return t.GetInt8Slot(calcVOffsetT(6), 6) == 6 }}, - testcase{"Int16Slot", func() bool { return t.GetInt16Slot(calcVOffsetT(7), 7) == 7 }}, - testcase{"Int32Slot", func() bool { return t.GetInt32Slot(calcVOffsetT(8), 8) == 8 }}, - testcase{"Int64Slot", func() bool { return t.GetInt64Slot(calcVOffsetT(9), 9) == 9 }}, - testcase{"Float32Slot", func() bool { return t.GetFloat32Slot(calcVOffsetT(10), 10) == 10 }}, - testcase{"Float64Slot", func() bool { return t.GetFloat64Slot(calcVOffsetT(11), 11) == 11 }}, - testcase{"UOffsetTSlot", func() bool { return t.GetUOffsetT(calcUOffsetT(calcVOffsetT(12))) == uoVal }}, - testcase{"VOffsetTSlot", func() bool { return t.GetVOffsetT(calcUOffsetT(calcVOffsetT(13))) == 13 }}, - testcase{"SOffsetTSlot", func() bool { return t.GetSOffsetT(calcUOffsetT(calcVOffsetT(14))) == soVal }}, - } - - testMutability := []testcase{ - testcase{"BoolSlot", func() bool { return t.MutateBoolSlot(calcVOffsetT(0), false) }}, - testcase{"ByteSlot", func() bool { return t.MutateByteSlot(calcVOffsetT(1), 2) }}, - testcase{"Uint8Slot", func() bool { return t.MutateUint8Slot(calcVOffsetT(2), 4) }}, - testcase{"Uint16Slot", func() bool { return t.MutateUint16Slot(calcVOffsetT(3), 6) }}, - testcase{"Uint32Slot", func() bool { return t.MutateUint32Slot(calcVOffsetT(4), 8) }}, - testcase{"Uint64Slot", func() bool { return t.MutateUint64Slot(calcVOffsetT(5), 10) }}, - testcase{"Int8Slot", func() bool { return t.MutateInt8Slot(calcVOffsetT(6), 12) }}, - testcase{"Int16Slot", func() bool { return t.MutateInt16Slot(calcVOffsetT(7), 14) }}, - testcase{"Int32Slot", func() bool { return t.MutateInt32Slot(calcVOffsetT(8), 16) }}, - testcase{"Int64Slot", func() bool { return t.MutateInt64Slot(calcVOffsetT(9), 18) }}, - testcase{"Float32Slot", func() bool { return t.MutateFloat32Slot(calcVOffsetT(10), 20) }}, - testcase{"Float64Slot", func() bool { return t.MutateFloat64Slot(calcVOffsetT(11), 22) }}, - testcase{"UOffsetTSlot", func() bool { return t.MutateUOffsetT(calcUOffsetT(calcVOffsetT(12)), 24) }}, - testcase{"VOffsetTSlot", func() bool { return t.MutateVOffsetT(calcUOffsetT(calcVOffsetT(13)), 26) }}, - testcase{"SOffsetTSlot", func() bool { return t.MutateSOffsetT(calcUOffsetT(calcVOffsetT(14)), 28) }}, - } - - testMutabilityWithoutSlot := []testcase{ - testcase{"BoolSlot", func() bool { return t.MutateBoolSlot(calcVOffsetT(16), false) }}, - testcase{"ByteSlot", func() bool { return t.MutateByteSlot(calcVOffsetT(16), 2) }}, - testcase{"Uint8Slot", func() bool { return t.MutateUint8Slot(calcVOffsetT(16), 2) }}, - testcase{"Uint16Slot", func() bool { return t.MutateUint16Slot(calcVOffsetT(16), 2) }}, - testcase{"Uint32Slot", func() bool { return t.MutateUint32Slot(calcVOffsetT(16), 2) }}, - testcase{"Uint64Slot", func() bool { return t.MutateUint64Slot(calcVOffsetT(16), 2) }}, - testcase{"Int8Slot", func() bool { return t.MutateInt8Slot(calcVOffsetT(16), 2) }}, - testcase{"Int16Slot", func() bool { return t.MutateInt16Slot(calcVOffsetT(16), 2) }}, - testcase{"Int32Slot", func() bool { return t.MutateInt32Slot(calcVOffsetT(16), 2) }}, - testcase{"Int64Slot", func() bool { return t.MutateInt64Slot(calcVOffsetT(16), 2) }}, - testcase{"Float32Slot", func() bool { return t.MutateFloat32Slot(calcVOffsetT(16), 2) }}, - testcase{"Float64Slot", func() bool { return t.MutateFloat64Slot(calcVOffsetT(16), 2) }}, - } - - testForMutatedValues := []testcase{ - testcase{"BoolSlot", func() bool { return t.GetBoolSlot(calcVOffsetT(0), true) == false }}, - testcase{"ByteSlot", func() bool { return t.GetByteSlot(calcVOffsetT(1), 1) == 2 }}, - testcase{"Uint8Slot", func() bool { return t.GetUint8Slot(calcVOffsetT(2), 1) == 4 }}, - testcase{"Uint16Slot", func() bool { return t.GetUint16Slot(calcVOffsetT(3), 1) == 6 }}, - testcase{"Uint32Slot", func() bool { return t.GetUint32Slot(calcVOffsetT(4), 1) == 8 }}, - testcase{"Uint64Slot", func() bool { return t.GetUint64Slot(calcVOffsetT(5), 1) == 10 }}, - testcase{"Int8Slot", func() bool { return t.GetInt8Slot(calcVOffsetT(6), 1) == 12 }}, - testcase{"Int16Slot", func() bool { return t.GetInt16Slot(calcVOffsetT(7), 1) == 14 }}, - testcase{"Int32Slot", func() bool { return t.GetInt32Slot(calcVOffsetT(8), 1) == 16 }}, - testcase{"Int64Slot", func() bool { return t.GetInt64Slot(calcVOffsetT(9), 1) == 18 }}, - testcase{"Float32Slot", func() bool { return t.GetFloat32Slot(calcVOffsetT(10), 1) == 20 }}, - testcase{"Float64Slot", func() bool { return t.GetFloat64Slot(calcVOffsetT(11), 1) == 22 }}, - testcase{"UOffsetTSlot", func() bool { return t.GetUOffsetT(calcUOffsetT(calcVOffsetT(12))) == 24 }}, - testcase{"VOffsetTSlot", func() bool { return t.GetVOffsetT(calcUOffsetT(calcVOffsetT(13))) == 26 }}, - testcase{"SOffsetTSlot", func() bool { return t.GetSOffsetT(calcUOffsetT(calcVOffsetT(14))) == 28 }}, - } - - // make sure original values are okay - for _, t := range testForOriginalValues { - if !t.testfn() { - fail(t.field + "' field doesn't have the expected original value") - } - } - - // try to mutate fields and check mutability - for _, t := range testMutability { - if !t.testfn() { - fail(FailString(t.field+"' field failed mutability test", "passed", "failed")) - } - } - - // try to mutate fields and check mutability - // these have wrong slots so should fail - for _, t := range testMutabilityWithoutSlot { - if t.testfn() { - fail(FailString(t.field+"' field failed no slot mutability test", "failed", "passed")) - } - } - - // test whether values have changed - for _, t := range testForMutatedValues { - if !t.testfn() { - fail(t.field + "' field doesn't have the expected mutated value") - } - } -} - -// BenchmarkVtableDeduplication measures the speed of vtable deduplication -// by creating prePop vtables, then populating b.N objects with a -// different single vtable. -// -// When b.N is large (as in long benchmarks), memory usage may be high. -func BenchmarkVtableDeduplication(b *testing.B) { - prePop := 10 - builder := flatbuffers.NewBuilder(0) - - // pre-populate some vtables: - for i := 0; i < prePop; i++ { - builder.StartObject(i) - for j := 0; j < i; j++ { - builder.PrependInt16Slot(j, int16(j), 0) - } - builder.EndObject() - } - - // benchmark deduplication of a new vtable: - b.ResetTimer() - for i := 0; i < b.N; i++ { - lim := prePop - - builder.StartObject(lim) - for j := 0; j < lim; j++ { - builder.PrependInt16Slot(j, int16(j), 0) - } - builder.EndObject() - } -} - -// BenchmarkParseGold measures the speed of parsing the 'gold' data -// used throughout this test suite. -func BenchmarkParseGold(b *testing.B) { - buf, offset := CheckGeneratedBuild(b.Fatalf) - monster := example.GetRootAsMonster(buf, offset) - - // use these to prevent allocations: - reuse_pos := example.Vec3{} - reuse_test3 := example.Test{} - reuse_table2 := flatbuffers.Table{} - reuse_monster2 := example.Monster{} - reuse_test4_0 := example.Test{} - reuse_test4_1 := example.Test{} - - b.SetBytes(int64(len(buf[offset:]))) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - monster.Hp() - monster.Mana() - name := monster.Name() - _ = name[0] - _ = name[len(name)-1] - - monster.Pos(&reuse_pos) - reuse_pos.X() - reuse_pos.Y() - reuse_pos.Z() - reuse_pos.Test1() - reuse_pos.Test2() - reuse_pos.Test3(&reuse_test3) - reuse_test3.A() - reuse_test3.B() - monster.TestType() - monster.Test(&reuse_table2) - reuse_monster2.Init(reuse_table2.Bytes, reuse_table2.Pos) - name2 := reuse_monster2.Name() - _ = name2[0] - _ = name2[len(name2)-1] - monster.InventoryLength() - l := monster.InventoryLength() - for i := 0; i < l; i++ { - monster.Inventory(i) - } - monster.Test4Length() - monster.Test4(&reuse_test4_0, 0) - monster.Test4(&reuse_test4_1, 1) - - reuse_test4_0.A() - reuse_test4_0.B() - reuse_test4_1.A() - reuse_test4_1.B() - - monster.TestarrayofstringLength() - str0 := monster.Testarrayofstring(0) - _ = str0[0] - _ = str0[len(str0)-1] - str1 := monster.Testarrayofstring(1) - _ = str1[0] - _ = str1[len(str1)-1] - } -} - -// BenchmarkBuildGold uses generated code to build the example Monster. -func BenchmarkBuildGold(b *testing.B) { - buf, offset := CheckGeneratedBuild(b.Fatalf) - bytes_length := int64(len(buf[offset:])) - - reuse_str := "MyMonster" - reuse_test1 := "test1" - reuse_test2 := "test2" - reuse_fred := "Fred" - - b.SetBytes(bytes_length) - bldr := flatbuffers.NewBuilder(0) - b.ResetTimer() - b.ReportAllocs() - for i := 0; i < b.N; i++ { - bldr.Reset() - - str := bldr.CreateString(reuse_str) - test1 := bldr.CreateString(reuse_test1) - test2 := bldr.CreateString(reuse_test2) - fred := bldr.CreateString(reuse_fred) - - example.MonsterStartInventoryVector(bldr, 5) - bldr.PrependByte(4) - bldr.PrependByte(3) - bldr.PrependByte(2) - bldr.PrependByte(1) - bldr.PrependByte(0) - inv := bldr.EndVector(5) - - example.MonsterStart(bldr) - example.MonsterAddName(bldr, fred) - mon2 := example.MonsterEnd(bldr) - - example.MonsterStartTest4Vector(bldr, 2) - example.CreateTest(bldr, 10, 20) - example.CreateTest(bldr, 30, 40) - test4 := bldr.EndVector(2) - - example.MonsterStartTestarrayofstringVector(bldr, 2) - bldr.PrependUOffsetT(test2) - bldr.PrependUOffsetT(test1) - testArrayOfString := bldr.EndVector(2) - - example.MonsterStart(bldr) - - pos := example.CreateVec3(bldr, 1.0, 2.0, 3.0, 3.0, 2, 5, 6) - example.MonsterAddPos(bldr, pos) - - example.MonsterAddHp(bldr, 80) - example.MonsterAddName(bldr, str) - example.MonsterAddInventory(bldr, inv) - example.MonsterAddTestType(bldr, 1) - example.MonsterAddTest(bldr, mon2) - example.MonsterAddTest4(bldr, test4) - example.MonsterAddTestarrayofstring(bldr, testArrayOfString) - mon := example.MonsterEnd(bldr) - - bldr.Finish(mon) - } -}
diff --git a/third_party/flatbuffers/tests/include_test1.fbs b/third_party/flatbuffers/tests/include_test1.fbs deleted file mode 100644 index 11aebe8..0000000 --- a/third_party/flatbuffers/tests/include_test1.fbs +++ /dev/null
@@ -1,5 +0,0 @@ -include "include_test2.fbs"; -include "include_test2.fbs"; // should be skipped -include "include_test1.fbs"; // should be skipped - -
diff --git a/third_party/flatbuffers/tests/include_test2.fbs b/third_party/flatbuffers/tests/include_test2.fbs deleted file mode 100644 index d22c0d9..0000000 --- a/third_party/flatbuffers/tests/include_test2.fbs +++ /dev/null
@@ -1,9 +0,0 @@ -include "include_test2.fbs"; // should be skipped - -namespace MyGame.OtherNameSpace; - -enum FromInclude:long { IncludeVal } - -struct Unused {} - -
diff --git a/third_party/flatbuffers/tests/monster_test.bfbs b/third_party/flatbuffers/tests/monster_test.bfbs deleted file mode 100644 index 78871d5..0000000 --- a/third_party/flatbuffers/tests/monster_test.bfbs +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/tests/monster_test.fbs b/third_party/flatbuffers/tests/monster_test.fbs deleted file mode 100755 index 81ec993..0000000 --- a/third_party/flatbuffers/tests/monster_test.fbs +++ /dev/null
@@ -1,86 +0,0 @@ -// test schema file - -include "include_test1.fbs"; - -namespace MyGame.Example2; - -table Monster {} // Test having same name as below, but in different namespace. - -namespace MyGame.Example; - -attribute "priority"; - -enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, } - -union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster } - -struct Test { a:short; b:byte; } - -table TestSimpleTableWithEnum (csharp_partial) { - color: Color = Green; -} - -struct Vec3 (force_align: 16) { - x:float; - y:float; - z:float; - test1:double; - test2:Color; - test3:Test; -} - -struct Ability { - id:uint(key); - distance:uint; -} - -table Stat { - id:string; - val:long; - count:ushort; -} - -/// an example documentation comment: monster object -table Monster { - pos:Vec3 (id: 0); - hp:short = 100 (id: 2); - mana:short = 150 (id: 1); - name:string (id: 3, required, key); - color:Color = Blue (id: 6); - inventory:[ubyte] (id: 5); - friendly:bool = false (deprecated, priority: 1, id: 4); - /// an example documentation comment: this will end up in the generated code - /// multiline too - testarrayoftables:[Monster] (id: 11); - testarrayofstring:[string] (id: 10); - testarrayofstring2:[string] (id: 28); - testarrayofbools:[bool] (id: 24); - testarrayofsortedstruct:[Ability] (id: 29); - enemy:MyGame.Example.Monster (id:12); // Test referring by full namespace. - test:Any (id: 8); - test4:[Test] (id: 9); - testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster"); - testempty:Stat (id:14); - testbool:bool (id:15); - testhashs32_fnv1:int (id:16, hash:"fnv1_32"); - testhashu32_fnv1:uint (id:17, hash:"fnv1_32"); - testhashs64_fnv1:long (id:18, hash:"fnv1_64"); - testhashu64_fnv1:ulong (id:19, hash:"fnv1_64"); - testhashs32_fnv1a:int (id:20, hash:"fnv1a_32"); - testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32", cpp_type:"Stat"); - testhashs64_fnv1a:long (id:22, hash:"fnv1a_64"); - testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64"); - testf:float = 3.14159 (id:25); - testf2:float = 3 (id:26); - testf3:float (id:27); -} - -rpc_service MonsterStorage { - Store(Monster):Stat (streaming: "none"); - Retrieve(Stat):Monster (streaming: "server", idempotent); -} - -root_type Monster; - -file_identifier "MONS"; -file_extension "mon";
diff --git a/third_party/flatbuffers/tests/monster_test.grpc.fb.cc b/third_party/flatbuffers/tests/monster_test.grpc.fb.cc deleted file mode 100644 index c8ed1f5..0000000 --- a/third_party/flatbuffers/tests/monster_test.grpc.fb.cc +++ /dev/null
@@ -1,85 +0,0 @@ -// Generated by the gRPC protobuf plugin. -// If you make any local change, they will be lost. -// source: monster_test - -#include "monster_test_generated.h" -#include "monster_test.grpc.fb.h" - -#include <grpc++/impl/codegen/async_stream.h> -#include <grpc++/impl/codegen/async_unary_call.h> -#include <grpc++/impl/codegen/channel_interface.h> -#include <grpc++/impl/codegen/client_unary_call.h> -#include <grpc++/impl/codegen/method_handler_impl.h> -#include <grpc++/impl/codegen/rpc_service_method.h> -#include <grpc++/impl/codegen/service_type.h> -#include <grpc++/impl/codegen/sync_stream.h> - -namespace MyGame { -namespace Example { - -static const char* MonsterStorage_method_names[] = { - "/MyGame.Example.MonsterStorage/Store", - "/MyGame.Example.MonsterStorage/Retrieve", -}; - -std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) { - std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel)); - return stub; -} - -MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) - : channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::RpcMethod::SERVER_STREAMING, channel) - {} - -::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) { - return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response); -} - -::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) { - return new ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>(channel_.get(), cq, rpcmethod_Store_, context, request); -} - -::grpc::ClientReader< flatbuffers::BufferRef<Monster>>* MonsterStorage::Stub::RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) { - return new ::grpc::ClientReader< flatbuffers::BufferRef<Monster>>(channel_.get(), rpcmethod_Retrieve_, context, request); -} - -::grpc::ClientAsyncReader< flatbuffers::BufferRef<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) { - return new ::grpc::ClientAsyncReader< flatbuffers::BufferRef<Monster>>(channel_.get(), cq, rpcmethod_Retrieve_, context, request, tag); -} - -MonsterStorage::Service::Service() { - (void)MonsterStorage_method_names; - AddMethod(new ::grpc::RpcServiceMethod( - MonsterStorage_method_names[0], - ::grpc::RpcMethod::NORMAL_RPC, - new ::grpc::RpcMethodHandler< MonsterStorage::Service, flatbuffers::BufferRef<Monster>, flatbuffers::BufferRef<Stat>>( - std::mem_fn(&MonsterStorage::Service::Store), this))); - AddMethod(new ::grpc::RpcServiceMethod( - MonsterStorage_method_names[1], - ::grpc::RpcMethod::SERVER_STREAMING, - new ::grpc::ServerStreamingHandler< MonsterStorage::Service, flatbuffers::BufferRef<Stat>, flatbuffers::BufferRef<Monster>>( - std::mem_fn(&MonsterStorage::Service::Retrieve), this))); -} - -MonsterStorage::Service::~Service() { -} - -::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) { - (void) context; - (void) request; - (void) response; - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); -} - -::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer) { - (void) context; - (void) request; - (void) writer; - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); -} - - -} // namespace MyGame -} // namespace Example -
diff --git a/third_party/flatbuffers/tests/monster_test.grpc.fb.h b/third_party/flatbuffers/tests/monster_test.grpc.fb.h deleted file mode 100644 index 8228d7a..0000000 --- a/third_party/flatbuffers/tests/monster_test.grpc.fb.h +++ /dev/null
@@ -1,161 +0,0 @@ -// Generated by the gRPC protobuf plugin. -// If you make any local change, they will be lost. -// source: monster_test -#ifndef GRPC_monster_5ftest__INCLUDED -#define GRPC_monster_5ftest__INCLUDED - -#include "monster_test_generated.h" -#include "flatbuffers/grpc.h" - -#include <grpc++/impl/codegen/async_stream.h> -#include <grpc++/impl/codegen/async_unary_call.h> -#include <grpc++/impl/codegen/rpc_method.h> -#include <grpc++/impl/codegen/service_type.h> -#include <grpc++/impl/codegen/status.h> -#include <grpc++/impl/codegen/stub_options.h> -#include <grpc++/impl/codegen/sync_stream.h> - -namespace grpc { -class CompletionQueue; -class Channel; -class RpcService; -class ServerCompletionQueue; -class ServerContext; -} // namespace grpc - -namespace MyGame { -namespace Example { - -class MonsterStorage GRPC_FINAL { - public: - class StubInterface { - public: - virtual ~StubInterface() {} - virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) = 0; - std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>>(AsyncStoreRaw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) { - return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>>(RetrieveRaw(context, request)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag)); - } - private: - virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) = 0; - virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) = 0; - }; - class Stub GRPC_FINAL : public StubInterface { - public: - Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); - ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) GRPC_OVERRIDE; - std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>>(AsyncStoreRaw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientReader< flatbuffers::BufferRef<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) { - return std::unique_ptr< ::grpc::ClientReader< flatbuffers::BufferRef<Monster>>>(RetrieveRaw(context, request)); - } - std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::BufferRef<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReader< flatbuffers::BufferRef<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag)); - } - - private: - std::shared_ptr< ::grpc::ChannelInterface> channel_; - ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) GRPC_OVERRIDE; - ::grpc::ClientReader< flatbuffers::BufferRef<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) GRPC_OVERRIDE; - ::grpc::ClientAsyncReader< flatbuffers::BufferRef<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE; - const ::grpc::RpcMethod rpcmethod_Store_; - const ::grpc::RpcMethod rpcmethod_Retrieve_; - }; - static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); - - class Service : public ::grpc::Service { - public: - Service(); - virtual ~Service(); - virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response); - virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer); - }; - template <class BaseClass> - class WithAsyncMethod_Store : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service *service) {} - public: - WithAsyncMethod_Store() { - ::grpc::Service::MarkMethodAsync(0); - } - ~WithAsyncMethod_Store() GRPC_OVERRIDE { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) GRPC_FINAL GRPC_OVERRIDE { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - void RequestStore(::grpc::ServerContext* context, flatbuffers::BufferRef<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::BufferRef<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag); - } - }; - template <class BaseClass> - class WithAsyncMethod_Retrieve : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service *service) {} - public: - WithAsyncMethod_Retrieve() { - ::grpc::Service::MarkMethodAsync(1); - } - ~WithAsyncMethod_Retrieve() GRPC_OVERRIDE { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer) GRPC_FINAL GRPC_OVERRIDE { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::BufferRef<Stat>* request, ::grpc::ServerAsyncWriter< flatbuffers::BufferRef<Monster>>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag); - } - }; - typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< Service > > AsyncService; - template <class BaseClass> - class WithGenericMethod_Store : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service *service) {} - public: - WithGenericMethod_Store() { - ::grpc::Service::MarkMethodGeneric(0); - } - ~WithGenericMethod_Store() GRPC_OVERRIDE { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) GRPC_FINAL GRPC_OVERRIDE { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - }; - template <class BaseClass> - class WithGenericMethod_Retrieve : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service *service) {} - public: - WithGenericMethod_Retrieve() { - ::grpc::Service::MarkMethodGeneric(1); - } - ~WithGenericMethod_Retrieve() GRPC_OVERRIDE { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer) GRPC_FINAL GRPC_OVERRIDE { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - }; -}; - -} // namespace Example -} // namespace MyGame - - -#endif // GRPC_monster_5ftest__INCLUDED
diff --git a/third_party/flatbuffers/tests/monster_test_generated.js b/third_party/flatbuffers/tests/monster_test_generated.js deleted file mode 100644 index 7b0165c..0000000 --- a/third_party/flatbuffers/tests/monster_test_generated.js +++ /dev/null
@@ -1,1674 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var MyGame = MyGame || {}; - -/** - * @const - * @namespace - */ -MyGame.Example = MyGame.Example || {}; - -/** - * @const - * @namespace - */ -MyGame.Example2 = MyGame.Example2 || {}; - -/** - * @const - * @namespace - */ -MyGame.OtherNameSpace = MyGame.OtherNameSpace || {}; - -/** - * @enum - */ -MyGame.Example.Color = { - Red: 1, - Green: 2, - Blue: 8 -}; - -/** - * @enum - */ -MyGame.Example.Any = { - NONE: 0, - Monster: 1, - TestSimpleTableWithEnum: 2, - MyGame_Example2_Monster: 3 -}; - -/** - * @constructor - */ -MyGame.Example2.Monster = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example2.Monster} - */ -MyGame.Example2.Monster.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example2.Monster=} obj - * @returns {MyGame.Example2.Monster} - */ -MyGame.Example2.Monster.getRootAsMonster = function(bb, obj) { - return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example2.Monster.startMonster = function(builder) { - builder.startObject(0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example2.Monster.endMonster = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -MyGame.Example.Test = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Test.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Test.prototype.a = function() { - return this.bb.readInt16(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Test.prototype.mutate_a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Test.prototype.b = function() { - return this.bb.readInt8(this.bb_pos + 2); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Test.prototype.mutate_b = function(value) { - var offset = this.bb.__offset(this.bb_pos, 2); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Test.createTest = function(builder, a, b) { - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b); - builder.writeInt16(a); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.TestSimpleTableWithEnum = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.TestSimpleTableWithEnum} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.TestSimpleTableWithEnum=} obj - * @returns {MyGame.Example.TestSimpleTableWithEnum} - */ -MyGame.Example.TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum = function(bb, obj) { - return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.color = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Green; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.mutate_color = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.TestSimpleTableWithEnum.startTestSimpleTableWithEnum = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -MyGame.Example.TestSimpleTableWithEnum.addColor = function(builder, color) { - builder.addFieldInt8(0, color, MyGame.Example.Color.Green); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TestSimpleTableWithEnum.endTestSimpleTableWithEnum = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -MyGame.Example.Vec3 = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Vec3} - */ -MyGame.Example.Vec3.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.x = function() { - return this.bb.readFloat32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_x = function(value) { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.y = function() { - return this.bb.readFloat32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_y = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.z = function() { - return this.bb.readFloat32(this.bb_pos + 8); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_z = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.test1 = function() { - return this.bb.readFloat64(this.bb_pos + 16); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_test1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.Vec3.prototype.test2 = function() { - return /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + 24)); -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_test2 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 24); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Vec3.prototype.test3 = function(obj) { - return (obj || new MyGame.Example.Test).__init(this.bb_pos + 26, this.bb); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} test1 - * @param {MyGame.Example.Color} test2 - * @param {number} test3_a - * @param {number} test3_b - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Vec3.createVec3 = function(builder, x, y, z, test1, test2, test3_a, test3_b) { - builder.prep(16, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.Ability = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Ability} - */ -MyGame.Example.Ability.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Ability.prototype.id = function() { - return this.bb.readUint32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Ability.prototype.mutate_id = function(value) { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Ability.prototype.distance = function() { - return this.bb.readUint32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Ability.prototype.mutate_distance = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} id - * @param {number} distance - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Ability.createAbility = function(builder, id, distance) { - builder.prep(4, 8); - builder.writeInt32(distance); - builder.writeInt32(id); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.Stat = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Stat} - */ -MyGame.Example.Stat.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ -MyGame.Example.Stat.getRootAsStat = function(bb, obj) { - return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Stat.prototype.id = function(optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Stat.prototype.val = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Stat.prototype.mutate_val = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Stat.prototype.count = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Stat.prototype.mutate_count = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeUint16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.Stat.startStat = function(builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} idOffset - */ -MyGame.Example.Stat.addId = function(builder, idOffset) { - builder.addFieldOffset(0, idOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} val - */ -MyGame.Example.Stat.addVal = function(builder, val) { - builder.addFieldInt64(1, val, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} count - */ -MyGame.Example.Stat.addCount = function(builder, count) { - builder.addFieldInt16(2, count, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Stat.endStat = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * an example documentation comment: monster object - * - * @constructor - */ -MyGame.Example.Monster = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.getRootAsMonster = function(bb, obj) { - return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @returns {boolean} - */ -MyGame.Example.Monster.bufferHasIdentifier = function(bb) { - return bb.__has_identifier('MONS'); -}; - -/** - * @param {MyGame.Example.Vec3=} obj - * @returns {MyGame.Example.Vec3} - */ -MyGame.Example.Monster.prototype.pos = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame.Example.Vec3).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.mana = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_mana = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.hp = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_hp = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Monster.prototype.name = function(optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.inventory = function(index) { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.inventoryLength = function() { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.inventoryArray = function() { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.Monster.prototype.color = function() { - var offset = this.bb.__offset(this.bb_pos, 16); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Blue; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_color = function(value) { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {MyGame.Example.Any} - */ -MyGame.Example.Monster.prototype.testType = function() { - var offset = this.bb.__offset(this.bb_pos, 18); - return offset ? /** @type {MyGame.Example.Any} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Any.NONE; -}; - -/** - * @param {MyGame.Example.Any} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_test_type = function(value) { - var offset = this.bb.__offset(this.bb_pos, 18); - - if (offset === 0) { - return false; - } - - this.bb.writeUint8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -MyGame.Example.Monster.prototype.test = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Monster.prototype.test4 = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new MyGame.Example.Test).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.test4Length = function() { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Monster.prototype.testarrayofstring = function(index, optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofstringLength = function() { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * an example documentation comment: this will end up in the generated code - * multiline too - * - * @param {number} index - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.prototype.testarrayoftables = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayoftablesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.prototype.enemy = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 28); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.testnestedflatbuffer = function(index) { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testnestedflatbufferLength = function() { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.testnestedflatbufferArray = function() { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ -MyGame.Example.Monster.prototype.testempty = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 32); - return offset ? (obj || new MyGame.Example.Stat).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.testbool = function() { - var offset = this.bb.__offset(this.bb_pos, 34); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param {boolean} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testbool = function(value) { - var offset = this.bb.__offset(this.bb_pos, 34); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashs32Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 36); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs32_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 36); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashu32Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 38); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu32_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 38); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashs64Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 40); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs64_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 40); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashu64Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 42); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu64_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 42); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashs32Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 44); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs32_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 44); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashu32Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 46); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu32_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 46); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashs64Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 48); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs64_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 48); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashu64Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 50); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu64_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 50); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.testarrayofbools = function(index) { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofboolsLength = function() { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Int8Array} - */ -MyGame.Example.Monster.prototype.testarrayofboolsArray = function() { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf = function() { - var offset = this.bb.__offset(this.bb_pos, 54); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf = function(value) { - var offset = this.bb.__offset(this.bb_pos, 54); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf2 = function() { - var offset = this.bb.__offset(this.bb_pos, 56); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf2 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 56); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf3 = function() { - var offset = this.bb.__offset(this.bb_pos, 58); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf3 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 58); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Monster.prototype.testarrayofstring2 = function(index, optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofstring2Length = function() { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Ability=} obj - * @returns {MyGame.Example.Ability} - */ -MyGame.Example.Monster.prototype.testarrayofsortedstruct = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? (obj || new MyGame.Example.Ability).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofsortedstructLength = function() { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.Monster.startMonster = function(builder) { - builder.startObject(30); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} posOffset - */ -MyGame.Example.Monster.addPos = function(builder, posOffset) { - builder.addFieldStruct(0, posOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} mana - */ -MyGame.Example.Monster.addMana = function(builder, mana) { - builder.addFieldInt16(1, mana, 150); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} hp - */ -MyGame.Example.Monster.addHp = function(builder, hp) { - builder.addFieldInt16(2, hp, 100); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} nameOffset - */ -MyGame.Example.Monster.addName = function(builder, nameOffset) { - builder.addFieldOffset(3, nameOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} inventoryOffset - */ -MyGame.Example.Monster.addInventory = function(builder, inventoryOffset) { - builder.addFieldOffset(5, inventoryOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createInventoryVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startInventoryVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -MyGame.Example.Monster.addColor = function(builder, color) { - builder.addFieldInt8(6, color, MyGame.Example.Color.Blue); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Any} testType - */ -MyGame.Example.Monster.addTestType = function(builder, testType) { - builder.addFieldInt8(7, testType, MyGame.Example.Any.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testOffset - */ -MyGame.Example.Monster.addTest = function(builder, testOffset) { - builder.addFieldOffset(8, testOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} test4Offset - */ -MyGame.Example.Monster.addTest4 = function(builder, test4Offset) { - builder.addFieldOffset(9, test4Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTest4Vector = function(builder, numElems) { - builder.startVector(4, numElems, 2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstringOffset - */ -MyGame.Example.Monster.addTestarrayofstring = function(builder, testarrayofstringOffset) { - builder.addFieldOffset(10, testarrayofstringOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofstringVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofstringVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayoftablesOffset - */ -MyGame.Example.Monster.addTestarrayoftables = function(builder, testarrayoftablesOffset) { - builder.addFieldOffset(11, testarrayoftablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayoftablesVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayoftablesVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} enemyOffset - */ -MyGame.Example.Monster.addEnemy = function(builder, enemyOffset) { - builder.addFieldOffset(12, enemyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testnestedflatbufferOffset - */ -MyGame.Example.Monster.addTestnestedflatbuffer = function(builder, testnestedflatbufferOffset) { - builder.addFieldOffset(13, testnestedflatbufferOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestnestedflatbufferVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestnestedflatbufferVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testemptyOffset - */ -MyGame.Example.Monster.addTestempty = function(builder, testemptyOffset) { - builder.addFieldOffset(14, testemptyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {boolean} testbool - */ -MyGame.Example.Monster.addTestbool = function(builder, testbool) { - builder.addFieldInt8(15, +testbool, +false); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1 - */ -MyGame.Example.Monster.addTesthashs32Fnv1 = function(builder, testhashs32Fnv1) { - builder.addFieldInt32(16, testhashs32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1 - */ -MyGame.Example.Monster.addTesthashu32Fnv1 = function(builder, testhashu32Fnv1) { - builder.addFieldInt32(17, testhashu32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1 - */ -MyGame.Example.Monster.addTesthashs64Fnv1 = function(builder, testhashs64Fnv1) { - builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1 - */ -MyGame.Example.Monster.addTesthashu64Fnv1 = function(builder, testhashu64Fnv1) { - builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1a - */ -MyGame.Example.Monster.addTesthashs32Fnv1a = function(builder, testhashs32Fnv1a) { - builder.addFieldInt32(20, testhashs32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1a - */ -MyGame.Example.Monster.addTesthashu32Fnv1a = function(builder, testhashu32Fnv1a) { - builder.addFieldInt32(21, testhashu32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1a - */ -MyGame.Example.Monster.addTesthashs64Fnv1a = function(builder, testhashs64Fnv1a) { - builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1a - */ -MyGame.Example.Monster.addTesthashu64Fnv1a = function(builder, testhashu64Fnv1a) { - builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofboolsOffset - */ -MyGame.Example.Monster.addTestarrayofbools = function(builder, testarrayofboolsOffset) { - builder.addFieldOffset(24, testarrayofboolsOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<boolean>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofboolsVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(+data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofboolsVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf - */ -MyGame.Example.Monster.addTestf = function(builder, testf) { - builder.addFieldFloat32(25, testf, 3.14159); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf2 - */ -MyGame.Example.Monster.addTestf2 = function(builder, testf2) { - builder.addFieldFloat32(26, testf2, 3.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf3 - */ -MyGame.Example.Monster.addTestf3 = function(builder, testf3) { - builder.addFieldFloat32(27, testf3, 0.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstring2Offset - */ -MyGame.Example.Monster.addTestarrayofstring2 = function(builder, testarrayofstring2Offset) { - builder.addFieldOffset(28, testarrayofstring2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofstring2Vector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofstring2Vector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofsortedstructOffset - */ -MyGame.Example.Monster.addTestarrayofsortedstruct = function(builder, testarrayofsortedstructOffset) { - builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofsortedstructVector = function(builder, numElems) { - builder.startVector(8, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.endMonster = function(builder) { - var offset = builder.endObject(); - builder.requiredField(offset, 10); // name - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} offset - */ -MyGame.Example.Monster.finishMonsterBuffer = function(builder, offset) { - builder.finish(offset, 'MONS'); -}; - -// Exports for Node.js and RequireJS -this.MyGame = MyGame;
diff --git a/third_party/flatbuffers/tests/monster_test_generated.ts b/third_party/flatbuffers/tests/monster_test_generated.ts deleted file mode 100644 index 3ff1bf9..0000000 --- a/third_party/flatbuffers/tests/monster_test_generated.ts +++ /dev/null
@@ -1,1683 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @enum - */ -export namespace MyGame.Example{ -export enum Color{ - Red= 1, - Green= 2, - Blue= 8 -}}; - -/** - * @enum - */ -export namespace MyGame.Example{ -export enum Any{ - NONE= 0, - Monster= 1, - TestSimpleTableWithEnum= 2, - MyGame_Example2_Monster= 3 -}}; - -/** - * @constructor - */ -export namespace MyGame.Example2{ -export class Monster { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Monster} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Monster { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {Monster=} obj - * @returns {Monster} - */ -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startMonster(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace MyGame.Example{ -export class Test { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Test} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Test { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -a():number { - return this.bb.readInt16(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_a(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -b():number { - return this.bb.readInt8(this.bb_pos + 2); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_b(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 2); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b); - builder.writeInt16(a); - return builder.offset(); -}; - -} -} -/** - * @constructor - */ -export namespace MyGame.Example{ -export class TestSimpleTableWithEnum { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {TestSimpleTableWithEnum} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {TestSimpleTableWithEnum=} obj - * @returns {TestSimpleTableWithEnum} - */ -static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum { - return (obj || new TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {MyGame.Example.Color} - */ -color():MyGame.Example.Color { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Green; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -mutate_color(value:MyGame.Example.Color):boolean { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -static addColor(builder:flatbuffers.Builder, color:MyGame.Example.Color) { - builder.addFieldInt8(0, color, MyGame.Example.Color.Green); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace MyGame.Example{ -export class Vec3 { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Vec3} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -x():number { - return this.bb.readFloat32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_x(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -y():number { - return this.bb.readFloat32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_y(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -z():number { - return this.bb.readFloat32(this.bb_pos + 8); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_z(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -test1():number { - return this.bb.readFloat64(this.bb_pos + 16); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_test1(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {MyGame.Example.Color} - */ -test2():MyGame.Example.Color { - return /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + 24)); -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -mutate_test2(value:MyGame.Example.Color):boolean { - var offset = this.bb.__offset(this.bb_pos, 24); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -test3(obj?:MyGame.Example.Test):MyGame.Example.Test { - return (obj || new MyGame.Example.Test).__init(this.bb_pos + 26, this.bb); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} test1 - * @param {MyGame.Example.Color} test2 - * @param {number} test3_a - * @param {number} test3_b - * @returns {flatbuffers.Offset} - */ -static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame.Example.Color, test3_a: number, test3_b: number):flatbuffers.Offset { - builder.prep(16, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); -}; - -} -} -/** - * @constructor - */ -export namespace MyGame.Example{ -export class Ability { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Ability} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Ability { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -id():number { - return this.bb.readUint32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_id(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -distance():number { - return this.bb.readUint32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_distance(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} id - * @param {number} distance - * @returns {flatbuffers.Offset} - */ -static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset { - builder.prep(4, 8); - builder.writeInt32(distance); - builder.writeInt32(id); - return builder.offset(); -}; - -} -} -/** - * @constructor - */ -export namespace MyGame.Example{ -export class Stat { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Stat} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Stat { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {Stat=} obj - * @returns {Stat} - */ -static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat { - return (obj || new Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -id():string -id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array -id(optionalEncoding?:any):string|Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @returns {flatbuffers.Long} - */ -val():flatbuffers.Long { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -mutate_val(value:flatbuffers.Long):boolean { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -count():number { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_count(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeUint16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startStat(builder:flatbuffers.Builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} idOffset - */ -static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, idOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} val - */ -static addVal(builder:flatbuffers.Builder, val:flatbuffers.Long) { - builder.addFieldInt64(1, val, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} count - */ -static addCount(builder:flatbuffers.Builder, count:number) { - builder.addFieldInt16(2, count, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endStat(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * an example documentation comment: monster object - * - * @constructor - */ -export namespace MyGame.Example{ -export class Monster { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Monster} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Monster { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {Monster=} obj - * @returns {Monster} - */ -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @returns {boolean} - */ -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('MONS'); -}; - -/** - * @param {MyGame.Example.Vec3=} obj - * @returns {MyGame.Example.Vec3} - */ -pos(obj?:MyGame.Example.Vec3):MyGame.Example.Vec3 { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame.Example.Vec3).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @returns {number} - */ -mana():number { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_mana(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -hp():number { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_hp(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -name():string -name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array -name(optionalEncoding?:any):string|Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -inventory(index: number):number { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -inventoryLength():number { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -inventoryArray():Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @returns {MyGame.Example.Color} - */ -color():MyGame.Example.Color { - var offset = this.bb.__offset(this.bb_pos, 16); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Blue; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -mutate_color(value:MyGame.Example.Color):boolean { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {MyGame.Example.Any} - */ -testType():MyGame.Example.Any { - var offset = this.bb.__offset(this.bb_pos, 18); - return offset ? /** @type {MyGame.Example.Any} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Any.NONE; -}; - -/** - * @param {MyGame.Example.Any} value - * @returns {boolean} - */ -mutate_test_type(value:MyGame.Example.Any):boolean { - var offset = this.bb.__offset(this.bb_pos, 18); - - if (offset === 0) { - return false; - } - - this.bb.writeUint8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -test<T extends flatbuffers.Table>(obj:T):T { - var offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -test4(index: number, obj?:MyGame.Example.Test):MyGame.Example.Test { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new MyGame.Example.Test).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; -}; - -/** - * @returns {number} - */ -test4Length():number { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -testarrayofstring(index: number):string -testarrayofstring(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array -testarrayofstring(index: number,optionalEncoding?:any):string|Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -testarrayofstringLength():number { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * an example documentation comment: this will end up in the generated code - * multiline too - * - * @param {number} index - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -testarrayoftables(index: number, obj?:MyGame.Example.Monster):MyGame.Example.Monster { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -testarrayoftablesLength():number { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -enemy(obj?:MyGame.Example.Monster):MyGame.Example.Monster { - var offset = this.bb.__offset(this.bb_pos, 28); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -testnestedflatbuffer(index: number):number { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -testnestedflatbufferLength():number { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -testnestedflatbufferArray():Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ -testempty(obj?:MyGame.Example.Stat):MyGame.Example.Stat { - var offset = this.bb.__offset(this.bb_pos, 32); - return offset ? (obj || new MyGame.Example.Stat).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {boolean} - */ -testbool():boolean { - var offset = this.bb.__offset(this.bb_pos, 34); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param {boolean} value - * @returns {boolean} - */ -mutate_testbool(value:boolean):boolean { - var offset = this.bb.__offset(this.bb_pos, 34); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, +value); - return true; -}; - -/** - * @returns {number} - */ -testhashs32Fnv1():number { - var offset = this.bb.__offset(this.bb_pos, 36); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testhashs32_fnv1(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 36); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -testhashu32Fnv1():number { - var offset = this.bb.__offset(this.bb_pos, 38); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testhashu32_fnv1(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 38); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -testhashs64Fnv1():flatbuffers.Long { - var offset = this.bb.__offset(this.bb_pos, 40); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -mutate_testhashs64_fnv1(value:flatbuffers.Long):boolean { - var offset = this.bb.__offset(this.bb_pos, 40); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -testhashu64Fnv1():flatbuffers.Long { - var offset = this.bb.__offset(this.bb_pos, 42); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -mutate_testhashu64_fnv1(value:flatbuffers.Long):boolean { - var offset = this.bb.__offset(this.bb_pos, 42); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -testhashs32Fnv1a():number { - var offset = this.bb.__offset(this.bb_pos, 44); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testhashs32_fnv1a(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 44); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -testhashu32Fnv1a():number { - var offset = this.bb.__offset(this.bb_pos, 46); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testhashu32_fnv1a(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 46); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -testhashs64Fnv1a():flatbuffers.Long { - var offset = this.bb.__offset(this.bb_pos, 48); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -mutate_testhashs64_fnv1a(value:flatbuffers.Long):boolean { - var offset = this.bb.__offset(this.bb_pos, 48); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -testhashu64Fnv1a():flatbuffers.Long { - var offset = this.bb.__offset(this.bb_pos, 50); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -mutate_testhashu64_fnv1a(value:flatbuffers.Long):boolean { - var offset = this.bb.__offset(this.bb_pos, 50); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {boolean} - */ -testarrayofbools(index: number):boolean { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; -}; - -/** - * @returns {number} - */ -testarrayofboolsLength():number { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Int8Array} - */ -testarrayofboolsArray():Int8Array { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @returns {number} - */ -testf():number { - var offset = this.bb.__offset(this.bb_pos, 54); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testf(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 54); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -testf2():number { - var offset = this.bb.__offset(this.bb_pos, 56); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testf2(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 56); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -testf3():number { - var offset = this.bb.__offset(this.bb_pos, 58); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_testf3(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 58); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -testarrayofstring2(index: number):string -testarrayofstring2(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array -testarrayofstring2(index: number,optionalEncoding?:any):string|Uint8Array { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -testarrayofstring2Length():number { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Ability=} obj - * @returns {MyGame.Example.Ability} - */ -testarrayofsortedstruct(index: number, obj?:MyGame.Example.Ability):MyGame.Example.Ability { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? (obj || new MyGame.Example.Ability).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; -}; - -/** - * @returns {number} - */ -testarrayofsortedstructLength():number { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startMonster(builder:flatbuffers.Builder) { - builder.startObject(30); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} posOffset - */ -static addPos(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset) { - builder.addFieldStruct(0, posOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} mana - */ -static addMana(builder:flatbuffers.Builder, mana:number) { - builder.addFieldInt16(1, mana, 150); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} hp - */ -static addHp(builder:flatbuffers.Builder, hp:number) { - builder.addFieldInt16(2, hp, 100); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} nameOffset - */ -static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, nameOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} inventoryOffset - */ -static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Offset) { - builder.addFieldOffset(5, inventoryOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -static createInventoryVector(builder:flatbuffers.Builder, data:number[] | Uint8Array):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startInventoryVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -static addColor(builder:flatbuffers.Builder, color:MyGame.Example.Color) { - builder.addFieldInt8(6, color, MyGame.Example.Color.Blue); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Any} testType - */ -static addTestType(builder:flatbuffers.Builder, testType:MyGame.Example.Any) { - builder.addFieldInt8(7, testType, MyGame.Example.Any.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testOffset - */ -static addTest(builder:flatbuffers.Builder, testOffset:flatbuffers.Offset) { - builder.addFieldOffset(8, testOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} test4Offset - */ -static addTest4(builder:flatbuffers.Builder, test4Offset:flatbuffers.Offset) { - builder.addFieldOffset(9, test4Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTest4Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstringOffset - */ -static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset:flatbuffers.Offset) { - builder.addFieldOffset(10, testarrayofstringOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestarrayofstringVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayoftablesOffset - */ -static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset:flatbuffers.Offset) { - builder.addFieldOffset(11, testarrayoftablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestarrayoftablesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} enemyOffset - */ -static addEnemy(builder:flatbuffers.Builder, enemyOffset:flatbuffers.Offset) { - builder.addFieldOffset(12, enemyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testnestedflatbufferOffset - */ -static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbufferOffset:flatbuffers.Offset) { - builder.addFieldOffset(13, testnestedflatbufferOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[] | Uint8Array):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestnestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testemptyOffset - */ -static addTestempty(builder:flatbuffers.Builder, testemptyOffset:flatbuffers.Offset) { - builder.addFieldOffset(14, testemptyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {boolean} testbool - */ -static addTestbool(builder:flatbuffers.Builder, testbool:boolean) { - builder.addFieldInt8(15, +testbool, +false); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1 - */ -static addTesthashs32Fnv1(builder:flatbuffers.Builder, testhashs32Fnv1:number) { - builder.addFieldInt32(16, testhashs32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1 - */ -static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) { - builder.addFieldInt32(17, testhashu32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1 - */ -static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:flatbuffers.Long) { - builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1 - */ -static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:flatbuffers.Long) { - builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1a - */ -static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) { - builder.addFieldInt32(20, testhashs32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1a - */ -static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number) { - builder.addFieldInt32(21, testhashu32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1a - */ -static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:flatbuffers.Long) { - builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1a - */ -static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:flatbuffers.Long) { - builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofboolsOffset - */ -static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) { - builder.addFieldOffset(24, testarrayofboolsOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<boolean>} data - * @returns {flatbuffers.Offset} - */ -static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(+data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestarrayofboolsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf - */ -static addTestf(builder:flatbuffers.Builder, testf:number) { - builder.addFieldFloat32(25, testf, 3.14159); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf2 - */ -static addTestf2(builder:flatbuffers.Builder, testf2:number) { - builder.addFieldFloat32(26, testf2, 3.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf3 - */ -static addTestf3(builder:flatbuffers.Builder, testf3:number) { - builder.addFieldFloat32(27, testf3, 0.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstring2Offset - */ -static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offset:flatbuffers.Offset) { - builder.addFieldOffset(28, testarrayofstring2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { -if(!data){ - return null -} - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestarrayofstring2Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofsortedstructOffset - */ -static addTestarrayofsortedstruct(builder:flatbuffers.Builder, testarrayofsortedstructOffset:flatbuffers.Offset) { - builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -static startTestarrayofsortedstructVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - builder.requiredField(offset, 10); // name - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} offset - */ -static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'MONS'); -}; - -} -}
diff --git a/third_party/flatbuffers/tests/monsterdata_python_wire.mon b/third_party/flatbuffers/tests/monsterdata_python_wire.mon deleted file mode 100644 index 190f43a..0000000 --- a/third_party/flatbuffers/tests/monsterdata_python_wire.mon +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/tests/monsterdata_test.golden b/third_party/flatbuffers/tests/monsterdata_test.golden deleted file mode 100644 index 73afc42..0000000 --- a/third_party/flatbuffers/tests/monsterdata_test.golden +++ /dev/null
@@ -1,48 +0,0 @@ -{ - pos: { - x: 1, - y: 2, - z: 3, - test1: 3, - test2: Green, - test3: { - a: 5, - b: 6 - } - }, - hp: 80, - name: "MyMonster", - inventory: [ - 0, - 1, - 2, - 3, - 4 - ], - test_type: Monster, - test: { - name: "Fred" - }, - test4: [ - { - a: 10, - b: 20 - }, - { - a: 30, - b: 40 - } - ], - testarrayofstring: [ - "test1", - "test2" - ], - testhashs32_fnv1: -579221183, - testhashu32_fnv1: 3715746113, - testhashs64_fnv1: 7930699090847568257, - testhashu64_fnv1: 7930699090847568257, - testhashs32_fnv1a: -1904106383, - testhashu32_fnv1a: 2390860913, - testhashs64_fnv1a: 4898026182817603057, - testhashu64_fnv1a: 4898026182817603057 -}
diff --git a/third_party/flatbuffers/tests/monsterdata_test.json b/third_party/flatbuffers/tests/monsterdata_test.json deleted file mode 100755 index e8e3e1d..0000000 --- a/third_party/flatbuffers/tests/monsterdata_test.json +++ /dev/null
@@ -1,55 +0,0 @@ -{ - pos: { - x: 1, - y: "2", - z: 3, - test1: 3, - test2: Green, - test3: { - a: 5, - b: 6 - } - }, - hp: 80, - name: "MyMonster", - inventory: [ - 0, - 1, - 2, - 3, - 4 - ], - test_type: Monster, - test: { - name: "Fred", - pos: null - }, - test4: [ - { - a: 10, - b: 20 - }, - { - b: "40", - a: 30 - } - ], - testarrayofstring: [ - "test1", - "test2" - ], - enemy: { - name: "Fred" - }, - testarrayofbools:[ - true, false, true - ], - testhashs32_fnv1: "This string is being hashed!", - testhashu32_fnv1: "This string is being hashed!", - testhashs64_fnv1: "This string is being hashed!", - testhashu64_fnv1: "This string is being hashed!", - testhashs32_fnv1a: "This string is being hashed!", - testhashu32_fnv1a: "This string is being hashed!", - testhashs64_fnv1a: "This string is being hashed!", - testhashu64_fnv1a: "This string is being hashed!", -}
diff --git a/third_party/flatbuffers/tests/monsterdata_test.mon b/third_party/flatbuffers/tests/monsterdata_test.mon deleted file mode 100644 index 21c4216..0000000 --- a/third_party/flatbuffers/tests/monsterdata_test.mon +++ /dev/null Binary files differ
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs deleted file mode 100644 index 5f979fe..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs +++ /dev/null
@@ -1,14 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA.NamespaceB -{ - -public enum EnumInNestedNS : sbyte -{ - A = 0, - B = 1, - C = 2, -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.go deleted file mode 100644 index 2b68991..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.go +++ /dev/null
@@ -1,16 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceB - -const ( - EnumInNestedNSA = 0 - EnumInNestedNSB = 1 - EnumInNestedNSC = 2 -) - -var EnumNamesEnumInNestedNS = map[int]string{ - EnumInNestedNSA:"A", - EnumInNestedNSB:"B", - EnumInNestedNSC:"C", -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.java deleted file mode 100644 index e23cecc..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.java +++ /dev/null
@@ -1,15 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA.NamespaceB; - -public final class EnumInNestedNS { - private EnumInNestedNS() { } - public static final byte A = 0; - public static final byte B = 1; - public static final byte C = 2; - - public static final String[] names = { "A", "B", "C", }; - - public static String name(int e) { return names[e]; } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php deleted file mode 100644 index d51cb41..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php +++ /dev/null
@@ -1,25 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA\NamespaceB; - -class EnumInNestedNS -{ - const A = 0; - const B = 1; - const C = 2; - - private static $names = array( - "A", - "B", - "C", - ); - - public static function Name($e) - { - if (!isset(self::$names[$e])) { - throw new \Exception(); - } - return self::$names[$e]; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.py deleted file mode 100644 index cb8218f..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.py +++ /dev/null
@@ -1,9 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceB - -class EnumInNestedNS(object): - A = 0 - B = 1 - C = 2 -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs deleted file mode 100644 index bb627ad..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs +++ /dev/null
@@ -1,30 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA.NamespaceB -{ - -using global::System; -using global::FlatBuffers; - -public struct StructInNestedNS : IFlatbufferObject -{ - private Struct __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public int A { get { return __p.bb.GetInt(__p.bb_pos + 0); } } - public void MutateA(int a) { __p.bb.PutInt(__p.bb_pos + 0, a); } - public int B { get { return __p.bb.GetInt(__p.bb_pos + 4); } } - public void MutateB(int b) { __p.bb.PutInt(__p.bb_pos + 4, b); } - - public static Offset<StructInNestedNS> CreateStructInNestedNS(FlatBufferBuilder builder, int A, int B) { - builder.Prep(4, 8); - builder.PutInt(B); - builder.PutInt(A); - return new Offset<StructInNestedNS>(builder.Offset); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go deleted file mode 100644 index 00840aa..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.go +++ /dev/null
@@ -1,41 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceB - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type StructInNestedNS struct { - _tab flatbuffers.Struct -} - -func (rcv *StructInNestedNS) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *StructInNestedNS) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *StructInNestedNS) A() int32 { - return rcv._tab.GetInt32(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *StructInNestedNS) MutateA(n int32) bool { - return rcv._tab.MutateInt32(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *StructInNestedNS) B() int32 { - return rcv._tab.GetInt32(rcv._tab.Pos + flatbuffers.UOffsetT(4)) -} -func (rcv *StructInNestedNS) MutateB(n int32) bool { - return rcv._tab.MutateInt32(rcv._tab.Pos+flatbuffers.UOffsetT(4), n) -} - -func CreateStructInNestedNS(builder *flatbuffers.Builder, a int32, b int32) flatbuffers.UOffsetT { - builder.Prep(4, 8) - builder.PrependInt32(b) - builder.PrependInt32(a) - return builder.Offset() -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java deleted file mode 100644 index 42d47c1..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java +++ /dev/null
@@ -1,27 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA.NamespaceB; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class StructInNestedNS extends Struct { - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public int a() { return bb.getInt(bb_pos + 0); } - public void mutateA(int a) { bb.putInt(bb_pos + 0, a); } - public int b() { return bb.getInt(bb_pos + 4); } - public void mutateB(int b) { bb.putInt(bb_pos + 4, b); } - - public static int createStructInNestedNS(FlatBufferBuilder builder, int a, int b) { - builder.prep(4, 8); - builder.putInt(b); - builder.putInt(a); - return builder.offset(); - } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.php deleted file mode 100644 index d305484..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.php +++ /dev/null
@@ -1,52 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA\NamespaceB; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class StructInNestedNS extends Struct -{ - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return StructInNestedNS - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return int - */ - public function GetA() - { - return $this->bb->getInt($this->bb_pos + 0); - } - - /** - * @return int - */ - public function GetB() - { - return $this->bb->getInt($this->bb_pos + 4); - } - - - /** - * @return int offset - */ - public static function createStructInNestedNS(FlatBufferBuilder $builder, $a, $b) - { - $builder->prep(4, 8); - $builder->putInt($b); - $builder->putInt($a); - return $builder->offset(); - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py deleted file mode 100644 index 59cceaa..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.py +++ /dev/null
@@ -1,23 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceB - -import flatbuffers - -class StructInNestedNS(object): - __slots__ = ['_tab'] - - # StructInNestedNS - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # StructInNestedNS - def A(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)) - # StructInNestedNS - def B(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4)) - -def CreateStructInNestedNS(builder, a, b): - builder.Prep(4, 8) - builder.PrependInt32(b) - builder.PrependInt32(a) - return builder.Offset()
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs deleted file mode 100644 index c33d1fb..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs +++ /dev/null
@@ -1,37 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA.NamespaceB -{ - -using global::System; -using global::FlatBuffers; - -public struct TableInNestedNS : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb) { return GetRootAsTableInNestedNS(_bb, new TableInNestedNS()); } - public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public TableInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public int Foo { get { int o = __p.__offset(4); return o != 0 ? __p.bb.GetInt(o + __p.bb_pos) : (int)0; } } - public bool MutateFoo(int foo) { int o = __p.__offset(4); if (o != 0) { __p.bb.PutInt(o + __p.bb_pos, foo); return true; } else { return false; } } - - public static Offset<TableInNestedNS> CreateTableInNestedNS(FlatBufferBuilder builder, - int foo = 0) { - builder.StartObject(1); - TableInNestedNS.AddFoo(builder, foo); - return TableInNestedNS.EndTableInNestedNS(builder); - } - - public static void StartTableInNestedNS(FlatBufferBuilder builder) { builder.StartObject(1); } - public static void AddFoo(FlatBufferBuilder builder, int foo) { builder.AddInt(0, foo, 0); } - public static Offset<TableInNestedNS> EndTableInNestedNS(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<TableInNestedNS>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go deleted file mode 100644 index 0e767b8..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.go +++ /dev/null
@@ -1,49 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceB - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type TableInNestedNS struct { - _tab flatbuffers.Table -} - -func GetRootAsTableInNestedNS(buf []byte, offset flatbuffers.UOffsetT) *TableInNestedNS { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &TableInNestedNS{} - x.Init(buf, n+offset) - return x -} - -func (rcv *TableInNestedNS) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *TableInNestedNS) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *TableInNestedNS) Foo() int32 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.GetInt32(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *TableInNestedNS) MutateFoo(n int32) bool { - return rcv._tab.MutateInt32Slot(4, n) -} - -func TableInNestedNSStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func TableInNestedNSAddFoo(builder *flatbuffers.Builder, foo int32) { - builder.PrependInt32Slot(0, foo, 0) -} -func TableInNestedNSEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java deleted file mode 100644 index 415fa69..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java +++ /dev/null
@@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA.NamespaceB; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class TableInNestedNS extends Table { - public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); } - public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public TableInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public int foo() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; } - public boolean mutateFoo(int foo) { int o = __offset(4); if (o != 0) { bb.putInt(o + bb_pos, foo); return true; } else { return false; } } - - public static int createTableInNestedNS(FlatBufferBuilder builder, - int foo) { - builder.startObject(1); - TableInNestedNS.addFoo(builder, foo); - return TableInNestedNS.endTableInNestedNS(builder); - } - - public static void startTableInNestedNS(FlatBufferBuilder builder) { builder.startObject(1); } - public static void addFoo(FlatBufferBuilder builder, int foo) { builder.addInt(0, foo, 0); } - public static int endTableInNestedNS(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.php deleted file mode 100644 index d16379d..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.php +++ /dev/null
@@ -1,84 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA\NamespaceB; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class TableInNestedNS extends Table -{ - /** - * @param ByteBuffer $bb - * @return TableInNestedNS - */ - public static function getRootAsTableInNestedNS(ByteBuffer $bb) - { - $obj = new TableInNestedNS(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return TableInNestedNS - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - /** - * @return int - */ - public function getFoo() - { - $o = $this->__offset(4); - return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startTableInNestedNS(FlatBufferBuilder $builder) - { - $builder->StartObject(1); - } - - /** - * @param FlatBufferBuilder $builder - * @return TableInNestedNS - */ - public static function createTableInNestedNS(FlatBufferBuilder $builder, $foo) - { - $builder->startObject(1); - self::addFoo($builder, $foo); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addFoo(FlatBufferBuilder $builder, $foo) - { - $builder->addIntX(0, $foo, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endTableInNestedNS(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py deleted file mode 100644 index d6d1674..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.py +++ /dev/null
@@ -1,30 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceB - -import flatbuffers - -class TableInNestedNS(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsTableInNestedNS(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TableInNestedNS() - x.Init(buf, n + offset) - return x - - # TableInNestedNS - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TableInNestedNS - def Foo(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) - return 0 - -def TableInNestedNSStart(builder): builder.StartObject(1) -def TableInNestedNSAddFoo(builder, foo): builder.PrependInt32Slot(0, foo, 0) -def TableInNestedNSEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/__init__.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/NamespaceB/__init__.py +++ /dev/null
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.cs deleted file mode 100644 index f28ed86..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.cs +++ /dev/null
@@ -1,36 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA -{ - -using global::System; -using global::FlatBuffers; - -public struct SecondTableInA : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb) { return GetRootAsSecondTableInA(_bb, new SecondTableInA()); } - public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public SecondTableInA __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceC.TableInC? ReferToC { get { int o = __p.__offset(4); return o != 0 ? (NamespaceC.TableInC?)(new NamespaceC.TableInC()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - - public static Offset<SecondTableInA> CreateSecondTableInA(FlatBufferBuilder builder, - Offset<NamespaceC.TableInC> refer_to_cOffset = default(Offset<NamespaceC.TableInC>)) { - builder.StartObject(1); - SecondTableInA.AddReferToC(builder, refer_to_cOffset); - return SecondTableInA.EndSecondTableInA(builder); - } - - public static void StartSecondTableInA(FlatBufferBuilder builder) { builder.StartObject(1); } - public static void AddReferToC(FlatBufferBuilder builder, Offset<NamespaceC.TableInC> referToCOffset) { builder.AddOffset(0, referToCOffset.Value, 0); } - public static Offset<SecondTableInA> EndSecondTableInA(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<SecondTableInA>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.go deleted file mode 100644 index bd691e8..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.go +++ /dev/null
@@ -1,50 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type SecondTableInA struct { - _tab flatbuffers.Table -} - -func GetRootAsSecondTableInA(buf []byte, offset flatbuffers.UOffsetT) *SecondTableInA { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &SecondTableInA{} - x.Init(buf, n+offset) - return x -} - -func (rcv *SecondTableInA) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *SecondTableInA) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *SecondTableInA) ReferToC(obj *TableInC) *TableInC { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(TableInC) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func SecondTableInAStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func SecondTableInAAddReferToC(builder *flatbuffers.Builder, referToC flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToC), 0) -} -func SecondTableInAEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.java deleted file mode 100644 index 7c56b88..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.java +++ /dev/null
@@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class SecondTableInA extends Table { - public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); } - public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public SecondTableInA __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceC.TableInC referToC() { return referToC(new NamespaceC.TableInC()); } - public NamespaceC.TableInC referToC(NamespaceC.TableInC obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - - public static int createSecondTableInA(FlatBufferBuilder builder, - int refer_to_cOffset) { - builder.startObject(1); - SecondTableInA.addReferToC(builder, refer_to_cOffset); - return SecondTableInA.endSecondTableInA(builder); - } - - public static void startSecondTableInA(FlatBufferBuilder builder) { builder.startObject(1); } - public static void addReferToC(FlatBufferBuilder builder, int referToCOffset) { builder.addOffset(0, referToCOffset, 0); } - public static int endSecondTableInA(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.php deleted file mode 100644 index c9bc65c..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.php +++ /dev/null
@@ -1,82 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class SecondTableInA extends Table -{ - /** - * @param ByteBuffer $bb - * @return SecondTableInA - */ - public static function getRootAsSecondTableInA(ByteBuffer $bb) - { - $obj = new SecondTableInA(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return SecondTableInA - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getReferToC() - { - $obj = new TableInC(); - $o = $this->__offset(4); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startSecondTableInA(FlatBufferBuilder $builder) - { - $builder->StartObject(1); - } - - /** - * @param FlatBufferBuilder $builder - * @return SecondTableInA - */ - public static function createSecondTableInA(FlatBufferBuilder $builder, $refer_to_c) - { - $builder->startObject(1); - self::addReferToC($builder, $refer_to_c); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addReferToC(FlatBufferBuilder $builder, $referToC) - { - $builder->addOffsetX(0, $referToC, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endSecondTableInA(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.py deleted file mode 100644 index 20dac3e..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/SecondTableInA.py +++ /dev/null
@@ -1,34 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceA - -import flatbuffers - -class SecondTableInA(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsSecondTableInA(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SecondTableInA() - x.Init(buf, n + offset) - return x - - # SecondTableInA - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SecondTableInA - def ReferToC(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .TableInC import TableInC - obj = TableInC() - obj.Init(self._tab.Bytes, x) - return obj - return None - -def SecondTableInAStart(builder): builder.StartObject(1) -def SecondTableInAAddReferToC(builder, referToC): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToC), 0) -def SecondTableInAEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.cs deleted file mode 100644 index 98f4e13..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.cs +++ /dev/null
@@ -1,38 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA -{ - -using System; -using FlatBuffers; - -public sealed class TableInC : Table { - public static TableInC GetRootAsTableInC(ByteBuffer _bb) { return GetRootAsTableInC(_bb, new TableInC()); } - public static TableInC GetRootAsTableInC(ByteBuffer _bb, TableInC obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public TableInC __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } - - public NamespaceA.TableInFirstNS ReferToA1 { get { return GetReferToA1(new NamespaceA.TableInFirstNS()); } } - public NamespaceA.TableInFirstNS GetReferToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } - public SecondTableInA ReferToA2 { get { return GetReferToA2(new SecondTableInA()); } } - public SecondTableInA GetReferToA2(SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } - - public static Offset<NamespaceC.TableInC> CreateTableInC(FlatBufferBuilder builder, - Offset<NamespaceA.TableInFirstNS> refer_to_a1Offset = default(Offset<NamespaceA.TableInFirstNS>), - Offset<SecondTableInA> refer_to_a2Offset = default(Offset<SecondTableInA>)) { - builder.StartObject(2); - TableInC.AddReferToA2(builder, refer_to_a2Offset); - TableInC.AddReferToA1(builder, refer_to_a1Offset); - return TableInC.EndTableInC(builder); - } - - public static void StartTableInC(FlatBufferBuilder builder) { builder.StartObject(2); } - public static void AddReferToA1(FlatBufferBuilder builder, Offset<NamespaceA.TableInFirstNS> referToA1Offset) { builder.AddOffset(0, referToA1Offset.Value, 0); } - public static void AddReferToA2(FlatBufferBuilder builder, Offset<SecondTableInA> referToA2Offset) { builder.AddOffset(1, referToA2Offset.Value, 0); } - public static Offset<NamespaceC.TableInC> EndTableInC(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<NamespaceC.TableInC>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.go deleted file mode 100644 index 6f3d3f2..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.go +++ /dev/null
@@ -1,46 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) -type TableInC struct { - _tab flatbuffers.Table -} - -func (rcv *TableInC) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *TableInC) ReferToA1(obj *TableInFirstNS) *TableInFirstNS { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(TableInFirstNS) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *TableInC) ReferToA2(obj *SecondTableInA) *SecondTableInA { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(SecondTableInA) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func TableInCStart(builder *flatbuffers.Builder) { builder.StartObject(2) } -func TableInCAddReferToA1(builder *flatbuffers.Builder, referToA1 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToA1), 0) } -func TableInCAddReferToA2(builder *flatbuffers.Builder, referToA2 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(referToA2), 0) } -func TableInCEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.java deleted file mode 100644 index 38fb3ab..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.java +++ /dev/null
@@ -1,38 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class TableInC extends Table { - public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); } - public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public TableInC __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } - - public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); } - public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } - public SecondTableInA referToA2() { return referToA2(new SecondTableInA()); } - public SecondTableInA referToA2(SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } - - public static int createTableInC(FlatBufferBuilder builder, - int refer_to_a1Offset, - int refer_to_a2Offset) { - builder.startObject(2); - TableInC.addReferToA2(builder, refer_to_a2Offset); - TableInC.addReferToA1(builder, refer_to_a1Offset); - return TableInC.endTableInC(builder); - } - - public static void startTableInC(FlatBufferBuilder builder) { builder.startObject(2); } - public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) { builder.addOffset(0, referToA1Offset, 0); } - public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) { builder.addOffset(1, referToA2Offset, 0); } - public static int endTableInC(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -}; -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.php deleted file mode 100644 index 49705f8..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.php +++ /dev/null
@@ -1,100 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class TableInC extends Table -{ - /** - * @param ByteBuffer $bb - * @return TableInC - */ - public static function getRootAsTableInC(ByteBuffer $bb) - { - $obj = new TableInC(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return TableInC - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getReferToA1() - { - $obj = new TableInFirstNS(); - $o = $this->__offset(4); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - public function getReferToA2() - { - $obj = new SecondTableInA(); - $o = $this->__offset(6); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startTableInC(FlatBufferBuilder $builder) - { - $builder->StartObject(2); - } - - /** - * @param FlatBufferBuilder $builder - * @return TableInC - */ - public static function createTableInC(FlatBufferBuilder $builder, $refer_to_a1, $refer_to_a2) - { - $builder->startObject(2); - self::addReferToA1($builder, $refer_to_a1); - self::addReferToA2($builder, $refer_to_a2); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addReferToA1(FlatBufferBuilder $builder, $referToA1) - { - $builder->addOffsetX(0, $referToA1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addReferToA2(FlatBufferBuilder $builder, $referToA2) - { - $builder->addOffsetX(1, $referToA2, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endTableInC(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.py deleted file mode 100644 index 4afea1a..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInC.py +++ /dev/null
@@ -1,39 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceA - -import flatbuffers - -class TableInC(object): - __slots__ = ['_tab'] - - # TableInC - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TableInC - def ReferToA1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .TableInFirstNS import TableInFirstNS - obj = TableInFirstNS() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # TableInC - def ReferToA2(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .SecondTableInA import SecondTableInA - obj = SecondTableInA() - obj.Init(self._tab.Bytes, x) - return obj - return None - -def TableInCStart(builder): builder.StartObject(2) -def TableInCAddReferToA1(builder, referToA1): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0) -def TableInCAddReferToA2(builder, referToA2): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0) -def TableInCEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.cs deleted file mode 100644 index 20f4b4b..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.cs +++ /dev/null
@@ -1,34 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA -{ - -using global::System; -using global::FlatBuffers; - -public struct TableInFirstNS : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static TableInFirstNS GetRootAsTableInFirstNS(ByteBuffer _bb) { return GetRootAsTableInFirstNS(_bb, new TableInFirstNS()); } - public static TableInFirstNS GetRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public TableInFirstNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceA.NamespaceB.TableInNestedNS? FooTable { get { int o = __p.__offset(4); return o != 0 ? (NamespaceA.NamespaceB.TableInNestedNS?)(new NamespaceA.NamespaceB.TableInNestedNS()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - public NamespaceA.NamespaceB.EnumInNestedNS FooEnum { get { int o = __p.__offset(6); return o != 0 ? (NamespaceA.NamespaceB.EnumInNestedNS)__p.bb.GetSbyte(o + __p.bb_pos) : NamespaceA.NamespaceB.EnumInNestedNS.A; } } - public bool MutateFooEnum(NamespaceA.NamespaceB.EnumInNestedNS foo_enum) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutSbyte(o + __p.bb_pos, (sbyte)foo_enum); return true; } else { return false; } } - public NamespaceA.NamespaceB.StructInNestedNS? FooStruct { get { int o = __p.__offset(8); return o != 0 ? (NamespaceA.NamespaceB.StructInNestedNS?)(new NamespaceA.NamespaceB.StructInNestedNS()).__assign(o + __p.bb_pos, __p.bb) : null; } } - - public static void StartTableInFirstNS(FlatBufferBuilder builder) { builder.StartObject(3); } - public static void AddFooTable(FlatBufferBuilder builder, Offset<NamespaceA.NamespaceB.TableInNestedNS> fooTableOffset) { builder.AddOffset(0, fooTableOffset.Value, 0); } - public static void AddFooEnum(FlatBufferBuilder builder, NamespaceA.NamespaceB.EnumInNestedNS fooEnum) { builder.AddSbyte(1, (sbyte)fooEnum, 0); } - public static void AddFooStruct(FlatBufferBuilder builder, Offset<NamespaceA.NamespaceB.StructInNestedNS> fooStructOffset) { builder.AddStruct(2, fooStructOffset.Value, 0); } - public static Offset<TableInFirstNS> EndTableInFirstNS(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<TableInFirstNS>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.go b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.go deleted file mode 100644 index b3354d3..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.go +++ /dev/null
@@ -1,81 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type TableInFirstNS struct { - _tab flatbuffers.Table -} - -func GetRootAsTableInFirstNS(buf []byte, offset flatbuffers.UOffsetT) *TableInFirstNS { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &TableInFirstNS{} - x.Init(buf, n+offset) - return x -} - -func (rcv *TableInFirstNS) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *TableInFirstNS) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *TableInFirstNS) FooTable(obj *TableInNestedNS) *TableInNestedNS { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(TableInNestedNS) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *TableInFirstNS) FooEnum() int8 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.GetInt8(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *TableInFirstNS) MutateFooEnum(n int8) bool { - return rcv._tab.MutateInt8Slot(6, n) -} - -func (rcv *TableInFirstNS) FooStruct(obj *StructInNestedNS) *StructInNestedNS { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - x := o + rcv._tab.Pos - if obj == nil { - obj = new(StructInNestedNS) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func TableInFirstNSStart(builder *flatbuffers.Builder) { - builder.StartObject(3) -} -func TableInFirstNSAddFooTable(builder *flatbuffers.Builder, fooTable flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(fooTable), 0) -} -func TableInFirstNSAddFooEnum(builder *flatbuffers.Builder, fooEnum int8) { - builder.PrependInt8Slot(1, fooEnum, 0) -} -func TableInFirstNSAddFooStruct(builder *flatbuffers.Builder, fooStruct flatbuffers.UOffsetT) { - builder.PrependStructSlot(2, flatbuffers.UOffsetT(fooStruct), 0) -} -func TableInFirstNSEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.java b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.java deleted file mode 100644 index b03c462..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.java +++ /dev/null
@@ -1,33 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceA; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class TableInFirstNS extends Table { - public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); } - public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public TableInFirstNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceA.NamespaceB.TableInNestedNS fooTable() { return fooTable(new NamespaceA.NamespaceB.TableInNestedNS()); } - public NamespaceA.NamespaceB.TableInNestedNS fooTable(NamespaceA.NamespaceB.TableInNestedNS obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - public byte fooEnum() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; } - public boolean mutateFooEnum(byte foo_enum) { int o = __offset(6); if (o != 0) { bb.put(o + bb_pos, foo_enum); return true; } else { return false; } } - public NamespaceA.NamespaceB.StructInNestedNS fooStruct() { return fooStruct(new NamespaceA.NamespaceB.StructInNestedNS()); } - public NamespaceA.NamespaceB.StructInNestedNS fooStruct(NamespaceA.NamespaceB.StructInNestedNS obj) { int o = __offset(8); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; } - - public static void startTableInFirstNS(FlatBufferBuilder builder) { builder.startObject(3); } - public static void addFooTable(FlatBufferBuilder builder, int fooTableOffset) { builder.addOffset(0, fooTableOffset, 0); } - public static void addFooEnum(FlatBufferBuilder builder, byte fooEnum) { builder.addByte(1, fooEnum, 0); } - public static void addFooStruct(FlatBufferBuilder builder, int fooStructOffset) { builder.addStruct(2, fooStructOffset, 0); } - public static int endTableInFirstNS(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.php b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.php deleted file mode 100644 index 9fb29c3..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.php +++ /dev/null
@@ -1,120 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceA; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class TableInFirstNS extends Table -{ - /** - * @param ByteBuffer $bb - * @return TableInFirstNS - */ - public static function getRootAsTableInFirstNS(ByteBuffer $bb) - { - $obj = new TableInFirstNS(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return TableInFirstNS - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getFooTable() - { - $obj = new TableInNestedNS(); - $o = $this->__offset(4); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @return sbyte - */ - public function getFooEnum() - { - $o = $this->__offset(6); - return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \NamespaceA\NamespaceB\EnumInNestedNS::A; - } - - public function getFooStruct() - { - $obj = new StructInNestedNS(); - $o = $this->__offset(8); - return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startTableInFirstNS(FlatBufferBuilder $builder) - { - $builder->StartObject(3); - } - - /** - * @param FlatBufferBuilder $builder - * @return TableInFirstNS - */ - public static function createTableInFirstNS(FlatBufferBuilder $builder, $foo_table, $foo_enum, $foo_struct) - { - $builder->startObject(3); - self::addFooTable($builder, $foo_table); - self::addFooEnum($builder, $foo_enum); - self::addFooStruct($builder, $foo_struct); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addFooTable(FlatBufferBuilder $builder, $fooTable) - { - $builder->addOffsetX(0, $fooTable, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param sbyte - * @return void - */ - public static function addFooEnum(FlatBufferBuilder $builder, $fooEnum) - { - $builder->addSbyteX(1, $fooEnum, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addFooStruct(FlatBufferBuilder $builder, $fooStruct) - { - $builder->addStructX(2, $fooStruct, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endTableInFirstNS(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.py deleted file mode 100644 index 40cbeba..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.py +++ /dev/null
@@ -1,54 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceA - -import flatbuffers - -class TableInFirstNS(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsTableInFirstNS(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TableInFirstNS() - x.Init(buf, n + offset) - return x - - # TableInFirstNS - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TableInFirstNS - def FooTable(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .TableInNestedNS import TableInNestedNS - obj = TableInNestedNS() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # TableInFirstNS - def FooEnum(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) - return 0 - - # TableInFirstNS - def FooStruct(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - x = o + self._tab.Pos - from .StructInNestedNS import StructInNestedNS - obj = StructInNestedNS() - obj.Init(self._tab.Bytes, x) - return obj - return None - -def TableInFirstNSStart(builder): builder.StartObject(3) -def TableInFirstNSAddFooTable(builder, fooTable): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fooTable), 0) -def TableInFirstNSAddFooEnum(builder, fooEnum): builder.PrependInt8Slot(1, fooEnum, 0) -def TableInFirstNSAddFooStruct(builder, fooStruct): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(fooStruct), 0) -def TableInFirstNSEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceA/__init__.py b/third_party/flatbuffers/tests/namespace_test/NamespaceA/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceA/__init__.py +++ /dev/null
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.cs b/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.cs deleted file mode 100644 index c7f2c8a..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.cs +++ /dev/null
@@ -1,40 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceC -{ - -using global::System; -using global::FlatBuffers; - -public struct TableInC : IFlatbufferObject -{ - private Table __p; - public ByteBuffer ByteBuffer { get { return __p.bb; } } - public static TableInC GetRootAsTableInC(ByteBuffer _bb) { return GetRootAsTableInC(_bb, new TableInC()); } - public static TableInC GetRootAsTableInC(ByteBuffer _bb, TableInC obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } - public void __init(int _i, ByteBuffer _bb) { __p.bb_pos = _i; __p.bb = _bb; } - public TableInC __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceA.TableInFirstNS? ReferToA1 { get { int o = __p.__offset(4); return o != 0 ? (NamespaceA.TableInFirstNS?)(new NamespaceA.TableInFirstNS()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - public NamespaceA.SecondTableInA? ReferToA2 { get { int o = __p.__offset(6); return o != 0 ? (NamespaceA.SecondTableInA?)(new NamespaceA.SecondTableInA()).__assign(__p.__indirect(o + __p.bb_pos), __p.bb) : null; } } - - public static Offset<TableInC> CreateTableInC(FlatBufferBuilder builder, - Offset<NamespaceA.TableInFirstNS> refer_to_a1Offset = default(Offset<NamespaceA.TableInFirstNS>), - Offset<NamespaceA.SecondTableInA> refer_to_a2Offset = default(Offset<NamespaceA.SecondTableInA>)) { - builder.StartObject(2); - TableInC.AddReferToA2(builder, refer_to_a2Offset); - TableInC.AddReferToA1(builder, refer_to_a1Offset); - return TableInC.EndTableInC(builder); - } - - public static void StartTableInC(FlatBufferBuilder builder) { builder.StartObject(2); } - public static void AddReferToA1(FlatBufferBuilder builder, Offset<NamespaceA.TableInFirstNS> referToA1Offset) { builder.AddOffset(0, referToA1Offset.Value, 0); } - public static void AddReferToA2(FlatBufferBuilder builder, Offset<NamespaceA.SecondTableInA> referToA2Offset) { builder.AddOffset(1, referToA2Offset.Value, 0); } - public static Offset<TableInC> EndTableInC(FlatBufferBuilder builder) { - int o = builder.EndObject(); - return new Offset<TableInC>(o); - } -}; - - -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.go b/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.go deleted file mode 100644 index 7e6c733..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.go +++ /dev/null
@@ -1,66 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceC - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type TableInC struct { - _tab flatbuffers.Table -} - -func GetRootAsTableInC(buf []byte, offset flatbuffers.UOffsetT) *TableInC { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &TableInC{} - x.Init(buf, n+offset) - return x -} - -func (rcv *TableInC) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *TableInC) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *TableInC) ReferToA1(obj *TableInFirstNS) *TableInFirstNS { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(TableInFirstNS) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *TableInC) ReferToA2(obj *SecondTableInA) *SecondTableInA { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - x := rcv._tab.Indirect(o + rcv._tab.Pos) - if obj == nil { - obj = new(SecondTableInA) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func TableInCStart(builder *flatbuffers.Builder) { - builder.StartObject(2) -} -func TableInCAddReferToA1(builder *flatbuffers.Builder, referToA1 flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToA1), 0) -} -func TableInCAddReferToA2(builder *flatbuffers.Builder, referToA2 flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(referToA2), 0) -} -func TableInCEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.java b/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.java deleted file mode 100644 index 56d4954..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.java +++ /dev/null
@@ -1,39 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -package NamespaceC; - -import java.nio.*; -import java.lang.*; -import java.util.*; -import com.google.flatbuffers.*; - -@SuppressWarnings("unused") -public final class TableInC extends Table { - public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); } - public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } - public TableInC __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - - public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); } - public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - public NamespaceA.SecondTableInA referToA2() { return referToA2(new NamespaceA.SecondTableInA()); } - public NamespaceA.SecondTableInA referToA2(NamespaceA.SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; } - - public static int createTableInC(FlatBufferBuilder builder, - int refer_to_a1Offset, - int refer_to_a2Offset) { - builder.startObject(2); - TableInC.addReferToA2(builder, refer_to_a2Offset); - TableInC.addReferToA1(builder, refer_to_a1Offset); - return TableInC.endTableInC(builder); - } - - public static void startTableInC(FlatBufferBuilder builder) { builder.startObject(2); } - public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) { builder.addOffset(0, referToA1Offset, 0); } - public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) { builder.addOffset(1, referToA2Offset, 0); } - public static int endTableInC(FlatBufferBuilder builder) { - int o = builder.endObject(); - return o; - } -} -
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.php b/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.php deleted file mode 100644 index 116aea1..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.php +++ /dev/null
@@ -1,100 +0,0 @@ -<?php -// automatically generated by the FlatBuffers compiler, do not modify - -namespace NamespaceC; - -use \Google\FlatBuffers\Struct; -use \Google\FlatBuffers\Table; -use \Google\FlatBuffers\ByteBuffer; -use \Google\FlatBuffers\FlatBufferBuilder; - -class TableInC extends Table -{ - /** - * @param ByteBuffer $bb - * @return TableInC - */ - public static function getRootAsTableInC(ByteBuffer $bb) - { - $obj = new TableInC(); - return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb)); - } - - /** - * @param int $_i offset - * @param ByteBuffer $_bb - * @return TableInC - **/ - public function init($_i, ByteBuffer $_bb) - { - $this->bb_pos = $_i; - $this->bb = $_bb; - return $this; - } - - public function getReferToA1() - { - $obj = new TableInFirstNS(); - $o = $this->__offset(4); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - public function getReferToA2() - { - $obj = new SecondTableInA(); - $o = $this->__offset(6); - return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0; - } - - /** - * @param FlatBufferBuilder $builder - * @return void - */ - public static function startTableInC(FlatBufferBuilder $builder) - { - $builder->StartObject(2); - } - - /** - * @param FlatBufferBuilder $builder - * @return TableInC - */ - public static function createTableInC(FlatBufferBuilder $builder, $refer_to_a1, $refer_to_a2) - { - $builder->startObject(2); - self::addReferToA1($builder, $refer_to_a1); - self::addReferToA2($builder, $refer_to_a2); - $o = $builder->endObject(); - return $o; - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addReferToA1(FlatBufferBuilder $builder, $referToA1) - { - $builder->addOffsetX(0, $referToA1, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @param int - * @return void - */ - public static function addReferToA2(FlatBufferBuilder $builder, $referToA2) - { - $builder->addOffsetX(1, $referToA2, 0); - } - - /** - * @param FlatBufferBuilder $builder - * @return int table offset - */ - public static function endTableInC(FlatBufferBuilder $builder) - { - $o = $builder->endObject(); - return $o; - } -}
diff --git a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.py b/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.py deleted file mode 100644 index 90b8736..0000000 --- a/third_party/flatbuffers/tests/namespace_test/NamespaceC/TableInC.py +++ /dev/null
@@ -1,46 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: NamespaceC - -import flatbuffers - -class TableInC(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsTableInC(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TableInC() - x.Init(buf, n + offset) - return x - - # TableInC - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TableInC - def ReferToA1(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .TableInFirstNS import TableInFirstNS - obj = TableInFirstNS() - obj.Init(self._tab.Bytes, x) - return obj - return None - - # TableInC - def ReferToA2(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - x = self._tab.Indirect(o + self._tab.Pos) - from .SecondTableInA import SecondTableInA - obj = SecondTableInA() - obj.Init(self._tab.Bytes, x) - return obj - return None - -def TableInCStart(builder): builder.StartObject(2) -def TableInCAddReferToA1(builder, referToA1): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToA1), 0) -def TableInCAddReferToA2(builder, referToA2): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(referToA2), 0) -def TableInCEnd(builder): return builder.EndObject()
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test1.fbs b/third_party/flatbuffers/tests/namespace_test/namespace_test1.fbs deleted file mode 100644 index 49449bf..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test1.fbs +++ /dev/null
@@ -1,17 +0,0 @@ -namespace NamespaceA.NamespaceB; - -table TableInNestedNS -{ - foo:int; -} - -enum EnumInNestedNS:byte -{ - A, B, C -} - -struct StructInNestedNS -{ - a:int; - b:int; -} \ No newline at end of file
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.h b/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.h deleted file mode 100644 index 2a71fbc..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.h +++ /dev/null
@@ -1,116 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_ -#define FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_ - -#include "flatbuffers/flatbuffers.h" - -namespace NamespaceA { -namespace NamespaceB { - -struct TableInNestedNS; - -struct StructInNestedNS; - -enum EnumInNestedNS { - EnumInNestedNS_A = 0, - EnumInNestedNS_B = 1, - EnumInNestedNS_C = 2, - EnumInNestedNS_MIN = EnumInNestedNS_A, - EnumInNestedNS_MAX = EnumInNestedNS_C -}; - -inline const char **EnumNamesEnumInNestedNS() { - static const char *names[] = { - "A", - "B", - "C", - nullptr - }; - return names; -} - -inline const char *EnumNameEnumInNestedNS(EnumInNestedNS e) { - const size_t index = static_cast<int>(e); - return EnumNamesEnumInNestedNS()[index]; -} - -MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS { - private: - int32_t a_; - int32_t b_; - - public: - StructInNestedNS() { - memset(this, 0, sizeof(StructInNestedNS)); - } - StructInNestedNS(const StructInNestedNS &_o) { - memcpy(this, &_o, sizeof(StructInNestedNS)); - } - StructInNestedNS(int32_t _a, int32_t _b) - : a_(flatbuffers::EndianScalar(_a)), - b_(flatbuffers::EndianScalar(_b)) { - } - int32_t a() const { - return flatbuffers::EndianScalar(a_); - } - void mutate_a(int32_t _a) { - flatbuffers::WriteScalar(&a_, _a); - } - int32_t b() const { - return flatbuffers::EndianScalar(b_); - } - void mutate_b(int32_t _b) { - flatbuffers::WriteScalar(&b_, _b); - } -}; -STRUCT_END(StructInNestedNS, 8); - -struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_FOO = 4 - }; - int32_t foo() const { - return GetField<int32_t>(VT_FOO, 0); - } - bool mutate_foo(int32_t _foo) { - return SetField<int32_t>(VT_FOO, _foo, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_FOO) && - verifier.EndTable(); - } -}; - -struct TableInNestedNSBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_foo(int32_t foo) { - fbb_.AddElement<int32_t>(TableInNestedNS::VT_FOO, foo, 0); - } - TableInNestedNSBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TableInNestedNSBuilder &operator=(const TableInNestedNSBuilder &); - flatbuffers::Offset<TableInNestedNS> Finish() { - const auto end = fbb_.EndTable(start_, 1); - auto o = flatbuffers::Offset<TableInNestedNS>(end); - return o; - } -}; - -inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t foo = 0) { - TableInNestedNSBuilder builder_(_fbb); - builder_.add_foo(foo); - return builder_.Finish(); -} - -} // namespace NamespaceB -} // namespace NamespaceA - -#endif // FLATBUFFERS_GENERATED_NAMESPACETEST1_NAMESPACEA_NAMESPACEB_H_
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.js b/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.js deleted file mode 100644 index 7551a18..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.js +++ /dev/null
@@ -1,190 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var NamespaceA = NamespaceA || {}; - -/** - * @const - * @namespace - */ -NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; - -/** - * @enum - */ -NamespaceA.NamespaceB.EnumInNestedNS = { - A: 0, - B: 1, - C: 2 -}; - -/** - * @constructor - */ -NamespaceA.NamespaceB.TableInNestedNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -NamespaceA.NamespaceB.TableInNestedNS.getRootAsTableInNestedNS = function(bb, obj) { - return (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.foo = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.mutate_foo = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.NamespaceB.TableInNestedNS.startTableInNestedNS = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} foo - */ -NamespaceA.NamespaceB.TableInNestedNS.addFoo = function(builder, foo) { - builder.addFieldInt32(0, foo, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.NamespaceB.TableInNestedNS.endTableInNestedNS = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -NamespaceA.NamespaceB.StructInNestedNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.NamespaceB.StructInNestedNS} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.a = function() { - return this.bb.readInt32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.mutate_a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.b = function() { - return this.bb.readInt32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.mutate_b = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -NamespaceA.NamespaceB.StructInNestedNS.createStructInNestedNS = function(builder, a, b) { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); -}; - -// Exports for Node.js and RequireJS -this.NamespaceA = NamespaceA;
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.ts b/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.ts deleted file mode 100644 index 42a1a69..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test1_generated.ts +++ /dev/null
@@ -1,179 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @enum - */ -export namespace NamespaceA.NamespaceB{ -export enum EnumInNestedNS{ - A= 0, - B= 1, - C= 2 -}}; - -/** - * @constructor - */ -export namespace NamespaceA.NamespaceB{ -export class TableInNestedNS { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {TableInNestedNS} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {TableInNestedNS=} obj - * @returns {TableInNestedNS} - */ -static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS { - return (obj || new TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {number} - */ -foo():number { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_foo(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startTableInNestedNS(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} foo - */ -static addFoo(builder:flatbuffers.Builder, foo:number) { - builder.addFieldInt32(0, foo, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace NamespaceA.NamespaceB{ -export class StructInNestedNS { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {StructInNestedNS} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -a():number { - return this.bb.readInt32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_a(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -b():number { - return this.bb.readInt32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -mutate_b(value:number):boolean { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); -}; - -} -}
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test2.fbs b/third_party/flatbuffers/tests/namespace_test/namespace_test2.fbs deleted file mode 100644 index 11d7dea..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test2.fbs +++ /dev/null
@@ -1,24 +0,0 @@ -include "namespace_test1.fbs"; - -namespace NamespaceA; - -table TableInFirstNS -{ - foo_table:NamespaceB.TableInNestedNS; - foo_enum:NamespaceB.EnumInNestedNS; - foo_struct:NamespaceB.StructInNestedNS; -} - -// Test switching namespaces inside a file. -namespace NamespaceC; - -table TableInC { - refer_to_a1:NamespaceA.TableInFirstNS; - refer_to_a2:NamespaceA.SecondTableInA; -} - -namespace NamespaceA; - -table SecondTableInA { - refer_to_c:NamespaceC.TableInC; -}
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.h b/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.h deleted file mode 100644 index 4e2a622..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.h +++ /dev/null
@@ -1,217 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_ -#define FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_ - -#include "flatbuffers/flatbuffers.h" - -#include "namespace_test1_generated.h" - -namespace NamespaceA { - -struct TableInFirstNS; - -} // namespace NamespaceA - -namespace NamespaceC { - -struct TableInC; - -} // namespace NamespaceC - -namespace NamespaceA { - -struct SecondTableInA; - -struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_FOO_TABLE = 4, - VT_FOO_ENUM = 6, - VT_FOO_STRUCT = 8 - }; - const NamespaceA::NamespaceB::TableInNestedNS *foo_table() const { - return GetPointer<const NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE); - } - NamespaceA::NamespaceB::TableInNestedNS *mutable_foo_table() { - return GetPointer<NamespaceA::NamespaceB::TableInNestedNS *>(VT_FOO_TABLE); - } - NamespaceA::NamespaceB::EnumInNestedNS foo_enum() const { - return static_cast<NamespaceA::NamespaceB::EnumInNestedNS>(GetField<int8_t>(VT_FOO_ENUM, 0)); - } - bool mutate_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS _foo_enum) { - return SetField<int8_t>(VT_FOO_ENUM, static_cast<int8_t>(_foo_enum), 0); - } - const NamespaceA::NamespaceB::StructInNestedNS *foo_struct() const { - return GetStruct<const NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT); - } - NamespaceA::NamespaceB::StructInNestedNS *mutable_foo_struct() { - return GetStruct<NamespaceA::NamespaceB::StructInNestedNS *>(VT_FOO_STRUCT); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_FOO_TABLE) && - verifier.VerifyTable(foo_table()) && - VerifyField<int8_t>(verifier, VT_FOO_ENUM) && - VerifyField<NamespaceA::NamespaceB::StructInNestedNS>(verifier, VT_FOO_STRUCT) && - verifier.EndTable(); - } -}; - -struct TableInFirstNSBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_foo_table(flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table) { - fbb_.AddOffset(TableInFirstNS::VT_FOO_TABLE, foo_table); - } - void add_foo_enum(NamespaceA::NamespaceB::EnumInNestedNS foo_enum) { - fbb_.AddElement<int8_t>(TableInFirstNS::VT_FOO_ENUM, static_cast<int8_t>(foo_enum), 0); - } - void add_foo_struct(const NamespaceA::NamespaceB::StructInNestedNS *foo_struct) { - fbb_.AddStruct(TableInFirstNS::VT_FOO_STRUCT, foo_struct); - } - TableInFirstNSBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TableInFirstNSBuilder &operator=(const TableInFirstNSBuilder &); - flatbuffers::Offset<TableInFirstNS> Finish() { - const auto end = fbb_.EndTable(start_, 3); - auto o = flatbuffers::Offset<TableInFirstNS>(end); - return o; - } -}; - -inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0, - NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A, - const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = 0) { - TableInFirstNSBuilder builder_(_fbb); - builder_.add_foo_struct(foo_struct); - builder_.add_foo_table(foo_table); - builder_.add_foo_enum(foo_enum); - return builder_.Finish(); -} - -} // namespace NamespaceA - -namespace NamespaceC { - -struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_REFER_TO_A1 = 4, - VT_REFER_TO_A2 = 6 - }; - const NamespaceA::TableInFirstNS *refer_to_a1() const { - return GetPointer<const NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1); - } - NamespaceA::TableInFirstNS *mutable_refer_to_a1() { - return GetPointer<NamespaceA::TableInFirstNS *>(VT_REFER_TO_A1); - } - const NamespaceA::SecondTableInA *refer_to_a2() const { - return GetPointer<const NamespaceA::SecondTableInA *>(VT_REFER_TO_A2); - } - NamespaceA::SecondTableInA *mutable_refer_to_a2() { - return GetPointer<NamespaceA::SecondTableInA *>(VT_REFER_TO_A2); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_REFER_TO_A1) && - verifier.VerifyTable(refer_to_a1()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_REFER_TO_A2) && - verifier.VerifyTable(refer_to_a2()) && - verifier.EndTable(); - } -}; - -struct TableInCBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_refer_to_a1(flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1) { - fbb_.AddOffset(TableInC::VT_REFER_TO_A1, refer_to_a1); - } - void add_refer_to_a2(flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2) { - fbb_.AddOffset(TableInC::VT_REFER_TO_A2, refer_to_a2); - } - TableInCBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - TableInCBuilder &operator=(const TableInCBuilder &); - flatbuffers::Offset<TableInC> Finish() { - const auto end = fbb_.EndTable(start_, 2); - auto o = flatbuffers::Offset<TableInC>(end); - return o; - } -}; - -inline flatbuffers::Offset<TableInC> CreateTableInC( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1 = 0, - flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2 = 0) { - TableInCBuilder builder_(_fbb); - builder_.add_refer_to_a2(refer_to_a2); - builder_.add_refer_to_a1(refer_to_a1); - return builder_.Finish(); -} - -} // namespace NamespaceC - -namespace NamespaceA { - -struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - enum { - VT_REFER_TO_C = 4 - }; - const NamespaceC::TableInC *refer_to_c() const { - return GetPointer<const NamespaceC::TableInC *>(VT_REFER_TO_C); - } - NamespaceC::TableInC *mutable_refer_to_c() { - return GetPointer<NamespaceC::TableInC *>(VT_REFER_TO_C); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_REFER_TO_C) && - verifier.VerifyTable(refer_to_c()) && - verifier.EndTable(); - } -}; - -struct SecondTableInABuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_refer_to_c(flatbuffers::Offset<NamespaceC::TableInC> refer_to_c) { - fbb_.AddOffset(SecondTableInA::VT_REFER_TO_C, refer_to_c); - } - SecondTableInABuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - SecondTableInABuilder &operator=(const SecondTableInABuilder &); - flatbuffers::Offset<SecondTableInA> Finish() { - const auto end = fbb_.EndTable(start_, 1); - auto o = flatbuffers::Offset<SecondTableInA>(end); - return o; - } -}; - -inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset<NamespaceC::TableInC> refer_to_c = 0) { - SecondTableInABuilder builder_(_fbb); - builder_.add_refer_to_c(refer_to_c); - return builder_.Finish(); -} - -} // namespace NamespaceA - -namespace NamespaceC { - -} // namespace NamespaceC - -namespace NamespaceA { - -} // namespace NamespaceA - -#endif // FLATBUFFERS_GENERATED_NAMESPACETEST2_NAMESPACEA_H_
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.js b/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.js deleted file mode 100644 index c1c25ef..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.js +++ /dev/null
@@ -1,292 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var NamespaceA = NamespaceA || {}; - -/** - * @const - * @namespace - */ -NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; - -/** - * @const - * @namespace - */ -var NamespaceC = NamespaceC || {}; - -/** - * @constructor - */ -NamespaceA.TableInFirstNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.TableInFirstNS} - */ -NamespaceA.TableInFirstNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.TableInFirstNS=} obj - * @returns {NamespaceA.TableInFirstNS} - */ -NamespaceA.TableInFirstNS.getRootAsTableInFirstNS = function(bb, obj) { - return (obj || new NamespaceA.TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -NamespaceA.TableInFirstNS.prototype.fooTable = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {NamespaceA.NamespaceB.EnumInNestedNS} - */ -NamespaceA.TableInFirstNS.prototype.fooEnum = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NamespaceA.NamespaceB.EnumInNestedNS.A; -}; - -/** - * @param {NamespaceA.NamespaceB.EnumInNestedNS} value - * @returns {boolean} - */ -NamespaceA.TableInFirstNS.prototype.mutate_foo_enum = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {NamespaceA.NamespaceB.StructInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.StructInNestedNS} - */ -NamespaceA.TableInFirstNS.prototype.fooStruct = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.TableInFirstNS.startTableInFirstNS = function(builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooTableOffset - */ -NamespaceA.TableInFirstNS.addFooTable = function(builder, fooTableOffset) { - builder.addFieldOffset(0, fooTableOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum - */ -NamespaceA.TableInFirstNS.addFooEnum = function(builder, fooEnum) { - builder.addFieldInt8(1, fooEnum, NamespaceA.NamespaceB.EnumInNestedNS.A); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooStructOffset - */ -NamespaceA.TableInFirstNS.addFooStruct = function(builder, fooStructOffset) { - builder.addFieldStruct(2, fooStructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.TableInFirstNS.endTableInFirstNS = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -NamespaceC.TableInC = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceC.TableInC} - */ -NamespaceC.TableInC.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceC.TableInC=} obj - * @returns {NamespaceC.TableInC} - */ -NamespaceC.TableInC.getRootAsTableInC = function(bb, obj) { - return (obj || new NamespaceC.TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.TableInFirstNS=} obj - * @returns {NamespaceA.TableInFirstNS} - */ -NamespaceC.TableInC.prototype.referToA1 = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceA.TableInFirstNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {NamespaceA.SecondTableInA=} obj - * @returns {NamespaceA.SecondTableInA} - */ -NamespaceC.TableInC.prototype.referToA2 = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new NamespaceA.SecondTableInA).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceC.TableInC.startTableInC = function(builder) { - builder.startObject(2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA1Offset - */ -NamespaceC.TableInC.addReferToA1 = function(builder, referToA1Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA2Offset - */ -NamespaceC.TableInC.addReferToA2 = function(builder, referToA2Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceC.TableInC.endTableInC = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -NamespaceA.SecondTableInA = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.SecondTableInA} - */ -NamespaceA.SecondTableInA.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.SecondTableInA=} obj - * @returns {NamespaceA.SecondTableInA} - */ -NamespaceA.SecondTableInA.getRootAsSecondTableInA = function(bb, obj) { - return (obj || new NamespaceA.SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceC.TableInC=} obj - * @returns {NamespaceC.TableInC} - */ -NamespaceA.SecondTableInA.prototype.referToC = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceC.TableInC).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.SecondTableInA.startSecondTableInA = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToCOffset - */ -NamespaceA.SecondTableInA.addReferToC = function(builder, referToCOffset) { - builder.addFieldOffset(0, referToCOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.SecondTableInA.endSecondTableInA = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -// Exports for Node.js and RequireJS -this.NamespaceA = NamespaceA; -this.NamespaceC = NamespaceC;
diff --git a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.ts b/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.ts deleted file mode 100644 index d08366b..0000000 --- a/third_party/flatbuffers/tests/namespace_test/namespace_test2_generated.ts +++ /dev/null
@@ -1,275 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as NS9459827973991502386 from "./namespace_test1_generated"; -/** - * @constructor - */ -export namespace NamespaceA{ -export class TableInFirstNS { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {TableInFirstNS} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInFirstNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {TableInFirstNS=} obj - * @returns {TableInFirstNS} - */ -static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS { - return (obj || new TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -fooTable(obj?:NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {NamespaceA.NamespaceB.EnumInNestedNS} - */ -fooEnum():NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A; -}; - -/** - * @param {NamespaceA.NamespaceB.EnumInNestedNS} value - * @returns {boolean} - */ -mutate_foo_enum(value:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS):boolean { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {NamespaceA.NamespaceB.StructInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.StructInNestedNS} - */ -fooStruct(obj?:NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startTableInFirstNS(builder:flatbuffers.Builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooTableOffset - */ -static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, fooTableOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum - */ -static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS) { - builder.addFieldInt8(1, fooEnum, NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooStructOffset - */ -static addFooStruct(builder:flatbuffers.Builder, fooStructOffset:flatbuffers.Offset) { - builder.addFieldStruct(2, fooStructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endTableInFirstNS(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace NamespaceC{ -export class TableInC { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {TableInC} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInC { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {TableInC=} obj - * @returns {TableInC} - */ -static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC { - return (obj || new TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.TableInFirstNS=} obj - * @returns {NamespaceA.TableInFirstNS} - */ -referToA1(obj?:NamespaceA.TableInFirstNS):NamespaceA.TableInFirstNS { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceA.TableInFirstNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {NamespaceA.SecondTableInA=} obj - * @returns {NamespaceA.SecondTableInA} - */ -referToA2(obj?:NamespaceA.SecondTableInA):NamespaceA.SecondTableInA { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new NamespaceA.SecondTableInA).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startTableInC(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA1Offset - */ -static addReferToA1(builder:flatbuffers.Builder, referToA1Offset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA2Offset - */ -static addReferToA2(builder:flatbuffers.Builder, referToA2Offset:flatbuffers.Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endTableInC(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace NamespaceA{ -export class SecondTableInA { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos:number = 0; -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {SecondTableInA} - */ -__init(i:number, bb:flatbuffers.ByteBuffer):SecondTableInA { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {SecondTableInA=} obj - * @returns {SecondTableInA} - */ -static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA { - return (obj || new SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceC.TableInC=} obj - * @returns {NamespaceC.TableInC} - */ -referToC(obj?:NamespaceC.TableInC):NamespaceC.TableInC { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceC.TableInC).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -static startSecondTableInA(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToCOffset - */ -static addReferToC(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToCOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -static endSecondTableInA(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -}
diff --git a/third_party/flatbuffers/tests/phpTest.php b/third_party/flatbuffers/tests/phpTest.php deleted file mode 100644 index 4dc83b2..0000000 --- a/third_party/flatbuffers/tests/phpTest.php +++ /dev/null
@@ -1,632 +0,0 @@ -<?php -// manual load for testing. please use PSR style autoloader when you use flatbuffers. -require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "php", "Constants.php")); -require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "php", "ByteBuffer.php")); -require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "php", "FlatbufferBuilder.php")); -require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "php", "Table.php")); -require join(DIRECTORY_SEPARATOR, array(dirname(dirname(__FILE__)), "php", "Struct.php")); -foreach (glob(join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "MyGame", "Example", "*.php"))) as $file) { - require $file; -} - -function main() -{ - /// Begin Test - $assert = new Assert(); - - // First, let's test reading a FlatBuffer generated by C++ code: - // This file was generated from monsterdata_test.json - - // Now test it: - $data = file_get_contents('monsterdata_test.mon'); - $bb = Google\FlatBuffers\ByteBuffer::wrap($data); - test_buffer($assert, $bb); - - // Second, let's create a FlatBuffer from scratch in JavaScript, and test it also. - // We use an initial size of 1 to exercise the reallocation algorithm, - // normally a size larger than the typical FlatBuffer you generate would be - // better for performance. - $fbb = new Google\FlatBuffers\FlatBufferBuilder(1); - - // We set up the same values as monsterdata.json: - $str = $fbb->createString("MyMonster"); - $name = $fbb->createString('Fred'); - \MyGame\Example\Monster::startMonster($fbb); - \MyGame\Example\Monster::addName($fbb, $name); - $enemy = \MyGame\Example\Monster::endMonster($fbb); - - $inv = \MyGame\Example\Monster::CreateInventoryVector($fbb, array(0, 1, 2, 3, 4)); - - $fred = $fbb->createString('Fred'); - \MyGame\Example\Monster::StartMonster($fbb); - \MyGame\Example\Monster::AddName($fbb, $fred); - $mon2 = \MyGame\Example\Monster::EndMonster($fbb); - - \MyGame\Example\Monster::StartTest4Vector($fbb, 2); - \MyGame\Example\Test::CreateTest($fbb, 10, 20); - \MyGame\Example\Test::CreateTest($fbb, 30, 40); - $test4 = $fbb->endVector(); - - $testArrayOfString = \MyGame\Example\Monster::CreateTestarrayofstringVector($fbb, array( - $fbb->createString('test1'), - $fbb->createString('test2') - )); - - \MyGame\Example\Monster::StartMonster($fbb); - \MyGame\Example\Monster::AddPos($fbb, \MyGame\Example\Vec3::CreateVec3($fbb, - 1.0, 2.0, 3.0, //float - 3.0, // double - \MyGame\Example\Color::Green, - 5, //short - 6)); - \MyGame\Example\Monster::AddHp($fbb, 80); - \MyGame\Example\Monster::AddName($fbb, $str); - \MyGame\Example\Monster::AddInventory($fbb, $inv); - \MyGame\Example\Monster::AddTestType($fbb, \MyGame\Example\Any::Monster); - \MyGame\Example\Monster::AddTest($fbb, $mon2); - \MyGame\Example\Monster::AddTest4($fbb, $test4); - \MyGame\Example\Monster::AddTestarrayofstring($fbb, $testArrayOfString); - \MyGame\Example\Monster::AddEnemy($fbb, $enemy); - \MyGame\Example\Monster::AddTestbool($fbb, false); - $mon = \MyGame\Example\Monster::EndMonster($fbb); - - \MyGame\Example\Monster::FinishMonsterBuffer($fbb, $mon); - - // Test it: - test_buffer($assert, $fbb->dataBuffer()); - - testByteBuffer($assert); - fuzzTest1($assert); -// testUnicode($assert); - - echo 'FlatBuffers php test: completed successfully' . PHP_EOL; -} - -try { - main(); - exit(0); -} catch(Exception $e) { - printf("Fatal error: Uncaught exception '%s' with message '%s. in %s:%d\n", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()); - printf("Stack trace:\n"); - echo $e->getTraceAsString() . PHP_EOL; - printf(" thrown in in %s:%d\n", $e->getFile(), $e->getLine()); - - die(-1); -} - -function test_buffer(Assert $assert, Google\FlatBuffers\ByteBuffer $bb) { - - $assert->ok(MyGame\Example\Monster::MonsterBufferHasIdentifier($bb)); - $monster = \MyGame\Example\Monster::GetRootAsMonster($bb); - - $assert->strictEqual($monster->GetHp(), 80); - $assert->strictEqual($monster->GetMana(), 150); // default - - $assert->strictEqual($monster->GetName(), 'MyMonster'); - - $pos = $monster->GetPos(); - $assert->strictEqual($pos->GetX(), 1.0); - $assert->strictEqual($pos->GetY(), 2.0); - $assert->strictEqual($pos->GetZ(), 3.0); - - $assert->Equal($pos->GetTest1(), 3.0); - $assert->strictEqual($pos->GetTest2(), \MyGame\Example\Color::Green); - - $t = $pos->GetTest3(); - $assert->strictEqual($t->GetA(), 5); - $assert->strictEqual($t->GetB(), 6); - $assert->strictEqual($monster->GetTestType(), \MyGame\Example\Any::Monster); - - $monster2 = new \MyGame\Example\Monster(); - $assert->strictEqual($monster->GetTest($monster2) != null, true); - $assert->strictEqual($monster2->GetName(), 'Fred'); - - $assert->strictEqual($monster->GetInventoryLength(), 5); - $invsum = 0; - for ($i = 0; $i < $monster->GetInventoryLength(); $i++) { - $invsum += $monster->GetInventory($i); - } - $assert->strictEqual($invsum, 10); - - $assert->strictEqual(bin2hex($monster->GetInventoryBytes()), "0001020304"); - - $test_0 = $monster->GetTest4(0); - $test_1 = $monster->GetTest4(1); - $assert->strictEqual($monster->GetTest4Length(), 2); - $assert->strictEqual($test_0->GetA() + $test_0->GetB() + $test_1->GetA() + $test_1->GetB(), 100); - - $assert->strictEqual($monster->GetTestarrayofstringLength(), 2); - $assert->strictEqual($monster->GetTestarrayofstring(0), 'test1'); - $assert->strictEqual($monster->GetTestarrayofstring(1), 'test2'); - - $fred = $monster->getEnemy(); - $assert->Equal('Fred', $fred->getName()); - - $assert->strictEqual($monster->GetTestbool(), false); -} - -//function testUnicode(Assert $assert) { -// // missing unicode_test.mon, implemented later -// $correct = file_get_contents('unicode_test.mon'); -// $json = json_decode(file_get_contents('unicode_test.json')); -// -// // Test reading -// $bb = flatbuffers\ByteBuffer::Wrap($correct); -// $monster = \MyGame\Example\Monster::GetRootAsMonster($bb); -// $assert->strictEqual($monster->GetName(), $json["name"]); -// -// //$assert->deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name)); -// //assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length); -// foreach ($json["testarrayoftables"]as $i => $table) { -// $value = $monster->GetTestArrayOfTables($i); -// $assert->strictEqual($value->GetName(), $table["name"]); -// //assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name)); -// } -// $assert->strictEqual($monster->GetTestarrayofstringLength(), $json["testarrayofstring"]["length"]); -// foreach ($json["testarrayofstring"] as $i => $string) { -// $assert->strictEqual($monster->GetTestarrayofstring($i), $string); -// //assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string)); -// } -// -// // Test writing -// $fbb = new FlatBuffers\FlatBufferBuilder(1); -// $name = $fbb->CreateString($json["name"]); -// $testarrayoftablesOffsets = array_map(function($table) use($fbb) { -// $name = $fbb->CreateString($table["name"]); -// \MyGame\Example\Monster::StartMonster($fbb); -// \MyGame\Example\Monster::AddName($fbb, $name); -// return \MyGame\Example\Monster::EndMonster($fbb); -// }, $json["testarrayoftables"]); -// $testarrayoftablesOffset = \MyGame\Example\Monster::CreateTestarrayoftablesVector($fbb, -// $testarrayoftablesOffsets); -//// $testarrayofstringOffset = \MyGame\Example\Monster::CreateTestarrayofstringVector($fbb, -//// $json["testarrayofstring"].map(function(string) { return fbb.createString(string); })); -// -// \MyGame\Example\Monster::startMonster($fbb); -// \MyGame\Example\Monster::addTestarrayofstring($fbb, $testarrayoftablesOffset); -// \MyGame\Example\Monster::addTestarrayoftables($fbb, $testarrayoftablesOffset); -// \MyGame\Example\Monster::addName($fbb, $name); -// \MyGame\Example\Monster::finishMonsterBuffer($fbb, \MyGame\Example\Monster::endMonster($fbb)); -// //;assert.deepEqual(new Buffer(fbb.asUint8Array()), correct); -//} - -// Low level stress/fuzz test: serialize/deserialize a variety of -// different kinds of data in different combinations -function fuzzTest1(Assert $assert) -{ - - // Values we're testing against: chosen to ensure no bits get chopped - // off anywhere, and also be different from eachother. - $bool_val = true; - $char_val = -127; // 0x81 - $uchar_val = 0xFF; - $short_val = -32222; // 0x8222; - $ushort_val = 0xFEEE; - $int_val = 0x7fffffff | 0; - // for now - $uint_val = 1; - $long_val = 2; - $ulong_val = 3; - -// var uint_val = 0xFDDDDDDD; -// var long_val = new flatbuffers.Long(0x44444444, 0x84444444); -// var ulong_val = new flatbuffers.Long(0xCCCCCCCC, 0xFCCCCCCC); - - $float_val = 3.14159; - $double_val = 3.14159265359; - - $test_values_max = 11; - $fields_per_object = 4; - // current implementation is not good at encoding. - $num_fuzz_objects = 1000; - $builder = new Google\FlatBuffers\FlatBufferBuilder(1); - - // can't use same implementation due to PHP_INTMAX overflow issue. - // we use mt_rand function to reproduce fuzzy test. - mt_srand(48271); - $objects = array(); - // Generate num_fuzz_objects random objects each consisting of - // fields_per_object fields, each of a random type. - for ($i = 0; $i < $num_fuzz_objects; $i++) { - $builder->startObject($fields_per_object); - for ($f = 0; $f < $fields_per_object; $f++) { - $choice = mt_rand() % $test_values_max; - switch ($choice) { - case 0: - $builder->addBoolX($f, $bool_val, 0); - break; - case 1: - $builder->addByteX($f, $char_val, 0); - break; - case 2: - $builder->addSbyteX($f, $uchar_val, 0); - break; - case 3: - $builder->addShortX($f, $short_val, 0); - break; - case 4: - $builder->addUshortX($f, $ushort_val, 0); - break; - case 5: - $builder->addIntX($f, $int_val, 0); - break; - case 6: - $builder->addUintX($f, $uint_val, 0); - break; - case 7: - $builder->addLongX($f, $long_val, 0); - break; - case 8: - $builder->addUlongX($f, $ulong_val, 0); - break; - case 9: - $builder->addFloatX($f, $float_val, 0); - break; - case 10: - $builder->addDoubleX($f, $double_val, 0); - break; - } - } - $objects[] = $builder->endObject(); - } - $builder->prep(8, 0); // Align whole buffer. - - mt_srand(48271); // Reset - $builder->finish($objects[count($objects) - 1]); - - $view = Google\FlatBuffers\ByteBuffer::wrap($builder->sizedByteArray()); - for ($i = 0; $i < $num_fuzz_objects; $i++) { - $offset = $view->capacity() - $objects[$i]; - for ($f = 0; $f < $fields_per_object; $f++) { - $choice = mt_rand() % $test_values_max; - $vtable_offset = fieldIndexToOffset($f); - $vtable = $offset - $view->getInt($offset); - $assert->ok($vtable_offset < $view->getShort($vtable)); - $field_offset = $offset + $view->getShort($vtable + $vtable_offset); - switch ($choice) { - case 0: - $assert->strictEqual(!!$view->getBool($field_offset), $bool_val); - break; - case 1: - $assert->strictEqual($view->getSbyte($field_offset), $char_val); - break; - case 2: - $assert->strictEqual($view->getByte($field_offset), $uchar_val); - break; - case 3: - $assert->strictEqual($view->getShort($field_offset), $short_val); - break; - case 4: - $assert->strictEqual($view->getUShort($field_offset), $ushort_val); - break; - case 5: - $assert->strictEqual($view->getInt($field_offset), $int_val); - break; - case 6: - $assert->strictEqual($view->getUint($field_offset), $uint_val); - break; - case 7: - if (PHP_INT_SIZE <= 4) break; - $assert->strictEqual($view->getLong($field_offset), $long_val); - break; - case 8: - if (PHP_INT_SIZE <= 4) break; - $assert->strictEqual($view->getUlong($field_offset), $ulong_val); - break; - case 9: - $assert->strictEqual(floor($view->getFloat($field_offset)), floor($float_val)); - break; - case 10: - $assert->strictEqual($view->getDouble($field_offset), $double_val); - break; - } - } - } -} - -function fieldIndexToOffset($field_id) { - // Should correspond to what EndTable() below builds up. - $fixed_fields = 2; // Vtable size and Object Size. - return ($field_id + $fixed_fields) * 2; -} - -function testByteBuffer(Assert $assert) { - - //Test: ByteBuffer_Length_MatchesBufferLength - $buffer = str_repeat("\0", 100); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal($uut->capacity(), strlen($buffer)); - - //Test: ByteBuffer_PutBytePopulatesBufferAtZeroOffset - $buffer = "\0"; - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putByte(0, "\x63"); // 99 - $assert->Equal("\x63", $uut->_buffer[0]); // don't share buffer as php user might confuse reference. - - //Test: ByteBuffer_PutByteCannotPutAtOffsetPastLength - $buffer = "\0"; - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putByte(1, "\x63"); // 99 - }); - - //Test: ByteBuffer_PutShortPopulatesBufferCorrectly - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putShort(0, 1); - - // Ensure Endiannes was written correctly - $assert->Equal(chr(0x01), $uut->_buffer[0]); - $assert->Equal(chr(0x00), $uut->_buffer[1]); - - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putShort(0, -32768); - - // Ensure Endiannes was written correctly - $assert->Equal(chr(0x00), $uut->_buffer[0]); - $assert->Equal(chr(0x80), $uut->_buffer[1]); - - //Test: ByteBuffer_PutShortCannotPutAtOffsetPastLength - $buffer = "\0"; - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putShort(2, "\x63"); // 99 - }); - - //Test: ByteBuffer_PutShortChecksLength - $buffer = "\0"; - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putShort(0, "\x63"); // 99 - }); - - //Test: ByteBuffer_PutShortChecksLengthAndOffset - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putShort(1, "\x63"); // 99 - }); - - //Test: ByteBuffer_PutIntPopulatesBufferCorrectly - $buffer = str_repeat("\0", 4); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putInt(0, 0x0A0B0C0D); - $assert->Equal(chr(0x0D), $uut->_buffer[0]); - $assert->Equal(chr(0x0C), $uut->_buffer[1]); - $assert->Equal(chr(0x0B), $uut->_buffer[2]); - $assert->Equal(chr(0x0A), $uut->_buffer[3]); - - $buffer = str_repeat("\0", 4); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putInt(0, -2147483648); - $assert->Equal(chr(0x00), $uut->_buffer[0]); - $assert->Equal(chr(0x00), $uut->_buffer[1]); - $assert->Equal(chr(0x00), $uut->_buffer[2]); - $assert->Equal(chr(0x80), $uut->_buffer[3]); - - //Test: ByteBuffer_PutIntCannotPutAtOffsetPastLength - $buffer = str_repeat("\0", 4); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putInt(2, 0x0A0B0C0D); - }); - - //Test: ByteBuffer_PutIntChecksLength - $buffer = str_repeat("\0", 1); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putInt(0, 0x0A0B0C0D); - }); - - //Test: ByteBuffer_PutIntChecksLengthAndOffset - $buffer = str_repeat("\0", 4); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putInt(2, 0x0A0B0C0D); - }); - - if (PHP_INT_SIZE > 4) { - //Test: ByteBuffer_PutLongPopulatesBufferCorrectly - $buffer = str_repeat("\0", 8); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $uut->putLong(0, 0x010203040A0B0C0D); - $assert->Equal(chr(0x0D), $uut->_buffer[0]); - $assert->Equal(chr(0x0C), $uut->_buffer[1]); - $assert->Equal(chr(0x0B), $uut->_buffer[2]); - $assert->Equal(chr(0x0A), $uut->_buffer[3]); - $assert->Equal(chr(0x04), $uut->_buffer[4]); - $assert->Equal(chr(0x03), $uut->_buffer[5]); - $assert->Equal(chr(0x02), $uut->_buffer[6]); - $assert->Equal(chr(0x01), $uut->_buffer[7]); - - //Test: ByteBuffer_PutLongCannotPutAtOffsetPastLength - $buffer = str_repeat("\0", 8); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putLong(2, 0x010203040A0B0C0D); - }); - - //Test: ByteBuffer_PutLongCannotPutAtOffsetPastLength - $buffer = str_repeat("\0", 1); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putLong(0, 0x010203040A0B0C0D); - }); - - - //Test: ByteBuffer_PutLongChecksLengthAndOffset - $buffer = str_repeat("\0", 8); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->putLong(2, 0x010203040A0B0C0D); - }); - } - - //Test: ByteBuffer_GetByteReturnsCorrectData - $buffer = str_repeat("\0", 1); - $buffer[0] = "\x63"; - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal("\x63", $uut->get(0)); - - //Test: ByteBuffer_GetByteChecksOffset - $buffer = str_repeat("\0", 1); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->get(1); - }); - - //Test: ByteBuffer_GetShortReturnsCorrectData - $buffer = str_repeat("\0", 2); - $buffer[0] = chr(0x01); - $buffer[1] = chr(0x00); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(1, $uut->getShort(0)); - - //Test: ByteBuffer_GetShortReturnsCorrectData (signed value) - $buffer = str_repeat("\0", 2); - $buffer[0] = chr(0x00); - $buffer[1] = chr(0x80); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(-32768, $uut->getShort(0)); - - //Test: ByteBuffer_GetShortChecksOffset - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getShort(2); - }); - - //Test: ByteBuffer_GetShortChecksLength - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getShort(1); - }); - - //Test: ByteBuffer_GetIntReturnsCorrectData - $buffer = str_repeat("\0", 4); - $buffer[0] = chr(0x0D); - $buffer[1] = chr(0x0C); - $buffer[2] = chr(0x0B); - $buffer[3] = chr(0x0A); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(0x0A0B0C0D, $uut->getInt(0)); - - $buffer = str_repeat("\0", 4); - $buffer[0] = chr(0x00); - $buffer[1] = chr(0x00); - $buffer[2] = chr(0x00); - $buffer[3] = chr(0x80); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(-2147483648, $uut->getInt(0)); - - //Test: ByteBuffer_GetIntChecksOffset - $buffer = str_repeat("\0", 4); - - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getInt(4); - }); - - //Test: ByteBuffer_GetIntChecksLength - $buffer = str_repeat("\0", 2); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getInt(0); - }); - - if (PHP_INT_SIZE > 4) { - //Test: ByteBuffer_GetLongReturnsCorrectData - $buffer = str_repeat("\0", 8); - $buffer[0] = chr(0x0D); - $buffer[1] = chr(0x0C); - $buffer[2] = chr(0x0B); - $buffer[3] = chr(0x0A); - $buffer[4] = chr(0x04); - $buffer[5] = chr(0x03); - $buffer[6] = chr(0x02); - $buffer[7] = chr(0x01); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(0x010203040A0B0C0D, $uut->getLong(0)); - - //Test: Signed Long - $buffer = str_repeat("\0", 8); - $buffer[0] = chr(0x00); - $buffer[1] = chr(0x00); - $buffer[2] = chr(0x00); - $buffer[3] = chr(0x00); - $buffer[4] = chr(0x00); - $buffer[5] = chr(0x00); - $buffer[6] = chr(0x00); - $buffer[7] = chr(0x80); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(-1 << 63, $uut->getLong(0)); - } - - //Test: ByteBuffer_GetLongChecksOffset - $buffer = str_repeat("\0", 8); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getLong(8); - }); - - //Test: ByteBuffer_GetLongChecksLength - $buffer = str_repeat("\0", 7); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Throws(new OutOfRangeException(), function() use ($uut) { - $uut->getLong(0); - }); - - //Test: big endian - $buffer = str_repeat("\0", 2); - // 0xFF 0x00 - // Little Endian: 255 - // Big Endian: 65280 - $buffer[0] = chr(0xff); - $buffer[1] = chr(0x00); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(65280, $uut->readLittleEndian(0, 2, true)); - - $buffer = str_repeat("\0", 4); - $buffer[0] = chr(0x0D); - $buffer[1] = chr(0x0C); - $buffer[2] = chr(0x0B); - $buffer[3] = chr(0x0A); - $uut = Google\FlatBuffers\ByteBuffer::wrap($buffer); - $assert->Equal(0x0D0C0B0A, $uut->readLittleEndian(0, 4, true)); - -} - -class Assert { - public function ok($result, $message = "") { - if (!$result){ - throw new Exception(!empty($message) ? $message : "{$result} is not true."); - } - } - - public function Equal($result, $expected, $message = "") { - if ($result != $expected) { - throw new Exception(!empty($message) ? $message : "given the result {$result} is not equals as {$expected}"); - } - } - - - public function strictEqual($result, $expected, $message = "") { - if ($result !== $expected) { - throw new Exception(!empty($message) ? $message : "given the result {$result} is not strict equals as {$expected}"); - } - } - - public function Throws($class, Callable $callback) { - try { - $callback(); - - throw new \Exception("passed statement don't throw an exception."); - } catch (\Exception $e) { - if (get_class($e) != get_class($class)) { - throw new Exception("passed statement doesn't throw " . get_class($class) . ". throwws " . get_class($e)); - } - } - } -}
diff --git a/third_party/flatbuffers/tests/prototest/imported.proto b/third_party/flatbuffers/tests/prototest/imported.proto deleted file mode 100644 index 5b43e4b..0000000 --- a/third_party/flatbuffers/tests/prototest/imported.proto +++ /dev/null
@@ -1,5 +0,0 @@ -package proto.test; - -message ImportedMessage { - optional int32 a = 26; -}
diff --git a/third_party/flatbuffers/tests/prototest/test.golden b/third_party/flatbuffers/tests/prototest/test.golden deleted file mode 100644 index 2c74413..0000000 --- a/third_party/flatbuffers/tests/prototest/test.golden +++ /dev/null
@@ -1,52 +0,0 @@ -// Generated from test.proto - -namespace _proto._test; - -/// Enum doc comment. -enum ProtoEnum : int { - FOO = 1, - /// Enum 2nd value doc comment misaligned. - BAR = 5, -} - -namespace _proto._test; - -table ImportedMessage { - a:int; -} - -namespace _proto._test; - -/// 2nd table doc comment with -/// many lines. -table ProtoMessage { - c:int = 16; - d:long; - p:uint; - e:ulong; - /// doc comment for f. - f:int = -1; - g:long; - h:uint; - q:ulong; - i:int; - j:long; - /// doc comment for k. - k:bool; - /// doc comment for l on 2 - /// lines - l:string (required); - m:string; - n:_proto._test._ProtoMessage.OtherMessage; - o:[string]; - z:_proto._test.ImportedMessage; -} - -namespace _proto._test._ProtoMessage; - -table OtherMessage { - a:double; - /// doc comment for b. - b:float = 3.14149; -} -
diff --git a/third_party/flatbuffers/tests/prototest/test.proto b/third_party/flatbuffers/tests/prototest/test.proto deleted file mode 100644 index 913b564..0000000 --- a/third_party/flatbuffers/tests/prototest/test.proto +++ /dev/null
@@ -1,45 +0,0 @@ -// Sample .proto file that we can translate to the corresponding .fbs. - -option some_option = is_ignored; -import "imported.proto"; - -package proto.test; - -/// Enum doc comment. -enum ProtoEnum { - FOO = 1; -/// Enum 2nd value doc comment misaligned. - BAR = 5; -} - -/// 2nd table doc comment with -/// many lines. -message ProtoMessage { - // Ignored non-doc comment. - // A nested message declaration, will be moved to top level in .fbs - message OtherMessage { - optional double a = 26; - /// doc comment for b. - optional float b = 32 [default = 3.14149]; - } - optional int32 c = 12 [default = 16]; - optional int64 d = 1 [default = 0]; - optional uint32 p = 1; - optional uint64 e = 2; - /// doc comment for f. - optional sint32 f = 3 [default = -1]; - optional sint64 g = 4; - optional fixed32 h = 5; - optional fixed64 q = 6; - optional sfixed32 i = 7; - optional sfixed64 j = 8; - /// doc comment for k. - optional bool k = 9; - /// doc comment for l on 2 - /// lines - required string l = 10; - optional bytes m = 11; - optional OtherMessage n = 12; - repeated string o = 14; - optional ImportedMessage z = 16; -}
diff --git a/third_party/flatbuffers/tests/py_test.py b/third_party/flatbuffers/tests/py_test.py deleted file mode 100644 index e660944..0000000 --- a/third_party/flatbuffers/tests/py_test.py +++ /dev/null
@@ -1,1371 +0,0 @@ -# coding=utf-8 -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os.path -import sys -PY_VERSION = sys.version_info[:2] - -import ctypes -from collections import defaultdict -import timeit -import unittest - - -from flatbuffers import compat -from flatbuffers.compat import range_func as compat_range - -import flatbuffers -from flatbuffers import number_types as N - -import MyGame # refers to generated code -import MyGame.Example # refers to generated code -import MyGame.Example.Any # refers to generated code -import MyGame.Example.Color # refers to generated code -import MyGame.Example.Monster # refers to generated code -import MyGame.Example.Test # refers to generated code -import MyGame.Example.Stat # refers to generated code -import MyGame.Example.Vec3 # refers to generated code - - -def assertRaises(test_case, fn, exception_class): - ''' Backwards-compatible assertion for exceptions raised. ''' - - exc = None - try: - fn() - except Exception as e: - exc = e - test_case.assertTrue(exc is not None) - test_case.assertTrue(isinstance(exc, exception_class)) - - -class TestWireFormat(unittest.TestCase): - def test_wire_format(self): - # Verify that using the generated Python code builds a buffer without - # returning errors, and is interpreted correctly: - gen_buf, gen_off = make_monster_from_generated_code() - CheckReadBuffer(gen_buf, gen_off) - - # Verify that the canonical flatbuffer file is readable by the - # generated Python code. Note that context managers are not part of - # Python 2.5, so we use the simpler open/close methods here: - f = open('monsterdata_test.mon', 'rb') - canonicalWireData = f.read() - f.close() - CheckReadBuffer(bytearray(canonicalWireData), 0) - - # Write the generated buffer out to a file: - f = open('monsterdata_python_wire.mon', 'wb') - f.write(gen_buf[gen_off:]) - f.close() - - -def CheckReadBuffer(buf, offset): - ''' CheckReadBuffer checks that the given buffer is evaluated correctly - as the example Monster. ''' - - def asserter(stmt): - ''' An assertion helper that is separated from TestCase classes. ''' - if not stmt: - raise AssertionError('CheckReadBuffer case failed') - - monster = MyGame.Example.Monster.Monster.GetRootAsMonster(buf, offset) - - asserter(monster.Hp() == 80) - asserter(monster.Mana() == 150) - asserter(monster.Name() == b'MyMonster') - - # initialize a Vec3 from Pos() - vec = monster.Pos() - asserter(vec is not None) - - # verify the properties of the Vec3 - asserter(vec.X() == 1.0) - asserter(vec.Y() == 2.0) - asserter(vec.Z() == 3.0) - asserter(vec.Test1() == 3.0) - asserter(vec.Test2() == 2) - - # initialize a Test from Test3(...) - t = MyGame.Example.Test.Test() - t = vec.Test3(t) - asserter(t is not None) - - # verify the properties of the Test - asserter(t.A() == 5) - asserter(t.B() == 6) - - # verify that the enum code matches the enum declaration: - union_type = MyGame.Example.Any.Any - asserter(monster.TestType() == union_type.Monster) - - # initialize a Table from a union field Test(...) - table2 = monster.Test() - asserter(type(table2) is flatbuffers.table.Table) - - # initialize a Monster from the Table from the union - monster2 = MyGame.Example.Monster.Monster() - monster2.Init(table2.Bytes, table2.Pos) - - asserter(monster2.Name() == b"Fred") - - # iterate through the first monster's inventory: - asserter(monster.InventoryLength() == 5) - - invsum = 0 - for i in compat_range(monster.InventoryLength()): - v = monster.Inventory(i) - invsum += int(v) - asserter(invsum == 10) - - asserter(monster.Test4Length() == 2) - - # create a 'Test' object and populate it: - test0 = monster.Test4(0) - asserter(type(test0) is MyGame.Example.Test.Test) - - test1 = monster.Test4(1) - asserter(type(test1) is MyGame.Example.Test.Test) - - # the position of test0 and test1 are swapped in monsterdata_java_wire - # and monsterdata_test_wire, so ignore ordering - v0 = test0.A() - v1 = test0.B() - v2 = test1.A() - v3 = test1.B() - sumtest12 = int(v0) + int(v1) + int(v2) + int(v3) - - asserter(sumtest12 == 100) - - asserter(monster.TestarrayofstringLength() == 2) - asserter(monster.Testarrayofstring(0) == b"test1") - asserter(monster.Testarrayofstring(1) == b"test2") - - asserter(monster.TestarrayoftablesLength() == 0) - asserter(monster.TestnestedflatbufferLength() == 0) - asserter(monster.Testempty() is None) - - -class TestFuzz(unittest.TestCase): - ''' Low level stress/fuzz test: serialize/deserialize a variety of - different kinds of data in different combinations ''' - - binary_type = compat.binary_types[0] # this will always exist - ofInt32Bytes = binary_type([0x83, 0x33, 0x33, 0x33]) - ofInt64Bytes = binary_type([0x84, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44]) - overflowingInt32Val = flatbuffers.encode.Get(flatbuffers.packer.int32, - ofInt32Bytes, 0) - overflowingInt64Val = flatbuffers.encode.Get(flatbuffers.packer.int64, - ofInt64Bytes, 0) - - # Values we're testing against: chosen to ensure no bits get chopped - # off anywhere, and also be different from eachother. - boolVal = True - int8Val = N.Int8Flags.py_type(-127) # 0x81 - uint8Val = N.Uint8Flags.py_type(0xFF) - int16Val = N.Int16Flags.py_type(-32222) # 0x8222 - uint16Val = N.Uint16Flags.py_type(0xFEEE) - int32Val = N.Int32Flags.py_type(overflowingInt32Val) - uint32Val = N.Uint32Flags.py_type(0xFDDDDDDD) - int64Val = N.Int64Flags.py_type(overflowingInt64Val) - uint64Val = N.Uint64Flags.py_type(0xFCCCCCCCCCCCCCCC) - # Python uses doubles, so force it here - float32Val = N.Float32Flags.py_type(ctypes.c_float(3.14159).value) - float64Val = N.Float64Flags.py_type(3.14159265359) - - def test_fuzz(self): - return self.check_once(11, 100) - - def check_once(self, fuzzFields, fuzzObjects): - testValuesMax = 11 # hardcoded to the number of scalar types - - builder = flatbuffers.Builder(0) - l = LCG() - - objects = [0 for _ in compat_range(fuzzObjects)] - - # Generate fuzzObjects random objects each consisting of - # fuzzFields fields, each of a random type. - for i in compat_range(fuzzObjects): - builder.StartObject(fuzzFields) - - for j in compat_range(fuzzFields): - choice = int(l.Next()) % testValuesMax - if choice == 0: - builder.PrependBoolSlot(int(j), self.boolVal, False) - elif choice == 1: - builder.PrependInt8Slot(int(j), self.int8Val, 0) - elif choice == 2: - builder.PrependUint8Slot(int(j), self.uint8Val, 0) - elif choice == 3: - builder.PrependInt16Slot(int(j), self.int16Val, 0) - elif choice == 4: - builder.PrependUint16Slot(int(j), self.uint16Val, 0) - elif choice == 5: - builder.PrependInt32Slot(int(j), self.int32Val, 0) - elif choice == 6: - builder.PrependUint32Slot(int(j), self.uint32Val, 0) - elif choice == 7: - builder.PrependInt64Slot(int(j), self.int64Val, 0) - elif choice == 8: - builder.PrependUint64Slot(int(j), self.uint64Val, 0) - elif choice == 9: - builder.PrependFloat32Slot(int(j), self.float32Val, 0) - elif choice == 10: - builder.PrependFloat64Slot(int(j), self.float64Val, 0) - else: - raise RuntimeError('unreachable') - - off = builder.EndObject() - - # store the offset from the end of the builder buffer, - # since it will keep growing: - objects[i] = off - - # Do some bookkeeping to generate stats on fuzzes: - stats = defaultdict(int) - def check(table, desc, want, got): - stats[desc] += 1 - self.assertEqual(want, got, "%s != %s, %s" % (want, got, desc)) - - l = LCG() # Reset. - - # Test that all objects we generated are readable and return the - # expected values. We generate random objects in the same order - # so this is deterministic. - for i in compat_range(fuzzObjects): - - table = flatbuffers.table.Table(builder.Bytes, - len(builder.Bytes) - objects[i]) - - for j in compat_range(fuzzFields): - field_count = flatbuffers.builder.VtableMetadataFields + j - f = N.VOffsetTFlags.py_type(field_count * - N.VOffsetTFlags.bytewidth) - choice = int(l.Next()) % testValuesMax - - if choice == 0: - check(table, "bool", self.boolVal, - table.GetSlot(f, False, N.BoolFlags)) - elif choice == 1: - check(table, "int8", self.int8Val, - table.GetSlot(f, 0, N.Int8Flags)) - elif choice == 2: - check(table, "uint8", self.uint8Val, - table.GetSlot(f, 0, N.Uint8Flags)) - elif choice == 3: - check(table, "int16", self.int16Val, - table.GetSlot(f, 0, N.Int16Flags)) - elif choice == 4: - check(table, "uint16", self.uint16Val, - table.GetSlot(f, 0, N.Uint16Flags)) - elif choice == 5: - check(table, "int32", self.int32Val, - table.GetSlot(f, 0, N.Int32Flags)) - elif choice == 6: - check(table, "uint32", self.uint32Val, - table.GetSlot(f, 0, N.Uint32Flags)) - elif choice == 7: - check(table, "int64", self.int64Val, - table.GetSlot(f, 0, N.Int64Flags)) - elif choice == 8: - check(table, "uint64", self.uint64Val, - table.GetSlot(f, 0, N.Uint64Flags)) - elif choice == 9: - check(table, "float32", self.float32Val, - table.GetSlot(f, 0, N.Float32Flags)) - elif choice == 10: - check(table, "float64", self.float64Val, - table.GetSlot(f, 0, N.Float64Flags)) - else: - raise RuntimeError('unreachable') - - # If enough checks were made, verify that all scalar types were used: - self.assertEqual(testValuesMax, len(stats), - "fuzzing failed to test all scalar types: %s" % stats) - - -class TestByteLayout(unittest.TestCase): - ''' TestByteLayout checks the bytes of a Builder in various scenarios. ''' - - def assertBuilderEquals(self, builder, want_chars_or_ints): - def integerize(x): - if isinstance(x, compat.string_types): - return ord(x) - return x - - want_ints = list(map(integerize, want_chars_or_ints)) - want = bytearray(want_ints) - got = builder.Bytes[builder.Head():] # use the buffer directly - self.assertEqual(want, got) - - def test_numbers(self): - b = flatbuffers.Builder(0) - self.assertBuilderEquals(b, []) - b.PrependBool(True) - self.assertBuilderEquals(b, [1]) - b.PrependInt8(-127) - self.assertBuilderEquals(b, [129, 1]) - b.PrependUint8(255) - self.assertBuilderEquals(b, [255, 129, 1]) - b.PrependInt16(-32222) - self.assertBuilderEquals(b, [0x22, 0x82, 0, 255, 129, 1]) # first pad - b.PrependUint16(0xFEEE) - # no pad this time: - self.assertBuilderEquals(b, [0xEE, 0xFE, 0x22, 0x82, 0, 255, 129, 1]) - b.PrependInt32(-53687092) - self.assertBuilderEquals(b, [204, 204, 204, 252, 0xEE, 0xFE, - 0x22, 0x82, 0, 255, 129, 1]) - b.PrependUint32(0x98765432) - self.assertBuilderEquals(b, [0x32, 0x54, 0x76, 0x98, - 204, 204, 204, 252, - 0xEE, 0xFE, 0x22, 0x82, - 0, 255, 129, 1]) - - def test_numbers64(self): - b = flatbuffers.Builder(0) - b.PrependUint64(0x1122334455667788) - self.assertBuilderEquals(b, [0x88, 0x77, 0x66, 0x55, - 0x44, 0x33, 0x22, 0x11]) - - b = flatbuffers.Builder(0) - b.PrependInt64(0x1122334455667788) - self.assertBuilderEquals(b, [0x88, 0x77, 0x66, 0x55, - 0x44, 0x33, 0x22, 0x11]) - - def test_1xbyte_vector(self): - b = flatbuffers.Builder(0) - self.assertBuilderEquals(b, []) - b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 1, 1) - self.assertBuilderEquals(b, [0, 0, 0]) # align to 4bytes - b.PrependByte(1) - self.assertBuilderEquals(b, [1, 0, 0, 0]) - b.EndVector(1) - self.assertBuilderEquals(b, [1, 0, 0, 0, 1, 0, 0, 0]) # padding - - def test_2xbyte_vector(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 2, 1) - self.assertBuilderEquals(b, [0, 0]) # align to 4bytes - b.PrependByte(1) - self.assertBuilderEquals(b, [1, 0, 0]) - b.PrependByte(2) - self.assertBuilderEquals(b, [2, 1, 0, 0]) - b.EndVector(2) - self.assertBuilderEquals(b, [2, 0, 0, 0, 2, 1, 0, 0]) # padding - - def test_1xuint16_vector(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Uint16Flags.bytewidth, 1, 1) - self.assertBuilderEquals(b, [0, 0]) # align to 4bytes - b.PrependUint16(1) - self.assertBuilderEquals(b, [1, 0, 0, 0]) - b.EndVector(1) - self.assertBuilderEquals(b, [1, 0, 0, 0, 1, 0, 0, 0]) # padding - - def test_2xuint16_vector(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Uint16Flags.bytewidth, 2, 1) - self.assertBuilderEquals(b, []) # align to 4bytes - b.PrependUint16(0xABCD) - self.assertBuilderEquals(b, [0xCD, 0xAB]) - b.PrependUint16(0xDCBA) - self.assertBuilderEquals(b, [0xBA, 0xDC, 0xCD, 0xAB]) - b.EndVector(2) - self.assertBuilderEquals(b, [2, 0, 0, 0, 0xBA, 0xDC, 0xCD, 0xAB]) - - def test_create_ascii_string(self): - b = flatbuffers.Builder(0) - b.CreateString(u"foo", encoding='ascii') - - # 0-terminated, no pad: - self.assertBuilderEquals(b, [3, 0, 0, 0, 'f', 'o', 'o', 0]) - b.CreateString(u"moop", encoding='ascii') - # 0-terminated, 3-byte pad: - self.assertBuilderEquals(b, [4, 0, 0, 0, 'm', 'o', 'o', 'p', - 0, 0, 0, 0, - 3, 0, 0, 0, 'f', 'o', 'o', 0]) - - def test_create_utf8_string(self): - b = flatbuffers.Builder(0) - b.CreateString(u"Цлїςσδε") - self.assertBuilderEquals(b, "\x0e\x00\x00\x00\xd0\xa6\xd0\xbb\xd1\x97" \ - "\xcf\x82\xcf\x83\xce\xb4\xce\xb5\x00\x00") - - b.CreateString(u"フムアムカモケモ") - self.assertBuilderEquals(b, "\x18\x00\x00\x00\xef\xbe\x8c\xef\xbe\x91" \ - "\xef\xbd\xb1\xef\xbe\x91\xef\xbd\xb6\xef\xbe\x93\xef\xbd\xb9\xef" \ - "\xbe\x93\x00\x00\x00\x00\x0e\x00\x00\x00\xd0\xa6\xd0\xbb\xd1\x97" \ - "\xcf\x82\xcf\x83\xce\xb4\xce\xb5\x00\x00") - - def test_create_arbitrary_string(self): - b = flatbuffers.Builder(0) - s = "\x01\x02\x03" - b.CreateString(s) # Default encoding is utf-8. - # 0-terminated, no pad: - self.assertBuilderEquals(b, [3, 0, 0, 0, 1, 2, 3, 0]) - s2 = "\x04\x05\x06\x07" - b.CreateString(s2) # Default encoding is utf-8. - # 0-terminated, 3-byte pad: - self.assertBuilderEquals(b, [4, 0, 0, 0, 4, 5, 6, 7, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 2, 3, 0]) - - def test_empty_vtable(self): - b = flatbuffers.Builder(0) - b.StartObject(0) - self.assertBuilderEquals(b, []) - b.EndObject() - self.assertBuilderEquals(b, [4, 0, 4, 0, 4, 0, 0, 0]) - - def test_vtable_with_one_true_bool(self): - b = flatbuffers.Builder(0) - self.assertBuilderEquals(b, []) - b.StartObject(1) - self.assertBuilderEquals(b, []) - b.PrependBoolSlot(0, True, False) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 8, 0, # length of object including vtable offset - 7, 0, # start of bool value - 6, 0, 0, 0, # offset for start of vtable (int32) - 0, 0, 0, # padded to 4 bytes - 1, # bool value - ]) - - def test_vtable_with_one_default_bool(self): - b = flatbuffers.Builder(0) - self.assertBuilderEquals(b, []) - b.StartObject(1) - self.assertBuilderEquals(b, []) - b.PrependBoolSlot(0, False, False) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 4, 0, # end of object from here - 0, 0, # entry 1 is zero - 6, 0, 0, 0, # offset for start of vtable (int32) - ]) - - def test_vtable_with_one_int16(self): - b = flatbuffers.Builder(0) - b.StartObject(1) - b.PrependInt16Slot(0, 0x789A, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 8, 0, # end of object from here - 6, 0, # offset to value - 6, 0, 0, 0, # offset for start of vtable (int32) - 0, 0, # padding to 4 bytes - 0x9A, 0x78, - ]) - - def test_vtable_with_two_int16(self): - b = flatbuffers.Builder(0) - b.StartObject(2) - b.PrependInt16Slot(0, 0x3456, 0) - b.PrependInt16Slot(1, 0x789A, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 8, 0, # vtable bytes - 8, 0, # end of object from here - 6, 0, # offset to value 0 - 4, 0, # offset to value 1 - 8, 0, 0, 0, # offset for start of vtable (int32) - 0x9A, 0x78, # value 1 - 0x56, 0x34, # value 0 - ]) - - def test_vtable_with_int16_and_bool(self): - b = flatbuffers.Builder(0) - b.StartObject(2) - b.PrependInt16Slot(0, 0x3456, 0) - b.PrependBoolSlot(1, True, False) - b.EndObject() - self.assertBuilderEquals(b, [ - 8, 0, # vtable bytes - 8, 0, # end of object from here - 6, 0, # offset to value 0 - 5, 0, # offset to value 1 - 8, 0, 0, 0, # offset for start of vtable (int32) - 0, # padding - 1, # value 1 - 0x56, 0x34, # value 0 - ]) - - def test_vtable_with_empty_vector(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 0, 1) - vecend = b.EndVector(0) - b.StartObject(1) - b.PrependUOffsetTRelativeSlot(0, vecend, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 8, 0, - 4, 0, # offset to vector offset - 6, 0, 0, 0, # offset for start of vtable (int32) - 4, 0, 0, 0, - 0, 0, 0, 0, # length of vector (not in struct) - ]) - - def test_vtable_with_empty_vector_of_byte_and_some_scalars(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Uint8Flags.bytewidth, 0, 1) - vecend = b.EndVector(0) - b.StartObject(2) - b.PrependInt16Slot(0, 55, 0) - b.PrependUOffsetTRelativeSlot(1, vecend, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 8, 0, # vtable bytes - 12, 0, - 10, 0, # offset to value 0 - 4, 0, # offset to vector offset - 8, 0, 0, 0, # vtable loc - 8, 0, 0, 0, # value 1 - 0, 0, 55, 0, # value 0 - - 0, 0, 0, 0, # length of vector (not in struct) - ]) - - def test_vtable_with_1_int16_and_2vector_of_int16(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Int16Flags.bytewidth, 2, 1) - b.PrependInt16(0x1234) - b.PrependInt16(0x5678) - vecend = b.EndVector(2) - b.StartObject(2) - b.PrependUOffsetTRelativeSlot(1, vecend, 0) - b.PrependInt16Slot(0, 55, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 8, 0, # vtable bytes - 12, 0, # length of object - 6, 0, # start of value 0 from end of vtable - 8, 0, # start of value 1 from end of buffer - 8, 0, 0, 0, # offset for start of vtable (int32) - 0, 0, # padding - 55, 0, # value 0 - 4, 0, 0, 0, # vector position from here - 2, 0, 0, 0, # length of vector (uint32) - 0x78, 0x56, # vector value 1 - 0x34, 0x12, # vector value 0 - ]) - - def test_vtable_with_1_struct_of_1_int8__1_int16__1_int32(self): - b = flatbuffers.Builder(0) - b.StartObject(1) - b.Prep(4+4+4, 0) - b.PrependInt8(55) - b.Pad(3) - b.PrependInt16(0x1234) - b.Pad(2) - b.PrependInt32(0x12345678) - structStart = b.Offset() - b.PrependStructSlot(0, structStart, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 16, 0, # end of object from here - 4, 0, # start of struct from here - 6, 0, 0, 0, # offset for start of vtable (int32) - 0x78, 0x56, 0x34, 0x12, # value 2 - 0, 0, # padding - 0x34, 0x12, # value 1 - 0, 0, 0, # padding - 55, # value 0 - ]) - - def test_vtable_with_1_vector_of_2_struct_of_2_int8(self): - b = flatbuffers.Builder(0) - b.StartVector(flatbuffers.number_types.Int8Flags.bytewidth*2, 2, 1) - b.PrependInt8(33) - b.PrependInt8(44) - b.PrependInt8(55) - b.PrependInt8(66) - vecend = b.EndVector(2) - b.StartObject(1) - b.PrependUOffsetTRelativeSlot(0, vecend, 0) - b.EndObject() - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 8, 0, - 4, 0, # offset of vector offset - 6, 0, 0, 0, # offset for start of vtable (int32) - 4, 0, 0, 0, # vector start offset - - 2, 0, 0, 0, # vector length - 66, # vector value 1,1 - 55, # vector value 1,0 - 44, # vector value 0,1 - 33, # vector value 0,0 - ]) - - def test_table_with_some_elements(self): - b = flatbuffers.Builder(0) - b.StartObject(2) - b.PrependInt8Slot(0, 33, 0) - b.PrependInt16Slot(1, 66, 0) - off = b.EndObject() - b.Finish(off) - - self.assertBuilderEquals(b, [ - 12, 0, 0, 0, # root of table: points to vtable offset - - 8, 0, # vtable bytes - 8, 0, # end of object from here - 7, 0, # start of value 0 - 4, 0, # start of value 1 - - 8, 0, 0, 0, # offset for start of vtable (int32) - - 66, 0, # value 1 - 0, # padding - 33, # value 0 - ]) - - def test__one_unfinished_table_and_one_finished_table(self): - b = flatbuffers.Builder(0) - b.StartObject(2) - b.PrependInt8Slot(0, 33, 0) - b.PrependInt8Slot(1, 44, 0) - off = b.EndObject() - b.Finish(off) - - b.StartObject(3) - b.PrependInt8Slot(0, 55, 0) - b.PrependInt8Slot(1, 66, 0) - b.PrependInt8Slot(2, 77, 0) - off = b.EndObject() - b.Finish(off) - - self.assertBuilderEquals(b, [ - 16, 0, 0, 0, # root of table: points to object - 0, 0, # padding - - 10, 0, # vtable bytes - 8, 0, # size of object - 7, 0, # start of value 0 - 6, 0, # start of value 1 - 5, 0, # start of value 2 - 10, 0, 0, 0, # offset for start of vtable (int32) - 0, # padding - 77, # value 2 - 66, # value 1 - 55, # value 0 - - 12, 0, 0, 0, # root of table: points to object - - 8, 0, # vtable bytes - 8, 0, # size of object - 7, 0, # start of value 0 - 6, 0, # start of value 1 - 8, 0, 0, 0, # offset for start of vtable (int32) - 0, 0, # padding - 44, # value 1 - 33, # value 0 - ]) - - def test_a_bunch_of_bools(self): - b = flatbuffers.Builder(0) - b.StartObject(8) - b.PrependBoolSlot(0, True, False) - b.PrependBoolSlot(1, True, False) - b.PrependBoolSlot(2, True, False) - b.PrependBoolSlot(3, True, False) - b.PrependBoolSlot(4, True, False) - b.PrependBoolSlot(5, True, False) - b.PrependBoolSlot(6, True, False) - b.PrependBoolSlot(7, True, False) - off = b.EndObject() - b.Finish(off) - - self.assertBuilderEquals(b, [ - 24, 0, 0, 0, # root of table: points to vtable offset - - 20, 0, # vtable bytes - 12, 0, # size of object - 11, 0, # start of value 0 - 10, 0, # start of value 1 - 9, 0, # start of value 2 - 8, 0, # start of value 3 - 7, 0, # start of value 4 - 6, 0, # start of value 5 - 5, 0, # start of value 6 - 4, 0, # start of value 7 - 20, 0, 0, 0, # vtable offset - - 1, # value 7 - 1, # value 6 - 1, # value 5 - 1, # value 4 - 1, # value 3 - 1, # value 2 - 1, # value 1 - 1, # value 0 - ]) - - def test_three_bools(self): - b = flatbuffers.Builder(0) - b.StartObject(3) - b.PrependBoolSlot(0, True, False) - b.PrependBoolSlot(1, True, False) - b.PrependBoolSlot(2, True, False) - off = b.EndObject() - b.Finish(off) - - self.assertBuilderEquals(b, [ - 16, 0, 0, 0, # root of table: points to vtable offset - - 0, 0, # padding - - 10, 0, # vtable bytes - 8, 0, # size of object - 7, 0, # start of value 0 - 6, 0, # start of value 1 - 5, 0, # start of value 2 - 10, 0, 0, 0, # vtable offset from here - - 0, # padding - 1, # value 2 - 1, # value 1 - 1, # value 0 - ]) - - def test_some_floats(self): - b = flatbuffers.Builder(0) - b.StartObject(1) - b.PrependFloat32Slot(0, 1.0, 0.0) - off = b.EndObject() - - self.assertBuilderEquals(b, [ - 6, 0, # vtable bytes - 8, 0, # size of object - 4, 0, # start of value 0 - 6, 0, 0, 0, # vtable offset - - 0, 0, 128, 63, # value 0 - ]) - - -def make_monster_from_generated_code(): - ''' Use generated code to build the example Monster. ''' - - b = flatbuffers.Builder(0) - string = b.CreateString("MyMonster") - test1 = b.CreateString("test1") - test2 = b.CreateString("test2") - fred = b.CreateString("Fred") - - MyGame.Example.Monster.MonsterStartInventoryVector(b, 5) - b.PrependByte(4) - b.PrependByte(3) - b.PrependByte(2) - b.PrependByte(1) - b.PrependByte(0) - inv = b.EndVector(5) - - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddName(b, fred) - mon2 = MyGame.Example.Monster.MonsterEnd(b) - - MyGame.Example.Monster.MonsterStartTest4Vector(b, 2) - MyGame.Example.Test.CreateTest(b, 10, 20) - MyGame.Example.Test.CreateTest(b, 30, 40) - test4 = b.EndVector(2) - - MyGame.Example.Monster.MonsterStartTestarrayofstringVector(b, 2) - b.PrependUOffsetTRelative(test2) - b.PrependUOffsetTRelative(test1) - testArrayOfString = b.EndVector(2) - - MyGame.Example.Monster.MonsterStart(b) - - pos = MyGame.Example.Vec3.CreateVec3(b, 1.0, 2.0, 3.0, 3.0, 2, 5, 6) - MyGame.Example.Monster.MonsterAddPos(b, pos) - - MyGame.Example.Monster.MonsterAddHp(b, 80) - MyGame.Example.Monster.MonsterAddName(b, string) - MyGame.Example.Monster.MonsterAddInventory(b, inv) - MyGame.Example.Monster.MonsterAddTestType(b, 1) - MyGame.Example.Monster.MonsterAddTest(b, mon2) - MyGame.Example.Monster.MonsterAddTest4(b, test4) - MyGame.Example.Monster.MonsterAddTestarrayofstring(b, testArrayOfString) - mon = MyGame.Example.Monster.MonsterEnd(b) - - b.Finish(mon) - - return b.Bytes, b.Head() - - -class TestAllCodePathsOfExampleSchema(unittest.TestCase): - def setUp(self, *args, **kwargs): - super(TestAllCodePathsOfExampleSchema, self).setUp(*args, **kwargs) - - b = flatbuffers.Builder(0) - MyGame.Example.Monster.MonsterStart(b) - gen_mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(gen_mon) - - self.mon = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - - def test_default_monster_pos(self): - self.assertTrue(self.mon.Pos() is None) - - def test_nondefault_monster_mana(self): - b = flatbuffers.Builder(0) - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddMana(b, 50) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - got_mon = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(50, got_mon.Mana()) - - def test_default_monster_hp(self): - self.assertEqual(100, self.mon.Hp()) - - def test_default_monster_name(self): - self.assertEqual('', self.mon.Name()) - - def test_default_monster_inventory_item(self): - self.assertEqual(0, self.mon.Inventory(0)) - - def test_default_monster_inventory_length(self): - self.assertEqual(0, self.mon.InventoryLength()) - - def test_default_monster_color(self): - self.assertEqual(MyGame.Example.Color.Color.Blue, self.mon.Color()) - - def test_nondefault_monster_color(self): - b = flatbuffers.Builder(0) - color = MyGame.Example.Color.Color.Red - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddColor(b, color) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(MyGame.Example.Color.Color.Red, mon2.Color()) - - def test_default_monster_testtype(self): - self.assertEqual(0, self.mon.TestType()) - - def test_default_monster_test_field(self): - self.assertEqual(None, self.mon.Test()) - - def test_default_monster_test4_item(self): - self.assertEqual(None, self.mon.Test4(0)) - - def test_default_monster_test4_length(self): - self.assertEqual(0, self.mon.Test4Length()) - - def test_default_monster_testarrayofstring(self): - self.assertEqual("", self.mon.Testarrayofstring(0)) - - def test_default_monster_testarrayofstring_length(self): - self.assertEqual(0, self.mon.TestarrayofstringLength()) - - def test_default_monster_testarrayoftables(self): - self.assertEqual(None, self.mon.Testarrayoftables(0)) - - def test_nondefault_monster_testarrayoftables(self): - b = flatbuffers.Builder(0) - - # make a child Monster within a vector of Monsters: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddHp(b, 99) - sub_monster = MyGame.Example.Monster.MonsterEnd(b) - - # build the vector: - MyGame.Example.Monster.MonsterStartTestarrayoftablesVector(b, 1) - b.PrependUOffsetTRelative(sub_monster) - vec = b.EndVector(1) - - # make the parent monster and include the vector of Monster: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddTestarrayoftables(b, vec) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Output(), 0) - self.assertEqual(99, mon2.Testarrayoftables(0).Hp()) - self.assertEqual(1, mon2.TestarrayoftablesLength()) - - def test_default_monster_testarrayoftables_length(self): - self.assertEqual(0, self.mon.TestarrayoftablesLength()) - - def test_nondefault_monster_enemy(self): - b = flatbuffers.Builder(0) - - # make an Enemy object: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddHp(b, 88) - enemy = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(enemy) - - # make the parent monster and include the vector of Monster: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddEnemy(b, enemy) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(88, mon2.Enemy().Hp()) - - def test_default_monster_testnestedflatbuffer(self): - self.assertEqual(0, self.mon.Testnestedflatbuffer(0)) - - def test_default_monster_testnestedflatbuffer_length(self): - self.assertEqual(0, self.mon.TestnestedflatbufferLength()) - - def test_nondefault_monster_testnestedflatbuffer(self): - b = flatbuffers.Builder(0) - - MyGame.Example.Monster.MonsterStartTestnestedflatbufferVector(b, 3) - b.PrependByte(4) - b.PrependByte(2) - b.PrependByte(0) - sub_buf = b.EndVector(3) - - # make the parent monster and include the vector of Monster: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddTestnestedflatbuffer(b, sub_buf) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(3, mon2.TestnestedflatbufferLength()) - self.assertEqual(0, mon2.Testnestedflatbuffer(0)) - self.assertEqual(2, mon2.Testnestedflatbuffer(1)) - self.assertEqual(4, mon2.Testnestedflatbuffer(2)) - - def test_nondefault_monster_testempty(self): - b = flatbuffers.Builder(0) - - # make a Stat object: - MyGame.Example.Stat.StatStart(b) - MyGame.Example.Stat.StatAddVal(b, 123) - my_stat = MyGame.Example.Stat.StatEnd(b) - b.Finish(my_stat) - - # include the stat object in a monster: - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddTestempty(b, my_stat) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(123, mon2.Testempty().Val()) - - def test_default_monster_testbool(self): - self.assertFalse(self.mon.Testbool()) - - def test_nondefault_monster_testbool(self): - b = flatbuffers.Builder(0) - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddTestbool(b, True) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertTrue(mon2.Testbool()) - - def test_default_monster_testhashes(self): - self.assertEqual(0, self.mon.Testhashs32Fnv1()) - self.assertEqual(0, self.mon.Testhashu32Fnv1()) - self.assertEqual(0, self.mon.Testhashs64Fnv1()) - self.assertEqual(0, self.mon.Testhashu64Fnv1()) - self.assertEqual(0, self.mon.Testhashs32Fnv1a()) - self.assertEqual(0, self.mon.Testhashu32Fnv1a()) - self.assertEqual(0, self.mon.Testhashs64Fnv1a()) - self.assertEqual(0, self.mon.Testhashu64Fnv1a()) - - def test_nondefault_monster_testhashes(self): - b = flatbuffers.Builder(0) - MyGame.Example.Monster.MonsterStart(b) - MyGame.Example.Monster.MonsterAddTesthashs32Fnv1(b, 1) - MyGame.Example.Monster.MonsterAddTesthashu32Fnv1(b, 2) - MyGame.Example.Monster.MonsterAddTesthashs64Fnv1(b, 3) - MyGame.Example.Monster.MonsterAddTesthashu64Fnv1(b, 4) - MyGame.Example.Monster.MonsterAddTesthashs32Fnv1a(b, 5) - MyGame.Example.Monster.MonsterAddTesthashu32Fnv1a(b, 6) - MyGame.Example.Monster.MonsterAddTesthashs64Fnv1a(b, 7) - MyGame.Example.Monster.MonsterAddTesthashu64Fnv1a(b, 8) - mon = MyGame.Example.Monster.MonsterEnd(b) - b.Finish(mon) - - # inspect the resulting data: - mon2 = MyGame.Example.Monster.Monster.GetRootAsMonster(b.Bytes, - b.Head()) - self.assertEqual(1, mon2.Testhashs32Fnv1()) - self.assertEqual(2, mon2.Testhashu32Fnv1()) - self.assertEqual(3, mon2.Testhashs64Fnv1()) - self.assertEqual(4, mon2.Testhashu64Fnv1()) - self.assertEqual(5, mon2.Testhashs32Fnv1a()) - self.assertEqual(6, mon2.Testhashu32Fnv1a()) - self.assertEqual(7, mon2.Testhashs64Fnv1a()) - self.assertEqual(8, mon2.Testhashu64Fnv1a()) - - def test_getrootas_for_nonroot_table(self): - b = flatbuffers.Builder(0) - string = b.CreateString("MyStat") - - MyGame.Example.Stat.StatStart(b) - MyGame.Example.Stat.StatAddId(b, string) - MyGame.Example.Stat.StatAddVal(b, 12345678) - MyGame.Example.Stat.StatAddCount(b, 12345) - stat = MyGame.Example.Stat.StatEnd(b) - b.Finish(stat) - - stat2 = MyGame.Example.Stat.Stat.GetRootAsStat(b.Bytes, b.Head()) - - self.assertEqual(b"MyStat", stat2.Id()) - self.assertEqual(12345678, stat2.Val()) - self.assertEqual(12345, stat2.Count()) - - -class TestVtableDeduplication(unittest.TestCase): - ''' TestVtableDeduplication verifies that vtables are deduplicated. ''' - - def test_vtable_deduplication(self): - b = flatbuffers.Builder(0) - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 11, 0) - b.PrependByteSlot(2, 22, 0) - b.PrependInt16Slot(3, 33, 0) - obj0 = b.EndObject() - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 44, 0) - b.PrependByteSlot(2, 55, 0) - b.PrependInt16Slot(3, 66, 0) - obj1 = b.EndObject() - - b.StartObject(4) - b.PrependByteSlot(0, 0, 0) - b.PrependByteSlot(1, 77, 0) - b.PrependByteSlot(2, 88, 0) - b.PrependInt16Slot(3, 99, 0) - obj2 = b.EndObject() - - got = b.Bytes[b.Head():] - - want = bytearray([ - 240, 255, 255, 255, # == -12. offset to dedupped vtable. - 99, 0, - 88, - 77, - 248, 255, 255, 255, # == -8. offset to dedupped vtable. - 66, 0, - 55, - 44, - 12, 0, - 8, 0, - 0, 0, - 7, 0, - 6, 0, - 4, 0, - 12, 0, 0, 0, - 33, 0, - 22, - 11, - ]) - - self.assertEqual((len(want), want), (len(got), got)) - - table0 = flatbuffers.table.Table(b.Bytes, len(b.Bytes) - obj0) - table1 = flatbuffers.table.Table(b.Bytes, len(b.Bytes) - obj1) - table2 = flatbuffers.table.Table(b.Bytes, len(b.Bytes) - obj2) - - def _checkTable(tab, voffsett_value, b, c, d): - # vtable size - got = tab.GetVOffsetTSlot(0, 0) - self.assertEqual(12, got, 'case 0, 0') - - # object size - got = tab.GetVOffsetTSlot(2, 0) - self.assertEqual(8, got, 'case 2, 0') - - # default value - got = tab.GetVOffsetTSlot(4, 0) - self.assertEqual(voffsett_value, got, 'case 4, 0') - - got = tab.GetSlot(6, 0, N.Uint8Flags) - self.assertEqual(b, got, 'case 6, 0') - - val = tab.GetSlot(8, 0, N.Uint8Flags) - self.assertEqual(c, val, 'failed 8, 0') - - got = tab.GetSlot(10, 0, N.Uint8Flags) - self.assertEqual(d, got, 'failed 10, 0') - - _checkTable(table0, 0, 11, 22, 33) - _checkTable(table1, 0, 44, 55, 66) - _checkTable(table2, 0, 77, 88, 99) - - -class TestExceptions(unittest.TestCase): - def test_object_is_nested_error(self): - b = flatbuffers.Builder(0) - b.StartObject(0) - assertRaises(self, lambda: b.StartObject(0), - flatbuffers.builder.IsNestedError) - - def test_object_is_not_nested_error(self): - b = flatbuffers.Builder(0) - assertRaises(self, lambda: b.EndObject(), - flatbuffers.builder.IsNotNestedError) - - def test_struct_is_not_inline_error(self): - b = flatbuffers.Builder(0) - b.StartObject(0) - assertRaises(self, lambda: b.PrependStructSlot(0, 1, 0), - flatbuffers.builder.StructIsNotInlineError) - - def test_unreachable_error(self): - b = flatbuffers.Builder(0) - assertRaises(self, lambda: b.PrependUOffsetTRelative(1), - flatbuffers.builder.OffsetArithmeticError) - - def test_create_string_is_nested_error(self): - b = flatbuffers.Builder(0) - b.StartObject(0) - s = 'test1' - assertRaises(self, lambda: b.CreateString(s), - flatbuffers.builder.IsNestedError) - - def test_finished_bytes_error(self): - b = flatbuffers.Builder(0) - assertRaises(self, lambda: b.Output(), - flatbuffers.builder.BuilderNotFinishedError) - - -def CheckAgainstGoldDataGo(): - try: - gen_buf, gen_off = make_monster_from_generated_code() - fn = 'monsterdata_go_wire.mon' - if not os.path.exists(fn): - print('Go-generated data does not exist, failed.') - return False - - # would like to use a context manager here, but it's less - # backwards-compatible: - f = open(fn, 'rb') - go_wire_data = f.read() - f.close() - - CheckReadBuffer(bytearray(go_wire_data), 0) - if not bytearray(gen_buf[gen_off:]) == bytearray(go_wire_data): - raise AssertionError('CheckAgainstGoldDataGo failed') - except: - print('Failed to test against Go-generated test data.') - return False - - print('Can read Go-generated test data, and Python generates bytewise identical data.') - return True - - -def CheckAgainstGoldDataJava(): - try: - gen_buf, gen_off = make_monster_from_generated_code() - fn = 'monsterdata_java_wire.mon' - if not os.path.exists(fn): - print('Java-generated data does not exist, failed.') - return False - f = open(fn, 'rb') - java_wire_data = f.read() - f.close() - - CheckReadBuffer(bytearray(java_wire_data), 0) - except: - print('Failed to read Java-generated test data.') - return False - - print('Can read Java-generated test data.') - return True - - -class LCG(object): - ''' Include simple random number generator to ensure results will be the - same cross platform. - http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator ''' - - __slots__ = ['n'] - - InitialLCGSeed = 48271 - - def __init__(self): - self.n = self.InitialLCGSeed - - def Reset(self): - self.n = self.InitialLCGSeed - - def Next(self): - self.n = ((self.n * 279470273) % 4294967291) & 0xFFFFFFFF - return self.n - - -def BenchmarkVtableDeduplication(count): - ''' - BenchmarkVtableDeduplication measures the speed of vtable deduplication - by creating `prePop` vtables, then populating `count` objects with a - different single vtable. - - When count is large (as in long benchmarks), memory usage may be high. - ''' - - prePop = 10 - builder = flatbuffers.Builder(0) - - # pre-populate some vtables: - for i in compat_range(prePop): - builder.StartObject(i) - for j in compat_range(i): - builder.PrependInt16Slot(j, j, 0) - builder.EndObject() - - # benchmark deduplication of a new vtable: - def f(): - builder.StartObject(prePop) - for j in compat_range(prePop): - builder.PrependInt16Slot(j, j, 0) - builder.EndObject() - - duration = timeit.timeit(stmt=f, number=count) - rate = float(count) / duration - print(('vtable deduplication rate: %.2f/sec' % rate)) - - -def BenchmarkCheckReadBuffer(count, buf, off): - ''' - BenchmarkCheckReadBuffer measures the speed of flatbuffer reading - by re-using the CheckReadBuffer function with the gold data. - ''' - - def f(): - CheckReadBuffer(buf, off) - - duration = timeit.timeit(stmt=f, number=count) - rate = float(count) / duration - data = float(len(buf) * count) / float(1024 * 1024) - data_rate = data / float(duration) - - print(('traversed %d %d-byte flatbuffers in %.2fsec: %.2f/sec, %.2fMB/sec') - % (count, len(buf), duration, rate, data_rate)) - - -def BenchmarkMakeMonsterFromGeneratedCode(count, length): - ''' - BenchmarkMakeMonsterFromGeneratedCode measures the speed of flatbuffer - creation by re-using the make_monster_from_generated_code function for - generating gold data examples. - ''' - - duration = timeit.timeit(stmt=make_monster_from_generated_code, - number=count) - rate = float(count) / duration - data = float(length * count) / float(1024 * 1024) - data_rate = data / float(duration) - - print(('built %d %d-byte flatbuffers in %.2fsec: %.2f/sec, %.2fMB/sec' % \ - (count, length, duration, rate, data_rate))) - - -def backward_compatible_run_tests(**kwargs): - if PY_VERSION < (2, 6): - sys.stderr.write("Python version less than 2.6 are not supported") - sys.stderr.flush() - return False - - # python2.6 has a reduced-functionality unittest.main function: - if PY_VERSION == (2, 6): - try: - unittest.main(**kwargs) - except SystemExit as e: - if not e.code == 0: - return False - return True - - # python2.7 and above let us not exit once unittest.main is run: - kwargs['exit'] = False - kwargs['verbosity'] = 0 - ret = unittest.main(**kwargs) - if ret.result.errors or ret.result.failures: - return False - - return True - -def main(): - import os - import sys - if not len(sys.argv) == 4: - sys.stderr.write('Usage: %s <benchmark vtable count>' - '<benchmark read count> <benchmark build count>\n' - % sys.argv[0]) - sys.stderr.write(' Provide COMPARE_GENERATED_TO_GO=1 to check' - 'for bytewise comparison to Go data.\n') - sys.stderr.write(' Provide COMPARE_GENERATED_TO_JAVA=1 to check' - 'for bytewise comparison to Java data.\n') - sys.stderr.flush() - sys.exit(1) - - kwargs = dict(argv=sys.argv[:-3]) - - # run tests, and run some language comparison checks if needed: - success = backward_compatible_run_tests(**kwargs) - if success and os.environ.get('COMPARE_GENERATED_TO_GO', 0) == "1": - success = success and CheckAgainstGoldDataGo() - if success and os.environ.get('COMPARE_GENERATED_TO_JAVA', 0) == "1": - success = success and CheckAgainstGoldDataJava() - - if not success: - sys.stderr.write('Tests failed, skipping benchmarks.\n') - sys.stderr.flush() - sys.exit(1) - - # run benchmarks (if 0, they will be a noop): - bench_vtable = int(sys.argv[1]) - bench_traverse = int(sys.argv[2]) - bench_build = int(sys.argv[3]) - if bench_vtable: - BenchmarkVtableDeduplication(bench_vtable) - if bench_traverse: - buf, off = make_monster_from_generated_code() - BenchmarkCheckReadBuffer(bench_traverse, buf, off) - if bench_build: - buf, off = make_monster_from_generated_code() - BenchmarkMakeMonsterFromGeneratedCode(bench_build, len(buf)) - -if __name__ == '__main__': - main()
diff --git a/third_party/flatbuffers/tests/test.cpp b/third_party/flatbuffers/tests/test.cpp deleted file mode 100644 index cc632bb..0000000 --- a/third_party/flatbuffers/tests/test.cpp +++ /dev/null
@@ -1,1558 +0,0 @@ -/* - * Copyright 2014 Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "flatbuffers/flatbuffers.h" -#include "flatbuffers/idl.h" -#include "flatbuffers/util.h" - -#include "monster_test_generated.h" -#include "namespace_test/namespace_test1_generated.h" -#include "namespace_test/namespace_test2_generated.h" -#include "union_vector/union_vector_generated.h" - -#ifndef FLATBUFFERS_CPP98_STL - #include <random> -#endif - -#include "flatbuffers/flexbuffers.h" - -using namespace MyGame::Example; - -#ifdef __ANDROID__ - #include <android/log.h> - #define TEST_OUTPUT_LINE(...) \ - __android_log_print(ANDROID_LOG_INFO, "FlatBuffers", __VA_ARGS__) - #define FLATBUFFERS_NO_FILE_TESTS -#else - #define TEST_OUTPUT_LINE(...) \ - { printf(__VA_ARGS__); printf("\n"); } -#endif - -int testing_fails = 0; - -void TestFail(const char *expval, const char *val, const char *exp, - const char *file, int line) { - TEST_OUTPUT_LINE("TEST FAILED: %s:%d, %s (%s) != %s", file, line, - exp, expval, val); - assert(0); - testing_fails++; -} - -void TestEqStr(const char *expval, const char *val, const char *exp, - const char *file, int line) { - if (strcmp(expval, val) != 0) { - TestFail(expval, val, exp, file, line); - } -} - -template<typename T, typename U> -void TestEq(T expval, U val, const char *exp, const char *file, int line) { - if (U(expval) != val) { - TestFail(flatbuffers::NumToString(expval).c_str(), - flatbuffers::NumToString(val).c_str(), - exp, file, line); - } -} - -#define TEST_EQ(exp, val) TestEq(exp, val, #exp, __FILE__, __LINE__) -#define TEST_NOTNULL(exp) TestEq(exp == NULL, false, #exp, __FILE__, __LINE__) -#define TEST_EQ_STR(exp, val) TestEqStr(exp, val, #exp, __FILE__, __LINE__) - -// Include simple random number generator to ensure results will be the -// same cross platform. -// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator -uint32_t lcg_seed = 48271; -uint32_t lcg_rand() { - return lcg_seed = ((uint64_t)lcg_seed * 279470273UL) % 4294967291UL; -} -void lcg_reset() { lcg_seed = 48271; } - -// example of how to build up a serialized buffer algorithmically: -flatbuffers::unique_ptr_t CreateFlatBufferTest(std::string &buffer) { - flatbuffers::FlatBufferBuilder builder; - - auto vec = Vec3(1, 2, 3, 0, Color_Red, Test(10, 20)); - - auto name = builder.CreateString("MyMonster"); - - unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - auto inventory = builder.CreateVector(inv_data, 10); - - // Alternatively, create the vector first, and fill in data later: - // unsigned char *inv_buf = nullptr; - // auto inventory = builder.CreateUninitializedVector<unsigned char>( - // 10, &inv_buf); - // memcpy(inv_buf, inv_data, 10); - - Test tests[] = { Test(10, 20), Test(30, 40) }; - auto testv = builder.CreateVectorOfStructs(tests, 2); - - // create monster with very few fields set: - // (same functionality as CreateMonster below, but sets fields manually) - flatbuffers::Offset<Monster> mlocs[3]; - auto fred = builder.CreateString("Fred"); - auto barney = builder.CreateString("Barney"); - auto wilma = builder.CreateString("Wilma"); - MonsterBuilder mb1(builder); - mb1.add_name(fred); - mlocs[0] = mb1.Finish(); - MonsterBuilder mb2(builder); - mb2.add_name(barney); - mb2.add_hp(1000); - mlocs[1] = mb2.Finish(); - MonsterBuilder mb3(builder); - mb3.add_name(wilma); - mlocs[2] = mb3.Finish(); - - // Create an array of strings. Also test string pooling, and lambdas. - const char *names[] = { "bob", "fred", "bob", "fred" }; - auto vecofstrings = - builder.CreateVector<flatbuffers::Offset<flatbuffers::String>>(4, - [&](size_t i) { - return builder.CreateSharedString(names[i]); - }); - - // Creating vectors of strings in one convenient call. - std::vector<std::string> names2; - names2.push_back("jane"); - names2.push_back("mary"); - auto vecofstrings2 = builder.CreateVectorOfStrings(names2); - - // Create an array of sorted tables, can be used with binary search when read: - auto vecoftables = builder.CreateVectorOfSortedTables(mlocs, 3); - - // Create an array of sorted structs, - // can be used with binary search when read: - std::vector<Ability> abilities; - abilities.push_back(Ability(4, 40)); - abilities.push_back(Ability(3, 30)); - abilities.push_back(Ability(2, 20)); - abilities.push_back(Ability(1, 10)); - auto vecofstructs = builder.CreateVectorOfSortedStructs(&abilities); - - // shortcut for creating monster with all fields set: - auto mloc = CreateMonster(builder, &vec, 150, 80, name, inventory, Color_Blue, - Any_Monster, mlocs[1].Union(), // Store a union. - testv, vecofstrings, vecoftables, 0, 0, 0, false, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.14159f, 3.0f, 0.0f, - vecofstrings2, vecofstructs); - - FinishMonsterBuffer(builder, mloc); - - #ifdef FLATBUFFERS_TEST_VERBOSE - // print byte data for debugging: - auto p = builder.GetBufferPointer(); - for (flatbuffers::uoffset_t i = 0; i < builder.GetSize(); i++) - printf("%d ", p[i]); - #endif - - // return the buffer for the caller to use. - auto bufferpointer = - reinterpret_cast<const char *>(builder.GetBufferPointer()); - buffer.assign(bufferpointer, bufferpointer + builder.GetSize()); - - return builder.ReleaseBufferPointer(); -} - -// example of accessing a buffer loaded in memory: -void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length, - bool pooled = true) { - - // First, verify the buffers integrity (optional) - flatbuffers::Verifier verifier(flatbuf, length); - TEST_EQ(VerifyMonsterBuffer(verifier), true); - - std::vector<uint8_t> test_buff; - test_buff.resize(length * 2); - std::memcpy(&test_buff[0], flatbuf , length); - std::memcpy(&test_buff[length], flatbuf , length); - - flatbuffers::Verifier verifierl(&test_buff[0], length - 1); - TEST_EQ(VerifyMonsterBuffer(verifierl), false); - TEST_EQ(verifierl.GetComputedSize(), 0); - - flatbuffers::Verifier verifier1(&test_buff[0], length); - TEST_EQ(VerifyMonsterBuffer(verifier1), true); - TEST_EQ(verifier1.GetComputedSize(), length); - - flatbuffers::Verifier verifier2(&test_buff[length], length); - TEST_EQ(VerifyMonsterBuffer(verifier2), true); - TEST_EQ(verifier2.GetComputedSize(), length); - - TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0); - TEST_EQ(MonsterBufferHasIdentifier(flatbuf), true); - TEST_EQ(strcmp(MonsterExtension(), "mon"), 0); - - // Access the buffer from the root. - auto monster = GetMonster(flatbuf); - - TEST_EQ(monster->hp(), 80); - TEST_EQ(monster->mana(), 150); // default - TEST_EQ_STR(monster->name()->c_str(), "MyMonster"); - // Can't access the following field, it is deprecated in the schema, - // which means accessors are not generated: - // monster.friendly() - - auto pos = monster->pos(); - TEST_NOTNULL(pos); - TEST_EQ(pos->z(), 3); - TEST_EQ(pos->test3().a(), 10); - TEST_EQ(pos->test3().b(), 20); - - auto inventory = monster->inventory(); - TEST_EQ(VectorLength(inventory), 10UL); // Works even if inventory is null. - TEST_NOTNULL(inventory); - unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - for (auto it = inventory->begin(); it != inventory->end(); ++it) - TEST_EQ(*it, inv_data[it - inventory->begin()]); - - TEST_EQ(monster->color(), Color_Blue); - - // Example of accessing a union: - TEST_EQ(monster->test_type(), Any_Monster); // First make sure which it is. - auto monster2 = reinterpret_cast<const Monster *>(monster->test()); - TEST_NOTNULL(monster2); - TEST_EQ_STR(monster2->name()->c_str(), "Fred"); - - // Example of accessing a vector of strings: - auto vecofstrings = monster->testarrayofstring(); - TEST_EQ(vecofstrings->Length(), 4U); - TEST_EQ_STR(vecofstrings->Get(0)->c_str(), "bob"); - TEST_EQ_STR(vecofstrings->Get(1)->c_str(), "fred"); - if (pooled) { - // These should have pointer equality because of string pooling. - TEST_EQ(vecofstrings->Get(0)->c_str(), vecofstrings->Get(2)->c_str()); - TEST_EQ(vecofstrings->Get(1)->c_str(), vecofstrings->Get(3)->c_str()); - } - - auto vecofstrings2 = monster->testarrayofstring2(); - if (vecofstrings2) { - TEST_EQ(vecofstrings2->Length(), 2U); - TEST_EQ_STR(vecofstrings2->Get(0)->c_str(), "jane"); - TEST_EQ_STR(vecofstrings2->Get(1)->c_str(), "mary"); - } - - // Example of accessing a vector of tables: - auto vecoftables = monster->testarrayoftables(); - TEST_EQ(vecoftables->Length(), 3U); - for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it) - TEST_EQ(strlen(it->name()->c_str()) >= 4, true); - TEST_EQ_STR(vecoftables->Get(0)->name()->c_str(), "Barney"); - TEST_EQ(vecoftables->Get(0)->hp(), 1000); - TEST_EQ_STR(vecoftables->Get(1)->name()->c_str(), "Fred"); - TEST_EQ_STR(vecoftables->Get(2)->name()->c_str(), "Wilma"); - TEST_NOTNULL(vecoftables->LookupByKey("Barney")); - TEST_NOTNULL(vecoftables->LookupByKey("Fred")); - TEST_NOTNULL(vecoftables->LookupByKey("Wilma")); - - // Test accessing a vector of sorted structs - auto vecofstructs = monster->testarrayofsortedstruct(); - if (vecofstructs) { // not filled in monster_test.bfbs - for (flatbuffers::uoffset_t i = 0; i < vecofstructs->size()-1; i++) { - auto left = vecofstructs->Get(i); - auto right = vecofstructs->Get(i+1); - TEST_EQ(true, (left->KeyCompareLessThan(right))); - } - TEST_NOTNULL(vecofstructs->LookupByKey(3)); - TEST_EQ(static_cast<const Ability*>(nullptr), vecofstructs->LookupByKey(5)); - } - - // Since Flatbuffers uses explicit mechanisms to override the default - // compiler alignment, double check that the compiler indeed obeys them: - // (Test consists of a short and byte): - TEST_EQ(flatbuffers::AlignOf<Test>(), 2UL); - TEST_EQ(sizeof(Test), 4UL); - - auto tests = monster->test4(); - TEST_NOTNULL(tests); - auto test_0 = tests->Get(0); - auto test_1 = tests->Get(1); - TEST_EQ(test_0->a(), 10); - TEST_EQ(test_0->b(), 20); - TEST_EQ(test_1->a(), 30); - TEST_EQ(test_1->b(), 40); - for (auto it = tests->begin(); it != tests->end(); ++it) { - TEST_EQ(it->a() == 10 || it->a() == 30, true); // Just testing iterators. - } - - // Checking for presence of fields: - TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_HP), true); - TEST_EQ(flatbuffers::IsFieldPresent(monster, Monster::VT_MANA), false); - - // Obtaining a buffer from a root: - TEST_EQ(GetBufferStartFromRootPointer(monster), flatbuf); -} - -// Change a FlatBuffer in-place, after it has been constructed. -void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length) { - // Get non-const pointer to root. - auto monster = GetMutableMonster(flatbuf); - - // Each of these tests mutates, then tests, then set back to the original, - // so we can test that the buffer in the end still passes our original test. - auto hp_ok = monster->mutate_hp(10); - TEST_EQ(hp_ok, true); // Field was present. - TEST_EQ(monster->hp(), 10); - // Mutate to default value - auto hp_ok_default = monster->mutate_hp(100); - TEST_EQ(hp_ok_default, true); // Field was present. - TEST_EQ(monster->hp(), 100); - // Test that mutate to default above keeps field valid for further mutations - auto hp_ok_2 = monster->mutate_hp(20); - TEST_EQ(hp_ok_2, true); - TEST_EQ(monster->hp(), 20); - monster->mutate_hp(80); - - // Monster originally at 150 mana (default value) - auto mana_default_ok = monster->mutate_mana(150); // Mutate to default value. - TEST_EQ(mana_default_ok, true); // Mutation should succeed, because default value. - TEST_EQ(monster->mana(), 150); - auto mana_ok = monster->mutate_mana(10); - TEST_EQ(mana_ok, false); // Field was NOT present, because default value. - TEST_EQ(monster->mana(), 150); - - // Mutate structs. - auto pos = monster->mutable_pos(); - auto test3 = pos->mutable_test3(); // Struct inside a struct. - test3.mutate_a(50); // Struct fields never fail. - TEST_EQ(test3.a(), 50); - test3.mutate_a(10); - - // Mutate vectors. - auto inventory = monster->mutable_inventory(); - inventory->Mutate(9, 100); - TEST_EQ(inventory->Get(9), 100); - inventory->Mutate(9, 9); - - auto tables = monster->mutable_testarrayoftables(); - auto first = tables->GetMutableObject(0); - TEST_EQ(first->hp(), 1000); - first->mutate_hp(0); - TEST_EQ(first->hp(), 0); - first->mutate_hp(1000); - - // Run the verifier and the regular test to make sure we didn't trample on - // anything. - AccessFlatBufferTest(flatbuf, length); -} - -// Unpack a FlatBuffer into objects. -void ObjectFlatBuffersTest(uint8_t *flatbuf) { - // Optional: we can specify resolver and rehasher functions to turn hashed - // strings into object pointers and back, to implement remote references - // and such. - auto resolver = flatbuffers::resolver_function_t( - [](void **pointer_adr, flatbuffers::hash_value_t hash) { - (void)pointer_adr; - (void)hash; - // Don't actually do anything, leave variable null. - }); - auto rehasher = flatbuffers::rehasher_function_t( - [](void *pointer) -> flatbuffers::hash_value_t { - (void)pointer; - return 0; - }); - - // Turn a buffer into C++ objects. - auto monster1 = UnPackMonster(flatbuf, &resolver); - - // Re-serialize the data. - flatbuffers::FlatBufferBuilder fbb1; - fbb1.Finish(CreateMonster(fbb1, monster1.get(), &rehasher), - MonsterIdentifier()); - - // Unpack again, and re-serialize again. - auto monster2 = UnPackMonster(fbb1.GetBufferPointer(), &resolver); - flatbuffers::FlatBufferBuilder fbb2; - fbb2.Finish(CreateMonster(fbb2, monster2.get(), &rehasher), - MonsterIdentifier()); - - // Now we've gone full round-trip, the two buffers should match. - auto len1 = fbb1.GetSize(); - auto len2 = fbb2.GetSize(); - TEST_EQ(len1, len2); - TEST_EQ(memcmp(fbb1.GetBufferPointer(), fbb2.GetBufferPointer(), - len1), 0); - - // Test it with the original buffer test to make sure all data survived. - AccessFlatBufferTest(fbb2.GetBufferPointer(), len2, false); - - // Test accessing fields, similar to AccessFlatBufferTest above. - TEST_EQ(monster2->hp, 80); - TEST_EQ(monster2->mana, 150); // default - TEST_EQ_STR(monster2->name.c_str(), "MyMonster"); - - auto &pos = monster2->pos; - TEST_NOTNULL(pos); - TEST_EQ(pos->z(), 3); - TEST_EQ(pos->test3().a(), 10); - TEST_EQ(pos->test3().b(), 20); - - auto &inventory = monster2->inventory; - TEST_EQ(inventory.size(), 10UL); - unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - for (auto it = inventory.begin(); it != inventory.end(); ++it) - TEST_EQ(*it, inv_data[it - inventory.begin()]); - - TEST_EQ(monster2->color, Color_Blue); - - auto monster3 = monster2->test.AsMonster(); - TEST_NOTNULL(monster3); - TEST_EQ_STR(monster3->name.c_str(), "Fred"); - - auto &vecofstrings = monster2->testarrayofstring; - TEST_EQ(vecofstrings.size(), 4U); - TEST_EQ_STR(vecofstrings[0].c_str(), "bob"); - TEST_EQ_STR(vecofstrings[1].c_str(), "fred"); - - auto &vecofstrings2 = monster2->testarrayofstring2; - TEST_EQ(vecofstrings2.size(), 2U); - TEST_EQ_STR(vecofstrings2[0].c_str(), "jane"); - TEST_EQ_STR(vecofstrings2[1].c_str(), "mary"); - - auto &vecoftables = monster2->testarrayoftables; - TEST_EQ(vecoftables.size(), 3U); - TEST_EQ_STR(vecoftables[0]->name.c_str(), "Barney"); - TEST_EQ(vecoftables[0]->hp, 1000); - TEST_EQ_STR(vecoftables[1]->name.c_str(), "Fred"); - TEST_EQ_STR(vecoftables[2]->name.c_str(), "Wilma"); - - auto &tests = monster2->test4; - TEST_EQ(tests[0].a(), 10); - TEST_EQ(tests[0].b(), 20); - TEST_EQ(tests[1].a(), 30); - TEST_EQ(tests[1].b(), 40); -} - -// Prefix a FlatBuffer with a size field. -void SizePrefixedTest() { - // Create size prefixed buffer. - flatbuffers::FlatBufferBuilder fbb; - fbb.FinishSizePrefixed(CreateMonster(fbb, 0, 200, 300, - fbb.CreateString("bob"))); - - // Verify it. - flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize()); - TEST_EQ(verifier.VerifySizePrefixedBuffer<Monster>(nullptr), true); - - // Access it. - auto m = flatbuffers::GetSizePrefixedRoot<MyGame::Example::Monster>( - fbb.GetBufferPointer()); - TEST_EQ(m->mana(), 200); - TEST_EQ(m->hp(), 300); - TEST_EQ_STR(m->name()->c_str(), "bob"); -} - -// example of parsing text straight into a buffer, and generating -// text back from it: -void ParseAndGenerateTextTest() { - // load FlatBuffer schema (.fbs) and JSON from disk - std::string schemafile; - std::string jsonfile; - TEST_EQ(flatbuffers::LoadFile( - "tests/monster_test.fbs", false, &schemafile), true); - TEST_EQ(flatbuffers::LoadFile( - "tests/monsterdata_test.golden", false, &jsonfile), true); - - // parse schema first, so we can use it to parse the data after - flatbuffers::Parser parser; - const char *include_directories[] = { "tests", nullptr }; - TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true); - TEST_EQ(parser.Parse(jsonfile.c_str(), include_directories), true); - - // here, parser.builder_ contains a binary buffer that is the parsed data. - - // First, verify it, just in case: - flatbuffers::Verifier verifier(parser.builder_.GetBufferPointer(), - parser.builder_.GetSize()); - TEST_EQ(VerifyMonsterBuffer(verifier), true); - - // to ensure it is correct, we now generate text back from the binary, - // and compare the two: - std::string jsongen; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, true); - - if (jsongen != jsonfile) { - printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str()); - TEST_NOTNULL(NULL); - } -} - -void ReflectionTest(uint8_t *flatbuf, size_t length) { - // Load a binary schema. - std::string bfbsfile; - TEST_EQ(flatbuffers::LoadFile( - "tests/monster_test.bfbs", true, &bfbsfile), true); - - // Verify it, just in case: - flatbuffers::Verifier verifier( - reinterpret_cast<const uint8_t *>(bfbsfile.c_str()), bfbsfile.length()); - TEST_EQ(reflection::VerifySchemaBuffer(verifier), true); - - // Make sure the schema is what we expect it to be. - auto &schema = *reflection::GetSchema(bfbsfile.c_str()); - auto root_table = schema.root_table(); - TEST_EQ_STR(root_table->name()->c_str(), "MyGame.Example.Monster"); - auto fields = root_table->fields(); - auto hp_field_ptr = fields->LookupByKey("hp"); - TEST_NOTNULL(hp_field_ptr); - auto &hp_field = *hp_field_ptr; - TEST_EQ_STR(hp_field.name()->c_str(), "hp"); - TEST_EQ(hp_field.id(), 2); - TEST_EQ(hp_field.type()->base_type(), reflection::Short); - auto friendly_field_ptr = fields->LookupByKey("friendly"); - TEST_NOTNULL(friendly_field_ptr); - TEST_NOTNULL(friendly_field_ptr->attributes()); - TEST_NOTNULL(friendly_field_ptr->attributes()->LookupByKey("priority")); - - // Make sure the table index is what we expect it to be. - auto pos_field_ptr = fields->LookupByKey("pos"); - TEST_NOTNULL(pos_field_ptr); - TEST_EQ(pos_field_ptr->type()->base_type(), reflection::Obj); - auto pos_table_ptr = schema.objects()->Get(pos_field_ptr->type()->index()); - TEST_NOTNULL(pos_table_ptr); - TEST_EQ_STR(pos_table_ptr->name()->c_str(), "MyGame.Example.Vec3"); - - // Now use it to dynamically access a buffer. - auto &root = *flatbuffers::GetAnyRoot(flatbuf); - - // Verify the buffer first using reflection based verification - TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length), - true); - - auto hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field); - TEST_EQ(hp, 80); - - // Rather than needing to know the type, we can also get the value of - // any field as an int64_t/double/string, regardless of what it actually is. - auto hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field); - TEST_EQ(hp_int64, 80); - auto hp_double = flatbuffers::GetAnyFieldF(root, hp_field); - TEST_EQ(hp_double, 80.0); - auto hp_string = flatbuffers::GetAnyFieldS(root, hp_field, &schema); - TEST_EQ_STR(hp_string.c_str(), "80"); - - // Get struct field through reflection - auto pos_struct = flatbuffers::GetFieldStruct(root, *pos_field_ptr); - TEST_NOTNULL(pos_struct); - TEST_EQ(flatbuffers::GetAnyFieldF( - *pos_struct, *pos_table_ptr->fields()->LookupByKey("z")), 3.0f); - - auto test3_field = pos_table_ptr->fields()->LookupByKey("test3"); - auto test3_struct = flatbuffers::GetFieldStruct(*pos_struct, *test3_field); - TEST_NOTNULL(test3_struct); - auto test3_object = schema.objects()->Get(test3_field->type()->index()); - - TEST_EQ(flatbuffers::GetAnyFieldF( - *test3_struct, *test3_object->fields()->LookupByKey("a")), 10); - - // We can also modify it. - flatbuffers::SetField<uint16_t>(&root, hp_field, 200); - hp = flatbuffers::GetFieldI<uint16_t>(root, hp_field); - TEST_EQ(hp, 200); - - // We can also set fields generically: - flatbuffers::SetAnyFieldI(&root, hp_field, 300); - hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field); - TEST_EQ(hp_int64, 300); - flatbuffers::SetAnyFieldF(&root, hp_field, 300.5); - hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field); - TEST_EQ(hp_int64, 300); - flatbuffers::SetAnyFieldS(&root, hp_field, "300"); - hp_int64 = flatbuffers::GetAnyFieldI(root, hp_field); - TEST_EQ(hp_int64, 300); - - // Test buffer is valid after the modifications - TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), flatbuf, length), - true); - - // Reset it, for further tests. - flatbuffers::SetField<uint16_t>(&root, hp_field, 80); - - // More advanced functionality: changing the size of items in-line! - // First we put the FlatBuffer inside an std::vector. - std::vector<uint8_t> resizingbuf(flatbuf, flatbuf + length); - // Find the field we want to modify. - auto &name_field = *fields->LookupByKey("name"); - // Get the root. - // This time we wrap the result from GetAnyRoot in a smartpointer that - // will keep rroot valid as resizingbuf resizes. - auto rroot = flatbuffers::piv(flatbuffers::GetAnyRoot(resizingbuf.data()), - resizingbuf); - SetString(schema, "totally new string", GetFieldS(**rroot, name_field), - &resizingbuf); - // Here resizingbuf has changed, but rroot is still valid. - TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "totally new string"); - // Now lets extend a vector by 100 elements (10 -> 110). - auto &inventory_field = *fields->LookupByKey("inventory"); - auto rinventory = flatbuffers::piv( - flatbuffers::GetFieldV<uint8_t>(**rroot, inventory_field), - resizingbuf); - flatbuffers::ResizeVector<uint8_t>(schema, 110, 50, *rinventory, - &resizingbuf); - // rinventory still valid, so lets read from it. - TEST_EQ(rinventory->Get(10), 50); - - // For reflection uses not covered already, there is a more powerful way: - // we can simply generate whatever object we want to add/modify in a - // FlatBuffer of its own, then add that to an existing FlatBuffer: - // As an example, let's add a string to an array of strings. - // First, find our field: - auto &testarrayofstring_field = *fields->LookupByKey("testarrayofstring"); - // Find the vector value: - auto rtestarrayofstring = flatbuffers::piv( - flatbuffers::GetFieldV<flatbuffers::Offset<flatbuffers::String>>( - **rroot, testarrayofstring_field), - resizingbuf); - // It's a vector of 2 strings, to which we add one more, initialized to - // offset 0. - flatbuffers::ResizeVector<flatbuffers::Offset<flatbuffers::String>>( - schema, 3, 0, *rtestarrayofstring, &resizingbuf); - // Here we just create a buffer that contans a single string, but this - // could also be any complex set of tables and other values. - flatbuffers::FlatBufferBuilder stringfbb; - stringfbb.Finish(stringfbb.CreateString("hank")); - // Add the contents of it to our existing FlatBuffer. - // We do this last, so the pointer doesn't get invalidated (since it is - // at the end of the buffer): - auto string_ptr = flatbuffers::AddFlatBuffer(resizingbuf, - stringfbb.GetBufferPointer(), - stringfbb.GetSize()); - // Finally, set the new value in the vector. - rtestarrayofstring->MutateOffset(2, string_ptr); - TEST_EQ_STR(rtestarrayofstring->Get(0)->c_str(), "bob"); - TEST_EQ_STR(rtestarrayofstring->Get(2)->c_str(), "hank"); - // Test integrity of all resize operations above. - flatbuffers::Verifier resize_verifier( - reinterpret_cast<const uint8_t *>(resizingbuf.data()), - resizingbuf.size()); - TEST_EQ(VerifyMonsterBuffer(resize_verifier), true); - - // Test buffer is valid using reflection as well - TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), resizingbuf.data(), - resizingbuf.size()), true); - - // As an additional test, also set it on the name field. - // Note: unlike the name change above, this just overwrites the offset, - // rather than changing the string in-place. - SetFieldT(*rroot, name_field, string_ptr); - TEST_EQ_STR(GetFieldS(**rroot, name_field)->c_str(), "hank"); - - // Using reflection, rather than mutating binary FlatBuffers, we can also copy - // tables and other things out of other FlatBuffers into a FlatBufferBuilder, - // either part or whole. - flatbuffers::FlatBufferBuilder fbb; - auto root_offset = flatbuffers::CopyTable(fbb, schema, *root_table, - *flatbuffers::GetAnyRoot(flatbuf), - true); - fbb.Finish(root_offset, MonsterIdentifier()); - // Test that it was copied correctly: - AccessFlatBufferTest(fbb.GetBufferPointer(), fbb.GetSize()); - - // Test buffer is valid using reflection as well - TEST_EQ(flatbuffers::Verify(schema, *schema.root_table(), - fbb.GetBufferPointer(), fbb.GetSize()), true); -} - -// Parse a .proto schema, output as .fbs -void ParseProtoTest() { - // load the .proto and the golden file from disk - std::string protofile; - std::string goldenfile; - TEST_EQ(flatbuffers::LoadFile( - "tests/prototest/test.proto", false, &protofile), true); - TEST_EQ(flatbuffers::LoadFile( - "tests/prototest/test.golden", false, &goldenfile), true); - - flatbuffers::IDLOptions opts; - opts.include_dependence_headers = false; - opts.proto_mode = true; - - // Parse proto. - flatbuffers::Parser parser(opts); - const char *include_directories[] = { "tests/prototest", nullptr }; - TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true); - - // Generate fbs. - auto fbs = flatbuffers::GenerateFBS(parser, "test"); - - // Ensure generated file is parsable. - flatbuffers::Parser parser2; - TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true); - - if (fbs != goldenfile) { - printf("%s----------------\n%s", fbs.c_str(), goldenfile.c_str()); - TEST_NOTNULL(NULL); - } -} - -template<typename T> void CompareTableFieldValue(flatbuffers::Table *table, - flatbuffers::voffset_t voffset, - T val) { - T read = table->GetField(voffset, static_cast<T>(0)); - TEST_EQ(read, val); -} - -// Low level stress/fuzz test: serialize/deserialize a variety of -// different kinds of data in different combinations -void FuzzTest1() { - - // Values we're testing against: chosen to ensure no bits get chopped - // off anywhere, and also be different from eachother. - const uint8_t bool_val = true; - const int8_t char_val = -127; // 0x81 - const uint8_t uchar_val = 0xFF; - const int16_t short_val = -32222; // 0x8222; - const uint16_t ushort_val = 0xFEEE; - const int32_t int_val = 0x83333333; - const uint32_t uint_val = 0xFDDDDDDD; - const int64_t long_val = 0x8444444444444444LL; - const uint64_t ulong_val = 0xFCCCCCCCCCCCCCCCULL; - const float float_val = 3.14159f; - const double double_val = 3.14159265359; - - const int test_values_max = 11; - const flatbuffers::voffset_t fields_per_object = 4; - const int num_fuzz_objects = 10000; // The higher, the more thorough :) - - flatbuffers::FlatBufferBuilder builder; - - lcg_reset(); // Keep it deterministic. - - flatbuffers::uoffset_t objects[num_fuzz_objects]; - - // Generate num_fuzz_objects random objects each consisting of - // fields_per_object fields, each of a random type. - for (int i = 0; i < num_fuzz_objects; i++) { - auto start = builder.StartTable(); - for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) { - int choice = lcg_rand() % test_values_max; - auto off = flatbuffers::FieldIndexToOffset(f); - switch (choice) { - case 0: builder.AddElement<uint8_t >(off, bool_val, 0); break; - case 1: builder.AddElement<int8_t >(off, char_val, 0); break; - case 2: builder.AddElement<uint8_t >(off, uchar_val, 0); break; - case 3: builder.AddElement<int16_t >(off, short_val, 0); break; - case 4: builder.AddElement<uint16_t>(off, ushort_val, 0); break; - case 5: builder.AddElement<int32_t >(off, int_val, 0); break; - case 6: builder.AddElement<uint32_t>(off, uint_val, 0); break; - case 7: builder.AddElement<int64_t >(off, long_val, 0); break; - case 8: builder.AddElement<uint64_t>(off, ulong_val, 0); break; - case 9: builder.AddElement<float >(off, float_val, 0); break; - case 10: builder.AddElement<double >(off, double_val, 0); break; - } - } - objects[i] = builder.EndTable(start, fields_per_object); - } - builder.PreAlign<flatbuffers::largest_scalar_t>(0); // Align whole buffer. - - lcg_reset(); // Reset. - - uint8_t *eob = builder.GetCurrentBufferPointer() + builder.GetSize(); - - // Test that all objects we generated are readable and return the - // expected values. We generate random objects in the same order - // so this is deterministic. - for (int i = 0; i < num_fuzz_objects; i++) { - auto table = reinterpret_cast<flatbuffers::Table *>(eob - objects[i]); - for (flatbuffers::voffset_t f = 0; f < fields_per_object; f++) { - int choice = lcg_rand() % test_values_max; - flatbuffers::voffset_t off = flatbuffers::FieldIndexToOffset(f); - switch (choice) { - case 0: CompareTableFieldValue(table, off, bool_val ); break; - case 1: CompareTableFieldValue(table, off, char_val ); break; - case 2: CompareTableFieldValue(table, off, uchar_val ); break; - case 3: CompareTableFieldValue(table, off, short_val ); break; - case 4: CompareTableFieldValue(table, off, ushort_val); break; - case 5: CompareTableFieldValue(table, off, int_val ); break; - case 6: CompareTableFieldValue(table, off, uint_val ); break; - case 7: CompareTableFieldValue(table, off, long_val ); break; - case 8: CompareTableFieldValue(table, off, ulong_val ); break; - case 9: CompareTableFieldValue(table, off, float_val ); break; - case 10: CompareTableFieldValue(table, off, double_val); break; - } - } - } -} - -// High level stress/fuzz test: generate a big schema and -// matching json data in random combinations, then parse both, -// generate json back from the binary, and compare with the original. -void FuzzTest2() { - lcg_reset(); // Keep it deterministic. - - const int num_definitions = 30; - const int num_struct_definitions = 5; // Subset of num_definitions. - const int fields_per_definition = 15; - const int instances_per_definition = 5; - const int deprecation_rate = 10; // 1 in deprecation_rate fields will - // be deprecated. - - std::string schema = "namespace test;\n\n"; - - struct RndDef { - std::string instances[instances_per_definition]; - - // Since we're generating schema and corresponding data in tandem, - // this convenience function adds strings to both at once. - static void Add(RndDef (&definitions_l)[num_definitions], - std::string &schema_l, - const int instances_per_definition_l, - const char *schema_add, const char *instance_add, - int definition) { - schema_l += schema_add; - for (int i = 0; i < instances_per_definition_l; i++) - definitions_l[definition].instances[i] += instance_add; - } - }; - - #define AddToSchemaAndInstances(schema_add, instance_add) \ - RndDef::Add(definitions, schema, instances_per_definition, \ - schema_add, instance_add, definition) - - #define Dummy() \ - RndDef::Add(definitions, schema, instances_per_definition, \ - "byte", "1", definition) - - RndDef definitions[num_definitions]; - - // We are going to generate num_definitions, the first - // num_struct_definitions will be structs, the rest tables. For each - // generate random fields, some of which may be struct/table types - // referring to previously generated structs/tables. - // Simultanenously, we generate instances_per_definition JSON data - // definitions, which will have identical structure to the schema - // being generated. We generate multiple instances such that when creating - // hierarchy, we get some variety by picking one randomly. - for (int definition = 0; definition < num_definitions; definition++) { - std::string definition_name = "D" + flatbuffers::NumToString(definition); - - bool is_struct = definition < num_struct_definitions; - - AddToSchemaAndInstances( - ((is_struct ? "struct " : "table ") + definition_name + " {\n").c_str(), - "{\n"); - - for (int field = 0; field < fields_per_definition; field++) { - const bool is_last_field = field == fields_per_definition - 1; - - // Deprecate 1 in deprecation_rate fields. Only table fields can be - // deprecated. - // Don't deprecate the last field to avoid dangling commas in JSON. - const bool deprecated = !is_struct && - !is_last_field && - (lcg_rand() % deprecation_rate == 0); - - std::string field_name = "f" + flatbuffers::NumToString(field); - AddToSchemaAndInstances((" " + field_name + ":").c_str(), - deprecated ? "" : (field_name + ": ").c_str()); - // Pick random type: - int base_type = lcg_rand() % (flatbuffers::BASE_TYPE_UNION + 1); - switch (base_type) { - case flatbuffers::BASE_TYPE_STRING: - if (is_struct) { - Dummy(); // No strings in structs. - } else { - AddToSchemaAndInstances("string", deprecated ? "" : "\"hi\""); - } - break; - case flatbuffers::BASE_TYPE_VECTOR: - if (is_struct) { - Dummy(); // No vectors in structs. - } - else { - AddToSchemaAndInstances("[ubyte]", - deprecated ? "" : "[\n0,\n1,\n255\n]"); - } - break; - case flatbuffers::BASE_TYPE_NONE: - case flatbuffers::BASE_TYPE_UTYPE: - case flatbuffers::BASE_TYPE_STRUCT: - case flatbuffers::BASE_TYPE_UNION: - if (definition) { - // Pick a random previous definition and random data instance of - // that definition. - int defref = lcg_rand() % definition; - int instance = lcg_rand() % instances_per_definition; - AddToSchemaAndInstances( - ("D" + flatbuffers::NumToString(defref)).c_str(), - deprecated - ? "" - : definitions[defref].instances[instance].c_str()); - } else { - // If this is the first definition, we have no definition we can - // refer to. - Dummy(); - } - break; - case flatbuffers::BASE_TYPE_BOOL: - AddToSchemaAndInstances("bool", deprecated - ? "" - : (lcg_rand() % 2 ? "true" : "false")); - break; - default: - // All the scalar types. - schema += flatbuffers::kTypeNames[base_type]; - - if (!deprecated) { - // We want each instance to use its own random value. - for (int inst = 0; inst < instances_per_definition; inst++) - definitions[definition].instances[inst] += - flatbuffers::NumToString(lcg_rand() % 128).c_str(); - } - } - AddToSchemaAndInstances( - deprecated ? "(deprecated);\n" : ";\n", - deprecated ? "" : is_last_field ? "\n" : ",\n"); - } - AddToSchemaAndInstances("}\n\n", "}"); - } - - schema += "root_type D" + flatbuffers::NumToString(num_definitions - 1); - schema += ";\n"; - - flatbuffers::Parser parser; - - // Will not compare against the original if we don't write defaults - parser.builder_.ForceDefaults(true); - - // Parse the schema, parse the generated data, then generate text back - // from the binary and compare against the original. - TEST_EQ(parser.Parse(schema.c_str()), true); - - const std::string &json = - definitions[num_definitions - 1].instances[0] + "\n"; - - TEST_EQ(parser.Parse(json.c_str()), true); - - std::string jsongen; - parser.opts.indent_step = 0; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, true); - - if (jsongen != json) { - // These strings are larger than a megabyte, so we show the bytes around - // the first bytes that are different rather than the whole string. - size_t len = std::min(json.length(), jsongen.length()); - for (size_t i = 0; i < len; i++) { - if (json[i] != jsongen[i]) { - i -= std::min(static_cast<size_t>(10), i); // show some context; - size_t end = std::min(len, i + 20); - for (; i < end; i++) - printf("at %d: found \"%c\", expected \"%c\"\n", - static_cast<int>(i), jsongen[i], json[i]); - break; - } - } - TEST_NOTNULL(NULL); - } - - printf("%dk schema tested with %dk of json\n", - static_cast<int>(schema.length() / 1024), - static_cast<int>(json.length() / 1024)); -} - -// Test that parser errors are actually generated. -void TestError(const char *src, const char *error_substr, - bool strict_json = false) { - flatbuffers::IDLOptions opts; - opts.strict_json = strict_json; - flatbuffers::Parser parser(opts); - TEST_EQ(parser.Parse(src), false); // Must signal error - // Must be the error we're expecting - TEST_NOTNULL(strstr(parser.error_.c_str(), error_substr)); -} - -// Test that parsing errors occur as we'd expect. -// Also useful for coverage, making sure these paths are run. -void ErrorTest() { - // In order they appear in idl_parser.cpp - TestError("table X { Y:byte; } root_type X; { Y: 999 }", "does not fit"); - TestError(".0", "floating point"); - TestError("\"\0", "illegal"); - TestError("\"\\q", "escape code"); - TestError("table ///", "documentation"); - TestError("@", "illegal"); - TestError("table 1", "expecting"); - TestError("table X { Y:[[int]]; }", "nested vector"); - TestError("table X { Y:1; }", "illegal type"); - TestError("table X { Y:int; Y:int; }", "field already"); - TestError("struct X { Y:string; }", "only scalar"); - TestError("struct X { Y:int (deprecated); }", "deprecate"); - TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }", - "missing type field"); - TestError("union Z { X } table X { Y:Z; } root_type X; { Y_type: 99, Y: {", - "type id"); - TestError("table X { Y:int; } root_type X; { Z:", "unknown field"); - TestError("table X { Y:int; } root_type X; { Y:", "string constant", true); - TestError("table X { Y:int; } root_type X; { \"Y\":1, }", "string constant", - true); - TestError("struct X { Y:int; Z:int; } table W { V:X; } root_type W; " - "{ V:{ Y:1 } }", "wrong number"); - TestError("enum E:byte { A } table X { Y:E; } root_type X; { Y:U }", - "unknown enum value"); - TestError("table X { Y:byte; } root_type X; { Y:; }", "starting"); - TestError("enum X:byte { Y } enum X {", "enum already"); - TestError("enum X:float {}", "underlying"); - TestError("enum X:byte { Y, Y }", "value already"); - TestError("enum X:byte { Y=2, Z=1 }", "ascending"); - TestError("enum X:byte (bit_flags) { Y=8 }", "bit flag out"); - TestError("table X { Y:int; } table X {", "datatype already"); - TestError("struct X (force_align: 7) { Y:int; }", "force_align"); - TestError("{}", "no root"); - TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "one json"); - TestError("root_type X;", "unknown root"); - TestError("struct X { Y:int; } root_type X;", "a table"); - TestError("union X { Y }", "referenced"); - TestError("union Z { X } struct X { Y:int; }", "only tables"); - TestError("table X { Y:[int]; YLength:int; }", "clash"); - TestError("table X { Y:string = 1; }", "scalar"); - TestError("table X { Y:byte; } root_type X; { Y:1, Y:2 }", "more than once"); -} - -template<typename T> T TestValue(const char *json, const char *type_name) { - flatbuffers::Parser parser; - - // Simple schema. - TEST_EQ(parser.Parse(std::string("table X { Y:" + std::string(type_name) + - "; } root_type X;").c_str()), true); - - TEST_EQ(parser.Parse(json), true); - auto root = flatbuffers::GetRoot<flatbuffers::Table>( - parser.builder_.GetBufferPointer()); - return root->GetField<T>(flatbuffers::FieldIndexToOffset(0), 0); -} - -bool FloatCompare(float a, float b) { return fabs(a - b) < 0.001; } - -// Additional parser testing not covered elsewhere. -void ValueTest() { - // Test scientific notation numbers. - TEST_EQ(FloatCompare(TestValue<float>("{ Y:0.0314159e+2 }","float"), - (float)3.14159), true); - - // Test conversion functions. - TEST_EQ(FloatCompare(TestValue<float>("{ Y:cos(rad(180)) }","float"), -1), - true); - - // Test negative hex constant. - TEST_EQ(TestValue<int>("{ Y:-0x80 }","int"), -128); - - // Make sure we do unsigned 64bit correctly. - TEST_EQ(TestValue<uint64_t>("{ Y:12335089644688340133 }","ulong"), - 12335089644688340133ULL); -} - -void EnumStringsTest() { - flatbuffers::Parser parser1; - TEST_EQ(parser1.Parse("enum E:byte { A, B, C } table T { F:[E]; }" - "root_type T;" - "{ F:[ A, B, \"C\", \"A B C\" ] }"), true); - flatbuffers::Parser parser2; - TEST_EQ(parser2.Parse("enum E:byte { A, B, C } table T { F:[int]; }" - "root_type T;" - "{ F:[ \"E.C\", \"E.A E.B E.C\" ] }"), true); -} - -void IntegerOutOfRangeTest() { - TestError("table T { F:byte; } root_type T; { F:128 }", - "constant does not fit"); - TestError("table T { F:byte; } root_type T; { F:-129 }", - "constant does not fit"); - TestError("table T { F:ubyte; } root_type T; { F:256 }", - "constant does not fit"); - TestError("table T { F:ubyte; } root_type T; { F:-1 }", - "constant does not fit"); - TestError("table T { F:short; } root_type T; { F:32768 }", - "constant does not fit"); - TestError("table T { F:short; } root_type T; { F:-32769 }", - "constant does not fit"); - TestError("table T { F:ushort; } root_type T; { F:65536 }", - "constant does not fit"); - TestError("table T { F:ushort; } root_type T; { F:-1 }", - "constant does not fit"); - TestError("table T { F:int; } root_type T; { F:2147483648 }", - "constant does not fit"); - TestError("table T { F:int; } root_type T; { F:-2147483649 }", - "constant does not fit"); - TestError("table T { F:uint; } root_type T; { F:4294967296 }", - "constant does not fit"); - TestError("table T { F:uint; } root_type T; { F:-1 }", - "constant does not fit"); -} - -void IntegerBoundaryTest() { - TEST_EQ(TestValue<int8_t>("{ Y:127 }","byte"), 127); - TEST_EQ(TestValue<int8_t>("{ Y:-128 }","byte"), -128); - TEST_EQ(TestValue<uint8_t>("{ Y:255 }","ubyte"), 255); - TEST_EQ(TestValue<uint8_t>("{ Y:0 }","ubyte"), 0); - TEST_EQ(TestValue<int16_t>("{ Y:32767 }","short"), 32767); - TEST_EQ(TestValue<int16_t>("{ Y:-32768 }","short"), -32768); - TEST_EQ(TestValue<uint16_t>("{ Y:65535 }","ushort"), 65535); - TEST_EQ(TestValue<uint16_t>("{ Y:0 }","ushort"), 0); - TEST_EQ(TestValue<int32_t>("{ Y:2147483647 }","int"), 2147483647); - TEST_EQ(TestValue<int32_t>("{ Y:-2147483648 }","int"), (-2147483647 - 1)); - TEST_EQ(TestValue<uint32_t>("{ Y:4294967295 }","uint"), 4294967295); - TEST_EQ(TestValue<uint32_t>("{ Y:0 }","uint"), 0); - TEST_EQ(TestValue<int64_t>("{ Y:9223372036854775807 }","long"), 9223372036854775807); - TEST_EQ(TestValue<int64_t>("{ Y:-9223372036854775808 }","long"), (-9223372036854775807 - 1)); - TEST_EQ(TestValue<uint64_t>("{ Y:18446744073709551615 }","ulong"), 18446744073709551615U); - TEST_EQ(TestValue<uint64_t>("{ Y:0 }","ulong"), 0); -} - -void UnicodeTest() { - flatbuffers::Parser parser; - // Without setting allow_non_utf8 = true, we treat \x sequences as byte sequences - // which are then validated as UTF-8. - TEST_EQ(parser.Parse("table T { F:string; }" - "root_type T;" - "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC" - "\\u5225\\u30B5\\u30A4\\u30C8\\xE2\\x82\\xAC\\u0080\\uD83D\\uDE0E\" }"), - true); - std::string jsongen; - parser.opts.indent_step = -1; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, true); - TEST_EQ(jsongen, - std::string( - "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC" - "\\u5225\\u30B5\\u30A4\\u30C8\\u20AC\\u0080\\uD83D\\uDE0E\"}")); -} - -void UnicodeTestAllowNonUTF8() { - flatbuffers::Parser parser; - parser.opts.allow_non_utf8 = true; - TEST_EQ(parser.Parse("table T { F:string; }" - "root_type T;" - "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC" - "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"), true); - std::string jsongen; - parser.opts.indent_step = -1; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, true); - TEST_EQ(jsongen, - std::string( - "{F: \"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC" - "\\u5225\\u30B5\\u30A4\\u30C8\\u0001\\x80\\u0080\\uD83D\\uDE0E\"}")); -} - -void UnicodeTestGenerateTextFailsOnNonUTF8() { - flatbuffers::Parser parser; - // Allow non-UTF-8 initially to model what happens when we load a binary flatbuffer from disk - // which contains non-UTF-8 strings. - parser.opts.allow_non_utf8 = true; - TEST_EQ(parser.Parse("table T { F:string; }" - "root_type T;" - "{ F:\"\\u20AC\\u00A2\\u30E6\\u30FC\\u30B6\\u30FC" - "\\u5225\\u30B5\\u30A4\\u30C8\\x01\\x80\\u0080\\uD83D\\uDE0E\" }"), true); - std::string jsongen; - parser.opts.indent_step = -1; - // Now, disallow non-UTF-8 (the default behavior) so GenerateText indicates failure. - parser.opts.allow_non_utf8 = false; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, false); -} - -void UnicodeSurrogatesTest() { - flatbuffers::Parser parser; - - TEST_EQ( - parser.Parse( - "table T { F:string (id: 0); }" - "root_type T;" - "{ F:\"\\uD83D\\uDCA9\"}"), true); - auto root = flatbuffers::GetRoot<flatbuffers::Table>( - parser.builder_.GetBufferPointer()); - auto string = root->GetPointer<flatbuffers::String *>( - flatbuffers::FieldIndexToOffset(0)); - TEST_EQ(strcmp(string->c_str(), "\xF0\x9F\x92\xA9"), 0); -} - -void UnicodeInvalidSurrogatesTest() { - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\\uD800\"}", "unpaired high surrogate"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\\uD800abcd\"}", "unpaired high surrogate"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\\uD800\\n\"}", "unpaired high surrogate"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\\uD800\\uD800\"}", "multiple high surrogates"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\\uDC00\"}", "unpaired low surrogate"); -} - -void InvalidUTF8Test() { - // "1 byte" pattern, under min length of 2 bytes - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\x80\"}", "illegal UTF-8 sequence"); - // 2 byte pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xDF\"}", "illegal UTF-8 sequence"); - // 3 byte pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xEF\xBF\"}", "illegal UTF-8 sequence"); - // 4 byte pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xF7\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "5 byte" pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFB\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "6 byte" pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFD\xBF\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "7 byte" pattern, string too short - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "5 byte" pattern, over max length of 4 bytes - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFB\xBF\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "6 byte" pattern, over max length of 4 bytes - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFD\xBF\xBF\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - // "7 byte" pattern, over max length of 4 bytes - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xFE\xBF\xBF\xBF\xBF\xBF\xBF\"}", "illegal UTF-8 sequence"); - - // Three invalid encodings for U+000A (\n, aka NEWLINE) - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xC0\x8A\"}", "illegal UTF-8 sequence"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xE0\x80\x8A\"}", "illegal UTF-8 sequence"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xF0\x80\x80\x8A\"}", "illegal UTF-8 sequence"); - - // Two invalid encodings for U+00A9 (COPYRIGHT SYMBOL) - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xE0\x81\xA9\"}", "illegal UTF-8 sequence"); - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xF0\x80\x81\xA9\"}", "illegal UTF-8 sequence"); - - // Invalid encoding for U+20AC (EURO SYMBOL) - TestError( - "table T { F:string; }" - "root_type T;" - "{ F:\"\xF0\x82\x82\xAC\"}", "illegal UTF-8 sequence"); - - // UTF-16 surrogate values between U+D800 and U+DFFF cannot be encoded in UTF-8 - TestError( - "table T { F:string; }" - "root_type T;" - // U+10400 "encoded" as U+D801 U+DC00 - "{ F:\"\xED\xA0\x81\xED\xB0\x80\"}", "illegal UTF-8 sequence"); -} - -void UnknownFieldsTest() { - flatbuffers::IDLOptions opts; - opts.skip_unexpected_fields_in_json = true; - flatbuffers::Parser parser(opts); - - TEST_EQ(parser.Parse("table T { str:string; i:int;}" - "root_type T;" - "{ str:\"test\"," - "unknown_string:\"test\"," - "\"unknown_string\":\"test\"," - "unknown_int:10," - "unknown_float:1.0," - "unknown_array: [ 1, 2, 3, 4]," - "unknown_object: { i: 10 }," - "\"unknown_object\": { \"i\": 10 }," - "i:10}"), true); - - std::string jsongen; - parser.opts.indent_step = -1; - auto result = GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); - TEST_EQ(result, true); - TEST_EQ(jsongen == "{str: \"test\",i: 10}", true); -} - -void ParseUnionTest() { - // Unions must be parseable with the type field following the object. - flatbuffers::Parser parser; - TEST_EQ(parser.Parse("table T { A:int; }" - "union U { T }" - "table V { X:U; }" - "root_type V;" - "{ X:{ A:1 }, X_type: T }"), true); - // Unions must be parsable with prefixed namespace. - flatbuffers::Parser parser2; - TEST_EQ(parser2.Parse("namespace N; table A {} namespace; union U { N.A }" - "table B { e:U; } root_type B;" - "{ e_type: N_A, e: {} }"), true); -} - -void UnionVectorTest() { - // load FlatBuffer fbs schema. - // TODO: load a JSON file with such a vector when JSON support is ready. - std::string schemafile; - TEST_EQ(flatbuffers::LoadFile( - "tests/union_vector/union_vector.fbs", false, &schemafile), true); - - // parse schema. - flatbuffers::IDLOptions idl_opts; - idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kCpp; - flatbuffers::Parser parser(idl_opts); - const char *include_directories[] = { "tests/union_vector", nullptr }; - TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true); - - flatbuffers::FlatBufferBuilder fbb; - - // union types. - std::vector<uint8_t> types; - types.push_back(static_cast<uint8_t>(Character_Belle)); - types.push_back(static_cast<uint8_t>(Character_MuLan)); - types.push_back(static_cast<uint8_t>(Character_BookFan)); - types.push_back(static_cast<uint8_t>(Character_Other)); - types.push_back(static_cast<uint8_t>(Character_Unused)); - - // union values. - std::vector<flatbuffers::Offset<void>> characters; - characters.push_back(fbb.CreateStruct(BookReader(/*books_read=*/7)).Union()); - characters.push_back(CreateAttacker(fbb, /*sword_attack_damage=*/5).Union()); - characters.push_back(fbb.CreateStruct(BookReader(/*books_read=*/2)).Union()); - characters.push_back(fbb.CreateString("Other").Union()); - characters.push_back(fbb.CreateString("Unused").Union()); - - // create Movie. - const auto movie_offset = - CreateMovie(fbb, - Character_Rapunzel, - fbb.CreateStruct(Rapunzel(/*hair_length=*/6)).Union(), - fbb.CreateVector(types), - fbb.CreateVector(characters)); - FinishMovieBuffer(fbb, movie_offset); - auto buf = fbb.GetBufferPointer(); - - flatbuffers::Verifier verifier(buf, fbb.GetSize()); - TEST_EQ(VerifyMovieBuffer(verifier), true); - - auto flat_movie = GetMovie(buf); - - auto TestMovie = [](const Movie *movie) { - TEST_EQ(movie->main_character_type() == Character_Rapunzel, true); - - auto cts = movie->characters_type(); - TEST_EQ(movie->characters_type()->size(), 5); - TEST_EQ(cts->GetEnum<Character>(0) == Character_Belle, true); - TEST_EQ(cts->GetEnum<Character>(1) == Character_MuLan, true); - TEST_EQ(cts->GetEnum<Character>(2) == Character_BookFan, true); - TEST_EQ(cts->GetEnum<Character>(3) == Character_Other, true); - TEST_EQ(cts->GetEnum<Character>(4) == Character_Unused, true); - - auto rapunzel = movie->main_character_as_Rapunzel(); - TEST_EQ(rapunzel->hair_length(), 6); - - auto cs = movie->characters(); - TEST_EQ(cs->size(), 5); - auto belle = cs->GetAs<BookReader>(0); - TEST_EQ(belle->books_read(), 7); - auto mu_lan = cs->GetAs<Attacker>(1); - TEST_EQ(mu_lan->sword_attack_damage(), 5); - auto book_fan = cs->GetAs<BookReader>(2); - TEST_EQ(book_fan->books_read(), 2); - auto other = cs->GetAsString(3); - TEST_EQ_STR(other->c_str(), "Other"); - auto unused = cs->GetAsString(4); - TEST_EQ_STR(unused->c_str(), "Unused"); - }; - - TestMovie(flat_movie); - - auto movie_object = flat_movie->UnPack(); - TEST_EQ(movie_object->main_character.AsRapunzel()->hair_length(), 6); - TEST_EQ(movie_object->characters[0].AsBelle()->books_read(), 7); - TEST_EQ(movie_object->characters[1].AsMuLan()->sword_attack_damage, 5); - TEST_EQ(movie_object->characters[2].AsBookFan()->books_read(), 2); - TEST_EQ_STR(movie_object->characters[3].AsOther()->c_str(), "Other"); - TEST_EQ_STR(movie_object->characters[4].AsUnused()->c_str(), "Unused"); - - fbb.Clear(); - fbb.Finish(Movie::Pack(fbb, movie_object)); - - auto repacked_movie = GetMovie(fbb.GetBufferPointer()); - - TestMovie(repacked_movie); -} - -void ConformTest() { - flatbuffers::Parser parser; - TEST_EQ(parser.Parse("table T { A:int; } enum E:byte { A }"), true); - - auto test_conform = [&](const char *test, const char *expected_err) { - flatbuffers::Parser parser2; - TEST_EQ(parser2.Parse(test), true); - auto err = parser2.ConformTo(parser); - TEST_NOTNULL(strstr(err.c_str(), expected_err)); - }; - - test_conform("table T { A:byte; }", "types differ for field"); - test_conform("table T { B:int; A:int; }", "offsets differ for field"); - test_conform("table T { A:int = 1; }", "defaults differ for field"); - test_conform("table T { B:float; }", "field renamed to different type"); - test_conform("enum E:byte { B, A }", "values differ for enum"); -} - -void FlexBuffersTest() { - flexbuffers::Builder slb(512, - flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS); - - // Write the equivalent of: - // { vec: [ -100, "Fred", 4.0 ], bar: [ 1, 2, 3 ], foo: 100 } - slb.Map([&]() { - slb.Vector("vec", [&]() { - slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100); - slb += "Fred"; - slb.IndirectFloat(4.0f); - }); - int ints[] = { 1, 2, 3 }; - slb.Vector("bar", ints, 3); - slb.FixedTypedVector("bar3", ints, 3); - slb.Double("foo", 100); - slb.Map("mymap", [&]() { - slb.String("foo", "Fred"); // Testing key and string reuse. - }); - }); - slb.Finish(); - - for (size_t i = 0; i < slb.GetBuffer().size(); i++) - printf("%d ", slb.GetBuffer().data()[i]); - printf("\n"); - - auto map = flexbuffers::GetRoot(slb.GetBuffer()).AsMap(); - TEST_EQ(map.size(), 5); - auto vec = map["vec"].AsVector(); - TEST_EQ(vec.size(), 3); - TEST_EQ(vec[0].AsInt64(), -100); - TEST_EQ_STR(vec[1].AsString().c_str(), "Fred"); - TEST_EQ(vec[1].AsInt64(), 0); // Number parsing failed. - TEST_EQ(vec[2].AsDouble(), 4.0); - TEST_EQ(vec[2].AsString().IsTheEmptyString(), true); // Wrong Type. - TEST_EQ_STR(vec[2].AsString().c_str(), ""); // This still works though. - TEST_EQ_STR(vec[2].ToString().c_str(), "4"); // Or have it converted. - auto tvec = map["bar"].AsTypedVector(); - TEST_EQ(tvec.size(), 3); - TEST_EQ(tvec[2].AsInt8(), 3); - auto tvec3 = map["bar3"].AsFixedTypedVector(); - TEST_EQ(tvec3.size(), 3); - TEST_EQ(tvec3[2].AsInt8(), 3); - TEST_EQ(map["foo"].AsUInt8(), 100); - TEST_EQ(map["unknown"].IsNull(), true); - auto mymap = map["mymap"].AsMap(); - // These should be equal by pointer equality, since key and value are shared. - TEST_EQ(mymap.Keys()[0].AsKey(), map.Keys()[2].AsKey()); - TEST_EQ(mymap.Values()[0].AsString().c_str(), vec[1].AsString().c_str()); - // We can mutate values in the buffer. - TEST_EQ(vec[0].MutateInt(-99), true); - TEST_EQ(vec[0].AsInt64(), -99); - TEST_EQ(vec[1].MutateString("John"), true); // Size must match. - TEST_EQ_STR(vec[1].AsString().c_str(), "John"); - TEST_EQ(vec[1].MutateString("Alfred"), false); // Too long. - TEST_EQ(vec[2].MutateFloat(2.0f), true); - TEST_EQ(vec[2].AsFloat(), 2.0f); - TEST_EQ(vec[2].MutateFloat(3.14159), false); // Double does not fit in float. -} - -int main(int /*argc*/, const char * /*argv*/[]) { - // Run our various test suites: - - std::string rawbuf; - auto flatbuf = CreateFlatBufferTest(rawbuf); - AccessFlatBufferTest(reinterpret_cast<const uint8_t *>(rawbuf.c_str()), - rawbuf.length()); - AccessFlatBufferTest(flatbuf.get(), rawbuf.length()); - - MutateFlatBuffersTest(flatbuf.get(), rawbuf.length()); - - ObjectFlatBuffersTest(flatbuf.get()); - - SizePrefixedTest(); - - #ifndef FLATBUFFERS_NO_FILE_TESTS - ParseAndGenerateTextTest(); - ReflectionTest(flatbuf.get(), rawbuf.length()); - ParseProtoTest(); - UnionVectorTest(); - #endif - - FuzzTest1(); - FuzzTest2(); - - ErrorTest(); - ValueTest(); - EnumStringsTest(); - IntegerOutOfRangeTest(); - IntegerBoundaryTest(); - UnicodeTest(); - UnicodeTestAllowNonUTF8(); - UnicodeTestGenerateTextFailsOnNonUTF8(); - UnicodeSurrogatesTest(); - UnicodeInvalidSurrogatesTest(); - InvalidUTF8Test(); - UnknownFieldsTest(); - ParseUnionTest(); - ConformTest(); - - FlexBuffersTest(); - - if (!testing_fails) { - TEST_OUTPUT_LINE("ALL TESTS PASSED"); - return 0; - } else { - TEST_OUTPUT_LINE("%d FAILED TESTS", testing_fails); - return 1; - } -} -
diff --git a/third_party/flatbuffers/tests/unicode_test.json b/third_party/flatbuffers/tests/unicode_test.json deleted file mode 100644 index 75e467a..0000000 --- a/third_party/flatbuffers/tests/unicode_test.json +++ /dev/null
@@ -1,19 +0,0 @@ -{ - "name": "unicode_test", - "testarrayoftables": [ - { "name": "Цлїςσδε" }, - { "name": "フムアムカモケモ" }, - { "name": "フムヤムカモケモ" }, - { "name": "㊀㊁㊂㊃㊄" }, - { "name": "☳☶☲" }, - { "name": "𡇙𝌆" } - ], - "testarrayofstring": [ - "Цлїςσδε", - "フムアムカモケモ", - "フムヤムカモケモ", - "㊀㊁㊂㊃㊄", - "☳☶☲", - "𡇙𝌆" - ] -}
diff --git a/third_party/flatbuffers/tests/union_vector/union_vector.fbs b/third_party/flatbuffers/tests/union_vector/union_vector.fbs deleted file mode 100644 index 495076f..0000000 --- a/third_party/flatbuffers/tests/union_vector/union_vector.fbs +++ /dev/null
@@ -1,31 +0,0 @@ -// Demonstrates the ability to have vectors of unions, and also to -// store structs and strings in unions. - -table Attacker { - sword_attack_damage: int; -} - -struct Rapunzel { - hair_length: int; -} - -struct BookReader { - books_read: int; -} - -union Character { - MuLan: Attacker, // Can have name be different from type. - Rapunzel, // Or just both the same, as before. - Belle: BookReader, - BookFan: BookReader, - Other: string, - Unused: string -} - -table Movie { - main_character: Character; - characters: [Character]; -} - -root_type Movie; -file_identifier "MOVI";
diff --git a/third_party/flatbuffers/tests/union_vector/union_vector_generated.h b/third_party/flatbuffers/tests/union_vector/union_vector_generated.h deleted file mode 100644 index 104c665..0000000 --- a/third_party/flatbuffers/tests/union_vector/union_vector_generated.h +++ /dev/null
@@ -1,598 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - - -#ifndef FLATBUFFERS_GENERATED_UNIONVECTOR_H_ -#define FLATBUFFERS_GENERATED_UNIONVECTOR_H_ - -#include "flatbuffers/flatbuffers.h" - -struct Attacker; -struct AttackerT; - -struct Rapunzel; - -struct BookReader; - -struct Movie; -struct MovieT; - -enum Character { - Character_NONE = 0, - Character_MuLan = 1, - Character_Rapunzel = 2, - Character_Belle = 3, - Character_BookFan = 4, - Character_Other = 5, - Character_Unused = 6, - Character_MIN = Character_NONE, - Character_MAX = Character_Unused -}; - -inline const char **EnumNamesCharacter() { - static const char *names[] = { - "NONE", - "MuLan", - "Rapunzel", - "Belle", - "BookFan", - "Other", - "Unused", - nullptr - }; - return names; -} - -inline const char *EnumNameCharacter(Character e) { - const size_t index = static_cast<int>(e); - return EnumNamesCharacter()[index]; -} - -struct CharacterUnion { - Character type; - void *value; - - CharacterUnion() : type(Character_NONE), value(nullptr) {} - CharacterUnion(CharacterUnion&& u) FLATBUFFERS_NOEXCEPT : - type(Character_NONE), value(nullptr) - { std::swap(type, u.type); std::swap(value, u.value); } - CharacterUnion(const CharacterUnion &) FLATBUFFERS_NOEXCEPT; - CharacterUnion &operator=(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT - { CharacterUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; } - CharacterUnion &operator=(CharacterUnion &&u) FLATBUFFERS_NOEXCEPT - { std::swap(type, u.type); std::swap(value, u.value); return *this; } - ~CharacterUnion() { Reset(); } - - void Reset(); - - static void *UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver); - flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; - - AttackerT *AsMuLan() { - return type == Character_MuLan ? - reinterpret_cast<AttackerT *>(value) : nullptr; - } - Rapunzel *AsRapunzel() { - return type == Character_Rapunzel ? - reinterpret_cast<Rapunzel *>(value) : nullptr; - } - BookReader *AsBelle() { - return type == Character_Belle ? - reinterpret_cast<BookReader *>(value) : nullptr; - } - BookReader *AsBookFan() { - return type == Character_BookFan ? - reinterpret_cast<BookReader *>(value) : nullptr; - } - std::string *AsOther() { - return type == Character_Other ? - reinterpret_cast<std::string *>(value) : nullptr; - } - std::string *AsUnused() { - return type == Character_Unused ? - reinterpret_cast<std::string *>(value) : nullptr; - } -}; - -bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type); -bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); - -MANUALLY_ALIGNED_STRUCT(4) Rapunzel FLATBUFFERS_FINAL_CLASS { - private: - int32_t hair_length_; - - public: - Rapunzel() { - memset(this, 0, sizeof(Rapunzel)); - } - Rapunzel(const Rapunzel &_o) { - memcpy(this, &_o, sizeof(Rapunzel)); - } - Rapunzel(int32_t _hair_length) - : hair_length_(flatbuffers::EndianScalar(_hair_length)) { - } - int32_t hair_length() const { - return flatbuffers::EndianScalar(hair_length_); - } - void mutate_hair_length(int32_t _hair_length) { - flatbuffers::WriteScalar(&hair_length_, _hair_length); - } -}; -STRUCT_END(Rapunzel, 4); - -MANUALLY_ALIGNED_STRUCT(4) BookReader FLATBUFFERS_FINAL_CLASS { - private: - int32_t books_read_; - - public: - BookReader() { - memset(this, 0, sizeof(BookReader)); - } - BookReader(const BookReader &_o) { - memcpy(this, &_o, sizeof(BookReader)); - } - BookReader(int32_t _books_read) - : books_read_(flatbuffers::EndianScalar(_books_read)) { - } - int32_t books_read() const { - return flatbuffers::EndianScalar(books_read_); - } - void mutate_books_read(int32_t _books_read) { - flatbuffers::WriteScalar(&books_read_, _books_read); - } -}; -STRUCT_END(BookReader, 4); - -struct AttackerT : public flatbuffers::NativeTable { - typedef Attacker TableType; - int32_t sword_attack_damage; - AttackerT() - : sword_attack_damage(0) { - } -}; - -struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef AttackerT NativeTableType; - enum { - VT_SWORD_ATTACK_DAMAGE = 4 - }; - int32_t sword_attack_damage() const { - return GetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, 0); - } - bool mutate_sword_attack_damage(int32_t _sword_attack_damage) { - return SetField<int32_t>(VT_SWORD_ATTACK_DAMAGE, _sword_attack_damage, 0); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<int32_t>(verifier, VT_SWORD_ATTACK_DAMAGE) && - verifier.EndTable(); - } - AttackerT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; - void UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; - static flatbuffers::Offset<Attacker> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); -}; - -struct AttackerBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_sword_attack_damage(int32_t sword_attack_damage) { - fbb_.AddElement<int32_t>(Attacker::VT_SWORD_ATTACK_DAMAGE, sword_attack_damage, 0); - } - AttackerBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - AttackerBuilder &operator=(const AttackerBuilder &); - flatbuffers::Offset<Attacker> Finish() { - const auto end = fbb_.EndTable(start_, 1); - auto o = flatbuffers::Offset<Attacker>(end); - return o; - } -}; - -inline flatbuffers::Offset<Attacker> CreateAttacker( - flatbuffers::FlatBufferBuilder &_fbb, - int32_t sword_attack_damage = 0) { - AttackerBuilder builder_(_fbb); - builder_.add_sword_attack_damage(sword_attack_damage); - return builder_.Finish(); -} - -flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); - -struct MovieT : public flatbuffers::NativeTable { - typedef Movie TableType; - CharacterUnion main_character; - std::vector<CharacterUnion> characters; - MovieT() { - } -}; - -struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef MovieT NativeTableType; - enum { - VT_MAIN_CHARACTER_TYPE = 4, - VT_MAIN_CHARACTER = 6, - VT_CHARACTERS_TYPE = 8, - VT_CHARACTERS = 10 - }; - Character main_character_type() const { - return static_cast<Character>(GetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, 0)); - } - bool mutate_main_character_type(Character _main_character_type) { - return SetField<uint8_t>(VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(_main_character_type), 0); - } - const void *main_character() const { - return GetPointer<const void *>(VT_MAIN_CHARACTER); - } - template<typename T> const T *main_character_as() const; - const Attacker *main_character_as_MuLan() const { - return main_character_type() == Character_MuLan ? static_cast<const Attacker *>(main_character()) : nullptr; - } - const Rapunzel *main_character_as_Rapunzel() const { - return main_character_type() == Character_Rapunzel ? static_cast<const Rapunzel *>(main_character()) : nullptr; - } - const BookReader *main_character_as_Belle() const { - return main_character_type() == Character_Belle ? static_cast<const BookReader *>(main_character()) : nullptr; - } - const BookReader *main_character_as_BookFan() const { - return main_character_type() == Character_BookFan ? static_cast<const BookReader *>(main_character()) : nullptr; - } - const flatbuffers::String *main_character_as_Other() const { - return main_character_type() == Character_Other ? static_cast<const flatbuffers::String *>(main_character()) : nullptr; - } - const flatbuffers::String *main_character_as_Unused() const { - return main_character_type() == Character_Unused ? static_cast<const flatbuffers::String *>(main_character()) : nullptr; - } - void *mutable_main_character() { - return GetPointer<void *>(VT_MAIN_CHARACTER); - } - const flatbuffers::Vector<uint8_t> *characters_type() const { - return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE); - } - flatbuffers::Vector<uint8_t> *mutable_characters_type() { - return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_CHARACTERS_TYPE); - } - const flatbuffers::Vector<flatbuffers::Offset<void>> *characters() const { - return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS); - } - flatbuffers::Vector<flatbuffers::Offset<void>> *mutable_characters() { - return GetPointer<flatbuffers::Vector<flatbuffers::Offset<void>> *>(VT_CHARACTERS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField<uint8_t>(verifier, VT_MAIN_CHARACTER_TYPE) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_MAIN_CHARACTER) && - VerifyCharacter(verifier, main_character(), main_character_type()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_CHARACTERS_TYPE) && - verifier.Verify(characters_type()) && - VerifyField<flatbuffers::uoffset_t>(verifier, VT_CHARACTERS) && - verifier.Verify(characters()) && - VerifyCharacterVector(verifier, characters(), characters_type()) && - verifier.EndTable(); - } - MovieT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; - void UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; - static flatbuffers::Offset<Movie> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); -}; - -struct MovieBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_main_character_type(Character main_character_type) { - fbb_.AddElement<uint8_t>(Movie::VT_MAIN_CHARACTER_TYPE, static_cast<uint8_t>(main_character_type), 0); - } - void add_main_character(flatbuffers::Offset<void> main_character) { - fbb_.AddOffset(Movie::VT_MAIN_CHARACTER, main_character); - } - void add_characters_type(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type) { - fbb_.AddOffset(Movie::VT_CHARACTERS_TYPE, characters_type); - } - void add_characters(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters) { - fbb_.AddOffset(Movie::VT_CHARACTERS, characters); - } - MovieBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - MovieBuilder &operator=(const MovieBuilder &); - flatbuffers::Offset<Movie> Finish() { - const auto end = fbb_.EndTable(start_, 4); - auto o = flatbuffers::Offset<Movie>(end); - return o; - } -}; - -inline flatbuffers::Offset<Movie> CreateMovie( - flatbuffers::FlatBufferBuilder &_fbb, - Character main_character_type = Character_NONE, - flatbuffers::Offset<void> main_character = 0, - flatbuffers::Offset<flatbuffers::Vector<uint8_t>> characters_type = 0, - flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<void>>> characters = 0) { - MovieBuilder builder_(_fbb); - builder_.add_characters(characters); - builder_.add_characters_type(characters_type); - builder_.add_main_character(main_character); - builder_.add_main_character_type(main_character_type); - return builder_.Finish(); -} - -inline flatbuffers::Offset<Movie> CreateMovieDirect( - flatbuffers::FlatBufferBuilder &_fbb, - Character main_character_type = Character_NONE, - flatbuffers::Offset<void> main_character = 0, - const std::vector<uint8_t> *characters_type = nullptr, - const std::vector<flatbuffers::Offset<void>> *characters = nullptr) { - return CreateMovie( - _fbb, - main_character_type, - main_character, - characters_type ? _fbb.CreateVector<uint8_t>(*characters_type) : 0, - characters ? _fbb.CreateVector<flatbuffers::Offset<void>>(*characters) : 0); -} - -flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); - -inline AttackerT *Attacker::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - auto _o = new AttackerT(); - UnPackTo(_o, _resolver); - return _o; -} - -inline void Attacker::UnPackTo(AttackerT *_o, const flatbuffers::resolver_function_t *_resolver) const { - (void)_o; - (void)_resolver; - { auto _e = sword_attack_damage(); _o->sword_attack_damage = _e; }; -} - -inline flatbuffers::Offset<Attacker> Attacker::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT* _o, const flatbuffers::rehasher_function_t *_rehasher) { - return CreateAttacker(_fbb, _o, _rehasher); -} - -inline flatbuffers::Offset<Attacker> CreateAttacker(flatbuffers::FlatBufferBuilder &_fbb, const AttackerT *_o, const flatbuffers::rehasher_function_t *_rehasher) { - (void)_rehasher; - (void)_o; - auto _sword_attack_damage = _o->sword_attack_damage; - return CreateAttacker( - _fbb, - _sword_attack_damage); -} - -inline MovieT *Movie::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - auto _o = new MovieT(); - UnPackTo(_o, _resolver); - return _o; -} - -inline void Movie::UnPackTo(MovieT *_o, const flatbuffers::resolver_function_t *_resolver) const { - (void)_o; - (void)_resolver; - { auto _e = main_character_type(); _o->main_character.type = _e; }; - { auto _e = main_character(); if (_e) _o->main_character.value = CharacterUnion::UnPack(_e, main_character_type(), _resolver); }; - { auto _e = characters_type(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].type = (Character)_e->Get(_i); } } }; - { auto _e = characters(); if (_e) { _o->characters.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->characters[_i].value = CharacterUnion::UnPack(_e->Get(_i), characters_type()->GetEnum<Character>(_i), _resolver); } } }; -} - -inline flatbuffers::Offset<Movie> Movie::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MovieT* _o, const flatbuffers::rehasher_function_t *_rehasher) { - return CreateMovie(_fbb, _o, _rehasher); -} - -inline flatbuffers::Offset<Movie> CreateMovie(flatbuffers::FlatBufferBuilder &_fbb, const MovieT *_o, const flatbuffers::rehasher_function_t *_rehasher) { - (void)_rehasher; - (void)_o; - auto _main_character_type = _o->main_character.type; - auto _main_character = _o->main_character.Pack(_fbb); - auto _characters_type = _o->characters.size() ? _fbb.CreateVector<uint8_t>(_o->characters.size(), [&](size_t i) { return static_cast<uint8_t>(_o->characters[i].type); }) : 0; - auto _characters = _o->characters.size() ? _fbb.CreateVector<flatbuffers::Offset<void>>(_o->characters.size(), [&](size_t i) { return _o->characters[i].Pack(_fbb, _rehasher); }) : 0; - return CreateMovie( - _fbb, - _main_character_type, - _main_character, - _characters_type, - _characters); -} - -inline bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type) { - switch (type) { - case Character_NONE: { - return true; - } - case Character_MuLan: { - auto ptr = reinterpret_cast<const Attacker *>(obj); - return verifier.VerifyTable(ptr); - } - case Character_Rapunzel: { - return true; - } - case Character_Belle: { - return true; - } - case Character_BookFan: { - return true; - } - case Character_Other: { - auto ptr = reinterpret_cast<const flatbuffers::String *>(obj); - return verifier.Verify(ptr); - } - case Character_Unused: { - auto ptr = reinterpret_cast<const flatbuffers::String *>(obj); - return verifier.Verify(ptr); - } - default: return false; - } -} - -inline bool VerifyCharacterVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { - if (values->size() != types->size()) return false; - for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { - if (!VerifyCharacter( - verifier, values->Get(i), types->GetEnum<Character>(i))) { - return false; - } - } - return true; -} - -inline void *CharacterUnion::UnPack(const void *obj, Character type, const flatbuffers::resolver_function_t *resolver) { - switch (type) { - case Character_MuLan: { - auto ptr = reinterpret_cast<const Attacker *>(obj); - return ptr->UnPack(resolver); - } - case Character_Rapunzel: { - auto ptr = reinterpret_cast<const Rapunzel *>(obj); - return new Rapunzel(*ptr); - } - case Character_Belle: { - auto ptr = reinterpret_cast<const BookReader *>(obj); - return new BookReader(*ptr); - } - case Character_BookFan: { - auto ptr = reinterpret_cast<const BookReader *>(obj); - return new BookReader(*ptr); - } - case Character_Other: { - auto ptr = reinterpret_cast<const flatbuffers::String *>(obj); - return new std::string(ptr->c_str(), ptr->size()); - } - case Character_Unused: { - auto ptr = reinterpret_cast<const flatbuffers::String *>(obj); - return new std::string(ptr->c_str(), ptr->size()); - } - default: return nullptr; - } -} - -inline flatbuffers::Offset<void> CharacterUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { - switch (type) { - case Character_MuLan: { - auto ptr = reinterpret_cast<const AttackerT *>(value); - return CreateAttacker(_fbb, ptr, _rehasher).Union(); - } - case Character_Rapunzel: { - auto ptr = reinterpret_cast<const Rapunzel *>(value); - return _fbb.CreateStruct(*ptr).Union(); - } - case Character_Belle: { - auto ptr = reinterpret_cast<const BookReader *>(value); - return _fbb.CreateStruct(*ptr).Union(); - } - case Character_BookFan: { - auto ptr = reinterpret_cast<const BookReader *>(value); - return _fbb.CreateStruct(*ptr).Union(); - } - case Character_Other: { - auto ptr = reinterpret_cast<const std::string *>(value); - return _fbb.CreateString(*ptr).Union(); - } - case Character_Unused: { - auto ptr = reinterpret_cast<const std::string *>(value); - return _fbb.CreateString(*ptr).Union(); - } - default: return 0; - } -} - -inline CharacterUnion::CharacterUnion(const CharacterUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) { - switch (type) { - case Character_MuLan: { - value = new AttackerT(*reinterpret_cast<AttackerT *>(u.value)); - break; - } - case Character_Rapunzel: { - value = new Rapunzel(*reinterpret_cast<Rapunzel *>(u.value)); - break; - } - case Character_Belle: { - value = new BookReader(*reinterpret_cast<BookReader *>(u.value)); - break; - } - case Character_BookFan: { - value = new BookReader(*reinterpret_cast<BookReader *>(u.value)); - break; - } - case Character_Other: { - value = new std::string(*reinterpret_cast<std::string *>(u.value)); - break; - } - case Character_Unused: { - value = new std::string(*reinterpret_cast<std::string *>(u.value)); - break; - } - default: - break; - } -} - -inline void CharacterUnion::Reset() { - switch (type) { - case Character_MuLan: { - auto ptr = reinterpret_cast<AttackerT *>(value); - delete ptr; - break; - } - case Character_Rapunzel: { - auto ptr = reinterpret_cast<Rapunzel *>(value); - delete ptr; - break; - } - case Character_Belle: { - auto ptr = reinterpret_cast<BookReader *>(value); - delete ptr; - break; - } - case Character_BookFan: { - auto ptr = reinterpret_cast<BookReader *>(value); - delete ptr; - break; - } - case Character_Other: { - auto ptr = reinterpret_cast<std::string *>(value); - delete ptr; - break; - } - case Character_Unused: { - auto ptr = reinterpret_cast<std::string *>(value); - delete ptr; - break; - } - default: break; - } - value = nullptr; - type = Character_NONE; -} - -inline const Movie *GetMovie(const void *buf) { - return flatbuffers::GetRoot<Movie>(buf); -} - -inline Movie *GetMutableMovie(void *buf) { - return flatbuffers::GetMutableRoot<Movie>(buf); -} - -inline const char *MovieIdentifier() { - return "MOVI"; -} - -inline bool MovieBufferHasIdentifier(const void *buf) { - return flatbuffers::BufferHasIdentifier( - buf, MovieIdentifier()); -} - -inline bool VerifyMovieBuffer( - flatbuffers::Verifier &verifier) { - return verifier.VerifyBuffer<Movie>(MovieIdentifier()); -} - -inline void FinishMovieBuffer( - flatbuffers::FlatBufferBuilder &fbb, - flatbuffers::Offset<Movie> root) { - fbb.Finish(root, MovieIdentifier()); -} - -inline std::unique_ptr<MovieT> UnPackMovie( - const void *buf, - const flatbuffers::resolver_function_t *res = nullptr) { - return std::unique_ptr<MovieT>(GetMovie(buf)->UnPack(res)); -} - -#endif // FLATBUFFERS_GENERATED_UNIONVECTOR_H_