pw_channel: Rework inheritance to avoid SiblingCast

Change pw_channel to a new inheritance pattern that places AnyChannel in
the middle of the hierarchy. The various Channel API classes are private
empty bases of AnyChannel. This ensures conversions between compatible
Channel variants are valid, since all channel implementations have all
channel variants as bases. Channel implementations extend a ChannelImpl
with properties specified in template parameters, and unsupported
functions are automatically disabled.

This change also refactors and simplifies the channel.h header.
Properties and code for checking them are moved to a properties.h
header. Also, the macros to generate ChannelImpl specializations are
greatly simplified.

Change-Id: Ib48bca41ec63ac107bf703b2102f03e9d6cd0347
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/247732
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Taylor Cramer <cramertj@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
21 files changed
tree: 08b6baf5cd65d6b75ffdbf70cef4953077de60fe
  1. .allstar/
  2. .github/
  3. .vscode/
  4. build_overrides/
  5. docker/
  6. docs/
  7. kudzu/
  8. pw_alignment/
  9. pw_allocator/
  10. pw_analog/
  11. pw_android_toolchain/
  12. pw_arduino_build/
  13. pw_assert/
  14. pw_assert_basic/
  15. pw_assert_fuchsia/
  16. pw_assert_log/
  17. pw_assert_tokenized/
  18. pw_assert_trap/
  19. pw_assert_zephyr/
  20. pw_async/
  21. pw_async2/
  22. pw_async2_basic/
  23. pw_async2_epoll/
  24. pw_async_basic/
  25. pw_async_fuchsia/
  26. pw_base64/
  27. pw_bloat/
  28. pw_blob_store/
  29. pw_bluetooth/
  30. pw_bluetooth_hci/
  31. pw_bluetooth_profiles/
  32. pw_bluetooth_proxy/
  33. pw_bluetooth_sapphire/
  34. pw_boot/
  35. pw_boot_cortex_m/
  36. pw_build/
  37. pw_build_android/
  38. pw_build_info/
  39. pw_build_mcuxpresso/
  40. pw_bytes/
  41. pw_channel/
  42. pw_checksum/
  43. pw_chre/
  44. pw_chrono/
  45. pw_chrono_embos/
  46. pw_chrono_freertos/
  47. pw_chrono_rp2040/
  48. pw_chrono_stl/
  49. pw_chrono_threadx/
  50. pw_chrono_zephyr/
  51. pw_cli/
  52. pw_cli_analytics/
  53. pw_clock_tree/
  54. pw_clock_tree_mcuxpresso/
  55. pw_compilation_testing/
  56. pw_config_loader/
  57. pw_console/
  58. pw_containers/
  59. pw_cpu_exception/
  60. pw_cpu_exception_cortex_m/
  61. pw_cpu_exception_risc_v/
  62. pw_crypto/
  63. pw_digital_io/
  64. pw_digital_io_linux/
  65. pw_digital_io_mcuxpresso/
  66. pw_digital_io_rp2040/
  67. pw_display/
  68. pw_dma_mcuxpresso/
  69. pw_docgen/
  70. pw_doctor/
  71. pw_emu/
  72. pw_env_setup/
  73. pw_env_setup_zephyr/
  74. pw_file/
  75. pw_format/
  76. pw_function/
  77. pw_fuzzer/
  78. pw_grpc/
  79. pw_hdlc/
  80. pw_hex_dump/
  81. pw_i2c/
  82. pw_i2c_linux/
  83. pw_i2c_mcuxpresso/
  84. pw_i2c_rp2040/
  85. pw_ide/
  86. pw_interrupt/
  87. pw_interrupt_cortex_m/
  88. pw_interrupt_xtensa/
  89. pw_interrupt_zephyr/
  90. pw_intrusive_ptr/
  91. pw_json/
  92. pw_kvs/
  93. pw_libc/
  94. pw_libcxx/
  95. pw_log/
  96. pw_log_android/
  97. pw_log_basic/
  98. pw_log_fuchsia/
  99. pw_log_null/
  100. pw_log_rpc/
  101. pw_log_string/
  102. pw_log_tokenized/
  103. pw_log_zephyr/
  104. pw_malloc/
  105. pw_malloc_freelist/
  106. pw_malloc_freertos/
  107. pw_metric/
  108. pw_minimal_cpp_stdlib/
  109. pw_module/
  110. pw_multibuf/
  111. pw_multisink/
  112. pw_numeric/
  113. pw_package/
  114. pw_perf_test/
  115. pw_persistent_ram/
  116. pw_polyfill/
  117. pw_preprocessor/
  118. pw_presubmit/
  119. pw_protobuf/
  120. pw_protobuf_compiler/
  121. pw_random/
  122. pw_random_fuchsia/
  123. pw_result/
  124. pw_ring_buffer/
  125. pw_router/
  126. pw_rpc/
  127. pw_rpc_transport/
  128. pw_rust/
  129. pw_sensor/
  130. pw_snapshot/
  131. pw_software_update/
  132. pw_span/
  133. pw_spi/
  134. pw_spi_linux/
  135. pw_spi_mcuxpresso/
  136. pw_spi_rp2040/
  137. pw_status/
  138. pw_stm32cube_build/
  139. pw_stream/
  140. pw_stream_shmem_mcuxpresso/
  141. pw_stream_uart_linux/
  142. pw_stream_uart_mcuxpresso/
  143. pw_string/
  144. pw_symbolizer/
  145. pw_sync/
  146. pw_sync_baremetal/
  147. pw_sync_embos/
  148. pw_sync_freertos/
  149. pw_sync_stl/
  150. pw_sync_threadx/
  151. pw_sync_zephyr/
  152. pw_sys_io/
  153. pw_sys_io_ambiq_sdk/
  154. pw_sys_io_arduino/
  155. pw_sys_io_baremetal_lm3s6965evb/
  156. pw_sys_io_baremetal_stm32f429/
  157. pw_sys_io_emcraft_sf2/
  158. pw_sys_io_mcuxpresso/
  159. pw_sys_io_rp2040/
  160. pw_sys_io_stdio/
  161. pw_sys_io_stm32cube/
  162. pw_sys_io_zephyr/
  163. pw_system/
  164. pw_target_runner/
  165. pw_thread/
  166. pw_thread_embos/
  167. pw_thread_freertos/
  168. pw_thread_stl/
  169. pw_thread_threadx/
  170. pw_thread_zephyr/
  171. pw_tls_client/
  172. pw_tls_client_boringssl/
  173. pw_tls_client_mbedtls/
  174. pw_tokenizer/
  175. pw_toolchain/
  176. pw_toolchain_bazel/
  177. pw_trace/
  178. pw_trace_tokenized/
  179. pw_transfer/
  180. pw_uart/
  181. pw_uart_mcuxpresso/
  182. pw_unit_test/
  183. pw_unit_test_zephyr/
  184. pw_varint/
  185. pw_watch/
  186. pw_web/
  187. pw_work_queue/
  188. seed/
  189. targets/
  190. third_party/
  191. ts/
  192. zephyr/
  193. .bazelignore
  194. .bazelrc
  195. .bazelversion
  196. .black.toml
  197. .clang-format
  198. .clang-tidy
  199. .eslintrc.cjs
  200. .git-blame-ignore-revs
  201. .gitattributes
  202. .gitignore
  203. .gn
  204. .mypy.ini
  205. .prettierignore
  206. .prettierrc.cjs
  207. .pw_ide.yaml
  208. .pylintrc
  209. .ruff.toml
  210. activate.bat
  211. Android.bp
  212. AUTHORS
  213. bootstrap.bat
  214. bootstrap.fish
  215. bootstrap.sh
  216. BUILD.bazel
  217. BUILD.gn
  218. BUILDCONFIG.gn
  219. CMakeLists.txt
  220. go.mod
  221. go.sum
  222. jest.config.ts
  223. Kconfig.zephyr
  224. LICENSE
  225. MODULE.bazel
  226. MODULE.bazel.lock
  227. modules.gni
  228. OWNERS
  229. package-lock.json
  230. package.json
  231. pigweed.json
  232. PIGWEED_MODULES
  233. README.md
  234. rollup-protos.config.js
  235. rollup.config.js
  236. tsconfig.json
  237. WORKSPACE
  238. WORKSPACE_OWNERS
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links