Some guidance on writing a Deimos C library interface

Jens Mueller jens.k.mueller at gmx.de
Fri Jul 13 20:24:50 PDT 2012


Hi,

there is some documentation on writing a Deimos interface.
E.g.
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP12
http://dlang.org/interfaceToC.html

I'd like to get a list of rules that one has to follow.

First you have to convert the name of the header file to a valid D
module name. Therefore, I found/came up with the following rules:
* a slash (/) has to be replaced by a dot (.)
* a dash (-) has to be replaced by a dot (.)
* a D keyword gets a underscore (_) appended

Maybe someone can commented on them. I suppose there are even more.
These are just the ones I encountered.

Some questions on module names I could not find a definite answer for:
1. The D page says they should be lower case. Should Deimos module names
   also be made lower case?
2. Should all interfaces be put in a common package, say deimos?

Translating the header file itself is pretty straightforward following
http://dlang.org/interfaceToC.html. Though some cases are not covered:
* E.g. use core.stdc.stdint for standard C types.
* const T* should be replaced with const(T)*
* How to deal with macros?

Can we write a recipe like guide for writing a Deimos interface?

Jens


More information about the Digitalmars-d mailing list