Skip to content

Commit 3e13b46

Browse files
committed
Fix jsongo import names
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Ic36cff3574ecf197d5ebd10933c780f1cb41e036
1 parent ee53b88 commit 3e13b46

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

‎binapigen/vppapi/parse_json.go‎

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
9090

9191
// parse file CRC
9292
crcNode := rootNode.At(fileVersionCrc)
93-
if crcNode.GetType() == jsongo.TypeValue {
93+
if crcNode.GetType() == jsongo.NodeTypeValue {
9494
file.CRC = crcNode.MustGetString()
9595
} else {
9696
logf("key %q expected to be TypeValue, but is %v", fileVersionCrc, crcNode.GetType())
@@ -100,7 +100,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
100100

101101
// parse file options
102102
optNode := rootNode.Map(fileOptions)
103-
if optNode.GetType() == jsongo.TypeMap {
103+
if optNode.GetType() == jsongo.NodeTypeMap {
104104
file.Options = make(map[string]string)
105105
for _, key := range optNode.GetKeys() {
106106
optionKey := key.(string)
@@ -115,7 +115,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
115115

116116
// parse imports
117117
importsNode := rootNode.Map(fileImports)
118-
if importsNode.GetType() == jsongo.TypeArray {
118+
if importsNode.GetType() == jsongo.NodeTypeArray {
119119
file.Imports = make([]string, 0, importsNode.Len())
120120
uniq := make(map[string]struct{})
121121
for i := 0; i < importsNode.Len(); i++ {
@@ -147,7 +147,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
147147

148148
// parse enum types
149149
enumsNode := rootNode.Map(fileEnums)
150-
if enumsNode.GetType() == jsongo.TypeArray {
150+
if enumsNode.GetType() == jsongo.NodeTypeArray {
151151
file.EnumTypes = make([]EnumType, 0)
152152
for i := 0; i < enumsNode.Len(); i++ {
153153
enum, err := parseEnum(enumsNode.At(i))
@@ -167,7 +167,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
167167

168168
// parse enumflags types
169169
enumflagsNode := rootNode.Map(fileEnumflags)
170-
if enumflagsNode.GetType() == jsongo.TypeArray {
170+
if enumflagsNode.GetType() == jsongo.NodeTypeArray {
171171
file.EnumflagTypes = make([]EnumType, 0)
172172
for i := 0; i < enumflagsNode.Len(); i++ {
173173
enumflag, err := parseEnum(enumflagsNode.At(i))
@@ -187,7 +187,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
187187

188188
// parse alias types
189189
aliasesNode := rootNode.Map(fileAliases)
190-
if aliasesNode.GetType() == jsongo.TypeMap {
190+
if aliasesNode.GetType() == jsongo.NodeTypeMap {
191191
file.AliasTypes = make([]AliasType, 0)
192192
for _, key := range aliasesNode.GetKeys() {
193193
aliasName := key.(string)
@@ -208,7 +208,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
208208

209209
// parse struct types
210210
typesNode := rootNode.Map(fileTypes)
211-
if typesNode.GetType() == jsongo.TypeArray {
211+
if typesNode.GetType() == jsongo.NodeTypeArray {
212212
file.StructTypes = make([]StructType, 0)
213213
for i := 0; i < typesNode.Len(); i++ {
214214
structyp, err := parseStruct(typesNode.At(i))
@@ -228,7 +228,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
228228

229229
// parse union types
230230
unionsNode := rootNode.Map(fileUnions)
231-
if unionsNode.GetType() == jsongo.TypeArray {
231+
if unionsNode.GetType() == jsongo.NodeTypeArray {
232232
file.UnionTypes = make([]UnionType, 0)
233233
for i := 0; i < unionsNode.Len(); i++ {
234234
union, err := parseUnion(unionsNode.At(i))
@@ -248,7 +248,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
248248

249249
// parse messages
250250
messagesNode := rootNode.Map(fileMessages)
251-
if messagesNode.GetType() == jsongo.TypeArray {
251+
if messagesNode.GetType() == jsongo.NodeTypeArray {
252252
file.Messages = make([]Message, messagesNode.Len())
253253
for i := 0; i < messagesNode.Len(); i++ {
254254
msg, err := parseMessage(messagesNode.At(i))
@@ -265,7 +265,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
265265

266266
// parse services
267267
servicesNode := rootNode.Map(fileServices)
268-
if servicesNode.GetType() == jsongo.TypeMap {
268+
if servicesNode.GetType() == jsongo.NodeTypeMap {
269269
file.Service = &Service{
270270
RPCs: make([]RPC, servicesNode.Len()),
271271
}
@@ -285,7 +285,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
285285

286286
// parse counters
287287
countersNode := rootNode.Map(fileCounters)
288-
if countersNode.GetType() == jsongo.TypeArray {
288+
if countersNode.GetType() == jsongo.NodeTypeArray {
289289
file.Counters = make([]Counter, countersNode.Len())
290290
for i := 0; i < countersNode.Len(); i++ {
291291
c, err := parseCounter(countersNode.At(i))
@@ -302,7 +302,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
302302

303303
// parse paths
304304
pathsNode := rootNode.Map(filePaths)
305-
if pathsNode.GetType() == jsongo.TypeArray {
305+
if pathsNode.GetType() == jsongo.NodeTypeArray {
306306
file.Paths = make([]CounterPaths, 0)
307307
for i := 0; i < pathsNode.Len(); i++ {
308308
counterPaths, err := parsePath(pathsNode.At(i))
@@ -322,7 +322,7 @@ func parseApiJsonFile(data []byte) (file *File, err error) {
322322

323323
// parseEnum parses VPP binary API enum object from JSON node
324324
func parseEnum(enumNode *jsongo.Node) (*EnumType, error) {
325-
if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.TypeValue {
325+
if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.NodeTypeValue {
326326
return nil, errors.New("invalid JSON for enum specified")
327327
}
328328

@@ -342,10 +342,10 @@ func parseEnum(enumNode *jsongo.Node) (*EnumType, error) {
342342

343343
// loop through enum entries, skip first (name) and last (enumtype)
344344
for j := 1; j < enumNode.Len()-1; j++ {
345-
if enumNode.At(j).GetType() == jsongo.TypeArray {
345+
if enumNode.At(j).GetType() == jsongo.NodeTypeArray {
346346
entry := enumNode.At(j)
347347

348-
if entry.Len() < 2 || entry.At(0).GetType() != jsongo.TypeValue || entry.At(1).GetType() != jsongo.TypeValue {
348+
if entry.Len() < 2 || entry.At(0).GetType() != jsongo.NodeTypeValue || entry.At(1).GetType() != jsongo.NodeTypeValue {
349349
return nil, errors.New("invalid JSON for enum entry specified")
350350
}
351351

@@ -367,7 +367,7 @@ func parseEnum(enumNode *jsongo.Node) (*EnumType, error) {
367367

368368
// parseUnion parses VPP binary API union object from JSON node
369369
func parseUnion(unionNode *jsongo.Node) (*UnionType, error) {
370-
if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.TypeValue {
370+
if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.NodeTypeValue {
371371
return nil, errors.New("invalid JSON for union specified")
372372
}
373373

@@ -382,7 +382,7 @@ func parseUnion(unionNode *jsongo.Node) (*UnionType, error) {
382382

383383
// loop through union fields, skip first (name)
384384
for j := 1; j < unionNode.Len(); j++ {
385-
if unionNode.At(j).GetType() == jsongo.TypeArray {
385+
if unionNode.At(j).GetType() == jsongo.NodeTypeArray {
386386
fieldNode := unionNode.At(j)
387387

388388
field, err := parseField(fieldNode)
@@ -399,7 +399,7 @@ func parseUnion(unionNode *jsongo.Node) (*UnionType, error) {
399399

400400
// parseStruct parses VPP binary API type object from JSON node
401401
func parseStruct(typeNode *jsongo.Node) (*StructType, error) {
402-
if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.TypeValue {
402+
if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.NodeTypeValue {
403403
return nil, errors.New("invalid JSON for type specified")
404404
}
405405

@@ -414,7 +414,7 @@ func parseStruct(typeNode *jsongo.Node) (*StructType, error) {
414414

415415
// loop through type fields, skip first (name)
416416
for j := 1; j < typeNode.Len(); j++ {
417-
if typeNode.At(j).GetType() == jsongo.TypeArray {
417+
if typeNode.At(j).GetType() == jsongo.NodeTypeArray {
418418
fieldNode := typeNode.At(j)
419419

420420
field, err := parseField(fieldNode)
@@ -431,15 +431,15 @@ func parseStruct(typeNode *jsongo.Node) (*StructType, error) {
431431

432432
// parseAlias parses VPP binary API alias object from JSON node
433433
func parseAlias(aliasName string, aliasNode *jsongo.Node) (*AliasType, error) {
434-
if aliasNode.Len() == 0 || aliasNode.At(aliasType).GetType() != jsongo.TypeValue {
434+
if aliasNode.Len() == 0 || aliasNode.At(aliasType).GetType() != jsongo.NodeTypeValue {
435435
return nil, errors.New("invalid JSON for alias specified")
436436
}
437437

438438
alias := AliasType{
439439
Name: aliasName,
440440
}
441441

442-
if typeNode := aliasNode.At(aliasType); typeNode.GetType() == jsongo.TypeValue {
442+
if typeNode := aliasNode.At(aliasType); typeNode.GetType() == jsongo.NodeTypeValue {
443443
typ, ok := typeNode.Get().(string)
444444
if !ok {
445445
return nil, fmt.Errorf("alias type is %T, not a string", typeNode.Get())
@@ -449,7 +449,7 @@ func parseAlias(aliasName string, aliasNode *jsongo.Node) (*AliasType, error) {
449449
}
450450
}
451451

452-
if lengthNode := aliasNode.At(aliasLength); lengthNode.GetType() == jsongo.TypeValue {
452+
if lengthNode := aliasNode.At(aliasLength); lengthNode.GetType() == jsongo.NodeTypeValue {
453453
length, ok := lengthNode.Get().(float64)
454454
if !ok {
455455
return nil, fmt.Errorf("alias length is %T, not a float64", lengthNode.Get())
@@ -462,7 +462,7 @@ func parseAlias(aliasName string, aliasNode *jsongo.Node) (*AliasType, error) {
462462

463463
// parseMessage parses VPP binary API message object from JSON node
464464
func parseMessage(msgNode *jsongo.Node) (*Message, error) {
465-
if msgNode.Len() < 2 || msgNode.At(0).GetType() != jsongo.TypeValue {
465+
if msgNode.Len() < 2 || msgNode.At(0).GetType() != jsongo.NodeTypeValue {
466466
return nil, errors.New("invalid JSON for message specified")
467467
}
468468

@@ -482,7 +482,7 @@ func parseMessage(msgNode *jsongo.Node) (*Message, error) {
482482
// parse message options
483483
var msgOpts map[string]string
484484
msgOptsNode := msgMeta.Map(messageOptions)
485-
if msgOptsNode.GetType() == jsongo.TypeMap {
485+
if msgOptsNode.GetType() == jsongo.NodeTypeMap {
486486
msgOpts = make(map[string]string)
487487
for _, opt := range msgOptsNode.GetKeys() {
488488
if _, ok := opt.(string); !ok {
@@ -503,7 +503,7 @@ func parseMessage(msgNode *jsongo.Node) (*Message, error) {
503503
// parse message comment
504504
var msgComment string
505505
msgCommentNode := msgMeta.At(messageComment)
506-
if msgCommentNode.GetType() == jsongo.TypeValue {
506+
if msgCommentNode.GetType() == jsongo.NodeTypeValue {
507507
comment, ok := msgCommentNode.Get().(string)
508508
if !ok {
509509
logf("message comment value invalid, expected string")
@@ -521,7 +521,7 @@ func parseMessage(msgNode *jsongo.Node) (*Message, error) {
521521

522522
// loop through message fields, skip first (name) and last (crc)
523523
for j := 1; j < msgNode.Len()-1; j++ {
524-
if msgNode.At(j).GetType() == jsongo.TypeArray {
524+
if msgNode.At(j).GetType() == jsongo.NodeTypeArray {
525525
fieldNode := msgNode.At(j)
526526

527527
field, err := parseField(fieldNode)
@@ -538,7 +538,7 @@ func parseMessage(msgNode *jsongo.Node) (*Message, error) {
538538

539539
// parseField parses VPP binary API object field from JSON node
540540
func parseField(field *jsongo.Node) (*Field, error) {
541-
if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue {
541+
if field.Len() < 2 || field.At(0).GetType() != jsongo.NodeTypeValue || field.At(1).GetType() != jsongo.NodeTypeValue {
542542
return nil, errors.New("invalid JSON for field specified")
543543
}
544544

@@ -559,15 +559,15 @@ func parseField(field *jsongo.Node) (*Field, error) {
559559
// field length (array) or field meta
560560
if field.Len() >= 3 {
561561
switch field.At(2).GetType() {
562-
case jsongo.TypeValue:
562+
case jsongo.NodeTypeValue:
563563
fieldLength, ok := field.At(2).Get().(float64)
564564
if !ok {
565565
return nil, fmt.Errorf("field length is %T, not float64", field.At(2).Get())
566566
}
567567
f.Length = int(fieldLength)
568568
f.Array = true
569569

570-
case jsongo.TypeMap:
570+
case jsongo.NodeTypeMap:
571571
fieldMeta := field.At(2)
572572
if fieldMeta.Len() == 0 {
573573
break
@@ -597,15 +597,15 @@ func parseField(field *jsongo.Node) (*Field, error) {
597597

598598
// parseServiceRPC parses VPP binary API service object from JSON node
599599
func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) {
600-
if rpcNode.Len() == 0 || rpcNode.At(serviceReply).GetType() != jsongo.TypeValue {
600+
if rpcNode.Len() == 0 || rpcNode.At(serviceReply).GetType() != jsongo.NodeTypeValue {
601601
return nil, errors.New("invalid JSON for service RPC specified")
602602
}
603603

604604
rpc := RPC{
605605
Request: rpcName,
606606
}
607607

608-
if replyNode := rpcNode.At(serviceReply); replyNode.GetType() == jsongo.TypeValue {
608+
if replyNode := rpcNode.At(serviceReply); replyNode.GetType() == jsongo.NodeTypeValue {
609609
reply, ok := replyNode.Get().(string)
610610
if !ok {
611611
return nil, fmt.Errorf("service RPC reply is %T, not a string", replyNode.Get())
@@ -614,7 +614,7 @@ func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) {
614614
}
615615

616616
// is stream (dump)
617-
if streamNode := rpcNode.At(serviceStream); streamNode.GetType() == jsongo.TypeValue {
617+
if streamNode := rpcNode.At(serviceStream); streamNode.GetType() == jsongo.NodeTypeValue {
618618
var ok bool
619619
rpc.Stream, ok = streamNode.Get().(bool)
620620
if !ok {
@@ -623,7 +623,7 @@ func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) {
623623
}
624624

625625
// stream message
626-
if streamMsgNode := rpcNode.At(serviceStreamMsg); streamMsgNode.GetType() == jsongo.TypeValue {
626+
if streamMsgNode := rpcNode.At(serviceStreamMsg); streamMsgNode.GetType() == jsongo.NodeTypeValue {
627627
var ok bool
628628
rpc.StreamMsg, ok = streamMsgNode.Get().(string)
629629
if !ok {
@@ -632,7 +632,7 @@ func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) {
632632
}
633633

634634
// events service (event subscription)
635-
if eventsNode := rpcNode.At(serviceEvents); eventsNode.GetType() == jsongo.TypeArray {
635+
if eventsNode := rpcNode.At(serviceEvents); eventsNode.GetType() == jsongo.NodeTypeArray {
636636
for j := 0; j < eventsNode.Len(); j++ {
637637
event := eventsNode.At(j).Get().(string)
638638
rpc.Events = append(rpc.Events, event)
@@ -646,18 +646,18 @@ func parseServiceRPC(rpcName string, rpcNode *jsongo.Node) (*RPC, error) {
646646
func parseCounter(counterNode *jsongo.Node) (*Counter, error) {
647647
// counter name
648648
c := &Counter{}
649-
if counterNameNode := counterNode.At(counterName); counterNameNode.GetType() == jsongo.TypeValue {
649+
if counterNameNode := counterNode.At(counterName); counterNameNode.GetType() == jsongo.NodeTypeValue {
650650
var ok bool
651651
if c.Name, ok = counterNameNode.Get().(string); !ok {
652652
return nil, fmt.Errorf("counter name is %T, not a string", counterNameNode.Get())
653653
}
654654
}
655655

656656
// counter elements
657-
if elementsNode := counterNode.At(elements); elementsNode.GetType() == jsongo.TypeArray {
657+
if elementsNode := counterNode.At(elements); elementsNode.GetType() == jsongo.NodeTypeArray {
658658
c.Elements = make([]Element, elementsNode.Len())
659659
for i := 0; i < elementsNode.Len(); i++ {
660-
if elementNode := elementsNode.At(i); elementNode.GetType() == jsongo.TypeMap {
660+
if elementNode := elementsNode.At(i); elementNode.GetType() == jsongo.NodeTypeMap {
661661
c.Elements[i] = Element{
662662
Name: elementNode.At(elementName).Get().(string),
663663
Severity: elementNode.At(elementSeverity).Get().(string),
@@ -675,17 +675,17 @@ func parseCounter(counterNode *jsongo.Node) (*Counter, error) {
675675
// parseCounter parses VPP binary API service object from JSON node
676676
func parsePath(pathsNode *jsongo.Node) (*[]CounterPaths, error) {
677677
paths := make([]CounterPaths, 0)
678-
if pathsNode.GetType() == jsongo.TypeMap {
678+
if pathsNode.GetType() == jsongo.NodeTypeMap {
679679
// TODO: fix parsing for this case
680680
logf("PATHS NODE IS MAP")
681681
return nil, nil
682-
} /*else if pathsNode.GetType() == jsongo.TypeArray {
682+
} /*else if pathsNode.GetType() == jsongo.NodeTypeArray {
683683
// expected
684684
}*/
685685
NodeLoop:
686686
for i := 0; i < pathsNode.Len(); i++ {
687687
pathNode := pathsNode.At(i)
688-
if pathValues := pathNode; pathValues.GetType() == jsongo.TypeMap {
688+
if pathValues := pathNode; pathValues.GetType() == jsongo.NodeTypeMap {
689689
for j, path := range paths {
690690
if path.Name == pathNode.At(counter).Get().(string) {
691691
paths[j].Paths = append(path.Paths, pathNode.At(counterPath).Get().(string))

0 commit comments

Comments
 (0)