xmos-ai-tools 1.3.2.dev80__py3-none-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xmos_ai_tools/__init__.py +7 -0
- xmos_ai_tools/io_server/__init__.py +151 -0
- xmos_ai_tools/runtime/__init__.py +0 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.cmake +13 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.make +8 -0
- xmos_ai_tools/runtime/include/flash_server.h +74 -0
- xmos_ai_tools/runtime/include/flatbuffers/allocator.h +68 -0
- xmos_ai_tools/runtime/include/flatbuffers/array.h +243 -0
- xmos_ai_tools/runtime/include/flatbuffers/base.h +474 -0
- xmos_ai_tools/runtime/include/flatbuffers/bfbs_generator.h +43 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer.h +142 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer_ref.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/code_generators.h +235 -0
- xmos_ai_tools/runtime/include/flatbuffers/default_allocator.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/detached_buffer.h +114 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffer_builder.h +1197 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffers.h +270 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatc.h +111 -0
- xmos_ai_tools/runtime/include/flatbuffers/flexbuffers.h +1897 -0
- xmos_ai_tools/runtime/include/flatbuffers/grpc.h +300 -0
- xmos_ai_tools/runtime/include/flatbuffers/hash.h +127 -0
- xmos_ai_tools/runtime/include/flatbuffers/idl.h +1232 -0
- xmos_ai_tools/runtime/include/flatbuffers/minireflect.h +419 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/flatc_pch.h +39 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/pch.h +38 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection.h +502 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection_generated.h +1449 -0
- xmos_ai_tools/runtime/include/flatbuffers/registry.h +128 -0
- xmos_ai_tools/runtime/include/flatbuffers/stl_emulation.h +509 -0
- xmos_ai_tools/runtime/include/flatbuffers/string.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/struct.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/table.h +168 -0
- xmos_ai_tools/runtime/include/flatbuffers/util.h +690 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector.h +370 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector_downward.h +271 -0
- xmos_ai_tools/runtime/include/flatbuffers/verifier.h +283 -0
- xmos_ai_tools/runtime/include/ioserver.h +44 -0
- xmos_ai_tools/runtime/include/lib_nn/api/TransposeConv.h +24 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16.h +27 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16_transform.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16_transform.h +34 -0
- xmos_ai_tools/runtime/include/lib_nn/api/expand_8_to_16.h +8 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16_transform.h +71 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_api.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_bin_types.h +14 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_config.h +287 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_conv2d_structs.h +72 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_image.h +26 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +303 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_helper.h +132 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_utils.h +150 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_operator.h +18 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_pooling.h +551 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_types.h +83 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_window_params.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16.h +54 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_kernel_transform.h +37 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_mappings.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +82 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16_transform.h +33 -0
- xmos_ai_tools/runtime/include/lib_nn/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memmove_word_aligned.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memset_256.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_sim.h +118 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3_vpu.h +216 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3a_registers.h +2869 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/asm_constants.h +41 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/window_op_plan.h +25 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/fast_flash.h +47 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/memory_parallel_transport.h +52 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_config.h +17 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_device_memory.h +62 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_shared_config.h +31 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/conv2d_float.h +155 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_common.h +19 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_custom_options.h +28 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_error_reporter.h +32 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_interpreter.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +71 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_profiler.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h +160 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/thread_call.h +119 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_defs.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_device.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_descriptors.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_requests.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud.h +518 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_conf_default.h +11 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_device.h +87 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_descriptors.h +191 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_requests.h +120 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/XUD_USB_Defines.h +70 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/hid.h +23 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio10.h +30 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio20.h +357 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudiocommon.h +168 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/delay_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/irfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
- xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
- xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_square_root.h +34 -0
- xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/log.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/max_abs.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/msb.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
- xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
- xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
- xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/window.h +31 -0
- xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_op_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/builtin_op_data.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/context_util.h +54 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +72 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +440 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/tensor_utils.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +626 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +178 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +1496 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/bits.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_util.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_io.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_io.h +31 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_util.h +52 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_lut.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_io.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h +46 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_io.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_util.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +1358 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/compatibility.h +122 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/max.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/min.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/optimized/neon_check.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor_utils.h +623 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/quantization_util.h +292 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +561 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add_n.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/arg_min_max.h +88 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_matmul.h +275 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h +101 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/binary_function.h +91 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_args.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_to.h +97 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/ceil.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +271 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/concatenation.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +289 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/cumsum.h +175 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depth_to_space.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h +319 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/dequantize.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/div.h +247 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/elu.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/exp.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fill.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_div.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_mod.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fully_connected.h +323 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/hard_swish.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +250 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h +291 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h +126 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h +121 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +18 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +194 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h +264 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h +224 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/l2normalization.h +90 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/leaky_relu.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/log_softmax.h +256 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/logistic.h +132 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/lstm_cell.h +422 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/maximum_minimum.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/neg.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pad.h +169 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pooling.h +303 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h +333 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h +244 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/prelu.h +111 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/quantize.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +491 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/requantize.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/round.h +51 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/select.h +151 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/slice.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/softmax.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h +109 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_depth.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/strided_slice.h +147 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +465 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/tanh.h +129 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose.h +203 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose_conv.h +225 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +278 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +1096 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +341 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/padding.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.h +104 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h +144 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/benchmarks/micro_benchmark.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/compatibility.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/expected_output_data.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/input_data.h +108 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/network_model.h +166 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/detection_responder.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/image_provider.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/main_functions.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/model_settings.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/flatbuffer_utils.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activation_utils.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activations.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_interface.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_slicers.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_tf_utils.h +310 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buf_mgr.h +145 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buffers.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_common.h +24 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_tflm_lib.h +613 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/mcps_macros.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/types.h +1286 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +94 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/dequantize.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +112 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/hard_swish.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/leaky_relu.h +43 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logical.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logistic.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval.h +541 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval_test.h +817 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_shared.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +158 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_tensor_utils.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pad.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +142 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/prelu.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/quantize.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/sub.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/conv_test_data.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/lstm_test_data.h +579 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h +139 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_eval.h +216 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_shared.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_add.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_fully_connected.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pad.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pooling.h +76 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reduce.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_helpers.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +170 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +53 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/memory_plan_struct.h +73 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +133 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocation_info.h +138 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +351 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_arena_constants.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +176 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +189 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +708 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +62 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler_interface.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_resource_variable.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_time.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_utils.h +162 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size_wrapper.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_allocator.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_interpreter.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/system_setup.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +334 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/test_conv_model.h +23 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/portable_type_to_tflitetype.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +24644 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_utils.h +33 -0
- xmos_ai_tools/runtime/include/tile_ram_server.h +38 -0
- xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
- xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
- xmos_ai_tools/xformer/__init__.py +60 -0
- xmos_ai_tools/xformer/flash.py +190 -0
- xmos_ai_tools/xinterpreters/__init__.py +1 -0
- xmos_ai_tools/xinterpreters/exceptions.py +38 -0
- xmos_ai_tools/xinterpreters/host_interpreter.py +652 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
- xmos_ai_tools-1.3.2.dev80.data/data/bin/xcore-opt +0 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/METADATA +33 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/RECORD +395 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/WHEEL +5 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1232 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2014 Google Inc. All rights reserved.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#ifndef FLATBUFFERS_IDL_H_
|
18
|
+
#define FLATBUFFERS_IDL_H_
|
19
|
+
|
20
|
+
#include <functional>
|
21
|
+
#include <map>
|
22
|
+
#include <memory>
|
23
|
+
#include <stack>
|
24
|
+
|
25
|
+
#include "flatbuffers/base.h"
|
26
|
+
#include "flatbuffers/flatbuffers.h"
|
27
|
+
#include "flatbuffers/flexbuffers.h"
|
28
|
+
#include "flatbuffers/hash.h"
|
29
|
+
#include "flatbuffers/reflection.h"
|
30
|
+
|
31
|
+
// This file defines the data types representing a parsed IDL (Interface
|
32
|
+
// Definition Language) / schema file.
|
33
|
+
|
34
|
+
// Limits maximum depth of nested objects.
|
35
|
+
// Prevents stack overflow while parse scheme, or json, or flexbuffer.
|
36
|
+
#if !defined(FLATBUFFERS_MAX_PARSING_DEPTH)
|
37
|
+
# define FLATBUFFERS_MAX_PARSING_DEPTH 64
|
38
|
+
#endif
|
39
|
+
|
40
|
+
namespace flatbuffers {
|
41
|
+
|
42
|
+
// The order of these matters for Is*() functions below.
|
43
|
+
// Additionally, Parser::ParseType assumes bool..string is a contiguous range
|
44
|
+
// of type tokens.
|
45
|
+
// clang-format off
|
46
|
+
#define FLATBUFFERS_GEN_TYPES_SCALAR(TD) \
|
47
|
+
TD(NONE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) \
|
48
|
+
TD(UTYPE, "", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) /* begin scalar/int */ \
|
49
|
+
TD(BOOL, "bool", uint8_t, boolean,bool, bool, bool, bool, Boolean, Bool) \
|
50
|
+
TD(CHAR, "byte", int8_t, byte, int8, sbyte, int8, i8, Byte, Int8) \
|
51
|
+
TD(UCHAR, "ubyte", uint8_t, byte, byte, byte, uint8, u8, UByte, UInt8) \
|
52
|
+
TD(SHORT, "short", int16_t, short, int16, short, int16, i16, Short, Int16) \
|
53
|
+
TD(USHORT, "ushort", uint16_t, short, uint16, ushort, uint16, u16, UShort, UInt16) \
|
54
|
+
TD(INT, "int", int32_t, int, int32, int, int32, i32, Int, Int32) \
|
55
|
+
TD(UINT, "uint", uint32_t, int, uint32, uint, uint32, u32, UInt, UInt32) \
|
56
|
+
TD(LONG, "long", int64_t, long, int64, long, int64, i64, Long, Int64) \
|
57
|
+
TD(ULONG, "ulong", uint64_t, long, uint64, ulong, uint64, u64, ULong, UInt64) /* end int */ \
|
58
|
+
TD(FLOAT, "float", float, float, float32, float, float32, f32, Float, Float32) /* begin float */ \
|
59
|
+
TD(DOUBLE, "double", double, double, float64, double, float64, f64, Double, Double) /* end float/scalar */
|
60
|
+
#define FLATBUFFERS_GEN_TYPES_POINTER(TD) \
|
61
|
+
TD(STRING, "string", Offset<void>, int, int, StringOffset, int, unused, Int, Offset<String>) \
|
62
|
+
TD(VECTOR, "", Offset<void>, int, int, VectorOffset, int, unused, Int, Offset<UOffset>) \
|
63
|
+
TD(STRUCT, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>) \
|
64
|
+
TD(UNION, "", Offset<void>, int, int, int, int, unused, Int, Offset<UOffset>)
|
65
|
+
#define FLATBUFFERS_GEN_TYPE_ARRAY(TD) \
|
66
|
+
TD(ARRAY, "", int, int, int, int, int, unused, Int, Offset<UOffset>)
|
67
|
+
// The fields are:
|
68
|
+
// - enum
|
69
|
+
// - FlatBuffers schema type.
|
70
|
+
// - C++ type.
|
71
|
+
// - Java type.
|
72
|
+
// - Go type.
|
73
|
+
// - C# / .Net type.
|
74
|
+
// - Python type.
|
75
|
+
// - Kotlin type.
|
76
|
+
// - Rust type.
|
77
|
+
|
78
|
+
// using these macros, we can now write code dealing with types just once, e.g.
|
79
|
+
|
80
|
+
/*
|
81
|
+
switch (type) {
|
82
|
+
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
|
83
|
+
RTYPE, KTYPE) \
|
84
|
+
case BASE_TYPE_ ## ENUM: \
|
85
|
+
// do something specific to CTYPE here
|
86
|
+
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
87
|
+
#undef FLATBUFFERS_TD
|
88
|
+
}
|
89
|
+
*/
|
90
|
+
|
91
|
+
// If not all FLATBUFFERS_GEN_() arguments are necessary for implementation
|
92
|
+
// of FLATBUFFERS_TD, you can use a variadic macro (with __VA_ARGS__ if needed).
|
93
|
+
// In the above example, only CTYPE is used to generate the code, it can be rewritten:
|
94
|
+
|
95
|
+
/*
|
96
|
+
switch (type) {
|
97
|
+
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
|
98
|
+
case BASE_TYPE_ ## ENUM: \
|
99
|
+
// do something specific to CTYPE here
|
100
|
+
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
101
|
+
#undef FLATBUFFERS_TD
|
102
|
+
}
|
103
|
+
*/
|
104
|
+
|
105
|
+
#define FLATBUFFERS_GEN_TYPES(TD) \
|
106
|
+
FLATBUFFERS_GEN_TYPES_SCALAR(TD) \
|
107
|
+
FLATBUFFERS_GEN_TYPES_POINTER(TD) \
|
108
|
+
FLATBUFFERS_GEN_TYPE_ARRAY(TD)
|
109
|
+
|
110
|
+
// Create an enum for all the types above.
|
111
|
+
#ifdef __GNUC__
|
112
|
+
__extension__ // Stop GCC complaining about trailing comma with -Wpendantic.
|
113
|
+
#endif
|
114
|
+
enum BaseType {
|
115
|
+
#define FLATBUFFERS_TD(ENUM, ...) \
|
116
|
+
BASE_TYPE_ ## ENUM,
|
117
|
+
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
118
|
+
#undef FLATBUFFERS_TD
|
119
|
+
};
|
120
|
+
|
121
|
+
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
|
122
|
+
static_assert(sizeof(CTYPE) <= sizeof(largest_scalar_t), \
|
123
|
+
"define largest_scalar_t as " #CTYPE);
|
124
|
+
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
|
125
|
+
#undef FLATBUFFERS_TD
|
126
|
+
|
127
|
+
inline bool IsScalar (BaseType t) { return t >= BASE_TYPE_UTYPE &&
|
128
|
+
t <= BASE_TYPE_DOUBLE; }
|
129
|
+
inline bool IsInteger(BaseType t) { return t >= BASE_TYPE_UTYPE &&
|
130
|
+
t <= BASE_TYPE_ULONG; }
|
131
|
+
inline bool IsFloat (BaseType t) { return t == BASE_TYPE_FLOAT ||
|
132
|
+
t == BASE_TYPE_DOUBLE; }
|
133
|
+
inline bool IsLong (BaseType t) { return t == BASE_TYPE_LONG ||
|
134
|
+
t == BASE_TYPE_ULONG; }
|
135
|
+
inline bool IsBool (BaseType t) { return t == BASE_TYPE_BOOL; }
|
136
|
+
inline bool IsOneByte(BaseType t) { return t >= BASE_TYPE_UTYPE &&
|
137
|
+
t <= BASE_TYPE_UCHAR; }
|
138
|
+
|
139
|
+
inline bool IsUnsigned(BaseType t) {
|
140
|
+
return (t == BASE_TYPE_UTYPE) || (t == BASE_TYPE_UCHAR) ||
|
141
|
+
(t == BASE_TYPE_USHORT) || (t == BASE_TYPE_UINT) ||
|
142
|
+
(t == BASE_TYPE_ULONG);
|
143
|
+
}
|
144
|
+
|
145
|
+
// clang-format on
|
146
|
+
|
147
|
+
extern const char *const kTypeNames[];
|
148
|
+
extern const char kTypeSizes[];
|
149
|
+
|
150
|
+
inline size_t SizeOf(BaseType t) { return kTypeSizes[t]; }
|
151
|
+
|
152
|
+
struct StructDef;
|
153
|
+
struct EnumDef;
|
154
|
+
class Parser;
|
155
|
+
|
156
|
+
// Represents any type in the IDL, which is a combination of the BaseType
|
157
|
+
// and additional information for vectors/structs_.
|
158
|
+
struct Type {
|
159
|
+
explicit Type(BaseType _base_type = BASE_TYPE_NONE, StructDef *_sd = nullptr,
|
160
|
+
EnumDef *_ed = nullptr, uint16_t _fixed_length = 0)
|
161
|
+
: base_type(_base_type),
|
162
|
+
element(BASE_TYPE_NONE),
|
163
|
+
struct_def(_sd),
|
164
|
+
enum_def(_ed),
|
165
|
+
fixed_length(_fixed_length) {}
|
166
|
+
|
167
|
+
bool operator==(const Type &o) {
|
168
|
+
return base_type == o.base_type && element == o.element &&
|
169
|
+
struct_def == o.struct_def && enum_def == o.enum_def;
|
170
|
+
}
|
171
|
+
|
172
|
+
Type VectorType() const {
|
173
|
+
return Type(element, struct_def, enum_def, fixed_length);
|
174
|
+
}
|
175
|
+
|
176
|
+
Offset<reflection::Type> Serialize(FlatBufferBuilder *builder) const;
|
177
|
+
|
178
|
+
bool Deserialize(const Parser &parser, const reflection::Type *type);
|
179
|
+
|
180
|
+
BaseType base_type;
|
181
|
+
BaseType element; // only set if t == BASE_TYPE_VECTOR
|
182
|
+
StructDef *struct_def; // only set if t or element == BASE_TYPE_STRUCT
|
183
|
+
EnumDef *enum_def; // set if t == BASE_TYPE_UNION / BASE_TYPE_UTYPE,
|
184
|
+
// or for an integral type derived from an enum.
|
185
|
+
uint16_t fixed_length; // only set if t == BASE_TYPE_ARRAY
|
186
|
+
};
|
187
|
+
|
188
|
+
// Represents a parsed scalar value, it's type, and field offset.
|
189
|
+
struct Value {
|
190
|
+
Value()
|
191
|
+
: constant("0"),
|
192
|
+
offset(static_cast<voffset_t>(~(static_cast<voffset_t>(0U)))) {}
|
193
|
+
Type type;
|
194
|
+
std::string constant;
|
195
|
+
voffset_t offset;
|
196
|
+
};
|
197
|
+
|
198
|
+
// Helper class that retains the original order of a set of identifiers and
|
199
|
+
// also provides quick lookup.
|
200
|
+
template<typename T> class SymbolTable {
|
201
|
+
public:
|
202
|
+
~SymbolTable() {
|
203
|
+
for (auto it = vec.begin(); it != vec.end(); ++it) { delete *it; }
|
204
|
+
}
|
205
|
+
|
206
|
+
bool Add(const std::string &name, T *e) {
|
207
|
+
vec.emplace_back(e);
|
208
|
+
auto it = dict.find(name);
|
209
|
+
if (it != dict.end()) return true;
|
210
|
+
dict[name] = e;
|
211
|
+
return false;
|
212
|
+
}
|
213
|
+
|
214
|
+
void Move(const std::string &oldname, const std::string &newname) {
|
215
|
+
auto it = dict.find(oldname);
|
216
|
+
if (it != dict.end()) {
|
217
|
+
auto obj = it->second;
|
218
|
+
dict.erase(it);
|
219
|
+
dict[newname] = obj;
|
220
|
+
} else {
|
221
|
+
FLATBUFFERS_ASSERT(false);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
T *Lookup(const std::string &name) const {
|
226
|
+
auto it = dict.find(name);
|
227
|
+
return it == dict.end() ? nullptr : it->second;
|
228
|
+
}
|
229
|
+
|
230
|
+
public:
|
231
|
+
std::map<std::string, T *> dict; // quick lookup
|
232
|
+
std::vector<T *> vec; // Used to iterate in order of insertion
|
233
|
+
};
|
234
|
+
|
235
|
+
// A name space, as set in the schema.
|
236
|
+
struct Namespace {
|
237
|
+
Namespace() : from_table(0) {}
|
238
|
+
|
239
|
+
// Given a (potentially unqualified) name, return the "fully qualified" name
|
240
|
+
// which has a full namespaced descriptor.
|
241
|
+
// With max_components you can request less than the number of components
|
242
|
+
// the current namespace has.
|
243
|
+
std::string GetFullyQualifiedName(const std::string &name,
|
244
|
+
size_t max_components = 1000) const;
|
245
|
+
|
246
|
+
std::vector<std::string> components;
|
247
|
+
size_t from_table; // Part of the namespace corresponds to a message/table.
|
248
|
+
};
|
249
|
+
|
250
|
+
inline bool operator<(const Namespace &a, const Namespace &b) {
|
251
|
+
size_t min_size = std::min(a.components.size(), b.components.size());
|
252
|
+
for (size_t i = 0; i < min_size; ++i) {
|
253
|
+
if (a.components[i] != b.components[i])
|
254
|
+
return a.components[i] < b.components[i];
|
255
|
+
}
|
256
|
+
return a.components.size() < b.components.size();
|
257
|
+
}
|
258
|
+
|
259
|
+
// Base class for all definition types (fields, structs_, enums_).
|
260
|
+
struct Definition {
|
261
|
+
Definition()
|
262
|
+
: generated(false),
|
263
|
+
defined_namespace(nullptr),
|
264
|
+
serialized_location(0),
|
265
|
+
index(-1),
|
266
|
+
refcount(1),
|
267
|
+
declaration_file(nullptr) {}
|
268
|
+
|
269
|
+
flatbuffers::Offset<
|
270
|
+
flatbuffers::Vector<flatbuffers::Offset<reflection::KeyValue>>>
|
271
|
+
SerializeAttributes(FlatBufferBuilder *builder, const Parser &parser) const;
|
272
|
+
|
273
|
+
bool DeserializeAttributes(Parser &parser,
|
274
|
+
const Vector<Offset<reflection::KeyValue>> *attrs);
|
275
|
+
|
276
|
+
std::string name;
|
277
|
+
std::string file;
|
278
|
+
std::vector<std::string> doc_comment;
|
279
|
+
SymbolTable<Value> attributes;
|
280
|
+
bool generated; // did we already output code for this definition?
|
281
|
+
Namespace *defined_namespace; // Where it was defined.
|
282
|
+
|
283
|
+
// For use with Serialize()
|
284
|
+
uoffset_t serialized_location;
|
285
|
+
int index; // Inside the vector it is stored.
|
286
|
+
int refcount;
|
287
|
+
const std::string *declaration_file;
|
288
|
+
};
|
289
|
+
|
290
|
+
struct FieldDef : public Definition {
|
291
|
+
FieldDef()
|
292
|
+
: deprecated(false),
|
293
|
+
key(false),
|
294
|
+
shared(false),
|
295
|
+
native_inline(false),
|
296
|
+
flexbuffer(false),
|
297
|
+
presence(kDefault),
|
298
|
+
nested_flatbuffer(NULL),
|
299
|
+
padding(0) {}
|
300
|
+
|
301
|
+
Offset<reflection::Field> Serialize(FlatBufferBuilder *builder, uint16_t id,
|
302
|
+
const Parser &parser) const;
|
303
|
+
|
304
|
+
bool Deserialize(Parser &parser, const reflection::Field *field);
|
305
|
+
|
306
|
+
bool IsScalarOptional() const {
|
307
|
+
return IsScalar(value.type.base_type) && IsOptional();
|
308
|
+
}
|
309
|
+
bool IsOptional() const { return presence == kOptional; }
|
310
|
+
bool IsRequired() const { return presence == kRequired; }
|
311
|
+
bool IsDefault() const { return presence == kDefault; }
|
312
|
+
|
313
|
+
Value value;
|
314
|
+
bool deprecated; // Field is allowed to be present in old data, but can't be.
|
315
|
+
// written in new data nor accessed in new code.
|
316
|
+
bool key; // Field functions as a key for creating sorted vectors.
|
317
|
+
bool shared; // Field will be using string pooling (i.e. CreateSharedString)
|
318
|
+
// as default serialization behavior if field is a string.
|
319
|
+
bool native_inline; // Field will be defined inline (instead of as a pointer)
|
320
|
+
// for native tables if field is a struct.
|
321
|
+
bool flexbuffer; // This field contains FlexBuffer data.
|
322
|
+
|
323
|
+
enum Presence {
|
324
|
+
// Field must always be present.
|
325
|
+
kRequired,
|
326
|
+
// Non-presence should be signalled to and controlled by users.
|
327
|
+
kOptional,
|
328
|
+
// Non-presence is hidden from users.
|
329
|
+
// Implementations may omit writing default values.
|
330
|
+
kDefault,
|
331
|
+
};
|
332
|
+
Presence static MakeFieldPresence(bool optional, bool required) {
|
333
|
+
FLATBUFFERS_ASSERT(!(required && optional));
|
334
|
+
// clang-format off
|
335
|
+
return required ? FieldDef::kRequired
|
336
|
+
: optional ? FieldDef::kOptional
|
337
|
+
: FieldDef::kDefault;
|
338
|
+
// clang-format on
|
339
|
+
}
|
340
|
+
Presence presence;
|
341
|
+
|
342
|
+
StructDef *nested_flatbuffer; // This field contains nested FlatBuffer data.
|
343
|
+
size_t padding; // Bytes to always pad after this field.
|
344
|
+
};
|
345
|
+
|
346
|
+
struct StructDef : public Definition {
|
347
|
+
StructDef()
|
348
|
+
: fixed(false),
|
349
|
+
predecl(true),
|
350
|
+
sortbysize(true),
|
351
|
+
has_key(false),
|
352
|
+
minalign(1),
|
353
|
+
bytesize(0) {}
|
354
|
+
|
355
|
+
void PadLastField(size_t min_align) {
|
356
|
+
auto padding = PaddingBytes(bytesize, min_align);
|
357
|
+
bytesize += padding;
|
358
|
+
if (fields.vec.size()) fields.vec.back()->padding = padding;
|
359
|
+
}
|
360
|
+
|
361
|
+
Offset<reflection::Object> Serialize(FlatBufferBuilder *builder,
|
362
|
+
const Parser &parser) const;
|
363
|
+
|
364
|
+
bool Deserialize(Parser &parser, const reflection::Object *object);
|
365
|
+
|
366
|
+
SymbolTable<FieldDef> fields;
|
367
|
+
|
368
|
+
bool fixed; // If it's struct, not a table.
|
369
|
+
bool predecl; // If it's used before it was defined.
|
370
|
+
bool sortbysize; // Whether fields come in the declaration or size order.
|
371
|
+
bool has_key; // It has a key field.
|
372
|
+
size_t minalign; // What the whole object needs to be aligned to.
|
373
|
+
size_t bytesize; // Size if fixed.
|
374
|
+
|
375
|
+
flatbuffers::unique_ptr<std::string> original_location;
|
376
|
+
};
|
377
|
+
|
378
|
+
struct EnumDef;
|
379
|
+
struct EnumValBuilder;
|
380
|
+
|
381
|
+
struct EnumVal {
|
382
|
+
Offset<reflection::EnumVal> Serialize(FlatBufferBuilder *builder,
|
383
|
+
const Parser &parser) const;
|
384
|
+
|
385
|
+
bool Deserialize(const Parser &parser, const reflection::EnumVal *val);
|
386
|
+
|
387
|
+
uint64_t GetAsUInt64() const { return static_cast<uint64_t>(value); }
|
388
|
+
int64_t GetAsInt64() const { return value; }
|
389
|
+
bool IsZero() const { return 0 == value; }
|
390
|
+
bool IsNonZero() const { return !IsZero(); }
|
391
|
+
|
392
|
+
std::string name;
|
393
|
+
std::vector<std::string> doc_comment;
|
394
|
+
Type union_type;
|
395
|
+
|
396
|
+
private:
|
397
|
+
friend EnumDef;
|
398
|
+
friend EnumValBuilder;
|
399
|
+
friend bool operator==(const EnumVal &lhs, const EnumVal &rhs);
|
400
|
+
|
401
|
+
EnumVal(const std::string &_name, int64_t _val) : name(_name), value(_val) {}
|
402
|
+
EnumVal() : value(0) {}
|
403
|
+
|
404
|
+
int64_t value;
|
405
|
+
};
|
406
|
+
|
407
|
+
struct EnumDef : public Definition {
|
408
|
+
EnumDef() : is_union(false), uses_multiple_type_instances(false) {}
|
409
|
+
|
410
|
+
Offset<reflection::Enum> Serialize(FlatBufferBuilder *builder,
|
411
|
+
const Parser &parser) const;
|
412
|
+
|
413
|
+
bool Deserialize(Parser &parser, const reflection::Enum *values);
|
414
|
+
|
415
|
+
template<typename T> void ChangeEnumValue(EnumVal *ev, T new_val);
|
416
|
+
void SortByValue();
|
417
|
+
void RemoveDuplicates();
|
418
|
+
|
419
|
+
std::string AllFlags() const;
|
420
|
+
const EnumVal *MinValue() const;
|
421
|
+
const EnumVal *MaxValue() const;
|
422
|
+
// Returns the number of integer steps from v1 to v2.
|
423
|
+
uint64_t Distance(const EnumVal *v1, const EnumVal *v2) const;
|
424
|
+
// Returns the number of integer steps from Min to Max.
|
425
|
+
uint64_t Distance() const { return Distance(MinValue(), MaxValue()); }
|
426
|
+
|
427
|
+
EnumVal *ReverseLookup(int64_t enum_idx,
|
428
|
+
bool skip_union_default = false) const;
|
429
|
+
EnumVal *FindByValue(const std::string &constant) const;
|
430
|
+
|
431
|
+
std::string ToString(const EnumVal &ev) const {
|
432
|
+
return IsUInt64() ? NumToString(ev.GetAsUInt64())
|
433
|
+
: NumToString(ev.GetAsInt64());
|
434
|
+
}
|
435
|
+
|
436
|
+
size_t size() const { return vals.vec.size(); }
|
437
|
+
|
438
|
+
const std::vector<EnumVal *> &Vals() const { return vals.vec; }
|
439
|
+
|
440
|
+
const EnumVal *Lookup(const std::string &enum_name) const {
|
441
|
+
return vals.Lookup(enum_name);
|
442
|
+
}
|
443
|
+
|
444
|
+
bool is_union;
|
445
|
+
// Type is a union which uses type aliases where at least one type is
|
446
|
+
// available under two different names.
|
447
|
+
bool uses_multiple_type_instances;
|
448
|
+
Type underlying_type;
|
449
|
+
|
450
|
+
private:
|
451
|
+
bool IsUInt64() const {
|
452
|
+
return (BASE_TYPE_ULONG == underlying_type.base_type);
|
453
|
+
}
|
454
|
+
|
455
|
+
friend EnumValBuilder;
|
456
|
+
SymbolTable<EnumVal> vals;
|
457
|
+
};
|
458
|
+
|
459
|
+
inline bool IsString(const Type &type) {
|
460
|
+
return type.base_type == BASE_TYPE_STRING;
|
461
|
+
}
|
462
|
+
|
463
|
+
inline bool IsStruct(const Type &type) {
|
464
|
+
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
|
465
|
+
}
|
466
|
+
|
467
|
+
inline bool IsUnion(const Type &type) {
|
468
|
+
return type.enum_def != nullptr && type.enum_def->is_union;
|
469
|
+
}
|
470
|
+
|
471
|
+
inline bool IsUnionType(const Type &type) {
|
472
|
+
return IsUnion(type) && IsInteger(type.base_type);
|
473
|
+
}
|
474
|
+
|
475
|
+
inline bool IsVector(const Type &type) {
|
476
|
+
return type.base_type == BASE_TYPE_VECTOR;
|
477
|
+
}
|
478
|
+
|
479
|
+
inline bool IsArray(const Type &type) {
|
480
|
+
return type.base_type == BASE_TYPE_ARRAY;
|
481
|
+
}
|
482
|
+
|
483
|
+
inline bool IsSeries(const Type &type) {
|
484
|
+
return IsVector(type) || IsArray(type);
|
485
|
+
}
|
486
|
+
|
487
|
+
inline bool IsEnum(const Type &type) {
|
488
|
+
return type.enum_def != nullptr && IsInteger(type.base_type);
|
489
|
+
}
|
490
|
+
|
491
|
+
inline size_t InlineSize(const Type &type) {
|
492
|
+
return IsStruct(type)
|
493
|
+
? type.struct_def->bytesize
|
494
|
+
: (IsArray(type)
|
495
|
+
? InlineSize(type.VectorType()) * type.fixed_length
|
496
|
+
: SizeOf(type.base_type));
|
497
|
+
}
|
498
|
+
|
499
|
+
inline size_t InlineAlignment(const Type &type) {
|
500
|
+
if (IsStruct(type)) {
|
501
|
+
return type.struct_def->minalign;
|
502
|
+
} else if (IsArray(type)) {
|
503
|
+
return IsStruct(type.VectorType()) ? type.struct_def->minalign
|
504
|
+
: SizeOf(type.element);
|
505
|
+
} else {
|
506
|
+
return SizeOf(type.base_type);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
inline bool operator==(const EnumVal &lhs, const EnumVal &rhs) {
|
510
|
+
return lhs.value == rhs.value;
|
511
|
+
}
|
512
|
+
inline bool operator!=(const EnumVal &lhs, const EnumVal &rhs) {
|
513
|
+
return !(lhs == rhs);
|
514
|
+
}
|
515
|
+
|
516
|
+
inline bool EqualByName(const Type &a, const Type &b) {
|
517
|
+
return a.base_type == b.base_type && a.element == b.element &&
|
518
|
+
(a.struct_def == b.struct_def ||
|
519
|
+
a.struct_def->name == b.struct_def->name) &&
|
520
|
+
(a.enum_def == b.enum_def || a.enum_def->name == b.enum_def->name);
|
521
|
+
}
|
522
|
+
|
523
|
+
struct RPCCall : public Definition {
|
524
|
+
Offset<reflection::RPCCall> Serialize(FlatBufferBuilder *builder,
|
525
|
+
const Parser &parser) const;
|
526
|
+
|
527
|
+
bool Deserialize(Parser &parser, const reflection::RPCCall *call);
|
528
|
+
|
529
|
+
StructDef *request, *response;
|
530
|
+
};
|
531
|
+
|
532
|
+
struct ServiceDef : public Definition {
|
533
|
+
Offset<reflection::Service> Serialize(FlatBufferBuilder *builder,
|
534
|
+
const Parser &parser) const;
|
535
|
+
bool Deserialize(Parser &parser, const reflection::Service *service);
|
536
|
+
|
537
|
+
SymbolTable<RPCCall> calls;
|
538
|
+
};
|
539
|
+
|
540
|
+
// Container of options that may apply to any of the source/text generators.
|
541
|
+
struct IDLOptions {
|
542
|
+
// field case style options for C++
|
543
|
+
enum CaseStyle { CaseStyle_Unchanged = 0, CaseStyle_Upper, CaseStyle_Lower };
|
544
|
+
|
545
|
+
bool gen_jvmstatic;
|
546
|
+
// Use flexbuffers instead for binary and text generation
|
547
|
+
bool use_flexbuffers;
|
548
|
+
bool strict_json;
|
549
|
+
bool output_default_scalars_in_json;
|
550
|
+
int indent_step;
|
551
|
+
bool output_enum_identifiers;
|
552
|
+
bool prefixed_enums;
|
553
|
+
bool scoped_enums;
|
554
|
+
bool include_dependence_headers;
|
555
|
+
bool mutable_buffer;
|
556
|
+
bool one_file;
|
557
|
+
bool proto_mode;
|
558
|
+
bool proto_oneof_union;
|
559
|
+
bool generate_all;
|
560
|
+
bool skip_unexpected_fields_in_json;
|
561
|
+
bool generate_name_strings;
|
562
|
+
bool generate_object_based_api;
|
563
|
+
bool gen_compare;
|
564
|
+
std::string cpp_object_api_pointer_type;
|
565
|
+
std::string cpp_object_api_string_type;
|
566
|
+
bool cpp_object_api_string_flexible_constructor;
|
567
|
+
CaseStyle cpp_object_api_field_case_style;
|
568
|
+
bool cpp_direct_copy;
|
569
|
+
bool gen_nullable;
|
570
|
+
bool java_checkerframework;
|
571
|
+
bool gen_generated;
|
572
|
+
bool gen_json_coders;
|
573
|
+
std::string object_prefix;
|
574
|
+
std::string object_suffix;
|
575
|
+
bool union_value_namespacing;
|
576
|
+
bool allow_non_utf8;
|
577
|
+
bool natural_utf8;
|
578
|
+
std::string include_prefix;
|
579
|
+
bool keep_include_path;
|
580
|
+
bool binary_schema_comments;
|
581
|
+
bool binary_schema_builtins;
|
582
|
+
bool binary_schema_gen_embed;
|
583
|
+
std::string go_import;
|
584
|
+
std::string go_namespace;
|
585
|
+
bool protobuf_ascii_alike;
|
586
|
+
bool size_prefixed;
|
587
|
+
std::string root_type;
|
588
|
+
bool force_defaults;
|
589
|
+
bool java_primitive_has_method;
|
590
|
+
bool cs_gen_json_serializer;
|
591
|
+
std::vector<std::string> cpp_includes;
|
592
|
+
std::string cpp_std;
|
593
|
+
bool cpp_static_reflection;
|
594
|
+
std::string proto_namespace_suffix;
|
595
|
+
std::string filename_suffix;
|
596
|
+
std::string filename_extension;
|
597
|
+
bool no_warnings;
|
598
|
+
bool warnings_as_errors;
|
599
|
+
std::string project_root;
|
600
|
+
bool cs_global_alias;
|
601
|
+
bool json_nested_flatbuffers;
|
602
|
+
bool json_nested_flexbuffers;
|
603
|
+
bool json_nested_legacy_flatbuffers;
|
604
|
+
|
605
|
+
// Possible options for the more general generator below.
|
606
|
+
enum Language {
|
607
|
+
kJava = 1 << 0,
|
608
|
+
kCSharp = 1 << 1,
|
609
|
+
kGo = 1 << 2,
|
610
|
+
kCpp = 1 << 3,
|
611
|
+
kPython = 1 << 5,
|
612
|
+
kPhp = 1 << 6,
|
613
|
+
kJson = 1 << 7,
|
614
|
+
kBinary = 1 << 8,
|
615
|
+
kTs = 1 << 9,
|
616
|
+
kJsonSchema = 1 << 10,
|
617
|
+
kDart = 1 << 11,
|
618
|
+
kLua = 1 << 12,
|
619
|
+
kLobster = 1 << 13,
|
620
|
+
kRust = 1 << 14,
|
621
|
+
kKotlin = 1 << 15,
|
622
|
+
kSwift = 1 << 16,
|
623
|
+
kMAX
|
624
|
+
};
|
625
|
+
|
626
|
+
enum MiniReflect { kNone, kTypes, kTypesAndNames };
|
627
|
+
|
628
|
+
MiniReflect mini_reflect;
|
629
|
+
|
630
|
+
// If set, require all fields in a table to be explicitly numbered.
|
631
|
+
bool require_explicit_ids;
|
632
|
+
|
633
|
+
// If set, implement serde::Serialize for generated Rust types
|
634
|
+
bool rust_serialize;
|
635
|
+
|
636
|
+
// If set, generate rust types in individual files with a root module file.
|
637
|
+
bool rust_module_root_file;
|
638
|
+
|
639
|
+
// The corresponding language bit will be set if a language is included
|
640
|
+
// for code generation.
|
641
|
+
unsigned long lang_to_generate;
|
642
|
+
|
643
|
+
// If set (default behavior), empty string fields will be set to nullptr to
|
644
|
+
// make the flatbuffer more compact.
|
645
|
+
bool set_empty_strings_to_null;
|
646
|
+
|
647
|
+
// If set (default behavior), empty vector fields will be set to nullptr to
|
648
|
+
// make the flatbuffer more compact.
|
649
|
+
bool set_empty_vectors_to_null;
|
650
|
+
|
651
|
+
IDLOptions()
|
652
|
+
: gen_jvmstatic(false),
|
653
|
+
use_flexbuffers(false),
|
654
|
+
strict_json(false),
|
655
|
+
output_default_scalars_in_json(false),
|
656
|
+
indent_step(2),
|
657
|
+
output_enum_identifiers(true),
|
658
|
+
prefixed_enums(true),
|
659
|
+
scoped_enums(false),
|
660
|
+
include_dependence_headers(true),
|
661
|
+
mutable_buffer(false),
|
662
|
+
one_file(false),
|
663
|
+
proto_mode(false),
|
664
|
+
proto_oneof_union(false),
|
665
|
+
generate_all(false),
|
666
|
+
skip_unexpected_fields_in_json(false),
|
667
|
+
generate_name_strings(false),
|
668
|
+
generate_object_based_api(false),
|
669
|
+
gen_compare(false),
|
670
|
+
cpp_object_api_pointer_type("std::unique_ptr"),
|
671
|
+
cpp_object_api_string_flexible_constructor(false),
|
672
|
+
cpp_object_api_field_case_style(CaseStyle_Unchanged),
|
673
|
+
cpp_direct_copy(true),
|
674
|
+
gen_nullable(false),
|
675
|
+
java_checkerframework(false),
|
676
|
+
gen_generated(false),
|
677
|
+
gen_json_coders(false),
|
678
|
+
object_suffix("T"),
|
679
|
+
union_value_namespacing(true),
|
680
|
+
allow_non_utf8(false),
|
681
|
+
natural_utf8(false),
|
682
|
+
keep_include_path(false),
|
683
|
+
binary_schema_comments(false),
|
684
|
+
binary_schema_builtins(false),
|
685
|
+
binary_schema_gen_embed(false),
|
686
|
+
protobuf_ascii_alike(false),
|
687
|
+
size_prefixed(false),
|
688
|
+
force_defaults(false),
|
689
|
+
java_primitive_has_method(false),
|
690
|
+
cs_gen_json_serializer(false),
|
691
|
+
cpp_static_reflection(false),
|
692
|
+
filename_suffix("_generated"),
|
693
|
+
filename_extension(),
|
694
|
+
no_warnings(false),
|
695
|
+
warnings_as_errors(false),
|
696
|
+
project_root(""),
|
697
|
+
cs_global_alias(false),
|
698
|
+
json_nested_flatbuffers(true),
|
699
|
+
json_nested_flexbuffers(true),
|
700
|
+
json_nested_legacy_flatbuffers(false),
|
701
|
+
mini_reflect(IDLOptions::kNone),
|
702
|
+
require_explicit_ids(false),
|
703
|
+
rust_serialize(false),
|
704
|
+
rust_module_root_file(false),
|
705
|
+
lang_to_generate(0),
|
706
|
+
set_empty_strings_to_null(true),
|
707
|
+
set_empty_vectors_to_null(true) {}
|
708
|
+
};
|
709
|
+
|
710
|
+
// This encapsulates where the parser is in the current source file.
|
711
|
+
struct ParserState {
|
712
|
+
ParserState()
|
713
|
+
: cursor_(nullptr),
|
714
|
+
line_start_(nullptr),
|
715
|
+
line_(0),
|
716
|
+
token_(-1),
|
717
|
+
attr_is_trivial_ascii_string_(true) {}
|
718
|
+
|
719
|
+
protected:
|
720
|
+
void ResetState(const char *source) {
|
721
|
+
cursor_ = source;
|
722
|
+
line_ = 0;
|
723
|
+
MarkNewLine();
|
724
|
+
}
|
725
|
+
|
726
|
+
void MarkNewLine() {
|
727
|
+
line_start_ = cursor_;
|
728
|
+
line_ += 1;
|
729
|
+
}
|
730
|
+
|
731
|
+
int64_t CursorPosition() const {
|
732
|
+
FLATBUFFERS_ASSERT(cursor_ && line_start_ && cursor_ >= line_start_);
|
733
|
+
return static_cast<int64_t>(cursor_ - line_start_);
|
734
|
+
}
|
735
|
+
|
736
|
+
const char *cursor_;
|
737
|
+
const char *line_start_;
|
738
|
+
int line_; // the current line being parsed
|
739
|
+
int token_;
|
740
|
+
|
741
|
+
// Flag: text in attribute_ is true ASCII string without escape
|
742
|
+
// sequences. Only printable ASCII (without [\t\r\n]).
|
743
|
+
// Used for number-in-string (and base64 string in future).
|
744
|
+
bool attr_is_trivial_ascii_string_;
|
745
|
+
std::string attribute_;
|
746
|
+
std::vector<std::string> doc_comment_;
|
747
|
+
};
|
748
|
+
|
749
|
+
// A way to make error propagation less error prone by requiring values to be
|
750
|
+
// checked.
|
751
|
+
// Once you create a value of this type you must either:
|
752
|
+
// - Call Check() on it.
|
753
|
+
// - Copy or assign it to another value.
|
754
|
+
// Failure to do so leads to an assert.
|
755
|
+
// This guarantees that this as return value cannot be ignored.
|
756
|
+
class CheckedError {
|
757
|
+
public:
|
758
|
+
explicit CheckedError(bool error)
|
759
|
+
: is_error_(error), has_been_checked_(false) {}
|
760
|
+
|
761
|
+
CheckedError &operator=(const CheckedError &other) {
|
762
|
+
is_error_ = other.is_error_;
|
763
|
+
has_been_checked_ = false;
|
764
|
+
other.has_been_checked_ = true;
|
765
|
+
return *this;
|
766
|
+
}
|
767
|
+
|
768
|
+
CheckedError(const CheckedError &other) {
|
769
|
+
*this = other; // Use assignment operator.
|
770
|
+
}
|
771
|
+
|
772
|
+
~CheckedError() { FLATBUFFERS_ASSERT(has_been_checked_); }
|
773
|
+
|
774
|
+
bool Check() {
|
775
|
+
has_been_checked_ = true;
|
776
|
+
return is_error_;
|
777
|
+
}
|
778
|
+
|
779
|
+
private:
|
780
|
+
bool is_error_;
|
781
|
+
mutable bool has_been_checked_;
|
782
|
+
};
|
783
|
+
|
784
|
+
// Additionally, in GCC we can get these errors statically, for additional
|
785
|
+
// assurance:
|
786
|
+
// clang-format off
|
787
|
+
#ifdef __GNUC__
|
788
|
+
#define FLATBUFFERS_CHECKED_ERROR CheckedError \
|
789
|
+
__attribute__((warn_unused_result))
|
790
|
+
#else
|
791
|
+
#define FLATBUFFERS_CHECKED_ERROR CheckedError
|
792
|
+
#endif
|
793
|
+
// clang-format on
|
794
|
+
|
795
|
+
class Parser : public ParserState {
|
796
|
+
public:
|
797
|
+
explicit Parser(const IDLOptions &options = IDLOptions())
|
798
|
+
: current_namespace_(nullptr),
|
799
|
+
empty_namespace_(nullptr),
|
800
|
+
flex_builder_(256, flexbuffers::BUILDER_FLAG_SHARE_ALL),
|
801
|
+
root_struct_def_(nullptr),
|
802
|
+
opts(options),
|
803
|
+
uses_flexbuffers_(false),
|
804
|
+
has_warning_(false),
|
805
|
+
advanced_features_(0),
|
806
|
+
source_(nullptr),
|
807
|
+
anonymous_counter_(0),
|
808
|
+
parse_depth_counter_(0) {
|
809
|
+
if (opts.force_defaults) { builder_.ForceDefaults(true); }
|
810
|
+
// Start out with the empty namespace being current.
|
811
|
+
empty_namespace_ = new Namespace();
|
812
|
+
namespaces_.push_back(empty_namespace_);
|
813
|
+
current_namespace_ = empty_namespace_;
|
814
|
+
known_attributes_["deprecated"] = true;
|
815
|
+
known_attributes_["required"] = true;
|
816
|
+
known_attributes_["key"] = true;
|
817
|
+
known_attributes_["shared"] = true;
|
818
|
+
known_attributes_["hash"] = true;
|
819
|
+
known_attributes_["id"] = true;
|
820
|
+
known_attributes_["force_align"] = true;
|
821
|
+
known_attributes_["bit_flags"] = true;
|
822
|
+
known_attributes_["original_order"] = true;
|
823
|
+
known_attributes_["nested_flatbuffer"] = true;
|
824
|
+
known_attributes_["csharp_partial"] = true;
|
825
|
+
known_attributes_["streaming"] = true;
|
826
|
+
known_attributes_["idempotent"] = true;
|
827
|
+
known_attributes_["cpp_type"] = true;
|
828
|
+
known_attributes_["cpp_ptr_type"] = true;
|
829
|
+
known_attributes_["cpp_ptr_type_get"] = true;
|
830
|
+
known_attributes_["cpp_str_type"] = true;
|
831
|
+
known_attributes_["cpp_str_flex_ctor"] = true;
|
832
|
+
known_attributes_["native_inline"] = true;
|
833
|
+
known_attributes_["native_custom_alloc"] = true;
|
834
|
+
known_attributes_["native_type"] = true;
|
835
|
+
known_attributes_["native_type_pack_name"] = true;
|
836
|
+
known_attributes_["native_default"] = true;
|
837
|
+
known_attributes_["flexbuffer"] = true;
|
838
|
+
known_attributes_["private"] = true;
|
839
|
+
}
|
840
|
+
|
841
|
+
~Parser() {
|
842
|
+
for (auto it = namespaces_.begin(); it != namespaces_.end(); ++it) {
|
843
|
+
delete *it;
|
844
|
+
}
|
845
|
+
}
|
846
|
+
|
847
|
+
// Parse the string containing either schema or JSON data, which will
|
848
|
+
// populate the SymbolTable's or the FlatBufferBuilder above.
|
849
|
+
// include_paths is used to resolve any include statements, and typically
|
850
|
+
// should at least include the project path (where you loaded source_ from).
|
851
|
+
// include_paths must be nullptr terminated if specified.
|
852
|
+
// If include_paths is nullptr, it will attempt to load from the current
|
853
|
+
// directory.
|
854
|
+
// If the source was loaded from a file and isn't an include file,
|
855
|
+
// supply its name in source_filename.
|
856
|
+
// All paths specified in this call must be in posix format, if you accept
|
857
|
+
// paths from user input, please call PosixPath on them first.
|
858
|
+
bool Parse(const char *_source, const char **include_paths = nullptr,
|
859
|
+
const char *source_filename = nullptr);
|
860
|
+
|
861
|
+
bool ParseJson(const char *json, const char *json_filename = nullptr);
|
862
|
+
|
863
|
+
// Set the root type. May override the one set in the schema.
|
864
|
+
bool SetRootType(const char *name);
|
865
|
+
|
866
|
+
// Mark all definitions as already having code generated.
|
867
|
+
void MarkGenerated();
|
868
|
+
|
869
|
+
// Get the files recursively included by the given file. The returned
|
870
|
+
// container will have at least the given file.
|
871
|
+
std::set<std::string> GetIncludedFilesRecursive(
|
872
|
+
const std::string &file_name) const;
|
873
|
+
|
874
|
+
// Fills builder_ with a binary version of the schema parsed.
|
875
|
+
// See reflection/reflection.fbs
|
876
|
+
void Serialize();
|
877
|
+
|
878
|
+
// Deserialize a schema buffer
|
879
|
+
bool Deserialize(const uint8_t *buf, const size_t size);
|
880
|
+
|
881
|
+
// Fills internal structure as if the schema passed had been loaded by parsing
|
882
|
+
// with Parse except that included filenames will not be populated.
|
883
|
+
bool Deserialize(const reflection::Schema *schema);
|
884
|
+
|
885
|
+
Type *DeserializeType(const reflection::Type *type);
|
886
|
+
|
887
|
+
// Checks that the schema represented by this parser is a safe evolution
|
888
|
+
// of the schema provided. Returns non-empty error on any problems.
|
889
|
+
std::string ConformTo(const Parser &base);
|
890
|
+
|
891
|
+
// Similar to Parse(), but now only accepts JSON to be parsed into a
|
892
|
+
// FlexBuffer.
|
893
|
+
bool ParseFlexBuffer(const char *source, const char *source_filename,
|
894
|
+
flexbuffers::Builder *builder);
|
895
|
+
|
896
|
+
StructDef *LookupStruct(const std::string &id) const;
|
897
|
+
StructDef *LookupStructThruParentNamespaces(const std::string &id) const;
|
898
|
+
|
899
|
+
std::string UnqualifiedName(const std::string &fullQualifiedName);
|
900
|
+
|
901
|
+
FLATBUFFERS_CHECKED_ERROR Error(const std::string &msg);
|
902
|
+
|
903
|
+
// @brief Verify that any of 'opts.lang_to_generate' supports Optional scalars
|
904
|
+
// in a schema.
|
905
|
+
// @param opts Options used to parce a schema and generate code.
|
906
|
+
static bool SupportsOptionalScalars(const flatbuffers::IDLOptions &opts);
|
907
|
+
|
908
|
+
private:
|
909
|
+
class ParseDepthGuard;
|
910
|
+
|
911
|
+
void Message(const std::string &msg);
|
912
|
+
void Warning(const std::string &msg);
|
913
|
+
FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val);
|
914
|
+
FLATBUFFERS_CHECKED_ERROR Next();
|
915
|
+
FLATBUFFERS_CHECKED_ERROR SkipByteOrderMark();
|
916
|
+
bool Is(int t) const;
|
917
|
+
bool IsIdent(const char *id) const;
|
918
|
+
FLATBUFFERS_CHECKED_ERROR Expect(int t);
|
919
|
+
std::string TokenToStringId(int t) const;
|
920
|
+
EnumDef *LookupEnum(const std::string &id);
|
921
|
+
FLATBUFFERS_CHECKED_ERROR ParseNamespacing(std::string *id,
|
922
|
+
std::string *last);
|
923
|
+
FLATBUFFERS_CHECKED_ERROR ParseTypeIdent(Type &type);
|
924
|
+
FLATBUFFERS_CHECKED_ERROR ParseType(Type &type);
|
925
|
+
FLATBUFFERS_CHECKED_ERROR AddField(StructDef &struct_def,
|
926
|
+
const std::string &name, const Type &type,
|
927
|
+
FieldDef **dest);
|
928
|
+
FLATBUFFERS_CHECKED_ERROR ParseField(StructDef &struct_def);
|
929
|
+
FLATBUFFERS_CHECKED_ERROR ParseString(Value &val, bool use_string_pooling);
|
930
|
+
FLATBUFFERS_CHECKED_ERROR ParseComma();
|
931
|
+
FLATBUFFERS_CHECKED_ERROR ParseAnyValue(Value &val, FieldDef *field,
|
932
|
+
size_t parent_fieldn,
|
933
|
+
const StructDef *parent_struct_def,
|
934
|
+
uoffset_t count,
|
935
|
+
bool inside_vector = false);
|
936
|
+
template<typename F>
|
937
|
+
FLATBUFFERS_CHECKED_ERROR ParseTableDelimiters(size_t &fieldn,
|
938
|
+
const StructDef *struct_def,
|
939
|
+
F body);
|
940
|
+
FLATBUFFERS_CHECKED_ERROR ParseTable(const StructDef &struct_def,
|
941
|
+
std::string *value, uoffset_t *ovalue);
|
942
|
+
void SerializeStruct(const StructDef &struct_def, const Value &val);
|
943
|
+
void SerializeStruct(FlatBufferBuilder &builder, const StructDef &struct_def,
|
944
|
+
const Value &val);
|
945
|
+
template<typename F>
|
946
|
+
FLATBUFFERS_CHECKED_ERROR ParseVectorDelimiters(uoffset_t &count, F body);
|
947
|
+
FLATBUFFERS_CHECKED_ERROR ParseVector(const Type &type, uoffset_t *ovalue,
|
948
|
+
FieldDef *field, size_t fieldn);
|
949
|
+
FLATBUFFERS_CHECKED_ERROR ParseArray(Value &array);
|
950
|
+
FLATBUFFERS_CHECKED_ERROR ParseNestedFlatbuffer(
|
951
|
+
Value &val, FieldDef *field, size_t fieldn,
|
952
|
+
const StructDef *parent_struct_def);
|
953
|
+
FLATBUFFERS_CHECKED_ERROR ParseMetaData(SymbolTable<Value> *attributes);
|
954
|
+
FLATBUFFERS_CHECKED_ERROR TryTypedValue(const std::string *name, int dtoken,
|
955
|
+
bool check, Value &e, BaseType req,
|
956
|
+
bool *destmatch);
|
957
|
+
FLATBUFFERS_CHECKED_ERROR ParseHash(Value &e, FieldDef *field);
|
958
|
+
FLATBUFFERS_CHECKED_ERROR TokenError();
|
959
|
+
FLATBUFFERS_CHECKED_ERROR ParseSingleValue(const std::string *name, Value &e,
|
960
|
+
bool check_now);
|
961
|
+
FLATBUFFERS_CHECKED_ERROR ParseFunction(const std::string *name, Value &e);
|
962
|
+
FLATBUFFERS_CHECKED_ERROR ParseEnumFromString(const Type &type,
|
963
|
+
std::string *result);
|
964
|
+
StructDef *LookupCreateStruct(const std::string &name,
|
965
|
+
bool create_if_new = true,
|
966
|
+
bool definition = false);
|
967
|
+
FLATBUFFERS_CHECKED_ERROR ParseEnum(bool is_union, EnumDef **dest,
|
968
|
+
const char *filename);
|
969
|
+
FLATBUFFERS_CHECKED_ERROR ParseNamespace();
|
970
|
+
FLATBUFFERS_CHECKED_ERROR StartStruct(const std::string &name,
|
971
|
+
StructDef **dest);
|
972
|
+
FLATBUFFERS_CHECKED_ERROR StartEnum(const std::string &name, bool is_union,
|
973
|
+
EnumDef **dest);
|
974
|
+
FLATBUFFERS_CHECKED_ERROR ParseDecl(const char *filename);
|
975
|
+
FLATBUFFERS_CHECKED_ERROR ParseService(const char *filename);
|
976
|
+
FLATBUFFERS_CHECKED_ERROR ParseProtoFields(StructDef *struct_def,
|
977
|
+
bool isextend, bool inside_oneof);
|
978
|
+
FLATBUFFERS_CHECKED_ERROR ParseProtoOption();
|
979
|
+
FLATBUFFERS_CHECKED_ERROR ParseProtoKey();
|
980
|
+
FLATBUFFERS_CHECKED_ERROR ParseProtoDecl();
|
981
|
+
FLATBUFFERS_CHECKED_ERROR ParseProtoCurliesOrIdent();
|
982
|
+
FLATBUFFERS_CHECKED_ERROR ParseTypeFromProtoType(Type *type);
|
983
|
+
FLATBUFFERS_CHECKED_ERROR SkipAnyJsonValue();
|
984
|
+
FLATBUFFERS_CHECKED_ERROR ParseFlexBufferNumericConstant(
|
985
|
+
flexbuffers::Builder *builder);
|
986
|
+
FLATBUFFERS_CHECKED_ERROR ParseFlexBufferValue(flexbuffers::Builder *builder);
|
987
|
+
FLATBUFFERS_CHECKED_ERROR StartParseFile(const char *source,
|
988
|
+
const char *source_filename);
|
989
|
+
FLATBUFFERS_CHECKED_ERROR ParseRoot(const char *_source,
|
990
|
+
const char **include_paths,
|
991
|
+
const char *source_filename);
|
992
|
+
FLATBUFFERS_CHECKED_ERROR DoParse(const char *_source,
|
993
|
+
const char **include_paths,
|
994
|
+
const char *source_filename,
|
995
|
+
const char *include_filename);
|
996
|
+
FLATBUFFERS_CHECKED_ERROR DoParseJson();
|
997
|
+
FLATBUFFERS_CHECKED_ERROR CheckClash(std::vector<FieldDef *> &fields,
|
998
|
+
StructDef *struct_def,
|
999
|
+
const char *suffix, BaseType baseType);
|
1000
|
+
FLATBUFFERS_CHECKED_ERROR ParseAlignAttribute(
|
1001
|
+
const std::string &align_constant, size_t min_align, size_t *align);
|
1002
|
+
|
1003
|
+
bool SupportsAdvancedUnionFeatures() const;
|
1004
|
+
bool SupportsAdvancedArrayFeatures() const;
|
1005
|
+
bool SupportsOptionalScalars() const;
|
1006
|
+
bool SupportsDefaultVectorsAndStrings() const;
|
1007
|
+
Namespace *UniqueNamespace(Namespace *ns);
|
1008
|
+
|
1009
|
+
FLATBUFFERS_CHECKED_ERROR RecurseError();
|
1010
|
+
template<typename F> CheckedError Recurse(F f);
|
1011
|
+
|
1012
|
+
const std::string &GetPooledString(const std::string &s) const;
|
1013
|
+
|
1014
|
+
public:
|
1015
|
+
SymbolTable<Type> types_;
|
1016
|
+
SymbolTable<StructDef> structs_;
|
1017
|
+
SymbolTable<EnumDef> enums_;
|
1018
|
+
SymbolTable<ServiceDef> services_;
|
1019
|
+
std::vector<Namespace *> namespaces_;
|
1020
|
+
Namespace *current_namespace_;
|
1021
|
+
Namespace *empty_namespace_;
|
1022
|
+
std::string error_; // User readable error_ if Parse() == false
|
1023
|
+
|
1024
|
+
FlatBufferBuilder builder_; // any data contained in the file
|
1025
|
+
flexbuffers::Builder flex_builder_;
|
1026
|
+
flexbuffers::Reference flex_root_;
|
1027
|
+
StructDef *root_struct_def_;
|
1028
|
+
std::string file_identifier_;
|
1029
|
+
std::string file_extension_;
|
1030
|
+
|
1031
|
+
std::map<uint64_t, std::string> included_files_;
|
1032
|
+
std::map<std::string, std::set<std::string>> files_included_per_file_;
|
1033
|
+
std::vector<std::string> native_included_files_;
|
1034
|
+
|
1035
|
+
std::map<std::string, bool> known_attributes_;
|
1036
|
+
|
1037
|
+
IDLOptions opts;
|
1038
|
+
bool uses_flexbuffers_;
|
1039
|
+
bool has_warning_;
|
1040
|
+
|
1041
|
+
uint64_t advanced_features_;
|
1042
|
+
|
1043
|
+
private:
|
1044
|
+
const char *source_;
|
1045
|
+
|
1046
|
+
std::string file_being_parsed_;
|
1047
|
+
|
1048
|
+
std::vector<std::pair<Value, FieldDef *>> field_stack_;
|
1049
|
+
|
1050
|
+
// TODO(cneo): Refactor parser to use string_cache more often to save
|
1051
|
+
// on memory usage.
|
1052
|
+
mutable std::set<std::string> string_cache_;
|
1053
|
+
|
1054
|
+
int anonymous_counter_;
|
1055
|
+
int parse_depth_counter_; // stack-overflow guard
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
// Utility functions for multiple generators:
|
1059
|
+
|
1060
|
+
extern std::string MakeCamel(const std::string &in, bool first = true);
|
1061
|
+
|
1062
|
+
extern std::string MakeScreamingCamel(const std::string &in);
|
1063
|
+
|
1064
|
+
// Generate text (JSON) from a given FlatBuffer, and a given Parser
|
1065
|
+
// object that has been populated with the corresponding schema.
|
1066
|
+
// If ident_step is 0, no indentation will be generated. Additionally,
|
1067
|
+
// if it is less than 0, no linefeeds will be generated either.
|
1068
|
+
// See idl_gen_text.cpp.
|
1069
|
+
// strict_json adds "quotes" around field names if true.
|
1070
|
+
// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8
|
1071
|
+
// byte arrays in String values), returns false.
|
1072
|
+
extern bool GenerateTextFromTable(const Parser &parser, const void *table,
|
1073
|
+
const std::string &tablename,
|
1074
|
+
std::string *text);
|
1075
|
+
extern bool GenerateText(const Parser &parser, const void *flatbuffer,
|
1076
|
+
std::string *text);
|
1077
|
+
extern bool GenerateTextFile(const Parser &parser, const std::string &path,
|
1078
|
+
const std::string &file_name);
|
1079
|
+
|
1080
|
+
// Generate Json schema to string
|
1081
|
+
// See idl_gen_json_schema.cpp.
|
1082
|
+
extern bool GenerateJsonSchema(const Parser &parser, std::string *json);
|
1083
|
+
|
1084
|
+
// Generate binary files from a given FlatBuffer, and a given Parser
|
1085
|
+
// object that has been populated with the corresponding schema.
|
1086
|
+
// See code_generators.cpp.
|
1087
|
+
extern bool GenerateBinary(const Parser &parser, const std::string &path,
|
1088
|
+
const std::string &file_name);
|
1089
|
+
|
1090
|
+
// Generate a C++ header from the definitions in the Parser object.
|
1091
|
+
// See idl_gen_cpp.
|
1092
|
+
extern bool GenerateCPP(const Parser &parser, const std::string &path,
|
1093
|
+
const std::string &file_name);
|
1094
|
+
|
1095
|
+
// Generate C# files from the definitions in the Parser object.
|
1096
|
+
// See idl_gen_csharp.cpp.
|
1097
|
+
extern bool GenerateCSharp(const Parser &parser, const std::string &path,
|
1098
|
+
const std::string &file_name);
|
1099
|
+
|
1100
|
+
extern bool GenerateDart(const Parser &parser, const std::string &path,
|
1101
|
+
const std::string &file_name);
|
1102
|
+
|
1103
|
+
// Generate Java files from the definitions in the Parser object.
|
1104
|
+
// See idl_gen_java.cpp.
|
1105
|
+
extern bool GenerateJava(const Parser &parser, const std::string &path,
|
1106
|
+
const std::string &file_name);
|
1107
|
+
|
1108
|
+
// Generate JavaScript or TypeScript code from the definitions in the Parser
|
1109
|
+
// object. See idl_gen_js.
|
1110
|
+
extern bool GenerateTS(const Parser &parser, const std::string &path,
|
1111
|
+
const std::string &file_name);
|
1112
|
+
|
1113
|
+
// Generate Go files from the definitions in the Parser object.
|
1114
|
+
// See idl_gen_go.cpp.
|
1115
|
+
extern bool GenerateGo(const Parser &parser, const std::string &path,
|
1116
|
+
const std::string &file_name);
|
1117
|
+
|
1118
|
+
// Generate Php code from the definitions in the Parser object.
|
1119
|
+
// See idl_gen_php.
|
1120
|
+
extern bool GeneratePhp(const Parser &parser, const std::string &path,
|
1121
|
+
const std::string &file_name);
|
1122
|
+
|
1123
|
+
// Generate Python files from the definitions in the Parser object.
|
1124
|
+
// See idl_gen_python.cpp.
|
1125
|
+
extern bool GeneratePython(const Parser &parser, const std::string &path,
|
1126
|
+
const std::string &file_name);
|
1127
|
+
|
1128
|
+
// Generate Lobster files from the definitions in the Parser object.
|
1129
|
+
// See idl_gen_lobster.cpp.
|
1130
|
+
extern bool GenerateLobster(const Parser &parser, const std::string &path,
|
1131
|
+
const std::string &file_name);
|
1132
|
+
|
1133
|
+
// Generate Lua files from the definitions in the Parser object.
|
1134
|
+
// See idl_gen_lua.cpp.
|
1135
|
+
extern bool GenerateLua(const Parser &parser, const std::string &path,
|
1136
|
+
const std::string &file_name);
|
1137
|
+
|
1138
|
+
// Generate Rust files from the definitions in the Parser object.
|
1139
|
+
// See idl_gen_rust.cpp.
|
1140
|
+
extern bool GenerateRust(const Parser &parser, const std::string &path,
|
1141
|
+
const std::string &file_name);
|
1142
|
+
|
1143
|
+
// Generate Json schema file
|
1144
|
+
// See idl_gen_json_schema.cpp.
|
1145
|
+
extern bool GenerateJsonSchema(const Parser &parser, const std::string &path,
|
1146
|
+
const std::string &file_name);
|
1147
|
+
|
1148
|
+
extern bool GenerateKotlin(const Parser &parser, const std::string &path,
|
1149
|
+
const std::string &file_name);
|
1150
|
+
|
1151
|
+
// Generate Swift classes.
|
1152
|
+
// See idl_gen_swift.cpp
|
1153
|
+
extern bool GenerateSwift(const Parser &parser, const std::string &path,
|
1154
|
+
const std::string &file_name);
|
1155
|
+
|
1156
|
+
// Generate a schema file from the internal representation, useful after
|
1157
|
+
// parsing a .proto schema.
|
1158
|
+
extern std::string GenerateFBS(const Parser &parser,
|
1159
|
+
const std::string &file_name);
|
1160
|
+
extern bool GenerateFBS(const Parser &parser, const std::string &path,
|
1161
|
+
const std::string &file_name);
|
1162
|
+
|
1163
|
+
// Generate a make rule for the generated TypeScript code.
|
1164
|
+
// See idl_gen_ts.cpp.
|
1165
|
+
extern std::string TSMakeRule(const Parser &parser, const std::string &path,
|
1166
|
+
const std::string &file_name);
|
1167
|
+
|
1168
|
+
// Generate a make rule for the generated C++ header.
|
1169
|
+
// See idl_gen_cpp.cpp.
|
1170
|
+
extern std::string CPPMakeRule(const Parser &parser, const std::string &path,
|
1171
|
+
const std::string &file_name);
|
1172
|
+
|
1173
|
+
// Generate a make rule for the generated Dart code
|
1174
|
+
// see idl_gen_dart.cpp
|
1175
|
+
extern std::string DartMakeRule(const Parser &parser, const std::string &path,
|
1176
|
+
const std::string &file_name);
|
1177
|
+
|
1178
|
+
// Generate a make rule for the generated Rust code.
|
1179
|
+
// See idl_gen_rust.cpp.
|
1180
|
+
extern std::string RustMakeRule(const Parser &parser, const std::string &path,
|
1181
|
+
const std::string &file_name);
|
1182
|
+
|
1183
|
+
// Generate a make rule for generated Java or C# files.
|
1184
|
+
// See code_generators.cpp.
|
1185
|
+
extern std::string CSharpMakeRule(const Parser &parser, const std::string &path,
|
1186
|
+
const std::string &file_name);
|
1187
|
+
extern std::string JavaMakeRule(const Parser &parser, const std::string &path,
|
1188
|
+
const std::string &file_name);
|
1189
|
+
|
1190
|
+
// Generate a make rule for the generated text (JSON) files.
|
1191
|
+
// See idl_gen_text.cpp.
|
1192
|
+
extern std::string TextMakeRule(const Parser &parser, const std::string &path,
|
1193
|
+
const std::string &file_names);
|
1194
|
+
|
1195
|
+
// Generate a make rule for the generated binary files.
|
1196
|
+
// See code_generators.cpp.
|
1197
|
+
extern std::string BinaryMakeRule(const Parser &parser, const std::string &path,
|
1198
|
+
const std::string &file_name);
|
1199
|
+
|
1200
|
+
// Generate GRPC Cpp interfaces.
|
1201
|
+
// See idl_gen_grpc.cpp.
|
1202
|
+
bool GenerateCppGRPC(const Parser &parser, const std::string &path,
|
1203
|
+
const std::string &file_name);
|
1204
|
+
|
1205
|
+
// Generate GRPC Go interfaces.
|
1206
|
+
// See idl_gen_grpc.cpp.
|
1207
|
+
bool GenerateGoGRPC(const Parser &parser, const std::string &path,
|
1208
|
+
const std::string &file_name);
|
1209
|
+
|
1210
|
+
// Generate GRPC Java classes.
|
1211
|
+
// See idl_gen_grpc.cpp
|
1212
|
+
bool GenerateJavaGRPC(const Parser &parser, const std::string &path,
|
1213
|
+
const std::string &file_name);
|
1214
|
+
|
1215
|
+
// Generate GRPC Python interfaces.
|
1216
|
+
// See idl_gen_grpc.cpp.
|
1217
|
+
bool GeneratePythonGRPC(const Parser &parser, const std::string &path,
|
1218
|
+
const std::string &file_name);
|
1219
|
+
|
1220
|
+
// Generate GRPC Swift interfaces.
|
1221
|
+
// See idl_gen_grpc.cpp.
|
1222
|
+
extern bool GenerateSwiftGRPC(const Parser &parser, const std::string &path,
|
1223
|
+
const std::string &file_name);
|
1224
|
+
|
1225
|
+
extern bool GenerateTSGRPC(const Parser &parser, const std::string &path,
|
1226
|
+
const std::string &file_name);
|
1227
|
+
|
1228
|
+
extern bool GenerateRustModuleRootFile(const Parser &parser,
|
1229
|
+
const std::string &path);
|
1230
|
+
} // namespace flatbuffers
|
1231
|
+
|
1232
|
+
#endif // FLATBUFFERS_IDL_H_
|