diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index de2e48a..e1df3e4 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1336,15 +1336,14 @@ cintroduceSpec ops (A.Specification _ n (A.RecordType _ b fs)) tell [";"] cintroduceSpec _ (A.Specification _ n (A.Protocol _ _)) = return () cintroduceSpec ops (A.Specification _ n (A.ProtocolCase _ ts)) - = do tell ["typedef enum {\n"] + = do tell ["typedef enum{"] seqComma [genName tag >> tell ["_"] >> genName n | (tag, _) <- ts] -- You aren't allowed to have an empty enum. when (ts == []) $ tell ["empty_protocol_"] >> genName n - tell ["\n"] - tell ["} "] + tell ["}"] genName n - tell [";\n"] + tell [";"] cintroduceSpec ops (A.Specification _ n (A.Proc _ sm fs p)) = do call genSpecMode ops sm tell ["void "] diff --git a/backends/GenerateCPPCSP.hs b/backends/GenerateCPPCSP.hs index 19a6c25..ef254c4 100644 --- a/backends/GenerateCPPCSP.hs +++ b/backends/GenerateCPPCSP.hs @@ -943,20 +943,6 @@ cppintroduceSpec ops (A.Specification _ n (A.RecordType _ b fs)) when b $ tell [" occam_struct_packed "] genName n tell [";"] ---We do variant protocols by introducing a new variant: -cppintroduceSpec _ (A.Specification _ n (A.ProtocolCase _ [])) - = do tell ["typedef class {} "] - genName n - tell [";"] -cppintroduceSpec ops (A.Specification _ n (A.ProtocolCase _ caseList)) - = do sequence_ [tell ["class "] >> genProtocolTagName n tag >> tell [" {}; "] | (tag , _) <- caseList] - cgmap (typedef_genCaseType n) caseList - createChainedType "boost::variant" (genProtocolName n) $ map ((genTupleProtocolTagName n) . fst) caseList - where - typedef_genCaseType :: A.Name -> (A.Name, [A.Type]) -> CGen() - typedef_genCaseType n (tag, typeList) - = createChainedType "boost::tuple" (genTupleProtocolTagName n tag) ((genProtocolTagName n tag) : (map (call genType ops) typeList)) - --Clause changed to handle array retyping cppintroduceSpec ops (A.Specification _ n (A.Retypes m am t v)) = do origT <- typeOfVariable v diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index 8f94124..833b442 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -499,11 +499,14 @@ testSpec = TestList -- I don't think ValAbbrev of channels/channel-ends makes much sense (occam doesn't support it, certainly) so they are not tested here. --TODO test Is more (involving subscripts, arrays and slices) + + --ProtocolCase: + ,testAllSame 800 ("typedef enum{empty_protocol_foo}foo;","") $ A.ProtocolCase emptyMeta [] + ,testAllSame 801 ("typedef enum{bar_foo}foo;","") $ A.ProtocolCase emptyMeta [(bar,[])] + ,testAllSame 802 ("typedef enum{bar_foo,wibble_foo}foo;","") $ A.ProtocolCase emptyMeta [(bar,[]),(simpleName "wibble",[])] --TODO IsExpr - --TODO Protocol - --TODO ProtocolCase --TODO Proc --TODO Retypes ]