Skip to content

Commit 37a1b7b

Browse files
authored
Merge pull request #47 from wravery/generatestubs
Generate NYI stubs for all of the field getters
2 parents 1092850 + 4a57b2b commit 37a1b7b

File tree

8 files changed

+794
-78
lines changed

8 files changed

+794
-78
lines changed

SchemaGenerator.cpp

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ struct )cpp" << interfaceType.type << R"cpp(
13651365
)cpp";
13661366
for (const auto& outputField : interfaceType.fields)
13671367
{
1368-
headerFile << getFieldDeclaration(outputField, true);
1368+
headerFile << getFieldDeclaration(outputField, true, false);
13691369
}
13701370
headerFile << R"cpp(};
13711371
)cpp";
@@ -1432,10 +1432,7 @@ class )cpp" << objectType.type << R"cpp(
14321432

14331433
for (const auto& outputField : objectType.fields)
14341434
{
1435-
if (interfaceFields.find(outputField.name) != interfaceFields.cend())
1436-
{
1437-
continue;
1438-
}
1435+
const bool inheritedField = interfaceFields.find(outputField.name) != interfaceFields.cend();
14391436

14401437
if (firstField)
14411438
{
@@ -1445,7 +1442,7 @@ class )cpp" << objectType.type << R"cpp(
14451442
firstField = false;
14461443
}
14471444

1448-
headerFile << getFieldDeclaration(outputField, false);
1445+
headerFile << getFieldDeclaration(outputField, false, inheritedField);
14491446
}
14501447

14511448
headerFile << R"cpp(
@@ -1541,7 +1538,7 @@ std::string Generator::getFieldDeclaration(const InputField & inputField) const
15411538
return output.str();
15421539
}
15431540

1544-
std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField) const noexcept
1541+
std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField, bool inheritedField) const noexcept
15451542
{
15461543
std::ostringstream output;
15471544
std::string fieldName(outputField.name);
@@ -1556,7 +1553,16 @@ std::string Generator::getFieldDeclaration(const OutputField & outputField, bool
15561553
<< R"cpp(&& )cpp" << argument.name << "Arg";
15571554
}
15581555

1559-
output << R"cpp() const = 0;
1556+
output << R"cpp() const)cpp";
1557+
if (interfaceField)
1558+
{
1559+
output << R"cpp( = 0)cpp";
1560+
}
1561+
else if (inheritedField)
1562+
{
1563+
output << R"cpp( override)cpp";
1564+
}
1565+
output << R"cpp(;
15601566
)cpp";
15611567

15621568
return output.str();
@@ -1890,6 +1896,28 @@ namespace object {
18901896

18911897
fieldName[0] = static_cast<char>(std::toupper(static_cast<unsigned char>(fieldName[0])));
18921898
sourceFile << R"cpp(
1899+
std::future<)cpp" << getOutputCppType(outputField, false)
1900+
<< R"cpp(> )cpp" << objectType.type
1901+
<< R"cpp(::get)cpp" << fieldName
1902+
<< R"cpp((service::FieldParams&&)cpp";
1903+
for (const auto& argument : outputField.arguments)
1904+
{
1905+
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
1906+
<< R"cpp(&&)cpp";
1907+
}
1908+
1909+
sourceFile << R"cpp() const
1910+
{
1911+
std::promise<)cpp" << getOutputCppType(outputField, false)
1912+
<< R"cpp(> promise;
1913+
1914+
promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex()cpp" << objectType.type
1915+
<< R"cpp(::get)cpp" << fieldName
1916+
<< R"cpp( is not implemented)ex")));
1917+
1918+
return promise.get_future();
1919+
}
1920+
18931921
std::future<response::Value> )cpp" << objectType.type
18941922
<< R"cpp(::resolve)cpp" << fieldName
18951923
<< R"cpp((service::ResolverParams&& params)

include/SchemaGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class Generator
277277

278278
bool outputHeader() const noexcept;
279279
std::string getFieldDeclaration(const InputField& inputField) const noexcept;
280-
std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField) const noexcept;
280+
std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField, bool inheritedField) const noexcept;
281281
std::string getResolverDeclaration(const OutputField& outputField) const noexcept;
282282

283283
bool outputSource() const noexcept;

0 commit comments

Comments
 (0)