1
- diff --git a/README.md b/README.md
2
- index 4d22c1e..805adb5 100644
3
- --- a/README.md
4
- +++ b/README.md
5
- @@ -14,6 +14,7 @@ The forms include:
6
-
7
- * tree - a simple tree representation
8
- * types - list understood types extracted from the schema
9
- + * annotate - a template file to annotate the yang modules
10
-
11
- The yang package, and the goyang program, are not complete and are a work in
12
- progress.
13
- diff --git a/annotate.go b/annotate.go
14
- new file mode 100644
15
- index 0000000..286a29c
16
- --- /dev/null
17
- +++ b/annotate.go
1
+ diff -ruN goyang-dir-orig/annotate.go goyang-dir/annotate.go
2
+ --- goyang-dir-orig/annotate.go 1969-12-31 16:00:00.000000000 -0800
3
+ +++ goyang-dir/annotate.go 2022-01-17 23:55:14.303340837 -0800
18
4
@@ -0,0 +1,395 @@
19
5
+ // Copyright 2015 Google Inc.
20
6
+ //
@@ -411,55 +397,111 @@ index 0000000..286a29c
411
397
+ }
412
398
+ }
413
399
+
414
- diff --git a/pkg/yang/entry.go b/pkg/yang/entry.go
415
- index dfd4525..cdf6eb1 100644
416
- --- a/pkg/yang/entry.go
417
- +++ b/pkg/yang/entry.go
418
- @@ -29,6 +29,7 @@ import (
400
+ diff -ruN goyang-dir-orig/pkg/yang/ast.go goyang-dir/pkg/yang/ast.go
401
+ --- goyang-dir-orig/pkg/yang/ast.go 2022-01-17 23:53:09.174875206 -0800
402
+ +++ goyang-dir/pkg/yang/ast.go 2022-01-18 14:03:49.606900799 -0800
403
+ @@ -391,6 +391,11 @@
404
+ descend(name, f.Type)
405
+
406
+ fn = func(s *Statement, v, p reflect.Value) error {
407
+ + if s.Keyword == "yang-version" ||
408
+ + s.Keyword == "import" {
409
+ + // unset for optimization
410
+ + return nil
411
+ + }
412
+ if v.Type() != at {
413
+ panic(fmt.Sprintf("given type %s, need type %s", v.Type(), at))
414
+ }
415
+ diff -ruN goyang-dir-orig/pkg/yang/entry.go goyang-dir/pkg/yang/entry.go
416
+ --- goyang-dir-orig/pkg/yang/entry.go 2022-01-17 23:53:09.174875206 -0800
417
+ +++ goyang-dir/pkg/yang/entry.go 2022-01-18 15:32:08.428212781 -0800
418
+ @@ -29,6 +29,7 @@
419
419
"sort"
420
420
"strconv"
421
421
"strings"
422
422
+ "sync"
423
423
424
424
"github.com/openconfig/goyang/pkg/indent"
425
425
)
426
- @@ -80,6 +81,7 @@ type Entry struct {
426
+ @@ -79,8 +80,9 @@
427
+ Mandatory TriState `json:",omitempty"` // whether this entry is mandatory in the tree
427
428
428
429
// Fields associated with directory nodes
429
- Dir map[string]*Entry `json:",omitempty"`
430
- + DirOKeys []string // Ordered Keys list in Dir
431
- Key string `json:",omitempty"` // Optional key name for lists (i.e., maps)
430
+ - Dir map[string]*Entry `json:",omitempty"`
431
+ - Key string `json:",omitempty"` // Optional key name for lists (i.e., maps)
432
+ + Dir map[string]*Entry `json:",omitempty"`
433
+ + DirOKeys []string // Ordered Keys list in Dir
434
+ + Key string `json:",omitempty"` // Optional key name for lists (i.e., maps)
432
435
433
436
// Fields associated with leaf nodes
434
- @@ -115,6 +117,11 @@ type Entry struct {
437
+ Type *YangType `json:",omitempty"`
438
+ @@ -115,6 +117,11 @@
435
439
// the augmenting entity per RFC6020 Section 7.15.2. The namespace
436
440
// of the Entry should be accessed using the Namespace function.
437
441
namespace *Value
438
442
+
439
443
+ ChildSchemaCache map[reflect.StructTag]*Entry `json:"-"`
440
- + ChildSchemaMutex sync.RWMutex `json:"-"`
441
- +
444
+ + ChildSchemaMutex sync.RWMutex `json:"-"`
445
+ +
442
446
+ IsSchemaValidated bool `json:"-"`
443
447
}
444
448
445
449
// An RPCEntry contains information related to an RPC Node.
446
- @@ -264,6 +271,7 @@ func newDirectory(n Node) *Entry {
450
+ @@ -262,11 +269,12 @@
451
+ // newDirectory returns an empty directory Entry.
452
+ func newDirectory(n Node) *Entry {
447
453
return &Entry{
448
- Kind: DirectoryEntry,
449
- Dir: make(map[string]*Entry),
454
+ - Kind: DirectoryEntry,
455
+ - Dir: make(map[string]*Entry),
456
+ - Node: n,
457
+ - Name: n.NName(),
458
+ - Extra: map[string][]interface{}{},
459
+ + Kind: DirectoryEntry,
460
+ + Dir: make(map[string]*Entry),
450
461
+ DirOKeys: make([]string, 0),
451
- Node: n,
452
- Name: n.NName(),
453
- Extra: map[string][]interface{}{},
454
- @@ -360,6 +368,7 @@ func (e *Entry) add(key string, value *Entry) *Entry {
462
+ + Node: n,
463
+ + Name: n.NName(),
464
+ + Extra: map[string][]interface{}{},
465
+ }
466
+ }
467
+
468
+ @@ -360,6 +368,7 @@
455
469
return e
456
470
}
457
471
e.Dir[key] = value
458
472
+ e.DirOKeys = append(e.DirOKeys, key)
459
473
return e
460
474
}
461
475
462
- @@ -999,7 +1008,7 @@ func (e *Entry) ApplyDeviate() []error {
476
+ @@ -540,6 +549,7 @@
477
+ e.Config, err = tristateValue(s.Config)
478
+ e.addError(err)
479
+ e.Prefix = getRootPrefix(e)
480
+ + e.Description = ""
481
+ return e
482
+ case *LeafList:
483
+ // Create the equivalent leaf element that we are a list of.
484
+ @@ -567,6 +577,7 @@
485
+ OrderedBy: s.OrderedBy,
486
+ }
487
+ e.Prefix = getRootPrefix(e)
488
+ + e.Description = ""
489
+ return e
490
+ case *Uses:
491
+ g := FindGrouping(s, s.Name, map[string]bool{})
492
+ @@ -932,6 +943,11 @@
493
+ e.Prefix = getRootPrefix(e)
494
+ }
495
+
496
+ + // unset for optimization
497
+ + e.Description = ""
498
+ + e.Extra = nil
499
+ + e.Augmented = nil
500
+ +
501
+ return e
502
+ }
503
+
504
+ @@ -999,7 +1015,7 @@
463
505
}
464
506
465
507
if devSpec.Default != "" {
@@ -468,53 +510,53 @@ index dfd4525..cdf6eb1 100644
468
510
}
469
511
470
512
if devSpec.Mandatory != TSUnset {
471
- @@ -1082,6 +1091 ,7 @@ func (e *Entry) FixChoice() {
513
+ @@ -1082,6 +1098 ,7 @@
472
514
}
473
515
ce.Parent = ne
474
516
e.Dir[k] = ne
475
517
+ e.DirOKeys = append(e.DirOKeys, k)
476
518
}
477
519
}
478
520
}
479
- @@ -1252,6 +1262 ,14 @@ func (e *Entry) shallowDup() *Entry {
521
+ @@ -1252,6 +1269 ,14 @@
480
522
// copied we will have to explicitly uncopy them.
481
523
ne := *e
482
524
483
- + //Copy the ordered Dir keys to new entry
484
- + if len(e.DirOKeys) > 0 {
485
- + ne.DirOKeys = make([]string, 0)
486
- + for _, key := range e.DirOKeys {
487
- + ne.DirOKeys = append(ne.DirOKeys, key)
488
- + }
525
+ + //Copy the ordered Dir keys to new entry
526
+ + if len(e.DirOKeys) > 0 {
527
+ + ne.DirOKeys = make([]string, 0)
528
+ + for _, key := range e.DirOKeys {
529
+ + ne.DirOKeys = append(ne.DirOKeys, key)
530
+ + }
489
531
+ }
490
532
+
491
533
// Now only copy direct children, clear their Dir, and fix up
492
534
// Parent pointers.
493
535
if e.Dir != nil {
494
- @@ -1275,6 +1293 ,14 @@ func (e *Entry) dup() *Entry {
536
+ @@ -1275,6 +1300 ,14 @@
495
537
// to do that.
496
538
ne := *e
497
539
498
- + //Copy the ordered Dir keys to new entry
499
- + if len(e.DirOKeys) > 0 {
500
- + ne.DirOKeys = make([]string, 0)
501
- + for _, key := range e.DirOKeys {
502
- + ne.DirOKeys = append(ne.DirOKeys, key)
503
- + }
504
- + }
540
+ + //Copy the ordered Dir keys to new entry
541
+ + if len(e.DirOKeys) > 0 {
542
+ + ne.DirOKeys = make([]string, 0)
543
+ + for _, key := range e.DirOKeys {
544
+ + ne.DirOKeys = append(ne.DirOKeys, key)
545
+ + }
546
+ + }
505
547
+
506
548
// Now recurse down to all of our children, fixing up Parent
507
549
// pointers as we go.
508
550
if e.Dir != nil {
509
- @@ -1310,6 +1336 ,7 @@ func (e *Entry) merge(prefix *Value, namespace *Value, oe *Entry) {
551
+ @@ -1310,6 +1343 ,7 @@
510
552
v.Parent = e
511
553
v.Exts = append(v.Exts, oe.Exts...)
512
554
e.Dir[k] = v
513
555
+ e.DirOKeys = append(e.DirOKeys, k)
514
556
}
515
557
}
516
558
}
517
- @@ -1371,8 +1398 ,8 @@ func (s sortedErrors) Less(i, j int) bool {
559
+ @@ -1371,8 +1405 ,8 @@
518
560
}
519
561
return nless(fi[x], fj[x])
520
562
}
@@ -525,10 +567,9 @@ index dfd4525..cdf6eb1 100644
525
567
case -1:
526
568
return true
527
569
case 1:
528
- diff --git a/pkg/yang/types.go b/pkg/yang/types.go
529
- index 307610a..ffb59a6 100644
530
- --- a/pkg/yang/types.go
531
- +++ b/pkg/yang/types.go
570
+ diff -ruN goyang-dir-orig/pkg/yang/types.go goyang-dir/pkg/yang/types.go
571
+ --- goyang-dir-orig/pkg/yang/types.go 2022-01-17 23:53:09.174875206 -0800
572
+ +++ goyang-dir/pkg/yang/types.go 2022-01-17 23:55:14.303340837 -0800
532
573
@@ -12,6 +12,9 @@
533
574
// See the License for the specific language governing permissions and
534
575
// limitations under the License.
@@ -539,7 +580,7 @@ index 307610a..ffb59a6 100644
539
580
package yang
540
581
541
582
// This file implements the functions relating to types and typedefs.
542
- @@ -69,6 +72,12 @@ func (d *typeDictionary) findExternal(n Node, prefix, name string) (*Typedef, er
583
+ @@ -69,6 +72,12 @@
543
584
}
544
585
if td := d.find(root, name); td != nil {
545
586
return td, nil
@@ -552,19 +593,29 @@ index 307610a..ffb59a6 100644
552
593
}
553
594
if prefix != "" {
554
595
name = prefix + ":" + name
555
- diff --git a/yang.go b/yang.go
556
- index 2480a4e..515d1b3 100644
557
- --- a/yang.go
558
- +++ b/yang.go
559
- @@ -58,6 +58,7 @@ import (
596
+ diff -ruN goyang-dir-orig/README.md goyang-dir/README.md
597
+ --- goyang-dir-orig/README.md 2022-01-17 23:53:09.174875206 -0800
598
+ +++ goyang-dir/README.md 2022-01-17 23:55:14.303340837 -0800
599
+ @@ -14,6 +14,7 @@
600
+
601
+ * tree - a simple tree representation
602
+ * types - list understood types extracted from the schema
603
+ + * annotate - a template file to annotate the yang modules
604
+
605
+ The yang package, and the goyang program, are not complete and are a work in
606
+ progress.
607
+ diff -ruN goyang-dir-orig/yang.go goyang-dir/yang.go
608
+ --- goyang-dir-orig/yang.go 2022-01-17 23:53:09.174875206 -0800
609
+ +++ goyang-dir/yang.go 2022-01-17 23:55:14.303340837 -0800
610
+ @@ -58,6 +58,7 @@
560
611
type formatter struct {
561
612
name string
562
613
f func(io.Writer, []*yang.Entry)
563
614
+ utilf func([]string, map[string]*yang.Module)
564
615
help string
565
616
flags *getopt.Set
566
617
}
567
- @@ -208,5 +209,8 @@ Formats:
618
+ @@ -208,5 +209,8 @@
568
619
entries[x] = yang.ToEntry(mods[n])
569
620
}
570
621
0 commit comments