diff --git a/apps/components_tests/fx/lexer.cpp b/apps/components_tests/fx/lexer.cpp index f8996118da..7c78edf96f 100644 --- a/apps/components_tests/fx/lexer.cpp +++ b/apps/components_tests/fx/lexer.cpp @@ -16,7 +16,7 @@ namespace template 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(lexer.next())); @@ -97,7 +97,7 @@ namespace auto token = lexer.next(); EXPECT_TRUE(std::holds_alternative(token)); - EXPECT_FLOAT_EQ(std::get(token).value, 0.123f); + EXPECT_FLOAT_EQ(std::get(token).mValue, 0.123f); } TEST(LexerTest, float_with_alpha_prefix) @@ -110,7 +110,7 @@ namespace auto token = lexer.next(); EXPECT_TRUE(std::holds_alternative(token)); - EXPECT_FLOAT_EQ(std::get(token).value, 0.123f); + EXPECT_FLOAT_EQ(std::get(token).mValue, 0.123f); } TEST(LexerTest, float_with_numeric_prefix) @@ -121,7 +121,7 @@ namespace auto token = lexer.next(); EXPECT_TRUE(std::holds_alternative(token)); - EXPECT_FLOAT_EQ(std::get(token).value, 123.123f); + EXPECT_FLOAT_EQ(std::get(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(token)); - EXPECT_EQ(std::get(token).value, 123); + EXPECT_EQ(std::get(token).mValue, 123); } TEST(LexerTest, float_suffix_should_be_float) @@ -143,7 +143,7 @@ namespace auto token = lexer.next(); EXPECT_TRUE(std::holds_alternative(token)); - EXPECT_FLOAT_EQ(std::get(token).value, 123.f); + EXPECT_FLOAT_EQ(std::get(token).mValue, 123.f); } TEST(LexerTest, simple_string) @@ -155,7 +155,7 @@ namespace auto token = lexer.next(); EXPECT_TRUE(std::holds_alternative(token)); - std::string parsed = std::string(std::get(token).value); + std::string parsed = std::string(std::get(token).mValue); EXPECT_EQ("test string", parsed); } diff --git a/components/fx/lexer.cpp b/components/fx/lexer.cpp index 43ce17717f..71179466b4 100644 --- a/components/fx/lexer.cpp +++ b/components/fx/lexer.cpp @@ -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(mHead + 1 - start) }; - mLastJumpBlock.content = sv; + mLastJumpBlock.mContent = sv; return sv; } } diff --git a/components/fx/lexer.hpp b/components/fx/lexer.hpp index c9120698aa..e86ce17e2b 100644 --- a/components/fx/lexer.hpp +++ b/components/fx/lexer.hpp @@ -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); diff --git a/components/fx/lexertypes.hpp b/components/fx/lexertypes.hpp index 327d6832c8..4f2a000ab5 100644 --- a/components/fx/lexertypes.hpp +++ b/components/fx/lexertypes.hpp @@ -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 source_format; - std::optional source_type; - std::optional 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 mSourceFormat; + std::optional mSourceType; + std::optional 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(); - auto key = std::get(mToken).value; + auto key = std::get(mToken).mValue; expect(); @@ -253,7 +253,7 @@ namespace Fx else if (key == "glsl_profile") { expect(); - mGLSLProfile = std::get(mToken).value; + mGLSLProfile = std::get(mToken).mValue; } else if (key == "glsl_extensions") { @@ -291,7 +291,7 @@ namespace Fx { expect(); - auto key = std::get(mToken).value; + auto key = std::get(mToken).mValue; expect(); @@ -425,28 +425,28 @@ namespace Fx expect(); 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(); const osg::ref_ptr image - = mImageManager.getImage(VFS::Path::Normalized(std::get(mToken).value), is3D); + = mImageManager.getImage(VFS::Path::Normalized(std::get(mToken).mValue), is3D); if constexpr (is1D) { type = Types::SamplerType::Texture_1D; @@ -469,24 +469,24 @@ namespace Fx expect(); } 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(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(mToken) && !std::holds_alternative(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 void Technique::parseBlock(bool named) { - mBlockName = T::repr; + mBlockName = T::mRepresentation; if (named) { expect("name is required for preceeding block declaration"); - mBlockName = std::get(mToken).value; + mBlockName = std::get(mToken).mValue; if (isNext()) parseBlockHeader(); @@ -782,7 +782,7 @@ namespace Fx { expect(); - data.emplace_back(std::get(mToken).value); + data.emplace_back(std::get(mToken).mValue); if (!isNext()) break; @@ -812,29 +812,29 @@ namespace Fx { expect("invalid key in block header"); - std::string_view key = std::get(mToken).value; + std::string_view key = std::get(mToken).mValue; expect(); if (key == "target") { expect(); - pass->mTarget = std::get(mToken).value; + pass->mTarget = std::get(mToken).mValue; } else if (key == "rt1") { expect(); - pass->mRenderTargets[0] = std::get(mToken).value; + pass->mRenderTargets[0] = std::get(mToken).mValue; } else if (key == "rt2") { expect(); - pass->mRenderTargets[1] = std::get(mToken).value; + pass->mRenderTargets[1] = std::get(mToken).mValue; } else if (key == "rt3") { expect(); - pass->mRenderTargets[2] = std::get(mToken).value; + pass->mRenderTargets[2] = std::get(mToken).mValue; } else if (key == "blend") { @@ -873,7 +873,7 @@ namespace Fx std::string_view Technique::asLiteral() const { - return std::get(mToken).value; + return std::get(mToken).mValue; } FlagsType Technique::parseFlags() @@ -1073,7 +1073,7 @@ namespace Fx { expect(); - return std::get(mToken).value; + return std::get(mToken).mValue; } float Technique::parseFloat() @@ -1081,9 +1081,9 @@ namespace Fx mToken = mLexer->next(); if (std::holds_alternative(mToken)) - return std::get(mToken).value; + return std::get(mToken).mValue; if (std::holds_alternative(mToken)) - return static_cast(std::get(mToken).value); + return static_cast(std::get(mToken).mValue); error("expected float value"); } @@ -1092,7 +1092,7 @@ namespace Fx { expect(); - return std::get(mToken).value; + return std::get(mToken).mValue; } template