Open pthedinger opened 8 years ago
In response to the above:
In terms of safety, would it be worth defining some abstract types (http://www.torek.net/torek/c/types2.html) to add some type safety?
As all our abstract types are nested typedefs of 'unsigned' (broad statement) there is no safety to be had... If it was c++ we could make them shim classes into POD, trivially optimised away.
However, we can try to persuade users that they are opaque types regarding the API by not putting the typedefs in the API! I am moving all our _impl.h files into src/ and may even strip the api/ headers of any implementation detail.... to be discussed re: is this an API or educational?
p.s, regarding 'streaming_channel' this is now defined in src/ thus is an opaque & safe type as far as the API is concerned - yippy!
p.s. we could still use structs (or unions) as we have not classes, but this would require a field operator viz: typedef union{unsigned v;} streaming_chanend; streaming_chanend c1 = {0}; c1.v = c2.v;
Cant have totally anonymous aggregates :-( typedef union{unsigned;} streaming_chanend; streaming_chanend c = 0;
Some useful feedback on the API:
1) event_select & event_select_no_wait could be merged and take an argument to determine whether to pause or not. This makes it easier to have different behaviour each time round the loop.
2) The port API is missing the pullup/down control functions.
3) The resource allocation functions should be prefixed with "hw_" to highlight that they are allocating hardware resources of a limited number.
4) The channel transactions could be simpler to use (and harder to break) if the transacting_chanend state was hidden in global state.
5) It would be helpful to have sendto/recvfrom for many-to-1 channels.