Safe Haskell | None |
---|---|
Language | Haskell2010 |
This huge module handles the loading and name resolution. The loadProto command recursively gets all the imported proto files. 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.
hprotoc will actually resolve more unqualified imported names than Google's protoc which requires more qualified names. I do not have the obsessive nature to fix this.
Synopsis
- loadProto :: [LocalFP] -> LocalFP -> IO (Env, [FileDescriptorProto])
- loadCodeGenRequest :: CodeGeneratorRequest -> LocalFP -> (Env, [FileDescriptorProto])
- makeNameMaps :: [MName String] -> [(CanonFP, [MName String])] -> Env -> Either ErrStr NameMap
- getTLS :: Env -> (TopLevel, [TopLevel])
- getPackageID :: PackageID a -> a
- data Env
- data TopLevel = TopLevel {
- top'Path :: FilePath
- top'Package :: PackageID [IName String]
- top'FDP :: Either ErrStr FileDescriptorProto
- top'mVals :: EMap
- type ReMap = Map (FIName Utf8) ProtoName
- data NameMap = NameMap (PackageID (FIName Utf8), [MName String], [MName String]) ReMap
- data PackageID a
- = PackageID {
- _getPackageID :: a
- | NoPackageID {
- _getNoPackageID :: a
- = PackageID {
- newtype LocalFP = LocalFP {}
- newtype CanonFP = CanonFP {}
Documentation
loadProto :: [LocalFP] -> LocalFP -> IO (Env, [FileDescriptorProto]) Source #
Given a list of paths to search, loads proto files by looking for them in the file system.
loadCodeGenRequest :: CodeGeneratorRequest -> LocalFP -> (Env, [FileDescriptorProto]) Source #
makeNameMaps :: [MName String] -> [(CanonFP, [MName String])] -> Env -> Either ErrStr NameMap Source #
Compute the nameMap that determine how to translate from proto names to haskell names
The loop oever makeNameMap uses the (optional) package name
makeNameMaps is called from the run' routine in ProtoCompile.hs for both standalone and plugin use.
hPrefix and hAs are command line controlled options.
hPrefix is "-p MODULE --prefix=MODULE dotted Haskell MODULE name to use as a prefix (default is none); last flag used"
hAs is "-a FILEPATH=MODULE --as=FILEPATH=MODULE assign prefix module to imported prot file: --as descriptor.proto=Text"
Note that setAs
puts both the full path and the basename as keys into the association list
getPackageID :: PackageID a -> a Source #
By construction Env is 0 or more Local Entity namespaces followed by 1 or more Global TopLevel namespaces (self and imported files). Entities in first Global TopLevel namespace can refer to each other and to Entities in the list of directly imported TopLevel namespaces only.
TopLevel corresponds to all items defined in a .proto file. This includes the FileOptions since this will be consulted when generating the Haskell module names, and the imported files are only known through their TopLevel data.
PackageID | |
| |
NoPackageID | |
|