Skip to content

Commit

Permalink
replaced ProtoName and ProtoNum with Proto
Browse files Browse the repository at this point in the history
  • Loading branch information
awalterschulze committed Aug 29, 2018
1 parent 5741cac commit c9ef97a
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 1,574 deletions.
8 changes: 4 additions & 4 deletions parser/proto/nomerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
//Latent fields are those fields you have already seen on your walk, but then after seeing a different field you see this field again.
//This typically happens when the protocol buffer user created an object marshaled it and then merged it with another value.
func NoLatentAppendingOrMerging(parser ProtoParser) error {
seen := make(map[uint64]bool)
seen := make(map[string]bool)
for {
if err := parser.Next(); err != nil {
if err == io.EOF {
Expand All @@ -34,11 +34,11 @@ func NoLatentAppendingOrMerging(parser ProtoParser) error {
}
if !parser.IsLeaf() {
if _, err := parser.Int(); err != nil {
if fieldNum, err := parser.Uint(); err == nil {
if _, ok := seen[fieldNum]; ok {
if fieldName, err := parser.String(); err == nil {
if _, ok := seen[fieldName]; ok {
return fmt.Errorf("%s requires merging", parser.Field().GetName())
}
seen[fieldNum] = true
seen[fieldName] = true
} else {
return fmt.Errorf("not an index, field or leaf: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion parser/proto/nomerge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func noMerge(data []byte, desc *descriptor.FileDescriptorSet, pkgName, msgName string) error {
parser, err := katydidproto.NewProtoNumParser(pkgName, msgName, desc)
parser, err := katydidproto.NewProtoParser(pkgName, msgName, desc)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions parser/proto/packed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var packedOutput1 = debug.Nodes{
}

func TestPacked1(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Packed", packedInput1.Description())
p, err := NewProtoParser("prototests", "Packed", packedInput1.Description())
if err != nil {
t.Fatal(err)
}
Expand All @@ -56,7 +56,7 @@ func TestPacked1(t *testing.T) {
}

func TestRandomPacked1(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Packed", packedInput1.Description())
p, err := NewProtoParser("prototests", "Packed", packedInput1.Description())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -95,7 +95,7 @@ var packedOutput2 = debug.Nodes{
}

func TestPacked2(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Packed", packedInput2.Description())
p, err := NewProtoParser("prototests", "Packed", packedInput2.Description())
if err != nil {
t.Fatal(err)
}
Expand All @@ -114,7 +114,7 @@ func TestPacked2(t *testing.T) {
}

func TestRandomPacked2(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Packed", packedInput2.Description())
p, err := NewProtoParser("prototests", "Packed", packedInput2.Description())
if err != nil {
t.Fatal(err)
}
Expand Down
10 changes: 2 additions & 8 deletions parser/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,12 @@ type ProtoParser interface {
Field() *descriptor.FieldDescriptorProto
}

//NewProtoNameParser returns a new protocol buffer parser the specific root message.
//NewProtoParser returns a new protocol buffer parser the specific root message.
//When the value of a field name is requested this parser will return the field name using the String method.
func NewProtoNameParser(rootPackage, rootMessage string, desc *descriptor.FileDescriptorSet) (ProtoParser, error) {
func NewProtoParser(rootPackage, rootMessage string, desc *descriptor.FileDescriptorSet) (ProtoParser, error) {
return newProtoParser(rootPackage, rootMessage, desc, true)
}

//NewProtoNumParser returns a new protocol buffer parser the specific root message.
//When the value of a field name is requested this parser will return the field number using the Uint method.
func NewProtoNumParser(rootPackage, rootMessage string, desc *descriptor.FileDescriptorSet) (ProtoParser, error) {
return newProtoParser(rootPackage, rootMessage, desc, false)
}

func newProtoParser(srcPackage, srcMessage string, desc *descriptor.FileDescriptorSet, fieldNames bool) (*protoParser, error) {
descMap, err := NewDescriptorMap(srcPackage, srcMessage, desc)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions parser/proto/proto3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var proto3Output1 = debug.Nodes{
}

func TestProto31(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Proto3", proto3Input1.Description())
p, err := NewProtoParser("prototests", "Proto3", proto3Input1.Description())
if err != nil {
t.Fatal(err)
}
Expand All @@ -68,7 +68,7 @@ func TestProto31(t *testing.T) {
}

func TestRandomProto31(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Proto3", proto3Input1.Description())
p, err := NewProtoParser("prototests", "Proto3", proto3Input1.Description())
if err != nil {
t.Fatal(err)
}
Expand Down
14 changes: 7 additions & 7 deletions parser/proto/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestDebug(t *testing.T) {
p, err := NewProtoNameParser("debug", "Debug", debug.DebugDescription())
p, err := NewProtoParser("debug", "Debug", debug.DebugDescription())
if err != nil {
t.Fatal(err)
}
Expand All @@ -44,7 +44,7 @@ func TestDebug(t *testing.T) {
}

func TestRandomDebug(t *testing.T) {
p, err := NewProtoNameParser("debug", "Debug", debug.DebugDescription())
p, err := NewProtoParser("debug", "Debug", debug.DebugDescription())
if err != nil {
t.Fatal(err)
}
Expand All @@ -71,7 +71,7 @@ func next(t *testing.T, parser parser.Interface) {
}

func TestSkipRepeated1(t *testing.T) {
p, err := NewProtoNameParser("debug", "Debug", debug.DebugDescription())
p, err := NewProtoParser("debug", "Debug", debug.DebugDescription())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestSkipRepeated1(t *testing.T) {
}

func TestSkipRepeated2(t *testing.T) {
p, err := NewProtoNameParser("debug", "Debug", debug.DebugDescription())
p, err := NewProtoParser("debug", "Debug", debug.DebugDescription())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestSkipRepeated2(t *testing.T) {
}

func TestIndexIsNotAString(t *testing.T) {
p, err := NewProtoNameParser("debug", "Debug", debug.DebugDescription())
p, err := NewProtoParser("debug", "Debug", debug.DebugDescription())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestIndexIsNotAString(t *testing.T) {
}

func TestExtensionsSmallContainer(t *testing.T) {
p, err := NewProtoNameParser("prototests", "Container", prototests.AContainer.Description())
p, err := NewProtoParser("prototests", "Container", prototests.AContainer.Description())
if err != nil {
t.Fatal(err)
}
Expand All @@ -175,7 +175,7 @@ func TestExtensionsSmallContainer(t *testing.T) {
}

func TestExtensionsBigContainer(t *testing.T) {
p, err := NewProtoNameParser("prototests", "BigContainer", prototests.ABigContainer.Description())
p, err := NewProtoParser("prototests", "BigContainer", prototests.ABigContainer.Description())
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 0 additions & 1 deletion relapse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ regenerate:
rmdir util
(cd funcs && make regenerate)
(cd compose && make regenerate)
(cd protonum && make regenerate)

clean:
rm *.txt || true
Expand Down
16 changes: 0 additions & 16 deletions relapse/protonum/Makefile

This file was deleted.

Loading

0 comments on commit c9ef97a

Please sign in to comment.