www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Looking for instructions on how to make a Derelict library

reply Matt Jones <matthew.brennan.jones gmail.com> writes:
Hey everyone,

I wanted to make a version of SQlite3 that uses Derelict to load 
the sqlite3 DLL when I'm ready. I can't find any instructions for 
how to make a basic Derelict style library. I looked around at 
http://derelictorg.github.io/, but could not find anything. Does 
anyone have any?

Thanks.
Sep 17 2017
parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 17 September 2017 at 21:15:08 UTC, Matt Jones wrote:
 Hey everyone,

 I wanted to make a version of SQlite3 that uses Derelict to 
 load the sqlite3 DLL when I'm ready. I can't find any 
 instructions for how to make a basic Derelict style library. I 
 looked around at http://derelictorg.github.io/, but could not 
 find anything. Does anyone have any?

 Thanks.
Just look at the existing Derelict packages. For a normal C library like sqlite3, it's pretty straightforward -- declare function pointers to ever public function in the API, translate all the types, convert any macros to D functions, and create a loader that extends derelict.util.SharedLibLoader and overrides loadSymbols. Examples: DerelictLua, DerelictODE, DerelictFT. You can also add support for static bindings by versioning out the function declarations and the loader in favor or normal function declarations. Examples: DerelictSDL2, DerelictGLFW3, DerelictAL. See the D wiki for links to articles that show how to translate C headers.
Sep 17 2017
parent reply Matt Jones <matthew.brennan.jones gmail.com> writes:
On Monday, 18 September 2017 at 00:21:23 UTC, Mike Parker wrote:

 See the D wiki for links to articles that show how to translate 
 C headers.
I've been reading the DerelictSDL2 source code. I think I have a handle on it. I'll have to look more at the wiki too. Thanks.
Sep 17 2017
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote:
 I've been reading the DerelictSDL2 source code. I think I have 
 a handle on it. I'll have to look more at the wiki too.

 Thanks.
Might be interesting to write up your experience with doing it as either blog post or part of the Derelict documentation (which is already quite good, IMO).
Sep 18 2017
next sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 18 September 2017 at 11:27:01 UTC, jmh530 wrote:
 On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote:
 I've been reading the DerelictSDL2 source code. I think I have 
 a handle on it. I'll have to look more at the wiki too.

 Thanks.
Might be interesting to write up your experience with doing it as either blog post or part of the Derelict documentation (which is already quite good, IMO).
I used to have a guide to creating "Derelictified" bindings for an older version. I should write one up for the current version.
Sep 18 2017
parent SrMordred <patric.dexheimer gmail.com> writes:
 I used to have a guide to creating "Derelictified" bindings for 
 an older version. I should write one up for the current version.
+1
Sep 18 2017
prev sibling parent Matt Jones <matthew.brennan.jones gmail.com> writes:
On Monday, 18 September 2017 at 11:27:01 UTC, jmh530 wrote:
 On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote:
 I've been reading the DerelictSDL2 source code. I think I have 
 a handle on it. I'll have to look more at the wiki too.

 Thanks.
Might be interesting to write up your experience with doing it as either blog post or part of the Derelict documentation (which is already quite good, IMO).
I was thinking of doing that. I'll have to figure out the best way to do that, once I get a better understanding of how Derelict works.
Sep 18 2017