FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cairo bindings

 
Post new topic   Reply to topic     Forum Index -> Bindings
View previous topic :: View next topic  
Author Message
DRK



Joined: 18 Apr 2006
Posts: 11

PostPosted: Thu May 04, 2006 8:44 am    Post subject: cairo bindings Reply with quote

Hi all.

Just wanted to announce that I've checked in a set of bindings for the cairo api. They're available in svn in the bindings/trunk/cairo directory, and currently support the base cairo functions, PNG functions, and Win32 functions.

Comments and suggestions welcome Smile

-- Daniel "So... many... functions... but must... keep typing..." Keep
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Fri Mar 02, 2007 10:36 pm    Post subject: Reply with quote

Hi,

Your bindings for cairo are either not compatible with d 1.0 or extremely bug ridden. I've been trying to get them working for hours with just more and more bugs popping up as I fix each.

I start with:

F:\Toolchain--D\compiler\bin\..\import\cairooo\callbacks.d(52): Error: identifier 'cairo_status_t' is not defined

this is followed by about a hundred similar messages, this enum is defined in cairo.cairotypes, but it appears as if the cairooo.* packages don't recognise anything from the cairo.* packages, despite finding and the files just fine.

I can fix this by manually importing cairo.cairotypes at the top of the offending files, then I get other errors, and so on and so on.

I was just curious as to if you (or anyone) had any ideas. Thanks for reading this.
Back to top
View user's profile Send private message
DRK



Joined: 18 Apr 2006
Posts: 11

PostPosted: Sat Mar 03, 2007 1:00 am    Post subject: Reply with quote

That's because they're almost a year old, and much has changed since then.

Basically, I never updated them since no one seemed particularly interested in them, and I didn't have much use for them.

That said, I'm doing a new computer graphics subject this year, so I may end up updating the whole thing for D 1.0 and cairo 1.4 (I think it's up to 1.4...).

As for the errors, it may simply be faster to start from scratch. cairo.* is mostly just auto-generated from a list of declarations (so fix the generator, and you fix the output). cairooo.* should hopefully only need a few adjustments, since it's largely just class wrappers for the stuff in cairo.*.

Anyway, no promises, but I'll look into it sometime soon.
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Sat Mar 03, 2007 7:47 pm    Post subject: Reply with quote

Thanks for your reply. I'm kind of glad it was a version issue, I was starting to worry that my compiler wasn't set up properly even though I've had it working with everything else.

what generator is used to create the bindings for cairo.* ?
Back to top
View user's profile Send private message
dan.lewis



Joined: 21 Feb 2007
Posts: 69
Location: Canada

PostPosted: Sat Mar 03, 2007 8:02 pm    Post subject: Reply with quote

Yeah. I like generators. : )

*not answering his question 'cause I don't know.
_________________
nop
nop ; problem solved
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Sun Mar 04, 2007 1:03 am    Post subject: Reply with quote

I tried to compile bcdgen but it has dependency problems (libxml2.lib doesn't want to link, saying it's an invalid library). Is there any chance you have a precompiled bcdgen, if that's what you used?

There's swig but it hasn't been updated since 2004 so I seriously doubt that will generate 1.0 compatible bindings. I don't understand why this stuff is even still available, it should be deleted because it's confusing.
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun Mar 04, 2007 12:08 pm    Post subject: Reply with quote

chojin wrote:
There's swig but it hasn't been updated since 2004 so I seriously doubt that will generate 1.0 compatible bindings. I don't understand why this stuff is even still available, it should be deleted because it's confusing.
The fact that swig4d is in the "Inactive" forum categories should be a good clue that the project hasn't been worked on in a while (unfortunately, most of the "Active" projects haven't been worked on in a while either).

The old work is still available because perhaps it's easier to start where the previous efforts left off. No one is hiding how long it's been since anyone worked on a particular project. I'd usually rather finish what someone started on that start from scratch, but different people have different preferences. If a project has been Tracified all one has to do is look at the "Timeline". If a project doesn't have Trac, that's a good clue it hasn't been worked on recently.

There are plans to make it more obvious how active a particular project is, but I don't know when that information will be available.
Back to top
View user's profile Send private message AIM Address
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Sun Mar 04, 2007 12:34 pm    Post subject: Reply with quote

jcc7 wrote:
The fact that swig4d is in the "Inactive" forum categories should be a good clue that the project hasn't been worked on in a while (unfortunately, most of the "Active" projects haven't been worked on in a while either). The old work is still available because perhaps it's easier to start where the previous efforts left off. .


I can understand that. I just have been frustrated because it seems everything I go to try with D is buggy or outdated. But I know the community is small at the moment. I remember when I was first playing with it and even all the tutorials I was doing were pretty much immediately outdated. Now that it's hit 1.0 I'm trying it again but it's still all over the place. Understandable, but frustrating. It will be great when those new features come in.

Anyway all I want to really do is update these cairo bindings, I'll commit them to the CVS when I'm done. Just need to work out how they were originally done so that I can update them properly.
Back to top
View user's profile Send private message
DRK



Joined: 18 Apr 2006
Posts: 11

PostPosted: Mon Mar 05, 2007 3:29 am    Post subject: Reply with quote

Well, it seems that I likely will be using DFL + cairo for this course, so I'm going to have to update them pretty damn soon (as in, over the next few days).

As for the generator, it wasn't bcdgen or swig... it was a little Python script that read in a list of the declarations, and then spat out the D declarations, the loading code, etc.

As for HOW I arrived at this list: I simply took the cairo.h in the distribution I got, and stripped out all the extra stuff from that, made a few batch changes with some regular expressions, and wrote the Python script to take it the rest of the way.

Like I said, over the next few days, I going to need to dig all this out again, so we'll see what happens.
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Mon Mar 05, 2007 2:24 pm    Post subject: Reply with quote

DRK,

I managed to generate some bindings for cairo, and I've converted the script from the cairo docs:

http://www.cairographics.org/SDLCLock

over to D. This code interacts with cairo and SDL, which I'm using the derelict libs for. My process was basically, convert the files in this package:

ftp://ftp.gtk.org/pub/gtk/v2.8/win32/cairo-dev-1.2.6.zip

using bcdgen over to several d files, created a loader using derelicts launcher (similar to what you did) and used an all.d import module to include all the other ones. I then compile these .d files into a lib, put them in /lib/ and put the generated files into /import/cairo.

I also grab relevant dll's from:

ftp://ftp.gtk.org/pub/gtk/v2.8/win32/cairo-1.2.6.zip

This all works fine and I am so close to getting it working, it compiles, it just doesn't link (with cairo. links fine with sdl). I get:

F:\Toolchain--D\compiler\samples\cairo\cairoload>build -clean clock.d sdl.lib ca
iro.lib
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved

clock.obj(clock)
Error 42: Symbol Undefined _cairo_fill
clock.obj(clock)
Error 42: Symbol Undefined _cairo_move_to
clock.obj(clock)
Error 42: Symbol Undefined _cairo_line_to
clock.obj(clock)
Error 42: Symbol Undefined _cairo_set_source_rgba
clock.obj(clock)
Error 42: Symbol Undefined _cairo_paint
clock.obj(clock)
Error 42: Symbol Undefined _cairo_set_line_cap
....

Any ideas?

I may save you some work converting them yourself if you help out on this set? I can send you a copy of my converted clock.d too if necessary.
Back to top
View user's profile Send private message
DRK



Joined: 18 Apr 2006
Posts: 11

PostPosted: Mon Mar 05, 2007 9:38 pm    Post subject: Reply with quote

chojin wrote:
...

F:\Toolchain--D\compiler\samples\cairo\cairoload>build -clean clock.d sdl.lib ca
iro.lib
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved

clock.obj(clock)
Error 42: Symbol Undefined _cairo_fill
clock.obj(clock)
Error 42: Symbol Undefined _cairo_move_to
clock.obj(clock)
Error 42: Symbol Undefined _cairo_line_to
clock.obj(clock)
Error 42: Symbol Undefined _cairo_set_source_rgba
clock.obj(clock)
Error 42: Symbol Undefined _cairo_paint
clock.obj(clock)
Error 42: Symbol Undefined _cairo_set_line_cap
....

Any ideas?

I may save you some work converting them yourself if you help out on this set? I can send you a copy of my converted clock.d too if necessary.


If I had to take a guess... those undefined symbols are coming out of clock.obj, AND you can see that they're using C name mangling. I'm not 100% sure since I've never used bcdgen (automatic conversion's for sissies! Razz) but shouldn't the library it generates have D mangling on the functions?

Without a closer look, I can't really say either way.

Also, I'm curious as to whether you solved the different sets of library functions the same way I did or another way Razz
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Mon Mar 05, 2007 10:30 pm    Post subject: Reply with quote

yeah, I did notice that it was using name mangling in the .obj, but the .d headers it produces are regular function names. from cairo.d, for example:

extern (C) void cairo_fill(void *);

I've added mangled versions as well, myself, but... no dice, still get the same errors?!

I thought you used an autogenerator which is why I took that path, there's around 200 functions to export in cairo.h alone, I figured it would be a silly idea to manually convert them all when cairo will probably put out a new version in a month? Better to develop an automatic solution and use frontend modules to interact with the autogenerated files. Maybe this is the reason your version is so outdated, being too hard to update manually Razz

Anyway, I'll pm you my deets
Back to top
View user's profile Send private message
DRK



Joined: 18 Apr 2006
Posts: 11

PostPosted: Mon Mar 05, 2007 10:33 pm    Post subject: Reply with quote

I've fixed everything in the cairo directory in svn, and re-ran all the snippets, tutorials and demos.

Basically, there were two changes to D since I wrote that code that broke everything.

  1. Imports were changed to private by default from public by default and
  2. implicit casts from arrays to pointers was disallowed.


Once I fixed those, it all worked perfectly. #2 there even exposed a few bugs in the snippets that I hadn't noticed before.

Finally, this has *not* been tested with the latest cairo libs; I've only tested it with my old copy of 1.0.4 from Tor Linqvist's (spelling?) site.

Sorry this took so long--I'm just glad it only turned out to be a few minor changes Smile
Back to top
View user's profile Send private message
chojin



Joined: 11 Feb 2007
Posts: 13

PostPosted: Tue Mar 06, 2007 12:36 am    Post subject: Reply with quote

nice work, I'll check it out now.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Bindings All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group