{-# LANGUAGE OverloadedStrings #-}
module Types(CArray, Page(..)) where
import System.Directory (getCurrentDirectory) -- default referer URI
import SpeechStyle (SpeechStyle)
import Data.CSS.Preprocessor.Conditions (ConditionalStyles, conditionalStyles)
import Data.CSS.Preprocessor.Text (TextStyle)
import Text.XML
import qualified Data.Map.Strict as M
import Network.URI
import Foreign.Ptr
import Foreign.StablePtr
type CArray a = Ptr a
data Page = Page {url :: URI, css :: ConditionalStyles (TextStyle SpeechStyle), html :: Document}
foreign export ccall c_initialReferer :: IO (StablePtr Page)
c_initialReferer = do
cwd <- getCurrentDirectory
newStablePtr $ Page {
-- Default to URIs being relative to CWD.
url = URI {uriScheme = "file:", uriPath = cwd,
uriAuthority = Nothing, uriQuery = "", uriFragment = ""},
-- Blank values:
css = conditionalStyles nullURI "temp",
html = Document {
documentPrologue = Prologue [] Nothing [],
documentRoot = Element "temp" M.empty [],
documentEpilogue = []
}
}
foreign export ccall c_freePage :: StablePtr Page -> IO ()
c_freePage = freeStablePtr