I've never heard of such a tool but it seems worth making... I'll have a whack at it when I get bored later this week.
On Wed, Oct 9, 2013 at 9:24 PM, Michel Pelletier <[email protected]> wrote: > Automation would be be great, and not just for Python, making the wrapper > was a bit tedious, although completely doable. I'm surprised there isn't > something like SWIG but for libffi, where you can point a .h file and some > kind of specfile at a tool that dumps the correct bindings incantation for > various languages. Maybe there is such a tool? A quick google didn't > reveal much to me. > > -Michel > > > On Wed, Oct 9, 2013 at 12:27 AM, Pieter Hintjens <[email protected]> wrote: >> >> Hi Michel, >> >> This is great fun! I'm going to look at what you did since I'd like to >> try generating Python wrappers for our standardish C APIs (FileMQ, >> Zyre, for instance). >> >> -Pieter >> >> On Wed, Oct 9, 2013 at 4:28 AM, Michel Pelletier >> <[email protected]> wrote: >> > Wanting to know more about Python and CFFI, I decided to do a >> > straightforward wrap job for Python around the CZMQ C API. I have it >> > reasonable complete enough to write some simple code and tests. I've >> > pushed >> > it up to github: >> > >> > https://github.com/michelp/pyczmq >> > >> > Most of the core functionality, zctx, zsocket, zsockopt, zpoller, zmsg, >> > zframe, zstr, zloop, zbeacon, zcert, zauth, are exposed as both straight >> > wrappers around the C interface as well as some namespaced functions >> > that >> > provide a high level functional interface (eg, turning cdata char * into >> > python byte strings, etc). For example: >> > >> > >> > ctx = zctx.new() >> > push = zsocket.new(ctx, zsocket.PUSH) >> > pull = zsocket.new(ctx, zsocket.PULL) >> > zsocket.bind(push, 'inproc://test') >> > zsocket.connect(pull, 'inproc://test') >> > zstr.send(push, 'foo') >> > assert zstr.recv(pull) == 'foo' >> > zstr.send(push, 'bar') >> > zsocket.poll(pull, 1) >> > assert zstr.recv_nowait(pull) == 'bar' >> > >> > >> > >> > There's also a first stab at providing an OO interface in the form of >> > Context, Socket, Beacon and Loop classes. Here's a working example: >> > >> > ctx = Context() >> > pub = ctx.socket('PUB') >> > sub = ctx.socket('SUB') >> > sub.set_subscribe('') >> > pub.bind('inproc://zoop') >> > sub.connect('inproc://zoop') >> > pub.send('foo') >> > sub.poll(1) >> > assert sub.recv() == 'foo' >> > >> > >> > This is a work in progress, it's useful enough now to create socket and >> > messages and send and receive data. I'd certainly love any form of >> > help, >> > just send me a pull request. Featured desired are way more tests! And >> > of >> > course any missing functions that need wrapping, or new functionality. >> > >> > Thanks and enjoy, >> > >> > -Michel >> > >> > _______________________________________________ >> > zeromq-dev mailing list >> > [email protected] >> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> > >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev > > > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
