Update of /cvsroot/gtk2hs/gtk2hs/gtk/abstract In directory sc8-pr-cvs1:/tmp/cvs-serv25460/gtk/abstract Modified Files: Box.chs Container.chs Misc.chs Object.chs Paned.chs Range.chs Scale.chs Widget.chs Log Message: Make compile with GHC 6.00. There are two major changes in the FFI which made me separate everything that has to do with Foreign and Foreign.C into a new file called general/FFI.hs. The file UTFCForeign.hs is now obsolete as its string conversion functions are now in FFI.hs. The nullForeignPtr function is also located here. All files now import FFI instead of Foreign and UTFCForeign. The major changes are: newForeignPtr now takes a pointer to a C function as finalizer. Every destructor function is now defined differently depending on whether the new GHC is used or not. In particular there is now a function called free :: Ptr a -> IO () imported from the Foreign library. In addition to that I defined a function foreignFree which can be used as finalizer to a C data structure. It is equivalent to free if GHC version <=5.04 is used. The second change is that ForeignPtr are no longer accepted as arguments to foreign calls. This change is mainly reflected in c2hs, but also in some files which directly called functions. Index: Box.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Box.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Box.chs 8 Nov 2002 10:39:21 -0000 1.6 +++ Box.chs 9 Jul 2003 22:42:43 -0000 1.7 @@ -47,8 +47,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: Container.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Container.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Container.chs 6 Oct 2002 16:14:07 -0000 1.4 +++ Container.chs 9 Jul 2003 22:42:43 -0000 1.5 @@ -61,8 +61,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import GObject (objectRef, objectUnref) import Object (makeNewObject) {#import Hierarchy#} @@ -162,7 +162,7 @@ -- strPtr <- throwIfNull "containerChildCompositeName: illegal name returned" $ -- {#call unsafe container_child_composite_name#} (toContainer con) -- (toWidget widget) --- str <- peekCString strPtr +-- str <- peekUTFString strPtr -- {#call unsafe g_free#} (castPtr strPtr) -- return str Index: Misc.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Misc.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Misc.chs 24 May 2002 09:43:24 -0000 1.2 +++ Misc.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -37,8 +37,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + {#import Hierarchy#} {#import Signal#} Index: Object.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Object.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Object.chs 5 Aug 2002 16:41:34 -0000 1.6 +++ Object.chs 9 Jul 2003 22:42:43 -0000 1.7 @@ -1,3 +1,4 @@ +{-# OPTIONS -cpp #-} -- -*-haskell-*- -- GIMP Toolkit (GTK) @entry Object@ -- @@ -44,8 +45,8 @@ objectGetProperty ) where -import Foreign -import UTFCForeign (withCString, CChar) +import FFI + import GObject (objectRef, objectUnref) {#import Signal#} {#import Hierarchy#} @@ -69,9 +70,18 @@ objectSink :: ObjectClass obj => Ptr obj -> IO () objectSink = object_sink.castPtr +#if __GLASGOW_HASKELL__>=504 + +foreign import ccall unsafe "gtk_object_sink" + object_sink :: Ptr Object -> IO () + +#else + foreign import ccall "gtk_object_sink" unsafe object_sink :: Ptr Object -> IO () +#endif + -- This is a convenience function to generate a new widget. It adds the -- finalizer with the method described under objectSink. -- @@ -96,7 +106,7 @@ -- objectSetProperty :: GObjectClass gobj => gobj -> String -> GenericValue -> IO () -objectSetProperty obj prop val = alloca $ \vaPtr -> withCString prop $ +objectSetProperty obj prop val = alloca $ \vaPtr -> withUTFString prop $ \sPtr -> poke vaPtr val >> {#call unsafe g_object_set_property#} (toGObject obj) sPtr vaPtr >> valueUnset vaPtr @@ -107,7 +117,7 @@ -- objectGetProperty :: GObjectClass gobj => gobj -> String -> IO GenericValue -objectGetProperty obj prop = alloca $ \vaPtr -> withCString prop $ \str -> do +objectGetProperty obj prop = alloca $ \vaPtr -> withUTFString prop $ \str -> do {#call unsafe g_object_get_property#} (toGObject obj) str vaPtr res <- peek vaPtr valueUnset vaPtr Index: Paned.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Paned.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Paned.chs 19 Dec 2002 18:13:39 -0000 1.3 +++ Paned.chs 9 Jul 2003 22:42:43 -0000 1.4 @@ -43,8 +43,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: Range.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Range.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Range.chs 8 Nov 2002 10:39:21 -0000 1.3 +++ Range.chs 9 Jul 2003 22:42:43 -0000 1.4 @@ -44,8 +44,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: Scale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Scale.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Scale.chs 24 May 2002 09:43:24 -0000 1.2 +++ Scale.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -40,8 +40,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: Widget.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Widget.chs,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Widget.chs 8 Mar 2003 17:44:00 -0000 1.11 +++ Widget.chs 9 Jul 2003 22:42:43 -0000 1.12 @@ -152,8 +152,8 @@ ) where import Monad (liftM, unless) -import UTFCForeign -import Foreign + +import FFI import Object (makeNewObject) import GObject (makeNewGObject) {#import Hierarchy#} @@ -239,7 +239,7 @@ --w `onStyleChanged` update@ -- widgetCreateLayout :: WidgetClass obj => obj -> String -> IO PangoLayout -widgetCreateLayout obj txt = withCString txt $ +widgetCreateLayout obj txt = withUTFString txt $ \strPtr -> makeNewGObject mkPangoLayout ({#call unsafe widget_create_pango_layout#} (toWidget obj) strPtr) @@ -296,13 +296,13 @@ -- widgetSetName :: WidgetClass w => w -> String -> IO () widgetSetName w name = - withCString name ({#call widget_set_name#} (toWidget w)) + withUTFString name ({#call widget_set_name#} (toWidget w)) -- @method widgetGetName@ Get the name of a widget. -- widgetGetName :: WidgetClass w => w -> IO String widgetGetName w = {#call unsafe widget_get_name#} (toWidget w) >>= - peekCString + peekUTFString -- @method widgetAddEvents@ Enable event signals. -- |