mirror of
https://github.com/hyprwm/hyprlang.git
synced 2024-11-16 18:25:57 +01:00
dynamic: fix dynamic variables being blocked by flag keywords
fixes #45
This commit is contained in:
parent
073678282e
commit
969cb076e5
4 changed files with 9 additions and 2 deletions
|
@ -620,7 +620,7 @@ CParseResult CConfig::parseLine(std::string line, bool dynamic) {
|
||||||
if (!h.options.allowFlags && h.name != LHS)
|
if (!h.options.allowFlags && h.name != LHS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (h.options.allowFlags && !LHS.starts_with(h.name))
|
if (h.options.allowFlags && (!LHS.starts_with(h.name) || LHS.contains(':') /* avoid cases where a category is called the same as a handler */))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = h.func(LHS.c_str(), RHS.c_str());
|
ret = h.func(LHS.c_str(), RHS.c_str());
|
||||||
|
|
|
@ -88,7 +88,7 @@ class CConfigImpl {
|
||||||
|
|
||||||
Hyprlang::SConfigOptions configOptions;
|
Hyprlang::SConfigOptions configOptions;
|
||||||
|
|
||||||
void parseComment(const std::string& comment);
|
void parseComment(const std::string& comment);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool noError = false;
|
bool noError = false;
|
||||||
|
|
|
@ -75,6 +75,10 @@ specialAnonymous {
|
||||||
value = 3
|
value = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flagsStuff {
|
||||||
|
value = 2
|
||||||
|
}
|
||||||
|
|
||||||
testCategory:testValueHex = 0xFFfFaAbB
|
testCategory:testValueHex = 0xFFfFaAbB
|
||||||
|
|
||||||
$RECURSIVE1 = a
|
$RECURSIVE1 = a
|
||||||
|
|
|
@ -98,6 +98,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
config.addConfigValue("testCategory:testColor1", (Hyprlang::INT)0);
|
config.addConfigValue("testCategory:testColor1", (Hyprlang::INT)0);
|
||||||
config.addConfigValue("testCategory:testColor2", (Hyprlang::INT)0);
|
config.addConfigValue("testCategory:testColor2", (Hyprlang::INT)0);
|
||||||
config.addConfigValue("testCategory:testColor3", (Hyprlang::INT)0);
|
config.addConfigValue("testCategory:testColor3", (Hyprlang::INT)0);
|
||||||
|
config.addConfigValue("flagsStuff:value", (Hyprlang::INT)0);
|
||||||
config.addConfigValue("myColors:pink", (Hyprlang::INT)0);
|
config.addConfigValue("myColors:pink", (Hyprlang::INT)0);
|
||||||
config.addConfigValue("myColors:green", (Hyprlang::INT)0);
|
config.addConfigValue("myColors:green", (Hyprlang::INT)0);
|
||||||
config.addConfigValue("myColors:random", (Hyprlang::INT)0);
|
config.addConfigValue("myColors:random", (Hyprlang::INT)0);
|
||||||
|
@ -170,6 +171,8 @@ int main(int argc, char** argv, char** envp) {
|
||||||
EXPECT(std::any_cast<int64_t>(config.getConfigValue("testCategory:testValueHex")), (Hyprlang::INT)0xAABBCCDD);
|
EXPECT(std::any_cast<int64_t>(config.getConfigValue("testCategory:testValueHex")), (Hyprlang::INT)0xAABBCCDD);
|
||||||
EXPECT(config.parseDynamic("testStringColon", "1:3:3:7").error, false);
|
EXPECT(config.parseDynamic("testStringColon", "1:3:3:7").error, false);
|
||||||
EXPECT(std::any_cast<const char*>(config.getConfigValue("testStringColon")), std::string{"1:3:3:7"});
|
EXPECT(std::any_cast<const char*>(config.getConfigValue("testStringColon")), std::string{"1:3:3:7"});
|
||||||
|
EXPECT(config.parseDynamic("flagsStuff:value = 69").error, false);
|
||||||
|
EXPECT(std::any_cast<int64_t>(config.getConfigValue("flagsStuff:value")), (Hyprlang::INT)69);
|
||||||
|
|
||||||
// test dynamic special
|
// test dynamic special
|
||||||
config.addSpecialConfigValue("specialGeneric:one", "boom", (Hyprlang::INT)0);
|
config.addSpecialConfigValue("specialGeneric:one", "boom", (Hyprlang::INT)0);
|
||||||
|
|
Loading…
Reference in a new issue