Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions SchemaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ struct )cpp" << interfaceType.type << R"cpp(
)cpp";
for (const auto& outputField : interfaceType.fields)
{
headerFile << getFieldDeclaration(outputField, true);
headerFile << getFieldDeclaration(outputField, true, false);
}
headerFile << R"cpp(};
)cpp";
Expand Down Expand Up @@ -1432,10 +1432,7 @@ class )cpp" << objectType.type << R"cpp(

for (const auto& outputField : objectType.fields)
{
if (interfaceFields.find(outputField.name) != interfaceFields.cend())
{
continue;
}
const bool inheritedField = interfaceFields.find(outputField.name) != interfaceFields.cend();

if (firstField)
{
Expand All @@ -1445,7 +1442,7 @@ class )cpp" << objectType.type << R"cpp(
firstField = false;
}

headerFile << getFieldDeclaration(outputField, false);
headerFile << getFieldDeclaration(outputField, false, inheritedField);
}

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

std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField) const noexcept
std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField, bool inheritedField) const noexcept
{
std::ostringstream output;
std::string fieldName(outputField.name);
Expand All @@ -1556,7 +1553,16 @@ std::string Generator::getFieldDeclaration(const OutputField & outputField, bool
<< R"cpp(&& )cpp" << argument.name << "Arg";
}

output << R"cpp() const = 0;
output << R"cpp() const)cpp";
if (interfaceField)
{
output << R"cpp( = 0)cpp";
}
else if (inheritedField)
{
output << R"cpp( override)cpp";
}
output << R"cpp(;
)cpp";

return output.str();
Expand Down Expand Up @@ -1890,6 +1896,28 @@ namespace object {

fieldName[0] = static_cast<char>(std::toupper(static_cast<unsigned char>(fieldName[0])));
sourceFile << R"cpp(
std::future<)cpp" << getOutputCppType(outputField, false)
<< R"cpp(> )cpp" << objectType.type
<< R"cpp(::get)cpp" << fieldName
<< R"cpp((service::FieldParams&&)cpp";
for (const auto& argument : outputField.arguments)
{
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
<< R"cpp(&&)cpp";
}

sourceFile << R"cpp() const
{
std::promise<)cpp" << getOutputCppType(outputField, false)
<< R"cpp(> promise;

promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex()cpp" << objectType.type
<< R"cpp(::get)cpp" << fieldName
<< R"cpp( is not implemented)ex")));

return promise.get_future();
}

std::future<response::Value> )cpp" << objectType.type
<< R"cpp(::resolve)cpp" << fieldName
<< R"cpp((service::ResolverParams&& params)
Expand Down
2 changes: 1 addition & 1 deletion include/SchemaGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Generator

bool outputHeader() const noexcept;
std::string getFieldDeclaration(const InputField& inputField) const noexcept;
std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField) const noexcept;
std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField, bool inheritedField) const noexcept;
std::string getResolverDeclaration(const OutputField& outputField) const noexcept;

bool outputSource() const noexcept;
Expand Down
Loading