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.
Files changed (395) hide show
  1. xmos_ai_tools/__init__.py +7 -0
  2. xmos_ai_tools/io_server/__init__.py +151 -0
  3. xmos_ai_tools/runtime/__init__.py +0 -0
  4. xmos_ai_tools/runtime/buildfiles/aitoolslib.cmake +13 -0
  5. xmos_ai_tools/runtime/buildfiles/aitoolslib.make +8 -0
  6. xmos_ai_tools/runtime/include/flash_server.h +74 -0
  7. xmos_ai_tools/runtime/include/flatbuffers/allocator.h +68 -0
  8. xmos_ai_tools/runtime/include/flatbuffers/array.h +243 -0
  9. xmos_ai_tools/runtime/include/flatbuffers/base.h +474 -0
  10. xmos_ai_tools/runtime/include/flatbuffers/bfbs_generator.h +43 -0
  11. xmos_ai_tools/runtime/include/flatbuffers/buffer.h +142 -0
  12. xmos_ai_tools/runtime/include/flatbuffers/buffer_ref.h +53 -0
  13. xmos_ai_tools/runtime/include/flatbuffers/code_generators.h +235 -0
  14. xmos_ai_tools/runtime/include/flatbuffers/default_allocator.h +64 -0
  15. xmos_ai_tools/runtime/include/flatbuffers/detached_buffer.h +114 -0
  16. xmos_ai_tools/runtime/include/flatbuffers/flatbuffer_builder.h +1197 -0
  17. xmos_ai_tools/runtime/include/flatbuffers/flatbuffers.h +270 -0
  18. xmos_ai_tools/runtime/include/flatbuffers/flatc.h +111 -0
  19. xmos_ai_tools/runtime/include/flatbuffers/flexbuffers.h +1897 -0
  20. xmos_ai_tools/runtime/include/flatbuffers/grpc.h +300 -0
  21. xmos_ai_tools/runtime/include/flatbuffers/hash.h +127 -0
  22. xmos_ai_tools/runtime/include/flatbuffers/idl.h +1232 -0
  23. xmos_ai_tools/runtime/include/flatbuffers/minireflect.h +419 -0
  24. xmos_ai_tools/runtime/include/flatbuffers/pch/flatc_pch.h +39 -0
  25. xmos_ai_tools/runtime/include/flatbuffers/pch/pch.h +38 -0
  26. xmos_ai_tools/runtime/include/flatbuffers/reflection.h +502 -0
  27. xmos_ai_tools/runtime/include/flatbuffers/reflection_generated.h +1449 -0
  28. xmos_ai_tools/runtime/include/flatbuffers/registry.h +128 -0
  29. xmos_ai_tools/runtime/include/flatbuffers/stl_emulation.h +509 -0
  30. xmos_ai_tools/runtime/include/flatbuffers/string.h +64 -0
  31. xmos_ai_tools/runtime/include/flatbuffers/struct.h +53 -0
  32. xmos_ai_tools/runtime/include/flatbuffers/table.h +168 -0
  33. xmos_ai_tools/runtime/include/flatbuffers/util.h +690 -0
  34. xmos_ai_tools/runtime/include/flatbuffers/vector.h +370 -0
  35. xmos_ai_tools/runtime/include/flatbuffers/vector_downward.h +271 -0
  36. xmos_ai_tools/runtime/include/flatbuffers/verifier.h +283 -0
  37. xmos_ai_tools/runtime/include/ioserver.h +44 -0
  38. xmos_ai_tools/runtime/include/lib_nn/api/TransposeConv.h +24 -0
  39. xmos_ai_tools/runtime/include/lib_nn/api/add_int16.h +27 -0
  40. xmos_ai_tools/runtime/include/lib_nn/api/add_int16_transform.h +42 -0
  41. xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16.h +22 -0
  42. xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16_transform.h +34 -0
  43. xmos_ai_tools/runtime/include/lib_nn/api/expand_8_to_16.h +8 -0
  44. xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16.h +42 -0
  45. xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16_transform.h +71 -0
  46. xmos_ai_tools/runtime/include/lib_nn/api/nn_api.h +15 -0
  47. xmos_ai_tools/runtime/include/lib_nn/api/nn_bin_types.h +14 -0
  48. xmos_ai_tools/runtime/include/lib_nn/api/nn_config.h +287 -0
  49. xmos_ai_tools/runtime/include/lib_nn/api/nn_conv2d_structs.h +72 -0
  50. xmos_ai_tools/runtime/include/lib_nn/api/nn_image.h +26 -0
  51. xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +303 -0
  52. xmos_ai_tools/runtime/include/lib_nn/api/nn_op_helper.h +132 -0
  53. xmos_ai_tools/runtime/include/lib_nn/api/nn_op_utils.h +150 -0
  54. xmos_ai_tools/runtime/include/lib_nn/api/nn_operator.h +18 -0
  55. xmos_ai_tools/runtime/include/lib_nn/api/nn_pooling.h +551 -0
  56. xmos_ai_tools/runtime/include/lib_nn/api/nn_types.h +83 -0
  57. xmos_ai_tools/runtime/include/lib_nn/api/nn_window_params.h +55 -0
  58. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16.h +54 -0
  59. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_kernel_transform.h +37 -0
  60. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_mappings.h +13 -0
  61. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +82 -0
  62. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
  63. xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16.h +22 -0
  64. xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16_transform.h +33 -0
  65. xmos_ai_tools/runtime/include/lib_nn/api/version.h +13 -0
  66. xmos_ai_tools/runtime/include/lib_nn/api/vpu_memmove_word_aligned.h +15 -0
  67. xmos_ai_tools/runtime/include/lib_nn/api/vpu_memset_256.h +55 -0
  68. xmos_ai_tools/runtime/include/lib_nn/api/vpu_sim.h +118 -0
  69. xmos_ai_tools/runtime/include/lib_nn/api/xs3_vpu.h +216 -0
  70. xmos_ai_tools/runtime/include/lib_nn/api/xs3a_registers.h +2869 -0
  71. xmos_ai_tools/runtime/include/lib_nn/src/asm/asm_constants.h +41 -0
  72. xmos_ai_tools/runtime/include/lib_nn/src/asm/window_op_plan.h +25 -0
  73. xmos_ai_tools/runtime/include/lib_tflite_micro/api/fast_flash.h +47 -0
  74. xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
  75. xmos_ai_tools/runtime/include/lib_tflite_micro/api/memory_parallel_transport.h +52 -0
  76. xmos_ai_tools/runtime/include/lib_tflite_micro/api/version.h +13 -0
  77. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_config.h +17 -0
  78. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_device_memory.h +62 -0
  79. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_shared_config.h +31 -0
  80. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/conv2d_float.h +155 -0
  81. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_common.h +19 -0
  82. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_custom_options.h +28 -0
  83. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_error_reporter.h +32 -0
  84. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_interpreter.h +49 -0
  85. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +71 -0
  86. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_profiler.h +49 -0
  87. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h +160 -0
  88. xmos_ai_tools/runtime/include/lib_tflite_micro/src/thread_call.h +119 -0
  89. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_defs.h +4 -0
  90. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_device.h +4 -0
  91. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_descriptors.h +4 -0
  92. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_requests.h +4 -0
  93. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud.h +518 -0
  94. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_conf_default.h +11 -0
  95. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_device.h +87 -0
  96. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_descriptors.h +191 -0
  97. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_requests.h +120 -0
  98. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/XUD_USB_Defines.h +70 -0
  99. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/hid.h +23 -0
  100. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio10.h +30 -0
  101. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio20.h +357 -0
  102. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudiocommon.h +168 -0
  103. xmos_ai_tools/runtime/include/signal/micro/kernels/delay_flexbuffers_generated_data.h +25 -0
  104. xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
  105. xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
  106. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
  107. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
  108. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
  109. xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
  110. xmos_ai_tools/runtime/include/signal/micro/kernels/irfft.h +31 -0
  111. xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
  112. xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
  113. xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
  114. xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
  115. xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
  116. xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
  117. xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
  118. xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
  119. xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
  120. xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
  121. xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
  122. xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
  123. xmos_ai_tools/runtime/include/signal/src/filter_bank_square_root.h +34 -0
  124. xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
  125. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
  126. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
  127. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
  128. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
  129. xmos_ai_tools/runtime/include/signal/src/log.h +30 -0
  130. xmos_ai_tools/runtime/include/signal/src/max_abs.h +31 -0
  131. xmos_ai_tools/runtime/include/signal/src/msb.h +32 -0
  132. xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
  133. xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
  134. xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
  135. xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
  136. xmos_ai_tools/runtime/include/signal/src/window.h +31 -0
  137. xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
  138. xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
  139. xmos_ai_tools/runtime/include/tensorflow/lite/builtin_op_data.h +22 -0
  140. xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +241 -0
  141. xmos_ai_tools/runtime/include/tensorflow/lite/c/builtin_op_data.h +20 -0
  142. xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +26 -0
  143. xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +30 -0
  144. xmos_ai_tools/runtime/include/tensorflow/lite/context_util.h +54 -0
  145. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +72 -0
  146. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +440 -0
  147. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/tensor_utils.h +28 -0
  148. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +626 -0
  149. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +178 -0
  150. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +1496 -0
  151. xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
  152. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/bits.h +102 -0
  153. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft.h +50 -0
  154. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_io.h +34 -0
  155. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_util.h +34 -0
  156. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank.h +63 -0
  157. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_io.h +35 -0
  158. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.h +50 -0
  159. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend.h +64 -0
  160. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_io.h +31 -0
  161. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_util.h +52 -0
  162. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h +48 -0
  163. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.h +33 -0
  164. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_lut.h +40 -0
  165. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale.h +39 -0
  166. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_io.h +33 -0
  167. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_util.h +45 -0
  168. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h +46 -0
  169. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_io.h +36 -0
  170. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_util.h +50 -0
  171. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control.h +47 -0
  172. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_util.h +57 -0
  173. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window.h +49 -0
  174. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_io.h +34 -0
  175. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_util.h +45 -0
  176. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +1358 -0
  177. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/compatibility.h +122 -0
  178. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +40 -0
  179. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/max.h +35 -0
  180. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/min.h +35 -0
  181. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/optimized/neon_check.h +20 -0
  182. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +141 -0
  183. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor_utils.h +623 -0
  184. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/quantization_util.h +292 -0
  185. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +561 -0
  186. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add_n.h +86 -0
  187. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/arg_min_max.h +88 -0
  188. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_matmul.h +275 -0
  189. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h +101 -0
  190. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/binary_function.h +91 -0
  191. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_args.h +56 -0
  192. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_to.h +97 -0
  193. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/ceil.h +37 -0
  194. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +271 -0
  195. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/concatenation.h +141 -0
  196. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +289 -0
  197. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/cumsum.h +175 -0
  198. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depth_to_space.h +79 -0
  199. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h +100 -0
  200. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h +319 -0
  201. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/dequantize.h +78 -0
  202. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/div.h +247 -0
  203. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/elu.h +37 -0
  204. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/exp.h +38 -0
  205. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fill.h +38 -0
  206. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor.h +39 -0
  207. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_div.h +35 -0
  208. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_mod.h +44 -0
  209. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fully_connected.h +323 -0
  210. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/hard_swish.h +168 -0
  211. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +250 -0
  212. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +241 -0
  213. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h +291 -0
  214. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h +126 -0
  215. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h +67 -0
  216. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h +121 -0
  217. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +18 -0
  218. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +194 -0
  219. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h +264 -0
  220. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h +117 -0
  221. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h +224 -0
  222. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/l2normalization.h +90 -0
  223. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/leaky_relu.h +69 -0
  224. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/log_softmax.h +256 -0
  225. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/logistic.h +132 -0
  226. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/lstm_cell.h +422 -0
  227. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/maximum_minimum.h +64 -0
  228. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +267 -0
  229. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/neg.h +37 -0
  230. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pad.h +169 -0
  231. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pooling.h +303 -0
  232. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h +333 -0
  233. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h +244 -0
  234. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/prelu.h +111 -0
  235. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h +140 -0
  236. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/quantize.h +89 -0
  237. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +491 -0
  238. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/requantize.h +70 -0
  239. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +233 -0
  240. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h +102 -0
  241. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/round.h +51 -0
  242. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/select.h +151 -0
  243. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/slice.h +80 -0
  244. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/softmax.h +233 -0
  245. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h +109 -0
  246. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_depth.h +80 -0
  247. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/strided_slice.h +147 -0
  248. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +465 -0
  249. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/tanh.h +129 -0
  250. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose.h +203 -0
  251. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose_conv.h +225 -0
  252. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +168 -0
  253. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +278 -0
  254. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +42 -0
  255. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +1096 -0
  256. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +341 -0
  257. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +49 -0
  258. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/padding.h +115 -0
  259. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.h +100 -0
  260. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.h +104 -0
  261. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.h +58 -0
  262. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h +63 -0
  263. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h +144 -0
  264. xmos_ai_tools/runtime/include/tensorflow/lite/micro/benchmarks/micro_benchmark.h +95 -0
  265. xmos_ai_tools/runtime/include/tensorflow/lite/micro/compatibility.h +32 -0
  266. xmos_ai_tools/runtime/include/tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h +49 -0
  267. xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +38 -0
  268. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
  269. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/expected_output_data.h +47 -0
  270. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/input_data.h +108 -0
  271. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/network_model.h +166 -0
  272. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/detection_responder.h +32 -0
  273. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/image_provider.h +38 -0
  274. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/main_functions.h +37 -0
  275. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/model_settings.h +35 -0
  276. xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +70 -0
  277. xmos_ai_tools/runtime/include/tensorflow/lite/micro/flatbuffer_utils.h +65 -0
  278. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activation_utils.h +57 -0
  279. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activations.h +64 -0
  280. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +78 -0
  281. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h +141 -0
  282. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_interface.h +75 -0
  283. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_slicers.h +56 -0
  284. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_tf_utils.h +310 -0
  285. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buf_mgr.h +145 -0
  286. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buffers.h +78 -0
  287. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_common.h +24 -0
  288. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_tflm_lib.h +613 -0
  289. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/mcps_macros.h +115 -0
  290. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/types.h +1286 -0
  291. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +45 -0
  292. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h +22 -0
  293. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +117 -0
  294. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +94 -0
  295. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +80 -0
  296. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/dequantize.h +38 -0
  297. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h +25 -0
  298. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +28 -0
  299. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +112 -0
  300. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/hard_swish.h +30 -0
  301. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +86 -0
  302. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +150 -0
  303. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/leaky_relu.h +43 -0
  304. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logical.h +35 -0
  305. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logistic.h +42 -0
  306. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval.h +541 -0
  307. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval_test.h +817 -0
  308. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_shared.h +150 -0
  309. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +158 -0
  310. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_tensor_utils.h +56 -0
  311. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +74 -0
  312. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pad.h +27 -0
  313. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +142 -0
  314. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/prelu.h +39 -0
  315. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/quantize.h +37 -0
  316. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +65 -0
  317. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
  318. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +67 -0
  319. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
  320. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/sub.h +60 -0
  321. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +100 -0
  322. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/conv_test_data.h +37 -0
  323. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/lstm_test_data.h +579 -0
  324. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +47 -0
  325. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h +139 -0
  326. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_eval.h +216 -0
  327. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_shared.h +78 -0
  328. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +38 -0
  329. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_add.h +48 -0
  330. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +89 -0
  331. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +74 -0
  332. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_fully_connected.h +78 -0
  333. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pad.h +49 -0
  334. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pooling.h +76 -0
  335. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reduce.h +47 -0
  336. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +44 -0
  337. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +58 -0
  338. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h +39 -0
  339. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_helpers.h +64 -0
  340. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +170 -0
  341. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +53 -0
  342. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/memory_plan_struct.h +73 -0
  343. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +95 -0
  344. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +133 -0
  345. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocation_info.h +138 -0
  346. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +351 -0
  347. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_arena_constants.h +28 -0
  348. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
  349. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +176 -0
  350. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +79 -0
  351. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +189 -0
  352. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
  353. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
  354. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +42 -0
  355. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +708 -0
  356. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +62 -0
  357. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +140 -0
  358. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler_interface.h +38 -0
  359. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_resource_variable.h +89 -0
  360. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_time.h +36 -0
  361. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_utils.h +162 -0
  362. xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +60 -0
  363. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
  364. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size.h +30 -0
  365. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size_wrapper.h +33 -0
  366. xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_allocator.h +125 -0
  367. xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_interpreter.h +69 -0
  368. xmos_ai_tools/runtime/include/tensorflow/lite/micro/system_setup.h +27 -0
  369. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +49 -0
  370. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +334 -0
  371. xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +267 -0
  372. xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/test_conv_model.h +23 -0
  373. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h +45 -0
  374. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h +36 -0
  375. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
  376. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
  377. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
  378. xmos_ai_tools/runtime/include/tensorflow/lite/portable_type_to_tflitetype.h +75 -0
  379. xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +24644 -0
  380. xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_utils.h +33 -0
  381. xmos_ai_tools/runtime/include/tile_ram_server.h +38 -0
  382. xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
  383. xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
  384. xmos_ai_tools/xformer/__init__.py +60 -0
  385. xmos_ai_tools/xformer/flash.py +190 -0
  386. xmos_ai_tools/xinterpreters/__init__.py +1 -0
  387. xmos_ai_tools/xinterpreters/exceptions.py +38 -0
  388. xmos_ai_tools/xinterpreters/host_interpreter.py +652 -0
  389. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
  390. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
  391. xmos_ai_tools-1.3.2.dev80.data/data/bin/xcore-opt +0 -0
  392. xmos_ai_tools-1.3.2.dev80.dist-info/METADATA +33 -0
  393. xmos_ai_tools-1.3.2.dev80.dist-info/RECORD +395 -0
  394. xmos_ai_tools-1.3.2.dev80.dist-info/WHEEL +5 -0
  395. xmos_ai_tools-1.3.2.dev80.dist-info/top_level.txt +1 -0
@@ -0,0 +1,690 @@
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_UTIL_H_
18
+ #define FLATBUFFERS_UTIL_H_
19
+
20
+ #include <ctype.h>
21
+ #include <errno.h>
22
+
23
+ #include "flatbuffers/base.h"
24
+ #include "flatbuffers/stl_emulation.h"
25
+
26
+ #ifndef FLATBUFFERS_PREFER_PRINTF
27
+ # include <iomanip>
28
+ # include <sstream>
29
+ #else // FLATBUFFERS_PREFER_PRINTF
30
+ # include <float.h>
31
+ # include <stdio.h>
32
+ #endif // FLATBUFFERS_PREFER_PRINTF
33
+
34
+ #include <string>
35
+
36
+ namespace flatbuffers {
37
+
38
+ // @locale-independent functions for ASCII characters set.
39
+
40
+ // Fast checking that character lies in closed range: [a <= x <= b]
41
+ // using one compare (conditional branch) operator.
42
+ inline bool check_ascii_range(char x, char a, char b) {
43
+ FLATBUFFERS_ASSERT(a <= b);
44
+ // (Hacker's Delight): `a <= x <= b` <=> `(x-a) <={u} (b-a)`.
45
+ // The x, a, b will be promoted to int and subtracted without overflow.
46
+ return static_cast<unsigned int>(x - a) <= static_cast<unsigned int>(b - a);
47
+ }
48
+
49
+ // Case-insensitive isalpha
50
+ inline bool is_alpha(char c) {
51
+ // ASCII only: alpha to upper case => reset bit 0x20 (~0x20 = 0xDF).
52
+ return check_ascii_range(c & 0xDF, 'a' & 0xDF, 'z' & 0xDF);
53
+ }
54
+
55
+ // Check for uppercase alpha
56
+ inline bool is_alpha_upper(char c) { return check_ascii_range(c, 'A', 'Z'); }
57
+
58
+ // Check (case-insensitive) that `c` is equal to alpha.
59
+ inline bool is_alpha_char(char c, char alpha) {
60
+ FLATBUFFERS_ASSERT(is_alpha(alpha));
61
+ // ASCII only: alpha to upper case => reset bit 0x20 (~0x20 = 0xDF).
62
+ return ((c & 0xDF) == (alpha & 0xDF));
63
+ }
64
+
65
+ // https://en.cppreference.com/w/cpp/string/byte/isxdigit
66
+ // isdigit and isxdigit are the only standard narrow character classification
67
+ // functions that are not affected by the currently installed C locale. although
68
+ // some implementations (e.g. Microsoft in 1252 codepage) may classify
69
+ // additional single-byte characters as digits.
70
+ inline bool is_digit(char c) { return check_ascii_range(c, '0', '9'); }
71
+
72
+ inline bool is_xdigit(char c) {
73
+ // Replace by look-up table.
74
+ return is_digit(c) || check_ascii_range(c & 0xDF, 'a' & 0xDF, 'f' & 0xDF);
75
+ }
76
+
77
+ // Case-insensitive isalnum
78
+ inline bool is_alnum(char c) { return is_alpha(c) || is_digit(c); }
79
+
80
+ inline char CharToUpper(char c) {
81
+ return static_cast<char>(::toupper(static_cast<unsigned char>(c)));
82
+ }
83
+
84
+ inline char CharToLower(char c) {
85
+ return static_cast<char>(::tolower(static_cast<unsigned char>(c)));
86
+ }
87
+
88
+ // @end-locale-independent functions for ASCII character set
89
+
90
+ #ifdef FLATBUFFERS_PREFER_PRINTF
91
+ template<typename T> size_t IntToDigitCount(T t) {
92
+ size_t digit_count = 0;
93
+ // Count the sign for negative numbers
94
+ if (t < 0) digit_count++;
95
+ // Count a single 0 left of the dot for fractional numbers
96
+ if (-1 < t && t < 1) digit_count++;
97
+ // Count digits until fractional part
98
+ T eps = std::numeric_limits<T>::epsilon();
99
+ while (t <= (-1 + eps) || (1 - eps) <= t) {
100
+ t /= 10;
101
+ digit_count++;
102
+ }
103
+ return digit_count;
104
+ }
105
+
106
+ template<typename T> size_t NumToStringWidth(T t, int precision = 0) {
107
+ size_t string_width = IntToDigitCount(t);
108
+ // Count the dot for floating point numbers
109
+ if (precision) string_width += (precision + 1);
110
+ return string_width;
111
+ }
112
+
113
+ template<typename T>
114
+ std::string NumToStringImplWrapper(T t, const char *fmt, int precision = 0) {
115
+ size_t string_width = NumToStringWidth(t, precision);
116
+ std::string s(string_width, 0x00);
117
+ // Allow snprintf to use std::string trailing null to detect buffer overflow
118
+ snprintf(const_cast<char *>(s.data()), (s.size() + 1), fmt, string_width, t);
119
+ return s;
120
+ }
121
+ #endif // FLATBUFFERS_PREFER_PRINTF
122
+
123
+ // Convert an integer or floating point value to a string.
124
+ // In contrast to std::stringstream, "char" values are
125
+ // converted to a string of digits, and we don't use scientific notation.
126
+ template<typename T> std::string NumToString(T t) {
127
+ // clang-format off
128
+
129
+ #ifndef FLATBUFFERS_PREFER_PRINTF
130
+ std::stringstream ss;
131
+ ss << t;
132
+ return ss.str();
133
+ #else // FLATBUFFERS_PREFER_PRINTF
134
+ auto v = static_cast<long long>(t);
135
+ return NumToStringImplWrapper(v, "%.*lld");
136
+ #endif // FLATBUFFERS_PREFER_PRINTF
137
+ // clang-format on
138
+ }
139
+ // Avoid char types used as character data.
140
+ template<> inline std::string NumToString<signed char>(signed char t) {
141
+ return NumToString(static_cast<int>(t));
142
+ }
143
+ template<> inline std::string NumToString<unsigned char>(unsigned char t) {
144
+ return NumToString(static_cast<int>(t));
145
+ }
146
+ template<> inline std::string NumToString<char>(char t) {
147
+ return NumToString(static_cast<int>(t));
148
+ }
149
+
150
+ // Special versions for floats/doubles.
151
+ template<typename T> std::string FloatToString(T t, int precision) {
152
+ // clang-format off
153
+
154
+ #ifndef FLATBUFFERS_PREFER_PRINTF
155
+ // to_string() prints different numbers of digits for floats depending on
156
+ // platform and isn't available on Android, so we use stringstream
157
+ std::stringstream ss;
158
+ // Use std::fixed to suppress scientific notation.
159
+ ss << std::fixed;
160
+ // Default precision is 6, we want that to be higher for doubles.
161
+ ss << std::setprecision(precision);
162
+ ss << t;
163
+ auto s = ss.str();
164
+ #else // FLATBUFFERS_PREFER_PRINTF
165
+ auto v = static_cast<double>(t);
166
+ auto s = NumToStringImplWrapper(v, "%0.*f", precision);
167
+ #endif // FLATBUFFERS_PREFER_PRINTF
168
+ // clang-format on
169
+ // Sadly, std::fixed turns "1" into "1.00000", so here we undo that.
170
+ auto p = s.find_last_not_of('0');
171
+ if (p != std::string::npos) {
172
+ // Strip trailing zeroes. If it is a whole number, keep one zero.
173
+ s.resize(p + (s[p] == '.' ? 2 : 1));
174
+ }
175
+ return s;
176
+ }
177
+
178
+ template<> inline std::string NumToString<double>(double t) {
179
+ return FloatToString(t, 12);
180
+ }
181
+ template<> inline std::string NumToString<float>(float t) {
182
+ return FloatToString(t, 6);
183
+ }
184
+
185
+ // Convert an integer value to a hexadecimal string.
186
+ // The returned string length is always xdigits long, prefixed by 0 digits.
187
+ // For example, IntToStringHex(0x23, 8) returns the string "00000023".
188
+ inline std::string IntToStringHex(int i, int xdigits) {
189
+ FLATBUFFERS_ASSERT(i >= 0);
190
+ // clang-format off
191
+
192
+ #ifndef FLATBUFFERS_PREFER_PRINTF
193
+ std::stringstream ss;
194
+ ss << std::setw(xdigits) << std::setfill('0') << std::hex << std::uppercase
195
+ << i;
196
+ return ss.str();
197
+ #else // FLATBUFFERS_PREFER_PRINTF
198
+ return NumToStringImplWrapper(i, "%.*X", xdigits);
199
+ #endif // FLATBUFFERS_PREFER_PRINTF
200
+ // clang-format on
201
+ }
202
+
203
+ // clang-format off
204
+ // Use locale independent functions {strtod_l, strtof_l, strtoll_l, strtoull_l}.
205
+ #if defined(FLATBUFFERS_LOCALE_INDEPENDENT) && (FLATBUFFERS_LOCALE_INDEPENDENT > 0)
206
+ class ClassicLocale {
207
+ #ifdef _MSC_VER
208
+ typedef _locale_t locale_type;
209
+ #else
210
+ typedef locale_t locale_type; // POSIX.1-2008 locale_t type
211
+ #endif
212
+ ClassicLocale();
213
+ ~ClassicLocale();
214
+ locale_type locale_;
215
+ static ClassicLocale instance_;
216
+ public:
217
+ static locale_type Get() { return instance_.locale_; }
218
+ };
219
+
220
+ #ifdef _MSC_VER
221
+ #define __strtoull_impl(s, pe, b) _strtoui64_l(s, pe, b, ClassicLocale::Get())
222
+ #define __strtoll_impl(s, pe, b) _strtoi64_l(s, pe, b, ClassicLocale::Get())
223
+ #define __strtod_impl(s, pe) _strtod_l(s, pe, ClassicLocale::Get())
224
+ #define __strtof_impl(s, pe) _strtof_l(s, pe, ClassicLocale::Get())
225
+ #else
226
+ #define __strtoull_impl(s, pe, b) strtoull_l(s, pe, b, ClassicLocale::Get())
227
+ #define __strtoll_impl(s, pe, b) strtoll_l(s, pe, b, ClassicLocale::Get())
228
+ #define __strtod_impl(s, pe) strtod_l(s, pe, ClassicLocale::Get())
229
+ #define __strtof_impl(s, pe) strtof_l(s, pe, ClassicLocale::Get())
230
+ #endif
231
+ #else
232
+ #define __strtod_impl(s, pe) strtod(s, pe)
233
+ #define __strtof_impl(s, pe) static_cast<float>(strtod(s, pe))
234
+ #ifdef _MSC_VER
235
+ #define __strtoull_impl(s, pe, b) _strtoui64(s, pe, b)
236
+ #define __strtoll_impl(s, pe, b) _strtoi64(s, pe, b)
237
+ #else
238
+ #define __strtoull_impl(s, pe, b) strtoull(s, pe, b)
239
+ #define __strtoll_impl(s, pe, b) strtoll(s, pe, b)
240
+ #endif
241
+ #endif
242
+
243
+ inline void strtoval_impl(int64_t *val, const char *str, char **endptr,
244
+ int base) {
245
+ *val = __strtoll_impl(str, endptr, base);
246
+ }
247
+
248
+ inline void strtoval_impl(uint64_t *val, const char *str, char **endptr,
249
+ int base) {
250
+ *val = __strtoull_impl(str, endptr, base);
251
+ }
252
+
253
+ inline void strtoval_impl(double *val, const char *str, char **endptr) {
254
+ *val = __strtod_impl(str, endptr);
255
+ }
256
+
257
+ // UBSAN: double to float is safe if numeric_limits<float>::is_iec559 is true.
258
+ __supress_ubsan__("float-cast-overflow")
259
+ inline void strtoval_impl(float *val, const char *str, char **endptr) {
260
+ *val = __strtof_impl(str, endptr);
261
+ }
262
+ #undef __strtoull_impl
263
+ #undef __strtoll_impl
264
+ #undef __strtod_impl
265
+ #undef __strtof_impl
266
+ // clang-format on
267
+
268
+ // Adaptor for strtoull()/strtoll().
269
+ // Flatbuffers accepts numbers with any count of leading zeros (-009 is -9),
270
+ // while strtoll with base=0 interprets first leading zero as octal prefix.
271
+ // In future, it is possible to add prefixed 0b0101.
272
+ // 1) Checks errno code for overflow condition (out of range).
273
+ // 2) If base <= 0, function try to detect base of number by prefix.
274
+ //
275
+ // Return value (like strtoull and strtoll, but reject partial result):
276
+ // - If successful, an integer value corresponding to the str is returned.
277
+ // - If full string conversion can't be performed, 0 is returned.
278
+ // - If the converted value falls out of range of corresponding return type, a
279
+ // range error occurs. In this case value MAX(T)/MIN(T) is returned.
280
+ template<typename T>
281
+ inline bool StringToIntegerImpl(T *val, const char *const str,
282
+ const int base = 0,
283
+ const bool check_errno = true) {
284
+ // T is int64_t or uint64_T
285
+ FLATBUFFERS_ASSERT(str);
286
+ if (base <= 0) {
287
+ auto s = str;
288
+ while (*s && !is_digit(*s)) s++;
289
+ if (s[0] == '0' && is_alpha_char(s[1], 'X'))
290
+ return StringToIntegerImpl(val, str, 16, check_errno);
291
+ // if a prefix not match, try base=10
292
+ return StringToIntegerImpl(val, str, 10, check_errno);
293
+ } else {
294
+ if (check_errno) errno = 0; // clear thread-local errno
295
+ auto endptr = str;
296
+ strtoval_impl(val, str, const_cast<char **>(&endptr), base);
297
+ if ((*endptr != '\0') || (endptr == str)) {
298
+ *val = 0; // erase partial result
299
+ return false; // invalid string
300
+ }
301
+ // errno is out-of-range, return MAX/MIN
302
+ if (check_errno && errno) return false;
303
+ return true;
304
+ }
305
+ }
306
+
307
+ template<typename T>
308
+ inline bool StringToFloatImpl(T *val, const char *const str) {
309
+ // Type T must be either float or double.
310
+ FLATBUFFERS_ASSERT(str && val);
311
+ auto end = str;
312
+ strtoval_impl(val, str, const_cast<char **>(&end));
313
+ auto done = (end != str) && (*end == '\0');
314
+ if (!done) *val = 0; // erase partial result
315
+ return done;
316
+ }
317
+
318
+ // Convert a string to an instance of T.
319
+ // Return value (matched with StringToInteger64Impl and strtod):
320
+ // - If successful, a numeric value corresponding to the str is returned.
321
+ // - If full string conversion can't be performed, 0 is returned.
322
+ // - If the converted value falls out of range of corresponding return type, a
323
+ // range error occurs. In this case value MAX(T)/MIN(T) is returned.
324
+ template<typename T> inline bool StringToNumber(const char *s, T *val) {
325
+ // Assert on `unsigned long` and `signed long` on LP64.
326
+ // If it is necessary, it could be solved with flatbuffers::enable_if<B,T>.
327
+ static_assert(sizeof(T) < sizeof(int64_t), "unexpected type T");
328
+ FLATBUFFERS_ASSERT(s && val);
329
+ int64_t i64;
330
+ // The errno check isn't needed, will return MAX/MIN on overflow.
331
+ if (StringToIntegerImpl(&i64, s, 0, false)) {
332
+ const int64_t max = (flatbuffers::numeric_limits<T>::max)();
333
+ const int64_t min = flatbuffers::numeric_limits<T>::lowest();
334
+ if (i64 > max) {
335
+ *val = static_cast<T>(max);
336
+ return false;
337
+ }
338
+ if (i64 < min) {
339
+ // For unsigned types return max to distinguish from
340
+ // "no conversion can be performed" when 0 is returned.
341
+ *val = static_cast<T>(flatbuffers::is_unsigned<T>::value ? max : min);
342
+ return false;
343
+ }
344
+ *val = static_cast<T>(i64);
345
+ return true;
346
+ }
347
+ *val = 0;
348
+ return false;
349
+ }
350
+
351
+ template<> inline bool StringToNumber<int64_t>(const char *str, int64_t *val) {
352
+ return StringToIntegerImpl(val, str);
353
+ }
354
+
355
+ template<>
356
+ inline bool StringToNumber<uint64_t>(const char *str, uint64_t *val) {
357
+ if (!StringToIntegerImpl(val, str)) return false;
358
+ // The strtoull accepts negative numbers:
359
+ // If the minus sign was part of the input sequence, the numeric value
360
+ // calculated from the sequence of digits is negated as if by unary minus
361
+ // in the result type, which applies unsigned integer wraparound rules.
362
+ // Fix this behaviour (except -0).
363
+ if (*val) {
364
+ auto s = str;
365
+ while (*s && !is_digit(*s)) s++;
366
+ s = (s > str) ? (s - 1) : s; // step back to one symbol
367
+ if (*s == '-') {
368
+ // For unsigned types return the max to distinguish from
369
+ // "no conversion can be performed".
370
+ *val = (flatbuffers::numeric_limits<uint64_t>::max)();
371
+ return false;
372
+ }
373
+ }
374
+ return true;
375
+ }
376
+
377
+ template<> inline bool StringToNumber(const char *s, float *val) {
378
+ return StringToFloatImpl(val, s);
379
+ }
380
+
381
+ template<> inline bool StringToNumber(const char *s, double *val) {
382
+ return StringToFloatImpl(val, s);
383
+ }
384
+
385
+ inline int64_t StringToInt(const char *s, int base = 10) {
386
+ int64_t val;
387
+ return StringToIntegerImpl(&val, s, base) ? val : 0;
388
+ }
389
+
390
+ inline uint64_t StringToUInt(const char *s, int base = 10) {
391
+ uint64_t val;
392
+ return StringToIntegerImpl(&val, s, base) ? val : 0;
393
+ }
394
+
395
+ typedef bool (*LoadFileFunction)(const char *filename, bool binary,
396
+ std::string *dest);
397
+ typedef bool (*FileExistsFunction)(const char *filename);
398
+
399
+ LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function);
400
+
401
+ FileExistsFunction SetFileExistsFunction(
402
+ FileExistsFunction file_exists_function);
403
+
404
+ // Check if file "name" exists.
405
+ bool FileExists(const char *name);
406
+
407
+ // Check if "name" exists and it is also a directory.
408
+ bool DirExists(const char *name);
409
+
410
+ // Load file "name" into "buf" returning true if successful
411
+ // false otherwise. If "binary" is false data is read
412
+ // using ifstream's text mode, otherwise data is read with
413
+ // no transcoding.
414
+ bool LoadFile(const char *name, bool binary, std::string *buf);
415
+
416
+ // Save data "buf" of length "len" bytes into a file
417
+ // "name" returning true if successful, false otherwise.
418
+ // If "binary" is false data is written using ifstream's
419
+ // text mode, otherwise data is written with no
420
+ // transcoding.
421
+ bool SaveFile(const char *name, const char *buf, size_t len, bool binary);
422
+
423
+ // Save data "buf" into file "name" returning true if
424
+ // successful, false otherwise. If "binary" is false
425
+ // data is written using ifstream's text mode, otherwise
426
+ // data is written with no transcoding.
427
+ inline bool SaveFile(const char *name, const std::string &buf, bool binary) {
428
+ return SaveFile(name, buf.c_str(), buf.size(), binary);
429
+ }
430
+
431
+ // Functionality for minimalistic portable path handling.
432
+
433
+ // The functions below behave correctly regardless of whether posix ('/') or
434
+ // Windows ('/' or '\\') separators are used.
435
+
436
+ // Any new separators inserted are always posix.
437
+ FLATBUFFERS_CONSTEXPR char kPathSeparator = '/';
438
+
439
+ // Returns the path with the extension, if any, removed.
440
+ std::string StripExtension(const std::string &filepath);
441
+
442
+ // Returns the extension, if any.
443
+ std::string GetExtension(const std::string &filepath);
444
+
445
+ // Return the last component of the path, after the last separator.
446
+ std::string StripPath(const std::string &filepath);
447
+
448
+ // Strip the last component of the path + separator.
449
+ std::string StripFileName(const std::string &filepath);
450
+
451
+ // Concatenates a path with a filename, regardless of whether the path
452
+ // ends in a separator or not.
453
+ std::string ConCatPathFileName(const std::string &path,
454
+ const std::string &filename);
455
+
456
+ // Replaces any '\\' separators with '/'
457
+ std::string PosixPath(const char *path);
458
+ std::string PosixPath(const std::string &path);
459
+
460
+ // This function ensure a directory exists, by recursively
461
+ // creating dirs for any parts of the path that don't exist yet.
462
+ void EnsureDirExists(const std::string &filepath);
463
+
464
+ // Obtains the absolute path from any other path.
465
+ // Returns the input path if the absolute path couldn't be resolved.
466
+ std::string AbsolutePath(const std::string &filepath);
467
+
468
+ // Returns files relative to the --project_root path, prefixed with `//`.
469
+ std::string RelativeToRootPath(const std::string &project,
470
+ const std::string &filepath);
471
+
472
+ // To and from UTF-8 unicode conversion functions
473
+
474
+ // Convert a unicode code point into a UTF-8 representation by appending it
475
+ // to a string. Returns the number of bytes generated.
476
+ inline int ToUTF8(uint32_t ucc, std::string *out) {
477
+ FLATBUFFERS_ASSERT(!(ucc & 0x80000000)); // Top bit can't be set.
478
+ // 6 possible encodings: http://en.wikipedia.org/wiki/UTF-8
479
+ for (int i = 0; i < 6; i++) {
480
+ // Max bits this encoding can represent.
481
+ uint32_t max_bits = 6 + i * 5 + static_cast<int>(!i);
482
+ if (ucc < (1u << max_bits)) { // does it fit?
483
+ // Remaining bits not encoded in the first byte, store 6 bits each
484
+ uint32_t remain_bits = i * 6;
485
+ // Store first byte:
486
+ (*out) += static_cast<char>((0xFE << (max_bits - remain_bits)) |
487
+ (ucc >> remain_bits));
488
+ // Store remaining bytes:
489
+ for (int j = i - 1; j >= 0; j--) {
490
+ (*out) += static_cast<char>(((ucc >> (j * 6)) & 0x3F) | 0x80);
491
+ }
492
+ return i + 1; // Return the number of bytes added.
493
+ }
494
+ }
495
+ FLATBUFFERS_ASSERT(0); // Impossible to arrive here.
496
+ return -1;
497
+ }
498
+
499
+ // Converts whatever prefix of the incoming string corresponds to a valid
500
+ // UTF-8 sequence into a unicode code. The incoming pointer will have been
501
+ // advanced past all bytes parsed.
502
+ // returns -1 upon corrupt UTF-8 encoding (ignore the incoming pointer in
503
+ // this case).
504
+ inline int FromUTF8(const char **in) {
505
+ int len = 0;
506
+ // Count leading 1 bits.
507
+ for (int mask = 0x80; mask >= 0x04; mask >>= 1) {
508
+ if (**in & mask) {
509
+ len++;
510
+ } else {
511
+ break;
512
+ }
513
+ }
514
+ if ((static_cast<unsigned char>(**in) << len) & 0x80)
515
+ return -1; // Bit after leading 1's must be 0.
516
+ if (!len) return *(*in)++;
517
+ // UTF-8 encoded values with a length are between 2 and 4 bytes.
518
+ if (len < 2 || len > 4) { return -1; }
519
+ // Grab initial bits of the code.
520
+ int ucc = *(*in)++ & ((1 << (7 - len)) - 1);
521
+ for (int i = 0; i < len - 1; i++) {
522
+ if ((**in & 0xC0) != 0x80) return -1; // Upper bits must 1 0.
523
+ ucc <<= 6;
524
+ ucc |= *(*in)++ & 0x3F; // Grab 6 more bits of the code.
525
+ }
526
+ // UTF-8 cannot encode values between 0xD800 and 0xDFFF (reserved for
527
+ // UTF-16 surrogate pairs).
528
+ if (ucc >= 0xD800 && ucc <= 0xDFFF) { return -1; }
529
+ // UTF-8 must represent code points in their shortest possible encoding.
530
+ switch (len) {
531
+ case 2:
532
+ // Two bytes of UTF-8 can represent code points from U+0080 to U+07FF.
533
+ if (ucc < 0x0080 || ucc > 0x07FF) { return -1; }
534
+ break;
535
+ case 3:
536
+ // Three bytes of UTF-8 can represent code points from U+0800 to U+FFFF.
537
+ if (ucc < 0x0800 || ucc > 0xFFFF) { return -1; }
538
+ break;
539
+ case 4:
540
+ // Four bytes of UTF-8 can represent code points from U+10000 to U+10FFFF.
541
+ if (ucc < 0x10000 || ucc > 0x10FFFF) { return -1; }
542
+ break;
543
+ }
544
+ return ucc;
545
+ }
546
+
547
+ #ifndef FLATBUFFERS_PREFER_PRINTF
548
+ // Wraps a string to a maximum length, inserting new lines where necessary. Any
549
+ // existing whitespace will be collapsed down to a single space. A prefix or
550
+ // suffix can be provided, which will be inserted before or after a wrapped
551
+ // line, respectively.
552
+ inline std::string WordWrap(const std::string in, size_t max_length,
553
+ const std::string wrapped_line_prefix,
554
+ const std::string wrapped_line_suffix) {
555
+ std::istringstream in_stream(in);
556
+ std::string wrapped, line, word;
557
+
558
+ in_stream >> word;
559
+ line = word;
560
+
561
+ while (in_stream >> word) {
562
+ if ((line.length() + 1 + word.length() + wrapped_line_suffix.length()) <
563
+ max_length) {
564
+ line += " " + word;
565
+ } else {
566
+ wrapped += line + wrapped_line_suffix + "\n";
567
+ line = wrapped_line_prefix + word;
568
+ }
569
+ }
570
+ wrapped += line;
571
+
572
+ return wrapped;
573
+ }
574
+ #endif // !FLATBUFFERS_PREFER_PRINTF
575
+
576
+ inline bool EscapeString(const char *s, size_t length, std::string *_text,
577
+ bool allow_non_utf8, bool natural_utf8) {
578
+ std::string &text = *_text;
579
+ text += "\"";
580
+ for (uoffset_t i = 0; i < length; i++) {
581
+ char c = s[i];
582
+ switch (c) {
583
+ case '\n': text += "\\n"; break;
584
+ case '\t': text += "\\t"; break;
585
+ case '\r': text += "\\r"; break;
586
+ case '\b': text += "\\b"; break;
587
+ case '\f': text += "\\f"; break;
588
+ case '\"': text += "\\\""; break;
589
+ case '\\': text += "\\\\"; break;
590
+ default:
591
+ if (c >= ' ' && c <= '~') {
592
+ text += c;
593
+ } else {
594
+ // Not printable ASCII data. Let's see if it's valid UTF-8 first:
595
+ const char *utf8 = s + i;
596
+ int ucc = FromUTF8(&utf8);
597
+ if (ucc < 0) {
598
+ if (allow_non_utf8) {
599
+ text += "\\x";
600
+ text += IntToStringHex(static_cast<uint8_t>(c), 2);
601
+ } else {
602
+ // There are two cases here:
603
+ //
604
+ // 1) We reached here by parsing an IDL file. In that case,
605
+ // we previously checked for non-UTF-8, so we shouldn't reach
606
+ // here.
607
+ //
608
+ // 2) We reached here by someone calling GenerateText()
609
+ // on a previously-serialized flatbuffer. The data might have
610
+ // non-UTF-8 Strings, or might be corrupt.
611
+ //
612
+ // In both cases, we have to give up and inform the caller
613
+ // they have no JSON.
614
+ return false;
615
+ }
616
+ } else {
617
+ if (natural_utf8) {
618
+ // utf8 points to past all utf-8 bytes parsed
619
+ text.append(s + i, static_cast<size_t>(utf8 - s - i));
620
+ } else if (ucc <= 0xFFFF) {
621
+ // Parses as Unicode within JSON's \uXXXX range, so use that.
622
+ text += "\\u";
623
+ text += IntToStringHex(ucc, 4);
624
+ } else if (ucc <= 0x10FFFF) {
625
+ // Encode Unicode SMP values to a surrogate pair using two \u
626
+ // escapes.
627
+ uint32_t base = ucc - 0x10000;
628
+ auto high_surrogate = (base >> 10) + 0xD800;
629
+ auto low_surrogate = (base & 0x03FF) + 0xDC00;
630
+ text += "\\u";
631
+ text += IntToStringHex(high_surrogate, 4);
632
+ text += "\\u";
633
+ text += IntToStringHex(low_surrogate, 4);
634
+ }
635
+ // Skip past characters recognized.
636
+ i = static_cast<uoffset_t>(utf8 - s - 1);
637
+ }
638
+ }
639
+ break;
640
+ }
641
+ }
642
+ text += "\"";
643
+ return true;
644
+ }
645
+
646
+ inline std::string BufferToHexText(const void *buffer, size_t buffer_size,
647
+ size_t max_length,
648
+ const std::string &wrapped_line_prefix,
649
+ const std::string &wrapped_line_suffix) {
650
+ std::string text = wrapped_line_prefix;
651
+ size_t start_offset = 0;
652
+ const char *s = reinterpret_cast<const char *>(buffer);
653
+ for (size_t i = 0; s && i < buffer_size; i++) {
654
+ // Last iteration or do we have more?
655
+ bool have_more = i + 1 < buffer_size;
656
+ text += "0x";
657
+ text += IntToStringHex(static_cast<uint8_t>(s[i]), 2);
658
+ if (have_more) { text += ','; }
659
+ // If we have more to process and we reached max_length
660
+ if (have_more &&
661
+ text.size() + wrapped_line_suffix.size() >= start_offset + max_length) {
662
+ text += wrapped_line_suffix;
663
+ text += '\n';
664
+ start_offset = text.size();
665
+ text += wrapped_line_prefix;
666
+ }
667
+ }
668
+ text += wrapped_line_suffix;
669
+ return text;
670
+ }
671
+
672
+ // Remove paired quotes in a string: "text"|'text' -> text.
673
+ std::string RemoveStringQuotes(const std::string &s);
674
+
675
+ // Change th global C-locale to locale with name <locale_name>.
676
+ // Returns an actual locale name in <_value>, useful if locale_name is "" or
677
+ // null.
678
+ bool SetGlobalTestLocale(const char *locale_name,
679
+ std::string *_value = nullptr);
680
+
681
+ // Read (or test) a value of environment variable.
682
+ bool ReadEnvironmentVariable(const char *var_name,
683
+ std::string *_value = nullptr);
684
+
685
+ // MSVC specific: Send all assert reports to STDOUT to prevent CI hangs.
686
+ void SetupDefaultCRTReportMode();
687
+
688
+ } // namespace flatbuffers
689
+
690
+ #endif // FLATBUFFERS_UTIL_H_