diff options
author | Ian Cottrell <iancottrell@google.com> | 2015-07-16 18:12:52 +0100 |
---|---|---|
committer | Ian Cottrell <iancottrell@google.com> | 2015-07-17 15:07:13 +0100 |
commit | 8b4156a2477e5ee688c0d8d86c057c281b83d9b6 (patch) | |
tree | 328dff0b81c1d8089b413ed7600445e27650ec7f /service/path | |
parent | 18ac8a5240b9bc6d1876e66e3fbae46ff50d019b (diff) | |
download | gpu-8b4156a2477e5ee688c0d8d86c057c281b83d9b6.tar.gz |
Rip out the ID objects and the resolve functions
Use paths and Get instead in all cases.
Change-Id: I227d1edffa7186f7a3f78818c3b09364d3187a52
Diffstat (limited to 'service/path')
-rw-r--r-- | service/path/blob.go | 68 | ||||
-rw-r--r-- | service/path/image.go | 68 | ||||
-rw-r--r-- | service/path/memory.go | 68 | ||||
-rw-r--r-- | service/path/path_binary.go | 204 | ||||
-rw-r--r-- | service/path/timing.go | 68 |
5 files changed, 476 insertions, 0 deletions
diff --git a/service/path/blob.go b/service/path/blob.go new file mode 100644 index 000000000..d57fed763 --- /dev/null +++ b/service/path/blob.go @@ -0,0 +1,68 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package path + +import ( + "fmt" + + "android.googlesource.com/platform/tools/gpu/binary" +) + +// Blob is a path that refers to a byte array. +type Blob struct { + binary.Generate + ID binary.ID // The blob's unique identifier. +} + +// String returns the string representation of the path. +func (b *Blob) String() string { return b.Path() } + +// Path implements the Path interface. +func (b *Blob) Path() string { + return fmt.Sprintf("Blob(%v)", b.ID) +} + +// Base implements the Path interface, returning nil as this is a root. +func (b *Blob) Base() Path { + return nil +} + +// Clone implements the Path interface, returning a deep-copy of this path. +func (b *Blob) Clone() Path { + return &Blob{ID: b.ID} +} + +// Validate implements the Path interface. +func (b *Blob) Validate() error { + switch { + case b == nil: + return fmt.Errorf("Blob is nil") + case !b.ID.Valid(): + return fmt.Errorf("Blob.ID is invalid") + } + return nil +} + +// FindBlob returns the first Blob found traversing the path p. +// If no Blob was found, then nil is returned. +func FindBlob(p Path) *Blob { + for p != nil { + if p, ok := p.(*Blob); ok { + return p + } + p = p.Base() + } + return nil +} diff --git a/service/path/image.go b/service/path/image.go new file mode 100644 index 000000000..78d11958b --- /dev/null +++ b/service/path/image.go @@ -0,0 +1,68 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package path + +import ( + "fmt" + + "android.googlesource.com/platform/tools/gpu/binary" +) + +// ImageInfo is a path that refers to a image information. +type ImageInfo struct { + binary.Generate + ID binary.ID // The ImageInfo's unique identifier. +} + +// String returns the string representation of the path. +func (i *ImageInfo) String() string { return i.Path() } + +// Path implements the Path interface. +func (i *ImageInfo) Path() string { + return fmt.Sprintf("ImageInfo(%v)", i.ID) +} + +// Base implements the Path interface, returning nil as this is a root. +func (i *ImageInfo) Base() Path { + return nil +} + +// Clone implements the Path interface, returning a deep-copy of this path. +func (i *ImageInfo) Clone() Path { + return &ImageInfo{ID: i.ID} +} + +// Validate implements the Path interface. +func (i *ImageInfo) Validate() error { + switch { + case i == nil: + return fmt.Errorf("ImageInfo is nil") + case !i.ID.Valid(): + return fmt.Errorf("ImageInfo.ID is invalid") + } + return nil +} + +// FindImageInfo returns the first ImageInfo found traversing the path p. +// If no ImageInfo was found, then nil is returned. +func FindImageInfo(p Path) *ImageInfo { + for p != nil { + if p, ok := p.(*ImageInfo); ok { + return p + } + p = p.Base() + } + return nil +} diff --git a/service/path/memory.go b/service/path/memory.go new file mode 100644 index 000000000..1447dbdda --- /dev/null +++ b/service/path/memory.go @@ -0,0 +1,68 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package path + +import ( + "fmt" + + "android.googlesource.com/platform/tools/gpu/binary" +) + +// MemoryInfo is a path that refers to a memory information. +type MemoryInfo struct { + binary.Generate + ID binary.ID // The MemoryInfo's unique identifier. +} + +// String returns the string representation of the path. +func (m *MemoryInfo) String() string { return m.Path() } + +// Path implements the Path interface. +func (m *MemoryInfo) Path() string { + return fmt.Sprintf("MemoryInfo(%v)", m.ID) +} + +// Base implements the Path interface, returning nil as this is a root. +func (m *MemoryInfo) Base() Path { + return nil +} + +// Clone implements the Path interface, returning a deep-copy of this path. +func (m *MemoryInfo) Clone() Path { + return &MemoryInfo{ID: m.ID} +} + +// Validate implements the Path interface. +func (m *MemoryInfo) Validate() error { + switch { + case m == nil: + return fmt.Errorf("MemoryInfo is nil") + case !m.ID.Valid(): + return fmt.Errorf("MemoryInfo.ID is invalid") + } + return nil +} + +// FindMemoryInfo returns the first MemoryInfo found traversing the path p. +// If no MemoryInfo was found, then nil is returned. +func FindMemoryInfo(p Path) *MemoryInfo { + for p != nil { + if p, ok := p.(*MemoryInfo); ok { + return p + } + p = p.Base() + } + return nil +} diff --git a/service/path/path_binary.go b/service/path/path_binary.go index 289c17510..18e685ddc 100644 --- a/service/path/path_binary.go +++ b/service/path/path_binary.go @@ -20,13 +20,17 @@ func init() { Namespace.Add((*Capture)(nil).Class()) Namespace.Add((*Atoms)(nil).Class()) Namespace.Add((*Atom)(nil).Class()) + Namespace.Add((*Blob)(nil).Class()) Namespace.Add((*Device)(nil).Class()) Namespace.Add((*Field)(nil).Class()) Namespace.Add((*Hierarchy)(nil).Class()) + Namespace.Add((*ImageInfo)(nil).Class()) Namespace.Add((*MapIndex)(nil).Class()) + Namespace.Add((*MemoryInfo)(nil).Class()) Namespace.Add((*Report)(nil).Class()) Namespace.Add((*Slice)(nil).Class()) Namespace.Add((*State)(nil).Class()) + Namespace.Add((*TimingInfo)(nil).Class()) } var ( @@ -34,13 +38,17 @@ var ( binaryIDCapture = binary.ID{0x0e, 0x9b, 0xe3, 0x62, 0x7b, 0x67, 0x5b, 0xe0, 0x44, 0x7b, 0x7b, 0x21, 0xa1, 0x50, 0x6d, 0x1b, 0xfb, 0xc7, 0x47, 0xe6} binaryIDAtoms = binary.ID{0x17, 0x6b, 0x7c, 0x08, 0xc2, 0x36, 0x2c, 0xe3, 0x1b, 0x17, 0xd5, 0x3a, 0x0a, 0x98, 0x5b, 0x76, 0xc5, 0x1d, 0x01, 0xa7} binaryIDAtom = binary.ID{0x58, 0x11, 0xbe, 0x6d, 0xfc, 0xe2, 0xe0, 0x12, 0x6c, 0x42, 0x55, 0x2d, 0xf3, 0x5e, 0x11, 0x1a, 0xc1, 0x6b, 0xfe, 0x3b} + binaryIDBlob = binary.ID{0xc4, 0x1a, 0xa9, 0xab, 0x6b, 0x4f, 0x1b, 0xf8, 0x21, 0x87, 0xdc, 0x25, 0x6a, 0x17, 0x4f, 0x6f, 0xc8, 0x1a, 0x61, 0xd7} binaryIDDevice = binary.ID{0xe6, 0xca, 0x6e, 0x0d, 0xa7, 0xca, 0xb0, 0xcb, 0xd5, 0x9e, 0x18, 0xa1, 0xcb, 0x83, 0xc8, 0x93, 0xef, 0xec, 0x12, 0xc0} binaryIDField = binary.ID{0xd2, 0x4f, 0x7f, 0x64, 0xec, 0x81, 0x92, 0x06, 0x6c, 0x25, 0x60, 0xfa, 0x5a, 0x0b, 0x9c, 0x6e, 0x73, 0xf7, 0x4b, 0x4c} binaryIDHierarchy = binary.ID{0x9f, 0x69, 0x5b, 0x87, 0x7f, 0x8b, 0x5c, 0xa3, 0xaa, 0x9d, 0xb4, 0x6e, 0xa9, 0x39, 0x2f, 0xd5, 0x77, 0x92, 0x8a, 0xad} + binaryIDImageInfo = binary.ID{0x25, 0x45, 0x6f, 0xb8, 0x75, 0x8a, 0x10, 0x97, 0x84, 0x5d, 0x5a, 0x6e, 0xa0, 0xe0, 0xe1, 0x2f, 0x2c, 0x8e, 0x55, 0xcb} binaryIDMapIndex = binary.ID{0x0d, 0x46, 0x56, 0xf3, 0x1d, 0xba, 0xf9, 0xd8, 0x5e, 0xcf, 0xcc, 0x0e, 0x84, 0x93, 0x38, 0x5b, 0xbb, 0xd2, 0xec, 0xde} + binaryIDMemoryInfo = binary.ID{0x02, 0x43, 0x5b, 0x41, 0x94, 0xbc, 0x33, 0xbd, 0x3c, 0xc5, 0xaa, 0xc5, 0x2a, 0xa2, 0x51, 0x37, 0x81, 0xcb, 0x59, 0x54} binaryIDReport = binary.ID{0xc3, 0x15, 0x30, 0x12, 0xb4, 0xa6, 0x7e, 0x71, 0x3a, 0xa3, 0xec, 0xb5, 0x93, 0x21, 0xf6, 0x2f, 0xd2, 0xf1, 0x4f, 0xa9} binaryIDSlice = binary.ID{0xd2, 0x2a, 0x0c, 0x1e, 0x91, 0x2e, 0x6b, 0x8d, 0xc1, 0xde, 0x05, 0xf2, 0x17, 0x1e, 0xf4, 0x42, 0x3b, 0x12, 0xd9, 0x76} binaryIDState = binary.ID{0xf1, 0xa4, 0x19, 0x51, 0x01, 0xc4, 0xe2, 0x90, 0xc2, 0xca, 0x28, 0x00, 0x17, 0x08, 0x72, 0xb9, 0x46, 0x3a, 0xd1, 0x7b} + binaryIDTimingInfo = binary.ID{0xad, 0xc7, 0xb9, 0x1b, 0xaa, 0x9c, 0x98, 0xc2, 0x28, 0xb0, 0xdc, 0x3a, 0x6f, 0xdb, 0xa8, 0xff, 0x9c, 0xb6, 0x9a, 0x89} ) type binaryClassArrayIndex struct{} @@ -281,6 +289,55 @@ var schemaAtom = &schema.Class{ }, } +type binaryClassBlob struct{} + +func (*Blob) Class() binary.Class { + return (*binaryClassBlob)(nil) +} +func doEncodeBlob(e binary.Encoder, o *Blob) error { + if err := e.ID(o.ID); err != nil { + return err + } + return nil +} +func doDecodeBlob(d binary.Decoder, o *Blob) error { + if obj, err := d.ID(); err != nil { + return err + } else { + o.ID = binary.ID(obj) + } + return nil +} +func doSkipBlob(d binary.Decoder) error { + if err := d.SkipID(); err != nil { + return err + } + return nil +} +func (*binaryClassBlob) ID() binary.ID { return binaryIDBlob } +func (*binaryClassBlob) New() binary.Object { return &Blob{} } +func (*binaryClassBlob) Encode(e binary.Encoder, obj binary.Object) error { + return doEncodeBlob(e, obj.(*Blob)) +} +func (*binaryClassBlob) Decode(d binary.Decoder) (binary.Object, error) { + obj := &Blob{} + return obj, doDecodeBlob(d, obj) +} +func (*binaryClassBlob) DecodeTo(d binary.Decoder, obj binary.Object) error { + return doDecodeBlob(d, obj.(*Blob)) +} +func (*binaryClassBlob) Skip(d binary.Decoder) error { return doSkipBlob(d) } +func (*binaryClassBlob) Schema() *schema.Class { return schemaBlob } + +var schemaBlob = &schema.Class{ + TypeID: binaryIDBlob, + Package: "path", + Name: "Blob", + Fields: []schema.Field{ + {Declared: "ID", Type: &schema.Primitive{Name: "binary.ID", Method: schema.ID}}, + }, +} + type binaryClassDevice struct{} func (*Device) Class() binary.Class { @@ -452,6 +509,55 @@ var schemaHierarchy = &schema.Class{ }, } +type binaryClassImageInfo struct{} + +func (*ImageInfo) Class() binary.Class { + return (*binaryClassImageInfo)(nil) +} +func doEncodeImageInfo(e binary.Encoder, o *ImageInfo) error { + if err := e.ID(o.ID); err != nil { + return err + } + return nil +} +func doDecodeImageInfo(d binary.Decoder, o *ImageInfo) error { + if obj, err := d.ID(); err != nil { + return err + } else { + o.ID = binary.ID(obj) + } + return nil +} +func doSkipImageInfo(d binary.Decoder) error { + if err := d.SkipID(); err != nil { + return err + } + return nil +} +func (*binaryClassImageInfo) ID() binary.ID { return binaryIDImageInfo } +func (*binaryClassImageInfo) New() binary.Object { return &ImageInfo{} } +func (*binaryClassImageInfo) Encode(e binary.Encoder, obj binary.Object) error { + return doEncodeImageInfo(e, obj.(*ImageInfo)) +} +func (*binaryClassImageInfo) Decode(d binary.Decoder) (binary.Object, error) { + obj := &ImageInfo{} + return obj, doDecodeImageInfo(d, obj) +} +func (*binaryClassImageInfo) DecodeTo(d binary.Decoder, obj binary.Object) error { + return doDecodeImageInfo(d, obj.(*ImageInfo)) +} +func (*binaryClassImageInfo) Skip(d binary.Decoder) error { return doSkipImageInfo(d) } +func (*binaryClassImageInfo) Schema() *schema.Class { return schemaImageInfo } + +var schemaImageInfo = &schema.Class{ + TypeID: binaryIDImageInfo, + Package: "path", + Name: "ImageInfo", + Fields: []schema.Field{ + {Declared: "ID", Type: &schema.Primitive{Name: "binary.ID", Method: schema.ID}}, + }, +} + type binaryClassMapIndex struct{} func (*MapIndex) Class() binary.Class { @@ -532,6 +638,55 @@ var schemaMapIndex = &schema.Class{ }, } +type binaryClassMemoryInfo struct{} + +func (*MemoryInfo) Class() binary.Class { + return (*binaryClassMemoryInfo)(nil) +} +func doEncodeMemoryInfo(e binary.Encoder, o *MemoryInfo) error { + if err := e.ID(o.ID); err != nil { + return err + } + return nil +} +func doDecodeMemoryInfo(d binary.Decoder, o *MemoryInfo) error { + if obj, err := d.ID(); err != nil { + return err + } else { + o.ID = binary.ID(obj) + } + return nil +} +func doSkipMemoryInfo(d binary.Decoder) error { + if err := d.SkipID(); err != nil { + return err + } + return nil +} +func (*binaryClassMemoryInfo) ID() binary.ID { return binaryIDMemoryInfo } +func (*binaryClassMemoryInfo) New() binary.Object { return &MemoryInfo{} } +func (*binaryClassMemoryInfo) Encode(e binary.Encoder, obj binary.Object) error { + return doEncodeMemoryInfo(e, obj.(*MemoryInfo)) +} +func (*binaryClassMemoryInfo) Decode(d binary.Decoder) (binary.Object, error) { + obj := &MemoryInfo{} + return obj, doDecodeMemoryInfo(d, obj) +} +func (*binaryClassMemoryInfo) DecodeTo(d binary.Decoder, obj binary.Object) error { + return doDecodeMemoryInfo(d, obj.(*MemoryInfo)) +} +func (*binaryClassMemoryInfo) Skip(d binary.Decoder) error { return doSkipMemoryInfo(d) } +func (*binaryClassMemoryInfo) Schema() *schema.Class { return schemaMemoryInfo } + +var schemaMemoryInfo = &schema.Class{ + TypeID: binaryIDMemoryInfo, + Package: "path", + Name: "MemoryInfo", + Fields: []schema.Field{ + {Declared: "ID", Type: &schema.Primitive{Name: "binary.ID", Method: schema.ID}}, + }, +} + type binaryClassReport struct{} func (*Report) Class() binary.Class { @@ -720,3 +875,52 @@ var schemaState = &schema.Class{ {Declared: "After", Type: &schema.Pointer{Type: &schema.Struct{Name: "Atom", ID: (*Atom)(nil).Class().ID()}}}, }, } + +type binaryClassTimingInfo struct{} + +func (*TimingInfo) Class() binary.Class { + return (*binaryClassTimingInfo)(nil) +} +func doEncodeTimingInfo(e binary.Encoder, o *TimingInfo) error { + if err := e.ID(o.ID); err != nil { + return err + } + return nil +} +func doDecodeTimingInfo(d binary.Decoder, o *TimingInfo) error { + if obj, err := d.ID(); err != nil { + return err + } else { + o.ID = binary.ID(obj) + } + return nil +} +func doSkipTimingInfo(d binary.Decoder) error { + if err := d.SkipID(); err != nil { + return err + } + return nil +} +func (*binaryClassTimingInfo) ID() binary.ID { return binaryIDTimingInfo } +func (*binaryClassTimingInfo) New() binary.Object { return &TimingInfo{} } +func (*binaryClassTimingInfo) Encode(e binary.Encoder, obj binary.Object) error { + return doEncodeTimingInfo(e, obj.(*TimingInfo)) +} +func (*binaryClassTimingInfo) Decode(d binary.Decoder) (binary.Object, error) { + obj := &TimingInfo{} + return obj, doDecodeTimingInfo(d, obj) +} +func (*binaryClassTimingInfo) DecodeTo(d binary.Decoder, obj binary.Object) error { + return doDecodeTimingInfo(d, obj.(*TimingInfo)) +} +func (*binaryClassTimingInfo) Skip(d binary.Decoder) error { return doSkipTimingInfo(d) } +func (*binaryClassTimingInfo) Schema() *schema.Class { return schemaTimingInfo } + +var schemaTimingInfo = &schema.Class{ + TypeID: binaryIDTimingInfo, + Package: "path", + Name: "TimingInfo", + Fields: []schema.Field{ + {Declared: "ID", Type: &schema.Primitive{Name: "binary.ID", Method: schema.ID}}, + }, +} diff --git a/service/path/timing.go b/service/path/timing.go new file mode 100644 index 000000000..f99a07c72 --- /dev/null +++ b/service/path/timing.go @@ -0,0 +1,68 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package path + +import ( + "fmt" + + "android.googlesource.com/platform/tools/gpu/binary" +) + +// TimingInfo is a path that refers to timing information. +type TimingInfo struct { + binary.Generate + ID binary.ID // The TimingInfo's unique identifier. +} + +// String returns the string representation of the path. +func (t *TimingInfo) String() string { return t.Path() } + +// Path implements the Path interface. +func (t *TimingInfo) Path() string { + return fmt.Sprintf("TimingInfo(%v)", t.ID) +} + +// Base implements the Path interface, returning nil as this is a root. +func (t *TimingInfo) Base() Path { + return nil +} + +// Clone implements the Path interface, returning a deep-copy of this path. +func (t *TimingInfo) Clone() Path { + return &TimingInfo{ID: t.ID} +} + +// Validate implements the Path interface. +func (t *TimingInfo) Validate() error { + switch { + case t == nil: + return fmt.Errorf("TimingInfo is nil") + case !t.ID.Valid(): + return fmt.Errorf("TimingInfo.ID is invalid") + } + return nil +} + +// FindTimingInfo returns the first TimingInfo found traversing the path p. +// If no TimingInfo was found, then nil is returned. +func FindTimingInfo(p Path) *TimingInfo { + for p != nil { + if p, ok := p.(*TimingInfo); ok { + return p + } + p = p.Base() + } + return nil +} |