After canard protocol stack receive done, it will invoke user callback, pass CanardBaseHandle as parameter.
so that user can easily to use related parameter.
I agree it would be nice to have some encapsulation on the generated C code. I was considering eventually diving into the YAML to do something simllar. The generated interfaces are currently very flexible, but somewhat error-prone.
I’m not inclined to modify the current C generation templates to use this style but I would support a new language option that would result in generating this type of C. I’m not going to do that work myself before C++ is out and I’m more inclined to look at expanding language support (e.g. Rust, Ada, Go, Javascript, Python) before revisiting C.
TL
While I’m not against this proposal it does have drawbacks from a high-assurance software standpoint mostly due to all the pointers you have to use. I’ve done this type of C before and it’s, basically, just a half implementation of Objective-C (I like to call this “Objecty-C”). For example:
Whereas the current C code is annoying because we all hate to type, the compiler is able to assure us that all the function calls are valid and that most of the required arguments (where not pointers) are present. In the Objecty-C example above you see the WTF comments where we now have to add error handling that should never occur and which is therefore really hard to cover in tests. We’re now doing a bunch of runtime checks with runtime failures. You can (i.e. you really should) add static analysis in to augment the compiler for this style of C but that isn’t a portable solution.
If you are not writing high-assurance code then this is a fun style to use, I admit, and you tend to just omit the pointer checks on self and trust the initializer to always populate the function pointer list. So I’m not against this existing but it is not appropriate as the default and/or only style of C for Nunavut to generate.
Everything can be pointed。
its not the point is not safe, its depending who use it.
after stack protocol received the message, its already know which kind of message I have received. so that protocol stack tell user, here is my tool(a point to a struct that include serialize and deserialize). user can use this tool or deserialize by its self.
I think extend struct CanardRxSubscription to be that tool.
nunavut can be auto generate struct CanardRxSubscription object, if user want subscribe it, just register it.