tags:

views:

731

answers:

2

Until now I have seen only tools and some information for the creation of Delphi code for a given C header file.

However, in the 'Delphi first' case, there is a Delphi interface declaration and a generated DLL, and no C header. Are there tools which can extract the necessary information and build a C header file for a DLL?

Such a tool could be helpful and time saving in cross-language / cross-platform projects. For example, with the C header file, it would be easier to create Java JNA binding code automatically with jnaerator. The tool chain would look like this:

Delphi source -> create C header -> convert to Java binding -> use Delphi DLL from Java

+1  A: 

While this works in theory, many Delphi DLLs will use calling conventions like register, don't pack records in standard C ways etc. Then on top there are RTL issues, coprocessor status word issues etc.

Probably most C compilers can workaround that by adding some pragma's, but I doubt the whole Java binding stuff will eat that.

So unless the DLL is crafted with this in mind, this will probably work more often not than that it will.

Reading and parsing the Delphi header is not that hard though. Pascal is easier to parse and transform than e.g. C. FPC (Free Pascal) has a pascal parser package that is used for its documentation tool that might be retargetable

Marco van de Voort
+5  A: 

Delphi's own compiler can output C/C++ header files from .pas files, using the -JPHNE parameter.

Remy Lebeau - TeamB