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,9 +1,9 @@
#include "TechniqueNoScopeSequences.h"
#include <cassert>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include <cassert>
using namespace techset;
namespace techset
@ -15,9 +15,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('{')
});
AddMatchers({create.Char('{')});
}
protected:
@ -29,13 +27,11 @@ namespace techset
state->m_acceptor->AcceptNextPass();
}
};
}
} // namespace techset
const std::vector<TechniqueParser::sequence_t*>& TechniqueNoScopeSequences::GetSequences()
{
static std::vector<TechniqueParser::sequence_t*> tests({
new SequencePass()
});
static std::vector<TechniqueParser::sequence_t*> tests({new SequencePass()});
return tests;
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <vector>
#include "Techset/Parsing/TechniqueFileParser.h"
#include <vector>
namespace techset
{
class TechniqueNoScopeSequences
@ -12,4 +12,4 @@ namespace techset
public:
static const std::vector<TechniqueParser::sequence_t*>& GetSequences();
};
}
} // namespace techset

View File

@ -1,10 +1,10 @@
#include "TechniquePassScopeSequences.h"
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include <cassert>
#include <sstream>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
using namespace techset;
namespace techset
@ -18,9 +18,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('}').Capture(CAPTURE_FIRST_TOKEN)
});
AddMatchers({create.Char('}').Capture(CAPTURE_FIRST_TOKEN)});
}
protected:
@ -46,11 +44,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("stateMap").Capture(CAPTURE_START),
create.String().Capture(CAPTURE_STATE_MAP_NAME),
create.Char(';')
});
AddMatchers({create.Keyword("stateMap").Capture(CAPTURE_START), create.String().Capture(CAPTURE_STATE_MAP_NAME), create.Char(';')});
}
protected:
@ -82,23 +76,21 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Or({
create.Keyword("vertexShader").Tag(TAG_VERTEX_SHADER),
create.Keyword("pixelShader").Tag(TAG_PIXEL_SHADER),
}).Capture(CAPTURE_START),
create.Or({
create.And({
create.Integer().Capture(CAPTURE_VERSION_MAJOR),
create.Char('.'),
create.Integer().Capture(CAPTURE_VERSION_MINOR),
}),
create.FloatingPoint().Capture(CAPTURE_VERSION), // This is dumb but cod devs made the format so cannot change it
create.String().Capture(CAPTURE_VERSION)
}),
create.String().Capture(CAPTURE_SHADER_NAME),
create.Char('{')
});
AddMatchers({create
.Or({
create.Keyword("vertexShader").Tag(TAG_VERTEX_SHADER),
create.Keyword("pixelShader").Tag(TAG_PIXEL_SHADER),
})
.Capture(CAPTURE_START),
create.Or({create.And({
create.Integer().Capture(CAPTURE_VERSION_MAJOR),
create.Char('.'),
create.Integer().Capture(CAPTURE_VERSION_MINOR),
}),
create.FloatingPoint().Capture(CAPTURE_VERSION), // This is dumb but cod devs made the format so cannot change it
create.String().Capture(CAPTURE_VERSION)}),
create.String().Capture(CAPTURE_SHADER_NAME),
create.Char('{')});
}
protected:
@ -145,29 +137,19 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Keyword("vertex").Capture(CAPTURE_FIRST_TOKEN),
create.Char('.'),
create.Identifier().Capture(CAPTURE_STREAM_DESTINATION_NAME),
create.Optional(create.And({
create.Char('['),
create.Integer().Capture(CAPTURE_STREAM_DESTINATION_INDEX),
create.Char(']')
})),
AddMatchers({create.Keyword("vertex").Capture(CAPTURE_FIRST_TOKEN),
create.Char('.'),
create.Identifier().Capture(CAPTURE_STREAM_DESTINATION_NAME),
create.Optional(create.And({create.Char('['), create.Integer().Capture(CAPTURE_STREAM_DESTINATION_INDEX), create.Char(']')})),
create.Char('='),
create.Char('='),
create.Keyword("code"),
create.Char('.'),
create.Identifier().Capture(CAPTURE_STREAM_SOURCE_NAME),
create.Optional(create.And({
create.Char('['),
create.Integer().Capture(CAPTURE_STREAM_SOURCE_INDEX),
create.Char(']')
})),
create.Keyword("code"),
create.Char('.'),
create.Identifier().Capture(CAPTURE_STREAM_SOURCE_NAME),
create.Optional(create.And({create.Char('['), create.Integer().Capture(CAPTURE_STREAM_SOURCE_INDEX), create.Char(']')})),
create.Char(';')
});
create.Char(';')});
}
static std::string CreateRoutingString(SequenceResult<SimpleParserValue>& result, const int nameCapture, const int indexCapture)
@ -198,16 +180,12 @@ namespace techset
throw ParsingException(firstToken.GetPos(), std::move(errorMessage));
}
};
}
} // namespace techset
const std::vector<TechniqueParser::sequence_t*>& TechniquePassScopeSequences::GetSequences()
{
static std::vector<TechniqueParser::sequence_t*> tests({
new SequenceEndPass(),
new SequenceStateMap(),
new SequenceShader(),
new SequenceVertexStreamRouting()
});
static std::vector<TechniqueParser::sequence_t*> tests(
{new SequenceEndPass(), new SequenceStateMap(), new SequenceShader(), new SequenceVertexStreamRouting()});
return tests;
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <vector>
#include "Techset/Parsing/TechniqueFileParser.h"
#include <vector>
namespace techset
{
class TechniquePassScopeSequences
@ -12,4 +12,4 @@ namespace techset
public:
static const std::vector<TechniqueParser::sequence_t*>& GetSequences();
};
}
} // namespace techset

View File

@ -1,9 +1,9 @@
#include "TechniqueShaderScopeSequences.h"
#include <cassert>
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include <cassert>
using namespace techset;
namespace techset
@ -15,9 +15,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Char('}')
});
AddMatchers({create.Char('}')});
}
protected:
@ -46,63 +44,45 @@ namespace techset
static std::unique_ptr<matcher_t> CodeMatchers(const SimpleMatcherFactory& create)
{
return create.And({
create.Or({
create.Keyword("constant").Tag(TAG_CONSTANT),
create.Keyword("sampler").Tag(TAG_SAMPLER)
}),
create.Char('.'),
create.Identifier().Capture(CAPTURE_CODE_ACCESSOR),
create.OptionalLoop(create.And({
create.Char('.'),
create.Identifier().Capture(CAPTURE_CODE_ACCESSOR)
})),
create.Optional(create.And({
create.Char('['),
create.Integer().Capture(CAPTURE_CODE_INDEX),
create.Char(']')
}))
});
return create.And({create.Or({create.Keyword("constant").Tag(TAG_CONSTANT), create.Keyword("sampler").Tag(TAG_SAMPLER)}),
create.Char('.'),
create.Identifier().Capture(CAPTURE_CODE_ACCESSOR),
create.OptionalLoop(create.And({create.Char('.'), create.Identifier().Capture(CAPTURE_CODE_ACCESSOR)})),
create.Optional(create.And({create.Char('['), create.Integer().Capture(CAPTURE_CODE_INDEX), create.Char(']')}))});
}
static std::unique_ptr<matcher_t> LiteralValueMatchers(const SimpleMatcherFactory& create)
{
return create.Or({
create.FloatingPoint(),
create.Integer()
}).Capture(CAPTURE_LITERAL_VALUE);
return create.Or({create.FloatingPoint(), create.Integer()}).Capture(CAPTURE_LITERAL_VALUE);
}
static std::unique_ptr<matcher_t> LiteralMatchers(const SimpleMatcherFactory& create)
{
return create.And({
create.Keyword("float4"),
create.Char('('),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(')'),
}).Tag(TAG_LITERAL);
return create
.And({
create.Keyword("float4"),
create.Char('('),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(','),
LiteralValueMatchers(create),
create.Char(')'),
})
.Tag(TAG_LITERAL);
}
static std::unique_ptr<matcher_t> MaterialMatchers(const SimpleMatcherFactory& create)
{
return create.And({
create.Keyword("material"),
create.Char('.'),
return create
.And({create.Keyword("material"),
create.Char('.'),
create.Or({
create.And({
create.Char('#'),
create.Integer().Capture(CAPTURE_MATERIAL_HASH)
}),
create.Identifier().Capture(CAPTURE_MATERIAL_NAME)
})
}).Tag(TAG_MATERIAL);
create.Or({create.And({create.Char('#'), create.Integer().Capture(CAPTURE_MATERIAL_HASH)}),
create.Identifier().Capture(CAPTURE_MATERIAL_NAME)})})
.Tag(TAG_MATERIAL);
}
public:
@ -110,22 +90,12 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Identifier().Capture(CAPTURE_FIRST_TOKEN).NoConsume(),
create.Identifier().Capture(CAPTURE_SHADER_ARGUMENT),
create.Optional(create.And({
create.Char('['),
create.Integer().Capture(CAPTURE_SHADER_INDEX),
create.Char(']')
})),
create.Char('='),
create.Or({
CodeMatchers(create),
LiteralMatchers(create),
MaterialMatchers(create)
}),
create.Char(';')
});
AddMatchers({create.Identifier().Capture(CAPTURE_FIRST_TOKEN).NoConsume(),
create.Identifier().Capture(CAPTURE_SHADER_ARGUMENT),
create.Optional(create.And({create.Char('['), create.Integer().Capture(CAPTURE_SHADER_INDEX), create.Char(']')})),
create.Char('='),
create.Or({CodeMatchers(create), LiteralMatchers(create), MaterialMatchers(create)}),
create.Char(';')});
}
static void ProcessCodeArgument(const TechniqueParserState* state, SequenceResult<SimpleParserValue>& result, ShaderArgument arg, const bool isSampler)
@ -146,7 +116,7 @@ namespace techset
source = ShaderArgumentCodeSource(std::move(accessors));
std::string errorMessage;
if(!isSampler)
if (!isSampler)
{
if (!state->m_acceptor->AcceptShaderConstantArgument(state->m_current_shader, std::move(arg), std::move(source), errorMessage))
throw ParsingException(result.NextCapture(CAPTURE_FIRST_TOKEN).GetPos(), std::move(errorMessage));
@ -223,14 +193,11 @@ namespace techset
ProcessMaterialArgument(state, result, std::move(arg));
}
};
}
} // namespace techset
const std::vector<TechniqueParser::sequence_t*>& TechniqueShaderScopeSequences::GetSequences()
{
static std::vector<TechniqueParser::sequence_t*> tests({
new SequenceEndShader(),
new SequenceShaderArgument()
});
static std::vector<TechniqueParser::sequence_t*> tests({new SequenceEndShader(), new SequenceShaderArgument()});
return tests;
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <vector>
#include "Techset/Parsing/TechniqueFileParser.h"
#include <vector>
namespace techset
{
class TechniqueShaderScopeSequences
@ -12,4 +12,4 @@ namespace techset
public:
static const std::vector<TechniqueParser::sequence_t*>& GetSequences();
};
}
} // namespace techset

View File

@ -1,9 +1,9 @@
#pragma once
#include "TechniqueFileParserState.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Impl/AbstractParser.h"
#include "TechniqueFileParserState.h"
namespace techset
{
@ -15,4 +15,4 @@ namespace techset
public:
TechniqueParser(SimpleLexer* lexer, ITechniqueDefinitionAcceptor* acceptor);
};
}
} // namespace techset

View File

@ -8,11 +8,11 @@ namespace techset
{
public:
ITechniqueDefinitionAcceptor* const m_acceptor;
bool m_in_pass;
bool m_in_shader;
ShaderSelector m_current_shader;
explicit TechniqueParserState(ITechniqueDefinitionAcceptor* acceptor);
};
}
} // namespace techset

View File

@ -15,10 +15,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.String().Capture(CAPTURE_TYPE_NAME),
create.Char(':')
});
AddMatchers({create.String().Capture(CAPTURE_TYPE_NAME), create.Char(':')});
}
protected:
@ -43,13 +40,7 @@ namespace techset
{
const SimpleMatcherFactory create(this);
AddMatchers({
create.Or({
create.Identifier(),
create.String()
}).Capture(CAPTURE_NAME),
create.Char(';')
});
AddMatchers({create.Or({create.Identifier(), create.String()}).Capture(CAPTURE_NAME), create.Char(';')});
}
protected:
@ -58,16 +49,15 @@ namespace techset
assert(!state->m_current_technique_types.empty());
const auto& techniqueNameToken = result.NextCapture(CAPTURE_NAME);
const auto& techniqueName = techniqueNameToken.m_type == SimpleParserValueType::STRING
? techniqueNameToken.StringValue()
: techniqueNameToken.IdentifierValue();
const auto& techniqueName =
techniqueNameToken.m_type == SimpleParserValueType::STRING ? techniqueNameToken.StringValue() : techniqueNameToken.IdentifierValue();
for (const auto techniqueTypeIndex : state->m_current_technique_types)
state->m_definition->SetTechniqueByIndex(techniqueTypeIndex, techniqueName);
state->m_current_technique_types.clear();
}
};
}
} // namespace techset
TechsetParser::TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
: AbstractParser(lexer, std::make_unique<TechsetParserState>(validTechniqueTypeNames, validTechniqueTypeNameCount))
@ -76,13 +66,8 @@ TechsetParser::TechsetParser(SimpleLexer* lexer, const char** validTechniqueType
const std::vector<TechsetParser::sequence_t*>& TechsetParser::GetTestsForState()
{
static std::vector<sequence_t*> allTests({
new SequenceTechniqueTypeName(),
new SequenceTechniqueName()
});
static std::vector<sequence_t*> techniqueTypeNameOnlyTests({
new SequenceTechniqueTypeName()
});
static std::vector<sequence_t*> allTests({new SequenceTechniqueTypeName(), new SequenceTechniqueName()});
static std::vector<sequence_t*> techniqueTypeNameOnlyTests({new SequenceTechniqueTypeName()});
return m_state->m_current_technique_types.empty() ? techniqueTypeNameOnlyTests : allTests;
}

View File

@ -1,11 +1,11 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "TechsetFileParserState.h"
#include "Techset/TechsetDefinition.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Impl/AbstractParser.h"
#include "Techset/TechsetDefinition.h"
#include "TechsetFileParserState.h"
#include "Utils/ClassUtils.h"
namespace techset
{
@ -18,4 +18,4 @@ namespace techset
TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
_NODISCARD std::unique_ptr<TechsetDefinition> GetTechsetDefinition() const;
};
}
} // namespace techset

View File

@ -1,11 +1,11 @@
#pragma once
#include "Techset/TechsetDefinition.h"
#include <map>
#include <memory>
#include <string>
#include "Techset/TechsetDefinition.h"
namespace techset
{
class TechsetParserState
@ -19,4 +19,4 @@ namespace techset
bool FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const;
};
}
} // namespace techset

View File

@ -94,7 +94,7 @@ namespace techset
{
return !(lhs < rhs);
}
}
} // namespace techset
ShaderArgumentMaterialSource::ShaderArgumentMaterialSource()
: m_is_hash(false),

View File

@ -66,6 +66,7 @@ namespace techset
{
protected:
ITechniqueDefinitionAcceptor() = default;
public:
virtual ~ITechniqueDefinitionAcceptor() = default;
ITechniqueDefinitionAcceptor(const ITechniqueDefinitionAcceptor& other) = default;
@ -81,11 +82,19 @@ namespace techset
virtual bool AcceptVertexShader(const std::string& vertexShaderName, std::string& errorMessage) = 0;
virtual bool AcceptPixelShader(const std::string& pixelShaderName, std::string& errorMessage) = 0;
virtual bool AcceptShaderConstantArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
virtual bool AcceptShaderSamplerArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
virtual bool AcceptShaderLiteralArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentLiteralSource source, std::string& errorMessage) = 0;
virtual bool AcceptShaderMaterialArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentMaterialSource source, std::string& errorMessage) = 0;
virtual bool
AcceptShaderConstantArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
virtual bool
AcceptShaderSamplerArgument(ShaderSelector shader, ShaderArgument shaderArgument, ShaderArgumentCodeSource source, std::string& errorMessage) = 0;
virtual bool AcceptShaderLiteralArgument(ShaderSelector shader,
ShaderArgument shaderArgument,
ShaderArgumentLiteralSource source,
std::string& errorMessage) = 0;
virtual bool AcceptShaderMaterialArgument(ShaderSelector shader,
ShaderArgument shaderArgument,
ShaderArgumentMaterialSource source,
std::string& errorMessage) = 0;
virtual bool AcceptVertexStreamRouting(const std::string& destination, const std::string& source, std::string& errorMessage) = 0;
};
}
} // namespace techset

View File

@ -1,11 +1,11 @@
#include "TechniqueFileReader.h"
#include <iostream>
#include "Parsing/TechniqueFileParser.h"
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Impl/ParserSingleInputStream.h"
#include "Parsing/Simple/SimpleLexer.h"
#include "Parsing/TechniqueFileParser.h"
#include <iostream>
using namespace techset;

View File

@ -1,12 +1,12 @@
#pragma once
#include "Parsing/IParserLineStream.h"
#include "TechniqueDefinitionAcceptor.h"
#include "Utils/ClassUtils.h"
#include <memory>
#include <string>
#include "Utils/ClassUtils.h"
#include "TechniqueDefinitionAcceptor.h"
#include "Parsing/IParserLineStream.h"
namespace techset
{
class TechniqueFileReader
@ -21,4 +21,4 @@ namespace techset
_NODISCARD bool ReadTechniqueDefinition() const;
};
}
} // namespace techset

View File

@ -1,13 +1,13 @@
#pragma once
#include "AssetLoading/IZoneAssetLoaderState.h"
#include "StateMap/StateMapDefinition.h"
#include "Utils/ClassUtils.h"
#include <memory>
#include <string>
#include <unordered_map>
#include "AssetLoading/IZoneAssetLoaderState.h"
#include "Utils/ClassUtils.h"
#include "StateMap/StateMapDefinition.h"
namespace techset
{
class TechniqueStateMapCache final : public IZoneAssetLoaderState
@ -23,4 +23,4 @@ namespace techset
std::unordered_map<std::string, const state_map::StateMapDefinition*> m_state_map_per_technique;
std::unordered_map<std::string, std::unique_ptr<state_map::StateMapDefinition>> m_state_map_cache;
};
}
} // namespace techset

View File

@ -15,4 +15,4 @@ namespace techset
bool GetTechniqueByIndex(size_t index, std::string& techniqueName) const;
void SetTechniqueByIndex(size_t index, std::string techniqueName);
};
}
} // namespace techset

View File

@ -1,12 +1,12 @@
#pragma once
#include <unordered_map>
#include <string>
#include <memory>
#include "Utils/ClassUtils.h"
#include "TechsetDefinition.h"
#include "AssetLoading/IZoneAssetLoaderState.h"
#include "TechsetDefinition.h"
#include "Utils/ClassUtils.h"
#include <memory>
#include <string>
#include <unordered_map>
namespace techset
{
@ -19,4 +19,4 @@ namespace techset
private:
std::unordered_map<std::string, std::unique_ptr<TechsetDefinition>> m_cache;
};
}
} // namespace techset

View File

@ -1,10 +1,10 @@
#include "TechsetFileReader.h"
#include <iostream>
#include "Parsing/TechsetFileParser.h"
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Impl/ParserSingleInputStream.h"
#include "Parsing/TechsetFileParser.h"
#include <iostream>
using namespace techset;

View File

@ -1,12 +1,12 @@
#pragma once
#include "Parsing/IParserLineStream.h"
#include "TechsetDefinition.h"
#include "Utils/ClassUtils.h"
#include <memory>
#include <string>
#include "Utils/ClassUtils.h"
#include "TechsetDefinition.h"
#include "Parsing/IParserLineStream.h"
namespace techset
{
class TechsetFileReader
@ -22,4 +22,4 @@ namespace techset
_NODISCARD std::unique_ptr<TechsetDefinition> ReadTechsetDefinition() const;
};
}
} // namespace techset