diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-11 15:04:26 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-11 15:04:26 +0100 |
commit | 9b69d02409737768caeb3b305f0217c138fd1ec2 (patch) | |
tree | bb6737a162455bbd9d06c46bddf7f0c7eb549964 /src/css | |
parent | 76fb59b1f1e02632bdaaf337bb7c882b4d5e9b69 (diff) | |
download | chawan-9b69d02409737768caeb3b305f0217c138fd1ec2.tar.gz |
css: fix {} macros on older Nim versions
old Nim chokes on unquoting enums without explicitly casting them to the target enum type.
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/values.nim | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/css/values.nim b/src/css/values.nim index c6f0d50c..6533c7f1 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -421,18 +421,21 @@ func `$`*(val: CSSComputedValue): string = else: result = $val.v -macro `{}`*(vals: CSSComputedValues, s: string): untyped = - let t = propertyType($s) +macro `{}`*(vals: CSSComputedValues; s: static string): untyped = + let t = propertyType(s) let vs = ident($valueType(t)) return quote do: - `vals`[`t`].`vs` + `vals`[CSSPropertyType(`t`)].`vs` -macro `{}=`*(vals: CSSComputedValues, s: string, val: typed) = - let t = propertyType($s) +macro `{}=`*(vals: CSSComputedValues, s: static string, val: typed) = + let t = propertyType(s) let v = valueType(t) let vs = ident($v) return quote do: - `vals`[`t`] = CSSComputedValue(v: `v`, `vs`: `val`) + `vals`[CSSPropertyType(`t`)] = CSSComputedValue( + v: CSSValueType(`v`), + `vs`: `val` + ) func inherited(t: CSSPropertyType): bool = return InheritedArray[t] |