now we can load PGF files as precompiled modules

This commit is contained in:
Krasimir Angelov
2024-01-30 13:02:40 +01:00
parent 021e271f29
commit c94d0f31bc
19 changed files with 161 additions and 99 deletions
+4
View File
@@ -19,6 +19,7 @@ module PGF2 (-- * PGF
#if defined(__linux__) || defined(__APPLE__)
writePGF_,
#endif
pgfFilePath,
-- * Abstract syntax
AbsName,abstractName,globalFlag,abstractFlag,
@@ -278,6 +279,9 @@ cookie_write cookie buf size = do
fmap fromIntegral $ (callback :: Ptr Word8 -> Int -> IO Int) buf (fromIntegral size)
#endif
pgfFilePath :: PGF -> FilePath
pgfFilePath p = unsafePerformIO (pgf_file_path (a_db p) >>= peekCString)
showPGF :: PGF -> String
showPGF p =
render (text "abstract" <+> ppAbstractName p <+> char '{' $$
+2
View File
@@ -93,6 +93,8 @@ foreign import ccall pgf_write_pgf_cookie :: Ptr () -> FunPtr (Ptr () -> Ptr Wor
foreign import ccall pgf_write_pgf_cookie :: Ptr () -> FunPtr (Ptr () -> Ptr Word8 -> CInt -> IO CInt) -> Ptr PgfDB -> Ptr PGF -> Ptr (Ptr PgfText) -> Ptr PgfExn -> IO ()
#endif
foreign import ccall pgf_file_path :: Ptr PgfDB -> IO CString
foreign import ccall "pgf_free_revision" pgf_free_revision_ :: Ptr PgfDB -> Ptr PGF -> IO ()
foreign import ccall "&pgf_free_revision" pgf_free_revision :: FinalizerEnvPtr PgfDB PGF