mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
Prevent shadow with _{{FIELD_NAME}} (#6991)
This commit is contained in:
@@ -261,8 +261,8 @@ struct KeyValue FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const KeyValue *o) const {
|
||||
return *key() < *o->key();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(key()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_key) const {
|
||||
return strcmp(key()->c_str(), _key);
|
||||
}
|
||||
const flatbuffers::String *value() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_VALUE);
|
||||
@@ -338,8 +338,8 @@ struct EnumVal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const EnumVal *o) const {
|
||||
return value() < o->value();
|
||||
}
|
||||
int KeyCompareWithValue(int64_t val) const {
|
||||
return static_cast<int>(value() > val) - static_cast<int>(value() < val);
|
||||
int KeyCompareWithValue(int64_t _value) const {
|
||||
return static_cast<int>(value() > _value) - static_cast<int>(value() < _value);
|
||||
}
|
||||
const reflection::Type *union_type() const {
|
||||
return GetPointer<const reflection::Type *>(VT_UNION_TYPE);
|
||||
@@ -436,8 +436,8 @@ struct Enum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Enum *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>> *values() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::EnumVal>> *>(VT_VALUES);
|
||||
@@ -587,8 +587,8 @@ struct Field FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Field *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const reflection::Type *type() const {
|
||||
return GetPointer<const reflection::Type *>(VT_TYPE);
|
||||
@@ -793,8 +793,8 @@ struct Object FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Object *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const flatbuffers::Vector<flatbuffers::Offset<reflection::Field>> *fields() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::Field>> *>(VT_FIELDS);
|
||||
@@ -945,8 +945,8 @@ struct RPCCall FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const RPCCall *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const reflection::Object *request() const {
|
||||
return GetPointer<const reflection::Object *>(VT_REQUEST);
|
||||
@@ -1061,8 +1061,8 @@ struct Service FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Service *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>> *calls() const {
|
||||
return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<reflection::RPCCall>> *>(VT_CALLS);
|
||||
@@ -1180,8 +1180,8 @@ struct SchemaFile FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const SchemaFile *o) const {
|
||||
return *filename() < *o->filename();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(filename()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_filename) const {
|
||||
return strcmp(filename()->c_str(), _filename);
|
||||
}
|
||||
/// Names of included files, relative to project root.
|
||||
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *included_filenames() const {
|
||||
|
||||
@@ -2033,8 +2033,8 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += " }";
|
||||
|
||||
if (is_string) {
|
||||
code_ += " int KeyCompareWithValue(const char *val) const {";
|
||||
code_ += " return strcmp({{FIELD_NAME}}()->c_str(), val);";
|
||||
code_ += " int KeyCompareWithValue(const char *_{{FIELD_NAME}}) const {";
|
||||
code_ += " return strcmp({{FIELD_NAME}}()->c_str(), _{{FIELD_NAME}});";
|
||||
code_ += " }";
|
||||
} else {
|
||||
FLATBUFFERS_ASSERT(IsScalar(field.value.type.base_type));
|
||||
@@ -2045,10 +2045,10 @@ class CppGenerator : public BaseGenerator {
|
||||
}
|
||||
// Returns {field<val: -1, field==val: 0, field>val: +1}.
|
||||
code_.SetValue("KEY_TYPE", type);
|
||||
code_ += " int KeyCompareWithValue({{KEY_TYPE}} val) const {";
|
||||
code_ += " int KeyCompareWithValue({{KEY_TYPE}} _{{FIELD_NAME}}) const {";
|
||||
code_ +=
|
||||
" return static_cast<int>({{FIELD_NAME}}() > val) - "
|
||||
"static_cast<int>({{FIELD_NAME}}() < val);";
|
||||
" return static_cast<int>({{FIELD_NAME}}() > _{{FIELD_NAME}}) - "
|
||||
"static_cast<int>({{FIELD_NAME}}() < _{{FIELD_NAME}});";
|
||||
code_ += " }";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,8 +694,8 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
|
||||
bool KeyCompareLessThan(const Ability *o) const {
|
||||
return id() < o->id();
|
||||
}
|
||||
int KeyCompareWithValue(uint32_t val) const {
|
||||
return static_cast<int>(id() > val) - static_cast<int>(id() < val);
|
||||
int KeyCompareWithValue(uint32_t _id) const {
|
||||
return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
|
||||
}
|
||||
uint32_t distance() const {
|
||||
return flatbuffers::EndianScalar(distance_);
|
||||
@@ -1017,8 +1017,8 @@ struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Stat *o) const {
|
||||
return count() < o->count();
|
||||
}
|
||||
int KeyCompareWithValue(uint16_t val) const {
|
||||
return static_cast<int>(count() > val) - static_cast<int>(count() < val);
|
||||
int KeyCompareWithValue(uint16_t _count) const {
|
||||
return static_cast<int>(count() > _count) - static_cast<int>(count() < _count);
|
||||
}
|
||||
template<size_t Index>
|
||||
auto get_field() const {
|
||||
@@ -1130,8 +1130,8 @@ struct Referrable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Referrable *o) const {
|
||||
return id() < o->id();
|
||||
}
|
||||
int KeyCompareWithValue(uint64_t val) const {
|
||||
return static_cast<int>(id() > val) - static_cast<int>(id() < val);
|
||||
int KeyCompareWithValue(uint64_t _id) const {
|
||||
return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
|
||||
}
|
||||
template<size_t Index>
|
||||
auto get_field() const {
|
||||
@@ -1327,8 +1327,8 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Monster *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const flatbuffers::Vector<uint8_t> *inventory() const {
|
||||
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
|
||||
@@ -788,8 +788,8 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Ability FLATBUFFERS_FINAL_CLASS {
|
||||
bool KeyCompareLessThan(const Ability *o) const {
|
||||
return id() < o->id();
|
||||
}
|
||||
int KeyCompareWithValue(uint32_t val) const {
|
||||
return static_cast<int>(id() > val) - static_cast<int>(id() < val);
|
||||
int KeyCompareWithValue(uint32_t _id) const {
|
||||
return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
|
||||
}
|
||||
uint32_t distance() const {
|
||||
return flatbuffers::EndianScalar(distance_);
|
||||
@@ -1053,8 +1053,8 @@ struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Stat *o) const {
|
||||
return count() < o->count();
|
||||
}
|
||||
int KeyCompareWithValue(uint16_t val) const {
|
||||
return static_cast<int>(count() > val) - static_cast<int>(count() < val);
|
||||
int KeyCompareWithValue(uint16_t _count) const {
|
||||
return static_cast<int>(count() > _count) - static_cast<int>(count() < _count);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -1143,8 +1143,8 @@ struct Referrable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Referrable *o) const {
|
||||
return id() < o->id();
|
||||
}
|
||||
int KeyCompareWithValue(uint64_t val) const {
|
||||
return static_cast<int>(id() > val) - static_cast<int>(id() < val);
|
||||
int KeyCompareWithValue(uint64_t _id) const {
|
||||
return static_cast<int>(id() > _id) - static_cast<int>(id() < _id);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -1321,8 +1321,8 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool KeyCompareLessThan(const Monster *o) const {
|
||||
return *name() < *o->name();
|
||||
}
|
||||
int KeyCompareWithValue(const char *val) const {
|
||||
return strcmp(name()->c_str(), val);
|
||||
int KeyCompareWithValue(const char *_name) const {
|
||||
return strcmp(name()->c_str(), _name);
|
||||
}
|
||||
const flatbuffers::Vector<uint8_t> *inventory() const {
|
||||
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_INVENTORY);
|
||||
|
||||
Reference in New Issue
Block a user