|
From: <as...@us...> - 2003-07-09 22:42:51
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/pango
In directory sc8-pr-cvs1:/tmp/cvs-serv25460/gtk/pango
Modified Files:
PangoLayout.chs PangoTypes.chs Rendering.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: PangoLayout.chs
===================================================================
RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/pango/PangoLayout.chs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- PangoLayout.chs 17 May 2003 22:57:07 -0000 1.5
+++ PangoLayout.chs 9 Jul 2003 22:42:45 -0000 1.6
@@ -95,8 +95,7 @@
) where
import Monad (liftM)
-import Foreign
-import UTFCForeign
+import FFI
{#import Hierarchy#}
import GObject (makeNewGObject)
import Markup (Markup)
@@ -134,20 +133,20 @@
-- @method layoutSetText@ Set the string in the layout.
--
layoutSetText :: PangoLayout -> String -> IO ()
-layoutSetText pl txt = withCStringLen txt $ \(strPtr,len) ->
+layoutSetText pl txt = withUTFStringLen txt $ \(strPtr,len) ->
{#call unsafe layout_set_text#} pl strPtr (fromIntegral len)
-- @method layoutGetText@ Retrieve the string in the layout.
--
layoutGetText :: PangoLayout -> IO String
-layoutGetText pl = {#call unsafe layout_get_text#} pl >>= peekCString
+layoutGetText pl = {#call unsafe layout_get_text#} pl >>= peekUTFString
-- @method layoutSetMarkup@ Set the string in the layout.
--
-- * The string may include @ref data Markup@.
--
layoutSetMarkup :: PangoLayout -> Markup -> IO ()
-layoutSetMarkup pl txt = withCStringLen txt $ \(strPtr,len) ->
+layoutSetMarkup pl txt = withUTFStringLen txt $ \(strPtr,len) ->
{#call unsafe layout_set_markup#} pl strPtr (fromIntegral len)
-- @method layoutSetMarkupWithAccel@ Set the string in the layout.
@@ -163,7 +162,7 @@
layoutSetMarkupWithAccel :: PangoLayout -> Markup -> IO Char
layoutSetMarkupWithAccel pl txt =
alloca $ \chrPtr ->
- withCStringLen txt $ \(strPtr,len) -> do
+ withUTFStringLen txt $ \(strPtr,len) -> do
{#call unsafe layout_set_markup_with_accel#} pl strPtr (fromIntegral len)
(fromIntegral (ord '_')) chrPtr
liftM (chr.fromIntegral) $ peek chrPtr
Index: PangoTypes.chs
===================================================================
RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/pango/PangoTypes.chs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- PangoTypes.chs 16 May 2003 22:25:16 -0000 1.2
+++ PangoTypes.chs 9 Jul 2003 22:42:45 -0000 1.3
@@ -1,3 +1,4 @@
+{-# OPTIONS -cpp #-}
-- GIMP Toolkit (GTK) - pango non-GObject types @entry PangoTypes@
--
-- Author : Axel Simon
@@ -31,13 +32,12 @@
module PangoTypes(
LayoutIter(LayoutIter),
layout_iter_free,
- LayoutLine,
+ LayoutLine(LayoutLine),
mkLayoutLine
) where
import Monad (liftM)
-import Foreign
-import UTFCForeign
+import FFI
{# context lib="pango" prefix="pango" #}
@@ -47,21 +47,65 @@
--
{#pointer *PangoLayoutIter as LayoutIter foreign newtype #}
-foreign import ccall "pango_layout_iter_free" unsafe
- layout_iter_free :: Ptr LayoutIter -> IO ()
-
-- @data LayoutLine@ A single line in a @ref data PangoLayout@.
--
{#pointer *PangoLayoutLine as LayoutLine foreign newtype #}
-foreign import ccall "pango_layout_line_ref" unsafe
- layout_line_ref :: Ptr LayoutLine -> IO ()
+mkLayoutLine :: Ptr LayoutLine -> IO LayoutLine
+mkLayoutLine llPtr = do
+ pango_layout_line_ref llPtr
+ liftM LayoutLine $ newForeignPtr llPtr (pango_layout_line_unref llPtr)
+
+
+#if __GLASGOW_HASKELL__>=600
+
+foreign import ccall unsafe "&pango_layout_iter_free"
+ layout_iter_free' :: FinalizerPtr LayoutIter
+
+layout_iter_free :: Ptr LayoutIter -> FinalizerPtr LayoutIter
+layout_iter_free _ = layout_iter_free'
+
+#elif __GLASGOW_HASKELL__>=504
+
+foreign import ccall unsafe "pango_layout_iter_free"
+ layout_iter_free :: Ptr LayoutIter -> IO ()
+
+#else
+
+foreign import ccall "pango_layout_iter_free" unsafe
+ layout_iter_free :: Ptr LayoutIter -> IO ()
+
+#endif
+
+#if __GLASGOW_HASKELL__>=600
+
+foreign import ccall unsafe "&pango_layout_line_unref"
+ pango_layout_line_unref' :: FinalizerPtr LayoutLine
+
+pango_layout_line_unref :: Ptr LayoutLine -> FinalizerPtr LayoutLine
+pango_layout_line_unref _ = pango_layout_line_unref'
+
+#elif __GLASGOW_HASKELL__>=504
+
+foreign import ccall unsafe "pango_layout_line_unref"
+ pango_layout_line_unref :: Ptr LayoutLine -> IO ()
+
+#else
foreign import ccall "pango_layout_line_unref" unsafe
- layout_line_unref :: Ptr LayoutLine -> IO ()
+ pango_layout_line_unref :: Ptr LayoutLine -> IO ()
-mkLayoutLine :: Ptr LayoutLine -> IO LayoutLine
-mkLayoutLine llPtr = do
- layout_line_ref llPtr
- liftM LayoutLine $ newForeignPtr llPtr (layout_line_unref llPtr)
+#endif
+
+#if __GLASGOW_HASKELL__>=504
+
+foreign import ccall unsafe "pango_layout_line_ref"
+ pango_layout_line_ref :: Ptr LayoutLine -> IO ()
+
+#else
+
+foreign import ccall "pango_layout_line_ref" unsafe
+ pango_layout_line_ref :: Ptr LayoutLine -> IO ()
+
+#endif
Index: Rendering.chs
===================================================================
RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/pango/Rendering.chs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Rendering.chs 9 Feb 2003 10:43:01 -0000 1.1
+++ Rendering.chs 9 Jul 2003 22:42:45 -0000 1.2
@@ -36,8 +36,8 @@
) where
import Monad (liftM)
-import Foreign
-import UTFCForeign
+import FFI
+
{#import Hierarchy#}
import GObject (makeNewGObject)
|