Check Special Symbols definitions
Wed Sep 12 14:57:57 WEST 2007 Miguel Vilaca <jmvilaca@di.uminho.pt>
* Check Special Symbols definitions
Check if special symbols definitions correspond to the default ones.
{
hunk ./Makefile 39
+ src/SpecialSymbols.hs \
hunk ./Makefile 205
+src/SpecialSymbols.o : src/SpecialSymbols.hs
+src/SpecialSymbols.o : src/Math.hi
+src/SpecialSymbols.o : src/Colors.hi
+src/SpecialSymbols.o : src/Shape.hi
hunk ./Makefile 210
+src/INRule.o : src/SpecialSymbols.hi
hunk ./Makefile 250
+src/INReductionStrategies.o : src/INReductionStrategies.hs
+src/INReductionStrategies.o : src/INRule.hi
+src/INReductionStrategies.o : src/Network.hi
+src/INReductionStrategies.o : src/Document.hi
hunk ./Makefile 255
+src/INTextual.o : src/SpecialSymbols.hi
hunk ./Makefile 264
-src/INReductionStrategies.o : src/INReductionStrategies.hs
-src/INReductionStrategies.o : src/INRule.hi
-src/INReductionStrategies.o : src/Network.hi
-src/INReductionStrategies.o : src/Document.hi
hunk ./Makefile 265
+src/INChecks.o : src/SpecialSymbols.hi
hunk ./Makefile 375
+src/NetworkUI.o : src/SpecialSymbols.hi
hunk ./src/INChecks.hs 34
+import SpecialSymbols
hunk ./src/INChecks.hs 50
+ | SymbolDiffPorts String Ports Ports -- ^ Symbol definition differ from default one.
hunk ./src/INChecks.hs 92
+ showsPrec _ (SymbolDiffPorts symb ports defaultPorts) =
+ showString "Symbol \"" . showString symb . showString "\" is defined with ports \n."
+ . shows ports . showString "\nwhich differ from the default definition with ports \n"
+ . shows defaultPorts
hunk ./src/INChecks.hs 198
+ , manCheck
hunk ./src/INChecks.hs 211
- . ( (empOrSing NET . funcNet . getNetwork)
+ . ( (emptyOrSingle NET . funcNet . getNetwork)
hunk ./src/INChecks.hs 215
- empOrSing k l = if null l then Map.empty else Map.singleton k l
hunk ./src/INChecks.hs 223
+-- | If the list of values is empty create the empty 'Map'. Else creates the singleton 'map' with key @k@.
+emptyOrSingle :: k -> [v] -> Map k [v]
+emptyOrSingle k l = if null l then Map.empty else Map.singleton k l
hunk ./src/INChecks.hs 446
- badInterfaceNode node = either (\str -> str == "interface" && not (isInterfaceNode (0,node)) )
+ badInterfaceNode node = either (\str -> str == fst interfaceSymbol && not (isInterfaceNode (0,node)) )
hunk ./src/INChecks.hs 472
+-- | Checks if declared management agents are defined in the exactly same way that they are in the default palette.
+-- Useful to avoid posterior problems with templates.
+manCheck :: Check g n e
+manCheck =
+ ( "Check management agents"
+ , "Check if management agents are defined in the exact same way that in 'ManagementAgents.INblobpalette' to avoid troubles with templates."
+ , "Management agents definitions match."
+ , "Management agent(s) definitions don't match"
+ , manCheck'
+ )
+
+manCheck' :: CheckOp g n e
+manCheck' doc =
+ emptyOrSingle PALETTE
+ . Map.elems
+ . Map.mapMaybeWithKey aux
+ . uncurry ( Map.intersectionWith (,) )
+ . ( Map.fromList >< Map.fromList )
+ $ (shapes $ getPalette doc, specialSymbols)
+
+ where aux :: String -> ((a,Maybe Ports,c),(a,Maybe Ports,c)) -> Maybe (INError g n e)
+ aux k ((_, Just ports1,_), (_, Just ports2,_))
+ | ports1 == ports2 = Nothing
+ | otherwise = Just $ SymbolDiffPorts k ports1 ports2
+
hunk ./src/INRule.hs 35
+import SpecialSymbols
hunk ./src/INRule.hs 143
- (Left "interface", Just [("interface",_)]) -> True
+ (Left str, ports) -> str == interName && ports == snd3 interDef
hunk ./src/INRule.hs 145
+ where (interName, interDef) = interfaceSymbol
hunk ./src/INTextual.hs 27
+import SpecialSymbols
hunk ./src/INTextual.hs 155
- Net { agents = delete ("interface",0) . nub [_$_]
+ Net { agents = delete (fst interfaceSymbol, 0) . nub
hunk ./src/INTextual.hs 173
- test (Simple _, Compound ("interface", [])) = False
+ test (Simple _, Compound (str, [])) = str /= fst interfaceSymbol
hunk ./src/NetworkUI.hs 34
+import SpecialSymbols
hunk ./src/NetworkUI.hs 671
- let interfacePal = [_$_]
- Palette [_$_]
- [ ("interface"
- , ( Circle { shapeStyle = ShapeStyle
- { styleStrokeWidth = 2
- , styleStrokeColour = RGB 255 255 255
- , styleFill = RGB 255 255 255
- }
- , shapeRadius = 0.25
- }
- , Just [("interface", DoublePoint 0.0 0.25)]
- , Just n ))
- ]
-
+ let interfacePal = Palette [interfaceSymbol]
hunk ./src/NetworkUI.hs 674
- setCurrentShape "interface" state
+ setCurrentShape (fst interfaceSymbol) state
hunk ./src/NetworkUI.hs 1153
- (nrs1, lhs5) = addNodes "interface" palette (length ports1) lhs4
- (nrs2, lhs6) = addNodes "interface" palette (length ports2) lhs5
+ (nrs1, lhs5) = addNodes (fst interfaceSymbol) palette (length ports1) lhs4
+ (nrs2, lhs6) = addNodes (fst interfaceSymbol) palette (length ports2) lhs5
hunk ./src/NetworkUI.hs 1189
- _ -> fail "Interface port with more than one port."
+ _ -> fail "Interface agent with more than one port."
hunk ./src/NetworkUI.hs 1318
- let pal = filter ( (/= "interface").fst ) [_$_]
+ let pal = filter ( (/= fst interfaceSymbol).fst )
hunk ./src/NetworkUI.hs 1517
+ if agentD `elem` map fst specialSymbols
+ then errorDialog diaW "Reserved agent name" $ "\"" ++ agentD ++ "\" is a reserved agent name for a special agent.\nPlease import the agent or choose a different name."
+ else
addfile ./src/SpecialSymbols.hs
hunk ./src/SpecialSymbols.hs 1
+module SpecialSymbols where
+
+import Shape
+import Colors
+import Math
+
+-- | List of Special Symbols.
+specialSymbols =
+ [ interfaceSymbol
+ , copySymbol
+ , duplicatorSymbol
+ , eraseSymbol
+ ]
+
+interfaceSymbol =
+ ( "interface"
+ , ( Circle { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = coconut
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.25
+ }
+ , Just [("interface",DoublePoint 0.0 0.25)]
+ , Nothing
+ )
+ )
+
+copySymbol =
+ ( "copy"
+ , ( TextInEllipse { shapeStyle = ShapeStyle { styleStrokeWidth = 1
+ , styleStrokeColour = licorice
+ , styleFill = silver
+ }
+ , shapeText = "c"
+ }
+ , Just [("src",DoublePoint 0.0 0.3),("fst_target",DoublePoint (-0.3) (-0.3)),("snd_target",DoublePoint 0.3 (-0.3))]
+ , Nothing
+ )
+ )
+
+duplicatorSymbol =
+ ( "duplicator"
+ , ( Composite { shapeSegments = [ Circle { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.5
+ }
+ , Arc { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.2
+ , shapeStart = 70.0
+ , shapeEnd = 270.0
+ , shapeCenter = DoublePoint 0.0 (-0.18)
+ }
+ , Arc { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.2
+ , shapeStart = 150.0
+ , shapeEnd = 90.0
+ , shapeCenter = DoublePoint 0.0 0.18
+ }
+ ]
+ }
+ , Just [("down",DoublePoint 0.0 0.5),("copy1",DoublePoint (-0.3) (-0.3)),("copy2",DoublePoint 0.3 (-0.3))]
+ , Nothing
+ )
+ )
+
+eraseSymbol =
+ ( "Erase"
+ , ( Composite { shapeSegments = [ Circle { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.5
+ }
+ , Arc { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.2
+ , shapeStart = 90.0
+ , shapeEnd = 270.0
+ , shapeCenter = DoublePoint 0.0 (-0.18)
+ }
+ , Arc { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 250 0 0
+ , styleFill = coconut
+ }
+ , shapeRadius = 0.2
+ , shapeStart = 90.0
+ , shapeEnd = 270.0
+ , shapeCenter = DoublePoint 0.0 0.18
+ }
+ ]
+ }
+ , Just [("down",DoublePoint 0.0 0.5)]
+ , Nothing
+ )
+ )
+
}