Commit 4b71f30c authored by Iustin Pop's avatar Iustin Pop
Browse files

Remove obsolete conversion function for Luxi TH



Due to the (now removed) custom filter field, we needed a conversion
function. Since now that field is gone, we can move to a simpler Luxi
TH implementation.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent dc6a0f82
...@@ -113,69 +113,69 @@ $(makeJSONInstance ''QrViaLuxi) ...@@ -113,69 +113,69 @@ $(makeJSONInstance ''QrViaLuxi)
-- | Currently supported Luxi operations and JSON serialization. -- | Currently supported Luxi operations and JSON serialization.
$(genLuxiOp "LuxiOp" $(genLuxiOp "LuxiOp"
[(luxiReqQuery, [(luxiReqQuery,
[ ("what", [t| QrViaLuxi |], [| id |]) [ ("what", [t| QrViaLuxi |])
, ("fields", [t| [String] |], [| id |]) , ("fields", [t| [String] |])
, ("qfilter", [t| Qlang.Filter |], [| id |]) , ("qfilter", [t| Qlang.Filter |])
]) ])
, (luxiReqQueryNodes, , (luxiReqQueryNodes,
[ ("names", [t| [String] |], [| id |]) [ ("names", [t| [String] |])
, ("fields", [t| [String] |], [| id |]) , ("fields", [t| [String] |])
, ("lock", [t| Bool |], [| id |]) , ("lock", [t| Bool |])
]) ])
, (luxiReqQueryGroups, , (luxiReqQueryGroups,
[ ("names", [t| [String] |], [| id |]) [ ("names", [t| [String] |])
, ("fields", [t| [String] |], [| id |]) , ("fields", [t| [String] |])
, ("lock", [t| Bool |], [| id |]) , ("lock", [t| Bool |])
]) ])
, (luxiReqQueryInstances, , (luxiReqQueryInstances,
[ ("names", [t| [String] |], [| id |]) [ ("names", [t| [String] |])
, ("fields", [t| [String] |], [| id |]) , ("fields", [t| [String] |])
, ("lock", [t| Bool |], [| id |]) , ("lock", [t| Bool |])
]) ])
, (luxiReqQueryJobs, , (luxiReqQueryJobs,
[ ("ids", [t| [Int] |], [| id |]) [ ("ids", [t| [Int] |])
, ("fields", [t| [String] |], [| id |]) , ("fields", [t| [String] |])
]) ])
, (luxiReqQueryExports, , (luxiReqQueryExports,
[ ("nodes", [t| [String] |], [| id |]) [ ("nodes", [t| [String] |])
, ("lock", [t| Bool |], [| id |]) , ("lock", [t| Bool |])
]) ])
, (luxiReqQueryConfigValues, , (luxiReqQueryConfigValues,
[ ("fields", [t| [String] |], [| id |]) ] [ ("fields", [t| [String] |]) ]
) )
, (luxiReqQueryClusterInfo, []) , (luxiReqQueryClusterInfo, [])
, (luxiReqQueryTags, , (luxiReqQueryTags,
[ ("kind", [t| String |], [| id |]) [ ("kind", [t| String |])
, ("name", [t| String |], [| id |]) , ("name", [t| String |])
]) ])
, (luxiReqSubmitJob, , (luxiReqSubmitJob,
[ ("job", [t| [OpCode] |], [| id |]) ] [ ("job", [t| [OpCode] |]) ]
) )
, (luxiReqSubmitManyJobs, , (luxiReqSubmitManyJobs,
[ ("ops", [t| [[OpCode]] |], [| id |]) ] [ ("ops", [t| [[OpCode]] |]) ]
) )
, (luxiReqWaitForJobChange, , (luxiReqWaitForJobChange,
[ ("job", [t| Int |], [| id |]) [ ("job", [t| Int |])
, ("fields", [t| [String]|], [| id |]) , ("fields", [t| [String]|])
, ("prev_job", [t| JSValue |], [| id |]) , ("prev_job", [t| JSValue |])
, ("prev_log", [t| JSValue |], [| id |]) , ("prev_log", [t| JSValue |])
, ("tmout", [t| Int |], [| id |]) , ("tmout", [t| Int |])
]) ])
, (luxiReqArchiveJob, , (luxiReqArchiveJob,
[ ("job", [t| Int |], [| id |]) ] [ ("job", [t| Int |]) ]
) )
, (luxiReqAutoArchiveJobs, , (luxiReqAutoArchiveJobs,
[ ("age", [t| Int |], [| id |]) [ ("age", [t| Int |])
, ("tmout", [t| Int |], [| id |]) , ("tmout", [t| Int |])
]) ])
, (luxiReqCancelJob, , (luxiReqCancelJob,
[ ("job", [t| Int |], [| id |]) ] [ ("job", [t| Int |]) ]
) )
, (luxiReqSetDrainFlag, , (luxiReqSetDrainFlag,
[ ("flag", [t| Bool |], [| id |]) ] [ ("flag", [t| Bool |]) ]
) )
, (luxiReqSetWatcherPause, , (luxiReqSetWatcherPause,
[ ("duration", [t| Double |], [| id |]) ] [ ("duration", [t| Double |]) ]
) )
]) ])
......
...@@ -52,7 +52,7 @@ module Ganeti.THH ( declareSADT ...@@ -52,7 +52,7 @@ module Ganeti.THH ( declareSADT
, buildParam , buildParam
) where ) where
import Control.Monad (liftM, liftM2) import Control.Monad (liftM)
import Data.Char import Data.Char
import Data.List import Data.List
import qualified Data.Set as Set import qualified Data.Set as Set
...@@ -499,7 +499,7 @@ genStrOfKey :: Name -> String -> Q [Dec] ...@@ -499,7 +499,7 @@ genStrOfKey :: Name -> String -> Q [Dec]
genStrOfKey = genConstrToStr ensureLower genStrOfKey = genConstrToStr ensureLower
-- | LuxiOp parameter type. -- | LuxiOp parameter type.
type LuxiParam = (String, Q Type, Q Exp) type LuxiParam = (String, Q Type)
-- | Generates the LuxiOp data type. -- | Generates the LuxiOp data type.
-- --
...@@ -508,19 +508,16 @@ type LuxiParam = (String, Q Type, Q Exp) ...@@ -508,19 +508,16 @@ type LuxiParam = (String, Q Type, Q Exp)
-- We can't use anything less generic, because the way different -- We can't use anything less generic, because the way different
-- operations are serialized differs on both parameter- and top-level. -- operations are serialized differs on both parameter- and top-level.
-- --
-- There are three things to be defined for each parameter: -- There are two things to be defined for each parameter:
-- --
-- * name -- * name
-- --
-- * type -- * type
-- --
-- * operation; this is the operation performed on the parameter before
-- serialization
--
genLuxiOp :: String -> [(String, [LuxiParam])] -> Q [Dec] genLuxiOp :: String -> [(String, [LuxiParam])] -> Q [Dec]
genLuxiOp name cons = do genLuxiOp name cons = do
decl_d <- mapM (\(cname, fields) -> do decl_d <- mapM (\(cname, fields) -> do
fields' <- mapM (\(_, qt, _) -> fields' <- mapM (\(_, qt) ->
qt >>= \t -> return (NotStrict, t)) qt >>= \t -> return (NotStrict, t))
fields fields
return $ NormalC (mkName cname) fields') return $ NormalC (mkName cname) fields')
...@@ -534,14 +531,14 @@ genLuxiOp name cons = do ...@@ -534,14 +531,14 @@ genLuxiOp name cons = do
-- | Generates the \"save\" expression for a single luxi parameter. -- | Generates the \"save\" expression for a single luxi parameter.
saveLuxiField :: Name -> LuxiParam -> Q Exp saveLuxiField :: Name -> LuxiParam -> Q Exp
saveLuxiField fvar (_, qt, fn) = saveLuxiField fvar (_, qt) =
[| JSON.showJSON ( $(liftM2 appFn fn $ varE fvar) ) |] [| JSON.showJSON $(varE fvar) |]
-- | Generates the \"save\" clause for entire LuxiOp constructor. -- | Generates the \"save\" clause for entire LuxiOp constructor.
saveLuxiConstructor :: (String, [LuxiParam]) -> Q Clause saveLuxiConstructor :: (String, [LuxiParam]) -> Q Clause
saveLuxiConstructor (sname, fields) = do saveLuxiConstructor (sname, fields) = do
let cname = mkName sname let cname = mkName sname
fnames = map (\(nm, _, _) -> mkName nm) fields fnames = map (mkName . fst) fields
pat = conP cname (map varP fnames) pat = conP cname (map varP fnames)
flist = map (uncurry saveLuxiField) (zip fnames fields) flist = map (uncurry saveLuxiField) (zip fnames fields)
finval = if null flist finval = if null flist
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment