20.02.2012 19:34, Gour пишет:
On Mon, 20 Feb 2012 18:02:49 +0400
Denis Shelomovskij<verylonglogin....@gmail.com>  wrote:

Hello Denis,

D has complete (IMHO) compiler support for calling C functions (using
extern(C)). But there is a lack of library support.

I'm glad you're working on (another) bindings tool being aware that it's
not reasonable that D will cover all our library needs.

Otoh, I'm also concerned that using just wrappers over C code would
erode (potential) type-safety and advantage of using D in the first
place. (In our app we envision to use wXD for GUI, need bindings for 3rd
party C lib, using one of Sqlite3 wrappers...)

Once original function is properly described in IDL, CWrap gives the
fallowing advantages:

If we eliminate htod which is Windows only and considering that manual
wrapping is not very attractive option, along with your list which sound
quite goo, my question is what would be some of pro/cons of CWrap in
comparison with e.g. SWIG and it's D support as well as with dstep
(https://github.com/jacob-carlborg/dstep) if our main objective would be
to keep some of D's advantages such as having higher-level (D-ish) API,
exception handling (insted of error-checking), type-safety etc.
available in our D bindings of C lib(s)?


Sincerely,
Gour


OK, I'm here again. Jacob Carlborg is right - CWrap is a different tool so it's incorrect to compare it with SWIG/dstep. It's developed as a high performance backend for other tools or for manual wrapping a couple of functions, not for translating entire *.h files or creating class hierarchy.

Let's imagine there is no std.file, no std.windows.charset, and no std.windows.registry. Look at my WinAPI examples - it will be easier and more robust to write IDL descriptions by hands (because you should read specs for every WinAPI function at least once) and use generated wrappers than to write lots of boring code to converts strings/check errors. E.g. I did it already (CWrap WinAPI examples) and it wasn't too long compared with reading specs.

Or let's imagine one will have to finally revise Phobos to stop producing garbage and/or make D usable without GC. He will kill himself if he want to write optimal-performance garbage-less calls to WinAPI or will spend lot of time by writing non-optimal. Or he will just use CWrap generated code.

Reply via email to