www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - New Blog Post: Writing a D Wrapper for a C Library

reply Mike Parker <aldacron gmail.com> writes:
Victor Porton decided to port an app he developed for a research 
project from Ada to D. In the process, he created a bindings and 
a wrapper for a C library, librdf. In this post, he shares the 
approach he took to translating the C API into the D wrapper.

The blog:
https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/


Reddit:
https://www.reddit.com/r/programming/comments/ap47uf/writing_a_d_wrapper_for_a_c_library/
Feb 10 2019
next sibling parent ag0aep6g <anonymous example.com> writes:
On 10.02.19 15:19, Mike Parker wrote:
 https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/
As far as I see, `context` shouldn't be const. You cast a const `this` to non-const void* and then "back" to non-const UserIOStream. Then doWriteBytes is called on this seemingly mutable object that's actually const. If I implement doWriteBytes in a way that mutates the object, I'm violating const.
Feb 10 2019
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 2/10/2019 6:19 AM, Mike Parker wrote:
 Victor Porton decided to port an app he developed for a research project from 
 Ada to D. In the process, he created a bindings and a wrapper for a C library, 
 librdf. In this post, he shares the approach he took to translating the C API 
 into the D wrapper.
 
 The blog:
 https://dlang.org/blog/2019/02/10/writing-a-d-wrapper-for-a-c-library/
 
 
 Reddit:
 https://www.reddit.com/r/programming/comments/ap47uf/writing_a_d_wrap
er_for_a_c_library/ 
It's on the front page (number 8) of Hacker News. https://news.ycombinator.com/news
Feb 10 2019