From: <as...@us...> - 2003-07-09 22:43:18
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/entry In directory sc8-pr-cvs1:/tmp/cvs-serv25460/gtk/entry Modified Files: Entry.chs HScale.chs SpinButton.chs VScale.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: Entry.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/entry/Entry.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Entry.chs 8 Nov 2002 10:39:21 -0000 1.6 +++ Entry.chs 9 Jul 2003 22:42:43 -0000 1.7 @@ -78,8 +78,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} @@ -89,10 +89,10 @@ -- methods originating in the Editable base class which is not really a base -- class of in the Gtk Hierarchy (it is non-existant). I renamed -{#pointer *Editable foreign#} +{#pointer *Editable foreign newtype#} toEditable :: EntryClass ed => ed -> Editable -toEditable = castForeignPtr.unEntry.toEntry +toEditable = Editable . castForeignPtr . unEntry . toEntry -- @method entrySelectRegion@ Select a span of text. -- @@ -126,7 +126,7 @@ -- entryInsertText :: EntryClass ed => ed -> String -> Int -> IO Int entryInsertText ed str pos = withObject (fromIntegral pos) $ \posPtr -> - withCStringLen str $ \(strPtr,len) -> do + withUTFStringLen str $ \(strPtr,len) -> do {#call editable_insert_text#} (toEditable ed) strPtr (fromIntegral len) posPtr liftM fromIntegral $ peek posPtr @@ -150,7 +150,7 @@ entryGetChars ed start end = do strPtr <- {#call unsafe editable_get_chars#} (toEditable ed) (fromIntegral start) (fromIntegral end) - str <- peekCString strPtr + str <- peekUTFString strPtr {#call unsafe g_free#} (castPtr strPtr) return str @@ -206,24 +206,24 @@ -- @method entrySetText@ Set the text of the @ref type Entry@ widget. -- entrySetText :: EntryClass ec => ec -> String -> IO () -entrySetText ec str = withCString str $ {#call entry_set_text#} (toEntry ec) +entrySetText ec str = withUTFString str $ {#call entry_set_text#} (toEntry ec) -- @method entryGetText@ Get the text of the @ref type Entry@ widget. -- entryGetText :: EntryClass ec => ec -> IO String -entryGetText ec = {#call entry_get_text#} (toEntry ec) >>= peekCString +entryGetText ec = {#call entry_get_text#} (toEntry ec) >>= peekUTFString -- @method entryAppendText@ Append to the text of the @ref type Entry@ widget. -- entryAppendText :: EntryClass ec => ec -> String -> IO () entryAppendText ec str = - withCString str $ {#call entry_append_text#} (toEntry ec) + withUTFString str $ {#call entry_append_text#} (toEntry ec) -- @method entryPrependText@ Prepend the text of the @ref type Entry@ widget. -- entryPrependText :: EntryClass ec => ec -> String -> IO () entryPrependText ec str = - withCString str $ {#call entry_prepend_text#} (toEntry ec) + withUTFString str $ {#call entry_prepend_text#} (toEntry ec) -- @method entrySetVisibility@ Set whether to use password mode (display stars -- instead of the text). Index: HScale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/entry/HScale.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- HScale.chs 24 May 2002 09:43:24 -0000 1.2 +++ HScale.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -36,8 +36,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: SpinButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/entry/SpinButton.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SpinButton.chs 5 Aug 2002 16:41:34 -0000 1.3 +++ SpinButton.chs 9 Jul 2003 22:42:43 -0000 1.4 @@ -61,8 +61,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} Index: VScale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/entry/VScale.chs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- VScale.chs 24 May 2002 09:43:24 -0000 1.2 +++ VScale.chs 9 Jul 2003 22:42:43 -0000 1.3 @@ -36,8 +36,8 @@ ) where import Monad (liftM) -import Foreign -import UTFCForeign +import FFI + import Object (makeNewObject) {#import Hierarchy#} {#import Signal#} |