21.01.2012 19:24, Gour пишет:
Hello!

We have a need to bind smaller to medium-size C library and would like
to provide more D-ish or higher-level bindings than just wrapper over C
code.

E.g. the C function looks like:

int swe_calc_ut ( double tjd_ut, int ipl, int iflag, double* xx, char* serr)

and we would like to e.g. use exception to handle errors instead of
checking return value and fill 'char* serr' or store the result of
6-field 'double* xx' array in some data structure etc.

Afaics, htod is more suitable for just wrapping C code, so I wonder if
there is something else you can recommend besides SWIG?


Sincerely,
Gour


I'm finishing a fast (I just don't see a faster way) and garbage-free CTFE-capable wrapper. But it requires IDL to be written for every C function.

It already performs C-arrays (with length or end element) to D arrays conversion and UTF-8/16/32 conversion (usable for WinAPI *W functions). It will soon wrap functions like `GetCurrentDirectoryW` where it will call C function twice (if it will not guess with buffer size at first time).

Sources: https://bitbucket.org/denis_sh/cwrap/src
Docs (just a draft): http://deoma-cmd.ru/d/docs/src/cwrap.html

For easy understanding of how does it work look at `examples/c.d` - this is a bunch of test C sources. D sources obtained from it are in `out` directory.

Reply via email to