[ox] Fix Mac build and fix MC to increment field counter on empty string

This commit is contained in:
Gary Talent 2020-05-08 21:32:56 -05:00
parent f91874182e
commit 819959745d
4 changed files with 6 additions and 4 deletions

View File

@ -29,7 +29,6 @@ class FileAddress {
static constexpr auto TypeName = "ox::FileAddress";
static constexpr auto Fields = 2;
protected:
union Data {
static constexpr auto TypeName = "ox::FileAddress::Data";
static constexpr auto Fields = 3;
@ -37,6 +36,8 @@ class FileAddress {
const char *constPath;
uint64_t inode;
};
protected:
FileAddressType m_type = FileAddressType::None;
Data m_data;

View File

@ -225,12 +225,13 @@ Error MetalClawReader::field(const char*, Handler handler) {
template<typename T>
Error MetalClawReader::field(const char* name, ox::Vector<T> *val) {
if (m_unionIdx == -1 || m_unionIdx == m_field) {
// set size of val if the field is present, don't worry about it if not
if (m_fieldPresence.get(m_field)) {
const auto [len, err] = arrayLength(name, false);
oxReturnError(err);
val->resize(len);
return field(name, val->data(), val->size());
}
return field(name, val->data(), val->size());
}
return OxError(0);
}

View File

@ -155,7 +155,7 @@ Error OrganicClawReader::field(const char *key, T *val, std::size_t valLen) {
template<typename T>
Error OrganicClawReader::field(const char *key, ox::Vector<T> *val) {
return field(nullptr, val->data(), val->size());
return field(key, val->data(), val->size());
}
template<typename T>

View File

@ -83,7 +83,7 @@ class OrganicClawWriter {
template<typename T>
Error OrganicClawWriter::field(const char *key, T *val, std::size_t len) {
if (targetValid()) {
OrganicClawWriter w(Json::Value(Json::arrayValue));
OrganicClawWriter w((Json::Value(Json::arrayValue)));
for (std::size_t i = 0; i < len; ++i) {
oxReturnError(w.field("", &val[i]));
}