From: Andy S. <And...@co...> - 2010-10-21 17:21:24
|
diffing dir... Wed Oct 20 20:37:01 EDT 2010 John Obbele <joh...@gm...> * Add wrapNewGObject to glib/**/GObject.chs Ignore-this: 9f5af0a8896f9cc4b83f84da5c97a5ab { hunk ./glib/System/Glib/GObject.chs 43 + wrapNewGObject, hunk ./glib/System/Glib/GObject.chs 149 +-- | This function wraps any newly created object that does not derived +-- from GInitiallyUnowned (that is a GObject with no floating +-- reference). Since newly created 'GObject's have a reference count of +-- one, they don't need ref'ing. +-- +wrapNewGObject :: GObjectClass obj => [_$_] + (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj +wrapNewGObject (constr, objectUnref) generator = do + objPtr <- generator + when (objPtr == nullPtr) (fail "wrapNewGObject: object is NULL") + obj <- newForeignPtr objPtr objectUnref + return $! constr obj + } |