@shd101wyy/yo 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/async-effects-recipes.md +74 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +85 -0
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +192 -6
- package/out/cjs/index.cjs +518 -517
- package/out/cjs/yo-cli.cjs +593 -592
- package/out/cjs/yo-lsp.cjs +522 -521
- package/out/esm/index.mjs +341 -340
- package/out/types/src/parser.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/build.yo +2 -2
- package/std/collections/array_list.yo +26 -0
- package/std/imm/map.yo +15 -15
- package/std/imm/sorted_map.yo +14 -14
- package/std/imm/string.yo +4 -4
- package/std/prelude.yo +18 -23
- package/std/process/command.yo +8 -8
- package/std/string/string.yo +76 -55
- package/std/string/unicode.yo +6 -6
- package/std/sys/signal.yo +6 -6
package/std/string/string.yo
CHANGED
|
@@ -112,7 +112,7 @@ impl(String,
|
|
|
112
112
|
count := usize(0);
|
|
113
113
|
byte_index := usize(0);
|
|
114
114
|
total_bytes := al.len();
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
while ((byte_index < total_bytes)),
|
|
117
117
|
(byte_index = (byte_index + usize(1))),
|
|
118
118
|
{
|
|
@@ -129,7 +129,7 @@ impl(String,
|
|
|
129
129
|
.None => ()
|
|
130
130
|
);
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
return count;
|
|
134
134
|
}
|
|
135
135
|
)
|
|
@@ -251,14 +251,14 @@ impl(String,
|
|
|
251
251
|
* Returns None if index is out of bounds
|
|
252
252
|
* For "你好世界", at(0) returns '你', at(1) returns '好', etc.
|
|
253
253
|
*/
|
|
254
|
-
at : (fn(self: Self, index: usize) -> Option(rune))(
|
|
254
|
+
at : (fn(self: Self, index: usize) -> Option(rune))(
|
|
255
255
|
match(self._bytes,
|
|
256
256
|
.None => { return .None; },
|
|
257
257
|
.Some(al) => {
|
|
258
258
|
char_count := usize(0);
|
|
259
259
|
byte_index := usize(0);
|
|
260
260
|
total_bytes := al.len();
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
while ((byte_index < total_bytes)),
|
|
263
263
|
(byte_index = (byte_index + usize(1))),
|
|
264
264
|
{
|
|
@@ -283,11 +283,11 @@ impl(String,
|
|
|
283
283
|
.None => ()
|
|
284
284
|
);
|
|
285
285
|
};
|
|
286
|
-
|
|
286
|
+
|
|
287
287
|
return .None;
|
|
288
288
|
}
|
|
289
289
|
)
|
|
290
|
-
|
|
290
|
+
),
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
293
|
* Concatenate two strings (like JavaScript +)
|
|
@@ -299,7 +299,7 @@ impl(String,
|
|
|
299
299
|
return Self(_bytes: .None);
|
|
300
300
|
});
|
|
301
301
|
new_bytes := ArrayList(u8).with_capacity((self_len + other_len));
|
|
302
|
-
|
|
302
|
+
|
|
303
303
|
match(self._bytes,
|
|
304
304
|
.Some(b) => match(b.ptr(),
|
|
305
305
|
.Some(p) => new_bytes.extend_from_ptr(p, self_len),
|
|
@@ -307,7 +307,7 @@ impl(String,
|
|
|
307
307
|
),
|
|
308
308
|
.None => ()
|
|
309
309
|
);
|
|
310
|
-
|
|
310
|
+
|
|
311
311
|
match(other._bytes,
|
|
312
312
|
.Some(b) => match(b.ptr(),
|
|
313
313
|
.Some(p) => new_bytes.extend_from_ptr(p, other_len),
|
|
@@ -315,7 +315,7 @@ impl(String,
|
|
|
315
315
|
),
|
|
316
316
|
.None => ()
|
|
317
317
|
);
|
|
318
|
-
|
|
318
|
+
|
|
319
319
|
return Self(_bytes: .Some(new_bytes));
|
|
320
320
|
}),
|
|
321
321
|
|
|
@@ -424,7 +424,7 @@ impl(String,
|
|
|
424
424
|
* Returns a new string containing characters from start (inclusive) to end (exclusive)
|
|
425
425
|
* If end is greater than length, it will substring to the end of the string
|
|
426
426
|
*/
|
|
427
|
-
substring : (fn(self: Self, start: usize, end: usize) -> Self)(
|
|
427
|
+
substring : (fn(self: Self, start: usize, end: usize) -> Self)(
|
|
428
428
|
match(self._bytes,
|
|
429
429
|
.None => { return Self(_bytes: .None); },
|
|
430
430
|
.Some(al) => {
|
|
@@ -471,7 +471,7 @@ impl(String,
|
|
|
471
471
|
Self(_bytes: .Some(new_bytes))
|
|
472
472
|
}
|
|
473
473
|
)
|
|
474
|
-
|
|
474
|
+
),
|
|
475
475
|
|
|
476
476
|
/**
|
|
477
477
|
* Find the first occurrence of a substring (like JavaScript indexOf)
|
|
@@ -484,7 +484,7 @@ impl(String,
|
|
|
484
484
|
true => {
|
|
485
485
|
(self_bytes : usize) = match(self._bytes, .Some(b) => b.len(), .None => usize(0));
|
|
486
486
|
(sub_bytes : usize) = match(substr._bytes, .Some(b) => b.len(), .None => usize(0));
|
|
487
|
-
|
|
487
|
+
|
|
488
488
|
cond(
|
|
489
489
|
(sub_bytes > self_bytes) => .None,
|
|
490
490
|
true => match(self._bytes,
|
|
@@ -494,7 +494,7 @@ impl(String,
|
|
|
494
494
|
.Some(sub_al) => {
|
|
495
495
|
char_index := usize(0);
|
|
496
496
|
byte_index := usize(0);
|
|
497
|
-
|
|
497
|
+
|
|
498
498
|
while (((byte_index < self_bytes) && (char_index < from_index))),
|
|
499
499
|
(byte_index = (byte_index + usize(1))),
|
|
500
500
|
{
|
|
@@ -512,7 +512,7 @@ impl(String,
|
|
|
512
512
|
.None => ()
|
|
513
513
|
);
|
|
514
514
|
};
|
|
515
|
-
|
|
515
|
+
|
|
516
516
|
while ((byte_index <= (self_bytes - sub_bytes))),
|
|
517
517
|
(byte_index = (byte_index + usize(1))),
|
|
518
518
|
{
|
|
@@ -546,14 +546,14 @@ impl(String,
|
|
|
546
546
|
}
|
|
547
547
|
);
|
|
548
548
|
};
|
|
549
|
-
|
|
549
|
+
|
|
550
550
|
cond(
|
|
551
551
|
matches => {
|
|
552
552
|
return .Some(char_index);
|
|
553
553
|
},
|
|
554
554
|
true => ()
|
|
555
555
|
);
|
|
556
|
-
|
|
556
|
+
|
|
557
557
|
first_byte_opt := self_al.get(byte_index);
|
|
558
558
|
match(first_byte_opt,
|
|
559
559
|
.Some(first_byte) => {
|
|
@@ -568,7 +568,7 @@ impl(String,
|
|
|
568
568
|
.None => ()
|
|
569
569
|
);
|
|
570
570
|
};
|
|
571
|
-
|
|
571
|
+
|
|
572
572
|
return .None;
|
|
573
573
|
}
|
|
574
574
|
)
|
|
@@ -594,7 +594,7 @@ impl(String,
|
|
|
594
594
|
*/
|
|
595
595
|
split : (fn(self: Self, separator: Self) -> ArrayList(Self))({
|
|
596
596
|
result := ArrayList(Self).new();
|
|
597
|
-
|
|
597
|
+
|
|
598
598
|
cond(
|
|
599
599
|
separator.is_empty() => {
|
|
600
600
|
char_count := self.len();
|
|
@@ -624,10 +624,10 @@ impl(String,
|
|
|
624
624
|
.Some(sep_al) => {
|
|
625
625
|
self_bytes := self_al.len();
|
|
626
626
|
sep_bytes := sep_al.len();
|
|
627
|
-
|
|
627
|
+
|
|
628
628
|
current_bytes := ArrayList(u8).new();
|
|
629
629
|
byte_index := usize(0);
|
|
630
|
-
|
|
630
|
+
|
|
631
631
|
while ((byte_index < self_bytes)),
|
|
632
632
|
(byte_index = (byte_index + usize(1))),
|
|
633
633
|
{
|
|
@@ -668,7 +668,7 @@ impl(String,
|
|
|
668
668
|
matches = false;
|
|
669
669
|
}
|
|
670
670
|
);
|
|
671
|
-
|
|
671
|
+
|
|
672
672
|
cond(
|
|
673
673
|
matches => {
|
|
674
674
|
cond(
|
|
@@ -689,7 +689,7 @@ impl(String,
|
|
|
689
689
|
}
|
|
690
690
|
);
|
|
691
691
|
};
|
|
692
|
-
|
|
692
|
+
|
|
693
693
|
cond(
|
|
694
694
|
(current_bytes.len() == usize(0)) => result.push(Self(_bytes: .None)),
|
|
695
695
|
true => result.push(Self(_bytes: .Some(current_bytes)))
|
|
@@ -716,13 +716,13 @@ impl(String,
|
|
|
716
716
|
.Some(sub_al) => {
|
|
717
717
|
self_bytes := self_al.len();
|
|
718
718
|
sub_bytes := sub_al.len();
|
|
719
|
-
|
|
719
|
+
|
|
720
720
|
cond(
|
|
721
721
|
(sub_bytes > self_bytes) => .None,
|
|
722
722
|
true => {
|
|
723
723
|
char_positions := ArrayList(usize).new();
|
|
724
724
|
byte_positions := ArrayList(usize).new();
|
|
725
|
-
|
|
725
|
+
|
|
726
726
|
byte_idx := usize(0);
|
|
727
727
|
char_idx := usize(0);
|
|
728
728
|
while ((byte_idx < self_bytes)),
|
|
@@ -744,12 +744,12 @@ impl(String,
|
|
|
744
744
|
.None => ()
|
|
745
745
|
);
|
|
746
746
|
};
|
|
747
|
-
|
|
747
|
+
|
|
748
748
|
max_char_index := cond(
|
|
749
749
|
(from_index >= char_idx) => char_idx,
|
|
750
750
|
true => (from_index + usize(1))
|
|
751
751
|
);
|
|
752
|
-
|
|
752
|
+
|
|
753
753
|
(last_match : Option(usize)) = .None;
|
|
754
754
|
i := usize(0);
|
|
755
755
|
while ((i < char_positions.len())),
|
|
@@ -809,7 +809,7 @@ impl(String,
|
|
|
809
809
|
.None => ()
|
|
810
810
|
);
|
|
811
811
|
};
|
|
812
|
-
|
|
812
|
+
|
|
813
813
|
return last_match;
|
|
814
814
|
}
|
|
815
815
|
)
|
|
@@ -836,7 +836,7 @@ impl(String,
|
|
|
836
836
|
.Some(prefix_al) => {
|
|
837
837
|
char_index := usize(0);
|
|
838
838
|
byte_index := usize(0);
|
|
839
|
-
|
|
839
|
+
|
|
840
840
|
while (((byte_index < self_bytes) && (char_index < position))),
|
|
841
841
|
(byte_index = (byte_index + usize(1))),
|
|
842
842
|
{
|
|
@@ -862,7 +862,7 @@ impl(String,
|
|
|
862
862
|
.None => ()
|
|
863
863
|
);
|
|
864
864
|
};
|
|
865
|
-
|
|
865
|
+
|
|
866
866
|
cond(
|
|
867
867
|
((byte_index + prefix_bytes) > self_bytes) => false,
|
|
868
868
|
true => {
|
|
@@ -926,11 +926,11 @@ impl(String,
|
|
|
926
926
|
(end_position > string_char_len) => string_char_len,
|
|
927
927
|
true => end_position
|
|
928
928
|
);
|
|
929
|
-
|
|
929
|
+
|
|
930
930
|
char_index := usize(0);
|
|
931
931
|
byte_index := usize(0);
|
|
932
932
|
end_byte_index := self_bytes;
|
|
933
|
-
|
|
933
|
+
|
|
934
934
|
while ((byte_index < self_bytes)),
|
|
935
935
|
(byte_index = (byte_index + usize(1))),
|
|
936
936
|
{
|
|
@@ -956,7 +956,7 @@ impl(String,
|
|
|
956
956
|
.None => ()
|
|
957
957
|
);
|
|
958
958
|
};
|
|
959
|
-
|
|
959
|
+
|
|
960
960
|
cond(
|
|
961
961
|
(suffix_bytes > end_byte_index) => false,
|
|
962
962
|
true => {
|
|
@@ -1015,10 +1015,10 @@ impl(String,
|
|
|
1015
1015
|
.Some(search_al) => {
|
|
1016
1016
|
self_bytes := self_al.len();
|
|
1017
1017
|
search_bytes := search_al.len();
|
|
1018
|
-
|
|
1018
|
+
|
|
1019
1019
|
byte_index := usize(0);
|
|
1020
1020
|
(found_at : Option(usize)) = .None;
|
|
1021
|
-
|
|
1021
|
+
|
|
1022
1022
|
while ((byte_index <= (self_bytes - search_bytes))),
|
|
1023
1023
|
(byte_index = (byte_index + usize(1))),
|
|
1024
1024
|
{
|
|
@@ -1052,7 +1052,7 @@ impl(String,
|
|
|
1052
1052
|
}
|
|
1053
1053
|
);
|
|
1054
1054
|
};
|
|
1055
|
-
|
|
1055
|
+
|
|
1056
1056
|
cond(
|
|
1057
1057
|
matches => {
|
|
1058
1058
|
found_at = .Some(byte_index);
|
|
@@ -1061,12 +1061,12 @@ impl(String,
|
|
|
1061
1061
|
true => ()
|
|
1062
1062
|
);
|
|
1063
1063
|
};
|
|
1064
|
-
|
|
1064
|
+
|
|
1065
1065
|
match(found_at,
|
|
1066
1066
|
.Some(pos) => {
|
|
1067
1067
|
(nv_bytes : usize) = match(new_value._bytes, .Some(b) => b.len(), .None => usize(0));
|
|
1068
1068
|
new_bytes := ArrayList(u8).with_capacity(((self_bytes - search_bytes) + nv_bytes));
|
|
1069
|
-
|
|
1069
|
+
|
|
1070
1070
|
match(self_al.ptr(),
|
|
1071
1071
|
.Some(p) => {
|
|
1072
1072
|
if((pos > usize(0)), {
|
|
@@ -1075,7 +1075,7 @@ impl(String,
|
|
|
1075
1075
|
},
|
|
1076
1076
|
.None => ()
|
|
1077
1077
|
);
|
|
1078
|
-
|
|
1078
|
+
|
|
1079
1079
|
match(new_value._bytes,
|
|
1080
1080
|
.Some(nv_al) => match(nv_al.ptr(),
|
|
1081
1081
|
.Some(p) => new_bytes.extend_from_ptr(p, nv_bytes),
|
|
@@ -1083,7 +1083,7 @@ impl(String,
|
|
|
1083
1083
|
),
|
|
1084
1084
|
.None => ()
|
|
1085
1085
|
);
|
|
1086
|
-
|
|
1086
|
+
|
|
1087
1087
|
(after_pos : usize) = (pos + search_bytes);
|
|
1088
1088
|
if((after_pos < self_bytes), {
|
|
1089
1089
|
match(self_al.ptr(),
|
|
@@ -1091,7 +1091,7 @@ impl(String,
|
|
|
1091
1091
|
.None => ()
|
|
1092
1092
|
);
|
|
1093
1093
|
});
|
|
1094
|
-
|
|
1094
|
+
|
|
1095
1095
|
return Self(_bytes: .Some(new_bytes));
|
|
1096
1096
|
},
|
|
1097
1097
|
.None => self
|
|
@@ -1116,7 +1116,7 @@ impl(String,
|
|
|
1116
1116
|
self_bytes := self_al.len();
|
|
1117
1117
|
search_bytes := search_al.len();
|
|
1118
1118
|
new_bytes := ArrayList(u8).new();
|
|
1119
|
-
|
|
1119
|
+
|
|
1120
1120
|
byte_index := usize(0);
|
|
1121
1121
|
while ((byte_index < self_bytes)),
|
|
1122
1122
|
(byte_index = (byte_index + usize(1))),
|
|
@@ -1158,7 +1158,7 @@ impl(String,
|
|
|
1158
1158
|
matches = false;
|
|
1159
1159
|
}
|
|
1160
1160
|
);
|
|
1161
|
-
|
|
1161
|
+
|
|
1162
1162
|
cond(
|
|
1163
1163
|
matches => {
|
|
1164
1164
|
match(new_value._bytes,
|
|
@@ -1179,7 +1179,7 @@ impl(String,
|
|
|
1179
1179
|
}
|
|
1180
1180
|
);
|
|
1181
1181
|
};
|
|
1182
|
-
|
|
1182
|
+
|
|
1183
1183
|
cond(
|
|
1184
1184
|
(new_bytes.len() == usize(0)) => Self(_bytes: .None),
|
|
1185
1185
|
true => Self(_bytes: .Some(new_bytes))
|
|
@@ -1200,7 +1200,7 @@ impl(String,
|
|
|
1200
1200
|
.Some(al) => {
|
|
1201
1201
|
(total : usize) = al.len();
|
|
1202
1202
|
new_bytes := ArrayList(u8).with_capacity(total);
|
|
1203
|
-
|
|
1203
|
+
|
|
1204
1204
|
i := usize(0);
|
|
1205
1205
|
while ((i < total)),
|
|
1206
1206
|
(i = (i + usize(1))),
|
|
@@ -1217,7 +1217,7 @@ impl(String,
|
|
|
1217
1217
|
.None => ()
|
|
1218
1218
|
);
|
|
1219
1219
|
};
|
|
1220
|
-
|
|
1220
|
+
|
|
1221
1221
|
Self(_bytes: .Some(new_bytes))
|
|
1222
1222
|
}
|
|
1223
1223
|
)
|
|
@@ -1233,7 +1233,7 @@ impl(String,
|
|
|
1233
1233
|
.Some(al) => {
|
|
1234
1234
|
(total : usize) = al.len();
|
|
1235
1235
|
new_bytes := ArrayList(u8).with_capacity(total);
|
|
1236
|
-
|
|
1236
|
+
|
|
1237
1237
|
i := usize(0);
|
|
1238
1238
|
while ((i < total)),
|
|
1239
1239
|
(i = (i + usize(1))),
|
|
@@ -1250,7 +1250,7 @@ impl(String,
|
|
|
1250
1250
|
.None => ()
|
|
1251
1251
|
);
|
|
1252
1252
|
};
|
|
1253
|
-
|
|
1253
|
+
|
|
1254
1254
|
Self(_bytes: .Some(new_bytes))
|
|
1255
1255
|
}
|
|
1256
1256
|
)
|
|
@@ -1314,7 +1314,7 @@ impl(String,
|
|
|
1314
1314
|
.None => Self(_bytes: .None),
|
|
1315
1315
|
.Some(al) => {
|
|
1316
1316
|
total_bytes := al.len();
|
|
1317
|
-
|
|
1317
|
+
|
|
1318
1318
|
cond(
|
|
1319
1319
|
(total_bytes == usize(0)) => Self(_bytes: .None),
|
|
1320
1320
|
true => {
|
|
@@ -1334,7 +1334,7 @@ impl(String,
|
|
|
1334
1334
|
.None => break
|
|
1335
1335
|
);
|
|
1336
1336
|
};
|
|
1337
|
-
|
|
1337
|
+
|
|
1338
1338
|
cond(
|
|
1339
1339
|
(start_idx >= total_bytes) => Self(_bytes: .None),
|
|
1340
1340
|
true => {
|
|
@@ -1361,7 +1361,7 @@ impl(String,
|
|
|
1361
1361
|
.None => Self(_bytes: .None),
|
|
1362
1362
|
.Some(al) => {
|
|
1363
1363
|
total_bytes := al.len();
|
|
1364
|
-
|
|
1364
|
+
|
|
1365
1365
|
cond(
|
|
1366
1366
|
(total_bytes == usize(0)) => Self(_bytes: .None),
|
|
1367
1367
|
true => {
|
|
@@ -1381,7 +1381,7 @@ impl(String,
|
|
|
1381
1381
|
.None => break
|
|
1382
1382
|
);
|
|
1383
1383
|
};
|
|
1384
|
-
|
|
1384
|
+
|
|
1385
1385
|
cond(
|
|
1386
1386
|
(end_idx == usize(0)) => Self(_bytes: .None),
|
|
1387
1387
|
true => {
|
|
@@ -1413,7 +1413,7 @@ impl(String, Eq(String)(
|
|
|
1413
1413
|
(==) : (fn(self: Self, other: Self) -> bool)({
|
|
1414
1414
|
(self_len : usize) = match(self._bytes, .Some(b) => b.len(), .None => usize(0));
|
|
1415
1415
|
(other_len : usize) = match(other._bytes, .Some(b) => b.len(), .None => usize(0));
|
|
1416
|
-
|
|
1416
|
+
|
|
1417
1417
|
cond(
|
|
1418
1418
|
(self_len != other_len) => false,
|
|
1419
1419
|
(self_len == usize(0)) => true,
|
|
@@ -1650,7 +1650,7 @@ impl(String,
|
|
|
1650
1650
|
* assert(`x`.repeat(usize(0)) == ``, "repeat 0");
|
|
1651
1651
|
* ```
|
|
1652
1652
|
*/
|
|
1653
|
-
repeat : (fn(self: Self, n: usize) -> Self)(
|
|
1653
|
+
repeat : (fn(self: Self, n: usize) -> Self)(
|
|
1654
1654
|
cond(
|
|
1655
1655
|
(n == usize(0)) => Self(_bytes: .None),
|
|
1656
1656
|
self.is_empty() => Self(_bytes: .None),
|
|
@@ -1681,7 +1681,7 @@ impl(String,
|
|
|
1681
1681
|
Self(_bytes: .Some(buf))
|
|
1682
1682
|
}
|
|
1683
1683
|
)
|
|
1684
|
-
|
|
1684
|
+
),
|
|
1685
1685
|
|
|
1686
1686
|
/**
|
|
1687
1687
|
* Join an `ArrayList(String)` with this string as separator.
|
|
@@ -2175,10 +2175,31 @@ impl(String, Clone(
|
|
|
2175
2175
|
)
|
|
2176
2176
|
));
|
|
2177
2177
|
|
|
2178
|
+
/// Like `assert`, but accepts a runtime `String` message (e.g. a template
|
|
2179
|
+
/// string with interpolation: `` `error: ${value}` ``).
|
|
2180
|
+
///
|
|
2181
|
+
/// Example:
|
|
2182
|
+
/// name := String.from("rule1");
|
|
2183
|
+
/// assert_dyn(name.len() > usize(0), `Invalid rule name: ${name}`);
|
|
2184
|
+
assert_dyn :: (fn(flag : bool, msg : String) -> unit)({
|
|
2185
|
+
assert(flag, msg.as_str());
|
|
2186
|
+
});
|
|
2187
|
+
|
|
2188
|
+
/// Like `panic`, but accepts a runtime `String` message (e.g. a template
|
|
2189
|
+
/// string with interpolation: `` `error: ${value}` ``).
|
|
2190
|
+
///
|
|
2191
|
+
/// Example:
|
|
2192
|
+
/// panic_dyn(`Something went wrong: ${details}`);
|
|
2193
|
+
panic_dyn :: (fn(msg : String) -> unit)({
|
|
2194
|
+
panic(msg.as_str());
|
|
2195
|
+
});
|
|
2196
|
+
|
|
2178
2197
|
export
|
|
2179
2198
|
String,
|
|
2180
2199
|
StringError,
|
|
2181
2200
|
StringChars,
|
|
2182
2201
|
StringBytes,
|
|
2183
|
-
StringLines
|
|
2202
|
+
StringLines,
|
|
2203
|
+
assert_dyn,
|
|
2204
|
+
panic_dyn
|
|
2184
2205
|
;
|
package/std/string/unicode.yo
CHANGED
|
@@ -32,9 +32,9 @@ _decode_utf8 :: (fn(bytes: ArrayList(u8), i: usize) -> _DecodeResult)({
|
|
|
32
32
|
(b0 : i32) = i32(bytes.get(i).unwrap());
|
|
33
33
|
cond(
|
|
34
34
|
// 1-byte ASCII
|
|
35
|
-
((b0 & i32(0x80)) == i32(0)) =>
|
|
35
|
+
((b0 & i32(0x80)) == i32(0)) =>
|
|
36
36
|
_DecodeResult(codepoint: b0, bytes_consumed: usize(1))
|
|
37
|
-
|
|
37
|
+
,
|
|
38
38
|
// 2-byte
|
|
39
39
|
((b0 & i32(0xE0)) == i32(0xC0)) => {
|
|
40
40
|
(b1 : i32) = i32(bytes.get((i + usize(1))).unwrap());
|
|
@@ -85,7 +85,7 @@ _encode_utf8 :: (fn(cp: i32, out: *(ArrayList(u8))) -> unit)({
|
|
|
85
85
|
|
|
86
86
|
// Special case folding: codepoints that expand to multiple codepoints
|
|
87
87
|
// when lowercased. These are Unicode case folding entries of type 'F' (full).
|
|
88
|
-
_special_to_lower :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)(
|
|
88
|
+
_special_to_lower :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)(
|
|
89
89
|
cond(
|
|
90
90
|
// ẞ (U+1E9E LATIN CAPITAL LETTER SHARP S) → ss
|
|
91
91
|
(cp == i32(0x1E9E)) => {
|
|
@@ -102,11 +102,11 @@ _special_to_lower :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)({
|
|
|
102
102
|
},
|
|
103
103
|
true => false
|
|
104
104
|
)
|
|
105
|
-
|
|
105
|
+
);
|
|
106
106
|
|
|
107
107
|
// Special case folding: codepoints that expand to multiple codepoints
|
|
108
108
|
// when uppercased.
|
|
109
|
-
_special_to_upper :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)(
|
|
109
|
+
_special_to_upper :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)(
|
|
110
110
|
cond(
|
|
111
111
|
// ß (U+00DF LATIN SMALL LETTER SHARP S) → SS
|
|
112
112
|
(cp == i32(0x00DF)) => {
|
|
@@ -160,7 +160,7 @@ _special_to_upper :: (fn(cp: i32, out: *(ArrayList(u8))) -> bool)({
|
|
|
160
160
|
},
|
|
161
161
|
true => false
|
|
162
162
|
)
|
|
163
|
-
|
|
163
|
+
);
|
|
164
164
|
|
|
165
165
|
// Convert a String to lowercase using Unicode-aware case mapping.
|
|
166
166
|
/// Convert a `String` to lowercase using Unicode case mapping rules.
|
package/std/sys/signal.yo
CHANGED
|
@@ -8,21 +8,21 @@ SignalHandler :: (fn(data: *(u8)) -> unit);
|
|
|
8
8
|
|
|
9
9
|
// Register a signal handler.
|
|
10
10
|
// Returns 0 on success, -errno on failure.
|
|
11
|
-
on_signal :: (fn(signum: i32, handler: SignalHandler) -> i32)(
|
|
11
|
+
on_signal :: (fn(signum: i32, handler: SignalHandler) -> i32)(
|
|
12
12
|
__yo_signal_start(signum, unsafe.cast(handler, *(u8)))
|
|
13
|
-
|
|
13
|
+
);
|
|
14
14
|
|
|
15
15
|
// Remove a signal handler (reset to default).
|
|
16
16
|
// Returns 0 on success, -errno on failure.
|
|
17
|
-
off_signal :: (fn(signum: i32) -> i32)(
|
|
17
|
+
off_signal :: (fn(signum: i32) -> i32)(
|
|
18
18
|
__yo_signal_stop(signum)
|
|
19
|
-
|
|
19
|
+
);
|
|
20
20
|
|
|
21
21
|
// Send a signal to a process.
|
|
22
22
|
// Returns 0 on success, -errno on failure.
|
|
23
|
-
kill :: (fn(pid: i32, signum: i32) -> i32)(
|
|
23
|
+
kill :: (fn(pid: i32, signum: i32) -> i32)(
|
|
24
24
|
__yo_kill(pid, signum)
|
|
25
|
-
|
|
25
|
+
);
|
|
26
26
|
|
|
27
27
|
export
|
|
28
28
|
SignalHandler,
|