Safe Haskell | None |
---|---|
Language | Haskell98 |
A strong feature of the protocol-buffers package is that it does
not contain any structures defined by descriptor.proto! This
prevents me hitting any annoying circular dependencies. The
structures defined here are included in each module created by
hprotoc
. They are optimized for use in code generation.
These values can be inspected at runtime by the user's code, but I have yet to write much documentation. Luckily the record field names are somewhat descriptive.
The other reflection is using the fileDescriptorProto
which
is put into the top level module created by hprotoc.
- data ProtoName = ProtoName {
- protobufName :: FIName Utf8
- haskellPrefix :: [MName String]
- parentModule :: [MName String]
- baseName :: MName String
- data ProtoFName = ProtoFName {}
- data ProtoInfo = ProtoInfo {
- protoMod :: ProtoName
- protoFilePath :: [FilePath]
- protoSource :: FilePath
- extensionKeys :: Seq KeyInfo
- messages :: [DescriptorInfo]
- enums :: [EnumInfo]
- oneofs :: [OneofInfo]
- knownKeyMap :: Map ProtoName (Seq FieldInfo)
- data DescriptorInfo = DescriptorInfo {}
- data FieldInfo = FieldInfo {
- fieldName :: ProtoFName
- fieldNumber :: FieldId
- wireTag :: WireTag
- packedTag :: Maybe (WireTag, WireTag)
- wireTagLength :: WireSize
- isPacked :: Bool
- isRequired :: Bool
- canRepeat :: Bool
- mightPack :: Bool
- typeCode :: FieldType
- typeName :: Maybe ProtoName
- hsRawDefault :: Maybe ByteString
- hsDefault :: Maybe HsDefault
- type KeyInfo = (ProtoName, FieldInfo)
- data HsDefault
- data SomeRealFloat
- data EnumInfo = EnumInfo {
- enumName :: ProtoName
- enumFilePath :: [FilePath]
- enumValues :: [(EnumCode, String)]
- type EnumInfoApp e = [(EnumCode, String, e)]
- class ReflectDescriptor m where
- class ReflectEnum e where
- data GetMessageInfo = GetMessageInfo {}
- data OneofInfo = OneofInfo {}
- makePNF :: ByteString -> [String] -> [String] -> String -> ProtoName
- toRF :: (RealFloat a, Fractional a) => SomeRealFloat -> a
- fromRF :: (RealFloat a, Fractional a) => a -> SomeRealFloat
Documentation
This is fully qualified name data type for code generation. The
haskellPrefix
was possibly specified on the hprotoc
command
line. The parentModule
is a combination of the module prefix
from the '.proto' file and any nested levels of definition.
The name components are likely to have been mangled to ensure the
baseName
started with an uppercase letter, in ['A'..'Z']
.
ProtoName | |
|
data ProtoFName Source #
ProtoFName | |
|
ProtoInfo | |
|
FieldInfo | |
|
HsDefault
stores the parsed default from the proto file in a
form that will make a nice literal in the
Language.Haskell.Exts.Syntax code generation by hprotoc
.
Note that Utf8 labeled byte sequences have been stripped to just
ByteString
here as this is sufficient for code generation.
On 25 August 2010 20:12, George van den Driessche georgevdd@google.com sent Chris Kuklewicz a patch to MakeReflections.parseDefEnum to ensure that HsDef'Enum holds the mangled form of the name.
data SomeRealFloat Source #
SomeRealFloat
projects Double/Float to Rational or a special IEEE type.
This is needed to track protobuf-2.3.0 which allows nan and inf and -inf default values.
EnumInfo | |
|
type EnumInfoApp e = [(EnumCode, String, e)] Source #
class ReflectDescriptor m where Source #
getMessageInfo :: m -> GetMessageInfo Source #
This is obtained via read
on the stored show
output of the DescriptorInfo
in
the module file. It is used in getting messages from the wire.
Must not inspect argument
reflectDescriptorInfo :: m -> DescriptorInfo Source #
class ReflectEnum e where Source #
reflectEnum :: EnumInfoApp e Source #
reflectEnumInfo :: e -> EnumInfo Source #
parentOfEnum :: e -> Maybe DescriptorInfo Source #
data GetMessageInfo Source #
GetMessageInfo
is used in getting messages from the wire. It
supplies the Set
of precomposed wire tags that must be found in
the message as well as a Set
of all allowed tags (including known
extension fields and all required wire tags).
Extension fields not in the allowedTags set are still loaded, but
only as ByteString
blobs that will have to interpreted later.
OneofInfo | |
|
makePNF :: ByteString -> [String] -> [String] -> String -> ProtoName Source #
makePNF
is used by the generated code to create a ProtoName with less newtype noise.
toRF :: (RealFloat a, Fractional a) => SomeRealFloat -> a Source #
fromRF :: (RealFloat a, Fractional a) => a -> SomeRealFloat Source #