func (v *ProtoData) VisitReserved(r *proto.Reserved) {
}
VisitReserved is currently not implemented.
package protostub
import (
	"io"
	"strings"
	"github.com/emicklei/proto"
)
type ProtoData struct {
	Types []ProtoType
	imports map[string]bool
	r     io.Reader
	depth int
}
func New(r io.Reader) *ProtoData {
	return &ProtoData{
		Types:   make([]ProtoType, 0),
		depth:   0,
		imports: make(map[string]bool),
		r:       r,
	}
}
func (v *ProtoData) Parse() error {
	p := proto.NewParser(v.r)
	pr, err := p.Parse()
	if err != nil {
		return err
	}
	for _, i := range pr.Elements {
		i.Accept(v)
	}
	return nil
}
var typeMap = map[string]string{
	"int32":    "int",
	"int64":    "int",
	"double":   "float",
	"uint32":   "int",
	"uint64":   "int",
	"sint32":   "int",
	"sint64":   "int",
	"fixed32":  "int",
	"fixed64":  "int",
	"sfixed32": "int",
	"sfixed64": "int",
	"bytes":    "str",
}
func TranslateType(t string) string {
	if val, ok := typeMap[t]; ok {
		return val
	}
	split := strings.Split(t, ".")
	return split[len(split)-1]
}
func (v *ProtoData) VisitMessage(m *proto.Message) {
	if m.Comment == nil {
		m.Comment = &proto.Comment{Lines: make([]string, 0)}
	}
	mv := NewMessageVisitor(m.Name, m.IsExtend, m.Comment)
	for _, i := range m.Elements {
		i.Accept(mv)
	}
	v.Types = append(v.Types, mv.message)
	mv.message.Types = mv.Types
}
func (v *ProtoData) VisitSyntax(s *proto.Syntax) {
}
func (v *ProtoData) VisitPackage(p *proto.Package) {
}
func (v *ProtoData) VisitOption(o *proto.Option) {
}
func (v *ProtoData) VisitImport(i *proto.Import) {
	split := strings.Split(i.Filename, "/")
	path := strings.Join(split[:len(split)-1], ".")
	if _, ok := v.imports[path]; ok {
		return
	}
	v.imports[path] = true
}
func (v *ProtoData) VisitNormalField(n *proto.NormalField) {
}
func (v *ProtoData) VisitEnumField(e *proto.EnumField) {
	panic("Cannot visit enum field")
}
func (v *ProtoData) VisitEnum(e *proto.Enum) {
	ev := NewEnumVisitor()
	e.Accept(ev)
	v.Types = append(v.Types, &ev.Enum)
}
func (v *ProtoData) VisitComment(c *proto.Comment) {
}
func (v *ProtoData) VisitOneof(o *proto.Oneof) {
	panic("Cannot visit oneof")
}
func (v *ProtoData) VisitOneofField(o *proto.OneOfField) {
	panic("Cannot visit oneof field")
}