[cocci] Determining names for function parameters with SmPL?
Markus Elfring <[email protected]>
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I constructed the following SmPL script variant.
@initialize:python@
@@
import sys
def store_data(id, parameters, computation):
for parameter in parameters:
sys.stdout.write(f"identifier “{id}”: parameter: {repr(parameter)}\n")
@searching@
expression e;
identifier action;
parameter list pl;
type return_type != void;
@@
static inline return_type action(pl)
{
return e;
}
@script:python collection@
id << searching.action;
parameters << searching.pl;
computation << searching.e;
@@
store_data(id, parameters, computation)
Corresponding source file example:
static inline long my_test_calculation(int x, int y)
{
return x + y;
}
Unfortunately, I am wondering about the following information.
Questionable test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch ../Probe/test-inline_function.c list_inline_non-void_functions3.cocci
…
identifier “my_test_calculation”: parameter: 'int x'
identifier “my_test_calculation”: parameter: 'int y'
The function arguments are passed as strings.
How should their names be determined from such data?
Will any other data structures become more appropriate for this use case?
Regards,
Markus