Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,10 +1,10 @@
#include "StructuredDataDefScopeSequences.h"
#include <sstream>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "StructuredDataDef/Parsing/StructuredDataDefSizeCalculator.h"
#include <sstream>
namespace sdd::def_scope_sequences
{
class SequenceEnum final : public StructuredDataDefParser::sequence_t
@ -17,16 +17,10 @@ namespace sdd::def_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("enum"),
create.Optional(create.And({
create.Char('('),
create.Integer().Capture(CAPTURE_RESERVED_COUNT),
create.Char(')')
})),
create.Identifier().Capture(CAPTURE_NAME),
create.Char('{')
});
AddMatchers({create.Keyword("enum"),
create.Optional(create.And({create.Char('('), create.Integer().Capture(CAPTURE_RESERVED_COUNT), create.Char(')')})),
create.Identifier().Capture(CAPTURE_NAME),
create.Char('{')});
}
protected:
@ -76,11 +70,7 @@ namespace sdd::def_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("struct"),
create.Identifier().Capture(CAPTURE_NAME),
create.Char('{')
});
AddMatchers({create.Keyword("struct"), create.Identifier().Capture(CAPTURE_NAME), create.Char('{')});
}
protected:
@ -136,11 +126,7 @@ namespace sdd::def_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("checksumoverride"),
create.Integer().Capture(CAPTURE_VALUE),
create.Char(';')
});
AddMatchers({create.Keyword("checksumoverride"), create.Integer().Capture(CAPTURE_VALUE), create.Char(';')});
}
protected:
@ -162,9 +148,7 @@ namespace sdd::def_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('}')
});
AddMatchers({create.Char('}')});
}
private:
@ -179,7 +163,7 @@ namespace sdd::def_scope_sequences
static void EnsureAllUsedTypesHaveBeenDefined(const StructuredDataDefParserState* state)
{
for(const auto& undefinedType : state->m_undefined_types)
for (const auto& undefinedType : state->m_undefined_types)
{
if (undefinedType.m_mapped_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
{
@ -194,11 +178,11 @@ namespace sdd::def_scope_sequences
{
auto& def = *state->m_current_def;
for(const auto& _struct : def.m_structs)
for (const auto& _struct : def.m_structs)
{
for(auto& property : _struct->m_properties)
for (auto& property : _struct->m_properties)
{
if(property.m_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
if (property.m_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
{
assert(property.m_type.m_info.type_index < state->m_undefined_types.size());
const auto& undefinedType = state->m_undefined_types[property.m_type.m_info.type_index];
@ -207,9 +191,9 @@ namespace sdd::def_scope_sequences
}
}
for(auto& indexedArray : def.m_indexed_arrays)
for (auto& indexedArray : def.m_indexed_arrays)
{
if(indexedArray.m_array_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
if (indexedArray.m_array_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
{
assert(indexedArray.m_array_type.m_info.type_index < state->m_undefined_types.size());
const auto& undefinedType = state->m_undefined_types[indexedArray.m_array_type.m_info.type_index];
@ -217,9 +201,9 @@ namespace sdd::def_scope_sequences
}
}
for(auto& enumedArray : def.m_enumed_arrays)
for (auto& enumedArray : def.m_enumed_arrays)
{
if(enumedArray.m_array_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
if (enumedArray.m_array_type.m_category == CommonStructuredDataTypeCategory::UNKNOWN)
{
assert(enumedArray.m_array_type.m_info.type_index < state->m_undefined_types.size());
const auto& undefinedType = state->m_undefined_types[enumedArray.m_array_type.m_info.type_index];
@ -234,7 +218,7 @@ namespace sdd::def_scope_sequences
{
StructuredDataDefSizeCalculator::CalculateSizesAndOffsetsForDef(*state->m_current_def);
}
catch(SizeCalculationException& e)
catch (SizeCalculationException& e)
{
throw ParsingException(TokenPos(), e.Message());
}
@ -275,7 +259,7 @@ namespace sdd::def_scope_sequences
state->m_checksum_override_value = 0u;
}
};
}
} // namespace sdd::def_scope_sequences
using namespace sdd;
using namespace def_scope_sequences;

View File

@ -8,8 +8,9 @@ namespace sdd
class StructuredDataDefScopeSequences final : AbstractScopeSequenceHolder<StructuredDataDefParser>
{
public:
StructuredDataDefScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences, std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
StructuredDataDefScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
void AddSequences() const;
};
}
} // namespace sdd

View File

@ -1,9 +1,9 @@
#include "StructuredDataEnumScopeSequences.h"
#include <algorithm>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include <algorithm>
namespace sdd::enum_scope_sequences
{
class SequenceEnumEntry final : public StructuredDataDefParser::sequence_t
@ -15,13 +15,7 @@ namespace sdd::enum_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.String().Capture(CAPTURE_ENTRY_VALUE),
create.Or({
create.Char(','),
create.Char('}').NoConsume()
})
});
AddMatchers({create.String().Capture(CAPTURE_ENTRY_VALUE), create.Or({create.Char(','), create.Char('}').NoConsume()})});
}
protected:
@ -30,7 +24,8 @@ namespace sdd::enum_scope_sequences
assert(state->m_current_enum);
const auto& entryValueToken = result.NextCapture(CAPTURE_ENTRY_VALUE);
if (state->m_current_enum->m_reserved_entry_count > 0 && static_cast<size_t>(state->m_current_enum->m_reserved_entry_count) <= state->m_current_enum->m_entries.size())
if (state->m_current_enum->m_reserved_entry_count > 0
&& static_cast<size_t>(state->m_current_enum->m_reserved_entry_count) <= state->m_current_enum->m_entries.size())
throw ParsingException(entryValueToken.GetPos(), "Enum entry count exceeds reserved count");
state->m_current_enum->m_entries.emplace_back(entryValueToken.StringValue(), state->m_current_enum->m_entries.size());
@ -44,10 +39,7 @@ namespace sdd::enum_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('}'),
create.Optional(create.Char(';'))
});
AddMatchers({create.Char('}'), create.Optional(create.Char(';'))});
}
protected:
@ -57,13 +49,13 @@ namespace sdd::enum_scope_sequences
state->m_current_enum = nullptr;
}
};
}
} // namespace sdd::enum_scope_sequences
using namespace sdd;
using namespace enum_scope_sequences;
StructuredDataEnumScopeSequences::StructuredDataEnumScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences)
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}

View File

@ -8,8 +8,9 @@ namespace sdd
class StructuredDataEnumScopeSequences final : AbstractScopeSequenceHolder<StructuredDataDefParser>
{
public:
StructuredDataEnumScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences, std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
StructuredDataEnumScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
void AddSequences() const;
};
}
} // namespace sdd

View File

@ -13,11 +13,7 @@ namespace sdd::no_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("version"),
create.Integer().Capture(CAPTURE_VERSION),
create.Char('{')
});
AddMatchers({create.Keyword("version"), create.Integer().Capture(CAPTURE_VERSION), create.Char('{')});
}
protected:
@ -28,13 +24,13 @@ namespace sdd::no_scope_sequences
state->m_defs.emplace_back(std::move(newDef));
}
};
}
} // namespace sdd::no_scope_sequences
using namespace sdd;
using namespace no_scope_sequences;
StructuredDataNoScopeSequences::StructuredDataNoScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences)
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences)
: AbstractScopeSequenceHolder(allSequences, scopeSequences)
{
}

View File

@ -8,8 +8,9 @@ namespace sdd
class StructuredDataNoScopeSequences final : AbstractScopeSequenceHolder<StructuredDataDefParser>
{
public:
StructuredDataNoScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences, std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
StructuredDataNoScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
void AddSequences() const;
};
}
} // namespace sdd

View File

@ -1,10 +1,10 @@
#include "StructuredDataStructScopeSequences.h"
#include <algorithm>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "Utils/Alignment.h"
#include <algorithm>
namespace sdd::struct_scope_sequences
{
class SequenceStructEntry final : public StructuredDataDefParser::sequence_t
@ -24,32 +24,21 @@ namespace sdd::struct_scope_sequences
static std::unique_ptr<matcher_t> TypeMatchers(const SimpleMatcherFactory& create)
{
return create.Or({
create.Keyword("int").Tag(TAG_TYPE_INT),
create.Keyword("byte").Tag(TAG_TYPE_BYTE),
create.Keyword("bool").Tag(TAG_TYPE_BOOL),
create.Keyword("float").Tag(TAG_TYPE_FLOAT),
create.Keyword("short").Tag(TAG_TYPE_SHORT),
create.And({
create.Keyword("string"),
create.Char('('),
create.Integer().Capture(CAPTURE_STRING_LENGTH),
create.Char(')')
}).Tag(TAG_TYPE_STRING),
create.Identifier().Tag(TAG_TYPE_NAMED).Capture(CAPTURE_TYPE_NAME)
});
return create.Or({create.Keyword("int").Tag(TAG_TYPE_INT),
create.Keyword("byte").Tag(TAG_TYPE_BYTE),
create.Keyword("bool").Tag(TAG_TYPE_BOOL),
create.Keyword("float").Tag(TAG_TYPE_FLOAT),
create.Keyword("short").Tag(TAG_TYPE_SHORT),
create.And({create.Keyword("string"), create.Char('('), create.Integer().Capture(CAPTURE_STRING_LENGTH), create.Char(')')})
.Tag(TAG_TYPE_STRING),
create.Identifier().Tag(TAG_TYPE_NAMED).Capture(CAPTURE_TYPE_NAME)});
}
static std::unique_ptr<matcher_t> ArrayMatchers(const SimpleMatcherFactory& create)
{
return create.And({
create.Char('['),
create.Or({
create.Integer().Capture(CAPTURE_ARRAY_SIZE),
create.Identifier().Capture(CAPTURE_ARRAY_SIZE)
}),
create.Char(']')
});
return create.And({create.Char('['),
create.Or({create.Integer().Capture(CAPTURE_ARRAY_SIZE), create.Identifier().Capture(CAPTURE_ARRAY_SIZE)}),
create.Char(']')});
}
public:
@ -57,12 +46,7 @@ namespace sdd::struct_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
TypeMatchers(create),
create.Identifier().Capture(CAPTURE_ENTRY_NAME),
create.OptionalLoop(ArrayMatchers(create)),
create.Char(';')
});
AddMatchers({TypeMatchers(create), create.Identifier().Capture(CAPTURE_ENTRY_NAME), create.OptionalLoop(ArrayMatchers(create)), create.Char(';')});
}
private:
@ -83,38 +67,39 @@ namespace sdd::struct_scope_sequences
case TAG_TYPE_SHORT:
return CommonStructuredDataType(CommonStructuredDataTypeCategory::SHORT);
case TAG_TYPE_STRING:
{
const auto& stringLengthToken = result.NextCapture(CAPTURE_STRING_LENGTH);
const auto stringLength = stringLengthToken.IntegerValue();
{
const auto& stringLengthToken = result.NextCapture(CAPTURE_STRING_LENGTH);
const auto stringLength = stringLengthToken.IntegerValue();
if (stringLength <= 0)
throw ParsingException(stringLengthToken.GetPos(), "String length must be greater than zero");
if (stringLength <= 0)
throw ParsingException(stringLengthToken.GetPos(), "String length must be greater than zero");
return {CommonStructuredDataTypeCategory::STRING, static_cast<size_t>(stringLength)};
}
return {CommonStructuredDataTypeCategory::STRING, static_cast<size_t>(stringLength)};
}
case TAG_TYPE_NAMED:
{
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE_NAME);
const auto typeName = typeNameToken.IdentifierValue();
const auto existingType = state->m_def_types_by_name.find(typeName);
if (existingType == state->m_def_types_by_name.end())
{
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE_NAME);
const auto typeName = typeNameToken.IdentifierValue();
const auto existingType = state->m_def_types_by_name.find(typeName);
if (existingType == state->m_def_types_by_name.end())
{
const auto undefinedTypeIndex = state->m_undefined_types.size();
const CommonStructuredDataType undefinedType(CommonStructuredDataTypeCategory::UNKNOWN, undefinedTypeIndex);
state->m_undefined_types.emplace_back(typeName, typeNameToken.GetPos());
state->m_def_types_by_name.emplace(std::make_pair(typeName, undefinedType));
return undefinedType;
}
return existingType->second;
const auto undefinedTypeIndex = state->m_undefined_types.size();
const CommonStructuredDataType undefinedType(CommonStructuredDataTypeCategory::UNKNOWN, undefinedTypeIndex);
state->m_undefined_types.emplace_back(typeName, typeNameToken.GetPos());
state->m_def_types_by_name.emplace(std::make_pair(typeName, undefinedType));
return undefinedType;
}
return existingType->second;
}
default:
throw ParsingException(TokenPos(), "Invalid Tag for Type @ ProcessType!!!");
}
}
static CommonStructuredDataType ProcessArray(StructuredDataDefParserState* state, const SimpleParserValue& arrayToken, const CommonStructuredDataType currentType)
static CommonStructuredDataType
ProcessArray(StructuredDataDefParserState* state, const SimpleParserValue& arrayToken, const CommonStructuredDataType currentType)
{
if (arrayToken.m_type == SimpleParserValueType::INTEGER)
{
@ -179,7 +164,8 @@ namespace sdd::struct_scope_sequences
for (auto i = arrayTokens.rbegin(); i != arrayTokens.rend(); ++i)
currentType = ProcessArray(state, i->get(), currentType);
state->m_current_struct->m_properties.emplace_back(result.NextCapture(CAPTURE_ENTRY_NAME).IdentifierValue(), currentType, state->m_current_struct_padding_offset);
state->m_current_struct->m_properties.emplace_back(
result.NextCapture(CAPTURE_ENTRY_NAME).IdentifierValue(), currentType, state->m_current_struct_padding_offset);
}
};
@ -192,13 +178,7 @@ namespace sdd::struct_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("pad"),
create.Char('('),
create.Integer().Capture(CAPTURE_PADDING_VALUE),
create.Char(')'),
create.Char(';')
});
AddMatchers({create.Keyword("pad"), create.Char('('), create.Integer().Capture(CAPTURE_PADDING_VALUE), create.Char(')'), create.Char(';')});
}
protected:
@ -221,10 +201,7 @@ namespace sdd::struct_scope_sequences
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('}'),
create.Optional(create.Char(';'))
});
AddMatchers({create.Char('}'), create.Optional(create.Char(';'))});
}
protected:
@ -242,7 +219,7 @@ namespace sdd::struct_scope_sequences
state->m_current_struct = nullptr;
}
};
}
} // namespace sdd::struct_scope_sequences
using namespace sdd;
using namespace struct_scope_sequences;

View File

@ -8,8 +8,9 @@ namespace sdd
class StructuredDataStructScopeSequences final : AbstractScopeSequenceHolder<StructuredDataDefParser>
{
public:
StructuredDataStructScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences, std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
StructuredDataStructScopeSequences(std::vector<std::unique_ptr<StructuredDataDefParser::sequence_t>>& allSequences,
std::vector<StructuredDataDefParser::sequence_t*>& scopeSequences);
void AddSequences() const;
};
}
} // namespace sdd

View File

@ -1,11 +1,11 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "StructuredDataDefParserState.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Impl/AbstractParser.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "StructuredDataDefParserState.h"
#include "Utils/ClassUtils.h"
namespace sdd
{
@ -16,7 +16,7 @@ namespace sdd
std::vector<sequence_t*> m_def_tests;
std::vector<sequence_t*> m_enum_tests;
std::vector<sequence_t*> m_struct_tests;
void CreateSequenceCollections();
protected:
@ -26,4 +26,4 @@ namespace sdd
explicit StructuredDataDefParser(SimpleLexer* lexer);
_NODISCARD std::vector<std::unique_ptr<CommonStructuredDataDef>> GetDefs() const;
};
}
} // namespace sdd

View File

@ -2,8 +2,7 @@
using namespace sdd;
UndefinedType::UndefinedType()
= default;
UndefinedType::UndefinedType() = default;
UndefinedType::UndefinedType(std::string name, const TokenPos firstUsagePos)
: m_name(std::move(name)),

View File

@ -1,14 +1,14 @@
#pragma once
#include <map>
#include <memory>
#include <vector>
#include <cstddef>
#include <string>
#include "Parsing/TokenPos.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include <cstddef>
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace sdd
{
class UndefinedType
@ -44,4 +44,4 @@ namespace sdd
StructuredDataDefParserState();
};
}
} // namespace sdd

View File

@ -1,11 +1,11 @@
#include "StructuredDataDefSizeCalculator.h"
#include <cassert>
#include <sstream>
#include "Utils/Alignment.h"
#include "Utils/ClassUtils.h"
#include <cassert>
#include <sstream>
using namespace sdd;
SizeCalculationException::SizeCalculationException(std::string message)

View File

@ -1,10 +1,10 @@
#pragma once
#include <string>
#include <exception>
#include "Utils/ClassUtils.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "Utils/ClassUtils.h"
#include <exception>
#include <string>
namespace sdd
{
@ -24,4 +24,4 @@ namespace sdd
public:
static void CalculateSizesAndOffsetsForDef(CommonStructuredDataDef& def);
};
}
} // namespace sdd

View File

@ -1,11 +1,11 @@
#include "StructuredDataDefReader.h"
#include "StructuredDataDef/Parsing/StructuredDataDefParser.h"
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Impl/DefinesStreamProxy.h"
#include "Parsing/Impl/IncludingStreamProxy.h"
#include "Parsing/Impl/ParserMultiInputStream.h"
#include "Parsing/Impl/ParserSingleInputStream.h"
#include "StructuredDataDef/Parsing/StructuredDataDefParser.h"
using namespace sdd;

View File

@ -1,12 +1,12 @@
#pragma once
#include "Parsing/IParserLineStream.h"
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include <memory>
#include <string>
#include <vector>
#include "StructuredDataDef/CommonStructuredDataDef.h"
#include "Parsing/IParserLineStream.h"
class StructuredDataDefReader
{
public: