Use member naming convention for components/fx

This commit is contained in:
Alexei Kotov
2026-07-22 13:48:15 +03:00
parent ea120a9f72
commit 16da7160c7
5 changed files with 107 additions and 107 deletions
+7 -7
View File
@@ -16,7 +16,7 @@ namespace
template <class Token>
void test()
{
const std::string content = std::string(Token::repr);
const std::string content = std::string(Token::mRepresentation);
Lexer lexer(content);
EXPECT_TRUE(std::holds_alternative<Token>(lexer.next()));
@@ -97,7 +97,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<Float>(token));
EXPECT_FLOAT_EQ(std::get<Float>(token).value, 0.123f);
EXPECT_FLOAT_EQ(std::get<Float>(token).mValue, 0.123f);
}
TEST(LexerTest, float_with_alpha_prefix)
@@ -110,7 +110,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<Float>(token));
EXPECT_FLOAT_EQ(std::get<Float>(token).value, 0.123f);
EXPECT_FLOAT_EQ(std::get<Float>(token).mValue, 0.123f);
}
TEST(LexerTest, float_with_numeric_prefix)
@@ -121,7 +121,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<Float>(token));
EXPECT_FLOAT_EQ(std::get<Float>(token).value, 123.123f);
EXPECT_FLOAT_EQ(std::get<Float>(token).mValue, 123.123f);
}
TEST(LexerTest, int_should_not_be_float)
@@ -132,7 +132,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<Integer>(token));
EXPECT_EQ(std::get<Integer>(token).value, 123);
EXPECT_EQ(std::get<Integer>(token).mValue, 123);
}
TEST(LexerTest, float_suffix_should_be_float)
@@ -143,7 +143,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<Float>(token));
EXPECT_FLOAT_EQ(std::get<Float>(token).value, 123.f);
EXPECT_FLOAT_EQ(std::get<Float>(token).mValue, 123.f);
}
TEST(LexerTest, simple_string)
@@ -155,7 +155,7 @@ namespace
auto token = lexer.next();
EXPECT_TRUE(std::holds_alternative<String>(token));
std::string parsed = std::string(std::get<String>(token).value);
std::string parsed = std::string(std::get<String>(token).mValue);
EXPECT_EQ("test string", parsed);
}
+4 -4
View File
@@ -56,12 +56,12 @@ namespace Fx
auto start = mHead;
std::size_t level = 1;
mLastJumpBlock.line = mLine;
mLastJumpBlock.mLine = mLine;
if (head() == '}')
{
mLastJumpBlock.content = {};
return mLastJumpBlock.content;
mLastJumpBlock.mContent = {};
return mLastJumpBlock.mContent;
}
for (; mHead != mTail; advance())
@@ -109,7 +109,7 @@ namespace Fx
mHead--;
mLine--;
auto sv = std::string_view{ start, static_cast<std::string_view::size_type>(mHead + 1 - start) };
mLastJumpBlock.content = sv;
mLastJumpBlock.mContent = sv;
return sv;
}
}
+2 -2
View File
@@ -30,8 +30,8 @@ namespace Fx
public:
struct Block
{
std::size_t line;
std::string_view content;
std::size_t mLine;
std::string_view mContent;
};
Lexer(std::string_view buffer);
+41 -41
View File
@@ -10,152 +10,152 @@ namespace Fx
{
struct Float
{
inline static constexpr std::string_view repr = "float";
float value = 0.0;
inline static constexpr std::string_view mRepresentation = "float";
float mValue = 0.0;
};
struct Integer
{
inline static constexpr std::string_view repr = "integer";
int value = 0;
inline static constexpr std::string_view mRepresentation = "integer";
int mValue = 0;
};
struct Boolean
{
inline static constexpr std::string_view repr = "boolean";
bool value = false;
inline static constexpr std::string_view mRepresentation = "boolean";
bool mValue = false;
};
struct Literal
{
inline static constexpr std::string_view repr = "literal";
std::string_view value;
inline static constexpr std::string_view mRepresentation = "literal";
std::string_view mValue;
};
struct String
{
inline static constexpr std::string_view repr = "string";
std::string_view value;
inline static constexpr std::string_view mRepresentation = "string";
std::string_view mValue;
};
struct Shared
{
inline static constexpr std::string_view repr = "shared";
inline static constexpr std::string_view mRepresentation = "shared";
};
struct Vertex
{
inline static constexpr std::string_view repr = "vertex";
inline static constexpr std::string_view mRepresentation = "vertex";
};
struct Fragment
{
inline static constexpr std::string_view repr = "fragment";
inline static constexpr std::string_view mRepresentation = "fragment";
};
struct Compute
{
inline static constexpr std::string_view repr = "compute";
inline static constexpr std::string_view mRepresentation = "compute";
};
struct Technique
{
inline static constexpr std::string_view repr = "technique";
inline static constexpr std::string_view mRepresentation = "technique";
};
struct Render_Target
{
inline static constexpr std::string_view repr = "render_target";
inline static constexpr std::string_view mRepresentation = "render_target";
};
struct Sampler_1D
{
inline static constexpr std::string_view repr = "sampler_1d";
inline static constexpr std::string_view mRepresentation = "sampler_1d";
};
struct Sampler_2D
{
inline static constexpr std::string_view repr = "sampler_2d";
inline static constexpr std::string_view mRepresentation = "sampler_2d";
};
struct Sampler_3D
{
inline static constexpr std::string_view repr = "sampler_3d";
inline static constexpr std::string_view mRepresentation = "sampler_3d";
};
struct Uniform_Bool
{
inline static constexpr std::string_view repr = "uniform_bool";
inline static constexpr std::string_view mRepresentation = "uniform_bool";
};
struct Uniform_Float
{
inline static constexpr std::string_view repr = "uniform_float";
inline static constexpr std::string_view mRepresentation = "uniform_float";
};
struct Uniform_Int
{
inline static constexpr std::string_view repr = "uniform_int";
inline static constexpr std::string_view mRepresentation = "uniform_int";
};
struct Uniform_Vec2
{
inline static constexpr std::string_view repr = "uniform_vec2";
inline static constexpr std::string_view mRepresentation = "uniform_vec2";
};
struct Uniform_Vec3
{
inline static constexpr std::string_view repr = "uniform_vec3";
inline static constexpr std::string_view mRepresentation = "uniform_vec3";
};
struct Uniform_Vec4
{
inline static constexpr std::string_view repr = "uniform_vec4";
inline static constexpr std::string_view mRepresentation = "uniform_vec4";
};
struct Eof
{
inline static constexpr std::string_view repr = "eof";
inline static constexpr std::string_view mRepresentation = "eof";
};
struct Equal
{
inline static constexpr std::string_view repr = "equal";
inline static constexpr std::string_view mRepresentation = "equal";
};
struct Open_bracket
{
inline static constexpr std::string_view repr = "open_bracket";
inline static constexpr std::string_view mRepresentation = "open_bracket";
};
struct Close_bracket
{
inline static constexpr std::string_view repr = "close_bracket";
inline static constexpr std::string_view mRepresentation = "close_bracket";
};
struct Open_Parenthesis
{
inline static constexpr std::string_view repr = "open_parenthesis";
inline static constexpr std::string_view mRepresentation = "open_parenthesis";
};
struct Close_Parenthesis
{
inline static constexpr std::string_view repr = "close_parenthesis";
inline static constexpr std::string_view mRepresentation = "close_parenthesis";
};
struct Quote
{
inline static constexpr std::string_view repr = "quote";
inline static constexpr std::string_view mRepresentation = "quote";
};
struct SemiColon
{
inline static constexpr std::string_view repr = "semicolon";
inline static constexpr std::string_view mRepresentation = "semicolon";
};
struct Comma
{
inline static constexpr std::string_view repr = "comma";
inline static constexpr std::string_view mRepresentation = "comma";
};
struct VBar
{
inline static constexpr std::string_view repr = "vbar";
inline static constexpr std::string_view mRepresentation = "vbar";
};
struct Colon
{
inline static constexpr std::string_view repr = "colon";
inline static constexpr std::string_view mRepresentation = "colon";
};
struct True
{
inline static constexpr std::string_view repr = "true";
inline static constexpr std::string_view mRepresentation = "true";
};
struct False
{
inline static constexpr std::string_view repr = "false";
inline static constexpr std::string_view mRepresentation = "false";
};
struct Vec2
{
inline static constexpr std::string_view repr = "vec2";
inline static constexpr std::string_view mRepresentation = "vec2";
};
struct Vec3
{
inline static constexpr std::string_view repr = "vec3";
inline static constexpr std::string_view mRepresentation = "vec3";
};
struct Vec4
{
inline static constexpr std::string_view repr = "vec4";
inline static constexpr std::string_view mRepresentation = "vec4";
};
using Token = std::variant<Float, Integer, Boolean, String, Literal, Equal, Open_bracket, Close_bracket,
+53 -53
View File
@@ -24,15 +24,15 @@ namespace
{
struct ProxyTextureData
{
osg::Texture::WrapMode wrap_s = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::WrapMode wrap_t = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::WrapMode wrap_r = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::FilterMode min_filter = osg::Texture::LINEAR_MIPMAP_LINEAR;
osg::Texture::FilterMode mag_filter = osg::Texture::LINEAR;
osg::Texture::InternalFormatMode compression = osg::Texture::USE_IMAGE_DATA_FORMAT;
std::optional<int> source_format;
std::optional<int> source_type;
std::optional<int> internal_format;
osg::Texture::WrapMode mWrapS = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::WrapMode mWrapT = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::WrapMode mWrapR = osg::Texture::CLAMP_TO_EDGE;
osg::Texture::FilterMode mMinFilter = osg::Texture::LINEAR_MIPMAP_LINEAR;
osg::Texture::FilterMode mMagFilter = osg::Texture::LINEAR;
osg::Texture::InternalFormatMode mCompression = osg::Texture::USE_IMAGE_DATA_FORMAT;
std::optional<int> mSourceFormat;
std::optional<int> mSourceType;
std::optional<int> mInternalFormat;
};
}
@@ -92,7 +92,7 @@ namespace Fx
std::string Technique::getBlockWithLineDirective()
{
auto block = mLexer->getLastJumpBlock();
return std::format("\n#line {}\n{}\n", block.line + 1, block.content);
return std::format("\n#line {}\n{}\n", block.mLine + 1, block.mContent);
}
Technique::UniformMap::iterator Technique::findUniform(std::string_view name)
@@ -228,7 +228,7 @@ namespace Fx
{
expect<Lexer::Literal>();
auto key = std::get<Lexer::Literal>(mToken).value;
auto key = std::get<Lexer::Literal>(mToken).mValue;
expect<Lexer::Equal>();
@@ -253,7 +253,7 @@ namespace Fx
else if (key == "glsl_profile")
{
expect<Lexer::String>();
mGLSLProfile = std::get<Lexer::String>(mToken).value;
mGLSLProfile = std::get<Lexer::String>(mToken).mValue;
}
else if (key == "glsl_extensions")
{
@@ -291,7 +291,7 @@ namespace Fx
{
expect<Lexer::Literal>();
auto key = std::get<Lexer::Literal>(mToken).value;
auto key = std::get<Lexer::Literal>(mToken).mValue;
expect<Lexer::Equal>();
@@ -425,28 +425,28 @@ namespace Fx
expect<Lexer::Equal>();
if (!is1D && key == "min_filter")
proxy.min_filter = parseFilterMode();
proxy.mMinFilter = parseFilterMode();
else if (!is1D && key == "mag_filter")
proxy.mag_filter = parseFilterMode();
proxy.mMagFilter = parseFilterMode();
else if (key == "wrap_s")
proxy.wrap_s = parseWrapMode();
proxy.mWrapS = parseWrapMode();
else if (key == "wrap_t")
proxy.wrap_t = parseWrapMode();
proxy.mWrapT = parseWrapMode();
else if (is3D && key == "wrap_r")
proxy.wrap_r = parseWrapMode();
proxy.mWrapR = parseWrapMode();
else if (key == "compression")
proxy.compression = parseCompression();
proxy.mCompression = parseCompression();
else if (key == "source_type")
proxy.source_type = parseSourceType();
proxy.mSourceType = parseSourceType();
else if (key == "source_format")
proxy.source_format = parseSourceFormat();
proxy.mSourceFormat = parseSourceFormat();
else if (key == "internal_format")
proxy.internal_format = parseInternalFormat();
proxy.mInternalFormat = parseInternalFormat();
else if (key == "source")
{
expect<Lexer::String>();
const osg::ref_ptr<osg::Image> image
= mImageManager.getImage(VFS::Path::Normalized(std::get<Lexer::String>(mToken).value), is3D);
= mImageManager.getImage(VFS::Path::Normalized(std::get<Lexer::String>(mToken).mValue), is3D);
if constexpr (is1D)
{
type = Types::SamplerType::Texture_1D;
@@ -469,24 +469,24 @@ namespace Fx
expect<Lexer::SemiColon>();
}
if (!sampler)
error(std::format("{} '{}' requires a filename", T::repr, mBlockName));
error(std::format("{} '{}' requires a filename", T::mRepresentation, mBlockName));
if (!is1D)
{
sampler->setFilter(osg::Texture::MIN_FILTER, proxy.min_filter);
sampler->setFilter(osg::Texture::MAG_FILTER, proxy.mag_filter);
sampler->setFilter(osg::Texture::MIN_FILTER, proxy.mMinFilter);
sampler->setFilter(osg::Texture::MAG_FILTER, proxy.mMagFilter);
}
if (is3D)
sampler->setWrap(osg::Texture::WRAP_R, proxy.wrap_r);
sampler->setWrap(osg::Texture::WRAP_S, proxy.wrap_s);
sampler->setWrap(osg::Texture::WRAP_T, proxy.wrap_t);
sampler->setInternalFormatMode(proxy.compression);
if (proxy.internal_format.has_value())
sampler->setInternalFormat(proxy.internal_format.value());
if (proxy.source_type.has_value())
sampler->setSourceType(proxy.source_type.value());
if (proxy.internal_format.has_value())
sampler->setSourceFormat(proxy.internal_format.value());
sampler->setWrap(osg::Texture::WRAP_R, proxy.mWrapR);
sampler->setWrap(osg::Texture::WRAP_S, proxy.mWrapS);
sampler->setWrap(osg::Texture::WRAP_T, proxy.mWrapT);
sampler->setInternalFormatMode(proxy.mCompression);
if (proxy.mInternalFormat.has_value())
sampler->setInternalFormat(proxy.mInternalFormat.value());
if (proxy.mSourceType.has_value())
sampler->setSourceType(proxy.mSourceType.value());
if (proxy.mInternalFormat.has_value())
sampler->setSourceFormat(proxy.mInternalFormat.value());
sampler->setName(std::string{ mBlockName });
sampler->setResizeNonPowerOfTwoHint(false);
@@ -677,9 +677,9 @@ namespace Fx
if (!std::holds_alternative<T>(mToken))
{
if (err.empty())
error(std::format("Expected {}", T::repr));
error(std::format("Expected {}", T::mRepresentation));
else
error(std::format("{}. Expected {}", err, T::repr));
error(std::format("{}. Expected {}", err, T::mRepresentation));
}
}
@@ -690,9 +690,9 @@ namespace Fx
if (!std::holds_alternative<T>(mToken) && !std::holds_alternative<T2>(mToken))
{
if (err.empty())
error(std::format("Expected {} or {}", T::repr, T2::repr));
error(std::format("Expected {} or {}", T::mRepresentation, T2::mRepresentation));
else
error(std::format("{}. Expected {} or {}", err, T::repr, T2::repr));
error(std::format("{}. Expected {} or {}", err, T::mRepresentation, T2::mRepresentation));
}
}
@@ -754,13 +754,13 @@ namespace Fx
template <class T>
void Technique::parseBlock(bool named)
{
mBlockName = T::repr;
mBlockName = T::mRepresentation;
if (named)
{
expect<Lexer::Literal>("name is required for preceeding block declaration");
mBlockName = std::get<Lexer::Literal>(mToken).value;
mBlockName = std::get<Lexer::Literal>(mToken).mValue;
if (isNext<Lexer::Open_Parenthesis>())
parseBlockHeader();
@@ -782,7 +782,7 @@ namespace Fx
{
expect<Lexer::Literal>();
data.emplace_back(std::get<Lexer::Literal>(mToken).value);
data.emplace_back(std::get<Lexer::Literal>(mToken).mValue);
if (!isNext<TDelimeter>())
break;
@@ -812,29 +812,29 @@ namespace Fx
{
expect<Lexer::Literal>("invalid key in block header");
std::string_view key = std::get<Lexer::Literal>(mToken).value;
std::string_view key = std::get<Lexer::Literal>(mToken).mValue;
expect<Lexer::Equal>();
if (key == "target")
{
expect<Lexer::Literal>();
pass->mTarget = std::get<Lexer::Literal>(mToken).value;
pass->mTarget = std::get<Lexer::Literal>(mToken).mValue;
}
else if (key == "rt1")
{
expect<Lexer::Literal>();
pass->mRenderTargets[0] = std::get<Lexer::Literal>(mToken).value;
pass->mRenderTargets[0] = std::get<Lexer::Literal>(mToken).mValue;
}
else if (key == "rt2")
{
expect<Lexer::Literal>();
pass->mRenderTargets[1] = std::get<Lexer::Literal>(mToken).value;
pass->mRenderTargets[1] = std::get<Lexer::Literal>(mToken).mValue;
}
else if (key == "rt3")
{
expect<Lexer::Literal>();
pass->mRenderTargets[2] = std::get<Lexer::Literal>(mToken).value;
pass->mRenderTargets[2] = std::get<Lexer::Literal>(mToken).mValue;
}
else if (key == "blend")
{
@@ -873,7 +873,7 @@ namespace Fx
std::string_view Technique::asLiteral() const
{
return std::get<Lexer::Literal>(mToken).value;
return std::get<Lexer::Literal>(mToken).mValue;
}
FlagsType Technique::parseFlags()
@@ -1073,7 +1073,7 @@ namespace Fx
{
expect<Lexer::String>();
return std::get<Lexer::String>(mToken).value;
return std::get<Lexer::String>(mToken).mValue;
}
float Technique::parseFloat()
@@ -1081,9 +1081,9 @@ namespace Fx
mToken = mLexer->next();
if (std::holds_alternative<Lexer::Float>(mToken))
return std::get<Lexer::Float>(mToken).value;
return std::get<Lexer::Float>(mToken).mValue;
if (std::holds_alternative<Lexer::Integer>(mToken))
return static_cast<float>(std::get<Lexer::Integer>(mToken).value);
return static_cast<float>(std::get<Lexer::Integer>(mToken).mValue);
error("expected float value");
}
@@ -1092,7 +1092,7 @@ namespace Fx
{
expect<Lexer::Integer>();
return std::get<Lexer::Integer>(mToken).value;
return std::get<Lexer::Integer>(mToken).mValue;
}
template <class OSGVec, class T>