Skip to content

Commit

Permalink
Add noX :: Maybe X; noX = Nothing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Jun 1, 2017
1 parent d98909b commit 187b83e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion domconv-webkit-jsaddle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion domconv-webkit-jsffi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
Expand Down Expand Up @@ -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 $
Expand Down

0 comments on commit 187b83e

Please sign in to comment.