digitalmars.D - Thick bingings and Deimos
- Victor Porton (9/9) Jan 24 2019 I found: https://wiki.dlang.org/Deimos "Translated header should
- rikki cattermole (7/18) Jan 24 2019 Deimos is a Github organization that was created prior to dub.
- Victor Porton (6/9) Jan 24 2019 Huh? Create a separate module with just two-three structs and
- rikki cattermole (5/13) Jan 24 2019 Not so much different repos, just different packages so you have a clean...
- Neia Neutuladh (6/14) Jan 24 2019 Yes. That way, you can use a tool like dstep to produce the raw bindings...
- JN (8/17) Jan 24 2019 The idea behind Deimos was to provide 1:1 (as much as possible)
- Vladimir Panteleev (6/13) Jan 24 2019 Placing bindings in Deimos and publishing them on Dub are
- Vladimir Panteleev (3/12) Jan 24 2019 I updated https://wiki.dlang.org/Deimos with some clarifications.
I found: https://wiki.dlang.org/Deimos "Translated header should not require linkage of any D binary." Thus it seems that I cannot create OO wrappers around C code like this: struct Wrapper { this() { theclibrary_init(); } ~this() { theclibrary_finalize(); } } It is sad that I cannot do this in Deimos. What to do?
Jan 24 2019
On 24/01/2019 11:48 PM, Victor Porton wrote:I found: https://wiki.dlang.org/Deimos "Translated header should not require linkage of any D binary." Thus it seems that I cannot create OO wrappers around C code like this: struct Wrapper { this() { theclibrary_init(); } ~this() { theclibrary_finalize(); } } It is sad that I cannot do this in Deimos. What to do?Deimos is a Github organization that was created prior to dub. It was meant for collecting bindings to C libraries. So yes a wrapper which you're asking about would not be an appropriate addition to it. You do not have to follow the rules of Deimos for your own libraries/bindings. But I would recommend heavily to separate the binding from the wrapper for cleaner code.
Jan 24 2019
On Thursday, 24 January 2019 at 10:52:22 UTC, rikki cattermole wrote:You do not have to follow the rules of Deimos for your own libraries/bindings. But I would recommend heavily to separate the binding from the wrapper for cleaner code.Huh? Create a separate module with just two-three structs and methods? Are you REALLY super that binding and wrapper should be in different repos?
Jan 24 2019
On 24/01/2019 11:55 PM, Victor Porton wrote:On Thursday, 24 January 2019 at 10:52:22 UTC, rikki cattermole wrote:Not so much different repos, just different packages so you have a clean separation. LuaD[0] is a good example even though it was created prior to dub. [0] https://github.com/JakobOvrum/LuaDYou do not have to follow the rules of Deimos for your own libraries/bindings. But I would recommend heavily to separate the binding from the wrapper for cleaner code.Huh? Create a separate module with just two-three structs and methods? Are you REALLY super that binding and wrapper should be in different repos?
Jan 24 2019
On Thu, 24 Jan 2019 10:55:06 +0000, Victor Porton wrote:On Thursday, 24 January 2019 at 10:52:22 UTC, rikki cattermole wrote:Yes. That way, you can use a tool like dstep to produce the raw bindings, potentially even automatically, and have it overwrite the bindings-only module, without having to overwrite the hand-written thick bindings.You do not have to follow the rules of Deimos for your own libraries/bindings. But I would recommend heavily to separate the binding from the wrapper for cleaner code.Huh? Create a separate module with just two-three structs and methods?Are you REALLY super that binding and wrapper should be in different repos?A module is a D source file, not a repository. The hint is that you have to write "module foo.bar;" at the top of each source file.
Jan 24 2019
On Thursday, 24 January 2019 at 10:48:12 UTC, Victor Porton wrote:I found: https://wiki.dlang.org/Deimos "Translated header should not require linkage of any D binary." Thus it seems that I cannot create OO wrappers around C code like this: struct Wrapper { this() { theclibrary_init(); } ~this() { theclibrary_finalize(); } } It is sad that I cannot do this in Deimos. What to do?The idea behind Deimos was to provide 1:1 (as much as possible) bindings to the C code, without any OO wrappers involved. However, Deimos was created before Dub and packages were really a thing. Nowadays, just publish a package to Dub package repository with your bindings. Just be clear in the description that it offers a wrapper over the original C library and it should be fine.
Jan 24 2019
On Thursday, 24 January 2019 at 10:54:53 UTC, JN wrote:The idea behind Deimos was to provide 1:1 (as much as possible) bindings to the C code, without any OO wrappers involved. However, Deimos was created before Dub and packages were really a thing. Nowadays, just publish a package to Dub package repository with your bindings. Just be clear in the description that it offers a wrapper over the original C library and it should be fine.Placing bindings in Deimos and publishing them on Dub are orthogonal. There are benefits to placing bindings in one place beyond the benefits provided by a Dub package: https://wiki.dlang.org/Deimos#Rationale
Jan 24 2019
On Thursday, 24 January 2019 at 10:48:12 UTC, Victor Porton wrote:I found: https://wiki.dlang.org/Deimos "Translated header should not require linkage of any D binary." Thus it seems that I cannot create OO wrappers around C code like this: struct Wrapper { this() { theclibrary_init(); } ~this() { theclibrary_finalize(); } } It is sad that I cannot do this in Deimos. What to do?I updated https://wiki.dlang.org/Deimos with some clarifications. Hope that helps.
Jan 24 2019