the namespace iterator now takes a PgfExn parameter like in the old runtime

This commit is contained in:
krangelov
2021-08-31 09:31:06 +02:00
parent aecaa422ec
commit e0288f46dc
6 changed files with 80 additions and 74 deletions

View File

@@ -187,15 +187,16 @@ categories p =
unsafePerformIO $ do
ref <- newIORef []
(allocaBytes (#size PgfItor) $ \itor ->
allocaBytes (#size PgfExn) $ \c_exn ->
bracket (wrapItorCallback (getCategories ref)) freeHaskellFunPtr $ \fptr ->
withForeignPtr (a_pgf p) $ \p_pgf -> do
(#poke PgfItor, fn) itor fptr
pgf_iter_categories p_pgf itor
pgf_iter_categories p_pgf itor c_exn
cs <- readIORef ref
return (reverse cs))
where
getCategories :: IORef [String] -> ItorCallback
getCategories ref itor key = do
getCategories ref itor key exn = do
names <- readIORef ref
name <- peekText key
writeIORef ref $ (name : names)
@@ -243,15 +244,16 @@ functions p =
unsafePerformIO $ do
ref <- newIORef []
(allocaBytes (#size PgfItor) $ \itor ->
allocaBytes (#size PgfExn) $ \c_exn ->
bracket (wrapItorCallback (getFunctions ref)) freeHaskellFunPtr $ \fptr ->
withForeignPtr (a_pgf p) $ \p_pgf -> do
(#poke PgfItor, fn) itor fptr
pgf_iter_functions p_pgf itor
pgf_iter_functions p_pgf itor c_exn
fs <- readIORef ref
return (reverse fs))
where
getFunctions :: IORef [String] -> ItorCallback
getFunctions ref itor key = do
getFunctions ref itor key exn = do
names <- readIORef ref
name <- peekText key
writeIORef ref $ (name : names)
@@ -263,15 +265,16 @@ functionsByCat p cat =
ref <- newIORef []
(withText cat $ \c_cat ->
allocaBytes (#size PgfItor) $ \itor ->
allocaBytes (#size PgfExn) $ \c_exn ->
bracket (wrapItorCallback (getFunctions ref)) freeHaskellFunPtr $ \fptr ->
withForeignPtr (a_pgf p) $ \p_pgf -> do
(#poke PgfItor, fn) itor fptr
pgf_iter_functions_by_cat p_pgf c_cat itor
pgf_iter_functions_by_cat p_pgf c_cat itor c_exn
fs <- readIORef ref
return (reverse fs))
where
getFunctions :: IORef [String] -> ItorCallback
getFunctions ref itor key = do
getFunctions ref itor key exn = do
names <- readIORef ref
name <- peekText key
writeIORef ref $ (name : names)