Commit c3807fa3 authored by Max Galkin's avatar Max Galkin Committed by Wouter van Oortmerssen

Fix for VS 2015 stricter warnings about "shadowed" names.

This change renames a few variables to fix the build in VS 2015.

VS 2015 new warnings:
http://blogs.msdn.com/b/vcblog/archive/2014/11/12/improvements-to-warnings-in-the-c-compiler.aspx

Change-Id: Ic9c3f75ee717f0125960c813df442ed4fbcceb4a
parent a360958b
...@@ -112,18 +112,18 @@ int main(int argc, const char *argv[]) { ...@@ -112,18 +112,18 @@ int main(int argc, const char *argv[]) {
std::vector<std::string> filenames; std::vector<std::string> filenames;
std::vector<const char *> include_directories; std::vector<const char *> include_directories;
size_t binary_files_from = std::numeric_limits<size_t>::max(); size_t binary_files_from = std::numeric_limits<size_t>::max();
for (int i = 1; i < argc; i++) { for (int argi = 1; argi < argc; argi++) {
const char *arg = argv[i]; const char *arg = argv[argi];
if (arg[0] == '-') { if (arg[0] == '-') {
if (filenames.size() && arg[1] != '-') if (filenames.size() && arg[1] != '-')
Error("invalid option location", arg, true); Error("invalid option location", arg, true);
std::string opt = arg; std::string opt = arg;
if (opt == "-o") { if (opt == "-o") {
if (++i >= argc) Error("missing path following", arg, true); if (++argi >= argc) Error("missing path following", arg, true);
output_path = flatbuffers::ConCatPathFileName(argv[i], ""); output_path = flatbuffers::ConCatPathFileName(argv[argi], "");
} else if(opt == "-I") { } else if(opt == "-I") {
if (++i >= argc) Error("missing path following", arg, true); if (++argi >= argc) Error("missing path following", arg, true);
include_directories.push_back(argv[i]); include_directories.push_back(argv[argi]);
} else if(opt == "--strict-json") { } else if(opt == "--strict-json") {
opts.strict_json = true; opts.strict_json = true;
} else if(opt == "--no-prefix") { } else if(opt == "--no-prefix") {
...@@ -149,7 +149,7 @@ int main(int argc, const char *argv[]) { ...@@ -149,7 +149,7 @@ int main(int argc, const char *argv[]) {
found:; found:;
} }
} else { } else {
filenames.push_back(argv[i]); filenames.push_back(argv[argi]);
} }
} }
......
...@@ -58,9 +58,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name, ...@@ -58,9 +58,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
} }
schema += ";\n\n"; schema += ";\n\n";
// Generate code for all the enum declarations. // Generate code for all the enum declarations.
for (auto it = parser.enums_.vec.begin(); for (auto enum_def_it = parser.enums_.vec.begin();
it != parser.enums_.vec.end(); ++it) { enum_def_it != parser.enums_.vec.end(); ++enum_def_it) {
EnumDef &enum_def = **it; EnumDef &enum_def = **enum_def_it;
schema += "enum " + enum_def.name + " : "; schema += "enum " + enum_def.name + " : ";
schema += GenType(enum_def.underlying_type) + " {\n"; schema += GenType(enum_def.underlying_type) + " {\n";
for (auto it = enum_def.vals.vec.begin(); for (auto it = enum_def.vals.vec.begin();
...@@ -75,9 +75,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name, ...@@ -75,9 +75,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
it != parser.structs_.vec.end(); ++it) { it != parser.structs_.vec.end(); ++it) {
StructDef &struct_def = **it; StructDef &struct_def = **it;
schema += "table " + struct_def.name + " {\n"; schema += "table " + struct_def.name + " {\n";
for (auto it = struct_def.fields.vec.begin(); for (auto field_it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) { field_it != struct_def.fields.vec.end(); ++field_it) {
auto &field = **it; auto &field = **field_it;
schema += " " + field.name + ":" + GenType(field.value.type); schema += " " + field.name + ":" + GenType(field.value.type);
if (field.value.constant != "0") schema += " = " + field.value.constant; if (field.value.constant != "0") schema += " = " + field.value.constant;
if (field.required) schema += " (required)"; if (field.required) schema += " (required)";
......
...@@ -787,17 +787,17 @@ StructDef *Parser::LookupCreateStruct(const std::string &name) { ...@@ -787,17 +787,17 @@ StructDef *Parser::LookupCreateStruct(const std::string &name) {
} }
void Parser::ParseEnum(bool is_union) { void Parser::ParseEnum(bool is_union) {
std::vector<std::string> dc = doc_comment_; std::vector<std::string> enum_comment = doc_comment_;
Next(); Next();
std::string name = attribute_; std::string enum_name = attribute_;
Expect(kTokenIdentifier); Expect(kTokenIdentifier);
auto &enum_def = *new EnumDef(); auto &enum_def = *new EnumDef();
enum_def.name = name; enum_def.name = enum_name;
if (!files_being_parsed_.empty()) enum_def.file = files_being_parsed_.top(); if (!files_being_parsed_.empty()) enum_def.file = files_being_parsed_.top();
enum_def.doc_comment = dc; enum_def.doc_comment = enum_comment;
enum_def.is_union = is_union; enum_def.is_union = is_union;
enum_def.defined_namespace = namespaces_.back(); enum_def.defined_namespace = namespaces_.back();
if (enums_.Add(name, &enum_def)) Error("enum already exists: " + name); if (enums_.Add(enum_name, &enum_def)) Error("enum already exists: " + enum_name);
if (is_union) { if (is_union) {
enum_def.underlying_type.base_type = BASE_TYPE_UTYPE; enum_def.underlying_type.base_type = BASE_TYPE_UTYPE;
enum_def.underlying_type.enum_def = &enum_def; enum_def.underlying_type.enum_def = &enum_def;
...@@ -821,19 +821,19 @@ void Parser::ParseEnum(bool is_union) { ...@@ -821,19 +821,19 @@ void Parser::ParseEnum(bool is_union) {
Expect('{'); Expect('{');
if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0)); if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0));
do { do {
std::string name = attribute_; std::string value_name = attribute_;
std::vector<std::string> dc = doc_comment_; std::vector<std::string> value_comment = doc_comment_;
Expect(kTokenIdentifier); Expect(kTokenIdentifier);
auto prevsize = enum_def.vals.vec.size(); auto prevsize = enum_def.vals.vec.size();
auto value = enum_def.vals.vec.size() auto value = enum_def.vals.vec.size()
? enum_def.vals.vec.back()->value + 1 ? enum_def.vals.vec.back()->value + 1
: 0; : 0;
auto &ev = *new EnumVal(name, value); auto &ev = *new EnumVal(value_name, value);
if (enum_def.vals.Add(name, &ev)) if (enum_def.vals.Add(value_name, &ev))
Error("enum value already exists: " + name); Error("enum value already exists: " + value_name);
ev.doc_comment = dc; ev.doc_comment = value_comment;
if (is_union) { if (is_union) {
ev.struct_def = LookupCreateStruct(name); ev.struct_def = LookupCreateStruct(value_name);
} }
if (IsNext('=')) { if (IsNext('=')) {
ev.value = atoi(attribute_.c_str()); ev.value = atoi(attribute_.c_str());
...@@ -1198,10 +1198,10 @@ bool Parser::Parse(const char *source, const char **include_paths, ...@@ -1198,10 +1198,10 @@ bool Parser::Parse(const char *source, const char **include_paths,
for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) {
auto &enum_def = **it; auto &enum_def = **it;
if (enum_def.is_union) { if (enum_def.is_union) {
for (auto it = enum_def.vals.vec.begin(); for (auto val_it = enum_def.vals.vec.begin();
it != enum_def.vals.vec.end(); val_it != enum_def.vals.vec.end();
++it) { ++val_it) {
auto &val = **it; auto &val = **val_it;
if (val.struct_def && val.struct_def->fixed) if (val.struct_def && val.struct_def->fixed)
Error("only tables can be union elements: " + val.name); Error("only tables can be union elements: " + val.name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment