mirror of https://github.com/openXC7/prjxray.git
lib: xc7series: const all the Span<>s
Span<T> can be converted to a Span<const T> but the reverse is not true. Since most of the uses of spans do not allow modification of the data, taking a Span<const T> is more versatile and importantly allows them to be used in const methods. Signed-off-by: Rick Altherr <kc8apf@kc8apf.net>
This commit is contained in:
parent
84d09c833e
commit
b0604362e0
|
|
@ -25,8 +25,8 @@ class BitstreamWriter {
|
||||||
typedef std::array<uint32_t, 6> header_t;
|
typedef std::array<uint32_t, 6> header_t;
|
||||||
typedef std::vector<ConfigurationPacket> packets_t;
|
typedef std::vector<ConfigurationPacket> packets_t;
|
||||||
// Only defined if a packet exists
|
// Only defined if a packet exists
|
||||||
typedef absl::optional<absl::Span<uint32_t>> op_data_t;
|
typedef absl::optional<absl::Span<const uint32_t>> op_data_t;
|
||||||
typedef absl::Span<uint32_t>::iterator data_iterator_t;
|
typedef absl::Span<const uint32_t>::iterator data_iterator_t;
|
||||||
using itr_value_type = uint32_t;
|
using itr_value_type = uint32_t;
|
||||||
|
|
||||||
class packet_iterator
|
class packet_iterator
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace xc7series {
|
||||||
|
|
||||||
class Configuration {
|
class Configuration {
|
||||||
public:
|
public:
|
||||||
using FrameMap = std::map<FrameAddress, absl::Span<uint32_t>>;
|
using FrameMap = std::map<FrameAddress, absl::Span<const uint32_t>>;
|
||||||
|
|
||||||
template <typename Collection>
|
template <typename Collection>
|
||||||
static absl::optional<Configuration> InitWithPackets(
|
static absl::optional<Configuration> InitWithPackets(
|
||||||
|
|
@ -28,7 +28,7 @@ class Configuration {
|
||||||
: part_(part) {
|
: part_(part) {
|
||||||
for (auto& frame : *frames) {
|
for (auto& frame : *frames) {
|
||||||
frames_[frame.first] =
|
frames_[frame.first] =
|
||||||
absl::Span<uint32_t>(frame.second);
|
absl::Span<const uint32_t>(frame.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class ConfigurationPacket {
|
||||||
ConfigurationPacket(unsigned int header_type,
|
ConfigurationPacket(unsigned int header_type,
|
||||||
Opcode opcode,
|
Opcode opcode,
|
||||||
ConfigurationRegister address,
|
ConfigurationRegister address,
|
||||||
const absl::Span<uint32_t>& data)
|
const absl::Span<const uint32_t>& data)
|
||||||
: header_type_(header_type),
|
: header_type_(header_type),
|
||||||
opcode_(opcode),
|
opcode_(opcode),
|
||||||
address_(address),
|
address_(address),
|
||||||
|
|
@ -47,13 +47,13 @@ class ConfigurationPacket {
|
||||||
unsigned int header_type() const { return header_type_; }
|
unsigned int header_type() const { return header_type_; }
|
||||||
const Opcode opcode() const { return opcode_; }
|
const Opcode opcode() const { return opcode_; }
|
||||||
const ConfigurationRegister address() const { return address_; }
|
const ConfigurationRegister address() const { return address_; }
|
||||||
const absl::Span<uint32_t>& data() const { return data_; }
|
const absl::Span<const uint32_t>& data() const { return data_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int header_type_;
|
unsigned int header_type_;
|
||||||
Opcode opcode_;
|
Opcode opcode_;
|
||||||
ConfigurationRegister address_;
|
ConfigurationRegister address_;
|
||||||
absl::Span<uint32_t> data_;
|
absl::Span<const uint32_t> data_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& o, const ConfigurationPacket& packet);
|
std::ostream& operator<<(std::ostream& o, const ConfigurationPacket& packet);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue