~emersion/drmdb

31b1727b1e79680eab433442fc4c15a316b22142 — Simon Ser 2 years ago f3f1f9b
drmtree: pretty-print type-specific property data
1 files changed, 20 insertions(+), 2 deletions(-)

M drmtree/drmtree.go
M drmtree/drmtree.go => drmtree/drmtree.go +20 -2
@@ 358,12 358,30 @@ func (m *PropertyMap) FormatTree(tf treefmt.Formatter) {
			s += " (" + strings.Join(attrs, ", ") +")"
		}

		// TODO: type-specific property data
		val := prop.Data
		if val == nil {
			val = prop.Value
		}
		tf.Printf("%v = %v", s, val)
		switch val := val.(type) {
		case []PlaneInFormatsModifier:
			tf.Printf("%v", s)
			tfc := tf.NewChild()
			for _, mod := range val {
				tfc.Printf("unknown modifier (0x%X)", mod.Modifier)
				tfcc := tfc.NewChild()
				for _, fmt := range mod.Formats {
					tfcc.Printf("%v", fmt)
				}
			}
		case []drm.Format:
			tf.Printf("%v", s)
			tfc := tf.NewChild()
			for _, fmt := range val {
				tfc.Printf("%v", fmt)
			}
		default:
			tf.Printf("%v = %v", s, val)
		}
	}
}