From 187b83e0292617c1660a59924fc339a827cd8a5e Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 1 Jun 2017 23:59:50 +1200 Subject: [PATCH] Add `noX :: Maybe X; noX = Nothing` functions --- domconv-webkit-jsaddle.hs | 6 +++++- domconv-webkit-jsffi.hs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/domconv-webkit-jsaddle.hs b/domconv-webkit-jsaddle.hs index 4f94667..9f5dd73 100644 --- a/domconv-webkit-jsaddle.hs +++ b/domconv-webkit-jsaddle.hs @@ -123,7 +123,7 @@ makeWebkitBindings idl args = do ffiExports name allParents = " , " ++ name ++ "(" ++ name ++ "), un" ++ name ++ (if name `elem` allParents then ", Is" ++ name ++ ", to" ++ name else "") - ++ ", " ++ "gType" ++ name + ++ ", no" ++ name ++ ", gType" ++ name ffiTypes hh prntmap allParents = forM_ prntmap $ \(n, parents) -> hPutStrLn hh $ @@ -176,6 +176,10 @@ makeWebkitBindings idl args = do ++ " typeGType _ = gType" ++ name ++ "\n" ++ " {-# INLINE typeGType #-}\n\n" + ++ "no" ++ name ++ " :: Maybe " ++ name ++ "\n" + ++ "no" ++ name ++ " = Nothing\n" + ++ "{-# INLINE no" ++ name ++ " #-}\n\n" + ++ "gType" ++ name ++ " :: JSM GType\n" ++ "gType" ++ name ++ " = GType . Object <$> jsg \"" ++ jsname name ++ "\"\n" oldWebKitGuard name s | webkitTypeGuard name /= "webkit-dom" = "#ifndef USE_OLD_WEBKIT\n" ++ s ++ "#endif\n" diff --git a/domconv-webkit-jsffi.hs b/domconv-webkit-jsffi.hs index 755aac2..eeb17d8 100644 --- a/domconv-webkit-jsffi.hs +++ b/domconv-webkit-jsffi.hs @@ -124,7 +124,7 @@ makeWebkitBindings idl args = do ffiExports name allParents = " , " ++ name ++ "(" ++ name ++ "), un" ++ name ++ (if name `elem` allParents then ", Is" ++ name ++ ", to" ++ name else "") - ++ ", " ++ "gType" ++ name + ++ ", no" ++ name ++ ", gType" ++ name jsffiTypes hh prntmap allParents = forM_ prntmap $ \(n, parents) -> hPutStrLn hh $ @@ -172,6 +172,10 @@ makeWebkitBindings idl args = do ++ " typeGType _ = gType" ++ name ++ "\n" ++ " {-# INLINE typeGType #-}\n" + ++ "no" ++ name ++ " :: Maybe " ++ name ++ "\n" + ++ "no" ++ name ++ " = Nothing\n" + ++ "{-# INLINE no" ++ name ++ " #-}\n\n" + ++ "foreign import javascript unsafe \"window[\\\"" ++ jsname name ++ "\\\"]\" gType" ++ name ++ " :: GType\n" webkitTypes hh prntmap allParents = forM_ prntmap $ \(n, parents) -> hPutStrLn hh $