cffi-clutter

Discussion of Common Lisp
Harnon
Posts: 78
Joined: Wed Jul 30, 2008 9:59 am

Re: cffi-clutter

Post by Harnon » Tue Jul 28, 2009 9:12 am

Well, i got version 0.9.2 to build. The instructions worked, i had just left some out. Yoopee! Now am working on 0.9.8. Just wondering, when you say "
It is mostly composed from semi-automatically generated bindings for Clutter and parts of GLib and GObject.", what did you use to semi-automatically generate it with?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: cffi-clutter

Post by ramarren » Tue Jul 28, 2009 9:43 am

Harnon wrote:Well, i got version 0.9.2 to build. The instructions worked, i had just left some out. Yoopee! Now am working on 0.9.8.
I wonder if the cffi groveller works on Windows... at least it seems to have some conditional code for it, so there is hope!
Harnon wrote:Just wondering, when you say "
It is mostly composed from semi-automatically generated bindings for Clutter and parts of GLib and GObject.", what did you use to semi-automatically generate it with?
A rather ugly hack involving regular expression to parse a very small subset of C syntax. Essentially, I copy-pasted synopses from the Clutter API documentation (like this one), then cut those parts I couldn't be bothered to parse and done some more hand-editing. Hence, semi-automatically.

This was generally silly, as I should have either used some existing solution, as there are several, or at least done this properly (a wasted chance to try out my attempt at parser combinators). But, well, by the time the ugliness of the hack really got to me I was done.

Done creating the bindings to C functions at least, there are lots of things which should be further wrapped even for a fairly minimal bindings. I just did mostly what was needed for the tutorial.

dmitry_vk
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan
Contact:

Re: cffi-clutter

Post by dmitry_vk » Tue Jul 28, 2009 12:05 pm

Ramarren, if you are interested, I've made documentation for my GObject binding (http://common-lisp.net/project/cl-gtk2/ ... index.html). It may make task of creating clutter binding a little easier (but I don't insist on it). You can see my attempt at http://paste.lisp.org/display/84338. The example works (with the threading issue I told about earlier) and demonstrates basic GObject usage.

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: cffi-clutter

Post by ramarren » Tue Jul 28, 2009 1:34 pm

dmitry_vk wrote:Ramarren, if you are interested, I've made documentation for my GObject binding (http://common-lisp.net/project/cl-gtk2/ ... index.html). It may make task of creating clutter binding a little easier (but I don't insist on it). You can see my attempt at http://paste.lisp.org/display/84338. The example works (with the threading issue I told about earlier) and demonstrates basic GObject usage.
It looks quite impressive... I wish something like this was done before I started. Using it properly now would most likely mean a total rewrite. Not that there is much code besides the function bindings, but still... I will have to look more into it. In any case a more complete GObject binding will certainly be useful, because from what I have seen every previous GTK binding implements as little of it as it can get away with, and it is a mess. Although I only looked in detail at cells-gtk FFI layer, trying to make it work, so I might be biased.

Two things. One, it would be probably be a good idea to separate this into an individual project, because it will just get confusing, and adding a dependency on GTK bindings just for GObject seems unintuitive.

Two, I, perhaps unnecessarily, worry about performance impact from wrapping GObjects in (meta)classes. This doesn't matter for GTK, where manipulating objects is relatively rare, but Clutter is much lower level, which means potentially having a callback per animation frame, and unwrapping all those objects is going to add up. Although probably general FFI overhead already swamps it... well, I am not going to benchmark it, certainly not now, and it seems to be the only way to find out. But, if there are Python bindings and people are presumably using them, then why worry... although maybe they implement most of their class behaviour in C. Oh, well.

dmitry_vk
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan
Contact:

Re: cffi-clutter

Post by dmitry_vk » Tue Jul 28, 2009 2:17 pm

Ramarren wrote:
dmitry_vk wrote:Ramarren, if you are interested, I've made documentation for my GObject binding (http://common-lisp.net/project/cl-gtk2/ ... index.html). It may make task of creating clutter binding a little easier (but I don't insist on it). You can see my attempt at http://paste.lisp.org/display/84338. The example works (with the threading issue I told about earlier) and demonstrates basic GObject usage.
It looks quite impressive... I wish something like this was done before I started. Using it properly now would most likely mean a total rewrite. Not that there is much code besides the function bindings, but still... I will have to look more into it. In any case a more complete GObject binding will certainly be useful, because from what I have seen every previous GTK binding implements as little of it as it can get away with, and it is a mess. Although I only looked in detail at cells-gtk FFI layer, trying to make it work, so I might be biased.

Two things. One, it would be probably be a good idea to separate this into an individual project, because it will just get confusing, and adding a dependency on GTK bindings just for GObject seems unintuitive.

Two, I, perhaps unnecessarily, worry about performance impact from wrapping GObjects in (meta)classes. This doesn't matter for GTK, where manipulating objects is relatively rare, but Clutter is much lower level, which means potentially having a callback per animation frame, and unwrapping all those objects is going to add up. Although probably general FFI overhead already swamps it... well, I am not going to benchmark it, certainly not now, and it seems to be the only way to find out. But, if there are Python bindings and people are presumably using them, then why worry... although maybe they implement most of their class behaviour in C. Oh, well.
I'm planning to split bindings to separate projects, but I'm still working on some parts of GObject (GBoxed and subclassing GObject) that require large modifications of source code, and splitting at this moment would be an obstacle.
I've though about performance of MOP, but I'll have to measure it (from what I can tell, MOP is a balanced protocol that allows efficiency in implementation). There are many ways where performance may drop, and all of them require measuring before deciding. But for now, I want to have a working GObject binding.

Harnon
Posts: 78
Joined: Wed Jul 30, 2008 9:59 am

Re: cffi-clutter

Post by Harnon » Wed Jul 29, 2009 11:26 am

Heh, i finally got 0.9.8 and 1.0.0. Soon, i can start playing with clutter. :D If anyone on windows needs help, just ask...

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: cffi-clutter

Post by ramarren » Wed Jul 29, 2009 12:47 pm

Harnon wrote:Heh, i finally got 0.9.8 and 1.0.0. Soon, I can start playing with clutter. :D If anyone on windows needs help, just ask...
I haven't yet noticed that 1.0.0 was out... as far as I can see there were no API changes since 0.9.6 on which I based the binding, so it should work without problems, but I will rerun the examples just in case. Not that they cover all that much, but will check if basic initialization didn't suddenly start to fail.

Harnon
Posts: 78
Joined: Wed Jul 30, 2008 9:59 am

Re: cffi-clutter

Post by Harnon » Sun Aug 02, 2009 1:14 pm

Just wandering, do i need threads to use clutter? You said it was pretty low level, lots of callbacks....

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: cffi-clutter

Post by ramarren » Sun Aug 02, 2009 1:51 pm

Harnon wrote:Just wandering, do i need threads to use clutter? You said it was pretty low level, lots of callbacks....
Threads are not necessary, but obviously without threads clutter main loop will block the REPL. GObject based systems are not very amenable to parallelism anyway due to signal propagation, so it is not as the graphics themselves can be threaded.

There is an option to init-clutter wrapper function controlling threads initialization, but it shouldn't really matter to the Lisp side.

_deepfire

Re: cffi-clutter

Post by _deepfire » Sun Aug 16, 2009 10:57 am

Good day Jakub,

I've sent you a mail, referring to a patch making cffi-clutter build on a more-or-less default machine, but never got a reply.

I guess gmail has my server blacklisted.

I reproduce the email below:

Good day Jakub, git://git.feelingofgreen.ru/cffi-clutter has two patches:
- streamlining loadability on (at least) ubuntu karmic, by using the :OR
feature of CFFI library path specification, and conditionalising out
the apparently unused private API references
- a basic .gitignore.
regards, Samium Gromoff

Post Reply