views:

389

answers:

4

Imagine I have the header files to a subsystem, but no access to the source code.

Now I want to generate stubs to match all functions declared in the header files (for testing purposes).

I wrote some simple code to do this, but it's not perfect. Does anyone know of any freely available software which will do this?

+2  A: 

Visual Assist X for Visual Studio has this functionality, although it isn't automated.

On the function

Tri ProjectTriOnPlane(Tri* a_Triangle);

And then, if the corresponding .c or .cpp is found, go to Refactor (VA X) -> Create Implementation, which will create an implementation like so:

Tri Camera::ProjectTriOnPlane( Tri* a_Triangle )
{

}

It also doesn't return something standard, that's a bit of a shame.

knight666
sorry, I need it bulk automated
Mawg
+2  A: 

Maybe Lzz does what you want.

swegi
Mawg
+1  A: 

You can write a stub generator pretty easily using Doxygen. It's not well known but it comes with a helper library that provides a very nice abstraction over the XML output (see this page).

If you look at the end of this header file, you'll see that you get nice IStructs, IClass objects, from which you can list ISections then IMembers. All very easy, and customizable to your liking.

As I doubt you'll get the exact stubs you want from a generic tool, you might be better off if you code your own using Doxygen, as all the heavy lifting of properly parsing C++ syntax is done for you.

And if your testing patterns are mainly dependent on the method parameters' type, you can probably generate full test stubs by analysing the method's parameters and generating appropriate code.

Florian
+3  A: 

Here is a solution with perl and vim http://www.vim.org/scripts/script.php?script_id=213 it uses ctags, and if one can easily remove the vim need if desired by using the included perl script.

Batz
This looks good, rhanks!
Mawg