Skip to content

Commit

Permalink
rename NullType to AnyType
Browse files Browse the repository at this point in the history
  • Loading branch information
tenfyzhong committed Jan 7, 2024
1 parent 3b686f9 commit f4f98ec
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (p GoParser) nameType(name string) Type {
case "uintptr":
// TODO
case "any":
return NullVal
return AnyVal
}
return &StructLikeType{
Name: name,
Expand Down
2 changes: 1 addition & 1 deletion go_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ type SampleMessage struct {
{
Field: "details",
Type: &ArrayType{
ChildType: NullVal,
ChildType: AnyVal,
},
Index: 2,
},
Expand Down
8 changes: 4 additions & 4 deletions json_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (p *JsonParser) parseStructs(root *Node) *Member {
}

switch root.Type {
case NullVal,
case AnyVal,
BoolVal,
Float64Val,
StringVal,
Expand All @@ -110,7 +110,7 @@ func (p *JsonParser) parseStructs(root *Node) *Member {
child := p.parseStructs(root.Children[0])
if child == nil {
member.Type = &ArrayType{
ChildType: NullVal,
ChildType: AnyVal,
}
} else {
member.Type = &ArrayType{
Expand Down Expand Up @@ -170,7 +170,7 @@ func (p *JsonParser) parseNode(tag string, v interface{}) *Node {
Field: tag,
}
if v == nil {
node.Type = NullVal
node.Type = AnyVal
}

switch c := v.(type) {
Expand Down Expand Up @@ -200,7 +200,7 @@ func (p *JsonParser) parseNode(tag string, v interface{}) *Node {
node.Children = append(node.Children, child)
} else {
child := &Node{
Type: NullVal,
Type: AnyVal,
}
node.Children = append(node.Children, child)
}
Expand Down
6 changes: 3 additions & 3 deletions json_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestJsonParser_Parse(t *testing.T) {
},
{
Field: "b",
Type: NullVal,
Type: AnyVal,
Index: 2,
GoTag: []string{`json:"b,omitempty"`},
},
Expand Down Expand Up @@ -558,7 +558,7 @@ func TestJsonParser_Parse(t *testing.T) {
{
Field: "hh",
Type: &ArrayType{
ChildType: NullVal,
ChildType: AnyVal,
},
Index: 8,
GoTag: []string{`json:"hh,omitempty"`},
Expand All @@ -567,7 +567,7 @@ func TestJsonParser_Parse(t *testing.T) {
Field: "jj",
Type: &ArrayType{
ChildType: &ArrayType{
ChildType: NullVal,
ChildType: AnyVal,
},
},
Index: 9,
Expand Down
2 changes: 1 addition & 1 deletion node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestNode_Fingerprint(t *testing.T) {
init: func(t *testing.T) *Node {
return &Node{
Field: "root",
Type: NullVal,
Type: AnyVal,
}
},
want1: "null",
Expand Down
2 changes: 1 addition & 1 deletion proto_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (v *ProtoVisitor) type2Type(str string) Type {
case "bytes":
return BinaryVal
case "google.protobuf.Any":
return NullVal
return AnyVal
}
return &StructLikeType{
Name: str,
Expand Down
2 changes: 1 addition & 1 deletion proto_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ message ErrorStatus {
{
Field: "details",
Type: &ArrayType{
ChildType: NullVal,
ChildType: AnyVal,
},
Index: 2,
},
Expand Down
16 changes: 8 additions & 8 deletions type.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
)

var (
NullVal Type = &NullType{}
AnyVal Type = &AnyType{}
BoolVal Type = &BoolType{}
Float32Val Type = &Float32Type{}
Float64Val Type = &Float64Type{}
Expand Down Expand Up @@ -44,14 +44,14 @@ type Type interface {
IsBasicType() bool
}

type NullType struct{}
type AnyType struct{}

func (v NullType) Json() string { return "null" }
func (v NullType) Go() string { return "any" }
func (v NullType) Proto() string { return "google.protobuf.Any" }
func (v NullType) Thrift() string { return "binary" }
func (v NullType) Value() string { return "nil" }
func (v NullType) IsBasicType() bool { return false }
func (v AnyType) Json() string { return "null" }
func (v AnyType) Go() string { return "any" }
func (v AnyType) Proto() string { return "google.protobuf.Any" }
func (v AnyType) Thrift() string { return "binary" }
func (v AnyType) Value() string { return "nil" }
func (v AnyType) IsBasicType() bool { return false }

type BoolType struct {
V bool
Expand Down

0 comments on commit f4f98ec

Please sign in to comment.