Skip to content

Commit 75934ea

Browse files
committed
Release v0.4.3
1 parent a58a3c0 commit 75934ea

File tree

8 files changed

+71
-24
lines changed

8 files changed

+71
-24
lines changed

RELEASE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
## v0.4.3
22

3+
Very minor release, just so that downstream code can take advantage of several fixes and new features.
4+
Also, this release restores the WASM/WASI build which broke due to `from_chars` compatibility across toolchains.
5+
36
### New features
47

5-
- Natural ordering for strings is now supported
8+
- Natural ordering for strings is now supported in `order-by` by all commands (as the new default)
9+
- `order-by` directives can be typed, like `asc:float` or `asc:f` will parse entries as float and sort them accordingly.
610

711
### Breaking
812

9-
- `s:enable` has been reworked as an overload of `s:when`.
10-
- Default string comparisons are now following natural ordering.
13+
- `s:enable.*` has been reworked as an overload of `s:when`. Use it as `s:when.*`.
14+
- Default string comparisons are now following natural ordering, which might break things.

TODO.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
## `v0.4.3`
44

5-
- [ ] Rework the mechanisms used in `order-by` and fill missing comparisons in the RPN
6-
- [ ] Extend `order-by` to support explicit types for comparison (extremely optional)
7-
- [x] Support for string natural order (111 > 22).
5+
- [x] Basic support for natural ordering (in commands only, not vm for now)
6+
- [x] Extend `order-by` to support explicit types for comparison (extremely optional)
7+
- [x] Fixing the WASM build
88

99
## `v0.4.5`
1010

11+
- [ ] Stringview version of `strnatcmp` to optimize the dot comparisons
12+
- [ ] Rework the mechanisms used in `order-by` and fill missing comparisons in the RPN
13+
14+
## `v0.4.7`
15+
1116
- [ ] Properly show ctx information while logging
1217
- [ ] In the UI for the demo, add a loader as the first boot is quite slow
1318
- [ ] Fill in the docs at least of the public interface

docs/ordering.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Ordering criteria are used in two situations:
33
- in the `order-by` attributes of cycles for each type but `for-range`
44
- as basic boolean binary operator in the RPN virtual machine
55

6-
The two implementations are not unified, so feature parity is desired but not intrinsic.
6+
The two implementations are not unified, so feature parity is desirable but not intrinsic.
77

88
## Order types
99

@@ -13,7 +13,7 @@ Whatever ordinal is assigned to the entries, sorting is just based on an ascendi
1313

1414
### `RANDOM`
1515

16-
Data of any type is first hashed, and `ASC` is applied to those hashes.
16+
Data of any type is first hashed, and `asc` is applied to those hashes.
1717
For integers, floats and booleans this just involves their immediate data.
1818
For strings the characters buffer is used as the hash source. If the dot notation is needed, each token separated by `.` will be hashed and compared on its own.
1919
Nodes should not be directly compared. Doing so is not illegal, just nonsensical.
@@ -22,24 +22,28 @@ Nodes should not be directly compared. Doing so is not illegal, just nonsensical
2222

2323
### Nodes
2424

25+
Via suffix `:n` or `:node`.
2526
Nodes should not be directly compared.
2627
Doing so is not illegal, just nonsensical and UB.
2728
A more precise semantic for this case might be introduced later on.
2829

29-
### Attributes
30+
### ~~Attributes~~
3031

31-
By default, they are cast to string before evaluation.
32+
They are always cast to string before evaluation. So they will not be compared as XML nodes.
3233

3334
### Integers
3435

36+
Via suffix `:i`, `:int` or `:integer`.
3537
Comparison as expected from any basic math class.
3638

3739
### Floats
3840

41+
Via suffix `:f`, `:float``.
3942
Comparison as expected from any basic math class.
4043

4144
### Booleans
4245

46+
Via suffix `:b`, `:bool` or `:boolean`.
4347
`true` is smaller than `false`.
4448

4549
### Strings
@@ -48,14 +52,17 @@ Strings are by far the most complex to handle as multiple criteria are possible.
4852

4953
#### Encoding ordering
5054

55+
Via suffix `:s`, `:str` or `:string`.
5156
Based on the binary representation of UTF-8 encoding.
5257

5358
#### Natural ordering
5459

60+
Via suffix `:ns`, `:natstr` or `:natural-string`.
5561
`hello10` bigger than `hello2`.
5662

5763
#### Lexicographic ordering
5864

65+
Via suffix `:ls`, `:lexistr` or `:lexi-string`.
5966
For symbols in the Latin alphabet this is more or less equivalent to the encoding ordering.
6067
However, different languages have totally different customary approaches, and are not often based on alphabets.
6168
Basically any criteria rooted in linguistic arguments goes in here.

docs/releases/v0.4.3.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## v0.4.3
2+
3+
Very minor release, just so that downstream code can take advantage of several fixes and new features.
4+
Also, this release restores the WASM/WASI build which broke due to `from_chars` compatibility across toolchains.
5+
6+
### New features
7+
8+
- Natural ordering for strings is now supported in `order-by` by all commands (as the new default)
9+
- `order-by` directives can be typed, like `asc:float` or `asc:f` will parse entries as float and sort them accordingly.
10+
11+
### Breaking
12+
13+
- `s:enable.*` has been reworked as an overload of `s:when`. Use it as `s:when.*`.
14+
- Default string comparisons are now following natural ordering, which might break things.

include/utils.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
namespace vs{
1010
namespace templ{
1111

12-
template <typename T, typename... Args> struct concatenator;
13-
14-
template <typename... Args0, typename... Args1>
15-
struct concatenator<std::variant<Args0...>, Args1...> {
16-
using type = std::variant<Args0..., Args1...>;
17-
};
18-
12+
/**
13+
* @brief Get a value from a variant, or if not valid returns a default value.
14+
*
15+
* @tparam T
16+
* @param ref
17+
* @param defval
18+
* @return const T&
19+
*/
1920
template<typename T>
2021
const T& get_or(const auto& ref, const T& defval) noexcept{
2122
if(std::holds_alternative<T>(ref))return std::get<T>(ref);

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(
22
'vs-templ',
33
['cpp'],
4-
version: '0.4.2',
4+
version: '0.4.3',
55
meson_version: '>= 1.1',
66
default_options: ['cpp_std=c++20'],
77
)

scripts/codegen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
2+
# Not used for now.
33
gperf ./schemas/vm.gperf --output-file ./src/vm.autogen.cpp

src/vs-templ.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,31 @@ std::optional<symbol> preprocessor::resolve_expr(const std::string_view& _str, c
220220

221221
preprocessor::order_t preprocessor::order_from_string(std::string_view str){
222222
//TODO: extend to specify type. Syntax: `type:method`
223+
int offset = 0;
223224
order_t tmp;
224-
if(str[0]=='.'){tmp.modifiers.dot=true;}
225-
if((std::string_view(str.begin()+tmp.modifiers.dot, str.end()) == std::string_view("asc"))){tmp.method=order_t::method_t::ASC;}
226-
else if((std::string_view(str.begin()+tmp.modifiers.dot, str.end()) == std::string_view("desc"))){tmp.method=order_t::method_t::DESC;}
227-
else if((std::string_view(str.begin()+tmp.modifiers.dot, str.end()) == std::string_view("random"))){tmp.method=order_t::method_t::RANDOM;}
225+
if(str.starts_with(".")){tmp.modifiers.dot=true;offset++;}
226+
std::string_view pstr = std::string_view(str.begin()+offset, str.end());
227+
if((pstr.starts_with("asc"))){tmp.method=order_t::method_t::ASC;offset+=std::string_view("asc").length();}
228+
else if(pstr.starts_with("desc")){tmp.method=order_t::method_t::DESC;offset+=std::string_view("desc").length();}
229+
else if(pstr.starts_with("random")){tmp.method=order_t::method_t::RANDOM;offset+=std::string_view("random").length();}
228230
else{
229-
log(log_t::WARNING,std::format("`{}` is not a valid criterion for comparison",str));
231+
log(log_t::WARNING,std::format("`{}` is not a valid criterion for comparison",pstr));
230232
}
231233

234+
pstr = std::string_view(str.begin()+offset, str.end());
235+
236+
//Technically this would allow things like `.arc:hello:i` but to be honest I am not concerned with that
237+
if(pstr==":i" || pstr==":int" || pstr==":integer")tmp.type=order_t::type_t::INTEGER;
238+
else if(pstr==":f" || pstr==":float")tmp.type=order_t::type_t::FLOAT;
239+
else if(pstr==":b" || pstr==":bool"|| pstr==":boolean")tmp.type=order_t::type_t::BOOLEAN;
240+
else if(pstr==":s" || pstr==":str"|| pstr==":string")tmp.type=order_t::type_t::STRING;
241+
else if(pstr==":ns" || pstr==":natstr" || pstr==":natural-string")tmp.type=order_t::type_t::NATURAL_STRING;
242+
else if(pstr==":ls" || pstr==":lexistr" || pstr==":lexi-string")tmp.type=order_t::type_t::LEXI_STRING;
243+
else if(pstr==":n" || pstr==":node")tmp.type=order_t::type_t::NODE;
244+
else if(pstr.length()>0){
245+
log(log_t::WARNING,std::format("`{}` is not a valid type for comparison",pstr));
246+
}
247+
232248
return tmp;
233249
}
234250

0 commit comments

Comments
 (0)