linux/tools/net/ynl
Jakub Kicinski 8553fb7c55 tools: ynl-gen: print setters for multi-val attrs
For basic types we "flatten" setters. If a request "a" has a simple
nest "b" with value "val" we print helpers like:

 req_set_a_b(struct a *req, int val)
 {
   req->_present.a = 1;
   req->b._present.val = 1;
   req->b.val = ...
 }

This is not possible for multi-attr because they have to be allocated
dynamically by the user. Print "object level" setters so that user
preparing the object doesn't have to futz with the presence bits
and other YNL internals.

Add the ability to pass in the variable name to generated setters.
Using "req" here doesn't feel right, while the attr is part of a request
it's not the request itself, so it seems cleaner to call it "obj".

Example:

 static inline void
 netdev_queue_id_set_id(struct netdev_queue_id *obj, __u32 id)
 {
	obj->_present.id = 1;
	obj->id = id;
 }

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250723171046.4027470-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-07-24 17:28:49 -07:00
..
generated tools: ynl: enable codegen for TC 2025-05-21 12:38:23 -07:00
lib tools: ynl-gen: support weird sub-message formats 2025-05-21 12:38:23 -07:00
pyynl tools: ynl-gen: print setters for multi-val attrs 2025-07-24 17:28:49 -07:00
samples tools: ynl: add a sample for TC 2025-05-21 12:38:23 -07:00
Makefile tools: ynl: add main install target 2025-01-09 12:53:27 -08:00
Makefile.deps tools: ynl: enable codegen for TC 2025-05-21 12:38:23 -07:00
pyproject.toml tools: ynl: add initial pyproject.toml for packaging 2025-01-09 12:53:27 -08:00
requirements.txt
ynl-regen.sh tools: ynl: move python code to separate sub-directory 2025-01-09 12:53:27 -08:00