Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seeking code stub generator (from header files) [closed]

Tags:

c++

c

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?


[Update] Five years after asking, this question is still getting upvotes.

It was closed as of-topic, which it is nowadays (althoguh it was not when it was originally posted). Fortunately, we can now ask for software recommendations at https://softwarerecs.stackexchange.com/

like image 595
Mawg says reinstate Monica Avatar asked Jan 07 '10 13:01

Mawg says reinstate Monica


People also ask

How to generate interface implementation source/header stubs?

codegen-cpp: Generate interface implementation source/header stub (s) for selection: Same as above, but only for a certain text selection in the currently opened header file codegen-cpp: Generate source file from header: Parses the currently opened header file and generates the source stubs. The output directory can be provided via the UI.

How do I write a stub generator?

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.

Is it possible to get C++ stubs from a generic tool?

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.

What is the purpose of the C++ Stub extension?

I grew tired of "writing" C++ definition stubs by copying around declarations from (interface) header files. Thus I wrote this extension, which helps generating said stubs from a header file. Additionally it allows creating the necessary files for an implementation of a given interface.


2 Answers

I think stubgen may be what you're after.

like image 180
Dushara Avatar answered Oct 18 '22 23:10

Dushara


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.

like image 29
Batz Avatar answered Oct 18 '22 21:10

Batz