(list *C.TF_DeviceList)
| 81 | } |
| 82 | |
| 83 | func deviceSliceFromDeviceList(list *C.TF_DeviceList) ([]Device, error) { |
| 84 | var devices []Device |
| 85 | status := newStatus() |
| 86 | |
| 87 | for i := 0; i < int(C.TF_DeviceListCount(list)); i++ { |
| 88 | name := C.TF_DeviceListName(list, C.int(i), status.c) |
| 89 | if err := status.Err(); err != nil { |
| 90 | return nil, fmt.Errorf("DeviceListName(index=%d) failed: %v", i, err) |
| 91 | } |
| 92 | |
| 93 | deviceType := C.TF_DeviceListType(list, C.int(i), status.c) |
| 94 | if err := status.Err(); err != nil { |
| 95 | return nil, fmt.Errorf("DeviceListType(index=%d) failed: %v", i, err) |
| 96 | } |
| 97 | |
| 98 | memoryLimitBytes := C.TF_DeviceListMemoryBytes(list, C.int(i), status.c) |
| 99 | if err := status.Err(); err != nil { |
| 100 | return nil, fmt.Errorf("DeviceListMemoryBytes(index=%d) failed: %v", i, err) |
| 101 | } |
| 102 | |
| 103 | device := Device{ |
| 104 | Name: C.GoString(name), |
| 105 | Type: C.GoString(deviceType), |
| 106 | MemoryLimitBytes: int64(memoryLimitBytes), |
| 107 | } |
| 108 | |
| 109 | devices = append(devices, device) |
| 110 | } |
| 111 | |
| 112 | return devices, nil |
| 113 | } |
| 114 | |
| 115 | // ListDevices returns the list of devices associated with a Session. |
| 116 | func (s *Session) ListDevices() ([]Device, error) { |
no test coverage detected