hprotoc 1.8.3 → 2.0.0
raw patch · 12 files changed
+899/−158 lines, 12 filesdep −QuickCheckdep ~protocol-buffersdep ~protocol-buffers-descriptor
Dependencies removed: QuickCheck
Dependency ranges changed: protocol-buffers, protocol-buffers-descriptor
Files
- README +5/−0
- Text/ProtocolBuffers/ProtoCompile.hs +7/−3
- Text/ProtocolBuffers/ProtoCompile/Gen.hs +17/−9
- Text/ProtocolBuffers/ProtoCompile/MakeReflections.hs +10/−6
- Text/ProtocolBuffers/ProtoCompile/Parser.hs +7/−7
- google-proto-files/google/protobuf/descriptor.proto +533/−0
- google-proto-files/google/protobuf/plugin.proto +145/−0
- hprotoc.cabal +22/−13
- protoc-gen-haskell/Text/Google/Protobuf/Compiler.hs +11/−7
- protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorRequest.hs +49/−42
- protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse.hs +46/−35
- protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse/File.hs +47/−36
+ README view
@@ -0,0 +1,5 @@+To regenerate the plugin haskell files, please run++hprotoc --prefix=Text -d protoc-gen-haskell -I google-proto-files/ google/protobuf/plugin.proto ++This was last populated from version 2.4.0a of Google's code.
Text/ProtocolBuffers/ProtoCompile.hs view
@@ -47,7 +47,7 @@ , optInclude :: [LocalFP] , optProto :: LocalFP , optDesc :: Maybe (LocalFP)- , optImports,optVerbose,optUnknownFields,optDryRun :: Bool }+ , optImports,optVerbose,optUnknownFields,optLazy,optDryRun :: Bool } deriving Show setPrefix,setTarget,setInclude,setProto,setDesc :: String -> Options -> Options@@ -60,6 +60,7 @@ setImports o = o { optImports = True } setVerbose o = o { optVerbose = True } setUnknown o = o { optUnknownFields = True }+setLazy o = o { optLazy = True } setDryRun o = o { optDryRun = True } toPrefix :: String -> [MName String]@@ -104,6 +105,8 @@ "dotted Haskell MODULE name to use as a prefix (default is none); last flag used" , Option ['u'] ["unknown_fields"] (NoArg (Mutate setUnknown)) "generated messages and groups all support unknown fields"+ , Option ['l'] ["lazy_fields"] (NoArg (Mutate setLazy))+ "new default is now messages with strict fields, this reverts to generating lazy fields" , Option ['v'] ["verbose"] (NoArg (Mutate setVerbose)) "increase amount of printed information" , Option [] ["version"] (NoArg (Switch VersionInfo))@@ -115,7 +118,7 @@ versionInfo = unlines $ [ "Welcome to protocol-buffers version "++showVersion version- , "Copyright (c) 2008, Christopher Kuklewicz."+ , "Copyright (c) 2008-2011, Christopher Kuklewicz." , "Released under BSD3 style license, see LICENSE file for details." , "Some proto files, such as descriptor.proto and unittest*.proto" , "are from google's code and are under an Apache 2.0 license."@@ -144,6 +147,7 @@ , optImports = False , optVerbose = False , optUnknownFields = False+ , optLazy = False , optDryRun = False } main :: IO ()@@ -241,7 +245,7 @@ unless (optDryRun options) $ dump o (optImports options) (optDesc options) fdp fdps nameMap <- either error return $ makeNameMaps (optPrefix options) (optAs options) env print' "Haskell name mangling done"- let protoInfo = makeProtoInfo (optUnknownFields options) nameMap fdp+ let protoInfo = makeProtoInfo (optUnknownFields options,optLazy options) nameMap fdp result = makeResult protoInfo seq result (print' "Recursive modules resolved") let produceMSG di = do
Text/ProtocolBuffers/ProtoCompile/Gen.hs view
@@ -250,7 +250,7 @@ -- Define LANGUAGE options as [ModulePramga] -------------------------------------------- modulePragmas :: [ModulePragma]-modulePragmas = [ LanguagePragma src (map Ident ["DeriveDataTypeable","MultiParamTypeClasses","FlexibleInstances"]) ]+modulePragmas = [ LanguagePragma src (map Ident ["BangPatterns","DeriveDataTypeable","FlexibleInstances","MultiParamTypeClasses"]) ] -------------------------------------------- -- EnumDescriptorProto module creation@@ -570,12 +570,13 @@ where eFields = F.foldr ((:) . fieldX) end (fields di) end = (if hasExt di then (extfield:) else id) $ (if storeUnknown di then [unknownField] else [])+ bangType = if lazyFields di then UnBangedTy else BangedTy extfield :: ([Name],BangType)- extfield = ([Ident "ext'field"],UnBangedTy (TyCon (private "ExtField")))+ extfield = ([Ident "ext'field"], bangType (TyCon (private "ExtField"))) unknownField :: ([Name],BangType)- unknownField = ([Ident "unknown'field"],UnBangedTy (TyCon (private "UnknownField")))+ unknownField = ([Ident "unknown'field"], bangType (TyCon (private "UnknownField"))) fieldX :: FieldInfo -> ([Name],BangType)- fieldX fi = ([baseIdent' . fieldName $ fi],UnBangedTy (labeled (TyCon typed)))+ fieldX fi = ([baseIdent' . fieldName $ fi], bangType (labeled (TyCon typed))) where labeled | canRepeat fi = typeApp "Seq" | isRequired fi = id | otherwise = typeApp "Maybe"@@ -619,8 +620,8 @@ instanceMergeable :: DescriptorInfo -> Decl instanceMergeable di = InstDecl src [] (private "Mergeable") [TyCon un]- [ inst "mergeEmpty" [] (foldl' App (Con un) (replicate len (pvar "mergeEmpty")))- , inst "mergeAppend" [PApp un patternVars1, PApp un patternVars2]+ [ -- inst "mergeEmpty" [] (foldl' App (Con un) (replicate len (pvar "mergeEmpty"))),+ inst "mergeAppend" [PApp un patternVars1, PApp un patternVars2] (foldl' App (Con un) (zipWith append vars1 vars2)) ] where un = unqualName (descName di)@@ -682,12 +683,14 @@ mUnknown | storeUnknown di = Just (last vars) | otherwise = Nothing +-- reusable 'cases' generator -- first case is for Group behavior, second case is for Message behavior, last is error handler cases g m e = Case (lvar "ft'") [ Alt src (litIntP' 10) (UnGuardedAlt g) noWhere , Alt src (litIntP' 11) (UnGuardedAlt m) noWhere , Alt src PWildCard (UnGuardedAlt e) noWhere ] +-- wireSize generation sizeCases = UnGuardedRhs $ cases (lvar "calc'Size") (pvar "prependMessageSize" $$ lvar "calc'Size") (pvar "wireSizeErr" $$ lvar "ft'" $$ lvar "self'")@@ -708,6 +711,7 @@ , litInt (getFieldType (typeCode fi)) , var] +-- wirePut generation putCases = UnGuardedRhs $ cases (lvar "put'Fields") (Do [ Qualifier $ pvar "putSize" $$@@ -735,6 +739,7 @@ foldl' App (pvar f) [ litInt (getWireTag (wireTag fi)) , litInt (getFieldType (typeCode fi)) , var]+-- wireGet generation -- new for 1.5.7, rewriting this a great deal! getCases = let param = if storeUnknown di then Paren (pvar "catch'Unknown" $$ lvar "update'Self")@@ -769,7 +774,8 @@ else litInt lo <=! x ) allowedExts --- nned to check isPacked and call appropriate wireGetKey[Un]Packed substitute function+-- wireGetErr for known extensions+-- need to check isPacked and call appropriate wireGetKey[Un]Packed substitute function toUpdateExt fi | Just (wt1,wt2) <- packedTag fi = [toUpdateExtUnpacked wt1, toUpdateExtPacked wt2] | otherwise = [toUpdateExtUnpacked (wireTag fi)] where (getUnP,getP) | isPacked fi = (pvar "wireGetKeyToPacked",pvar "wireGetKey")@@ -782,11 +788,13 @@ Alt src (litIntP . getWireTag $ wt2) (UnGuardedAlt $ getP $$ Var (mayQualName protoName (fieldName fi)) $$ lvar "old'Self") noWhere++-- wireGet without extensions toUpdate fi | Just (wt1,wt2) <- packedTag fi = [toUpdateUnpacked wt1 fi, toUpdatePacked wt2 fi] | otherwise = [toUpdateUnpacked (wireTag fi) fi] toUpdateUnpacked wt1 fi = Alt src (litIntP . getWireTag $ wt1) (UnGuardedAlt $ - preludevar "fmap" $$ (Paren $ Lambda src [patvar "new'Field"] $+ preludevar "fmap" $$ (Paren $ Lambda src [PBangPat (patvar "new'Field")] $ RecUpdate (lvar "old'Self") [FieldUpdate (unqualFName . fieldName $ fi) (labelUpdateUnpacked fi)])@@ -803,7 +811,7 @@ | otherwise = x toUpdatePacked wt2 fi = Alt src (litIntP . getWireTag $ wt2) (UnGuardedAlt $ - preludevar "fmap" $$ (Paren $ Lambda src [patvar "new'Field"] $+ preludevar "fmap" $$ (Paren $ Lambda src [PBangPat (patvar "new'Field")] $ RecUpdate (lvar "old'Self") [FieldUpdate (unqualFName . fieldName $ fi) (labelUpdatePacked fi)])
Text/ProtocolBuffers/ProtoCompile/MakeReflections.hs view
@@ -66,8 +66,11 @@ Nothing -> imp $ "toHaskell failed to find "++show k++" among "++show (M.keys reMap) Just pn -> pn -makeProtoInfo :: Bool -> NameMap -> D.FileDescriptorProto -> ProtoInfo-makeProtoInfo unknownField (NameMap (packageName,hPrefix,hParent) reMap)+makeProtoInfo :: (Bool,Bool) -- unknownField and lazyFields for makeDescriptorInfo'+ -> NameMap+ -> D.FileDescriptorProto + -> ProtoInfo+makeProtoInfo (unknownField,lazyFields) (NameMap (packageName,hPrefix,hParent) reMap) fdp@(D.FileDescriptorProto { D.FileDescriptorProto.name = Just rawName }) = ProtoInfo protoName (pnPath protoName) (toString rawName) keyInfos allMessages allEnums allKeys where protoName = case hParent of@@ -89,7 +92,7 @@ (D.DescriptorProto.name x)) groups parent' = fqAppend parent [IName (fromJust (D.DescriptorProto.name msg))]- in makeDescriptorInfo' reMap parent getKnownKeys msgIsGroup unknownField msg+ in makeDescriptorInfo' reMap parent getKnownKeys msgIsGroup (unknownField,lazyFields) msg : concatMap (\x -> processMSG parent' (checkGroup x) x) (F.toList (D.DescriptorProto.nested_type msg)) processENM parent msg = foldr ((:) . makeEnumInfo' reMap parent') nested@@ -123,9 +126,10 @@ makeDescriptorInfo' :: ReMap -> FIName Utf8 -> (ProtoName -> Seq FieldInfo)- -> Bool -> Bool+ -> Bool -- msgIsGroup+ -> (Bool,Bool) -- unknownField and lazyFields -> D.DescriptorProto -> DescriptorInfo-makeDescriptorInfo' reMap parent getKnownKeys msgIsGroup unknownField+makeDescriptorInfo' reMap parent getKnownKeys msgIsGroup (unknownField,lazyFields) (D.DescriptorProto.DescriptorProto { D.DescriptorProto.name = Just rawName , D.DescriptorProto.field = rawFields@@ -133,7 +137,7 @@ , D.DescriptorProto.extension_range = extension_range }) = let di = DescriptorInfo protoName (pnPath protoName) msgIsGroup fieldInfos keyInfos extRangeList (getKnownKeys protoName)- unknownField+ unknownField lazyFields in di -- trace (toString rawName ++ "\n" ++ show di ++ "\n\n") $ di where protoName = toHaskell reMap $ fqAppend parent [IName rawName] fieldInfos = fmap (toFieldInfo' reMap (protobufName protoName)) rawFields
Text/ProtocolBuffers/ProtoCompile/Parser.hs view
@@ -280,7 +280,7 @@ , D.NamePart.is_extension = is_extension } fileOption = pOptionWith getOld >>= setOption >>= setNew >> eol where- getOld = fmap (fromMaybe mergeEmpty . D.FileDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.FileDescriptorProto.options) getState setNew p = update' (\s -> s {D.FileDescriptorProto.options=Just p}) setOption (Left uno,old) = return' (old {D.FileOptions.uninterpreted_option = D.FileOptions.uninterpreted_option old |> uno})@@ -312,7 +312,7 @@ upExtField f = update' (\s -> s {D.DescriptorProto.extension=D.DescriptorProto.extension s |> f}) messageOption = pOptionWith getOld >>= setOption >>= setNew >> eol where- getOld = fmap (fromMaybe mergeEmpty . D.DescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.DescriptorProto.options) getState setNew p = update' (\s -> s {D.DescriptorProto.options=Just p}) setOption (Left uno,old) = return' (old {D.MessageOptions.uninterpreted_option = D.MessageOptions.uninterpreted_option old |> uno })@@ -420,7 +420,7 @@ fieldOption :: Label -> Maybe Type -> P D.FieldDescriptorProto () fieldOption label mt = liftM2 (,) pOptionE getOld >>= setOption >>= setNew where- getOld = fmap (fromMaybe mergeEmpty . D.FieldDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.FieldDescriptorProto.options) getState setNew p = update' (\s -> s { D.FieldDescriptorProto.options = Just p }) setOption (Left uno,old) = return' (old {D.FieldOptions.uninterpreted_option = D.FieldOptions.uninterpreted_option old |> uno })@@ -460,7 +460,7 @@ where rest = (enumOption <|> enumVal) >> eols >> (pChar '}' <|> rest) enumOption = pOptionWith getOld >>= setOption >>= setNew >> eol where- getOld = fmap (fromMaybe mergeEmpty . D.EnumDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.EnumDescriptorProto.options) getState setNew p = update' (\s -> s {D.EnumDescriptorProto.options=Just p}) setOption (Left uno,old) = return' $ (old {D.EnumOptions.uninterpreted_option = D.EnumOptions.uninterpreted_option old |> uno })@@ -481,7 +481,7 @@ subEnumValue = enumValueOption >> ( (pChar ']' >> eol) <|> (pChar ',' >> subEnumValue) ) enumValueOption = liftM2 (,) pOptionE getOld >>= setOption >>= setNew where- getOld = fmap (fromMaybe mergeEmpty . D.EnumValueDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.EnumValueDescriptorProto.options) getState setNew p = update' (\s -> s {D.EnumValueDescriptorProto.options=Just p}) setOption (Left uno,old) = return' $ (old {D.EnumValueOptions.uninterpreted_option = D.EnumValueOptions.uninterpreted_option old |> uno })@@ -507,7 +507,7 @@ serviceOption,rpc :: P D.ServiceDescriptorProto () serviceOption = pOptionWith getOld >>= setOption >>= setNew >> eol where- getOld = fmap (fromMaybe mergeEmpty . D.ServiceDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.ServiceDescriptorProto.options) getState setNew p = update' (\s -> s {D.ServiceDescriptorProto.options=Just p}) setOption (Left uno,old) = return' (old {D.ServiceOptions.uninterpreted_option = D.ServiceOptions.uninterpreted_option old |> uno })@@ -530,7 +530,7 @@ subRpc = pChar '}' <|> (choice [ eol, rpcOption ] >> subRpc) rpcOption = pOptionWith getOld >>= setOption >>= setNew >> eol where- getOld = fmap (fromMaybe mergeEmpty . D.MethodDescriptorProto.options) getState+ getOld = fmap (fromMaybe defaultValue . D.MethodDescriptorProto.options) getState setNew p = update' (\s -> s {D.MethodDescriptorProto.options=Just p}) setOption (Left uno,old) = return' $ (old {D.MethodOptions.uninterpreted_option = D.MethodOptions.uninterpreted_option old |> uno })
+ google-proto-files/google/protobuf/descriptor.proto view
@@ -0,0 +1,533 @@+// Protocol Buffers - Google's data interchange format+// Copyright 2008 Google Inc. All rights reserved.+// http://code.google.com/p/protobuf/+//+// Redistribution and use in source and binary forms, with or without+// modification, are permitted provided that the following conditions are+// met:+//+// * Redistributions of source code must retain the above copyright+// notice, this list of conditions and the following disclaimer.+// * Redistributions in binary form must reproduce the above+// copyright notice, this list of conditions and the following disclaimer+// in the documentation and/or other materials provided with the+// distribution.+// * Neither the name of Google Inc. nor the names of its+// 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.++// Author: kenton@google.com (Kenton Varda)+// Based on original Protocol Buffers design by+// Sanjay Ghemawat, Jeff Dean, and others.+//+// The messages in this file describe the definitions found in .proto files.+// A valid .proto file can be translated directly to a FileDescriptorProto+// without any other information (e.g. without reading its imports).++++package google.protobuf;+option java_package = "com.google.protobuf";+option java_outer_classname = "DescriptorProtos";++// descriptor.proto must be optimized for speed because reflection-based+// algorithms don't work during bootstrapping.+option optimize_for = SPEED;++// The protocol compiler can output a FileDescriptorSet containing the .proto+// files it parses.+message FileDescriptorSet {+ repeated FileDescriptorProto file = 1;+}++// Describes a complete .proto file.+message FileDescriptorProto {+ optional string name = 1; // file name, relative to root of source tree+ optional string package = 2; // e.g. "foo", "foo.bar", etc.++ // Names of files imported by this file.+ repeated string dependency = 3;++ // All top-level definitions in this file.+ repeated DescriptorProto message_type = 4;+ repeated EnumDescriptorProto enum_type = 5;+ repeated ServiceDescriptorProto service = 6;+ repeated FieldDescriptorProto extension = 7;++ optional FileOptions options = 8;++ // This field contains optional information about the original source code.+ // You may safely remove this entire field whithout harming runtime+ // functionality of the descriptors -- the information is needed only by+ // development tools.+ optional SourceCodeInfo source_code_info = 9;+}++// Describes a message type.+message DescriptorProto {+ optional string name = 1;++ repeated FieldDescriptorProto field = 2;+ repeated FieldDescriptorProto extension = 6;++ repeated DescriptorProto nested_type = 3;+ repeated EnumDescriptorProto enum_type = 4;++ message ExtensionRange {+ optional int32 start = 1;+ optional int32 end = 2;+ }+ repeated ExtensionRange extension_range = 5;++ optional MessageOptions options = 7;+}++// Describes a field within a message.+message FieldDescriptorProto {+ enum Type {+ // 0 is reserved for errors.+ // Order is weird for historical reasons.+ TYPE_DOUBLE = 1;+ TYPE_FLOAT = 2;+ TYPE_INT64 = 3; // Not ZigZag encoded. Negative numbers+ // take 10 bytes. Use TYPE_SINT64 if negative+ // values are likely.+ TYPE_UINT64 = 4;+ TYPE_INT32 = 5; // Not ZigZag encoded. Negative numbers+ // take 10 bytes. Use TYPE_SINT32 if negative+ // values are likely.+ TYPE_FIXED64 = 6;+ TYPE_FIXED32 = 7;+ TYPE_BOOL = 8;+ TYPE_STRING = 9;+ TYPE_GROUP = 10; // Tag-delimited aggregate.+ TYPE_MESSAGE = 11; // Length-delimited aggregate.++ // New in version 2.+ TYPE_BYTES = 12;+ TYPE_UINT32 = 13;+ TYPE_ENUM = 14;+ TYPE_SFIXED32 = 15;+ TYPE_SFIXED64 = 16;+ TYPE_SINT32 = 17; // Uses ZigZag encoding.+ TYPE_SINT64 = 18; // Uses ZigZag encoding.+ };++ enum Label {+ // 0 is reserved for errors+ LABEL_OPTIONAL = 1;+ LABEL_REQUIRED = 2;+ LABEL_REPEATED = 3;+ // TODO(sanjay): Should we add LABEL_MAP?+ };++ optional string name = 1;+ optional int32 number = 3;+ optional Label label = 4;++ // If type_name is set, this need not be set. If both this and type_name+ // are set, this must be either TYPE_ENUM or TYPE_MESSAGE.+ optional Type type = 5;++ // For message and enum types, this is the name of the type. If the name+ // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping+ // rules are used to find the type (i.e. first the nested types within this+ // message are searched, then within the parent, on up to the root+ // namespace).+ optional string type_name = 6;++ // For extensions, this is the name of the type being extended. It is+ // resolved in the same manner as type_name.+ optional string extendee = 2;++ // For numeric types, contains the original text representation of the value.+ // For booleans, "true" or "false".+ // For strings, contains the default text contents (not escaped in any way).+ // For bytes, contains the C escaped value. All bytes >= 128 are escaped.+ // TODO(kenton): Base-64 encode?+ optional string default_value = 7;++ optional FieldOptions options = 8;+}++// Describes an enum type.+message EnumDescriptorProto {+ optional string name = 1;++ repeated EnumValueDescriptorProto value = 2;++ optional EnumOptions options = 3;+}++// Describes a value within an enum.+message EnumValueDescriptorProto {+ optional string name = 1;+ optional int32 number = 2;++ optional EnumValueOptions options = 3;+}++// Describes a service.+message ServiceDescriptorProto {+ optional string name = 1;+ repeated MethodDescriptorProto method = 2;++ optional ServiceOptions options = 3;+}++// Describes a method of a service.+message MethodDescriptorProto {+ optional string name = 1;++ // Input and output type names. These are resolved in the same way as+ // FieldDescriptorProto.type_name, but must refer to a message type.+ optional string input_type = 2;+ optional string output_type = 3;++ optional MethodOptions options = 4;+}++// ===================================================================+// Options++// Each of the definitions above may have "options" attached. These are+// just annotations which may cause code to be generated slightly differently+// or may contain hints for code that manipulates protocol messages.+//+// Clients may define custom options as extensions of the *Options messages.+// These extensions may not yet be known at parsing time, so the parser cannot+// store the values in them. Instead it stores them in a field in the *Options+// message called uninterpreted_option. This field must have the same name+// across all *Options messages. We then use this field to populate the+// extensions when we build a descriptor, at which point all protos have been+// parsed and so all extensions are known.+//+// Extension numbers for custom options may be chosen as follows:+// * For options which will only be used within a single application or+// organization, or for experimental options, use field numbers 50000+// through 99999. It is up to you to ensure that you do not use the+// same number for multiple options.+// * For options which will be published and used publicly by multiple+// independent entities, e-mail kenton@google.com to reserve extension+// numbers. Simply tell me how many you need and I'll send you back a+// set of numbers to use -- there's no need to explain how you intend to+// use them. If this turns out to be popular, a web service will be set up+// to automatically assign option numbers.+++message FileOptions {++ // Sets the Java package where classes generated from this .proto will be+ // placed. By default, the proto package is used, but this is often+ // inappropriate because proto packages do not normally start with backwards+ // domain names.+ optional string java_package = 1;+++ // If set, all the classes from the .proto file are wrapped in a single+ // outer class with the given name. This applies to both Proto1+ // (equivalent to the old "--one_java_file" option) and Proto2 (where+ // a .proto always translates to a single class, but you may want to+ // explicitly choose the class name).+ optional string java_outer_classname = 8;++ // If set true, then the Java code generator will generate a separate .java+ // file for each top-level message, enum, and service defined in the .proto+ // file. Thus, these types will *not* be nested inside the outer class+ // named by java_outer_classname. However, the outer class will still be+ // generated to contain the file's getDescriptor() method as well as any+ // top-level extensions defined in the file.+ optional bool java_multiple_files = 10 [default=false];++ // If set true, then the Java code generator will generate equals() and+ // hashCode() methods for all messages defined in the .proto file. This is+ // purely a speed optimization, as the AbstractMessage base class includes+ // reflection-based implementations of these methods.+ optional bool java_generate_equals_and_hash = 20 [default=false];++ // Generated classes can be optimized for speed or code size.+ enum OptimizeMode {+ SPEED = 1; // Generate complete code for parsing, serialization,+ // etc.+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.+ }+ optional OptimizeMode optimize_for = 9 [default=SPEED];+++++ // Should generic services be generated in each language? "Generic" services+ // are not specific to any particular RPC system. They are generated by the+ // main code generators in each language (without additional plugins).+ // Generic services were the only kind of service generation supported by+ // early versions of proto2.+ //+ // Generic services are now considered deprecated in favor of using plugins+ // that generate code specific to your particular RPC system. Therefore,+ // these default to false. Old code which depends on generic services should+ // explicitly set them to true.+ optional bool cc_generic_services = 16 [default=false];+ optional bool java_generic_services = 17 [default=false];+ optional bool py_generic_services = 18 [default=false];++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message MessageOptions {+ // Set true to use the old proto1 MessageSet wire format for extensions.+ // This is provided for backwards-compatibility with the MessageSet wire+ // format. You should not use this for any other reason: It's less+ // efficient, has fewer features, and is more complicated.+ //+ // The message must be defined exactly as follows:+ // message Foo {+ // option message_set_wire_format = true;+ // extensions 4 to max;+ // }+ // Note that the message cannot have any defined fields; MessageSets only+ // have extensions.+ //+ // All extensions of your type must be singular messages; e.g. they cannot+ // be int32s, enums, or repeated messages.+ //+ // Because this is an option, the above two restrictions are not enforced by+ // the protocol compiler.+ optional bool message_set_wire_format = 1 [default=false];++ // Disables the generation of the standard "descriptor()" accessor, which can+ // conflict with a field of the same name. This is meant to make migration+ // from proto1 easier; new code should avoid fields named "descriptor".+ optional bool no_standard_descriptor_accessor = 2 [default=false];++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message FieldOptions {+ // The ctype option instructs the C++ code generator to use a different+ // representation of the field than it normally would. See the specific+ // options below. This option is not yet implemented in the open source+ // release -- sorry, we'll try to include it in a future version!+ optional CType ctype = 1 [default = STRING];+ enum CType {+ // Default mode.+ STRING = 0;++ CORD = 1;++ STRING_PIECE = 2;+ }+ // The packed option can be enabled for repeated primitive fields to enable+ // a more efficient representation on the wire. Rather than repeatedly+ // writing the tag and type for each element, the entire array is encoded as+ // a single length-delimited blob.+ optional bool packed = 2;+++ // Is this field deprecated?+ // Depending on the target platform, this can emit Deprecated annotations+ // for accessors, or it will be completely ignored; in the very least, this+ // is a formalization for deprecating fields.+ optional bool deprecated = 3 [default=false];++ // EXPERIMENTAL. DO NOT USE.+ // For "map" fields, the name of the field in the enclosed type that+ // is the key for this map. For example, suppose we have:+ // message Item {+ // required string name = 1;+ // required string value = 2;+ // }+ // message Config {+ // repeated Item items = 1 [experimental_map_key="name"];+ // }+ // In this situation, the map key for Item will be set to "name".+ // TODO: Fully-implement this, then remove the "experimental_" prefix.+ optional string experimental_map_key = 9;++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message EnumOptions {++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message EnumValueOptions {+ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message ServiceOptions {++ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC+ // framework. We apologize for hoarding these numbers to ourselves, but+ // we were already using them long before we decided to release Protocol+ // Buffers.++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++message MethodOptions {++ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC+ // framework. We apologize for hoarding these numbers to ourselves, but+ // we were already using them long before we decided to release Protocol+ // Buffers.++ // The parser stores options it doesn't recognize here. See above.+ repeated UninterpretedOption uninterpreted_option = 999;++ // Clients can define custom options in extensions of this message. See above.+ extensions 1000 to max;+}++// A message representing a option the parser does not recognize. This only+// appears in options protos created by the compiler::Parser class.+// DescriptorPool resolves these when building Descriptor objects. Therefore,+// options protos in descriptor objects (e.g. returned by Descriptor::options(),+// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions+// in them.+message UninterpretedOption {+ // The name of the uninterpreted option. Each string represents a segment in+ // a dot-separated name. is_extension is true iff a segment represents an+ // extension (denoted with parentheses in options specs in .proto files).+ // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents+ // "foo.(bar.baz).qux".+ message NamePart {+ required string name_part = 1;+ required bool is_extension = 2;+ }+ repeated NamePart name = 2;++ // The value of the uninterpreted option, in whatever type the tokenizer+ // identified it as during parsing. Exactly one of these should be set.+ optional string identifier_value = 3;+ optional uint64 positive_int_value = 4;+ optional int64 negative_int_value = 5;+ optional double double_value = 6;+ optional bytes string_value = 7;+ optional string aggregate_value = 8;+}++// ===================================================================+// Optional source code info++// Encapsulates information about the original source file from which a+// FileDescriptorProto was generated.+message SourceCodeInfo {+ // A Location identifies a piece of source code in a .proto file which+ // corresponds to a particular definition. This information is intended+ // to be useful to IDEs, code indexers, documentation generators, and similar+ // tools.+ //+ // For example, say we have a file like:+ // message Foo {+ // optional string foo = 1;+ // }+ // Let's look at just the field definition:+ // optional string foo = 1;+ // ^ ^^ ^^ ^ ^^^+ // a bc de f ghi+ // We have the following locations:+ // span path represents+ // [a,i) [ 4, 0, 2, 0 ] The whole field definition.+ // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).+ // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).+ // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).+ // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).+ //+ // Notes:+ // - A location may refer to a repeated field itself (i.e. not to any+ // particular index within it). This is used whenever a set of elements are+ // logically enclosed in a single code segment. For example, an entire+ // extend block (possibly containing multiple extension definitions) will+ // have an outer location whose path refers to the "extensions" repeated+ // field without an index.+ // - Multiple locations may have the same path. This happens when a single+ // logical declaration is spread out across multiple places. The most+ // obvious example is the "extend" block again -- there may be multiple+ // extend blocks in the same scope, each of which will have the same path.+ // - A location's span is not always a subset of its parent's span. For+ // example, the "extendee" of an extension declaration appears at the+ // beginning of the "extend" block and is shared by all extensions within+ // the block.+ // - Just because a location's span is a subset of some other location's span+ // does not mean that it is a descendent. For example, a "group" defines+ // both a type and a field in a single declaration. Thus, the locations+ // corresponding to the type and field and their components will overlap.+ // - Code which tries to interpret locations should probably be designed to+ // ignore those that it doesn't understand, as more types of locations could+ // be recorded in the future.+ repeated Location location = 1;+ message Location {+ // Identifies which part of the FileDescriptorProto was defined at this+ // location.+ //+ // Each element is a field number or an index. They form a path from+ // the root FileDescriptorProto to the place where the definition. For+ // example, this path:+ // [ 4, 3, 2, 7, 1 ]+ // refers to:+ // file.message_type(3) // 4, 3+ // .field(7) // 2, 7+ // .name() // 1+ // This is because FileDescriptorProto.message_type has field number 4:+ // repeated DescriptorProto message_type = 4;+ // and DescriptorProto.field has field number 2:+ // repeated FieldDescriptorProto field = 2;+ // and FieldDescriptorProto.name has field number 1:+ // optional string name = 1;+ //+ // Thus, the above path gives the location of a field name. If we removed+ // the last element:+ // [ 4, 3, 2, 7 ]+ // this path refers to the whole field declaration (from the beginning+ // of the label to the terminating semicolon).+ repeated int32 path = 1 [packed=true];++ // Always has exactly three or four elements: start line, start column,+ // end line (optional, otherwise assumed same as start line), end column.+ // These are packed into a single field for efficiency. Note that line+ // and column numbers are zero-based -- typically you will want to add+ // 1 to each before displaying to a user.+ repeated int32 span = 2 [packed=true];++ // TODO(kenton): Record comments appearing before and after the+ // declaration.+ }+}
+ google-proto-files/google/protobuf/plugin.proto view
@@ -0,0 +1,145 @@+// Protocol Buffers - Google's data interchange format+// Copyright 2008 Google Inc. All rights reserved.+// http://code.google.com/p/protobuf/+//+// Redistribution and use in source and binary forms, with or without+// modification, are permitted provided that the following conditions are+// met:+//+// * Redistributions of source code must retain the above copyright+// notice, this list of conditions and the following disclaimer.+// * Redistributions in binary form must reproduce the above+// copyright notice, this list of conditions and the following disclaimer+// in the documentation and/or other materials provided with the+// distribution.+// * Neither the name of Google Inc. nor the names of its+// 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.++// Author: kenton@google.com (Kenton Varda)+//+// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to+// change.+//+// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is+// just a program that reads a CodeGeneratorRequest from stdin and writes a+// CodeGeneratorResponse to stdout.+//+// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead+// of dealing with the raw protocol defined here.+//+// A plugin executable needs only to be placed somewhere in the path. The+// plugin should be named "protoc-gen-$NAME", and will then be used when the+// flag "--${NAME}_out" is passed to protoc.++package google.protobuf.compiler;++import "google/protobuf/descriptor.proto";++// An encoded CodeGeneratorRequest is written to the plugin's stdin.+message CodeGeneratorRequest {+ // The .proto files that were explicitly listed on the command-line. The+ // code generator should generate code only for these files. Each file's+ // descriptor will be included in proto_file, below.+ repeated string file_to_generate = 1;++ // The generator parameter passed on the command-line.+ optional string parameter = 2;++ // FileDescriptorProtos for all files in files_to_generate and everything+ // they import. The files will appear in topological order, so each file+ // appears before any file that imports it.+ //+ // protoc guarantees that all proto_files will be written after+ // the fields above, even though this is not technically guaranteed by the+ // protobuf wire format. This theoretically could allow a plugin to stream+ // in the FileDescriptorProtos and handle them one by one rather than read+ // the entire set into memory at once. However, as of this writing, this+ // is not similarly optimized on protoc's end -- it will store all fields in+ // memory at once before sending them to the plugin.+ repeated FileDescriptorProto proto_file = 15;+}++// The plugin writes an encoded CodeGeneratorResponse to stdout.+message CodeGeneratorResponse {+ // Error message. If non-empty, code generation failed. The plugin process+ // should exit with status code zero even if it reports an error in this way.+ //+ // This should be used to indicate errors in .proto files which prevent the+ // code generator from generating correct code. Errors which indicate a+ // problem in protoc itself -- such as the input CodeGeneratorRequest being+ // unparseable -- should be reported by writing a message to stderr and+ // exiting with a non-zero status code.+ optional string error = 1;++ // Represents a single generated file.+ message File {+ // The file name, relative to the output directory. The name must not+ // contain "." or ".." components and must be relative, not be absolute (so,+ // the file cannot lie outside the output directory). "/" must be used as+ // the path separator, not "\".+ //+ // If the name is omitted, the content will be appended to the previous+ // file. This allows the generator to break large files into small chunks,+ // and allows the generated text to be streamed back to protoc so that large+ // files need not reside completely in memory at one time. Note that as of+ // this writing protoc does not optimize for this -- it will read the entire+ // CodeGeneratorResponse before writing files to disk.+ optional string name = 1;++ // If non-empty, indicates that the named file should already exist, and the+ // content here is to be inserted into that file at a defined insertion+ // point. This feature allows a code generator to extend the output+ // produced by another code generator. The original generator may provide+ // insertion points by placing special annotations in the file that look+ // like:+ // @@protoc_insertion_point(NAME)+ // The annotation can have arbitrary text before and after it on the line,+ // which allows it to be placed in a comment. NAME should be replaced with+ // an identifier naming the point -- this is what other generators will use+ // as the insertion_point. Code inserted at this point will be placed+ // immediately above the line containing the insertion point (thus multiple+ // insertions to the same point will come out in the order they were added).+ // The double-@ is intended to make it unlikely that the generated code+ // could contain things that look like insertion points by accident.+ //+ // For example, the C++ code generator places the following line in the+ // .pb.h files that it generates:+ // // @@protoc_insertion_point(namespace_scope)+ // This line appears within the scope of the file's package namespace, but+ // outside of any particular class. Another plugin can then specify the+ // insertion_point "namespace_scope" to generate additional classes or+ // other declarations that should be placed in this scope.+ //+ // Note that if the line containing the insertion point begins with+ // whitespace, the same whitespace will be added to every line of the+ // inserted text. This is useful for languages like Python, where+ // indentation matters. In these languages, the insertion point comment+ // should be indented the same amount as any inserted code will need to be+ // in order to work correctly in that context.+ //+ // The code generator that generates the initial file and the one which+ // inserts into it must both run as part of a single invocation of protoc.+ // Code generators are executed in the order in which they appear on the+ // command line.+ //+ // If |insertion_point| is present, |name| must also be present.+ optional string insertion_point = 2;++ // The file contents.+ optional string content = 15;+ }+ repeated File file = 15;+}
hprotoc.cabal view
@@ -1,36 +1,45 @@ name: hprotoc-version: 1.8.3+version: 2.0.0 cabal-version: >= 1.6 build-type: Simple license: BSD3 license-file: LICENSE-copyright: (c) 2008 Christopher Edward Kuklewicz+copyright: (c) 2008-2011 Christopher Edward Kuklewicz author: Christopher Edward Kuklewicz maintainer: Chris Kuklewicz <protobuf@personal.mightyreason.com> stability: Experimental-homepage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers+homepage: http://hackage.haskell.org/package/hprotoc package-url: http://code.haskell.org/protocol-buffers/ synopsis: Parse Google Protocol Buffer specifications-description: Parse "http://code.google.com/apis/protocolbuffers/docs/proto.html" and perhaps general haskell code to use them+description: Parse language defined at "http://code.google.com/apis/protocolbuffers/docs/proto.html" and general haskell code to implement messages. category: Text-Tested-With: GHC ==6.8.3-extra-source-files:+Tested-With: GHC == 7.0.3+extra-source-files: README,+ google-proto-files/google/protobuf/descriptor.proto,+ google-proto-files/google/protobuf/plugin.proto flag small_base description: Choose the new smaller, split-up base package. Executable hprotoc Main-Is: Text/ProtocolBuffers/ProtoCompile.hs- Hs-Source-Dirs: .,protoc-gen-haskell+ Hs-Source-Dirs: .,+ protoc-gen-haskell build-tools: alex ghc-options: -O2 -Wall -fspec-constr-count=10- build-depends: protocol-buffers == 1.8.3, protocol-buffers-descriptor == 1.8.3- build-depends: binary, utf8-string- build-depends: parsec < 3, haskell-src-exts >= 1.7.0,- containers,bytestring,array,- filepath >= 1.1.0.0,+ ghc-prof-options: -O2 -auto-all -prof+ build-depends: protocol-buffers == 1.11.1,+ protocol-buffers-descriptor == 1.11.2+ build-depends: array,+ binary,+ bytestring,+ containers, directory >= 1.0.0.1,- mtl,QuickCheck+ filepath >= 1.1.0.0,+ haskell-src-exts >= 1.7.0,+ mtl,+ parsec < 3,+ utf8-string if flag(small_base) build-depends: base == 4.*
protoc-gen-haskell/Text/Google/Protobuf/Compiler.hs view
@@ -1,16 +1,20 @@+{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} module Text.Google.Protobuf.Compiler (protoInfo, fileDescriptorProto) where-import Prelude ((+))-import qualified Prelude as P'+import Prelude ((+), (/))+import qualified Prelude as Prelude'+import qualified Data.Typeable as Prelude' 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 []}"+protoInfo+ = Prelude'.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/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 = True, lazyFields = 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 = True, lazyFields = 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 = True, lazyFields = 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")+fileDescriptorProto+ = P'.getFromBS (P'.wireGet 11)+ (P'.pack+ "\134\ETX\n\FSgoogle/protobuf/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
@@ -1,56 +1,62 @@+{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} module Text.Google.Protobuf.Compiler.CodeGeneratorRequest (CodeGeneratorRequest(..)) where-import Prelude ((+))-import qualified Prelude as P'+import Prelude ((+), (/))+import qualified Prelude as Prelude'+import qualified Data.Typeable as Prelude' 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)+data CodeGeneratorRequest = CodeGeneratorRequest{file_to_generate :: !(P'.Seq P'.Utf8), parameter :: !(P'.Maybe P'.Utf8),+ proto_file :: !(P'.Seq DescriptorProtos.FileDescriptorProto),+ unknown'field :: !P'.UnknownField}+ deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable) +instance P'.UnknownMessage CodeGeneratorRequest where+ getUnknownField = unknown'field+ putUnknownField u'f msg = msg{unknown'field = u'f}+ 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)+ mergeAppend (CodeGeneratorRequest x'1 x'2 x'3 x'4) (CodeGeneratorRequest y'1 y'2 y'3 y'4)+ = CodeGeneratorRequest (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) (P'.mergeAppend x'4 y'4) instance P'.Default CodeGeneratorRequest where- defaultValue = CodeGeneratorRequest P'.defaultValue P'.defaultValue P'.defaultValue+ defaultValue = CodeGeneratorRequest P'.defaultValue 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'+ wireSize ft' self'@(CodeGeneratorRequest x'1 x'2 x'3 x'4)+ = 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'+ calc'Size = (P'.wireSizeRep 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeRep 1 11 x'3 + P'.wireSizeUnknownField x'4)+ wirePut ft' self'@(CodeGeneratorRequest x'1 x'2 x'3 x'4)+ = 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'+ put'Fields+ = do+ P'.wirePutRep 10 9 x'1+ P'.wirePutOpt 18 9 x'2+ P'.wirePutRep 122 11 x'3+ P'.wirePutUnknownField x'4+ wireGet ft'+ = case ft' of+ 10 -> P'.getBareMessageWith (P'.catch'Unknown update'Self)+ 11 -> P'.getMessageWith (P'.catch'Unknown 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+ update'Self wire'Tag old'Self+ = case wire'Tag of+ 10 -> Prelude'.fmap (\ !new'Field -> old'Self{file_to_generate = P'.append (file_to_generate old'Self) new'Field})+ (P'.wireGet 9)+ 18 -> Prelude'.fmap (\ !new'Field -> old'Self{parameter = Prelude'.Just new'Field}) (P'.wireGet 9)+ 122 -> Prelude'.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'@@ -59,5 +65,6 @@ 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}"+ reflectDescriptorInfo _+ = Prelude'.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 = True, lazyFields = False}"
protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse.hs view
@@ -1,49 +1,59 @@+{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} module Text.Google.Protobuf.Compiler.CodeGeneratorResponse (CodeGeneratorResponse(..)) where-import Prelude ((+))-import qualified Prelude as P'+import Prelude ((+), (/))+import qualified Prelude as Prelude'+import qualified Data.Typeable as Prelude' 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)+data CodeGeneratorResponse = CodeGeneratorResponse{error :: !(P'.Maybe P'.Utf8),+ file :: !(P'.Seq Google.Protobuf.Compiler.CodeGeneratorResponse.File),+ unknown'field :: !P'.UnknownField}+ deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable) +instance P'.UnknownMessage CodeGeneratorResponse where+ getUnknownField = unknown'field+ putUnknownField u'f msg = msg{unknown'field = u'f}+ 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)+ mergeAppend (CodeGeneratorResponse x'1 x'2 x'3) (CodeGeneratorResponse y'1 y'2 y'3)+ = CodeGeneratorResponse (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) instance P'.Default CodeGeneratorResponse where- defaultValue = CodeGeneratorResponse P'.defaultValue P'.defaultValue+ defaultValue = CodeGeneratorResponse P'.defaultValue 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'+ wireSize ft' self'@(CodeGeneratorResponse 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'.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'+ calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeRep 1 11 x'2 + P'.wireSizeUnknownField x'3)+ wirePut ft' self'@(CodeGeneratorResponse 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'.wirePutRep 122 11 x'2- wireGet ft' = case ft' of- 10 -> P'.getBareMessageWith update'Self- 11 -> P'.getMessageWith update'Self- _ -> P'.wireGetErr ft'+ put'Fields+ = do+ P'.wirePutOpt 10 9 x'1+ P'.wirePutRep 122 11 x'2+ P'.wirePutUnknownField x'3+ wireGet ft'+ = case ft' of+ 10 -> P'.getBareMessageWith (P'.catch'Unknown update'Self)+ 11 -> P'.getMessageWith (P'.catch'Unknown 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+ update'Self wire'Tag old'Self+ = case wire'Tag of+ 10 -> Prelude'.fmap (\ !new'Field -> old'Self{error = Prelude'.Just new'Field}) (P'.wireGet 9)+ 122 -> Prelude'.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'@@ -52,5 +62,6 @@ 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}"+ reflectDescriptorInfo _+ = Prelude'.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 = True, lazyFields = False}"
protoc-gen-haskell/Text/Google/Protobuf/Compiler/CodeGeneratorResponse/File.hs view
@@ -1,49 +1,59 @@+{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} module Text.Google.Protobuf.Compiler.CodeGeneratorResponse.File (File(..)) where-import Prelude ((+))-import qualified Prelude as P'+import Prelude ((+), (/))+import qualified Prelude as Prelude'+import qualified Data.Typeable as Prelude' 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)+data File = File{name :: !(P'.Maybe P'.Utf8), insertion_point :: !(P'.Maybe P'.Utf8), content :: !(P'.Maybe P'.Utf8),+ unknown'field :: !P'.UnknownField}+ deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable) +instance P'.UnknownMessage File where+ getUnknownField = unknown'field+ putUnknownField u'f msg = msg{unknown'field = u'f}+ 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)+ mergeAppend (File x'1 x'2 x'3 x'4) (File y'1 y'2 y'3 y'4)+ = File (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) (P'.mergeAppend x'4 y'4) instance P'.Default File where- defaultValue = File P'.defaultValue P'.defaultValue P'.defaultValue+ defaultValue = File P'.defaultValue 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'+ wireSize ft' self'@(File x'1 x'2 x'3 x'4)+ = 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'+ calc'Size = (P'.wireSizeOpt 1 9 x'1 + P'.wireSizeOpt 1 9 x'2 + P'.wireSizeOpt 1 9 x'3 + P'.wireSizeUnknownField x'4)+ wirePut ft' self'@(File x'1 x'2 x'3 x'4)+ = 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'+ put'Fields+ = do+ P'.wirePutOpt 10 9 x'1+ P'.wirePutOpt 18 9 x'2+ P'.wirePutOpt 122 9 x'3+ P'.wirePutUnknownField x'4+ wireGet ft'+ = case ft' of+ 10 -> P'.getBareMessageWith (P'.catch'Unknown update'Self)+ 11 -> P'.getMessageWith (P'.catch'Unknown 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+ update'Self wire'Tag old'Self+ = case wire'Tag of+ 10 -> Prelude'.fmap (\ !new'Field -> old'Self{name = Prelude'.Just new'Field}) (P'.wireGet 9)+ 18 -> Prelude'.fmap (\ !new'Field -> old'Self{insertion_point = Prelude'.Just new'Field}) (P'.wireGet 9)+ 122 -> Prelude'.fmap (\ !new'Field -> old'Self{content = Prelude'.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'@@ -52,5 +62,6 @@ 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}"+ reflectDescriptorInfo _+ = Prelude'.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 = True, lazyFields = False}"