You are not logged in.
Pages: 1
So, I'm planning on doing some conversion of about 800K (compressed) of C source to C++. It's already in a nice C-OO style of coding. That is:
struct xyz { ... };
void xyz_move(struct xyz* pxyz, ...other args...)
void xyz_add(struct xyz* pxyz, ...other args...)
Yet it's also written K&R style which died in the 80s...
void
xyz_something(pxyz, a, b, c, d)
struct xyz *pxyz,
int a, b
char *c
int d
{
...body here
}
So the conversion isn't that hard. The problem is that it's totally and wickedly unorganized... i.e. one file has 3 C "classes" listed, as well as the prototypes for 2 of the function sets. The other function set is in a different header, and all 3 are in their own implementation files, along with other random functions prototyped in a totally different header.
Short story: it's a mess. I'd like to convert it to a nice 1-to-1 header/implementation relationship, but there's alot of code. I'm wondering if anyone knows of any tools (or even simple refactoring techniques) to aid me. I can do it manually, it will just take me a long time.
Note: during this conversion I will not be switching the stuff over to C++ types (i.e. std::list<xyz*> instead of struct xyz**). That will be done later, so in all honesty I only need C refactoring tools....
Offline
if it's only about creating header files, you could maybe write your own tool.
just collect all structs and search for something like struct_[w_]+([^)*]).
Offline
Hmmm, yeah I guess I could collect code and things, but what I'd like to do, is take a struct, along with related prototypes into one header file, and cram the implementations on the function in a related file. Bascially I'm trying to save myself a few days of random... "ok this is a XYZ function, copy, paste in xyh.c and xyz.h, delete from original"
There should be refactoring tools out there to do something similar... maybe I'll check the vim scripts...
Offline
Some tools I've heard of are cproto, protoize, and c2dep.
Offline
Pages: 1