Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/26 #28

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/internal_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func (t *internalType) Resolve(tr TypeRegistry, vr ValueRegistry) *IncludeSet {
func (t *internalType) PrintPublicDeclaration(w io.Writer) {
t.PrintDocLink(w)

if t.comment != "" {
fmt.Fprintln(w, "// ", t.comment)
}

if t.IsAlias() {
fmt.Fprintf(w, "type %s = %s\n", t.PublicName(), t.resolvedAliasType.PublicName())
} else {
Expand Down
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
10 changes: 6 additions & 4 deletions exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

"VK_USE_64_BIT_PTR_DEFINES": {
"constantValue": "unsafe.Sizeof(uintptr(0))",
"comment": "Included for completeness, but this value is only used in a macro to determine how VK_NULL_HANDLE should be defined in C, based on architecture and compiler."
"!comment": "Included for completeness, but this value is only used in a macro to determine how VK_NULL_HANDLE should be defined in C, based on architecture and compiler."
}

},

"handle": {
"VK_DEFINE_HANDLE": { "publicName": "handle", "underlyingType": "uintptr_t",
"VK_DEFINE_HANDLE": {
"publicName": "handle",
"underlyingType": "uintptr_t",
"constants": {
"VK_NULL_HANDLE" : "0"
}
Expand All @@ -50,7 +52,7 @@
},
"VK_USE_64_BIT_PTR_DEFINES": {
"publicName": "!ignore",
"comment": "This and several following entries are defined as types in the spec, though they're really values. !ignore allows this type to be created for resolving the feature set, but it will not be output to the generated code."
"!comment": "This and several following entries are defined as types in the spec, though they're really values. !ignore allows this type to be created for resolving the feature set, but it will not be output to the generated code."
},
"VK_NULL_HANDLE": {
"publicName": "!ignore"
Expand Down Expand Up @@ -128,7 +130,7 @@

"external" : {
"int8_t": { "go:type": "int8", "primitive": true,
"comment": "Primitive indicates a direct replacement? Necessary or not?" },
"!comment": "Primitive indicates a direct replacement? Necessary or not?" },
"uint8_t": { "go:type": "uint8", "primitive": true },
"int16_t": { "go:type": "int16", "primitive": true },
"uint16_t": { "go:type": "uint16", "primitive": 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