Hello,
I am new to coccinelle and am interested in creating a patch which can define functions based on the function pointers
available in a struct declaration. Since the names of the pointers don't exactly match the
function definitions I want, I used a python script to modify the names. Below is my script:
@m_rule@
field list f_list;
identifier I;
@@
struct I {
f_list
};
@script:python p_rule@
nf << m_rule.f_list;
n_list;
@@
new_nf = []
for f in nf:
parts = f.split("(")
r_type = parts[0]
if '*' in r_type:
r_type=r_type.strip()
else:
r_type = r_type.lstrip()
f_name = parts[1].split(")")[0].replace("*", "").strip()
params = parts[2].split(")")[0]
new_nf.append(r_type + "pv_" + f_name + "(" + params + ")")
new_nf.append(r_type + "hvm_" + f_name + "(" + params + ")")
Please how can I write a new rule that defines several lines of function definitions from
the p_rule new_nf list available in my python structure?
I tried adding the list in a plus(+) entry but that does not work.
Thank you in advance for your help.