Skip to content

Commit 1abe820

Browse files
committed
Run everything through clang-format
1 parent a9c7101 commit 1abe820

22 files changed

+3553
-2874
lines changed

.clang-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ PenaltyBreakFirstLessLess: 120
9393
PenaltyBreakString: 1000
9494
PenaltyBreakTemplateDeclaration: 10
9595
PenaltyExcessCharacter: 1000000
96-
PenaltyReturnTypeOnItsOwnLine: 4
96+
PenaltyReturnTypeOnItsOwnLine: 500
9797
PointerAlignment: Left
9898
ReflowComments: true
99-
SortIncludes: false
99+
SortIncludes: true
100100
SortUsingDeclarations: true
101101
SpaceAfterCStyleCast: false
102102
SpaceAfterLogicalNot: false

include/SchemaGenerator.h

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#ifndef SCHEMAGENERATOR_H
77
#define SCHEMAGENERATOR_H
88

9-
#include "graphqlservice/GraphQLService.h"
109
#include "graphqlservice/GraphQLGrammar.h"
10+
#include "graphqlservice/GraphQLService.h"
1111

1212
#include <array>
1313
#include <cstdio>
@@ -174,7 +174,7 @@ struct OutputField
174174
std::optional<tao::graphqlpeg::position> position;
175175
bool interfaceField = false;
176176
bool inheritedField = false;
177-
std::string_view accessor{ strGet };
177+
std::string_view accessor { strGet };
178178
};
179179

180180
using OutputFieldList = std::vector<OutputField>;
@@ -255,7 +255,8 @@ class IncludeGuardScope
255255
class NamespaceScope
256256
{
257257
public:
258-
explicit NamespaceScope(std::ostream& outputFile, std::string_view cppNamespace, bool deferred = false) noexcept;
258+
explicit NamespaceScope(
259+
std::ostream& outputFile, std::string_view cppNamespace, bool deferred = false) noexcept;
259260
NamespaceScope(NamespaceScope&& other) noexcept;
260261
~NamespaceScope() noexcept;
261262

@@ -268,7 +269,8 @@ class NamespaceScope
268269
std::string_view _cppNamespace;
269270
};
270271

271-
// Keep track of whether we want to add a blank separator line once some additional content is about to be output.
272+
// Keep track of whether we want to add a blank separator line once some additional content is about
273+
// to be output.
272274
class PendingBlankLine
273275
{
274276
public:
@@ -316,7 +318,8 @@ class Generator
316318
void visitDirectiveDefinition(const peg::ast_node& directiveDefinition);
317319

318320
static const std::string& getSafeCppName(const std::string& type) noexcept;
319-
static OutputFieldList getOutputFields(const std::vector<std::unique_ptr<peg::ast_node>>& fields);
321+
static OutputFieldList getOutputFields(
322+
const std::vector<std::unique_ptr<peg::ast_node>>& fields);
320323
static InputFieldList getInputFields(const std::vector<std::unique_ptr<peg::ast_node>>& fields);
321324

322325
// Recursively visit a Type node until we reach a NamedType and we've
@@ -361,28 +364,35 @@ class Generator
361364
};
362365

363366
void validateSchema();
364-
void fixupOutputFieldList(OutputFieldList& fields, const std::optional<std::unordered_set<std::string>>& interfaceFields, const std::optional<std::string_view>& accessor);
367+
void fixupOutputFieldList(OutputFieldList& fields,
368+
const std::optional<std::unordered_set<std::string>>& interfaceFields,
369+
const std::optional<std::string_view>& accessor);
365370
void fixupInputFieldList(InputFieldList& fields);
366371

367372
const std::string& getCppType(const std::string& type) const noexcept;
368373
std::string getInputCppType(const InputField& field) const noexcept;
369374
std::string getOutputCppType(const OutputField& field) const noexcept;
370375

371376
bool outputHeader() const noexcept;
372-
void outputObjectDeclaration(std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const;
377+
void outputObjectDeclaration(
378+
std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const;
373379
std::string getFieldDeclaration(const InputField& inputField) const noexcept;
374380
std::string getFieldDeclaration(const OutputField& outputField) const noexcept;
375381
std::string getResolverDeclaration(const OutputField& outputField) const noexcept;
376382

377383
bool outputSource() const noexcept;
378-
void outputObjectImplementation(std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const;
384+
void outputObjectImplementation(
385+
std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const;
379386
void outputObjectIntrospection(std::ostream& sourceFile, const ObjectType& objectType) const;
380-
std::string getArgumentDefaultValue(size_t level, const response::Value& defaultValue) const noexcept;
381-
std::string getArgumentDeclaration(const InputField& argument, const char* prefixToken, const char* argumentsToken, const char* defaultToken) const noexcept;
387+
std::string getArgumentDefaultValue(
388+
size_t level, const response::Value& defaultValue) const noexcept;
389+
std::string getArgumentDeclaration(const InputField& argument, const char* prefixToken,
390+
const char* argumentsToken, const char* defaultToken) const noexcept;
382391
std::string getArgumentAccessType(const InputField& argument) const noexcept;
383392
std::string getResultAccessType(const OutputField& result) const noexcept;
384393
std::string getTypeModifiers(const TypeModifierStack& modifiers) const noexcept;
385-
std::string getIntrospectionType(const std::string& type, const TypeModifierStack& modifiers) const noexcept;
394+
std::string getIntrospectionType(
395+
const std::string& type, const TypeModifierStack& modifiers) const noexcept;
386396

387397
std::vector<std::string> outputSeparateFiles() const noexcept;
388398

include/Validation.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,9 @@ struct ValidateArgumentMap
7474
std::map<std::string, ValidateArgumentValuePtr> values;
7575
};
7676

77-
using ValidateArgumentVariant = std::variant<
78-
ValidateArgumentVariable,
79-
response::IntType,
80-
response::FloatType,
81-
response::StringType,
82-
response::BooleanType,
83-
ValidateArgumentEnumValue,
84-
ValidateArgumentList,
85-
ValidateArgumentMap>;
77+
using ValidateArgumentVariant = std::variant<ValidateArgumentVariable, response::IntType,
78+
response::FloatType, response::StringType, response::BooleanType, ValidateArgumentEnumValue,
79+
ValidateArgumentList, ValidateArgumentMap>;
8680

8781
struct ValidateArgumentValue
8882
{
@@ -128,7 +122,8 @@ using ValidateFieldArguments = std::map<std::string, ValidateArgumentValuePtr>;
128122

129123
struct ValidateField
130124
{
131-
ValidateField(std::string&& returnType, std::optional<std::string>&& objectType, const std::string& fieldName, ValidateFieldArguments&& arguments);
125+
ValidateField(std::string&& returnType, std::optional<std::string>&& objectType,
126+
const std::string& fieldName, ValidateFieldArguments&& arguments);
132127

133128
bool operator==(const ValidateField& other) const;
134129

@@ -163,7 +158,8 @@ class ValidateVariableTypeVisitor
163158
ValidateType _variableType;
164159
};
165160

166-
// ValidateExecutableVisitor visits the AST and validates that it is executable against the service schema.
161+
// ValidateExecutableVisitor visits the AST and validates that it is executable against the service
162+
// schema.
167163
class ValidateExecutableVisitor
168164
{
169165
public:
@@ -209,11 +205,13 @@ class ValidateExecutableVisitor
209205
void visitFragmentSpread(const peg::ast_node& fragmentSpread);
210206
void visitInlineFragment(const peg::ast_node& inlineFragment);
211207

212-
void visitDirectives(introspection::DirectiveLocation location, const peg::ast_node& directives);
213-
214-
bool validateInputValue(bool hasNonNullDefaultValue, const ValidateArgumentValuePtr& argument, const ValidateType& type);
215-
bool validateVariableType(bool isNonNull, const ValidateType& variableType, const schema_location& position, const ValidateType& inputType);
208+
void visitDirectives(
209+
introspection::DirectiveLocation location, const peg::ast_node& directives);
216210

211+
bool validateInputValue(bool hasNonNullDefaultValue, const ValidateArgumentValuePtr& argument,
212+
const ValidateType& type);
213+
bool validateVariableType(bool isNonNull, const ValidateType& variableType,
214+
const schema_location& position, const ValidateType& inputType);
217215

218216
const Request& _service;
219217
std::vector<schema_error> _errors;

include/graphqlservice/GraphQLParse.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef GRAPHQLPARSE_H
77
#define GRAPHQLPARSE_H
88

9+
// clang-format off
910
#ifdef GRAPHQL_DLLEXPORTS
1011
#ifdef IMPL_GRAPHQLPEG_DLL
1112
#define GRAPHQLPEG_EXPORT __declspec(dllexport)
@@ -15,6 +16,7 @@
1516
#else // !GRAPHQL_DLLEXPORTS
1617
#define GRAPHQLPEG_EXPORT
1718
#endif // !GRAPHQL_DLLEXPORTS
19+
// clang-format on
1820

1921
#include <memory>
2022
#include <string_view>
@@ -37,7 +39,7 @@ GRAPHQLPEG_EXPORT ast parseFile(std::string_view filename);
3739

3840
} /* namespace peg */
3941

40-
GRAPHQLPEG_EXPORT peg::ast operator "" _graphql(const char* text, size_t size);
42+
GRAPHQLPEG_EXPORT peg::ast operator"" _graphql(const char* text, size_t size);
4143

4244
} /* namespace graphql */
4345

include/graphqlservice/GraphQLResponse.h

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef GRAPHQLRESPONSE_H
77
#define GRAPHQLRESPONSE_H
88

9+
// clang-format off
910
#ifdef GRAPHQL_DLLEXPORTS
1011
#ifdef IMPL_GRAPHQLRESPONSE_DLL
1112
#define GRAPHQLRESPONSE_EXPORT __declspec(dllexport)
@@ -15,6 +16,7 @@
1516
#else // !GRAPHQL_DLLEXPORTS
1617
#define GRAPHQLRESPONSE_EXPORT
1718
#endif // !GRAPHQL_DLLEXPORTS
19+
// clang-format on
1820

1921
#include <memory>
2022
#include <string>
@@ -28,15 +30,15 @@ namespace graphql::response {
2830
// of the [June 2018 spec](https://facebook.github.io/graphql/June2018/#sec-Serialization-Format).
2931
enum class Type : uint8_t
3032
{
31-
Map, // JSON Object
32-
List, // JSON Array
33-
String, // JSON String
34-
Null, // JSON null
35-
Boolean, // JSON true or false
36-
Int, // JSON Number
37-
Float, // JSON Number
38-
EnumValue, // JSON String
39-
Scalar, // JSON any type
33+
Map, // JSON Object
34+
List, // JSON Array
35+
String, // JSON String
36+
Null, // JSON null
37+
Boolean, // JSON true or false
38+
Int, // JSON Number
39+
Float, // JSON Number
40+
EnumValue, // JSON String
41+
Scalar, // JSON any type
4042
};
4143

4244
struct Value;
@@ -157,28 +159,36 @@ struct Value
157159
// Specialized for all single-value Types.
158160
template <typename ValueType>
159161
void set(typename std::enable_if_t<std::is_same_v<std::decay_t<ValueType>, ValueType>,
160-
typename ValueTypeTraits<ValueType>::set_type> value);
162+
typename ValueTypeTraits<ValueType>::set_type>
163+
value);
161164

162165
// Specialized for all Types.
163166
template <typename ValueType>
164167
typename std::enable_if_t<std::is_same_v<std::decay_t<ValueType>, ValueType>,
165-
typename ValueTypeTraits<ValueType>::get_type> get() const;
168+
typename ValueTypeTraits<ValueType>::get_type>
169+
get() const;
166170

167171
// Specialized for all Types which allocate extra memory.
168172
template <typename ValueType>
169173
typename ValueTypeTraits<ValueType>::release_type release();
170174

171175
// Compatibility wrappers
172176
template <typename ReferenceType>
173-
[[deprecated("Use the unqualified Value::set<> specialization instead of specializing on the r-value reference.")]]
174-
void set(typename std::enable_if_t<std::is_rvalue_reference_v<ReferenceType>, ReferenceType> value)
177+
[[deprecated("Use the unqualified Value::set<> specialization instead of specializing on the "
178+
"r-value reference.")]] void
179+
set(typename std::enable_if_t<std::is_rvalue_reference_v<ReferenceType>, ReferenceType> value)
175180
{
176181
set<std::decay_t<ReferenceType>>(std::move(value));
177182
}
178183

179184
template <typename ReferenceType>
180-
[[deprecated("Use the unqualified Value::get<> specialization instead of specializing on the const reference.")]]
181-
typename std::enable_if_t<std::is_lvalue_reference_v<ReferenceType> && std::is_const_v<typename std::remove_reference_t<ReferenceType>>, ReferenceType> get() const
185+
[[deprecated("Use the unqualified Value::get<> specialization instead of specializing on the "
186+
"const reference.")]]
187+
typename std::enable_if_t<
188+
std::is_lvalue_reference_v<
189+
ReferenceType> && std::is_const_v<typename std::remove_reference_t<ReferenceType>>,
190+
ReferenceType>
191+
get() const
182192
{
183193
return get<std::decay_t<ReferenceType>>();
184194
}
@@ -190,22 +200,38 @@ struct Value
190200

191201
#ifdef GRAPHQL_DLLEXPORTS
192202
// Export all of the specialized template methods
193-
template <> GRAPHQLRESPONSE_EXPORT void Value::set<StringType>(StringType&& value);
194-
template <> GRAPHQLRESPONSE_EXPORT void Value::set<BooleanType>(BooleanType value);
195-
template <> GRAPHQLRESPONSE_EXPORT void Value::set<IntType>(IntType value);
196-
template <> GRAPHQLRESPONSE_EXPORT void Value::set<FloatType>(FloatType value);
197-
template <> GRAPHQLRESPONSE_EXPORT void Value::set<ScalarType>(ScalarType&& value);
198-
template <> GRAPHQLRESPONSE_EXPORT const MapType& Value::get<MapType>() const;
199-
template <> GRAPHQLRESPONSE_EXPORT const ListType& Value::get<ListType>() const;
200-
template <> GRAPHQLRESPONSE_EXPORT const StringType& Value::get<StringType>() const;
201-
template <> GRAPHQLRESPONSE_EXPORT BooleanType Value::get<BooleanType>() const;
202-
template <> GRAPHQLRESPONSE_EXPORT IntType Value::get<IntType>() const;
203-
template <> GRAPHQLRESPONSE_EXPORT FloatType Value::get<FloatType>() const;
204-
template <> GRAPHQLRESPONSE_EXPORT const ScalarType& Value::get<ScalarType>() const;
205-
template <> GRAPHQLRESPONSE_EXPORT MapType Value::release<MapType>();
206-
template <> GRAPHQLRESPONSE_EXPORT ListType Value::release<ListType>();
207-
template <> GRAPHQLRESPONSE_EXPORT StringType Value::release<StringType>();
208-
template <> GRAPHQLRESPONSE_EXPORT ScalarType Value::release<ScalarType>();
203+
template <>
204+
GRAPHQLRESPONSE_EXPORT void Value::set<StringType>(StringType&& value);
205+
template <>
206+
GRAPHQLRESPONSE_EXPORT void Value::set<BooleanType>(BooleanType value);
207+
template <>
208+
GRAPHQLRESPONSE_EXPORT void Value::set<IntType>(IntType value);
209+
template <>
210+
GRAPHQLRESPONSE_EXPORT void Value::set<FloatType>(FloatType value);
211+
template <>
212+
GRAPHQLRESPONSE_EXPORT void Value::set<ScalarType>(ScalarType&& value);
213+
template <>
214+
GRAPHQLRESPONSE_EXPORT const MapType& Value::get<MapType>() const;
215+
template <>
216+
GRAPHQLRESPONSE_EXPORT const ListType& Value::get<ListType>() const;
217+
template <>
218+
GRAPHQLRESPONSE_EXPORT const StringType& Value::get<StringType>() const;
219+
template <>
220+
GRAPHQLRESPONSE_EXPORT BooleanType Value::get<BooleanType>() const;
221+
template <>
222+
GRAPHQLRESPONSE_EXPORT IntType Value::get<IntType>() const;
223+
template <>
224+
GRAPHQLRESPONSE_EXPORT FloatType Value::get<FloatType>() const;
225+
template <>
226+
GRAPHQLRESPONSE_EXPORT const ScalarType& Value::get<ScalarType>() const;
227+
template <>
228+
GRAPHQLRESPONSE_EXPORT MapType Value::release<MapType>();
229+
template <>
230+
GRAPHQLRESPONSE_EXPORT ListType Value::release<ListType>();
231+
template <>
232+
GRAPHQLRESPONSE_EXPORT StringType Value::release<StringType>();
233+
template <>
234+
GRAPHQLRESPONSE_EXPORT ScalarType Value::release<ScalarType>();
209235
#endif // GRAPHQL_DLLEXPORTS
210236

211237
} /* namespace graphql::response */

0 commit comments

Comments
 (0)