Seeking Code Stub Generator (From Header Files)

Seeking code stub generator (from header files)

I think stubgen may be what you're after.

Generate .cpp source from a .h file

Most graphical editors have some plugins available to do that like vim, gedit or Eclipse.
But I am not aware of a shell or perl script to do that.

Automatically Generate C Code From Header

UML modeling tools are capable of generating default implementation in the language of choice. Generally there is also a support for importing source code (including C headers). You can try to import your headers and generate source code from them. I personally have experience with Enterprise Architect and it supports both of these operations.

Automatic generation of function stubs

I have the same problem before and now I am using trial version of Visual Assist X. The task mentioned can be done by right clicking on the method name -> Refactor -> Create Implementation and then Refactor -> Move Implementation to CPP file.

I am no Visual Assist X's affiliate or what, but this really increases my coding speed with Visual C++ dramatically.

How to extract declarations (a .hpp file) from implementation (a .cpp file)?

Please see Dehydra or Treehydra. One of these two tools should allow you perform this via GCC.

Dehydra is a lightweight, scriptable, general purpose static analysis
tool capable of application-specific analyses of C++ code.

Generate Ocaml bindings stubs from C header file

There is not enough information in a C header file to write bindings for another language. In very simple cases (for example, all functions take only integer or floating-point arguments), it's possible, but as soon as pointers get involved, you need to provide more information: will the function read from the pointed-to value, write to it, or both? Must the interface allow a null pointer? Is this in fact a pointer to an array, and where's the size? Is this char* a pointer to a zero-terminated string?

IDL expands C function declarations with extra annotations to cover all these points. That's why camlidl works on IDL and not directly on C headers. You won't find anything significantly less painful.

There's another approach, which is to liberally annotate your C headers with macros that have an empty expansion but provide extra type information, e.g.

int memmove(void ANN_OUT ANN_SIZE(n) ANN_NOT_NULL *dest,
const void ANN_IN ANN_SIZE(n) ANN_NOT_NULL *src,
size_t n);

Such annotations are not standardized, so if you go this route you'll have to write your own tools. (Look up Cil if you want to parse C.) I recommend that instead you treat the IDL declarations as primary, and generate the C header files from them.

How to auto generate stubs for protocols in XCode 4.2?

From your question, I can't understand exactly what you need.

If you need boilerplate code like the -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath implementation that comes when you subclass UITableViewController, then you should create your own templates as Grouchal suggests. Also check a similar question I asked here.

I think that the tutorial you link to refers to code sense, for example:

  • In a header file, add a protocol like <UITextFieldDelegate>:

@interface FirstViewController : UIViewController <UITextFieldDelegate>

  • Save, and then in your .m file, you can see the new methods that you can implement just by typing a dash "-" and then pressing "Escape" on your keyboard. It helps if you type the first letters, for example "-tex" and then "Escape" will display the methods of the UITextFieldDelegate.

Try the same with UITableViewDelegate and UITableViewDataSource, you will see that you'll get a similar result as the one at step 4 of your tutorial (note that in the screenshot, the user has already typed "-tab" to get the list of methods).



Related Topics



Leave a reply



Submit