digitalmars.D.learn - Deimos rules?
- Xavier Bigand (3/3) Nov 13 2013 I work on XCB integration, so I think that I can add bindings in deimos.
- Jonathan M Davis (13/17) Nov 13 2013 It's completely project-dependent. Deimos is for D bindings to C librari...
- qznc (4/33) Nov 14 2013 Ah, that reminds that the tutorial needs some good advice about
- Jacob Carlborg (6/9) Nov 14 2013 I would say stay as close to the original C code as possible. Although I...
- Joseph Rushton Wakeling (8/10) Nov 14 2013 In some ways I wonder why D's types aren't just specified according to t...
- Xavier Bigand (5/13) Nov 14 2013 I started by changing extension of files from .h to .d, and translating
- Jonathan M Davis (8/20) Nov 14 2013 It's a stylistic choice, and Walter went with not putting the sizes in t...
- Jacob Carlborg (6/10) Nov 15 2013 Personally I would mix the wrappers and bindings in the same project, as...
- Xavier Bigand (6/9) Dec 01 2013 I think it's enough mature to be integrated to deimos.
I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?
Nov 13 2013
On Wednesday, November 13, 2013 23:01:58 Xavier Bigand wrote:I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?It's completely project-dependent. Deimos is for D bindings to C libraries. They need to be the extern(C) declarations which correspond to the C header declarations without any D wrappers. Beyond that, how the project is put together or how the bindings are generated is really up to whoever does the header translation. DStep is new enough that I expect that most of Deimos has been converted by hand. There's also htod on Windows, but it does a pretty poor job, because it's D1-compatible (e.g. it doesn't handle const right). So, you can translate the headers however you want, and there are no syntactic rules. I'd say that you should follow the same file layout as the actual C headers (a one-to-one translation of header.h -> header.d), but how everything is formatted in those files doesn't really matter. It's up to you. - Jonathan M Davis
Nov 13 2013
On Wednesday, 13 November 2013 at 22:46:45 UTC, Jonathan M Davis wrote:On Wednesday, November 13, 2013 23:01:58 Xavier Bigand wrote:Ah, that reminds that the tutorial needs some good advice about this. As far as I know, DStep is the current state of art.I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?It's completely project-dependent. Deimos is for D bindings to C libraries. They need to be the extern(C) declarations which correspond to the C header declarations without any D wrappers. Beyond that, how the project is put together or how the bindings are generated is really up to whoever does the header translation. DStep is new enough that I expect that most of Deimos has been converted by hand. There's also htod on Windows, but it does a pretty poor job, because it's D1-compatible (e.g. it doesn't handle const right). So, you can translate the headers however you want, and there are no syntactic rules. I'd say that you should follow the same file layout as the actual C headers (a one-to-one translation of header.h -> header.d), but how everything is formatted in those files doesn't really matter. It's up to you.
Nov 14 2013
On 2013-11-13 23:01, Xavier Bigand wrote:I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?I would say stay as close to the original C code as possible. Although I do prefer to translate typedefs like int8_t to real D types, like byte, if they exist. -- /Jacob Carlborg
Nov 14 2013
On 14/11/13 13:13, Jacob Carlborg wrote:I would say stay as close to the original C code as possible. Although I do prefer to translate typedefs like int8_t to real D types, like byte, if they exist.In some ways I wonder why D's types aren't just specified according to the number of bits -- int8, int16, int32, int64 instead of byte, short, int, long. I suppose on balance it's probably less readable and easier to make mistakes writing. More generally -- is it considered desirable to provide not only the C-like translation, but also a higher-level "D-ified" wrapper? Or is that considered overkill for Deimos?
Nov 14 2013
Le 14/11/2013 13:13, Jacob Carlborg a écrit :On 2013-11-13 23:01, Xavier Bigand wrote:I started by changing extension of files from .h to .d, and translating in place everything. I take libX11 as model. I'll certainly make a pull request when I will able to run a simple demo. I let all originals comments as it during the translation.I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?I would say stay as close to the original C code as possible. Although I do prefer to translate typedefs like int8_t to real D types, like byte, if they exist.
Nov 14 2013
On Thursday, November 14, 2013 15:06:59 Joseph Rushton Wakeling wrote:On 14/11/13 13:13, Jacob Carlborg wrote:It's a stylistic choice, and Walter went with not putting the sizes in the type names. But since their sizes are still fixed, it doesn't really matter.I would say stay as close to the original C code as possible. Although I do prefer to translate typedefs like int8_t to real D types, like byte, if they exist.In some ways I wonder why D's types aren't just specified according to the number of bits -- int8, int16, int32, int64 instead of byte, short, int, long. I suppose on balance it's probably less readable and easier to make mistakes writing.More generally -- is it considered desirable to provide not only the C-like translation, but also a higher-level "D-ified" wrapper? Or is that considered overkill for Deimos?Deimos is specifically for bindings to C libraries and _not_ for D-ified wrappers. And that's the stance that Walter has taken when it's come up. But with dub and code.dlang.org, it should be simple enough to put a D-ified wrapper in a place where folks can find it. - Jonathan M Davis
Nov 14 2013
On 2013-11-15 05:30, Jonathan M Davis wrote:Deimos is specifically for bindings to C libraries and _not_ for D-ified wrappers. And that's the stance that Walter has taken when it's come up. But with dub and code.dlang.org, it should be simple enough to put a D-ified wrapper in a place where folks can find it.Personally I would mix the wrappers and bindings in the same project, as along as you could use the bindings completely separate without the wrappers. -- /Jacob Carlborg
Nov 15 2013
Le 13/11/2013 23:01, Xavier Bigand a écrit :I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I respect some syntactical rules?I think it's enough mature to be integrated to deimos. It builds fine but I have some issues with XCB, the official sample written in C doesn't work too, so the bindings seems correct. You can fork it from : https://github.com/D-Quick/XCB
Dec 01 2013