From: Duncan C. <dun...@us...> - 2004-12-08 00:08:46
|
Update of /cvsroot/gtk2hs/gtk2hs/gconf/System/Gnome/GConf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16252/gconf/System/Gnome/GConf Modified Files: GConfClient.chs GConfValue.chs Log Message: Apply a couple of patches that we had in our old c2hs tree to our new one. This makes c2hs understand hierarchical module names and fixes the handling of typedef'ed C types. Also make GConfValue.chs & GConfClient.chs work with our new c2hs. It's not entirely obvious to me if this is an improvement in c2hs or a regression. Index: GConfValue.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gconf/System/Gnome/GConf/GConfValue.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GConfValue.chs 8 Aug 2004 19:09:56 -0000 1.3 +++ GConfValue.chs 8 Dec 2004 00:08:21 -0000 1.4 @@ -110,8 +110,8 @@ marshalToGConfValue n = do value <- {# call unsafe gconf_value_new #} (fromIntegral $ fromEnum GconfValueInt) - {# call unsafe gconf_value_set_int #} value (fromIntegral n) - return value + {# call unsafe gconf_value_set_int #} (GConfValue value) (fromIntegral n) + return (GConfValue value) instance GConfValueClass Bool where typeofGConfValue _ = GconfValueBool @@ -119,8 +119,8 @@ marshalToGConfValue b = do value <- {# call unsafe gconf_value_new #} (fromIntegral $ fromEnum GconfValueBool) - {# call unsafe gconf_value_set_bool #} value (fromBool b) - return value + {# call unsafe gconf_value_set_bool #} (GConfValue value) (fromBool b) + return (GConfValue value) instance GConfValueClass Double where typeofGConfValue _ = GconfValueFloat @@ -128,8 +128,8 @@ marshalToGConfValue f = do value <- {# call unsafe gconf_value_new #} (fromIntegral $ fromEnum GconfValueFloat) - {# call unsafe gconf_value_set_float #} value (realToFrac f) - return value + {# call unsafe gconf_value_set_float #} (GConfValue value) (realToFrac f) + return (GConfValue value) -- Now unfortunately String & [a] overlap, although really they don't since Char -- is not an instance of GConfPrimitiveValueClass, however classes are open so @@ -145,8 +145,8 @@ value <- {# call unsafe gconf_value_new #} (fromIntegral $ fromEnum GconfValueString) withCString s $ \strPtr -> - {# call unsafe gconf_value_set_string #} value strPtr - return value + {# call unsafe gconf_value_set_string #} (GConfValue value) strPtr + return (GConfValue value) instance (GConfPrimitiveValueClass a, GConfPrimitiveValueClass b) => GConfValueClass (a,b) where typeofGConfValue _ = GconfValuePair @@ -154,8 +154,8 @@ unsafeMarshalFromGConfValue value = do a <- {# call unsafe gconf_value_get_car #} value b <- {# call unsafe gconf_value_get_cdr #} value - a' <- marshalFromGConfValue a - b' <- marshalFromGConfValue b + a' <- marshalFromGConfValue (GConfValue a) + b' <- marshalFromGConfValue (GConfValue b) return (a',b') marshalToGConfValue (a,b) = do @@ -163,9 +163,9 @@ (fromIntegral $ fromEnum GconfValuePair) a' <- marshalToGConfValue a b' <- marshalToGConfValue b - {# call unsafe gconf_value_set_car_nocopy #} value a' - {# call unsafe gconf_value_set_cdr_nocopy #} value b' - return value + {# call unsafe gconf_value_set_car_nocopy #} (GConfValue value) a' + {# call unsafe gconf_value_set_cdr_nocopy #} (GConfValue value) b' + return (GConfValue value) instance GConfPrimitiveValueClass a => GConfValueClass [a] where @@ -189,10 +189,10 @@ (fromIntegral $ fromEnum GconfValueList) valuesPtrs <- mapM (liftM (\(GConfValue ptr) -> ptr) . marshalToGConfValue) list valuesList <- toGSList valuesPtrs - {# call unsafe gconf_value_set_list_type #} value + {# call unsafe gconf_value_set_list_type #} (GConfValue value) (fromIntegral $ fromEnum $ typeofGConfValue (undefined::a)) - {# call unsafe gconf_value_set_list_nocopy #} value valuesList - return value + {# call unsafe gconf_value_set_list_nocopy #} (GConfValue value) valuesList + return (GConfValue value) ---------------- -- For convenience and best practice, an instance for Enum @@ -273,19 +273,19 @@ (fromIntegral $ fromEnum GconfValueList) valuesPtrs <- mapM (liftM (\(GConfValue ptr) -> ptr) . marshalToGConfValue) as valuesList <- toGSList valuesPtrs - {# call unsafe gconf_value_set_list_type #} value + {# call unsafe gconf_value_set_list_type #} (GConfValue value) (fromIntegral $ fromEnum $ (case as of [] -> GconfValueInvalid --unknown type (a:_) -> gconfValueDynGetType (head as))) - {# call unsafe gconf_value_set_list_nocopy #} value valuesList - return value + {# call unsafe gconf_value_set_list_nocopy #} (GConfValue value) valuesList + return (GConfValue value) unsafeMarshalGConfValueDynPairFromGConfValue :: GConfValue -> IO (GConfValueDyn, GConfValueDyn) unsafeMarshalGConfValueDynPairFromGConfValue value = do a <- {# call unsafe gconf_value_get_car #} value b <- {# call unsafe gconf_value_get_cdr #} value - a' <- marshalFromGConfValue a - b' <- marshalFromGConfValue b + a' <- marshalFromGConfValue (GConfValue a) + b' <- marshalFromGConfValue (GConfValue b) return (a', b') marshalGConfValueDynPairToGConfValue :: (GConfValueDyn, GConfValueDyn) -> IO GConfValue @@ -294,9 +294,9 @@ (fromIntegral $ fromEnum GconfValuePair) a' <- marshalToGConfValue a b' <- marshalToGConfValue b - {# call unsafe gconf_value_set_car_nocopy #} value a' - {# call unsafe gconf_value_set_cdr_nocopy #} value b' - return value + {# call unsafe gconf_value_set_car_nocopy #} (GConfValue value) a' + {# call unsafe gconf_value_set_cdr_nocopy #} (GConfValue value) b' + return (GConfValue value) instance GConfValueClass GConfValueDyn where typeofGConfValue _ = undefined -- will never be used Index: GConfClient.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gconf/System/Gnome/GConf/GConfClient.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- GConfClient.chs 19 Aug 2004 07:54:19 -0000 1.5 +++ GConfClient.chs 8 Dec 2004 00:08:21 -0000 1.6 @@ -222,7 +222,7 @@ keyStrPtr <- {# call unsafe gconf_entry_get_key #} entry valuePtr <- {# call unsafe gconf_entry_get_value #} entry key <- peekUTFString keyStrPtr - value <- marshalFromGConfValue valuePtr + value <- marshalFromGConfValue (GConfValue valuePtr) handler key value gconfNotifyRemove :: GConf -> GConfConnectId -> IO () @@ -241,7 +241,7 @@ value <- propagateGError $ \gerrorPtr -> withCString key $ \strPtr -> {# call gconf_client_get #} gc strPtr gerrorPtr - marshalFromGConfValue value + marshalFromGConfValue (GConfValue value) gconfGetInt :: GConf -> String -> IO Int gconfGetInt = gconfGet @@ -308,7 +308,7 @@ value <- propagateGError $ \gerrorPtr -> withCString key $ \strPtr -> {# call gconf_client_get_without_default #} gc strPtr gerrorPtr - marshalFromGConfValue value + marshalFromGConfValue (GConfValue value) -- | Returns the default value stored in the key's schema, if the key has a -- schema associated and the schema exists and the schema contains a default @@ -321,7 +321,7 @@ value <- propagateGError $ \gerrorPtr -> withCString key $ \strPtr -> {# call gconf_client_get_default_from_schema #} gc strPtr gerrorPtr - marshalFromGConfValue value + marshalFromGConfValue (GConfValue value) -- | Unsets the value of key; if key is already unset, has no effect. An error -- of note is 'GConfOverridden', indicating that the system administrator has @@ -375,7 +375,7 @@ keyStrPtr <- {# call unsafe gconf_entry_get_key #} entry' valuePtr <- {# call unsafe gconf_entry_get_value #} entry' key <- peekUTFString keyStrPtr - value <- marshalFromGConfValue valuePtr + value <- marshalFromGConfValue (GConfValue valuePtr) -- gconf_entry_free is depreciated, use gconf_entry_unref -- however gconf_entry_unref is not documented and docs -- still say to use gconf_entry_free. Confusing. |