Skip to content

Commit

Permalink
Merge branch 'protobuf-fakeroot' into proto-sort-by-type
Browse files Browse the repository at this point in the history
  • Loading branch information
robshakir committed Feb 13, 2018
2 parents 207ecbe + 19448c8 commit e2ae77e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions ygen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,15 @@ func mappedDefinitions(yangFiles, includePaths []string, cfg *GeneratorConfig) (
errs = append(errs, errors.New("found a nil module in the returned module set"))
continue
}
// Ensure that we do not try and traverse an empty module.
if module.Dir != nil {
for _, e := range module.Dir {
if !excluded[module.Name] {
rootElems = append(rootElems, e)
}
treeElems = append(treeElems, e)

for _, e := range module.Dir {
if !excluded[module.Name] {
rootElems = append(rootElems, e)
}
treeElems = append(treeElems, e)
}
}

if errs != nil {
return nil, errs
}
Expand Down
6 changes: 3 additions & 3 deletions ygen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,21 +339,21 @@ type protoMsgConfig struct {
// the message.
func writeProto3Msg(msg *yangDirectory, msgs map[string]*yangDirectory, state *genState, cfg *protoMsgConfig) (*generatedProto3Message, util.Errors) {
if cfg.nestedMessages {
if !isValidNestedMessage(msg, cfg.compressPaths) {
if !outputNestedMessage(msg, cfg.compressPaths) {
return nil, nil
}
return writeProto3MsgNested(msg, msgs, state, cfg)
}
return writeProto3MsgSingleMsg(msg, msgs, state, cfg)
}

// isValidNestedMessage determines whether the message represented by the supplied
// outputNestedMessage determines whether the message represented by the supplied
// yangDirectory is a message that should be output when nested messages are being
// created. The compressPaths argument specifies whether path compression is enabled.
// Valid messages are those that are direct children of a module, or become a direct
// child when path compression is enabled (i.e., lists that have their parent
// surrounding container removed).
func isValidNestedMessage(msg *yangDirectory, compressPaths bool) bool {
func outputNestedMessage(msg *yangDirectory, compressPaths bool) bool {
// If path compression is enabled, and this entry is a list, then its top-level
// parent will have been removed, therefore this is a valid message. The path
// is 4 elements long since it is of the form
Expand Down

0 comments on commit e2ae77e

Please sign in to comment.