cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* Re: [Cocci] Using SmPL scripts to mangle function arguments
@ 2020-05-17  9:22 Markus Elfring
  2020-05-17  9:45 ` Julia Lawall
  2020-05-26  1:21 ` Thomas Adam
  0 siblings, 2 replies; 7+ messages in thread
From: Markus Elfring @ 2020-05-17  9:22 UTC (permalink / raw)
  To: Thomas Adam; +Cc: cocci

> Hence, func_new() reduces the number of arguments to just one
> -- a format string, and variadic arguments.

* Does this wording contain a contradiction?

* Would you like to fiddle with any more variadic functions?


> My question is how would I go about trying to get coccinelle to help me
> translate this?  Is this even possible?

Generally, yes.

A more complete source code transformation approach can become challenging.


> @@
> expression O1, O2, O3
> @@
>
> - func_old(O1, O2, O3, ...);

Can it be that the item “charstring” would contain multiple expressions?

If you would like to reuse the last function parameters,
the passed code should be stored into corresponding metavariables
of a type like “constant” or “expression list”.
https://github.com/coccinelle/coccinelle/blob/7cf2c23e64066d5249a64a316cc5347831f7a63f/docs/manual/cocci_syntax.tex#L199


> + func_new("%s: ...", __func__, O3);
>
> I suspect I might be stretching coccinelle's abilities in trying to craft
> new parameters, but I thought I'd ask.

I imagine that the clarification of corresponding application details
can become more interesting.

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [Cocci] Using SmPL scripts to mangle function arguments
@ 2020-05-26 11:23 Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2020-05-26 11:23 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

> > @@
> > expression L, F;
> > @@
> >
> > - func_old(L, F, ...);
> > + func_old(__func_, ...);
>
> You can't add ...  Coccinelle has no idea what it refers to.

The software knows something about the involved source code.
This knowledge can be applied according to the functionality
of the SmPL ellipsis for deletions already.
The situation is different for code additions so far.
I am curious if this detail will eventually change somehow.

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-27 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17  9:22 [Cocci] Using SmPL scripts to mangle function arguments Markus Elfring
2020-05-17  9:45 ` Julia Lawall
2020-05-26  1:21 ` Thomas Adam
2020-05-26  6:00   ` Markus Elfring
2020-05-26  6:41   ` Julia Lawall
2020-05-27 14:21   ` Markus Elfring
2020-05-26 11:23 Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).