Skip to content

Commit

Permalink
Fixes for #26, ignore !comment, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bbredesen committed Mar 9, 2023
1 parent a2ae182 commit 0ff7bb7
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 18 deletions.
7 changes: 0 additions & 7 deletions def/base_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ func ReadBaseTypeExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr
entry := NewOrUpdateBaseTypeFromJSON(key.String(), exVal, tr, vr)
tr[key.String()] = entry

// exVal.Get("constants").ForEach(func(ck, cv gjson.Result) bool {
// newVal := NewConstantValue(ck.String(), cv.String(), key.String())

// vr[newVal.RegistryName()] = newVal
// return true
// })

return true
})

Expand Down
2 changes: 1 addition & 1 deletion def/command_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func NewCommandParamFromXML(elt *xmlquery.Node, forCommand *commandType) *comman

func ReadCommandExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry) {
exceptions.Get("command").ForEach(func(key, exVal gjson.Result) bool {
if key.String() == "comment" {
if key.String() == "!comment" {
return true
} // Ignore comments

Expand Down
4 changes: 0 additions & 4 deletions def/external_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ func NewOrUpdateExternalTypeFromJSON(key string, exception gjson.Result, tr Type
existing := tr[key]
var updatedEntry *externalType

if key == "!comment" {
return nil
}

if existing == nil {
logrus.WithField("registry type", key).Info("no existing registry entry for external type")
updatedEntry = &externalType{}
Expand Down
4 changes: 3 additions & 1 deletion def/handle_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewHandleTypeFromXML(node *xmlquery.Node) TypeDefiner {

func ReadHandleExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr ValueRegistry) {
exceptions.Get("handle").ForEach(func(key, exVal gjson.Result) bool {
if key.String() == "comment" {
if key.String() == "!comment" {
return true
} // Ignore comments

Expand Down Expand Up @@ -101,5 +101,7 @@ func NewHandleTypeFromJSON(key, json gjson.Result) TypeDefiner {
rval.publicName = json.Get("publicName").String()
rval.underlyingTypeName = json.Get("underlyingType").String()

rval.comment = json.Get("comment").String()

return &rval
}
4 changes: 0 additions & 4 deletions def/struct_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,7 @@ func ReadStructExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr V
}

entry := NewOrUpdateStructTypeFromJSON(key, exVal, existing)
// if entry == nil {
// delete(tr, key.String())
// } else {
tr[key.String()] = entry
// }

return true
})
Expand Down
1 change: 0 additions & 1 deletion def/union_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func ReadUnionExceptionsFromJSON(exceptions gjson.Result, tr TypeRegistry, vr Va
} // Ignore comments

UpdateUnionTypeFromJSON(key, exVal, tr[key.String()].(*unionType))
// tr[key.String()] = entry

return true
})
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func main() {
platforms[plat.Name()] = plat
}
jsonDoc.Get("platform").ForEach(func(key, value gjson.Result) bool {
if key.String() == "!comment" {
return true
}
r := feat.NewOrUpdatePlatformFromJSON(key.String(), value, platforms[key.String()])
platforms[r.Name()] = r
return true
Expand Down

0 comments on commit 0ff7bb7

Please sign in to comment.