Documentation
¶
Index ¶
- func TranslateType(t string) string
- type Enum
- type EnumVisitor
- type Function
- type Member
- type Message
- type MessageVisitor
- type ProtoData
- func (v *ProtoData) Parse() error
- func (v *ProtoData) VisitComment(c *proto.Comment)
- func (v *ProtoData) VisitEnum(e *proto.Enum)
- func (v *ProtoData) VisitEnumField(e *proto.EnumField)
- func (v *ProtoData) VisitExtensions(e *proto.Extensions)
- func (v *ProtoData) VisitGroup(g *proto.Group)
- func (v *ProtoData) VisitImport(i *proto.Import)
- func (v *ProtoData) VisitMapField(m *proto.MapField)
- func (v *ProtoData) VisitMessage(m *proto.Message)
- func (v *ProtoData) VisitNormalField(n *proto.NormalField)
- func (v *ProtoData) VisitOneof(o *proto.Oneof)
- func (v *ProtoData) VisitOneofField(o *proto.OneOfField)
- func (v *ProtoData) VisitOption(o *proto.Option)
- func (v *ProtoData) VisitPackage(p *proto.Package)
- func (v *ProtoData) VisitRPC(r *proto.RPC)
- func (v *ProtoData) VisitReserved(r *proto.Reserved)
- func (v *ProtoData) VisitService(r *proto.Service)
- func (v *ProtoData) VisitSyntax(s *proto.Syntax)
- type ProtoType
- type Service
- type ServiceVisitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TranslateType ¶
TranslateType takes in a protobuf type and translates it to a Python primitive type. If there is no translation needed, the input is returned unaltered.
Types ¶
type Enum ¶
type Enum struct {
Members []Member
// contains filtered or unexported fields
}
Enum is a protobuf enum
type EnumVisitor ¶
EnumVisitor is the Visitor for an enum, created by the main visitor. It contains an Enum with all the type data - see types.go.
func (*EnumVisitor) VisitEnum ¶
func (ev *EnumVisitor) VisitEnum(e *proto.Enum)
VisitEnum will set the correct name and visit the elements
func (*EnumVisitor) VisitEnumField ¶
func (ev *EnumVisitor) VisitEnumField(e *proto.EnumField)
VisitEnumField creates an enum field to the member list
type Function ¶
type Function struct {
Comment []string
// contains filtered or unexported fields
}
Function is a function, usually a RPC method in this case
type Member ¶
type Member struct {
Comment []string
// contains filtered or unexported fields
}
Member is a member of a message
type Message ¶
type Message struct {
Types []ProtoType
Members []Member
IsExtend bool
Comment []string
// contains filtered or unexported fields
}
Message represents a ProtoBuf message
type MessageVisitor ¶
type MessageVisitor struct {
ProtoData
// contains filtered or unexported fields
}
MessageVisitor is created by the main visitor. It contains a Message with all the type data - see types.go.
func NewMessageVisitor ¶
func NewMessageVisitor(name string, extend bool, comment *proto.Comment) *MessageVisitor
NewMessageVisitor creates a new message visitor. `extend` indicates if this is an extension, and comment contains the comment attached to this message.
func (*MessageVisitor) VisitNormalField ¶
func (mv *MessageVisitor) VisitNormalField(n *proto.NormalField)
VisitNormalField adds the field to the list. Also makes sure primitive types are properly translated.
func (*MessageVisitor) VisitOneof ¶
func (mv *MessageVisitor) VisitOneof(o *proto.Oneof)
VisitOneof visits a OneOf
func (*MessageVisitor) VisitOneofField ¶
func (mv *MessageVisitor) VisitOneofField(o *proto.OneOfField)
VisitOneofField visits a field in a OneOf
type ProtoData ¶
type ProtoData struct {
Types []ProtoType
// contains filtered or unexported fields
}
ProtoData is the main visitor, which passes off to the other ones. I try to have a visitor per "major" type - message, service, enum, etc. This base Visitor handles the basic stuff.
func (*ProtoData) Parse ¶
Parse will parse the proto file, and dispatch to all the visitors. Error is returned on failure
func (*ProtoData) VisitComment ¶
VisitComment currently does nothing, comments are only handled when attached to messages and their fields.
func (*ProtoData) VisitEnumField ¶
VisitEnumField will panic when called here, as enum fields should be inside enums.
func (*ProtoData) VisitExtensions ¶
func (v *ProtoData) VisitExtensions(e *proto.Extensions)
VisitExtensions is currently not implemented
func (*ProtoData) VisitGroup ¶
VisitGroup is currently not implemented
func (*ProtoData) VisitImport ¶
VisitImport will try to translate a proto import to a python one. Currently it is a bit of a hack.
func (*ProtoData) VisitMapField ¶
VisitMapField is currently not implemented
func (*ProtoData) VisitMessage ¶
VisitMessage will create a MessageVisitor, and dispatch it. The message type is included in protodata.
func (*ProtoData) VisitNormalField ¶
func (v *ProtoData) VisitNormalField(n *proto.NormalField)
VisitNormalField does nothing here, and is implemented in the message visitor.
func (*ProtoData) VisitOneof ¶
VisitOneof will panic when called from here.
func (*ProtoData) VisitOneofField ¶
func (v *ProtoData) VisitOneofField(o *proto.OneOfField)
VisitOneofField will panic when called from here.
func (*ProtoData) VisitOption ¶
VisitOption presently does nothing.
func (*ProtoData) VisitPackage ¶
VisitPackage presently does nothing.
func (*ProtoData) VisitReserved ¶
VisitReserved is currently not implemented.
func (*ProtoData) VisitService ¶
VisitService will create a new service visitor, and dispatch it.
func (*ProtoData) VisitSyntax ¶
VisitSyntax presently does nothing.
type Service ¶
type Service struct {
Types []ProtoType
Functions []Function
Comment []string
// contains filtered or unexported fields
}
Service representts a protobuf service
type ServiceVisitor ¶
type ServiceVisitor struct {
ProtoData
// contains filtered or unexported fields
}
ServiceVisitor will visit a service and extract the types.
func NewServiceVisitor ¶
func NewServiceVisitor(name string, comment *proto.Comment) *ServiceVisitor
NewServiceVisitor will create a new service visitor, from a name and a comment.
func (*ServiceVisitor) VisitRPC ¶
func (sv *ServiceVisitor) VisitRPC(r *proto.RPC)
VisitRPC will visit a RPC, and make sure the function specification is included in the service data definition.