views:

524

answers:

3

For a project I'm working on, I need to have a lot of source code files generated from an interface description. That description is currently IDL (really, a pidgin IDL-like language), but I'm not married to it and am willing to consider alternatives.

What sorts of code generators are available that can take IDL (or something like it) and generate C / C++ code from a template?

I'm aware of SWIG, but since I'm not wrapping objects into one of the existing languages, I'd have to write my own binding. That appears difficult to me, but I'd love to be proven wrong.

Mozilla uses XPIDL for their purposes, but although they provide a build process for it, it's not entirely clear how to use it to generate anything but Mozilla-relevant sources.

I've cobbled together my own solution using a couple of Boost Spirit parsers, but it's very rickety and often needs tweaking in order to do its job properly. Ideally, the software I'm looking for would take one template file (of some form or another) and one IDL file (or some other interface specification) and merge them together to generate a single output file.

Thanks!

A: 

In Windows midl.exe is there to generate COM code from IDL files. There should be something similar in every CORBA implementation. Your question suggests your're talking about some Unix, there you could surely find other ways. Just look for flex, bison, rake , yaml.

With best regards Friedrich

Friedrich
+1  A: 

You could take a look at Flick "The Flexible IDL Compiler Kit".

titanae
A: 

We are looking in to use XDR. We have also heard of Googles Protocol Buffers which seem pretty good, but will not be used this time...

We took XDR because the language is pretty much the same from C for structs, for the task is basically port old code and we want as simple way to go.

epatel