January 30, 2007

I recently ventured into the Lisp community with a trivial wrapping of a library called FreeImage. I used CFFI for this and was quite pleased– well, except for one thing. That thing would be that I had to specially build the library to not use stdcall. CFFI does not support stdcall, yet (if ever). I generally prefer being able to build libraries without changing the source for a single language. So, I could just post instructions on what is needed to be done to the FreeImage sourcecode and let the user still get the source from the FreeImage web-site or I could always do a build and post it with trivial-freeimage. I have even thought about asking the developers of FreeImage if they would except a patch that would allow a user to use a define of LISP or some such thing to build especially for cffi. I would rather do none of the above. I suppose I will need to create a backend for each Lisp I wish to support– using their respective ffi– and then maybe have a front-end that hides it all away from the end-user of trivial-freeimage. That is rather disappointing as I very much like cffi. I wish cffi had support for stdcall and cdecl like ctypes in python (just found that out today from a co-worker who thought my situation was amusing and wanted to show off ctypes).

The cffi developers are looking into adding support for stdcall. I have offered to help in anyway that I can. I am looking at the source of cffi to try and grok it. I did not mean to come across as one of words and not action. I also did not mean to come across as not appreciating cffi as I do appreciate it very much. CFFI does not have a donate paypal option but if they will institute one I will donate to help out since it will be unlikely I will be up to speed on the source before they finish adding stdcall.


4 Responses to “Depressing”

  1. Oh man. You’re making me feel bad. What can I tell you? stdcall support is in the TODO list. It’s just a matter of figuring out the best syntax really since DEFCFUN’s syntax doesn’t have an obvious place to fit options such as calling convention. 🙂

    Anyway, I just brought that issue up in the cffi-devel mailing list. Your comments are welcome.

  2. I feel a little bit bad too, but in my grumpy old age I’ve come to recognize that I cannot both provide for all my own needs and everyone else’s wishlist too: and that this is unlikely to change in the near future. The best that I think can be done by a purely volunteer community is to make available what they have, and not to attempt to hide missing elements or problems; but for that to be part of a solution, the rest of the volunteers, when they find that there’s something that they need, have to participate in that. I find it depressing when programmers admit defeat without even trying to adapt what is out there to their needs, as it seems to show that making (for example, though I had nothing to do with it) cffi freely available for all to use and modify was a waste of time.

    I hope you don’t think I’m picking on you: really I’m hoping to encourage you not to admit defeat when something out there doesn’t quite serve your need, but instead to shape it to make it what you need (and then, optionally, to allow others with similar needs to use it too).

    Good luck.

  3. dispossessed Says:

    Just for the record, I had already offered to help in any way possible before the comment was made.

  4. For what it’s worth, SBCL can call stdcall functions with the exact same syntax as it uses to call cdecl functions, which means that the same CFFI definitions should work for both. (cdecl and stdcall use the same argument order, the only question is who removes the arguments from the stack, and there’s a way for the caller to always remove the arguments without screwing up if the callee has also removed them.)

    Callbacks, however, are an entirely different matter, and have the same problem as Luis mentioned with CFFI: How do you add information about calling convention without breaking the existing syntax?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: