From: Duncan C. <dun...@wo...> - 2005-03-22 14:32:03
|
On Tue, 2005-03-22 at 08:28 +0000, Axel Simon wrote: > On Tue, 2005-03-22 at 04:38 +0000, Duncan Coutts wrote: > > FYI: I've modified the code generator to generate constructors like so: > > > > eventBoxNew :: IO EventBox > > eventBoxNew = > > makeNewObject mkEventBox $ > > liftM (castPtr :: Ptr Widget -> Ptr EventBox) $ > > {# call unsafe event_box_new #} > > > > It now inserts a castPtr call. The interesting bit is that it makes sure > > the cast is used safely by annotating it with a type. So if the type the > > code generator guesses is wrong, you'll fird out when you compile the > > module. > > Ok. Don't know if that makes things better - I doubt that this can go > wrong. No it can't go wrong at runtime or anything. It's more of a safty measure when using the code generator. It made me feel nervous having the code generator go round adding castPtr liberally since if it did something wrong it might mask the bug. > Shall we change makeNewObject to throw an exception if the > passed-in pointer is NULL. That is over due, really. Yep good idea. > A big problem might be the error message which ideally would at least > mention the type. And the function called too preferably. If ghc were better with its debugging stacktrace it wouldn't be so much of a problem. > > Basically all constructors for objects that derive from GtkWidget return > > a Widget rather than the specific subclass type. Though there are one or > > two exceptions. > > I vaguely recall that. > > What do we do about Cabal? I suppose we need to add a .cabal file and > install those with ghc 6.4 or later. Yes we probably do. I hadn't realsied before that ghc was going to drop backwards compatability for its package format. > BTW, I had to add -I. to compile > c2hs since ghc doesn't look in the current directory anymore when > searching for C include files (even if you say #include"..." which is > supposed to look into . as well). Is that the same thing I fixed? I changed: tools_c2hs_toplevel_C2HSConfig_hs_HCFLAGS = -fffi -fvia-C \ '-\#include<tools/c2hs/toplevel/c2hs_config.h>' to tools_c2hs_toplevel_C2HSConfig_hs_HCFLAGS = -fffi -fvia-C \ '-\#include<c2hs_config.h>' It's in cvs. Duncan BTW can we make the gtk2hs-devel list default to reply to list rather than reply to sender? |