getting shit to build
This commit is contained in:
parent
4d7b2b15fe
commit
c07bc5eda0
@ -4,9 +4,9 @@ import Data.Word (Word16)
|
|||||||
|
|
||||||
import qualified Network.Socket as S
|
import qualified Network.Socket as S
|
||||||
|
|
||||||
data Connection = Connection { connSocket :: S.Socket,
|
--data Connection = Connection { connSocket :: S.Socket,
|
||||||
connNick :: String,
|
-- connNick :: String,
|
||||||
}
|
-- }
|
||||||
|
|
||||||
-- The host to connect to.
|
-- The host to connect to.
|
||||||
type Host = String
|
type Host = String
|
||||||
@ -14,5 +14,5 @@ type Host = String
|
|||||||
-- The port to connect to.
|
-- The port to connect to.
|
||||||
type Port = Word16
|
type Port = Word16
|
||||||
|
|
||||||
connect :: Host -> Port
|
--connect :: Host -> Port
|
||||||
connect = error "unimplemented"
|
--connect = error "unimplemented"
|
||||||
|
@ -1,4 +1,36 @@
|
|||||||
|
{-# LANGUAGE MagicHash #-}
|
||||||
|
{-# LANGUAGE UnboxedTuples #-}
|
||||||
|
|
||||||
module IRC.Plugins.Loader where
|
module IRC.Plugins.Loader where
|
||||||
|
|
||||||
test :: Int
|
import GHC.Exts ( addrToAny# )
|
||||||
test = 1
|
import GHC.Ptr ( Ptr(..) )
|
||||||
|
import System.Info ( os, arch )
|
||||||
|
import GHCi.ObjLink
|
||||||
|
import Encoding
|
||||||
|
|
||||||
|
load :: IO (Either String (IO ()))
|
||||||
|
load = do initObjLinker RetainCAFs
|
||||||
|
loadObj "Plugin.o"
|
||||||
|
_ret <- resolveObjs
|
||||||
|
ptr <- lookupSymbol (mangleSymbol Nothing "Plugin" "f")
|
||||||
|
case ptr of
|
||||||
|
Nothing -> return $ Left "Couldn’t load symbol"
|
||||||
|
Just (Ptr addr) -> case addrToAny# addr of
|
||||||
|
(# f #) -> return $ Right f
|
||||||
|
|
||||||
|
mangleSymbol :: Maybe String -> String -> String -> String
|
||||||
|
mangleSymbol pkg module' valsym =
|
||||||
|
prefixUnderscore <>
|
||||||
|
maybe "" (\p -> zEncodeString p <> "_") pkg <>
|
||||||
|
zEncodeString module' <> "_" <> zEncodeString valsym <> "_closure"
|
||||||
|
|
||||||
|
prefixUnderscore :: String
|
||||||
|
prefixUnderscore =
|
||||||
|
case (os,arch) of
|
||||||
|
("mingw32","x86_64") -> ""
|
||||||
|
("cygwin","x86_64") -> ""
|
||||||
|
("mingw32",_) -> "_"
|
||||||
|
("darwin",_) -> "_"
|
||||||
|
("cygwin",_) -> "_"
|
||||||
|
_ -> ""
|
||||||
|
Loading…
Reference in New Issue
Block a user