Commit 58b37916 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Remove toDist... functions completely



Since thre already is `DictObject` class with `toDict`, there is no need
for them, just polluting the name space.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent c2e136e2
......@@ -47,7 +47,6 @@ module Ganeti.Objects
, fillBeParams
, allBeParamFields
, Instance(..)
, toDictInstance
, getDiskSizeRequirements
, PartialNDParams(..)
, FilledNDParams(..)
......
......@@ -1035,7 +1035,7 @@ resolveDependencies mopc jid = do
-- | JSON serialisation for 'MetaOpCode'.
showMeta :: MetaOpCode -> JSValue
showMeta (MetaOpCode params op) =
let objparams = toDictCommonOpParams params
let objparams = toDict params
objop = toDictOpCode op
in makeObj (objparams ++ objop)
......
......@@ -1007,14 +1007,6 @@ buildObjectSerialisation sname fields = do
objVarName :: Name
objVarName = mkName "_o"
-- | The toDict function name for a given type.
toDictName :: String -> Name
toDictName sname = mkName ("toDict" ++ sname)
-- | The fromDict function name for a given type.
fromDictName :: String -> Name
fromDictName sname = mkName ("fromDict" ++ sname)
-- | Generates 'DictObject' instance.
genDictObject :: (Name -> Field -> Q Exp) -- ^ a saving function
-> (Field -> Q Exp) -- ^ a loading function
......@@ -1031,16 +1023,11 @@ genDictObject save_fn load_fn sname fields = do
-- fromDict
fdexp <- loadConstructor name load_fn fields
let fdclause = Clause [VarP objVarName] (NormalB fdexp) []
-- the toDict... function
let tdname = toDictName sname
tdsigt <- [t| $(conT name) -> [(String, JSON.JSValue)] |]
-- the final instance
return $ [InstanceD [] (AppT (ConT ''DictObject) (ConT name))
[ ValD (VarP 'toDict) (NormalB (VarE tdname)) []
, FunD 'fromDict [fdclause]
]] ++
[ SigD tdname tdsigt
, ValD (VarP tdname) (NormalB (VarE 'toDict)) [] ]
return [InstanceD [] (AppT (ConT ''DictObject) (ConT name))
[ FunD 'toDict [tdclause]
, FunD 'fromDict [fdclause]
]]
-- | Generates the save object functionality.
genSaveObject :: String -> Q [Dec]
......@@ -1165,14 +1152,6 @@ buildParamAllFields sname fields =
val = ListE $ map (LitE . StringL . fieldName) fields
in [sig, ValD (VarP vname) (NormalB val) []]
-- | Builds the 'DictObject' instance for a filled parameter.
buildDictObjectInst :: Name -> String -> [Dec]
buildDictObjectInst name sname =
[InstanceD [] (AppT (ConT ''DictObject) (ConT name))
[ ValD (VarP 'toDict) (NormalB (VarE (toDictName sname))) []
, ValD (VarP 'fromDict) (NormalB (VarE (fromDictName sname))) []
]]
-- | Generates the serialisation for a partial parameter.
buildPParamSerialisation :: String -> [Field] -> Q [Dec]
buildPParamSerialisation sname fields = do
......
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