{-# LANGUAGE PostfixOperators #-}
module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.CSharpRenderer (
CSharpProject(..)
) where
import Prelude hiding (break,print,(<>),sin,cos,tan,floor)
import qualified Prelude as P ((<>))
import Drasil.GOOL (csName, csVersion)
import Language.Drasil.Choices (ImplementationType(..))
import Language.Drasil.Code.Imperative.GOOL.ClassInterface (AuxiliarySym(..))
import Language.Drasil.Code.Imperative.README (ReadMeInfo(..))
import qualified
Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as
G (doxConfig, readMe, makefile, noRunIfLib, doxDocConfig,
docIfEnabled)
import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable,
asFragment, buildAll, nativeBinary, osClassDefault, executable, sharedLibrary)
import Language.Drasil.Code.Imperative.Doxygen.Import (no)
newtype CSharpProject a = CSP {forall a. CSharpProject a -> a
unCSP :: a}
instance Functor CSharpProject where
fmap :: forall a b. (a -> b) -> CSharpProject a -> CSharpProject b
fmap a -> b
f (CSP a
x) = b -> CSharpProject b
forall a. a -> CSharpProject a
CSP (a -> b
f a
x)
instance Applicative CSharpProject where
pure :: forall a. a -> CSharpProject a
pure = a -> CSharpProject a
forall a. a -> CSharpProject a
CSP
(CSP a -> b
f) <*> :: forall a b.
CSharpProject (a -> b) -> CSharpProject a -> CSharpProject b
<*> (CSP a
x) = b -> CSharpProject b
forall a. a -> CSharpProject a
CSP (a -> b
f a
x)
instance Monad CSharpProject where
CSP a
x >>= :: forall a b.
CSharpProject a -> (a -> CSharpProject b) -> CSharpProject b
>>= a -> CSharpProject b
f = a -> CSharpProject b
f a
x
instance AuxiliarySym CSharpProject where
doxConfig :: String
-> SoftwareDossierState
-> Verbosity
-> CSharpProject FileAndContents
doxConfig = CSharpProject Doc
-> String
-> SoftwareDossierState
-> Verbosity
-> CSharpProject FileAndContents
forall (r :: * -> *).
(AuxiliarySym r, Applicative r) =>
r Doc
-> String -> SoftwareDossierState -> Verbosity -> r FileAndContents
G.doxConfig CSharpProject Doc
forall (r :: * -> *). AuxiliarySym r => r Doc
optimizeDox
readMe :: ReadMeInfo -> CSharpProject FileAndContents
readMe ReadMeInfo
rmi =
ReadMeInfo -> CSharpProject FileAndContents
forall (r :: * -> *).
Applicative r =>
ReadMeInfo -> r FileAndContents
G.readMe ReadMeInfo
rmi {
langName = csName,
langVersion = csVersion,
invalidOS = Just "All OS's except Windows"}
optimizeDox :: CSharpProject Doc
optimizeDox = Doc -> CSharpProject Doc
forall a. a -> CSharpProject a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Doc
no
makefile :: [String]
-> ImplementationType
-> [Comments]
-> SoftwareDossierState
-> ProgData
-> CSharpProject FileAndContents
makefile [String]
fs ImplementationType
it [Comments]
cms = Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> CSharpProject FileAndContents
forall (r :: * -> *).
Applicative r =>
Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> r FileAndContents
G.makefile ([String] -> ImplementationType -> Maybe BuildConfig
csBuildConfig [String]
fs ImplementationType
it)
(ImplementationType -> Maybe Runnable -> Maybe Runnable
G.noRunIfLib ImplementationType
it Maybe Runnable
csRunnable) ([Comments] -> DocConfig -> Maybe DocConfig
G.docIfEnabled [Comments]
cms DocConfig
G.doxDocConfig)
auxHelperDoc :: CSharpProject Doc -> Doc
auxHelperDoc = CSharpProject Doc -> Doc
forall a. CSharpProject a -> a
unCSP
csBuildConfig :: [FilePath] -> ImplementationType -> Maybe BuildConfig
csBuildConfig :: [String] -> ImplementationType -> Maybe BuildConfig
csBuildConfig [String]
fs ImplementationType
it = ([CommandFragment] -> CommandFragment -> [[CommandFragment]])
-> BuildName -> Maybe BuildConfig
buildAll (\[CommandFragment]
i CommandFragment
o -> [String -> String -> String -> CommandFragment
osClassDefault String
"CSC" String
"csc" String
"mcs"
CommandFragment -> [CommandFragment] -> [CommandFragment]
forall a. a -> [a] -> [a]
: ImplementationType -> [CommandFragment]
target ImplementationType
it [CommandFragment] -> [CommandFragment] -> [CommandFragment]
forall a. [a] -> [a] -> [a]
++ [String -> CommandFragment
asFragment String
"-out:" CommandFragment -> CommandFragment -> CommandFragment
forall a. Semigroup a => a -> a -> a
P.<> CommandFragment
o] [CommandFragment] -> [CommandFragment] -> [CommandFragment]
forall a. [a] -> [a] -> [a]
++ (String -> CommandFragment) -> [String] -> [CommandFragment]
forall a b. (a -> b) -> [a] -> [b]
map (String -> CommandFragment
asFragment (String -> CommandFragment)
-> (String -> String) -> String -> CommandFragment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
"-r:" ++)) [String]
fs
[CommandFragment] -> [CommandFragment] -> [CommandFragment]
forall a. [a] -> [a] -> [a]
++ [CommandFragment]
i]) (ImplementationType -> BuildName
outName ImplementationType
it)
where target :: ImplementationType -> [CommandFragment]
target ImplementationType
Library = [String -> CommandFragment
asFragment String
"-t:library"]
target ImplementationType
Program = []
outName :: ImplementationType -> BuildName
outName ImplementationType
Library = BuildName
sharedLibrary
outName ImplementationType
Program = BuildName
executable
csRunnable :: Maybe Runnable
csRunnable :: Maybe Runnable
csRunnable = Maybe Runnable
nativeBinary