Automatic binding generation

bls bizprac at orange.fr
Fri Jan 6 13:44:59 PST 2012


On 01/06/2012 12:34 PM, Piotr Szturmaj wrote:
> Is should be possible to use debug info of a library to generate D or
> other language bindings. Current approaches are SWIG, htod and/or manual
> coding. The first two do not always work as expected (try using them to
> make OpenCV bindings) as parser-based converters do not always support
> all build environment details. Often, you need a fully capable C/C++
> compiler to correctly parse headers.
>
> Function information may be extracted from:
>
> * PDB files using DIA SDK on Windows
> * DWARF info using libdwarf or libdw on *nixes
>
> Debug files contain information about functions, their argument types
> and return types, about structs and classes/namespaces (C++). Recent
> version of DWARF may even contain information about macros.
>
> The usual binding creation would be simple:
>
> 1. build library using existing build environment with debug info
> 2. run converter to generate D bindings (this may be used to make C#'s
> bindings as well)
>
> Thanks to the 1st point we can avoid many incompatibilities with
> SWIG/htod parsers as we get all symbols in one file. The whole process
> may be automated in most circumstances. Eventually some fixup files may
> be used to assist with conversion (similar to SWIG files, but without
> enumerating everything).
>
> Thoughts?

Sure,  not exactly what you have in mind, but at least an exotic thought
Source commenting -> Doxygen XML output -> XML to D.

This is not as obscure as one might think, F.I. - GCCXML based bindings. 
- Ages ago I've  talked with Frank (keinfarbton) about using Java2XML to 
automate SWT porting...





More information about the Digitalmars-d mailing list