packages feed

hprotoc 1.6.0 → 1.7.0

raw patch · 8 files changed

+334/−51 lines, 8 filesdep ~directorydep ~filepath

Dependency ranges changed: directory, filepath

Files

LICENSE view
@@ -8,3 +8,4 @@     * Neither the name of the copyright holder nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+hi
Text/ProtocolBuffers/ProtoCompile.hs view
@@ -1,23 +1,27 @@ -- | This is the Main module for the command line program 'hprotoc' module Main where -import Control.Monad(when,forM_)-import qualified Data.ByteString.Lazy.Char8 as LC (writeFile)+import Control.Monad(unless,forM_)+import Control.Monad.State(State, execState, modify)+import qualified Data.ByteString.Lazy.Char8 as LC (hGetContents, hPut, pack, unpack)+import Data.Foldable (toList) import Data.List(break) import qualified Data.Sequence as Seq (fromList,singleton)+import Data.Sequence ((|>)) import Data.Version(showVersion) import Language.Haskell.Exts.Pretty(prettyPrintStyleMode,Style(..),Mode(..),PPHsMode(..),PPLayout(..)) import System.Console.GetOpt(OptDescr(Option),ArgDescr(NoArg,ReqArg)                             ,usageInfo,getOpt,ArgOrder(ReturnInOrder)) import System.Directory(getCurrentDirectory,createDirectoryIfMissing)-import System.Environment(getArgs)+import System.Environment(getProgName, getArgs) import System.FilePath(takeDirectory,combine,joinPath) import qualified System.FilePath.Posix as Canon(takeBaseName)+import System.IO (stdin, stdout) -import Text.ProtocolBuffers.Basic(defaultValue)+import Text.ProtocolBuffers.Basic(defaultValue, Utf8(..), utf8) import Text.ProtocolBuffers.Identifiers(MName,checkDIString,mangle) import Text.ProtocolBuffers.Reflections(ProtoInfo(..),EnumInfo(..))-import Text.ProtocolBuffers.WireMessage (messagePut)+import Text.ProtocolBuffers.WireMessage (messagePut, messageGet)  import qualified Text.DescriptorProtos.FileDescriptorProto as D(FileDescriptorProto) import qualified Text.DescriptorProtos.FileDescriptorProto as D.FileDescriptorProto(FileDescriptorProto(..))@@ -27,9 +31,14 @@ import Text.ProtocolBuffers.ProtoCompile.BreakRecursion(makeResult) import Text.ProtocolBuffers.ProtoCompile.Gen(protoModule,descriptorModules,enumModule) import Text.ProtocolBuffers.ProtoCompile.MakeReflections(makeProtoInfo,serializeFDP)-import Text.ProtocolBuffers.ProtoCompile.Resolve(loadProto,makeNameMaps,getTLS-                                                ,LocalFP(..),CanonFP(..),TopLevel(..))+import Text.ProtocolBuffers.ProtoCompile.Resolve(loadProto,loadCodeGenRequest,makeNameMaps,getTLS+                                                ,Env,LocalFP(..),CanonFP(..),TopLevel(..)) +import Text.Google.Protobuf.Compiler.CodeGeneratorRequest+import Text.Google.Protobuf.Compiler.CodeGeneratorResponse hiding (error, file)+import qualified Text.Google.Protobuf.Compiler.CodeGeneratorResponse as CGR(file)+import qualified Text.Google.Protobuf.Compiler.CodeGeneratorResponse.File as CGR.File+ -- The Paths_hprotoc module is produced by cabal import Paths_hprotoc(version) @@ -140,7 +149,24 @@  main :: IO () main = do+  progName <- getProgName+  case progName of+    "protoc-gen-haskell" -> pluginMain+    _                    -> standaloneMain++pluginMain :: IO ()+pluginMain = do   defs <- defaultOptions+  inputBytes <- LC.hGetContents stdin+  let req = either error fst $ messageGet inputBytes+  let prefix = fmap (LC.unpack . utf8) $ parameter req+  let opts = maybe defs (flip setPrefix $ defs) prefix+  let resp = runPlugin opts req+  LC.hPut stdout $ messagePut resp++standaloneMain :: IO ()+standaloneMain = do+  defs <- defaultOptions   args <- getArgs   case processOptions args of     Left msg -> putStrLn msg@@ -154,7 +180,7 @@                        else putStrLn "Processing complete, have a nice day." process options (Mutate f:rest) = process (f options) rest process options (Run f:rest) = let options' = f options-                            in run options' >> process options' rest+                            in runStandalone options' >> process options' rest process _options (Switch VersionInfo:_) = putStrLn versionInfo    mkdirFor :: FilePath -> IO ()@@ -166,42 +192,69 @@ myMode :: PPHsMode myMode = PPHsMode 2 2 2 2 4 1 True PPOffsideRule False -- True -dump :: Bool -> Maybe LocalFP -> D.FileDescriptorProto -> [D.FileDescriptorProto] -> IO ()-dump _ Nothing _ _ = return ()-dump imports (Just (LocalFP dumpFile)) fdp fdps = do-  putStrLn $ "dumping to filename: "++show dumpFile+dump :: (Monad m) => Output m -> Bool -> Maybe LocalFP -> D.FileDescriptorProto -> [D.FileDescriptorProto] -> m ()+dump _ _ Nothing _ _ = return ()+dump o imports (Just (LocalFP dumpFile)) fdp fdps = do+  outputReport o $ "dumping to filename: "++show dumpFile   let s = if imports then Seq.fromList fdps else Seq.singleton fdp-  LC.writeFile dumpFile (messagePut $ defaultValue { D.FileDescriptorSet.file = s })-  putStrLn $ "finished dumping FileDescriptorSet binary of: "++show (D.FileDescriptorProto.name fdp)+  outputWriteFile o dumpFile $ LC.unpack (messagePut $ defaultValue { D.FileDescriptorSet.file = s })+  outputReport o $ "finished dumping FileDescriptorSet binary of: "++show (D.FileDescriptorProto.name fdp) -run :: Options -> IO ()-run options = do+data (Monad m) => Output m = Output {+  outputReport :: String -> m (),+  outputWriteFile :: FilePath -> String -> m ()+}++runStandalone :: Options -> IO ()+runStandalone options = do   (env,fdps) <- loadProto (optInclude options) (optProto options)   putStrLn "All proto files loaded"+  run' standaloneMode options env fdps where+    standaloneMode :: Output IO+    standaloneMode = Output putStrLn emitFile+    emitFile file contents = do+      let fullPath = combine (unLocalFP . optTarget $ options) file+      putStrLn fullPath+      mkdirFor fullPath+      unless (optDryRun options) $ writeFile fullPath contents++runPlugin :: Options -> CodeGeneratorRequest -> CodeGeneratorResponse+runPlugin options req = execState (run' pluginOutput options env fdps) defaultValue where+  (env,fdps) = loadCodeGenRequest req (head requestedFiles)+  pluginOutput :: Output (State CodeGeneratorResponse)+  pluginOutput = Output {+      outputReport = const $ return (),+      outputWriteFile = appendFileRecord+    }+  appendFileRecord :: FilePath -> String -> State CodeGeneratorResponse ()+  appendFileRecord f c = modify $ \resp -> resp {+          CGR.file = (CGR.file resp) |> newFile+        } where+      newFile = defaultValue {+          CGR.File.name = Just $ Utf8 $ LC.pack f,+          CGR.File.content = Just $ Utf8 $ LC.pack c+        }+  requestedFiles = map (LocalFP . LC.unpack . utf8) . toList . file_to_generate $ req++run' :: (Monad m) => Output m -> Options -> Env -> [D.FileDescriptorProto] -> m ()+run' o@(Output print' writeFile') options env fdps = do   let fdp = either error id . top'FDP . fst . getTLS $ env-  when (not (optDryRun options)) $ dump (optImports options) (optDesc options) fdp fdps+  unless (optDryRun options) $ dump o (optImports options) (optDesc options) fdp fdps   nameMap <- either error return $ makeNameMaps (optPrefix options) (optAs options) env-  putStrLn "Haskell name mangling done"+  print' "Haskell name mangling done"   let protoInfo = makeProtoInfo (optUnknownFields options) nameMap fdp       result = makeResult protoInfo-  seq result (putStrLn "Recursive modules resolved")+  seq result (print' "Recursive modules resolved")   let produceMSG di = do-        when (not (optDryRun options)) $ do+        unless (optDryRun options) $ do           -- There might be several modules           let fileModules = descriptorModules result di           forM_ fileModules $ \ (relPath,modSyn) -> do-            let file = combine (unLocalFP . optTarget $ options) relPath-            print file-            mkdirFor file-            writeFile file (prettyPrintStyleMode style myMode modSyn)+            writeFile' relPath (prettyPrintStyleMode style myMode modSyn)       produceENM ei = do-        let file = combine (unLocalFP . optTarget $ options) . joinPath . enumFilePath $ ei-        print file-        when (not (optDryRun options)) $ do-          mkdirFor file-          writeFile file (prettyPrintStyleMode style myMode (enumModule ei))+        let file = joinPath . enumFilePath $ ei+        writeFile' file (prettyPrintStyleMode style myMode (enumModule ei))   mapM_ produceMSG (messages protoInfo)   mapM_ produceENM (enums protoInfo)-  let file = combine (unLocalFP . optTarget $ options) . joinPath . protoFilePath $ protoInfo-  print file-  writeFile file (prettyPrintStyleMode style myMode (protoModule result protoInfo (serializeFDP fdp)))+  let file = joinPath . protoFilePath $ protoInfo+  writeFile' file (prettyPrintStyleMode style myMode (protoModule result protoInfo (serializeFDP fdp)))
Text/ProtocolBuffers/ProtoCompile/Resolve.hs view
@@ -10,7 +10,7 @@ -- The makeNameMaps command makes the translator from proto name to -- Haskell name.  Many possible errors in the proto data are caught -- and reported by these operations.-module Text.ProtocolBuffers.ProtoCompile.Resolve(loadProto,makeNameMap,makeNameMaps,getTLS+module Text.ProtocolBuffers.ProtoCompile.Resolve(loadProto,loadCodeGenRequest,makeNameMap,makeNameMaps,getTLS                                                 ,Env(..),TopLevel(..),ReMap,NameMap(..),LocalFP(..),CanonFP(..)) where  import qualified Text.DescriptorProtos.DescriptorProto                as D(DescriptorProto)@@ -51,6 +51,8 @@ import qualified Text.DescriptorProtos.ServiceOptions   as D(ServiceOptions) import qualified Text.DescriptorProtos.ServiceOptions   as D.ServiceOptions(ServiceOptions(uninterpreted_option)) +import qualified Text.Google.Protobuf.Compiler.CodeGeneratorRequest as CGR+ import Text.ProtocolBuffers.Header import Text.ProtocolBuffers.Identifiers import Text.ProtocolBuffers.Extensions@@ -59,6 +61,7 @@ import Text.ProtocolBuffers.ProtoCompile.Parser  import Control.Applicative+import Control.Monad.Identity import Control.Monad.State import Control.Monad.Reader import Control.Monad.Error@@ -67,10 +70,9 @@ import Data.Ratio import Data.Ix(inRange) import Data.List(foldl',stripPrefix,lookup,isPrefixOf,isSuffixOf)-import Data.Map(Map)+import Data.Map(Map, keys) import Data.Maybe(mapMaybe) import Data.Monoid(Monoid(..))-import Data.Set(Set) import System.Directory import qualified System.FilePath as Local(pathSeparator,splitDirectories,joinPath,combine,makeRelative) import qualified System.FilePath.Posix as Canon(pathSeparator,splitDirectories,joinPath,takeBaseName)@@ -791,6 +793,8 @@                                               | otherwise ->                     fqFail ("fqField.actualType : This Enum is invalid, you cannot pack a non-repeated field.") fdp entity                   (Just t, Nothing) -> return t+                  (Just TYPE_MESSAGE, Just (E'Message {})) -> return TYPE_MESSAGE+                  (Just TYPE_ENUM, Just (E'Enum {})) -> return TYPE_ENUM                   (mt,me) -> fqFail ("fqField.actualType: "++show mt++" and "++show (fmap eName me)++" is invalid.") fdp entity   -- Check that a default value of an TYPE_ENUM is valid   case (mTypeName,D.FieldDescriptorProto.default_value fdp) of@@ -1074,14 +1078,17 @@                 else fail $ "file found but it is not below path, cannot make canonical name:\n  path: "                             ++show truepath++"\n  file: "++show truefile -loadProto :: [LocalFP] -> LocalFP -> IO (Env,[D.FileDescriptorProto])-loadProto protoDirs protoFile = goState (load Set.empty protoFile) where++-- | Given a path, tries to find and parse a FileDescriptorProto+-- corresponding to it; returns also a canonicalised path.+type DescriptorReader m = (Monad m) => LocalFP -> m (D.FileDescriptorProto, LocalFP)++loadProto' :: (Monad r) => DescriptorReader r -> LocalFP -> r (Env,[D.FileDescriptorProto])+loadProto' fdpReader protoFile = goState (load Set.empty protoFile) where   goState act = do (env,m) <- runStateT act mempty                    let fromRight (Right x) = x                        fromRight (Left s) = error $ "loadProto failed to resolve a FileDescriptorProto: "++s                    return (env,map (fromRight . top'FDP . fst . getTLS) (M.elems m))-  loadFailed f msg = fail . unlines $ ["Parsing proto:",show (unLocalFP f),"has failed with message",msg]-  load :: Set.Set LocalFP -> LocalFP -> StateT (Map LocalFP Env) IO Env   load parentsIn file = do     built <- get     when (Set.member file parentsIn)@@ -1090,16 +1097,8 @@     case M.lookup file built of       Just result -> return result       Nothing -> do-        mayToRead <- liftIO $ findFile protoDirs file-        case mayToRead of-          Nothing -> loadFailed file (unlines (["loading failed, could not find file: "++show (unLocalFP file)-                                               ,"Searched paths were:"] ++ map (("  "++).show.unLocalFP) protoDirs))-          Just (toRead,relpath) -> do-            protoContents <- liftIO $ do print ("Loading filepath: "++show (unLocalFP toRead))-                                         LC.readFile (unLocalFP toRead)-            parsed'fdp <- either (loadFailed toRead . show) return $-                          (parseProto (unCanonFP relpath) protoContents)-            packageName <- either (loadFailed toRead . show) (return . map iToString . snd) $+            (parsed'fdp, canonicalFile) <- lift $ fdpReader file+            packageName <- either (loadFailed canonicalFile . show) (return . map iToString . snd) $                            (checkDIUtf8 (getPackage parsed'fdp)) -- =<< getJust "makeTopLevel.packageName: you need a pacakge declaration in your proto file" (D.FileDescriptorProto.package parsed'fdp))             let parents = Set.insert file parentsIn                 importList = map (fpCanonToLocal . CanonFP . toString) . F.toList . D.FileDescriptorProto.dependency $ parsed'fdp@@ -1109,3 +1108,34 @@             either (loadFailed file) return (top'FDP . getTL $ global'env)             modify (M.insert file global'env) -- add to memorized results             return global'env++loadFailed :: (Monad m) => LocalFP -> String -> m a+loadFailed f msg = fail . unlines $ ["Parsing proto:",show (unLocalFP f),"has failed with message",msg]++-- | Given a list of paths to search, loads proto files by+-- looking for them in the file system.+loadProto :: [LocalFP] -> LocalFP -> IO (Env,[D.FileDescriptorProto])+loadProto protoDirs protoFile = loadProto' findAndParseSource protoFile where+      findAndParseSource :: DescriptorReader IO+      findAndParseSource file = do+        mayToRead <- liftIO $ findFile protoDirs file+        case mayToRead of+          Nothing -> loadFailed file (unlines (["loading failed, could not find file: "++show (unLocalFP file)+                                               ,"Searched paths were:"] ++ map (("  "++).show.unLocalFP) protoDirs))+          Just (toRead,relpath) -> do+            protoContents <- liftIO $ do putStrLn ("Loading filepath: "++show (unLocalFP toRead))+                                         LC.readFile (unLocalFP toRead)+            parsed'fdp <- either (loadFailed toRead . show) return $+                          (parseProto (unCanonFP relpath) protoContents)+            return (parsed'fdp, toRead)++loadCodeGenRequest :: CGR.CodeGeneratorRequest -> LocalFP -> (Env,[D.FileDescriptorProto])+loadCodeGenRequest req protoFile = runIdentity $ loadProto' lookUpParsedSource protoFile where+  lookUpParsedSource :: DescriptorReader Identity+  lookUpParsedSource file = case M.lookup file fdpsByName of+    Just result -> return (result, file)+    Nothing -> loadFailed file ("Request refers to file: "++show (unLocalFP file)+                                    ++" but it was not supplied in the request.")+  fdpsByName = M.fromList . map keyByName . F.toList . CGR.proto_file $ req+  keyByName fdp = (fdpName fdp, fdp)+  fdpName = LocalFP . maybe "" (LC.unpack . utf8) . D.FileDescriptorProto.name
hprotoc.cabal view
@@ -1,5 +1,5 @@ name:           hprotoc-version:        1.6.0+version:        1.7.0 cabal-version:  >= 1.6 build-type:     Simple license:        BSD3@@ -22,12 +22,16 @@  Executable hprotoc   Main-Is:         Text/ProtocolBuffers/ProtoCompile.hs+  Hs-Source-Dirs:  .,protoc-gen-haskell   build-tools:     alex   ghc-options:     -O2 -Wall   build-depends:   protocol-buffers == 1.6.0, protocol-buffers-descriptor == 1.6.0   build-depends:   binary, utf8-string   build-depends:   parsec < 3, haskell-src-exts >= 1.7.0,-                   containers,bytestring,array,filepath == 1.1.0.2,directory == 1.0.0.3,mtl,QuickCheck+                   containers,bytestring,array,+                   filepath >= 1.1.0.0 && <= 1.1.0.2,+                   directory >= 1.0.0.1 && <= 1.0.0.3,+                   mtl,QuickCheck    if flag(small_base)         build-depends: base == 4.*@@ -35,6 +39,10 @@         build-depends: base == 3.*    other-modules:   Paths_hprotoc+                   Text.Google.Protobuf.Compiler+                   Text.Google.Protobuf.Compiler.CodeGeneratorRequest+                   Text.Google.Protobuf.Compiler.CodeGeneratorResponse+                   Text.Google.Protobuf.Compiler.CodeGeneratorResponse.File                    Text.ProtocolBuffers.ProtoCompile.BreakRecursion                    Text.ProtocolBuffers.ProtoCompile.Gen                    Text.ProtocolBuffers.ProtoCompile.Instances
+ protoc-gen-haskell/Text/Google/Protobuf/Compiler.hs view
@@ -0,0 +1,16 @@+module Text.Google.Protobuf.Compiler (protoInfo, fileDescriptorProto) where+import Prelude ((+))+import qualified Prelude as P'+import qualified Text.ProtocolBuffers.Header as P'+import Text.DescriptorProtos.FileDescriptorProto (FileDescriptorProto)+import Text.ProtocolBuffers.Reflections (ProtoInfo)+import qualified Text.ProtocolBuffers.WireMessage as P' (wireGet,getFromBS)+ +protoInfo :: ProtoInfo+protoInfo = P'.read+             "ProtoInfo {protoMod = ProtoName {protobufName = FIName \".google.protobuf.compiler\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\"], baseName = MName \"Compiler\"}, protoFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler.hs\"], protoSource = \"google/protobuf/compiler/plugin.proto\", extensionKeys = fromList [], messages = [DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorRequest\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\"], baseName = MName \"CodeGeneratorRequest\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorRequest.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.file_to_generate\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"file_to_generate\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.parameter\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"parameter\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.proto_file\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"proto_file\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".google.protobuf.FileDescriptorProto\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"DescriptorProtos\"], baseName = MName \"FileDescriptorProto\"}), hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False},DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\"], baseName = MName \"CodeGeneratorResponse\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorResponse.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.error\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName' = FName \"error\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.file\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName' = FName \"file\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName = MName \"File\"}), hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False},DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName = MName \"File\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorResponse\",\"File.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.name\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"name\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"insertion_point\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.content\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"content\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False}], enums = [], knownKeyMap = fromList []}"+ +fileDescriptorProto :: FileDescriptorProto+fileDescriptorProto = P'.getFromBS (P'.wireGet 11)+                       (P'.pack+                         "\143\ETX\n%google/protobuf/compiler/plugin.proto\DC2\CANgoogle.protobuf.compiler\SUB google/protobuf/descriptor.proto\"}\n\DC4CodeGeneratorRequest\DC2\CAN\n\DLEfile_to_generate\CAN\SOH \ETX(\t\DC2\DC1\n\tparameter\CAN\STX \SOH(\t\DC28\n\nproto_file\CAN\SI \ETX(\v2$.google.protobuf.FileDescriptorProto\"\170\SOH\n\NAKCodeGeneratorResponse\DC2\r\n\ENQerror\CAN\SOH \SOH(\t\DC2B\n\EOTfile\CAN\SI \ETX(\v24.google.protobuf.compiler.CodeGeneratorResponse.File\SUB>\n\EOTFile\DC2\f\n\EOTname\CAN\SOH \SOH(\t\DC2\ETB\n\SIinsertion_point\CAN\STX \SOH(\t\DC2\SI\n\acontent\CAN\SI \SOH(\t")
+ protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorRequest.hs view
@@ -0,0 +1,63 @@+module Text.Google.Protobuf.Compiler.CodeGeneratorRequest (CodeGeneratorRequest(..)) where+import Prelude ((+))+import qualified Prelude as P'+import qualified Text.ProtocolBuffers.Header as P'+import qualified Text.DescriptorProtos.FileDescriptorProto as DescriptorProtos (FileDescriptorProto)+ +data CodeGeneratorRequest = CodeGeneratorRequest{file_to_generate :: P'.Seq P'.Utf8, parameter :: P'.Maybe P'.Utf8,+                                                 proto_file :: P'.Seq DescriptorProtos.FileDescriptorProto}+                          deriving (P'.Show, P'.Eq, P'.Ord, P'.Typeable)+ +instance P'.Mergeable CodeGeneratorRequest where+  mergeEmpty = CodeGeneratorRequest P'.mergeEmpty P'.mergeEmpty P'.mergeEmpty+  mergeAppend (CodeGeneratorRequest x'1 x'2 x'3) (CodeGeneratorRequest y'1 y'2 y'3) = CodeGeneratorRequest (P'.mergeAppend x'1 y'1)+                                                                                       (P'.mergeAppend x'2 y'2)+                                                                                       (P'.mergeAppend x'3 y'3)+ +instance P'.Default CodeGeneratorRequest where+  defaultValue = CodeGeneratorRequest P'.defaultValue P'.defaultValue P'.defaultValue+ +instance P'.Wire CodeGeneratorRequest where+  wireSize ft' self'@(CodeGeneratorRequest x'1 x'2 x'3) = case ft' of+                                                            10 -> calc'Size+                                                            11 -> P'.prependMessageSize calc'Size+                                                            _ -> P'.wireSizeErr ft' self'+    where+        calc'Size = (P'.wireSizeRep 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeRep 1 11 x'3)+  wirePut ft' self'@(CodeGeneratorRequest x'1 x'2 x'3) = case ft' of+                                                           10 -> put'Fields+                                                           11 -> do+                                                                   P'.putSize (P'.wireSize 10 self')+                                                                   put'Fields+                                                           _ -> P'.wirePutErr ft' self'+    where+        put'Fields = do+                       P'.wirePutRep 10 9 x'1+                       P'.wirePutOpt 18 9 x'2+                       P'.wirePutRep 122 11 x'3+  wireGet ft' = case ft' of+                  10 -> P'.getBareMessageWith update'Self+                  11 -> P'.getMessageWith update'Self+                  _ -> P'.wireGetErr ft'+    where+        update'Self wire'Tag old'Self = case wire'Tag of+                                          10 -> P'.fmap+                                                 (\ new'Field ->+                                                   old'Self{file_to_generate = P'.append (file_to_generate old'Self) new'Field})+                                                 (P'.wireGet 9)+                                          18 -> P'.fmap (\ new'Field -> old'Self{parameter = P'.Just new'Field}) (P'.wireGet 9)+                                          122 -> P'.fmap+                                                  (\ new'Field -> old'Self{proto_file = P'.append (proto_file old'Self) new'Field})+                                                  (P'.wireGet 11)+                                          _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in+                                                P'.unknown field'Number wire'Type old'Self+ +instance P'.MessageAPI msg' (msg' -> CodeGeneratorRequest) CodeGeneratorRequest where+  getVal m' f' = f' m'+ +instance P'.GPB CodeGeneratorRequest+ +instance P'.ReflectDescriptor CodeGeneratorRequest where+  getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 122])+  reflectDescriptorInfo _ = P'.read+                             "DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorRequest\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\"], baseName = MName \"CodeGeneratorRequest\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorRequest.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.file_to_generate\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"file_to_generate\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.parameter\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"parameter\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorRequest.proto_file\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorRequest\"], baseName' = FName \"proto_file\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".google.protobuf.FileDescriptorProto\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"DescriptorProtos\"], baseName = MName \"FileDescriptorProto\"}), hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False}"
+ protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse.hs view
@@ -0,0 +1,56 @@+module Text.Google.Protobuf.Compiler.CodeGeneratorResponse (CodeGeneratorResponse(..)) where+import Prelude ((+))+import qualified Prelude as P'+import qualified Text.ProtocolBuffers.Header as P'+import qualified Text.Google.Protobuf.Compiler.CodeGeneratorResponse.File as Google.Protobuf.Compiler.CodeGeneratorResponse (File)+ +data CodeGeneratorResponse = CodeGeneratorResponse{error :: P'.Maybe P'.Utf8,+                                                   file :: P'.Seq Google.Protobuf.Compiler.CodeGeneratorResponse.File}+                           deriving (P'.Show, P'.Eq, P'.Ord, P'.Typeable)+ +instance P'.Mergeable CodeGeneratorResponse where+  mergeEmpty = CodeGeneratorResponse P'.mergeEmpty P'.mergeEmpty+  mergeAppend (CodeGeneratorResponse x'1 x'2) (CodeGeneratorResponse y'1 y'2) = CodeGeneratorResponse (P'.mergeAppend x'1 y'1)+                                                                                 (P'.mergeAppend x'2 y'2)+ +instance P'.Default CodeGeneratorResponse where+  defaultValue = CodeGeneratorResponse P'.defaultValue P'.defaultValue+ +instance P'.Wire CodeGeneratorResponse where+  wireSize ft' self'@(CodeGeneratorResponse x'1 x'2) = case ft' of+                                                         10 -> calc'Size+                                                         11 -> P'.prependMessageSize calc'Size+                                                         _ -> P'.wireSizeErr ft' self'+    where+        calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeRep 1 11 x'2)+  wirePut ft' self'@(CodeGeneratorResponse x'1 x'2) = case ft' of+                                                        10 -> put'Fields+                                                        11 -> do+                                                                P'.putSize (P'.wireSize 10 self')+                                                                put'Fields+                                                        _ -> P'.wirePutErr ft' self'+    where+        put'Fields = do+                       P'.wirePutOpt 10 9 x'1+                       P'.wirePutRep 122 11 x'2+  wireGet ft' = case ft' of+                  10 -> P'.getBareMessageWith update'Self+                  11 -> P'.getMessageWith update'Self+                  _ -> P'.wireGetErr ft'+    where+        update'Self wire'Tag old'Self = case wire'Tag of+                                          10 -> P'.fmap (\ new'Field -> old'Self{error = P'.Just new'Field}) (P'.wireGet 9)+                                          122 -> P'.fmap (\ new'Field -> old'Self{file = P'.append (file old'Self) new'Field})+                                                  (P'.wireGet 11)+                                          _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in+                                                P'.unknown field'Number wire'Type old'Self+ +instance P'.MessageAPI msg' (msg' -> CodeGeneratorResponse) CodeGeneratorResponse where+  getVal m' f' = f' m'+ +instance P'.GPB CodeGeneratorResponse+ +instance P'.ReflectDescriptor CodeGeneratorResponse where+  getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 122])+  reflectDescriptorInfo _ = P'.read+                             "DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\"], baseName = MName \"CodeGeneratorResponse\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorResponse.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.error\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName' = FName \"error\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.file\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName' = FName \"file\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName = MName \"File\"}), hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False}"
+ protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse/File.hs view
@@ -0,0 +1,56 @@+module Text.Google.Protobuf.Compiler.CodeGeneratorResponse.File (File(..)) where+import Prelude ((+))+import qualified Prelude as P'+import qualified Text.ProtocolBuffers.Header as P'+ +data File = File{name :: P'.Maybe P'.Utf8, insertion_point :: P'.Maybe P'.Utf8, content :: P'.Maybe P'.Utf8}+          deriving (P'.Show, P'.Eq, P'.Ord, P'.Typeable)+ +instance P'.Mergeable File where+  mergeEmpty = File P'.mergeEmpty P'.mergeEmpty P'.mergeEmpty+  mergeAppend (File x'1 x'2 x'3) (File y'1 y'2 y'3) = File (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2)+                                                       (P'.mergeAppend x'3 y'3)+ +instance P'.Default File where+  defaultValue = File P'.defaultValue P'.defaultValue P'.defaultValue+ +instance P'.Wire File where+  wireSize ft' self'@(File x'1 x'2 x'3) = case ft' of+                                            10 -> calc'Size+                                            11 -> P'.prependMessageSize calc'Size+                                            _ -> P'.wireSizeErr ft' self'+    where+        calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeOpt 1 9 x'3)+  wirePut ft' self'@(File x'1 x'2 x'3) = case ft' of+                                           10 -> put'Fields+                                           11 -> do+                                                   P'.putSize (P'.wireSize 10 self')+                                                   put'Fields+                                           _ -> P'.wirePutErr ft' self'+    where+        put'Fields = do+                       P'.wirePutOpt 10 9 x'1+                       P'.wirePutOpt 18 9 x'2+                       P'.wirePutOpt 122 9 x'3+  wireGet ft' = case ft' of+                  10 -> P'.getBareMessageWith update'Self+                  11 -> P'.getMessageWith update'Self+                  _ -> P'.wireGetErr ft'+    where+        update'Self wire'Tag old'Self = case wire'Tag of+                                          10 -> P'.fmap (\ new'Field -> old'Self{name = P'.Just new'Field}) (P'.wireGet 9)+                                          18 -> P'.fmap (\ new'Field -> old'Self{insertion_point = P'.Just new'Field})+                                                 (P'.wireGet 9)+                                          122 -> P'.fmap (\ new'Field -> old'Self{content = P'.Just new'Field}) (P'.wireGet 9)+                                          _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in+                                                P'.unknown field'Number wire'Type old'Self+ +instance P'.MessageAPI msg' (msg' -> File) File where+  getVal m' f' = f' m'+ +instance P'.GPB File+ +instance P'.ReflectDescriptor File where+  getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList []) (P'.fromDistinctAscList [10, 18, 122])+  reflectDescriptorInfo _ = P'.read+                             "DescriptorInfo {descName = ProtoName {protobufName = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File\", haskellPrefix = [MName \"Text\"], parentModule = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\"], baseName = MName \"File\"}, descFilePath = [\"Text\",\"Google\",\"Protobuf\",\"Compiler\",\"CodeGeneratorResponse\",\"File.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.name\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"name\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"insertion_point\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 18}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".google.protobuf.compiler.CodeGeneratorResponse.File.content\", haskellPrefix' = [MName \"Text\"], parentModule' = [MName \"Google\",MName \"Protobuf\",MName \"Compiler\",MName \"CodeGeneratorResponse\",MName \"File\"], baseName' = FName \"content\"}, fieldNumber = FieldId {getFieldId = 15}, wireTag = WireTag {getWireTag = 122}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing}], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False}"