Skip to content

Commit b7829aa

Browse files
authored
Merge pull request #104 from wravery/master
Sync to latest PEGTL commit and fix breaks
2 parents b4081f4 + 10a2526 commit b7829aa

File tree

7 files changed

+79
-79
lines changed

7 files changed

+79
-79
lines changed

PEGTL

Submodule PEGTL updated 309 files

include/graphqlservice/GraphQLService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ GRAPHQLSERVICE_EXPORT void addErrorMessage(std::string&& message, response::Valu
4545
struct schema_location
4646
{
4747
size_t line = 0;
48-
size_t byte_in_line = 0;
48+
size_t column = 1;
4949
};
5050

5151
GRAPHQLSERVICE_EXPORT void addErrorLocation(const schema_location& location, response::Value& error);

src/GraphQLService.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void addErrorLocation(const schema_location& location, response::Value& error)
2929

3030
errorLocation.reserve(2);
3131
errorLocation.emplace_back(std::string { strLine }, response::Value(static_cast<response::IntType>(location.line)));
32-
errorLocation.emplace_back(std::string { strColumn }, response::Value(static_cast<response::IntType>(location.byte_in_line + 1)));
32+
errorLocation.emplace_back(std::string { strColumn }, response::Value(static_cast<response::IntType>(location.column)));
3333

3434
response::Value errorLocations(response::Type::List);
3535

@@ -254,7 +254,7 @@ void ValueVisitor::visitVariable(const peg::ast_node& variable)
254254

255255
error << "Unknown variable name: " << name;
256256

257-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
257+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
258258
}
259259

260260
_value = response::Value(itr->second);
@@ -510,7 +510,7 @@ schema_location ResolverParams::getLocation() const
510510
{
511511
auto position = field.begin();
512512

513-
return { position.line, position.byte_in_line };
513+
return { position.line, position.column };
514514
}
515515

516516
uint8_t Base64::verifyFromBase64(char ch)
@@ -737,7 +737,7 @@ std::future<response::Value> ModifiedResult<response::IntType>::convert(FieldRes
737737

738738
error << "Field may not have sub-fields name: " << params.fieldName;
739739

740-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
740+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
741741
}
742742

743743
return resolve(std::move(result), std::move(params),
@@ -758,7 +758,7 @@ std::future<response::Value> ModifiedResult<response::FloatType>::convert(FieldR
758758

759759
error << "Field may not have sub-fields name: " << params.fieldName;
760760

761-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
761+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
762762
}
763763

764764
return resolve(std::move(result), std::move(params),
@@ -779,7 +779,7 @@ std::future<response::Value> ModifiedResult<response::StringType>::convert(Field
779779

780780
error << "Field may not have sub-fields name: " << params.fieldName;
781781

782-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
782+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
783783
}
784784

785785
return resolve(std::move(result), std::move(params),
@@ -800,7 +800,7 @@ std::future<response::Value> ModifiedResult<response::BooleanType>::convert(Fiel
800800

801801
error << "Field may not have sub-fields name: " << params.fieldName;
802802

803-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
803+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
804804
}
805805

806806
return resolve(std::move(result), std::move(params),
@@ -821,7 +821,7 @@ std::future<response::Value> ModifiedResult<response::Value>::convert(FieldResul
821821

822822
error << "Field may not have sub-fields name: " << params.fieldName;
823823

824-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
824+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
825825
}
826826

827827
return resolve(std::move(result), std::move(params),
@@ -842,7 +842,7 @@ std::future<response::Value> ModifiedResult<response::IdType>::convert(FieldResu
842842

843843
error << "Field may not have sub-fields name: " << params.fieldName;
844844

845-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
845+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
846846
}
847847

848848
return resolve(std::move(result), std::move(params),
@@ -863,7 +863,7 @@ std::future<response::Value> ModifiedResult<Object>::convert(FieldResult<std::sh
863863

864864
error << "Field must have sub-fields name: " << params.fieldName;
865865

866-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
866+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
867867
}
868868

869869
return std::async(params.launch,
@@ -1013,7 +1013,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
10131013
promise.set_exception(std::make_exception_ptr(
10141014
schema_exception { { schema_error{
10151015
error.str(),
1016-
{ position.line, position.byte_in_line },
1016+
{ position.line, position.column },
10171017
{ _path }
10181018
} } }));
10191019

@@ -1095,7 +1095,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
10951095
{
10961096
if (message.location.line == 0)
10971097
{
1098-
message.location = { position.line, position.byte_in_line };
1098+
message.location = { position.line, position.column };
10991099
}
11001100

11011101
if (message.path.empty())
@@ -1123,7 +1123,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
11231123
promise.set_exception(std::make_exception_ptr(
11241124
schema_exception { { schema_error{
11251125
message.str(),
1126-
{ position.line, position.byte_in_line },
1126+
{ position.line, position.column },
11271127
std::move(selectionSetParams.errorPath)
11281128
} } }));
11291129

@@ -1146,7 +1146,7 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)
11461146

11471147
error << "Unknown fragment name: " << name;
11481148

1149-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { _path } } } };
1149+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { _path } } } };
11501150
}
11511151

11521152
bool skip = (_typeNames.count(itr->second.getType()) == 0);
@@ -1676,7 +1676,7 @@ void SubscriptionDefinitionVisitor::visitField(const peg::ast_node& field)
16761676

16771677
error << "Extra subscription root field name: " << name;
16781678

1679-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
1679+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
16801680
}
16811681

16821682
DirectiveVisitor directiveVisitor(_params.variables);
@@ -1723,7 +1723,7 @@ void SubscriptionDefinitionVisitor::visitFragmentSpread(const peg::ast_node& fra
17231723

17241724
error << "Unknown fragment name: " << name;
17251725

1726-
throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
1726+
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
17271727
}
17281728

17291729
bool skip = !_subscriptionObject->matchesType(itr->second.getType());
@@ -1852,7 +1852,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
18521852
message << "Duplicate named operations name: " << name;
18531853
}
18541854

1855-
errors.push_back({ message.str(), { position.line, position.byte_in_line } });
1855+
errors.push_back({ message.str(), { position.line, position.column } });
18561856
}
18571857

18581858
hasAnonymous = hasAnonymous || name.empty();
@@ -1873,7 +1873,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
18731873
message << "Unexpected named operation name: " << name;
18741874
}
18751875

1876-
errors.push_back({ message.str(), { position.line, position.byte_in_line } });
1876+
errors.push_back({ message.str(), { position.line, position.column } });
18771877
}
18781878

18791879
auto itr = _operations.find(operationType);
@@ -1889,7 +1889,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
18891889
message << " name: " << name;
18901890
}
18911891

1892-
errors.push_back({ message.str(), { position.line, position.byte_in_line } });
1892+
errors.push_back({ message.str(), { position.line, position.column } });
18931893
}
18941894

18951895
if (!errors.empty())
@@ -1955,7 +1955,7 @@ std::future<response::Value> Request::resolveValidated(std::launch launch, const
19551955

19561956
message << "Unexpected type definition";
19571957

1958-
throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
1958+
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
19591959
}
19601960
}
19611961

@@ -1995,7 +1995,7 @@ std::future<response::Value> Request::resolveValidated(std::launch launch, const
19951995
message << " name: " << operationName;
19961996
}
19971997

1998-
throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
1998+
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
19991999
}
20002000

20012001
// http://spec.graphql.org/June2018/#sec-Normal-and-Serial-Execution
@@ -2069,7 +2069,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCall
20692069
message << " name: " << params.operationName;
20702070
}
20712071

2072-
throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
2072+
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
20732073
}
20742074

20752075
auto itr = _operations.find(std::string { strSubscription });

src/GraphQLTree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct ast_selector<escaped_unicode>
8888
}
8989
}
9090

91-
throw parse_error("invalid escaped unicode code point", { n->begin(), n->end() });
91+
throw parse_error("invalid escaped unicode code point", n->begin());
9292
}
9393
};
9494

@@ -141,7 +141,7 @@ struct ast_selector<escaped_char>
141141
}
142142
}
143143

144-
throw parse_error("invalid escaped character sequence", { n->begin(), n->end() });
144+
throw parse_error("invalid escaped character sequence", n->begin());
145145
}
146146
};
147147

@@ -574,7 +574,7 @@ struct ast_control
574574
static const std::string error_message;
575575

576576
template <typename Input, typename... State>
577-
static void raise(const Input& in, State&&...)
577+
[[noreturn]] static void raise(const Input& in, State&&...)
578578
{
579579
throw parse_error(error_message, in);
580580
}

src/SchemaGenerator.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ void Generator::validateSchema()
383383
if (itrPosition != _typePositions.cend())
384384
{
385385
error << " line: " << itrPosition->second.line
386-
<< " column: " << (itrPosition->second.byte_in_line + 1);
386+
<< " column: " << itrPosition->second.column;
387387
}
388388

389389
throw std::runtime_error(error.str());
@@ -513,7 +513,7 @@ void Generator::validateSchema()
513513
if (itrPosition != _typePositions.cend())
514514
{
515515
error << " line: " << itrPosition->second.line
516-
<< " column: " << (itrPosition->second.byte_in_line + 1);
516+
<< " column: " << itrPosition->second.column;
517517
}
518518

519519
throw std::runtime_error(error.str());
@@ -558,7 +558,7 @@ void Generator::fixupOutputFieldList(OutputFieldList& fields, const std::optiona
558558
if (entry.position)
559559
{
560560
error << " line: " << entry.position->line
561-
<< " column: " << (entry.position->byte_in_line + 1);
561+
<< " column: " << entry.position->column;
562562
}
563563

564564
throw std::runtime_error(error.str());
@@ -595,7 +595,7 @@ void Generator::fixupOutputFieldList(OutputFieldList& fields, const std::optiona
595595
if (entry.position)
596596
{
597597
error << " line: " << entry.position->line
598-
<< " column: " << (entry.position->byte_in_line + 1);
598+
<< " column: " << entry.position->column;
599599
}
600600

601601
throw std::runtime_error(error.str());
@@ -626,7 +626,7 @@ void Generator::fixupInputFieldList(InputFieldList& fields)
626626
if (entry.position)
627627
{
628628
error << " line: " << entry.position->line
629-
<< " column: " << (entry.position->byte_in_line + 1);
629+
<< " column: " << entry.position->column;
630630
}
631631

632632
throw std::runtime_error(error.str());
@@ -655,7 +655,7 @@ void Generator::fixupInputFieldList(InputFieldList& fields)
655655
if (entry.position)
656656
{
657657
error << " line: " << entry.position->line
658-
<< " column: " << (entry.position->byte_in_line + 1);
658+
<< " column: " << entry.position->column;
659659
}
660660

661661
throw std::runtime_error(error.str());
@@ -1298,7 +1298,7 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
12981298
field.defaultValue = defaultValue.getValue();
12991299
field.defaultValueString = child->children.back()->string_view();
13001300

1301-
defaultValueLocation = { position.line, position.byte_in_line };
1301+
defaultValueLocation = { position.line, position.column };
13021302
}
13031303
else if (child->is_type<peg::description>())
13041304
{
@@ -1318,7 +1318,7 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
13181318

13191319
error << "Expected Non-Null default value for field name: " << field.name
13201320
<< " line: " << defaultValueLocation.line
1321-
<< " column: " << (defaultValueLocation.byte_in_line + 1);
1321+
<< " column: " << defaultValueLocation.column;
13221322

13231323
throw std::runtime_error(error.str());
13241324
}
@@ -3608,10 +3608,10 @@ int main(int argc, char** argv)
36083608
std::cerr << "Invalid GraphQL: " << pe.what()
36093609
<< std::endl;
36103610

3611-
for (const auto& position : pe.positions)
3611+
for (const auto& position : pe.positions())
36123612
{
36133613
std::cerr << "\tline: " << position.line
3614-
<< " column: " << (position.byte_in_line + 1)
3614+
<< " column: " << position.column
36153615
<< std::endl;
36163616
}
36173617

0 commit comments

Comments
 (0)