On 03/09/2018 5:07 AM, Russel Winder wrote:
On Mon, 2018-09-03 at 01:00 +1200, rikki cattermole via Digitalmars-d-
learn wrote:

[…]
You don't need to create a complete binding for something to use a
subset of it.

True, but all too often you find there are so many interdependencies of
names, you end up binding most of the API. I tried fiddling with
Fontconfig using Python which has no binding and was able to hack up
just enough using CFFI to get things working. So I think in this case a
subset for the application is feasible – as opposed to creating a
complete binding.

You won't need to actually fill out any c struct's that you don't need either. Make them opaque as long as they are referenced via pointer and not by value.

Writing up a Derelict style binding is easy enough since e.g.
SharedLib
struct handles most of the work (from util package).


https://github.com/DerelictOrg/DerelictUtil/blob/master/source/derelict/util/sharedlib.d#L118

I am not convinced this is a good approach since you do not get the
signatures at compile time. The advantage of a binding, or subset of a
binding is that you get full compiler support.

Ugh, you do know that the linker which does all the hard work doesn't know anything about the signature of the C function? That is the part SharedLib replaces. You will of course define it with a proper signature on D's side with a helpful cast :)

i.e. https://github.com/DerelictOrg/DerelictGL3/blob/master/source/derelict/opengl/versions/gl1x.d

Reply via email to