apache / mynewt-core

An OS to build, deploy and securely manage billions of devices
https://mynewt.apache.org/
Apache License 2.0
825 stars 369 forks source link

util/stream: Update OSTREAM_DEF and ISTREAM_DEF #3282

Closed kasjer closed 3 months ago

kasjer commented 3 months ago

OSTREAM_DEF macro is utility macro for creating function table for output stream with function names derived from stream type name.

i.e. OSTREAM_DEF(mem) would create function table like this: const struct out_stream_vft mem_vft = { .write = mem_write, .flush = mem_flush, .pump_from = mem_pump_from, } along with prototypes: static int mem_write(struct out_stream , const uint8_t , uint32_t); static int mem_flush(struct out_stream ); static int mem_pump_from(struct out_stream , struct in_stream *, uint32_t);

last function was late addition and is optional

This change removes requirement to define pump_from function from OSTREAM_DEF User still can create function table with pump_from funtion without using macro if pumping is required.