writePGF now allows to select list of languages

This commit is contained in:
Krasimir Angelov
2023-01-28 11:59:39 +01:00
parent 471adbf63a
commit 8fca37cfeb
9 changed files with 76 additions and 14 deletions

View File

@@ -188,11 +188,15 @@ newNGF abs_name mb_fpath =
fptr <- newForeignPtrEnv pgf_free_revision c_db c_revision
return (PGF c_db fptr Map.empty)
writePGF :: FilePath -> PGF -> IO ()
writePGF fpath p =
writePGF :: FilePath -> PGF -> Maybe [ConcName] -> IO ()
writePGF fpath p mb_langs =
withCString fpath $ \c_fpath ->
withForeignPtr (a_revision p) $ \c_revision ->
withPgfExn "writePGF" (pgf_write_pgf c_fpath (a_db p) c_revision)
maybe (\f -> f nullPtr) (withLangs []) mb_langs $ \c_langs ->
withPgfExn "writePGF" (pgf_write_pgf c_fpath (a_db p) c_revision c_langs)
where
withLangs clangs [] f = withArray0 nullPtr (reverse clangs) f
withLangs clangs (lang:langs) f = withText lang $ \clang -> withLangs (clang:clangs) langs f
showPGF :: PGF -> String
showPGF p =

View File

@@ -78,7 +78,7 @@ foreign import ccall pgf_new_ngf :: Ptr PgfText -> CString -> Ptr (Ptr PGF) -> P
foreign import ccall pgf_merge_pgf :: Ptr PgfDB -> Ptr PGF -> CString -> Ptr PgfExn -> IO ()
foreign import ccall pgf_write_pgf :: CString -> Ptr PgfDB -> Ptr PGF -> Ptr PgfExn -> IO ()
foreign import ccall pgf_write_pgf :: CString -> Ptr PgfDB -> Ptr PGF -> Ptr (Ptr PgfText) -> Ptr PgfExn -> IO ()
foreign import ccall "pgf_free_revision" pgf_free_revision_ :: Ptr PgfDB -> Ptr PGF -> IO ()