Hi guys,
Thanks for your advises.
I write 2 cocci files to make this convert happened.
c1.cocci:
@@
typedef device_method_t;
@convert type@
- struct pci_driver
+ device_method_t
c2.cocci:
@convert name@
identifier abc;
@@
- device_method_t abc
+ device_method_t abc[]
= ...;
After spacthing these 2 coccis sequentially, I can get:
static device_method_t xxx[] = {
from:
static struct pci_driver xxx = {
Then comes the more complicated problem:
How can I convert the initialization part of the valuable definition after
converting it's type?
the original code:
static device_method_t alx_driver[] = {
.suspend = alx_suspend,
.resume = alx_resume,
};
the code I expect:
static device_method_t alx_methods[] = {
/* Device interface */
DEVMETHOD(device_suspend, alx_suspend),
DEVMETHOD(device_resume, alx_resume),
{0, 0}
};
Can somebody give me some advise?
Thanks.
To julia:
I just start it now, no sure whether I can make it, maybe we can do it
together o(∩_∩)o
-----Original Message-----
From: Julia Lawall
Sent: Friday, June 08, 2012 5:37 PM
To: Michael Stefaniuc
Cc: leeyafo ; [email protected]
Subject: Re: [Cocci] How can I replace a structure name in a C file
On Fri, 8 Jun 2012, Michael Stefaniuc wrote:
Hello,
On 06/08/2012 10:33 AM, leeyafo wrote:
Hello guys:
I'm new to Coccinelle, And now I wanna to develop a tool to translate
Linux ethernet driver to freebsd.
the first problem is to convert an instance of "struct pci_driver" to
"device_method_t".
Can anybody give me some sample cocci code?
I have try the following code, but it does not work as expect.
@@
@@
- static struct pci_driver alx_driver = {
+ static device_method_t alx_methods[] = {
coccinelle is not line base like diff but knows C so you need to replace
full C entities.
@@
typedef device_method_t;
@@
- struct pci_driver alx_driver
+ device_method_t alx_methods[]
= ...;
If you would have changed just the type it would have been even simpler:
@@
typedef device_method_t;
@@
- struct pci_driver
+ device_method_t
I guess that if the introduction of an array is wanted, the more complex
rule will be needed.
Thanks,
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)