Skip to content

Commit 0693dbe

Browse files
QMP API generated isNullable cleanup
1 parent 8f6d628 commit 0693dbe

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

internal/qmp-gen/templates/alternate

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ type {{ $basename }} interface {
2626

2727
{{- if $type.NullType }}
2828
// Special case handling of JSON null type
29-
type is{{ $subname }}Nullable interface {
30-
isNull() bool
31-
}
32-
type {{ $subname }} struct {
33-
isNotNull bool
34-
}
35-
func (n {{ $subname }}) isNull() bool {
36-
return !n.isNotNull
37-
}
29+
type {{ $subname }} struct {}
30+
func ({{ $subname }}) isNull() bool { return true }
3831
{{- else }}
3932
// {{ $subname }} is an implementation of {{ $basename }}
4033
type {{ $subname }} {{ $type.Go }}

internal/qmp-gen/templates/main

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"fmt"
2222
)
2323

24+
type isNullable interface {
25+
isNull() bool
26+
}
27+
2428
{{ range . }}
2529
{{ render . }}
2630
{{ end }}

qmp/raw/autogen.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"fmt"
2222
)
2323

24+
type isNullable interface {
25+
isNull() bool
26+
}
27+
2428
// ACPIOSTInfo -> ACPIOSTInfo (struct)
2529

2630
// ACPIOSTInfo implements the "ACPIOSTInfo" QMP API type.
@@ -3123,16 +3127,9 @@ func (BlockdevOptionsVvfat) isBlockdevRefOrNull() {}
31233127
func (BlockdevOptionsVxhs) isBlockdevRefOrNull() {}
31243128

31253129
// Special case handling of JSON null type
3126-
type isBlockdevRefOrNullNullNullable interface {
3127-
isNull() bool
3128-
}
3129-
type BlockdevRefOrNullNull struct {
3130-
isNotNull bool
3131-
}
3130+
type BlockdevRefOrNullNull struct{}
31323131

3133-
func (n BlockdevRefOrNullNull) isNull() bool {
3134-
return !n.isNotNull
3135-
}
3132+
func (BlockdevRefOrNullNull) isNull() bool { return true }
31363133
func (BlockdevRefOrNullNull) isBlockdevRefOrNull() {}
31373134

31383135
// BlockdevRefOrNullReference is an implementation of BlockdevRefOrNull
@@ -9729,16 +9726,9 @@ type StrOrNull interface {
97299726
}
97309727

97319728
// Special case handling of JSON null type
9732-
type isStrOrNullNNullable interface {
9733-
isNull() bool
9734-
}
9735-
type StrOrNullN struct {
9736-
isNotNull bool
9737-
}
9729+
type StrOrNullN struct{}
97389730

9739-
func (n StrOrNullN) isNull() bool {
9740-
return !n.isNotNull
9741-
}
9731+
func (StrOrNullN) isNull() bool { return true }
97429732
func (StrOrNullN) isStrOrNull() {}
97439733

97449734
// StrOrNullS is an implementation of StrOrNull

0 commit comments

Comments
 (0)