authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-01 14:22:29+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-01 14:22:29+02:00
log381dc2d9509ffeaf60a1775ee0983c7dd1b9e346
tree34dc901cf638a113cd7bf84d90125b9c64685b3d
parent575a98a0813181c268e86d590b6267583736bafd
parenta0a854b1fc5e64a07b2026ac0668f8d417ab6bf1
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15139 from ziglang/macos-13-fixes

Fixes for latest macOS 13.3 SDK release

7 files changed, 1960 insertions(+), 1794 deletions(-)

lib/libc/darwin/libSystem.13.tbd+207-672
......@@ -2,21 +2,8 @@
22tbd-version: 4
33targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
44 arm64e-macos, arm64e-maccatalyst ]
5uuids:
6 - target: x86_64-macos
7 value: 085E3D5D-7871-3E9E-A097-AAD940171411
8 - target: x86_64-maccatalyst
9 value: 085E3D5D-7871-3E9E-A097-AAD940171411
10 - target: arm64-macos
11 value: 00000000-0000-0000-0000-000000000000
12 - target: arm64-maccatalyst
13 value: 00000000-0000-0000-0000-000000000000
14 - target: arm64e-macos
15 value: B54723A8-A25C-3D6C-A51B-2B8BBA733DD3
16 - target: arm64e-maccatalyst
17 value: B54723A8-A25C-3D6C-A51B-2B8BBA733DD3
185install-name: '/usr/lib/libSystem.B.dylib'
19current-version: 1319
6current-version: 1319.100.3
207reexported-libraries:
218 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
229 arm64e-macos, arm64e-maccatalyst ]
......@@ -57,21 +44,8 @@ exports:
5744tbd-version: 4
5845targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
5946 arm64e-macos, arm64e-maccatalyst ]
60uuids:
61 - target: x86_64-macos
62 value: A7D96CB6-7562-3C14-8B54-ED5E484B54E2
63 - target: x86_64-maccatalyst
64 value: A7D96CB6-7562-3C14-8B54-ED5E484B54E2
65 - target: arm64-macos
66 value: 00000000-0000-0000-0000-000000000000
67 - target: arm64-maccatalyst
68 value: 00000000-0000-0000-0000-000000000000
69 - target: arm64e-macos
70 value: 7A88909B-ED36-360D-ACE9-81107AF0FE14
71 - target: arm64e-maccatalyst
72 value: 7A88909B-ED36-360D-ACE9-81107AF0FE14
7347install-name: '/usr/lib/system/libcache.dylib'
74current-version: 90
48current-version: 92
7549parent-umbrella:
7650 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
7751 arm64e-macos, arm64e-maccatalyst ]
......@@ -95,21 +69,8 @@ exports:
9569tbd-version: 4
9670targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
9771 arm64e-macos, arm64e-maccatalyst ]
98uuids:
99 - target: x86_64-macos
100 value: 6E120635-E858-30FE-95F6-64D90E33095D
101 - target: x86_64-maccatalyst
102 value: 6E120635-E858-30FE-95F6-64D90E33095D
103 - target: arm64-macos
104 value: 00000000-0000-0000-0000-000000000000
105 - target: arm64-maccatalyst
106 value: 00000000-0000-0000-0000-000000000000
107 - target: arm64e-macos
108 value: 452A7C15-97FA-32A0-B514-744E117E2B39
109 - target: arm64e-maccatalyst
110 value: 452A7C15-97FA-32A0-B514-744E117E2B39
11172install-name: '/usr/lib/system/libcommonCrypto.dylib'
112current-version: 60198.60.2
73current-version: 65535.100.4
11374parent-umbrella:
11475 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
11576 arm64e-macos, arm64e-maccatalyst ]
......@@ -189,13 +150,6 @@ exports:
189150--- !tapi-tbd
190151tbd-version: 4
191152targets: [ x86_64-macos, arm64-macos, arm64e-macos ]
192uuids:
193 - target: x86_64-macos
194 value: E9412018-811C-36B7-9F58-6471398EE465
195 - target: arm64-macos
196 value: 954CFCC0-97A8-329B-B5AA-FF9046F3E94F
197 - target: arm64e-macos
198 value: 9F57BC0A-3F18-3F00-B772-40B6A8616E26
199153install-name: '/usr/lib/system/libcompiler_rt.dylib'
200154current-version: 103.1
201155parent-umbrella:
......@@ -424,19 +378,6 @@ exports:
424378tbd-version: 4
425379targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
426380 arm64e-macos, arm64e-maccatalyst ]
427uuids:
428 - target: x86_64-macos
429 value: F92F30BA-35BE-3ED9-B562-FBEC1B7089B5
430 - target: x86_64-maccatalyst
431 value: F92F30BA-35BE-3ED9-B562-FBEC1B7089B5
432 - target: arm64-macos
433 value: 00000000-0000-0000-0000-000000000000
434 - target: arm64-maccatalyst
435 value: 00000000-0000-0000-0000-000000000000
436 - target: arm64e-macos
437 value: 3689048E-9EC2-32D9-B833-B5EDE2839092
438 - target: arm64e-maccatalyst
439 value: 3689048E-9EC2-32D9-B833-B5EDE2839092
440381install-name: '/usr/lib/system/libcopyfile.dylib'
441382parent-umbrella:
442383 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -452,21 +393,8 @@ exports:
452393tbd-version: 4
453394targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
454395 arm64e-macos, arm64e-maccatalyst ]
455uuids:
456 - target: x86_64-macos
457 value: 1A8A8D34-268F-3D42-936A-8A0029817E22
458 - target: x86_64-maccatalyst
459 value: 1A8A8D34-268F-3D42-936A-8A0029817E22
460 - target: arm64-macos
461 value: 00000000-0000-0000-0000-000000000000
462 - target: arm64-maccatalyst
463 value: 00000000-0000-0000-0000-000000000000
464 - target: arm64e-macos
465 value: E32C0A9B-EDD0-376D-A504-A06C215E89FE
466 - target: arm64e-maccatalyst
467 value: E32C0A9B-EDD0-376D-A504-A06C215E89FE
468396install-name: '/usr/lib/system/libcorecrypto.dylib'
469current-version: 1386.60.8
397current-version: 1387.100.43
470398parent-umbrella:
471399 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
472400 arm64e-macos, arm64e-maccatalyst ]
......@@ -766,21 +694,8 @@ exports:
766694tbd-version: 4
767695targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
768696 arm64e-macos, arm64e-maccatalyst ]
769uuids:
770 - target: x86_64-macos
771 value: 6282E528-6A67-334B-ACCF-1F8FD89369BD
772 - target: x86_64-maccatalyst
773 value: 6282E528-6A67-334B-ACCF-1F8FD89369BD
774 - target: arm64-macos
775 value: 00000000-0000-0000-0000-000000000000
776 - target: arm64-maccatalyst
777 value: 00000000-0000-0000-0000-000000000000
778 - target: arm64e-macos
779 value: 191028D2-0477-3EBC-9EEF-A85ACAFC7193
780 - target: arm64e-maccatalyst
781 value: 191028D2-0477-3EBC-9EEF-A85ACAFC7193
782697install-name: '/usr/lib/system/libdispatch.dylib'
783current-version: 1412
698current-version: 1415.100.11
784699parent-umbrella:
785700 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
786701 arm64e-macos, arm64e-maccatalyst ]
......@@ -942,19 +857,6 @@ exports:
942857tbd-version: 4
943858targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
944859 arm64e-macos, arm64e-maccatalyst ]
945uuids:
946 - target: x86_64-macos
947 value: 6F97B8FD-BA81-3779-ADB2-5ECD91F42B75
948 - target: x86_64-maccatalyst
949 value: 6F97B8FD-BA81-3779-ADB2-5ECD91F42B75
950 - target: arm64-macos
951 value: 427D321B-B30E-367F-8E2C-1DA6FD2D0962
952 - target: arm64-maccatalyst
953 value: 427D321B-B30E-367F-8E2C-1DA6FD2D0962
954 - target: arm64e-macos
955 value: C1700833-CCA0-3BA5-8614-C149347F5503
956 - target: arm64e-maccatalyst
957 value: C1700833-CCA0-3BA5-8614-C149347F5503
958860install-name: '/usr/lib/system/libdyld.dylib'
959861parent-umbrella:
960862 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -1040,19 +942,6 @@ exports:
1040942tbd-version: 4
1041943targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
1042944 arm64e-macos, arm64e-maccatalyst ]
1043uuids:
1044 - target: x86_64-macos
1045 value: 4C623CBE-6FF4-3731-A647-6EEF7A6F51C7
1046 - target: x86_64-maccatalyst
1047 value: 4C623CBE-6FF4-3731-A647-6EEF7A6F51C7
1048 - target: arm64-macos
1049 value: 00000000-0000-0000-0000-000000000000
1050 - target: arm64-maccatalyst
1051 value: 00000000-0000-0000-0000-000000000000
1052 - target: arm64e-macos
1053 value: B63E11DD-4648-3355-A51C-C1B650654C0F
1054 - target: arm64e-maccatalyst
1055 value: B63E11DD-4648-3355-A51C-C1B650654C0F
1056945install-name: '/usr/lib/system/libkeymgr.dylib'
1057946current-version: 31
1058947parent-umbrella:
......@@ -1070,21 +959,8 @@ exports:
1070959--- !tapi-tbd
1071960tbd-version: 4
1072961targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64e-macos ]
1073uuids:
1074 - target: x86_64-macos
1075 value: 632C478C-AAF6-3330-AA8E-0D0FCA4C6237
1076 - target: x86_64-maccatalyst
1077 value: 632C478C-AAF6-3330-AA8E-0D0FCA4C6237
1078 - target: arm64-macos
1079 value: F71DA09E-609F-3C9A-95BF-22B22CFAD5A5
1080 - target: arm64-maccatalyst
1081 value: F71DA09E-609F-3C9A-95BF-22B22CFAD5A5
1082 - target: arm64e-macos
1083 value: 471DA066-B65F-36B1-93B7-243C71F8838B
1084 - target: arm64e-maccatalyst
1085 value: 471DA066-B65F-36B1-93B7-243C71F8838B
1086962install-name: '/usr/lib/system/libmacho.dylib'
1087current-version: 1001.2
963current-version: 1005
1088964parent-umbrella:
1089965 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64e-macos ]
1090966 umbrella: System
......@@ -1130,21 +1006,8 @@ exports:
11301006tbd-version: 4
11311007targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
11321008 arm64e-macos, arm64e-maccatalyst ]
1133uuids:
1134 - target: x86_64-macos
1135 value: 9C3DCECF-ED9C-3F0F-9E9C-28DC842D4D65
1136 - target: x86_64-maccatalyst
1137 value: 9C3DCECF-ED9C-3F0F-9E9C-28DC842D4D65
1138 - target: arm64-macos
1139 value: 00000000-0000-0000-0000-000000000000
1140 - target: arm64-maccatalyst
1141 value: 00000000-0000-0000-0000-000000000000
1142 - target: arm64e-macos
1143 value: A052DB52-9ECA-39EC-8DD4-05A0856579B7
1144 - target: arm64e-maccatalyst
1145 value: A052DB52-9ECA-39EC-8DD4-05A0856579B7
11461009install-name: '/usr/lib/system/libquarantine.dylib'
1147current-version: 146.60.2
1010current-version: 147.100.8
11481011parent-umbrella:
11491012 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
11501013 arm64e-macos, arm64e-maccatalyst ]
......@@ -1188,21 +1051,8 @@ exports:
11881051tbd-version: 4
11891052targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
11901053 arm64e-macos, arm64e-maccatalyst ]
1191uuids:
1192 - target: x86_64-macos
1193 value: A7C519E4-A2A5-33E1-B9D6-52951921392F
1194 - target: x86_64-maccatalyst
1195 value: A7C519E4-A2A5-33E1-B9D6-52951921392F
1196 - target: arm64-macos
1197 value: 00000000-0000-0000-0000-000000000000
1198 - target: arm64-maccatalyst
1199 value: 00000000-0000-0000-0000-000000000000
1200 - target: arm64e-macos
1201 value: E785FBDF-82C9-3642-A38D-EDB07D118303
1202 - target: arm64e-maccatalyst
1203 value: E785FBDF-82C9-3642-A38D-EDB07D118303
12041054install-name: '/usr/lib/system/libremovefile.dylib'
1205current-version: 63
1055current-version: 68
12061056parent-umbrella:
12071057 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
12081058 arm64e-macos, arm64e-maccatalyst ]
......@@ -1219,19 +1069,6 @@ exports:
12191069tbd-version: 4
12201070targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
12211071 arm64e-macos, arm64e-maccatalyst ]
1222uuids:
1223 - target: x86_64-macos
1224 value: D32DFE04-D5D4-3BD7-B9B5-9ED721B993EE
1225 - target: x86_64-maccatalyst
1226 value: D32DFE04-D5D4-3BD7-B9B5-9ED721B993EE
1227 - target: arm64-macos
1228 value: 00000000-0000-0000-0000-000000000000
1229 - target: arm64-maccatalyst
1230 value: 00000000-0000-0000-0000-000000000000
1231 - target: arm64e-macos
1232 value: 1E8F925A-501E-32BD-9BE3-2EE5FDEA8818
1233 - target: arm64e-maccatalyst
1234 value: 1E8F925A-501E-32BD-9BE3-2EE5FDEA8818
12351072install-name: '/usr/lib/system/libsystem_asl.dylib'
12361073current-version: 395
12371074parent-umbrella:
......@@ -1313,21 +1150,8 @@ exports:
13131150tbd-version: 4
13141151targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
13151152 arm64e-macos, arm64e-maccatalyst ]
1316uuids:
1317 - target: x86_64-macos
1318 value: 942C1938-B1BC-3B74-912C-D7E7E2B6DC72
1319 - target: x86_64-maccatalyst
1320 value: 942C1938-B1BC-3B74-912C-D7E7E2B6DC72
1321 - target: arm64-macos
1322 value: 00000000-0000-0000-0000-000000000000
1323 - target: arm64-maccatalyst
1324 value: 00000000-0000-0000-0000-000000000000
1325 - target: arm64e-macos
1326 value: B126606C-8D07-3F9D-AD5E-9864CF11D901
1327 - target: arm64e-maccatalyst
1328 value: B126606C-8D07-3F9D-AD5E-9864CF11D901
13291153install-name: '/usr/lib/system/libsystem_blocks.dylib'
1330current-version: 84
1154current-version: 87
13311155parent-umbrella:
13321156 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
13331157 arm64e-macos, arm64e-maccatalyst ]
......@@ -1345,38 +1169,25 @@ exports:
13451169tbd-version: 4
13461170targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
13471171 arm64e-macos, arm64e-maccatalyst ]
1348uuids:
1349 - target: x86_64-macos
1350 value: 376F7CB7-6DD2-3E00-976F-77DD755BDB0D
1351 - target: x86_64-maccatalyst
1352 value: 376F7CB7-6DD2-3E00-976F-77DD755BDB0D
1353 - target: arm64-macos
1354 value: 00000000-0000-0000-0000-000000000000
1355 - target: arm64-maccatalyst
1356 value: 00000000-0000-0000-0000-000000000000
1357 - target: arm64e-macos
1358 value: 756CD0D2-3241-3A74-8C59-02632DCEE221
1359 - target: arm64e-maccatalyst
1360 value: 756CD0D2-3241-3A74-8C59-02632DCEE221
13611172install-name: '/usr/lib/system/libsystem_c.dylib'
1362current-version: 1534.40.2
1173current-version: 1534.100.14
13631174parent-umbrella:
13641175 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
13651176 arm64e-macos, arm64e-maccatalyst ]
13661177 umbrella: System
13671178exports:
13681179 - targets: [ x86_64-macos, x86_64-maccatalyst ]
1369 symbols: [ '___opendir2$INODE64', ___strtopx, '__readdir_unlocked$INODE64',
1370 '__seekdir$INODE64', '_alphasort$INODE64', '_daemon$1050',
1371 '_fdopendir$INODE64', _fstatx64_np, '_fstatx_np$INODE64',
1372 '_fts_children$INODE64', '_fts_close$INODE64', '_fts_open$INODE64',
1373 '_fts_open_b$INODE64', '_fts_read$INODE64', '_fts_set$INODE64',
1374 '_ftw$INODE64', '_getmntinfo$INODE64', _getmntinfo64, '_getmntinfo_r_np$INODE64',
1375 '_glob$INODE64', '_glob_b$INODE64', _lstatx64_np, '_lstatx_np$INODE64',
1376 '_nftw$INODE64', '_opendir$INODE64', '_readdir$INODE64', '_readdir_r$INODE64',
1180 symbols: [ '___opendir2$INODE64', '__readdir_unlocked$INODE64', '__seekdir$INODE64',
1181 '_alphasort$INODE64', '_daemon$1050', '_fdopendir$INODE64',
1182 _fstatx64_np, '_fstatx_np$INODE64', '_fts_children$INODE64',
1183 '_fts_close$INODE64', '_fts_open$INODE64', '_fts_open_b$INODE64',
1184 '_fts_read$INODE64', '_fts_set$INODE64', '_ftw$INODE64', '_getmntinfo$INODE64',
1185 _getmntinfo64, '_getmntinfo_r_np$INODE64', '_glob$INODE64',
1186 '_glob_b$INODE64', _lstatx64_np, '_lstatx_np$INODE64', '_nftw$INODE64',
1187 '_opendir$INODE64', '_readdir$INODE64', '_readdir_r$INODE64',
13771188 '_rewinddir$INODE64', '_scandir$INODE64', '_scandir_b$INODE64',
1378 '_seekdir$INODE64', _statx64_np, '_statx_np$INODE64', '_telldir$INODE64',
1379 mcount ]
1189 '_seekdir$INODE64', _statx64_np, '_statx_np$INODE64', _strtoencf80_l,
1190 '_telldir$INODE64', mcount ]
13801191 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
13811192 arm64e-macos, arm64e-maccatalyst ]
13821193 symbols: [ '$ld$weak$os10.11$_basename_r', '$ld$weak$os10.11$_clock_getres',
......@@ -1387,26 +1198,24 @@ exports:
13871198 __CurrentRuneLocale, __DefaultRuneLocale, __Exit, __NSGetArgc,
13881199 __NSGetArgv, __NSGetEnviron, __NSGetMachExecuteHeader, __NSGetProgname,
13891200 __PathLocale, __Read_RuneMagi, ___Balloc_D2A, ___Bfree_D2A,
1390 ___ULtod_D2A, ____mb_cur_max, ____mb_cur_max_l, ____runetype,
1391 ____runetype_l, ____tolower, ____tolower_l, ____toupper, ____toupper_l,
1392 ___add_ovflpage, ___addel, ___any_on_D2A, ___assert_rtn, ___b2d_D2A,
1393 ___big_delete, ___big_insert, ___big_keydata, ___big_return,
1394 ___big_split, ___bigtens_D2A, ___bt_close, ___bt_cmp, ___bt_defcmp,
1395 ___bt_defpfx, ___bt_delete, ___bt_dleaf, ___bt_fd, ___bt_free,
1396 ___bt_get, ___bt_new, ___bt_open, ___bt_pgin, ___bt_pgout,
1397 ___bt_put, ___bt_ret, ___bt_search, ___bt_seq, ___bt_setcur,
1398 ___bt_split, ___bt_sync, ___buf_free, ___call_hash, ___cleanup,
1399 ___cmp_D2A, ___collate_equiv_match, ___collate_load_error,
1400 ___collate_lookup, ___collate_lookup_l, ___copybits_D2A, ___cxa_atexit,
1401 ___cxa_finalize, ___cxa_finalize_ranges, ___cxa_thread_atexit,
1402 ___d2b_D2A, ___dbpanic, ___decrement_D2A, ___default_hash,
1403 ___default_utx, ___delpair, ___diff_D2A, ___dtoa, ___expand_table,
1404 ___fflush, ___fgetwc, ___find_bigpair, ___find_last_page,
1405 ___fix_locale_grouping_str, ___fread, ___free_ovflpage, ___freedtoa,
1406 ___gdtoa, ___gdtoa_locks, ___get_buf, ___get_page, ___gethex_D2A,
1407 ___getonlyClocaleconv, ___hash_open, ___hdtoa, ___hexdig_D2A,
1408 ___hexdig_init_D2A, ___hexnan_D2A, ___hi0bits_D2A, ___hldtoa,
1409 ___i2b_D2A, ___ibitmap, ___increment_D2A, ___isctype, ___istype,
1201 ____mb_cur_max, ____mb_cur_max_l, ____runetype, ____runetype_l,
1202 ____tolower, ____tolower_l, ____toupper, ____toupper_l, ___add_ovflpage,
1203 ___addel, ___any_on_D2A, ___assert_rtn, ___b2d_D2A, ___big_delete,
1204 ___big_insert, ___big_keydata, ___big_return, ___big_split,
1205 ___bigtens_D2A, ___bt_close, ___bt_cmp, ___bt_defcmp, ___bt_defpfx,
1206 ___bt_delete, ___bt_dleaf, ___bt_fd, ___bt_free, ___bt_get,
1207 ___bt_new, ___bt_open, ___bt_pgin, ___bt_pgout, ___bt_put,
1208 ___bt_ret, ___bt_search, ___bt_seq, ___bt_setcur, ___bt_split,
1209 ___bt_sync, ___buf_free, ___call_hash, ___cleanup, ___cmp_D2A,
1210 ___collate_equiv_match, ___collate_load_error, ___collate_lookup,
1211 ___collate_lookup_l, ___copybits_D2A, ___cxa_atexit, ___cxa_finalize,
1212 ___cxa_finalize_ranges, ___cxa_thread_atexit, ___d2b_D2A,
1213 ___dbpanic, ___default_hash, ___default_utx, ___delpair, ___diff_D2A,
1214 ___dtoa, ___expand_table, ___fflush, ___fgetwc, ___find_bigpair,
1215 ___find_last_page, ___fix_locale_grouping_str, ___fread, ___free_ovflpage,
1216 ___freedtoa, ___gdtoa, ___gdtoa_locks, ___get_buf, ___get_page,
1217 ___getonlyClocaleconv, ___hash_open, ___hdtoa, ___hi0bits_D2A,
1218 ___hldtoa, ___i2b_D2A, ___ibitmap, ___isctype, ___istype,
14101219 ___istype_l, ___ldtoa, ___libc_init, ___lo0bits_D2A, ___log2,
14111220 ___lshift_D2A, ___maskrune, ___maskrune_l, ___match_D2A, ___mb_cur_max,
14121221 ___mb_sb_limit, ___memccpy_chk, ___memcpy_chk, ___memmove_chk,
......@@ -1417,53 +1226,54 @@ exports:
14171226 ___rec_iput, ___rec_open, ___rec_put, ___rec_ret, ___rec_search,
14181227 ___rec_seq, ___rec_sync, ___rec_vmap, ___rec_vpipe, ___reclaim_buf,
14191228 ___rshift_D2A, ___rv_alloc_D2A, ___s2b_D2A, ___sF, ___sclose,
1420 ___sdidinit, ___set_ones_D2A, ___setonlyClocaleconv, ___sflags,
1421 ___sflush, ___sfp, ___sfvwrite, ___sglue, ___sinit, ___slbexpand,
1422 ___smakebuf, ___snprintf_chk, ___snprintf_object_size_chk,
1423 ___split_page, ___sprintf_chk, ___sprintf_object_size_chk,
1424 ___sread, ___srefill, ___srget, ___sseek, ___stack_chk_fail,
1425 ___stack_chk_guard, ___stderrp, ___stdinp, ___stdoutp, ___stpcpy_chk,
1426 ___stpncpy_chk, ___strcat_chk, ___strcp_D2A, ___strcpy_chk,
1427 ___strlcat_chk, ___strlcpy_chk, ___strncat_chk, ___strncpy_chk,
1428 ___strtodg, ___strtopdd, ___sum_D2A, ___svfscanf, ___swbuf,
1429 ___swhatbuf, ___swrite, ___swsetup, ___tens_D2A, ___tinytens_D2A,
1430 ___tolower, ___tolower_l, ___toupper, ___toupper_l, ___trailz_D2A,
1431 ___ulp_D2A, ___ungetc, ___ungetwc, ___vsnprintf_chk, ___vsprintf_chk,
1432 ___wcwidth, ___wcwidth_l, __allocenvstate, __atexit_receipt,
1433 __c_locale, __cleanup, __closeutx, __copyenv, __cthread_init_routine,
1434 __deallocenvstate, __endutxent, __flockfile_debug_stub, __fseeko,
1435 __ftello, __fwalk, __getenvp, __getutxent, __getutxid, __getutxline,
1436 __inet_aton_check, __init_clock_port, __int_to_time, __libc_fork_child,
1437 __libc_initializer, __long_to_time, __mkpath_np, __mktemp,
1438 __openutx, __os_assert_log, __os_assert_log_ctx, __os_assumes_log,
1439 __os_assumes_log_ctx, __os_avoid_tail_call, __os_crash, __os_crash_callback,
1440 __os_crash_fmt, __os_crash_msg, __os_debug_log, __os_debug_log_error_offset,
1441 __os_debug_log_error_str, __putenvp, __pututxline, __rand48_add,
1442 __rand48_mult, __rand48_seed, __readdir_unlocked, __reclaim_telldir,
1443 __seekdir, __setenvp, __setutxent, __sigaction_nobind, __sigintr,
1444 __signal_nobind, __sigvec_nobind, __sread, __sseek, __subsystem_init,
1445 __swrite, __time32_to_time, __time64_to_time, __time_to_int,
1446 __time_to_long, __time_to_time32, __time_to_time64, __unsetenvp,
1447 __utmpxname, _a64l, _abort, _abort_report_np, _abs, _acl_add_flag_np,
1448 _acl_add_perm, _acl_calc_mask, _acl_clear_flags_np, _acl_clear_perms,
1449 _acl_copy_entry, _acl_copy_ext, _acl_copy_ext_native, _acl_copy_int,
1450 _acl_copy_int_native, _acl_create_entry, _acl_create_entry_np,
1451 _acl_delete_def_file, _acl_delete_entry, _acl_delete_fd_np,
1452 _acl_delete_file_np, _acl_delete_flag_np, _acl_delete_link_np,
1453 _acl_delete_perm, _acl_dup, _acl_free, _acl_from_text, _acl_get_entry,
1454 _acl_get_fd, _acl_get_fd_np, _acl_get_file, _acl_get_flag_np,
1455 _acl_get_flagset_np, _acl_get_link_np, _acl_get_perm_np, _acl_get_permset,
1456 _acl_get_permset_mask_np, _acl_get_qualifier, _acl_get_tag_type,
1457 _acl_init, _acl_maximal_permset_mask_np, _acl_set_fd, _acl_set_fd_np,
1458 _acl_set_file, _acl_set_flagset_np, _acl_set_link_np, _acl_set_permset,
1459 _acl_set_permset_mask_np, _acl_set_qualifier, _acl_set_tag_type,
1460 _acl_size, _acl_to_text, _acl_valid, _acl_valid_fd_np, _acl_valid_file_np,
1461 _acl_valid_link, _addr2ascii, _alarm, _alphasort, _arc4random,
1462 _arc4random_addrandom, _arc4random_buf, _arc4random_stir,
1463 _arc4random_uniform, _ascii2addr, _asctime, _asctime_r, _asprintf,
1464 _asprintf_l, _asxprintf, _asxprintf_exec, _atexit, _atexit_b,
1465 _atof, _atof_l, _atoi, _atoi_l, _atol, _atol_l, _atoll, _atoll_l,
1466 _backtrace, _backtrace_async, _backtrace_from_fp, _backtrace_image_offsets,
1229 ___sdidinit, ___setonlyClocaleconv, ___sflags, ___sflush,
1230 ___sfp, ___sfvwrite, ___sglue, ___sinit, ___slbexpand, ___smakebuf,
1231 ___snprintf_chk, ___snprintf_object_size_chk, ___split_page,
1232 ___sprintf_chk, ___sprintf_object_size_chk, ___sread, ___srefill,
1233 ___srget, ___sseek, ___stack_chk_fail, ___stack_chk_guard,
1234 ___stderrp, ___stdinp, ___stdoutp, ___stpcpy_chk, ___stpncpy_chk,
1235 ___strcat_chk, ___strcp_D2A, ___strcpy_chk, ___strlcat_chk,
1236 ___strlcpy_chk, ___strncat_chk, ___strncpy_chk, ___sum_D2A,
1237 ___svfscanf, ___swbuf, ___swhatbuf, ___swrite, ___swsetup,
1238 ___tens_D2A, ___tinytens_D2A, ___tolower, ___tolower_l, ___toupper,
1239 ___toupper_l, ___trailz_D2A, ___ulp_D2A, ___ungetc, ___ungetwc,
1240 ___vsnprintf_chk, ___vsprintf_chk, ___wcwidth, ___wcwidth_l,
1241 __allocenvstate, __atexit_receipt, __c_locale, __cleanup,
1242 __closeutx, __copyenv, __cthread_init_routine, __deallocenvstate,
1243 __endutxent, __flockfile_debug_stub, __fseeko, __ftello, __fwalk,
1244 __getenvp, __getutxent, __getutxid, __getutxline, __inet_aton_check,
1245 __init_clock_port, __int_to_time, __libc_fork_child, __libc_fork_parent,
1246 __libc_fork_prepare, __libc_initializer, __long_to_time, __mkpath_np,
1247 __mktemp, __openutx, __os_assert_log, __os_assert_log_ctx,
1248 __os_assumes_log, __os_assumes_log_ctx, __os_avoid_tail_call,
1249 __os_crash, __os_crash_callback, __os_crash_fmt, __os_crash_msg,
1250 __os_debug_log, __os_debug_log_error_offset, __os_debug_log_error_str,
1251 __putenvp, __pututxline, __rand48_add, __rand48_mult, __rand48_seed,
1252 __readdir_unlocked, __reclaim_telldir, __seekdir, __setenvp,
1253 __setutxent, __sigaction_nobind, __sigintr, __signal_nobind,
1254 __sigvec_nobind, __sread, __sseek, __subsystem_init, __swrite,
1255 __time32_to_time, __time64_to_time, __time_to_int, __time_to_long,
1256 __time_to_time32, __time_to_time64, __unsetenvp, __utmpxname,
1257 _a64l, _abort, _abort_report_np, _abs, _acl_add_flag_np, _acl_add_perm,
1258 _acl_calc_mask, _acl_clear_flags_np, _acl_clear_perms, _acl_copy_entry,
1259 _acl_copy_ext, _acl_copy_ext_native, _acl_copy_int, _acl_copy_int_native,
1260 _acl_create_entry, _acl_create_entry_np, _acl_delete_def_file,
1261 _acl_delete_entry, _acl_delete_fd_np, _acl_delete_file_np,
1262 _acl_delete_flag_np, _acl_delete_link_np, _acl_delete_perm,
1263 _acl_dup, _acl_free, _acl_from_text, _acl_get_entry, _acl_get_fd,
1264 _acl_get_fd_np, _acl_get_file, _acl_get_flag_np, _acl_get_flagset_np,
1265 _acl_get_link_np, _acl_get_perm_np, _acl_get_permset, _acl_get_permset_mask_np,
1266 _acl_get_qualifier, _acl_get_tag_type, _acl_init, _acl_maximal_permset_mask_np,
1267 _acl_set_fd, _acl_set_fd_np, _acl_set_file, _acl_set_flagset_np,
1268 _acl_set_link_np, _acl_set_permset, _acl_set_permset_mask_np,
1269 _acl_set_qualifier, _acl_set_tag_type, _acl_size, _acl_to_text,
1270 _acl_valid, _acl_valid_fd_np, _acl_valid_file_np, _acl_valid_link,
1271 _addr2ascii, _alarm, _alphasort, _arc4random, _arc4random_addrandom,
1272 _arc4random_buf, _arc4random_stir, _arc4random_uniform, _ascii2addr,
1273 _asctime, _asctime_r, _asprintf, _asprintf_l, _asxprintf,
1274 _asxprintf_exec, _atexit, _atexit_b, _atof, _atof_l, _atoi,
1275 _atoi_l, _atol, _atol_l, _atoll, _atoll_l, _backtrace, _backtrace_async,
1276 _backtrace_from_fp, _backtrace_image_offsets, _backtrace_set_pcs_func,
14671277 _backtrace_symbols, _backtrace_symbols_fd, _basename, _basename_r,
14681278 _bcopy, _brk, _bsd_signal, _bsearch, _bsearch_b, _btowc, _btowc_l,
14691279 _catclose, _catgets, _catopen, _cfgetispeed, _cfgetospeed,
......@@ -1587,16 +1397,17 @@ exports:
15871397 _strncat, _strndup, _strnstr, _strnunvis, _strnunvisx, _strnvis,
15881398 _strnvisx, _strpbrk, _strptime, _strptime_l, _strrchr, _strsenvisx,
15891399 _strsep, _strsignal, _strsignal_r, _strsnvis, _strsnvisx,
1590 _strspn, _strsvis, _strsvisx, _strtod, _strtod_l, _strtof,
1591 _strtof_l, _strtofflags, _strtoimax, _strtoimax_l, _strtok,
1592 _strtok_r, _strtol, _strtol_l, _strtold, _strtold_l, _strtoll,
1593 _strtoll_l, _strtonum, _strtoq, _strtoq_l, _strtoul, _strtoul_l,
1594 _strtoull, _strtoull_l, _strtoumax, _strtoumax_l, _strtouq,
1595 _strtouq_l, _strunvis, _strunvisx, _strvis, _strvisx, _strxfrm,
1596 _strxfrm_l, _suboptarg, _svis, _swab, _swprintf, _swprintf_l,
1597 _swscanf, _swscanf_l, _sxprintf, _sxprintf_exec, _sync_volume_np,
1598 _sys_errlist, _sys_nerr, _sys_siglist, _sys_signame, _sysconf,
1599 _sysctl, _sysctlbyname, _sysctlnametomib, _system, '_system$NOCANCEL',
1400 _strspn, _strsvis, _strsvisx, _strtod, _strtod_l, _strtoencf16,
1401 _strtoencf32, _strtoencf64, _strtoencf64x, _strtof, _strtof_l,
1402 _strtofflags, _strtoimax, _strtoimax_l, _strtok, _strtok_r,
1403 _strtol, _strtol_l, _strtold, _strtold_l, _strtoll, _strtoll_l,
1404 _strtonum, _strtoq, _strtoq_l, _strtoul, _strtoul_l, _strtoull,
1405 _strtoull_l, _strtoumax, _strtoumax_l, _strtouq, _strtouq_l,
1406 _strunvis, _strunvisx, _strvis, _strvisx, _strxfrm, _strxfrm_l,
1407 _suboptarg, _svis, _swab, _swprintf, _swprintf_l, _swscanf,
1408 _swscanf_l, _sxprintf, _sxprintf_exec, _sync_volume_np, _sys_errlist,
1409 _sys_nerr, _sys_siglist, _sys_signame, _sysconf, _sysctl,
1410 _sysctlbyname, _sysctlnametomib, _system, '_system$NOCANCEL',
16001411 _tcdrain, '_tcdrain$NOCANCEL', _tcflow, _tcflush, _tcgetattr,
16011412 _tcgetpgrp, _tcgetsid, _tcsendbreak, _tcsetattr, _tcsetpgrp,
16021413 _tdelete, _telldir, _tempnam, _tfind, _thread_stack_async_pcs,
......@@ -1652,21 +1463,8 @@ reexports:
16521463tbd-version: 4
16531464targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
16541465 arm64e-macos, arm64e-maccatalyst ]
1655uuids:
1656 - target: x86_64-macos
1657 value: 2053883C-79F4-3AF8-A37C-DE204E208C60
1658 - target: x86_64-maccatalyst
1659 value: 2053883C-79F4-3AF8-A37C-DE204E208C60
1660 - target: arm64-macos
1661 value: 00000000-0000-0000-0000-000000000000
1662 - target: arm64-maccatalyst
1663 value: 00000000-0000-0000-0000-000000000000
1664 - target: arm64e-macos
1665 value: CB445464-28B4-353C-976E-59DA0E229FED
1666 - target: arm64e-maccatalyst
1667 value: CB445464-28B4-353C-976E-59DA0E229FED
16681466install-name: '/usr/lib/system/libsystem_collections.dylib'
1669current-version: 1534.40.2
1467current-version: 1534.100.14
16701468parent-umbrella:
16711469 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
16721470 arm64e-macos, arm64e-maccatalyst ]
......@@ -1695,21 +1493,8 @@ exports:
16951493tbd-version: 4
16961494targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
16971495 arm64e-macos, arm64e-maccatalyst ]
1698uuids:
1699 - target: x86_64-macos
1700 value: E7F80C5C-E18C-3201-ACB6-9A4C46B6574B
1701 - target: x86_64-maccatalyst
1702 value: E7F80C5C-E18C-3201-ACB6-9A4C46B6574B
1703 - target: arm64-macos
1704 value: 00000000-0000-0000-0000-000000000000
1705 - target: arm64-maccatalyst
1706 value: 00000000-0000-0000-0000-000000000000
1707 - target: arm64e-macos
1708 value: 113A1DDB-1B61-3C33-9FD5-B39A2A29D779
1709 - target: arm64e-maccatalyst
1710 value: 113A1DDB-1B61-3C33-9FD5-B39A2A29D779
17111496install-name: '/usr/lib/system/libsystem_configuration.dylib'
1712current-version: 1241.60.3
1497current-version: 1241.100.11
17131498parent-umbrella:
17141499 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
17151500 arm64e-macos, arm64e-maccatalyst ]
......@@ -1735,19 +1520,6 @@ exports:
17351520tbd-version: 4
17361521targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
17371522 arm64e-macos, arm64e-maccatalyst ]
1738uuids:
1739 - target: x86_64-macos
1740 value: D44E0845-001C-3C46-B3A7-E4926DAEF6B3
1741 - target: x86_64-maccatalyst
1742 value: D44E0845-001C-3C46-B3A7-E4926DAEF6B3
1743 - target: arm64-macos
1744 value: 00000000-0000-0000-0000-000000000000
1745 - target: arm64-maccatalyst
1746 value: 00000000-0000-0000-0000-000000000000
1747 - target: arm64e-macos
1748 value: 2694748C-A452-3438-BB47-161D7B220AE2
1749 - target: arm64e-maccatalyst
1750 value: 2694748C-A452-3438-BB47-161D7B220AE2
17511523install-name: '/usr/lib/system/libsystem_containermanager.dylib'
17521524parent-umbrella:
17531525 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -1792,6 +1564,7 @@ exports:
17921564 _container_create_or_lookup_app_group_paths, _container_create_or_lookup_app_group_paths_for_current_user,
17931565 _container_create_or_lookup_app_group_paths_for_platform,
17941566 _container_create_or_lookup_app_group_paths_from_entitlements,
1567 _container_create_or_lookup_app_group_paths_from_entitlements_4ls,
17951568 _container_create_or_lookup_for_current_user, _container_create_or_lookup_for_platform,
17961569 _container_create_or_lookup_group_container_paths_for_current_user,
17971570 _container_create_or_lookup_path, _container_create_or_lookup_path_for_current_user,
......@@ -1910,19 +1683,6 @@ exports:
19101683tbd-version: 4
19111684targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
19121685 arm64e-macos, arm64e-maccatalyst ]
1913uuids:
1914 - target: x86_64-macos
1915 value: D86D13CC-2AF9-3A17-BCF3-0D16703F99A7
1916 - target: x86_64-maccatalyst
1917 value: D86D13CC-2AF9-3A17-BCF3-0D16703F99A7
1918 - target: arm64-macos
1919 value: 00000000-0000-0000-0000-000000000000
1920 - target: arm64-maccatalyst
1921 value: 00000000-0000-0000-0000-000000000000
1922 - target: arm64e-macos
1923 value: 6E9DED8E-2A44-33E3-909F-74B4786482A2
1924 - target: arm64e-maccatalyst
1925 value: 6E9DED8E-2A44-33E3-909F-74B4786482A2
19261686install-name: '/usr/lib/system/libsystem_coreservices.dylib'
19271687current-version: 129
19281688parent-umbrella:
......@@ -1944,19 +1704,6 @@ exports:
19441704tbd-version: 4
19451705targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
19461706 arm64e-macos, arm64e-maccatalyst ]
1947uuids:
1948 - target: x86_64-macos
1949 value: E272E2C2-8511-3C94-8C39-F5319F2812BB
1950 - target: x86_64-maccatalyst
1951 value: E272E2C2-8511-3C94-8C39-F5319F2812BB
1952 - target: arm64-macos
1953 value: 00000000-0000-0000-0000-000000000000
1954 - target: arm64-maccatalyst
1955 value: 00000000-0000-0000-0000-000000000000
1956 - target: arm64e-macos
1957 value: 74F6C923-5FF6-39D0-90DE-8FB4812EA263
1958 - target: arm64e-maccatalyst
1959 value: 74F6C923-5FF6-39D0-90DE-8FB4812EA263
19601707install-name: '/usr/lib/system/libsystem_darwin.dylib'
19611708parent-umbrella:
19621709 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -1995,21 +1742,8 @@ exports:
19951742tbd-version: 4
19961743targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
19971744 arm64e-macos, arm64e-maccatalyst ]
1998uuids:
1999 - target: x86_64-macos
2000 value: 77610ACE-81D4-33E5-A343-5FDA27F53E10
2001 - target: x86_64-maccatalyst
2002 value: 77610ACE-81D4-33E5-A343-5FDA27F53E10
2003 - target: arm64-macos
2004 value: 00000000-0000-0000-0000-000000000000
2005 - target: arm64-maccatalyst
2006 value: 00000000-0000-0000-0000-000000000000
2007 - target: arm64e-macos
2008 value: F87EFC17-B673-3488-B503-C67E2FFDE6A0
2009 - target: arm64e-maccatalyst
2010 value: F87EFC17-B673-3488-B503-C67E2FFDE6A0
20111745install-name: '/usr/lib/system/libsystem_dnssd.dylib'
2012current-version: 1790.60.25
1746current-version: 1807.101.2
20131747parent-umbrella:
20141748 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
20151749 arm64e-macos, arm64e-maccatalyst ]
......@@ -2045,21 +1779,8 @@ exports:
20451779tbd-version: 4
20461780targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
20471781 arm64e-macos, arm64e-maccatalyst ]
2048uuids:
2049 - target: x86_64-macos
2050 value: 223BBDCF-6D59-3770-9E6A-38B762676030
2051 - target: x86_64-maccatalyst
2052 value: 223BBDCF-6D59-3770-9E6A-38B762676030
2053 - target: arm64-macos
2054 value: 00000000-0000-0000-0000-000000000000
2055 - target: arm64-maccatalyst
2056 value: 00000000-0000-0000-0000-000000000000
2057 - target: arm64e-macos
2058 value: EE355E15-A47F-3BED-A955-1041497449AE
2059 - target: arm64e-maccatalyst
2060 value: EE355E15-A47F-3BED-A955-1041497449AE
20611782install-name: '/usr/lib/system/libsystem_featureflags.dylib'
2062current-version: 71
1783current-version: 74
20631784parent-umbrella:
20641785 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
20651786 arm64e-macos, arm64e-maccatalyst ]
......@@ -2072,19 +1793,6 @@ exports:
20721793tbd-version: 4
20731794targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
20741795 arm64e-macos, arm64e-maccatalyst ]
2075uuids:
2076 - target: x86_64-macos
2077 value: 7B76D94D-56F7-3B8A-B63D-ED567EFA12F6
2078 - target: x86_64-maccatalyst
2079 value: 7B76D94D-56F7-3B8A-B63D-ED567EFA12F6
2080 - target: arm64-macos
2081 value: 00000000-0000-0000-0000-000000000000
2082 - target: arm64-maccatalyst
2083 value: 00000000-0000-0000-0000-000000000000
2084 - target: arm64e-macos
2085 value: 67168754-ABAC-33C6-AFF7-FF53F1A8745C
2086 - target: arm64e-maccatalyst
2087 value: 67168754-ABAC-33C6-AFF7-FF53F1A8745C
20881796install-name: '/usr/lib/system/libsystem_info.dylib'
20891797parent-umbrella:
20901798 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -2209,21 +1917,8 @@ exports:
22091917tbd-version: 4
22101918targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
22111919 arm64e-macos, arm64e-maccatalyst ]
2212uuids:
2213 - target: x86_64-macos
2214 value: 7C3DCC95-9F42-3C7C-8796-476FF67B9CF7
2215 - target: x86_64-maccatalyst
2216 value: 7C3DCC95-9F42-3C7C-8796-476FF67B9CF7
2217 - target: arm64-macos
2218 value: EB0327EE-CB9C-37ED-AB6A-E9AF74E814F0
2219 - target: arm64-maccatalyst
2220 value: EB0327EE-CB9C-37ED-AB6A-E9AF74E814F0
2221 - target: arm64e-macos
2222 value: AEBF397E-E2EF-3A49-BE58-23D4558511F6
2223 - target: arm64e-maccatalyst
2224 value: AEBF397E-E2EF-3A49-BE58-23D4558511F6
22251920install-name: '/usr/lib/system/libsystem_kernel.dylib'
2226current-version: 8792.61.2
1921current-version: 8796.101.5
22271922parent-umbrella:
22281923 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
22291924 arm64e-macos, arm64e-maccatalyst ]
......@@ -2243,19 +1938,20 @@ exports:
22431938 ___channel_get_opt, ___channel_open, ___channel_set_opt, ___channel_sync,
22441939 ___chmod, ___chmod_extended, ___close_nocancel, ___coalition,
22451940 ___coalition_info, ___coalition_ledger, ___commpage_gettimeofday,
2246 ___connect, ___connect_nocancel, ___copyfile, ___csrctl, ___darwin_check_fd_set_overflow,
2247 ___debug_syscall_reject, ___debug_syscall_reject_config, ___delete,
2248 ___disable_threadsignal, ___error, ___execve, ___exit, ___fchmod,
2249 ___fchmod_extended, ___fcntl, ___fcntl_nocancel, ___fork,
2250 ___fs_snapshot, ___fstat64_extended, ___fstat_extended, ___fsync_nocancel,
2251 ___get_remove_counter, ___getattrlist, ___getdirentries64,
2252 ___gethostuuid, ___getlogin, ___getpeername, ___getpid, ___getrlimit,
2253 ___getsgroups, ___getsockname, ___gettid, ___gettimeofday,
2254 ___getwgroups, ___guarded_open_dprotected_np, ___guarded_open_np,
2255 ___identitysvc, ___inc_remove_counter, ___initgroups, ___ioctl,
2256 ___iopolicysys, ___kdebug_trace, ___kdebug_trace64, ___kdebug_trace_string,
2257 ___kdebug_typefilter, ___kill, ___kqueue_workloop_ctl, ___lchown,
2258 ___libkernel_init, ___libkernel_init_after_boot_tasks, ___libkernel_init_late,
1941 ___connect, ___connect_nocancel, ___copyfile, ___crossarch_trap,
1942 ___csrctl, ___darwin_check_fd_set_overflow, ___debug_syscall_reject,
1943 ___debug_syscall_reject_config, ___delete, ___disable_threadsignal,
1944 ___error, ___execve, ___exit, ___fchmod, ___fchmod_extended,
1945 ___fcntl, ___fcntl_nocancel, ___fork, ___fs_snapshot, ___fstat64_extended,
1946 ___fstat_extended, ___fsync_nocancel, ___get_remove_counter,
1947 ___getattrlist, ___getdirentries64, ___gethostuuid, ___getlogin,
1948 ___getpeername, ___getpid, ___getrlimit, ___getsgroups, ___getsockname,
1949 ___gettid, ___gettimeofday, ___getwgroups, ___guarded_open_dprotected_np,
1950 ___guarded_open_np, ___identitysvc, ___inc_remove_counter,
1951 ___initgroups, ___ioctl, ___iopolicysys, ___kdebug_trace,
1952 ___kdebug_trace64, ___kdebug_trace_string, ___kdebug_typefilter,
1953 ___kill, ___kqueue_workloop_ctl, ___lchown, ___libkernel_init,
1954 ___libkernel_init_after_boot_tasks, ___libkernel_init_late,
22591955 ___libkernel_platform_init, ___libkernel_voucher_init, ___listen,
22601956 ___log_data, ___lseek, ___lstat64_extended, ___lstat_extended,
22611957 ___mac_execve, ___mac_get_fd, ___mac_get_file, ___mac_get_link,
......@@ -2572,32 +2268,32 @@ exports:
25722268 _posix_spawnattr_set_uid_np, _posix_spawnattr_setarchpref_np,
25732269 _posix_spawnattr_setauditsessionport_np, _posix_spawnattr_setbinpref_np,
25742270 _posix_spawnattr_setcoalition_np, _posix_spawnattr_setcpumonitor,
2575 _posix_spawnattr_setcpumonitor_default, _posix_spawnattr_setexceptionports_np,
2576 _posix_spawnattr_setflags, _posix_spawnattr_setjetsam_ext,
2577 _posix_spawnattr_setmacpolicyinfo_np, _posix_spawnattr_setnosmt_np,
2578 _posix_spawnattr_setpcontrol_np, _posix_spawnattr_setpgroup,
2579 _posix_spawnattr_setprocesstype_np, _posix_spawnattr_setsigdefault,
2580 _posix_spawnattr_setsigmask, _posix_spawnattr_setspecialport_np,
2581 _pread, '_pread$NOCANCEL', _preadv, '_preadv$NOCANCEL', _proc_clear_cpulimits,
2582 _proc_clear_delayidlesleep, _proc_clear_dirty, _proc_clear_vmpressure,
2583 _proc_current_thread_schedinfo, _proc_denap_assertion_begin_with_msg,
2584 _proc_denap_assertion_complete, _proc_disable_apptype, _proc_disable_cpumon,
2585 _proc_disable_wakemon, _proc_donate_importance_boost, _proc_enable_apptype,
2586 _proc_get_cpumon_params, _proc_get_dirty, _proc_get_wakemon_params,
2587 _proc_importance_assertion_begin_with_msg, _proc_importance_assertion_complete,
2588 _proc_kmsgbuf, _proc_libversion, _proc_list_dynkqueueids,
2589 _proc_list_uptrs, _proc_listallpids, _proc_listchildpids,
2590 _proc_listcoalitions, _proc_listpgrppids, _proc_listpids,
2591 _proc_listpidspath, _proc_name, _proc_pid_rusage, _proc_piddynkqueueinfo,
2592 _proc_pidfdinfo, _proc_pidfileportinfo, _proc_pidinfo, _proc_pidoriginatorinfo,
2593 _proc_pidpath, _proc_pidpath_audittoken, _proc_regionfilename,
2594 _proc_reset_footprint_interval, _proc_resume_cpumon, _proc_rlimit_control,
2595 _proc_set_cpumon_defaults, _proc_set_cpumon_params, _proc_set_cpumon_params_fatal,
2596 _proc_set_csm, _proc_set_delayidlesleep, _proc_set_dirty,
2597 _proc_set_no_smt, _proc_set_owner_vmpressure, _proc_set_wakemon_defaults,
2598 _proc_set_wakemon_params, _proc_setcpu_percentage, _proc_setpcontrol,
2599 _proc_setthread_cpupercent, _proc_setthread_csm, _proc_setthread_no_smt,
2600 _proc_suppress, _proc_terminate, _proc_terminate_all_rsr,
2271 _posix_spawnattr_setcpumonitor_default, _posix_spawnattr_setdataless_iopolicy_np,
2272 _posix_spawnattr_setexceptionports_np, _posix_spawnattr_setflags,
2273 _posix_spawnattr_setjetsam_ext, _posix_spawnattr_setmacpolicyinfo_np,
2274 _posix_spawnattr_setnosmt_np, _posix_spawnattr_setpcontrol_np,
2275 _posix_spawnattr_setpgroup, _posix_spawnattr_setprocesstype_np,
2276 _posix_spawnattr_setsigdefault, _posix_spawnattr_setsigmask,
2277 _posix_spawnattr_setspecialport_np, _pread, '_pread$NOCANCEL',
2278 _preadv, '_preadv$NOCANCEL', _proc_clear_cpulimits, _proc_clear_delayidlesleep,
2279 _proc_clear_dirty, _proc_clear_vmpressure, _proc_current_thread_schedinfo,
2280 _proc_denap_assertion_begin_with_msg, _proc_denap_assertion_complete,
2281 _proc_disable_apptype, _proc_disable_cpumon, _proc_disable_wakemon,
2282 _proc_donate_importance_boost, _proc_enable_apptype, _proc_get_cpumon_params,
2283 _proc_get_dirty, _proc_get_wakemon_params, _proc_importance_assertion_begin_with_msg,
2284 _proc_importance_assertion_complete, _proc_kmsgbuf, _proc_libversion,
2285 _proc_list_dynkqueueids, _proc_list_uptrs, _proc_listallpids,
2286 _proc_listchildpids, _proc_listcoalitions, _proc_listpgrppids,
2287 _proc_listpids, _proc_listpidspath, _proc_name, _proc_pid_rusage,
2288 _proc_piddynkqueueinfo, _proc_pidfdinfo, _proc_pidfileportinfo,
2289 _proc_pidinfo, _proc_pidoriginatorinfo, _proc_pidpath, _proc_pidpath_audittoken,
2290 _proc_regionfilename, _proc_reset_footprint_interval, _proc_resume_cpumon,
2291 _proc_rlimit_control, _proc_set_cpumon_defaults, _proc_set_cpumon_params,
2292 _proc_set_cpumon_params_fatal, _proc_set_csm, _proc_set_delayidlesleep,
2293 _proc_set_dirty, _proc_set_no_smt, _proc_set_owner_vmpressure,
2294 _proc_set_wakemon_defaults, _proc_set_wakemon_params, _proc_setcpu_percentage,
2295 _proc_setpcontrol, _proc_setthread_cpupercent, _proc_setthread_csm,
2296 _proc_setthread_no_smt, _proc_suppress, _proc_terminate, _proc_terminate_all_rsr,
26012297 _proc_trace_log, _proc_track_dirty, _proc_udata_info, _proc_uuid_policy,
26022298 _processor_assign, _processor_control, _processor_exit, _processor_get_assignment,
26032299 _processor_info, _processor_set_create, _processor_set_default,
......@@ -2707,25 +2403,8 @@ exports:
27072403tbd-version: 4
27082404targets: [ x86_64-macos, x86_64-maccatalyst, x86_64h-macos, x86_64h-maccatalyst,
27092405 arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ]
2710uuids:
2711 - target: x86_64-macos
2712 value: DC460796-C8A7-3507-8539-C890D9EDDC8C
2713 - target: x86_64-maccatalyst
2714 value: DC460796-C8A7-3507-8539-C890D9EDDC8C
2715 - target: x86_64h-macos
2716 value: 73F0FC1C-FC2A-3B36-8796-7C2C2CBA7214
2717 - target: x86_64h-maccatalyst
2718 value: 73F0FC1C-FC2A-3B36-8796-7C2C2CBA7214
2719 - target: arm64-macos
2720 value: 00000000-0000-0000-0000-000000000000
2721 - target: arm64-maccatalyst
2722 value: 00000000-0000-0000-0000-000000000000
2723 - target: arm64e-macos
2724 value: 6BEE17F3-04F2-3B1F-B8EB-C94379ABA9BD
2725 - target: arm64e-maccatalyst
2726 value: 6BEE17F3-04F2-3B1F-B8EB-C94379ABA9BD
27272406install-name: '/usr/lib/system/libsystem_m.dylib'
2728current-version: 3226.0.1
2407current-version: 3226.100.4
27292408parent-umbrella:
27302409 - targets: [ x86_64-macos, x86_64-maccatalyst, x86_64h-macos, x86_64h-maccatalyst,
27312410 arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ]
......@@ -2938,21 +2617,8 @@ exports:
29382617tbd-version: 4
29392618targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
29402619 arm64e-macos, arm64e-maccatalyst ]
2941uuids:
2942 - target: x86_64-macos
2943 value: F609F029-BCD0-3A54-B48A-99B3CE8378CE
2944 - target: x86_64-maccatalyst
2945 value: F609F029-BCD0-3A54-B48A-99B3CE8378CE
2946 - target: arm64-macos
2947 value: 00000000-0000-0000-0000-000000000000
2948 - target: arm64-maccatalyst
2949 value: 00000000-0000-0000-0000-000000000000
2950 - target: arm64e-macos
2951 value: 04185997-16D2-30DA-8691-7C82612635A3
2952 - target: arm64e-maccatalyst
2953 value: 04185997-16D2-30DA-8691-7C82612635A3
29542620install-name: '/usr/lib/system/libsystem_malloc.dylib'
2955current-version: 409.60.6
2621current-version: 425.100.7
29562622parent-umbrella:
29572623 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
29582624 arm64e-macos, arm64e-maccatalyst ]
......@@ -2992,7 +2658,7 @@ exports:
29922658 _malloc_zone_print, _malloc_zone_print_ptr_info, _malloc_zone_realloc,
29932659 _malloc_zone_register, _malloc_zone_statistics, _malloc_zone_unregister,
29942660 _malloc_zone_valloc, _malloc_zones, _mstats, _pgm_diagnose_fault_from_crash_reporter,
2995 _pgm_disable_for_current_thread, _posix_memalign, _quarantine_diagnose_fault_from_crash_reporter,
2661 _posix_memalign, _quarantine_diagnose_fault_from_crash_reporter,
29962662 _realloc, '_reallocarray$DARWIN_EXTSN', '_reallocarrayf$DARWIN_EXTSN',
29972663 _scalable_zone_info, _scalable_zone_statistics, _set_malloc_singlethreaded,
29982664 _stack_logging_enable_logging, _szone_check_counter, _szone_check_modulo,
......@@ -3002,19 +2668,6 @@ exports:
30022668tbd-version: 4
30032669targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
30042670 arm64e-macos, arm64e-maccatalyst ]
3005uuids:
3006 - target: x86_64-macos
3007 value: 09114B12-EC3D-3943-A1BD-9909EE2F85B6
3008 - target: x86_64-maccatalyst
3009 value: 09114B12-EC3D-3943-A1BD-9909EE2F85B6
3010 - target: arm64-macos
3011 value: 00000000-0000-0000-0000-000000000000
3012 - target: arm64-maccatalyst
3013 value: 00000000-0000-0000-0000-000000000000
3014 - target: arm64e-macos
3015 value: 8737AB7F-91FA-3C06-B797-566A62D0751C
3016 - target: arm64e-maccatalyst
3017 value: 8737AB7F-91FA-3C06-B797-566A62D0751C
30182671install-name: '/usr/lib/system/libsystem_networkextension.dylib'
30192672parent-umbrella:
30202673 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -3039,9 +2692,9 @@ exports:
30392692 _NEHelperSettingsSetArray, _NEHelperSettingsSetBool, _NEHelperSettingsSetNumber,
30402693 _NEHelperVPNConfigurationExists, _NEHelperVPNSetEnabled, _g_ne_read_uuid_cache,
30412694 _g_ne_uuid_cache_hit, _ne_copy_cached_bundle_identifier_for_uuid,
3042 _ne_copy_cached_preferred_bundle_for_bundle_identifier, _ne_copy_cached_uuids_for_bundle_identifier,
3043 _ne_copy_signature_info_for_pid, _ne_copy_signing_identifier_for_pid,
3044 _ne_copy_uuid_cache, _ne_force_reset_uuid_cache, _ne_get_configuration_generation,
2695 _ne_copy_cached_uuids_for_bundle_identifier, _ne_copy_signature_info_for_pid,
2696 _ne_copy_signing_identifier_for_pid, _ne_copy_uuid_cache,
2697 _ne_force_reset_uuid_cache, _ne_get_configuration_generation,
30452698 _ne_is_sockaddr_valid, _ne_log_large_obj, _ne_log_obj, _ne_print_backtrace,
30462699 _ne_privacy_dns_netagent_id, _ne_privacy_proxy_netagent_id,
30472700 _ne_session_add_necp_drop_dest_from_dest_list, _ne_session_add_necp_drop_dest_from_path,
......@@ -3069,20 +2722,20 @@ exports:
30692722 _ne_session_policy_match_get_service, _ne_session_policy_match_get_service_action,
30702723 _ne_session_policy_match_get_service_type, _ne_session_policy_match_is_drop,
30712724 _ne_session_policy_match_is_flow_divert, _ne_session_policy_match_service_is_registered,
3072 _ne_session_release, _ne_session_retain, _ne_session_send_barrier,
3073 _ne_session_service_get_dns_service_id, _ne_session_service_get_dns_service_id_for_interface,
3074 _ne_session_service_matches_address, _ne_session_service_matches_address_for_interface,
3075 _ne_session_set_event_handler, _ne_session_set_socket_attributes,
3076 _ne_session_set_socket_context_attribute, _ne_session_set_socket_tracker_attributes,
3077 _ne_session_should_disable_nexus, _ne_session_start, _ne_session_start_on_behalf_of,
3078 _ne_session_start_with_options, _ne_session_status_to_string,
3079 _ne_session_stop, _ne_session_stop_all_with_plugin_type, _ne_session_stop_reason_to_string,
3080 _ne_session_type_to_string, _ne_session_use_as_system_vpn,
3081 _ne_session_vod_evaluate_connection_present, _ne_session_vpn_include_all_networks_configs_present,
3082 _ne_socket_set_attribution, _ne_socket_set_domains, _ne_socket_set_is_app_initiated,
3083 _ne_socket_set_website_attribution, _ne_tracker_build_cache,
3084 _ne_tracker_build_trie, _ne_tracker_check_info_changed, _ne_tracker_clear_cache,
3085 _ne_tracker_context_get_domain, _ne_tracker_context_get_domain_owner,
2725 _ne_session_random_port_fallback, _ne_session_release, _ne_session_retain,
2726 _ne_session_send_barrier, _ne_session_service_get_dns_service_id,
2727 _ne_session_service_get_dns_service_id_for_interface, _ne_session_service_matches_address,
2728 _ne_session_service_matches_address_for_interface, _ne_session_set_event_handler,
2729 _ne_session_set_socket_attributes, _ne_session_set_socket_context_attribute,
2730 _ne_session_set_socket_tracker_attributes, _ne_session_should_disable_nexus,
2731 _ne_session_start, _ne_session_start_on_behalf_of, _ne_session_start_with_options,
2732 _ne_session_status_to_string, _ne_session_stop, _ne_session_stop_all_with_plugin_type,
2733 _ne_session_stop_reason_to_string, _ne_session_type_to_string,
2734 _ne_session_use_as_system_vpn, _ne_session_vod_evaluate_connection_present,
2735 _ne_session_vpn_include_all_networks_configs_present, _ne_socket_set_attribution,
2736 _ne_socket_set_domains, _ne_socket_set_is_app_initiated, _ne_socket_set_website_attribution,
2737 _ne_tracker_build_cache, _ne_tracker_build_trie, _ne_tracker_check_info_changed,
2738 _ne_tracker_clear_cache, _ne_tracker_context_get_domain, _ne_tracker_context_get_domain_owner,
30862739 _ne_tracker_context_is_from_app_list, _ne_tracker_context_is_from_web_list,
30872740 _ne_tracker_get_ddg_dictionary, _ne_tracker_lookup_app_domains,
30882741 _ne_tracker_set_test_domains, _ne_tracker_validate_domain,
......@@ -3095,21 +2748,8 @@ exports:
30952748tbd-version: 4
30962749targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
30972750 arm64e-macos, arm64e-maccatalyst ]
3098uuids:
3099 - target: x86_64-macos
3100 value: 0463374D-9E62-3E58-A668-C9EFF9DB217C
3101 - target: x86_64-maccatalyst
3102 value: 0463374D-9E62-3E58-A668-C9EFF9DB217C
3103 - target: arm64-macos
3104 value: 00000000-0000-0000-0000-000000000000
3105 - target: arm64-maccatalyst
3106 value: 00000000-0000-0000-0000-000000000000
3107 - target: arm64e-macos
3108 value: 62FA1CCF-D4BB-3606-BDC9-C2F247A12CE8
3109 - target: arm64e-maccatalyst
3110 value: 62FA1CCF-D4BB-3606-BDC9-C2F247A12CE8
31112751install-name: '/usr/lib/system/libsystem_notify.dylib'
3112current-version: 306
2752current-version: 312
31132753parent-umbrella:
31142754 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
31152755 arm64e-macos, arm64e-maccatalyst ]
......@@ -3128,21 +2768,8 @@ exports:
31282768tbd-version: 4
31292769targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
31302770 arm64e-macos, arm64e-maccatalyst ]
3131uuids:
3132 - target: x86_64-macos
3133 value: F314B62B-98F4-3A7C-8296-8739F8B6855A
3134 - target: x86_64-maccatalyst
3135 value: F314B62B-98F4-3A7C-8296-8739F8B6855A
3136 - target: arm64-macos
3137 value: ABF0BAEB-706B-3AC1-B6AD-B5CF380B8963
3138 - target: arm64-maccatalyst
3139 value: ABF0BAEB-706B-3AC1-B6AD-B5CF380B8963
3140 - target: arm64e-macos
3141 value: B215AE90-4ED2-3FCD-8CCC-6C0D93CC4F41
3142 - target: arm64e-maccatalyst
3143 value: B215AE90-4ED2-3FCD-8CCC-6C0D93CC4F41
31442771install-name: '/usr/lib/system/libsystem_platform.dylib'
3145current-version: 288
2772current-version: 292.100.1
31462773parent-umbrella:
31472774 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
31482775 arm64e-macos, arm64e-maccatalyst ]
......@@ -3204,37 +2831,18 @@ exports:
32042831 _os_unfair_lock_unlock, _os_unfair_lock_unlock_no_tsd, _os_unfair_recursive_lock_lock_with_options,
32052832 _os_unfair_recursive_lock_owned, _os_unfair_recursive_lock_trylock,
32062833 _os_unfair_recursive_lock_tryunlock4objc, _os_unfair_recursive_lock_unlock,
3207 _os_unfair_recursive_lock_unlock_forked_child, _platform_task_attach,
3208 _platform_task_copy_next_thread, _platform_task_detach, _platform_task_is_64_bit,
3209 _platform_task_perform, _platform_task_resume_threads, _platform_task_suspend_threads,
3210 _platform_task_update_threads, _platform_thread_abort_safely,
3211 _platform_thread_get_pthread, _platform_thread_get_state,
3212 _platform_thread_get_unique_id, _platform_thread_info, _platform_thread_perform,
3213 _platform_thread_release, _platform_thread_resume, _platform_thread_set_state,
3214 _platform_thread_suspend, _setcontext, _setjmp, _siglongjmp,
3215 _sigsetjmp, _spin_lock, _spin_lock_try, _spin_unlock, _swapcontext,
3216 _sys_cache_control, _sys_dcache_flush, _sys_icache_invalidate ]
2834 _os_unfair_recursive_lock_unlock_forked_child, _setcontext,
2835 _setjmp, _siglongjmp, _sigsetjmp, _spin_lock, _spin_lock_try,
2836 _spin_unlock, _swapcontext, _sys_cache_control, _sys_dcache_flush,
2837 _sys_icache_invalidate ]
32172838 - targets: [ arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ]
32182839 symbols: [ __ctx_done ]
32192840--- !tapi-tbd
32202841tbd-version: 4
32212842targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
32222843 arm64e-macos, arm64e-maccatalyst ]
3223uuids:
3224 - target: x86_64-macos
3225 value: 5920E36F-53EC-33F0-B675-8AE48B58418C
3226 - target: x86_64-maccatalyst
3227 value: 5920E36F-53EC-33F0-B675-8AE48B58418C
3228 - target: arm64-macos
3229 value: 51C613E3-4ABF-359C-B275-2608BB1BE0B6
3230 - target: arm64-maccatalyst
3231 value: 51C613E3-4ABF-359C-B275-2608BB1BE0B6
3232 - target: arm64e-macos
3233 value: 132084C6-C347-3489-9AC2-FCAAD21CDB73
3234 - target: arm64e-maccatalyst
3235 value: 132084C6-C347-3489-9AC2-FCAAD21CDB73
32362844install-name: '/usr/lib/system/libsystem_pthread.dylib'
3237current-version: 514
2845current-version: 514.100.2
32382846parent-umbrella:
32392847 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
32402848 arm64e-macos, arm64e-maccatalyst ]
......@@ -3328,21 +2936,8 @@ exports:
33282936tbd-version: 4
33292937targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
33302938 arm64e-macos, arm64e-maccatalyst ]
3331uuids:
3332 - target: x86_64-macos
3333 value: D199B283-8F09-3F2F-A17E-274BFF7733BE
3334 - target: x86_64-maccatalyst
3335 value: D199B283-8F09-3F2F-A17E-274BFF7733BE
3336 - target: arm64-macos
3337 value: 00000000-0000-0000-0000-000000000000
3338 - target: arm64-maccatalyst
3339 value: 00000000-0000-0000-0000-000000000000
3340 - target: arm64e-macos
3341 value: 3680811A-78F7-361A-ABBE-8E783165AC81
3342 - target: arm64e-maccatalyst
3343 value: 3680811A-78F7-361A-ABBE-8E783165AC81
33442939install-name: '/usr/lib/system/libsystem_sandbox.dylib'
3345current-version: 1845.60.12
2940current-version: 1846.100.185
33462941parent-umbrella:
33472942 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
33482943 arm64e-macos, arm64e-maccatalyst ]
......@@ -3370,8 +2965,8 @@ exports:
33702965 _rootless_check_trusted_class, _rootless_check_trusted_fd,
33712966 _rootless_convert_to_datavault, _rootless_manifest_free, _rootless_manifest_parse,
33722967 _rootless_mkdir_datavault, _rootless_mkdir_nounlink, _rootless_mkdir_restricted,
3373 _rootless_preflight, _rootless_protected_volume, _rootless_register_trusted_storage_class,
3374 _rootless_remove_datavault_in_favor_of_static_storage_class,
2968 _rootless_preflight, _rootless_protected_volume, _rootless_protected_volume_fd,
2969 _rootless_register_trusted_storage_class, _rootless_remove_datavault_in_favor_of_static_storage_class,
33752970 _rootless_remove_restricted_in_favor_of_static_storage_class,
33762971 _rootless_restricted_environment, _rootless_suspend, _rootless_trusted_by_self_token,
33772972 _rootless_verify_trusted_by_self_token, _sandbox_builtin_query,
......@@ -3415,21 +3010,8 @@ exports:
34153010tbd-version: 4
34163011targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
34173012 arm64e-macos, arm64e-maccatalyst ]
3418uuids:
3419 - target: x86_64-macos
3420 value: F24B1FA9-5692-35BA-9A9C-E071B7BFA5D7
3421 - target: x86_64-maccatalyst
3422 value: F24B1FA9-5692-35BA-9A9C-E071B7BFA5D7
3423 - target: arm64-macos
3424 value: 00000000-0000-0000-0000-000000000000
3425 - target: arm64-maccatalyst
3426 value: 00000000-0000-0000-0000-000000000000
3427 - target: arm64e-macos
3428 value: 82513DC5-565F-3A4E-9431-4511FB0C22FA
3429 - target: arm64e-maccatalyst
3430 value: 82513DC5-565F-3A4E-9431-4511FB0C22FA
34313013install-name: '/usr/lib/system/libsystem_secinit.dylib'
3432current-version: 119.40.2
3014current-version: 120.100.7
34333015parent-umbrella:
34343016 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
34353017 arm64e-macos, arm64e-maccatalyst ]
......@@ -3444,19 +3026,6 @@ exports:
34443026tbd-version: 4
34453027targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
34463028 arm64e-macos, arm64e-maccatalyst ]
3447uuids:
3448 - target: x86_64-macos
3449 value: A5915FB2-F0C9-3BF0-ADC6-BEB571C73E57
3450 - target: x86_64-maccatalyst
3451 value: A5915FB2-F0C9-3BF0-ADC6-BEB571C73E57
3452 - target: arm64-macos
3453 value: 00000000-0000-0000-0000-000000000000
3454 - target: arm64-maccatalyst
3455 value: 00000000-0000-0000-0000-000000000000
3456 - target: arm64e-macos
3457 value: B31CD553-083B-39C6-BCB9-B0413ECAF562
3458 - target: arm64e-maccatalyst
3459 value: B31CD553-083B-39C6-BCB9-B0413ECAF562
34603029install-name: '/usr/lib/system/libsystem_symptoms.dylib'
34613030parent-umbrella:
34623031 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
......@@ -3474,21 +3043,8 @@ exports:
34743043tbd-version: 4
34753044targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
34763045 arm64e-macos, arm64e-maccatalyst ]
3477uuids:
3478 - target: x86_64-macos
3479 value: C5359E6E-7B63-3E51-A664-3E3581E15F52
3480 - target: x86_64-maccatalyst
3481 value: C5359E6E-7B63-3E51-A664-3E3581E15F52
3482 - target: arm64-macos
3483 value: 00000000-0000-0000-0000-000000000000
3484 - target: arm64-maccatalyst
3485 value: 00000000-0000-0000-0000-000000000000
3486 - target: arm64e-macos
3487 value: 616F473A-EB21-377D-B3B4-F1581F127F0D
3488 - target: arm64e-maccatalyst
3489 value: 616F473A-EB21-377D-B3B4-F1581F127F0D
34903046install-name: '/usr/lib/system/libsystem_trace.dylib'
3491current-version: 1406.60.2
3047current-version: 1431.100.13
34923048parent-umbrella:
34933049 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
34943050 arm64e-macos, arm64e-maccatalyst ]
......@@ -3534,15 +3090,17 @@ exports:
35343090 _os_log_backtrace_create_from_return_address, _os_log_backtrace_destroy,
35353091 _os_log_backtrace_get_frames, _os_log_backtrace_get_length,
35363092 _os_log_backtrace_print_to_blob, _os_log_backtrace_serialize_to_blob,
3537 _os_log_create, _os_log_errors_count, _os_log_fault_default_callback,
3538 _os_log_faults_count, _os_log_fmt_compose, _os_log_fmt_convert_trace,
3539 _os_log_fmt_extract_pubdata, _os_log_fmt_get_plugin, _os_log_get_type,
3540 _os_log_is_debug_enabled, _os_log_is_enabled, _os_log_pack_compose,
3541 _os_log_pack_send, _os_log_pack_send_and_compose, _os_log_set_client_type,
3542 _os_log_set_enabled, _os_log_set_fault_callback, _os_log_shim_enabled,
3093 _os_log_compare_enablement, _os_log_copy_decorated_message,
3094 _os_log_copy_message_string, _os_log_create, _os_log_errors_count,
3095 _os_log_fault_default_callback, _os_log_faults_count, _os_log_fmt_compose,
3096 _os_log_fmt_convert_trace, _os_log_fmt_extract_pubdata, _os_log_fmt_get_plugin,
3097 _os_log_get_type, _os_log_is_debug_enabled, _os_log_is_enabled,
3098 _os_log_pack_compose, _os_log_pack_send, _os_log_pack_send_and_compose,
3099 _os_log_set_client_type, _os_log_set_enabled, _os_log_set_fault_callback,
3100 _os_log_set_hook, _os_log_set_test_callback, _os_log_shim_enabled,
35433101 _os_log_shim_legacy_logging_enabled, _os_log_shim_with_CFString,
3544 _os_log_type_enabled, _os_log_with_args, _os_signpost_enabled,
3545 _os_signpost_id_generate, _os_signpost_id_make_with_pointer,
3102 _os_log_type_enabled, _os_log_type_get_name, _os_log_with_args,
3103 _os_signpost_enabled, _os_signpost_id_generate, _os_signpost_id_make_with_pointer,
35463104 _os_signpost_set_introspection_hook_4Perf, _os_state_add_handler,
35473105 _os_state_remove_handler, _os_trace_debug_enabled, _os_trace_get_mode,
35483106 _os_trace_get_type, _os_trace_info_enabled, _os_trace_set_mode ]
......@@ -3551,21 +3109,8 @@ exports:
35513109tbd-version: 4
35523110targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
35533111 arm64e-macos, arm64e-maccatalyst ]
3554uuids:
3555 - target: x86_64-macos
3556 value: E45FA86E-48EB-3926-A24C-323DB84D3700
3557 - target: x86_64-maccatalyst
3558 value: E45FA86E-48EB-3926-A24C-323DB84D3700
3559 - target: arm64-macos
3560 value: 00000000-0000-0000-0000-000000000000
3561 - target: arm64-maccatalyst
3562 value: 00000000-0000-0000-0000-000000000000
3563 - target: arm64e-macos
3564 value: 1228EDDF-7C61-3674-8C42-B537FFE9EDDA
3565 - target: arm64e-maccatalyst
3566 value: 1228EDDF-7C61-3674-8C42-B537FFE9EDDA
35673112install-name: '/usr/lib/system/libunwind.dylib'
3568current-version: 202.100
3113current-version: 1500.26
35693114parent-umbrella:
35703115 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
35713116 arm64e-macos, arm64e-maccatalyst ]
......@@ -3614,7 +3159,8 @@ exports:
36143159 __Unwind_GetLanguageSpecificData, __Unwind_GetRegionStart,
36153160 __Unwind_GetTextRelBase, __Unwind_RaiseException, __Unwind_Resume,
36163161 __Unwind_Resume_or_Rethrow, __Unwind_SetGR, __Unwind_SetIP,
3617 ___deregister_frame, ___register_frame, ___unw_add_dynamic_fde,
3162 ___deregister_frame, ___register_frame, ___unw_add_dynamic_eh_frame_section,
3163 ___unw_add_dynamic_fde, ___unw_remove_dynamic_eh_frame_section,
36183164 ___unw_remove_dynamic_fde, _unw_get_fpreg, _unw_get_proc_info,
36193165 _unw_get_proc_name, _unw_get_reg, _unw_getcontext, _unw_init_local,
36203166 _unw_is_fpreg, _unw_is_signal_frame, _unw_iterate_dwarf_unwind_cache,
......@@ -3624,21 +3170,8 @@ exports:
36243170tbd-version: 4
36253171targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
36263172 arm64e-macos, arm64e-maccatalyst ]
3627uuids:
3628 - target: x86_64-macos
3629 value: 7E56F9FE-DC35-3354-BA23-4103C09E22DD
3630 - target: x86_64-maccatalyst
3631 value: 7E56F9FE-DC35-3354-BA23-4103C09E22DD
3632 - target: arm64-macos
3633 value: 00000000-0000-0000-0000-000000000000
3634 - target: arm64-maccatalyst
3635 value: 00000000-0000-0000-0000-000000000000
3636 - target: arm64e-macos
3637 value: 8EF4547D-1AF8-37CF-B15A-29405BF12642
3638 - target: arm64e-maccatalyst
3639 value: 8EF4547D-1AF8-37CF-B15A-29405BF12642
36403173install-name: '/usr/lib/system/libxpc.dylib'
3641current-version: 2462.60.15
3174current-version: 2462.100.95
36423175parent-umbrella:
36433176 - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
36443177 arm64e-macos, arm64e-maccatalyst ]
......@@ -3685,12 +3218,13 @@ exports:
36853218 _XPC_COALITION_INFO_KEY_RESOURCE_USAGE_BLOB, __availability_version_check,
36863219 __launch_job_routine, __launch_job_routine_async, __launch_msg2,
36873220 __launch_server_test_routine, __launch_service_stats_copy_4ppse_impl,
3688 __libxpc_initializer, __spawn_via_launchd, __system_ios_support_version_copy_string_sysctl,
3689 __system_version_copy_string_plist, __system_version_copy_string_sysctl,
3690 __system_version_fallback, __system_version_parse_string,
3691 __vproc_get_last_exit_status, __vproc_grab_subset, __vproc_kickstart_by_label,
3692 __vproc_log, __vproc_log_error, __vproc_logv, __vproc_pid_is_managed,
3693 __vproc_post_fork_ping, __vproc_send_signal_by_label, __vproc_set_global_on_demand,
3221 __launch_service_stats_copy_impl, __libxpc_initializer, __spawn_via_launchd,
3222 __system_ios_support_version_copy_string_sysctl, __system_version_copy_string_plist,
3223 __system_version_copy_string_sysctl, __system_version_fallback,
3224 __system_version_parse_string, __vproc_get_last_exit_status,
3225 __vproc_grab_subset, __vproc_kickstart_by_label, __vproc_log,
3226 __vproc_log_error, __vproc_logv, __vproc_pid_is_managed, __vproc_post_fork_ping,
3227 __vproc_send_signal_by_label, __vproc_set_global_on_demand,
36943228 __vproc_standby_begin, __vproc_standby_count, __vproc_standby_end,
36953229 __vproc_standby_timeout, __vproc_transaction_begin, __vproc_transaction_count,
36963230 __vproc_transaction_count_for_pid, __vproc_transaction_end,
......@@ -3762,16 +3296,17 @@ exports:
37623296 _launch_perfcheck_property_endpoint_name, _launch_perfcheck_property_endpoint_needs_activation,
37633297 _launch_perfcheck_property_endpoints, _launch_remove_external_service,
37643298 _launch_service_instance_copy_uuids, _launch_service_instance_create,
3765 _launch_service_instance_remove, _launch_service_stats_disable_4ppse,
3766 _launch_service_stats_enable_4ppse, _launch_service_stats_is_enabled_4ppse,
3767 _launch_set_service_enabled, _launch_set_system_service_enabled,
3768 _launch_socket_service_check_in, _launch_version_for_user_service_4coresim,
3769 _launch_wait, _launchd_close, _launchd_fdopen, _launchd_getfd,
3770 _launchd_msg_recv, _launchd_msg_send, _load_launchd_jobs_at_loginwindow_prompt,
3771 _mpm_uncork_fork, _mpm_wait, _os_system_version_get_current_version,
3772 _os_system_version_get_ios_support_version, _os_system_version_sim_get_current_host_version,
3773 _os_transaction_copy_description, _os_transaction_create,
3774 _os_transaction_get_description, _os_transaction_get_timestamp,
3299 _launch_service_instance_remove, _launch_service_stats_disable,
3300 _launch_service_stats_disable_4ppse, _launch_service_stats_enable,
3301 _launch_service_stats_enable_4ppse, _launch_service_stats_is_enabled,
3302 _launch_service_stats_is_enabled_4ppse, _launch_set_service_enabled,
3303 _launch_set_system_service_enabled, _launch_socket_service_check_in,
3304 _launch_version_for_user_service_4coresim, _launch_wait, _launchd_close,
3305 _launchd_fdopen, _launchd_getfd, _launchd_msg_recv, _launchd_msg_send,
3306 _load_launchd_jobs_at_loginwindow_prompt, _mpm_uncork_fork,
3307 _mpm_wait, _os_system_version_get_current_version, _os_system_version_get_ios_support_version,
3308 _os_system_version_sim_get_current_host_version, _os_transaction_copy_description,
3309 _os_transaction_create, _os_transaction_get_description, _os_transaction_get_timestamp,
37753310 _os_transaction_needs_more_time, _place_hold_on_real_loginwindow,
37763311 _reboot2, _reboot3, _vproc_release, _vproc_retain, _vproc_standby_begin,
37773312 _vproc_standby_end, _vproc_swap_complex, _vproc_swap_integer,
src/link/tapi.zig+1-1
......@@ -36,7 +36,7 @@ pub const TbdV3 = struct {
3636pub const TbdV4 = struct {
3737 tbd_version: u3,
3838 targets: []const []const u8,
39 uuids: []const struct {
39 uuids: ?[]const struct {
4040 target: []const u8,
4141 value: []const u8,
4242 },
src/link/tapi/Tokenizer.zig+338-223
......@@ -1,7 +1,7 @@
11const Tokenizer = @This();
22
33const std = @import("std");
4const log = std.log.scoped(.tapi);
4const log = std.log.scoped(.yaml);
55const testing = std.testing;
66
77buffer: []const u8,
......@@ -13,29 +13,31 @@ pub const Token = struct {
1313 end: usize,
1414
1515 pub const Id = enum {
16 Eof,
17
18 NewLine,
19 DocStart, // ---
20 DocEnd, // ...
21 SeqItemInd, // -
22 MapValueInd, // :
23 FlowMapStart, // {
24 FlowMapEnd, // }
25 FlowSeqStart, // [
26 FlowSeqEnd, // ]
27
28 Comma,
29 Space,
30 Tab,
31 Comment, // #
32 Alias, // *
33 Anchor, // &
34 Tag, // !
35 SingleQuote, // '
36 DoubleQuote, // "
37
38 Literal,
16 // zig fmt: off
17 eof,
18
19 new_line,
20 doc_start, // ---
21 doc_end, // ...
22 seq_item_ind, // -
23 map_value_ind, // :
24 flow_map_start, // {
25 flow_map_end, // }
26 flow_seq_start, // [
27 flow_seq_end, // ]
28
29 comma,
30 space,
31 tab,
32 comment, // #
33 alias, // *
34 anchor, // &
35 tag, // !
36
37 single_quoted, // '...'
38 double_quoted, // "..."
39 literal,
40 // zig fmt: on
3941 };
4042};
4143
......@@ -45,8 +47,8 @@ pub const TokenIterator = struct {
4547 buffer: []const Token,
4648 pos: TokenIndex = 0,
4749
48 pub fn next(self: *TokenIterator) Token {
49 const token = self.buffer[self.pos];
50 pub fn next(self: *TokenIterator) ?Token {
51 const token = self.peek() orelse return null;
5052 self.pos += 1;
5153 return token;
5254 }
......@@ -74,180 +76,212 @@ pub const TokenIterator = struct {
7476 }
7577};
7678
79fn stringMatchesPattern(comptime pattern: []const u8, slice: []const u8) bool {
80 comptime var count: usize = 0;
81 inline while (count < pattern.len) : (count += 1) {
82 if (count >= slice.len) return false;
83 const c = slice[count];
84 if (pattern[count] != c) return false;
85 }
86 return true;
87}
88
89fn matchesPattern(self: Tokenizer, comptime pattern: []const u8) bool {
90 return stringMatchesPattern(pattern, self.buffer[self.index..]);
91}
92
7793pub fn next(self: *Tokenizer) Token {
7894 var result = Token{
79 .id = .Eof,
95 .id = .eof,
8096 .start = self.index,
8197 .end = undefined,
8298 };
8399
84 var state: union(enum) {
85 Start,
86 NewLine,
87 Space,
88 Tab,
89 Hyphen: usize,
90 Dot: usize,
91 Literal,
92 } = .Start;
100 var state: enum {
101 start,
102 new_line,
103 space,
104 tab,
105 comment,
106 single_quoted,
107 double_quoted,
108 literal,
109 } = .start;
93110
94111 while (self.index < self.buffer.len) : (self.index += 1) {
95112 const c = self.buffer[self.index];
96113 switch (state) {
97 .Start => switch (c) {
114 .start => switch (c) {
98115 ' ' => {
99 state = .Space;
116 state = .space;
100117 },
101118 '\t' => {
102 state = .Tab;
119 state = .tab;
103120 },
104121 '\n' => {
105 result.id = .NewLine;
122 result.id = .new_line;
106123 self.index += 1;
107124 break;
108125 },
109126 '\r' => {
110 state = .NewLine;
127 state = .new_line;
111128 },
112 '-' => {
113 state = .{ .Hyphen = 1 };
129
130 '-' => if (self.matchesPattern("---")) {
131 result.id = .doc_start;
132 self.index += "---".len;
133 break;
134 } else if (self.matchesPattern("- ")) {
135 result.id = .seq_item_ind;
136 self.index += "- ".len;
137 break;
138 } else {
139 state = .literal;
114140 },
115 '.' => {
116 state = .{ .Dot = 1 };
141
142 '.' => if (self.matchesPattern("...")) {
143 result.id = .doc_end;
144 self.index += "...".len;
145 break;
146 } else {
147 state = .literal;
117148 },
149
118150 ',' => {
119 result.id = .Comma;
151 result.id = .comma;
120152 self.index += 1;
121153 break;
122154 },
123155 '#' => {
124 result.id = .Comment;
125 self.index += 1;
126 break;
156 state = .comment;
127157 },
128158 '*' => {
129 result.id = .Alias;
159 result.id = .alias;
130160 self.index += 1;
131161 break;
132162 },
133163 '&' => {
134 result.id = .Anchor;
164 result.id = .anchor;
135165 self.index += 1;
136166 break;
137167 },
138168 '!' => {
139 result.id = .Tag;
140 self.index += 1;
141 break;
142 },
143 '\'' => {
144 result.id = .SingleQuote;
145 self.index += 1;
146 break;
147 },
148 '"' => {
149 result.id = .DoubleQuote;
169 result.id = .tag;
150170 self.index += 1;
151171 break;
152172 },
153173 '[' => {
154 result.id = .FlowSeqStart;
174 result.id = .flow_seq_start;
155175 self.index += 1;
156176 break;
157177 },
158178 ']' => {
159 result.id = .FlowSeqEnd;
179 result.id = .flow_seq_end;
160180 self.index += 1;
161181 break;
162182 },
163183 ':' => {
164 result.id = .MapValueInd;
184 result.id = .map_value_ind;
165185 self.index += 1;
166186 break;
167187 },
168188 '{' => {
169 result.id = .FlowMapStart;
189 result.id = .flow_map_start;
170190 self.index += 1;
171191 break;
172192 },
173193 '}' => {
174 result.id = .FlowMapEnd;
194 result.id = .flow_map_end;
175195 self.index += 1;
176196 break;
177197 },
198 '\'' => {
199 state = .single_quoted;
200 },
201 '"' => {
202 state = .double_quoted;
203 },
178204 else => {
179 state = .Literal;
205 state = .literal;
206 },
207 },
208
209 .comment => switch (c) {
210 '\r', '\n' => {
211 result.id = .comment;
212 break;
180213 },
214 else => {},
181215 },
182 .Space => switch (c) {
216
217 .space => switch (c) {
183218 ' ' => {},
184219 else => {
185 result.id = .Space;
220 result.id = .space;
186221 break;
187222 },
188223 },
189 .Tab => switch (c) {
224
225 .tab => switch (c) {
190226 '\t' => {},
191227 else => {
192 result.id = .Tab;
228 result.id = .tab;
193229 break;
194230 },
195231 },
196 .NewLine => switch (c) {
232
233 .new_line => switch (c) {
197234 '\n' => {
198 result.id = .NewLine;
235 result.id = .new_line;
199236 self.index += 1;
200237 break;
201238 },
202239 else => {}, // TODO this should be an error condition
203240 },
204 .Hyphen => |*count| switch (c) {
205 ' ' => {
206 result.id = .SeqItemInd;
241
242 .single_quoted => switch (c) {
243 '\'' => if (!self.matchesPattern("''")) {
244 result.id = .single_quoted;
207245 self.index += 1;
208246 break;
247 } else {
248 self.index += "''".len - 1;
209249 },
210 '-' => {
211 count.* += 1;
212
213 if (count.* == 3) {
214 result.id = .DocStart;
215 self.index += 1;
216 break;
217 }
218 },
219 else => {
220 state = .Literal;
221 },
250 else => {},
222251 },
223 .Dot => |*count| switch (c) {
224 '.' => {
225 count.* += 1;
226252
227 if (count.* == 3) {
228 result.id = .DocEnd;
253 .double_quoted => switch (c) {
254 '"' => {
255 if (stringMatchesPattern("\\", self.buffer[self.index - 1 ..])) {
256 self.index += 1;
257 } else {
258 result.id = .double_quoted;
229259 self.index += 1;
230260 break;
231261 }
232262 },
233 else => {
234 state = .Literal;
235 },
263 else => {},
236264 },
237 .Literal => switch (c) {
265
266 .literal => switch (c) {
238267 '\r', '\n', ' ', '\'', '"', ',', ':', ']', '}' => {
239 result.id = .Literal;
268 result.id = .literal;
240269 break;
241270 },
242271 else => {
243 result.id = .Literal;
272 result.id = .literal;
244273 },
245274 },
246275 }
247276 }
248277
249 if (state == .Literal and result.id == .Eof) {
250 result.id = .Literal;
278 if (self.index >= self.buffer.len) {
279 switch (state) {
280 .literal => {
281 result.id = .literal;
282 },
283 else => {},
284 }
251285 }
252286
253287 result.end = self.index;
......@@ -263,22 +297,24 @@ fn testExpected(source: []const u8, expected: []const Token.Id) !void {
263297 .buffer = source,
264298 };
265299
266 var token_len: usize = 0;
267 for (expected) |exp| {
268 token_len += 1;
300 var given = std.ArrayList(Token.Id).init(testing.allocator);
301 defer given.deinit();
302
303 while (true) {
269304 const token = tokenizer.next();
270 try testing.expectEqual(exp, token.id);
305 try given.append(token.id);
306 if (token.id == .eof) break;
271307 }
272308
273 while (tokenizer.next().id != .Eof) {
274 token_len += 1; // consume all tokens
275 }
309 try testing.expectEqualSlices(Token.Id, expected, given.items);
310}
276311
277 try testing.expectEqual(expected.len, token_len);
312test {
313 std.testing.refAllDecls(@This());
278314}
279315
280316test "empty doc" {
281 try testExpected("", &[_]Token.Id{.Eof});
317 try testExpected("", &[_]Token.Id{.eof});
282318}
283319
284320test "empty doc with explicit markers" {
......@@ -286,7 +322,22 @@ test "empty doc with explicit markers" {
286322 \\---
287323 \\...
288324 , &[_]Token.Id{
289 .DocStart, .NewLine, .DocEnd, .Eof,
325 .doc_start, .new_line, .doc_end, .eof,
326 });
327}
328
329test "empty doc with explicit markers and a directive" {
330 try testExpected(
331 \\--- !tbd-v1
332 \\...
333 , &[_]Token.Id{
334 .doc_start,
335 .space,
336 .tag,
337 .literal,
338 .new_line,
339 .doc_end,
340 .eof,
290341 });
291342}
292343
......@@ -296,15 +347,15 @@ test "sequence of values" {
296347 \\- 1
297348 \\- 2
298349 , &[_]Token.Id{
299 .SeqItemInd,
300 .Literal,
301 .NewLine,
302 .SeqItemInd,
303 .Literal,
304 .NewLine,
305 .SeqItemInd,
306 .Literal,
307 .Eof,
350 .seq_item_ind,
351 .literal,
352 .new_line,
353 .seq_item_ind,
354 .literal,
355 .new_line,
356 .seq_item_ind,
357 .literal,
358 .eof,
308359 });
309360}
310361
......@@ -313,24 +364,24 @@ test "sequence of sequences" {
313364 \\- [ val1, val2]
314365 \\- [val3, val4 ]
315366 , &[_]Token.Id{
316 .SeqItemInd,
317 .FlowSeqStart,
318 .Space,
319 .Literal,
320 .Comma,
321 .Space,
322 .Literal,
323 .FlowSeqEnd,
324 .NewLine,
325 .SeqItemInd,
326 .FlowSeqStart,
327 .Literal,
328 .Comma,
329 .Space,
330 .Literal,
331 .Space,
332 .FlowSeqEnd,
333 .Eof,
367 .seq_item_ind,
368 .flow_seq_start,
369 .space,
370 .literal,
371 .comma,
372 .space,
373 .literal,
374 .flow_seq_end,
375 .new_line,
376 .seq_item_ind,
377 .flow_seq_start,
378 .literal,
379 .comma,
380 .space,
381 .literal,
382 .space,
383 .flow_seq_end,
384 .eof,
334385 });
335386}
336387
......@@ -339,16 +390,16 @@ test "mappings" {
339390 \\key1: value1
340391 \\key2: value2
341392 , &[_]Token.Id{
342 .Literal,
343 .MapValueInd,
344 .Space,
345 .Literal,
346 .NewLine,
347 .Literal,
348 .MapValueInd,
349 .Space,
350 .Literal,
351 .Eof,
393 .literal,
394 .map_value_ind,
395 .space,
396 .literal,
397 .new_line,
398 .literal,
399 .map_value_ind,
400 .space,
401 .literal,
402 .eof,
352403 });
353404}
354405
......@@ -357,21 +408,21 @@ test "inline mapped sequence of values" {
357408 \\key : [ val1,
358409 \\ val2 ]
359410 , &[_]Token.Id{
360 .Literal,
361 .Space,
362 .MapValueInd,
363 .Space,
364 .FlowSeqStart,
365 .Space,
366 .Literal,
367 .Comma,
368 .Space,
369 .NewLine,
370 .Space,
371 .Literal,
372 .Space,
373 .FlowSeqEnd,
374 .Eof,
411 .literal,
412 .space,
413 .map_value_ind,
414 .space,
415 .flow_seq_start,
416 .space,
417 .literal,
418 .comma,
419 .space,
420 .new_line,
421 .space,
422 .literal,
423 .space,
424 .flow_seq_end,
425 .eof,
375426 });
376427}
377428
......@@ -388,52 +439,50 @@ test "part of tbd" {
388439 \\install-name: '/usr/lib/libSystem.B.dylib'
389440 \\...
390441 , &[_]Token.Id{
391 .DocStart,
392 .Space,
393 .Tag,
394 .Literal,
395 .NewLine,
396 .Literal,
397 .MapValueInd,
398 .Space,
399 .Literal,
400 .NewLine,
401 .Literal,
402 .MapValueInd,
403 .Space,
404 .FlowSeqStart,
405 .Space,
406 .Literal,
407 .Space,
408 .FlowSeqEnd,
409 .NewLine,
410 .NewLine,
411 .Literal,
412 .MapValueInd,
413 .NewLine,
414 .Space,
415 .SeqItemInd,
416 .Literal,
417 .MapValueInd,
418 .Space,
419 .Literal,
420 .NewLine,
421 .Space,
422 .Literal,
423 .MapValueInd,
424 .Space,
425 .Literal,
426 .NewLine,
427 .NewLine,
428 .Literal,
429 .MapValueInd,
430 .Space,
431 .SingleQuote,
432 .Literal,
433 .SingleQuote,
434 .NewLine,
435 .DocEnd,
436 .Eof,
442 .doc_start,
443 .space,
444 .tag,
445 .literal,
446 .new_line,
447 .literal,
448 .map_value_ind,
449 .space,
450 .literal,
451 .new_line,
452 .literal,
453 .map_value_ind,
454 .space,
455 .flow_seq_start,
456 .space,
457 .literal,
458 .space,
459 .flow_seq_end,
460 .new_line,
461 .new_line,
462 .literal,
463 .map_value_ind,
464 .new_line,
465 .space,
466 .seq_item_ind,
467 .literal,
468 .map_value_ind,
469 .space,
470 .literal,
471 .new_line,
472 .space,
473 .literal,
474 .map_value_ind,
475 .space,
476 .literal,
477 .new_line,
478 .new_line,
479 .literal,
480 .map_value_ind,
481 .space,
482 .single_quoted,
483 .new_line,
484 .doc_end,
485 .eof,
437486 });
438487}
439488
......@@ -443,18 +492,84 @@ test "Unindented list" {
443492 \\- foo: 1
444493 \\c: 1
445494 , &[_]Token.Id{
446 .Literal,
447 .MapValueInd,
448 .NewLine,
449 .SeqItemInd,
450 .Literal,
451 .MapValueInd,
452 .Space,
453 .Literal,
454 .NewLine,
455 .Literal,
456 .MapValueInd,
457 .Space,
458 .Literal,
495 .literal,
496 .map_value_ind,
497 .new_line,
498 .seq_item_ind,
499 .literal,
500 .map_value_ind,
501 .space,
502 .literal,
503 .new_line,
504 .literal,
505 .map_value_ind,
506 .space,
507 .literal,
508 .eof,
509 });
510}
511
512test "escape sequences" {
513 try testExpected(
514 \\a: 'here''s an apostrophe'
515 \\b: "a newline\nand a\ttab"
516 \\c: "\"here\" and there"
517 , &[_]Token.Id{
518 .literal,
519 .map_value_ind,
520 .space,
521 .single_quoted,
522 .new_line,
523 .literal,
524 .map_value_ind,
525 .space,
526 .double_quoted,
527 .new_line,
528 .literal,
529 .map_value_ind,
530 .space,
531 .double_quoted,
532 .eof,
533 });
534}
535
536test "comments" {
537 try testExpected(
538 \\key: # some comment about the key
539 \\# first value
540 \\- val1
541 \\# second value
542 \\- val2
543 , &[_]Token.Id{
544 .literal,
545 .map_value_ind,
546 .space,
547 .comment,
548 .new_line,
549 .comment,
550 .new_line,
551 .seq_item_ind,
552 .literal,
553 .new_line,
554 .comment,
555 .new_line,
556 .seq_item_ind,
557 .literal,
558 .eof,
559 });
560}
561
562test "quoted literals" {
563 try testExpected(
564 \\'#000000'
565 \\'[000000'
566 \\"&someString"
567 , &[_]Token.Id{
568 .single_quoted,
569 .new_line,
570 .single_quoted,
571 .new_line,
572 .double_quoted,
573 .eof,
459574 });
460575}
src/link/tapi/parse.zig+378-323
......@@ -1,8 +1,7 @@
11const std = @import("std");
22const assert = std.debug.assert;
3const log = std.log.scoped(.tapi);
3const log = std.log.scoped(.yaml);
44const mem = std.mem;
5const testing = std.testing;
65
76const Allocator = mem.Allocator;
87const Tokenizer = @import("Tokenizer.zig");
......@@ -11,9 +10,9 @@ const TokenIndex = Tokenizer.TokenIndex;
1110const TokenIterator = Tokenizer.TokenIterator;
1211
1312pub const ParseError = error{
13 InvalidEscapeSequence,
1414 MalformedYaml,
1515 NestedDocuments,
16 UnexpectedTag,
1716 UnexpectedEof,
1817 UnexpectedToken,
1918 Unhandled,
......@@ -22,6 +21,8 @@ pub const ParseError = error{
2221pub const Node = struct {
2322 tag: Tag,
2423 tree: *const Tree,
24 start: TokenIndex,
25 end: TokenIndex,
2526
2627 pub const Tag = enum {
2728 doc,
......@@ -61,9 +62,12 @@ pub const Node = struct {
6162 }
6263
6364 pub const Doc = struct {
64 base: Node = Node{ .tag = Tag.doc, .tree = undefined },
65 start: ?TokenIndex = null,
66 end: ?TokenIndex = null,
65 base: Node = Node{
66 .tag = Tag.doc,
67 .tree = undefined,
68 .start = undefined,
69 .end = undefined,
70 },
6771 directive: ?TokenIndex = null,
6872 value: ?*Node = null,
6973
......@@ -86,10 +90,8 @@ pub const Node = struct {
8690 _ = fmt;
8791 if (self.directive) |id| {
8892 try std.fmt.format(writer, "{{ ", .{});
89 const directive = self.base.tree.tokens[id];
90 try std.fmt.format(writer, ".directive = {s}, ", .{
91 self.base.tree.source[directive.start..directive.end],
92 });
93 const directive = self.base.tree.getRaw(id, id);
94 try std.fmt.format(writer, ".directive = {s}, ", .{directive});
9395 }
9496 if (self.value) |node| {
9597 try std.fmt.format(writer, "{}", .{node});
......@@ -101,22 +103,27 @@ pub const Node = struct {
101103 };
102104
103105 pub const Map = struct {
104 base: Node = Node{ .tag = Tag.map, .tree = undefined },
105 start: ?TokenIndex = null,
106 end: ?TokenIndex = null,
106 base: Node = Node{
107 .tag = Tag.map,
108 .tree = undefined,
109 .start = undefined,
110 .end = undefined,
111 },
107112 values: std.ArrayListUnmanaged(Entry) = .{},
108113
109114 pub const base_tag: Node.Tag = .map;
110115
111116 pub const Entry = struct {
112117 key: TokenIndex,
113 value: *Node,
118 value: ?*Node,
114119 };
115120
116121 pub fn deinit(self: *Map, allocator: Allocator) void {
117122 for (self.values.items) |entry| {
118 entry.value.deinit(allocator);
119 allocator.destroy(entry.value);
123 if (entry.value) |value| {
124 value.deinit(allocator);
125 allocator.destroy(value);
126 }
120127 }
121128 self.values.deinit(allocator);
122129 }
......@@ -131,20 +138,24 @@ pub const Node = struct {
131138 _ = fmt;
132139 try std.fmt.format(writer, "{{ ", .{});
133140 for (self.values.items) |entry| {
134 const key = self.base.tree.tokens[entry.key];
135 try std.fmt.format(writer, "{s} => {}, ", .{
136 self.base.tree.source[key.start..key.end],
137 entry.value,
138 });
141 const key = self.base.tree.getRaw(entry.key, entry.key);
142 if (entry.value) |value| {
143 try std.fmt.format(writer, "{s} => {}, ", .{ key, value });
144 } else {
145 try std.fmt.format(writer, "{s} => null, ", .{key});
146 }
139147 }
140148 return std.fmt.format(writer, " }}", .{});
141149 }
142150 };
143151
144152 pub const List = struct {
145 base: Node = Node{ .tag = Tag.list, .tree = undefined },
146 start: ?TokenIndex = null,
147 end: ?TokenIndex = null,
153 base: Node = Node{
154 .tag = Tag.list,
155 .tree = undefined,
156 .start = undefined,
157 .end = undefined,
158 },
148159 values: std.ArrayListUnmanaged(*Node) = .{},
149160
150161 pub const base_tag: Node.Tag = .list;
......@@ -174,15 +185,18 @@ pub const Node = struct {
174185 };
175186
176187 pub const Value = struct {
177 base: Node = Node{ .tag = Tag.value, .tree = undefined },
178 start: ?TokenIndex = null,
179 end: ?TokenIndex = null,
188 base: Node = Node{
189 .tag = Tag.value,
190 .tree = undefined,
191 .start = undefined,
192 .end = undefined,
193 },
194 string_value: std.ArrayListUnmanaged(u8) = .{},
180195
181196 pub const base_tag: Node.Tag = .value;
182197
183198 pub fn deinit(self: *Value, allocator: Allocator) void {
184 _ = self;
185 _ = allocator;
199 self.string_value.deinit(allocator);
186200 }
187201
188202 pub fn format(
......@@ -193,11 +207,8 @@ pub const Node = struct {
193207 ) !void {
194208 _ = options;
195209 _ = fmt;
196 const start = self.base.tree.tokens[self.start.?];
197 const end = self.base.tree.tokens[self.end.?];
198 return std.fmt.format(writer, "{s}", .{
199 self.base.tree.source[start.start..end.end],
200 });
210 const raw = self.base.tree.getRaw(self.base.start, self.base.end);
211 return std.fmt.format(writer, "{s}", .{raw});
201212 }
202213 };
203214};
......@@ -233,6 +244,21 @@ pub const Tree = struct {
233244 self.docs.deinit(self.allocator);
234245 }
235246
247 pub fn getDirective(self: Tree, doc_index: usize) ?[]const u8 {
248 assert(doc_index < self.docs.items.len);
249 const doc = self.docs.items[doc_index].cast(Node.Doc) orelse return null;
250 const id = doc.directive orelse return null;
251 return self.getRaw(id, id);
252 }
253
254 pub fn getRaw(self: Tree, start: TokenIndex, end: TokenIndex) []const u8 {
255 assert(start <= end);
256 assert(start < self.tokens.len and end < self.tokens.len);
257 const start_token = self.tokens[start];
258 const end_token = self.tokens[end];
259 return self.source[start_token.start..end_token.end];
260 }
261
236262 pub fn parse(self: *Tree, source: []const u8) !void {
237263 var tokenizer = Tokenizer{ .buffer = source };
238264 var tokens = std.ArrayList(Token).init(self.allocator);
......@@ -252,8 +278,8 @@ pub const Tree = struct {
252278 });
253279
254280 switch (token.id) {
255 .Eof => break,
256 .NewLine => {
281 .eof => break,
282 .new_line => {
257283 line += 1;
258284 prev_line_last_col = token.end;
259285 },
......@@ -272,20 +298,20 @@ pub const Tree = struct {
272298 .line_cols = &self.line_cols,
273299 };
274300
275 while (true) {
276 if (parser.token_it.peek() == null) return;
301 parser.eatCommentsAndSpace(&.{});
277302
278 const pos = parser.token_it.pos;
279 const token = parser.token_it.next();
303 while (true) {
304 parser.eatCommentsAndSpace(&.{});
305 const token = parser.token_it.next() orelse break;
280306
281 log.debug("Next token: {}, {}", .{ pos, token });
307 log.debug("(main) next {s}@{d}", .{ @tagName(token.id), parser.token_it.pos - 1 });
282308
283309 switch (token.id) {
284 .Space, .Comment, .NewLine => {},
285 .Eof => break,
310 .eof => break,
286311 else => {
287 const doc = try parser.doc(pos);
288 try self.docs.append(self.allocator, &doc.base);
312 parser.token_it.seekBy(-1);
313 const doc = try parser.doc();
314 try self.docs.append(self.allocator, doc);
289315 },
290316 }
291317 }
......@@ -298,355 +324,308 @@ const Parser = struct {
298324 token_it: *TokenIterator,
299325 line_cols: *const std.AutoHashMap(TokenIndex, LineCol),
300326
301 fn doc(self: *Parser, start: TokenIndex) ParseError!*Node.Doc {
327 fn value(self: *Parser) ParseError!?*Node {
328 self.eatCommentsAndSpace(&.{});
329
330 const pos = self.token_it.pos;
331 const token = self.token_it.next() orelse return error.UnexpectedEof;
332
333 log.debug(" next {s}@{d}", .{ @tagName(token.id), pos });
334
335 switch (token.id) {
336 .literal => if (self.eatToken(.map_value_ind, &.{ .new_line, .comment })) |_| {
337 // map
338 self.token_it.seekTo(pos);
339 return self.map();
340 } else {
341 // leaf value
342 self.token_it.seekTo(pos);
343 return self.leaf_value();
344 },
345 .single_quoted, .double_quoted => {
346 // leaf value
347 self.token_it.seekBy(-1);
348 return self.leaf_value();
349 },
350 .seq_item_ind => {
351 // list
352 self.token_it.seekBy(-1);
353 return self.list();
354 },
355 .flow_seq_start => {
356 // list
357 self.token_it.seekBy(-1);
358 return self.list_bracketed();
359 },
360 else => return null,
361 }
362 }
363
364 fn doc(self: *Parser) ParseError!*Node {
302365 const node = try self.allocator.create(Node.Doc);
303366 errdefer self.allocator.destroy(node);
304 node.* = .{ .start = start };
367 node.* = .{};
305368 node.base.tree = self.tree;
369 node.base.start = self.token_it.pos;
306370
307 self.token_it.seekTo(start);
308
309 log.debug("Doc start: {}, {}", .{ start, self.tree.tokens[start] });
371 log.debug("(doc) begin {s}@{d}", .{ @tagName(self.tree.tokens[node.base.start].id), node.base.start });
310372
311 const explicit_doc: bool = if (self.eatToken(.DocStart)) |_| explicit_doc: {
312 if (self.eatToken(.Tag)) |_| {
313 node.directive = try self.expectToken(.Literal);
373 // Parse header
374 const explicit_doc: bool = if (self.eatToken(.doc_start, &.{})) |doc_pos| explicit_doc: {
375 if (self.getCol(doc_pos) > 0) return error.MalformedYaml;
376 if (self.eatToken(.tag, &.{ .new_line, .comment })) |_| {
377 node.directive = try self.expectToken(.literal, &.{ .new_line, .comment });
314378 }
315 _ = try self.expectToken(.NewLine);
316379 break :explicit_doc true;
317380 } else false;
318381
319 while (true) {
320 const pos = self.token_it.pos;
321 const token = self.token_it.next();
322
323 log.debug("Next token: {}, {}", .{ pos, token });
382 // Parse value
383 node.value = try self.value();
384 if (node.value == null) {
385 self.token_it.seekBy(-1);
386 }
387 errdefer if (node.value) |val| {
388 val.deinit(self.allocator);
389 self.allocator.destroy(val);
390 };
324391
325 switch (token.id) {
326 .Tag => {
327 return error.UnexpectedTag;
328 },
329 .Literal, .SingleQuote, .DoubleQuote => {
330 _ = try self.expectToken(.MapValueInd);
331 const map_node = try self.map(pos);
332 node.value = &map_node.base;
333 },
334 .SeqItemInd => {
335 const list_node = try self.list(pos);
336 node.value = &list_node.base;
337 },
338 .FlowSeqStart => {
339 const list_node = try self.list_bracketed(pos);
340 node.value = &list_node.base;
341 },
342 .DocEnd => {
343 if (explicit_doc) break;
344 return error.UnexpectedToken;
345 },
346 .DocStart, .Eof => {
347 self.token_it.seekBy(-1);
348 break;
349 },
350 else => {
351 return error.UnexpectedToken;
352 },
392 // Parse footer
393 footer: {
394 if (self.eatToken(.doc_end, &.{})) |pos| {
395 if (!explicit_doc) return error.UnexpectedToken;
396 if (self.getCol(pos) > 0) return error.MalformedYaml;
397 node.base.end = pos;
398 break :footer;
399 }
400 if (self.eatToken(.doc_start, &.{})) |pos| {
401 if (!explicit_doc) return error.UnexpectedToken;
402 if (self.getCol(pos) > 0) return error.MalformedYaml;
403 self.token_it.seekBy(-1);
404 node.base.end = pos - 1;
405 break :footer;
406 }
407 if (self.eatToken(.eof, &.{})) |pos| {
408 node.base.end = pos - 1;
409 break :footer;
353410 }
411 return error.UnexpectedToken;
354412 }
355413
356 node.end = self.token_it.pos - 1;
414 log.debug("(doc) end {s}@{d}", .{ @tagName(self.tree.tokens[node.base.end].id), node.base.end });
357415
358 log.debug("Doc end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] });
359
360 return node;
416 return &node.base;
361417 }
362418
363 fn map(self: *Parser, start: TokenIndex) ParseError!*Node.Map {
419 fn map(self: *Parser) ParseError!*Node {
364420 const node = try self.allocator.create(Node.Map);
365421 errdefer self.allocator.destroy(node);
366 node.* = .{ .start = start };
422 node.* = .{};
367423 node.base.tree = self.tree;
424 node.base.start = self.token_it.pos;
425 errdefer {
426 for (node.values.items) |entry| {
427 if (entry.value) |val| {
428 val.deinit(self.allocator);
429 self.allocator.destroy(val);
430 }
431 }
432 node.values.deinit(self.allocator);
433 }
368434
369 self.token_it.seekTo(start);
370
371 log.debug("Map start: {}, {}", .{ start, self.tree.tokens[start] });
435 log.debug("(map) begin {s}@{d}", .{ @tagName(self.tree.tokens[node.base.start].id), node.base.start });
372436
373 const col = self.getCol(start);
437 const col = self.getCol(node.base.start);
374438
375439 while (true) {
376 self.eatCommentsAndSpace();
440 self.eatCommentsAndSpace(&.{});
377441
378 // Parse key.
442 // Parse key
379443 const key_pos = self.token_it.pos;
380 if (self.getCol(key_pos) != col) {
444 if (self.getCol(key_pos) < col) {
381445 break;
382446 }
383447
384 const key = self.token_it.next();
448 const key = self.token_it.next() orelse return error.UnexpectedEof;
385449 switch (key.id) {
386 .Literal => {},
387 else => {
450 .literal => {},
451 .doc_start, .doc_end, .eof => {
388452 self.token_it.seekBy(-1);
389453 break;
390454 },
455 else => {
456 // TODO key not being a literal
457 return error.Unhandled;
458 },
391459 }
392460
393 log.debug("Map key: {}, '{s}'", .{ key, self.tree.source[key.start..key.end] });
461 log.debug("(map) key {s}@{d}", .{ self.tree.getRaw(key_pos, key_pos), key_pos });
394462
395463 // Separator
396 _ = try self.expectToken(.MapValueInd);
397
398 // Parse value.
399 const value: *Node = value: {
400 if (self.eatToken(.NewLine)) |_| {
401 self.eatCommentsAndSpace();
402
403 // Explicit, complex value such as list or map.
404 const value_pos = self.token_it.pos;
405 const value = self.token_it.next();
406 switch (value.id) {
407 .Literal, .SingleQuote, .DoubleQuote => {
408 // Assume nested map.
409 const map_node = try self.map(value_pos);
410 break :value &map_node.base;
411 },
412 .SeqItemInd => {
413 // Assume list of values.
414 const list_node = try self.list(value_pos);
415 break :value &list_node.base;
416 },
417 else => {
418 log.err("{}", .{key});
419 return error.Unhandled;
420 },
421 }
422 } else {
423 self.eatCommentsAndSpace();
424
425 const value_pos = self.token_it.pos;
426 const value = self.token_it.next();
427 switch (value.id) {
428 .Literal, .SingleQuote, .DoubleQuote => {
429 // Assume leaf value.
430 const leaf_node = try self.leaf_value(value_pos);
431 break :value &leaf_node.base;
432 },
433 .FlowSeqStart => {
434 const list_node = try self.list_bracketed(value_pos);
435 break :value &list_node.base;
436 },
437 else => {
438 log.err("{}", .{key});
439 return error.Unhandled;
440 },
464 _ = try self.expectToken(.map_value_ind, &.{ .new_line, .comment });
465
466 // Parse value
467 const val = try self.value();
468 errdefer if (val) |v| {
469 v.deinit(self.allocator);
470 self.allocator.destroy(v);
471 };
472
473 if (val) |v| {
474 if (self.getCol(v.start) < self.getCol(key_pos)) {
475 return error.MalformedYaml;
476 }
477 if (v.cast(Node.Value)) |_| {
478 if (self.getCol(v.start) == self.getCol(key_pos)) {
479 return error.MalformedYaml;
441480 }
442481 }
443 };
444 log.debug("Map value: {}", .{value});
482 }
445483
446484 try node.values.append(self.allocator, .{
447485 .key = key_pos,
448 .value = value,
486 .value = val,
449487 });
450
451 _ = self.eatToken(.NewLine);
452488 }
453489
454 node.end = self.token_it.pos - 1;
490 node.base.end = self.token_it.pos - 1;
455491
456 log.debug("Map end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] });
492 log.debug("(map) end {s}@{d}", .{ @tagName(self.tree.tokens[node.base.end].id), node.base.end });
457493
458 return node;
494 return &node.base;
459495 }
460496
461 fn list(self: *Parser, start: TokenIndex) ParseError!*Node.List {
497 fn list(self: *Parser) ParseError!*Node {
462498 const node = try self.allocator.create(Node.List);
463499 errdefer self.allocator.destroy(node);
464 node.* = .{
465 .start = start,
466 };
500 node.* = .{};
467501 node.base.tree = self.tree;
502 node.base.start = self.token_it.pos;
503 errdefer {
504 for (node.values.items) |val| {
505 val.deinit(self.allocator);
506 self.allocator.destroy(val);
507 }
508 node.values.deinit(self.allocator);
509 }
468510
469 self.token_it.seekTo(start);
470
471 log.debug("List start: {}, {}", .{ start, self.tree.tokens[start] });
472
473 const col = self.getCol(start);
511 log.debug("(list) begin {s}@{d}", .{ @tagName(self.tree.tokens[node.base.start].id), node.base.start });
474512
475513 while (true) {
476 self.eatCommentsAndSpace();
514 self.eatCommentsAndSpace(&.{});
477515
478 if (self.getCol(self.token_it.pos) != col) {
479 break;
480 }
481 _ = self.eatToken(.SeqItemInd) orelse {
482 break;
483 };
516 _ = self.eatToken(.seq_item_ind, &.{}) orelse break;
484517
485 const pos = self.token_it.pos;
486 const token = self.token_it.next();
487 const value: *Node = value: {
488 switch (token.id) {
489 .Literal, .SingleQuote, .DoubleQuote => {
490 if (self.eatToken(.MapValueInd)) |_| {
491 // nested map
492 const map_node = try self.map(pos);
493 break :value &map_node.base;
494 } else {
495 // standalone (leaf) value
496 const leaf_node = try self.leaf_value(pos);
497 break :value &leaf_node.base;
498 }
499 },
500 .FlowSeqStart => {
501 const list_node = try self.list_bracketed(pos);
502 break :value &list_node.base;
503 },
504 else => {
505 log.err("{}", .{token});
506 return error.Unhandled;
507 },
508 }
509 };
510 try node.values.append(self.allocator, value);
511
512 _ = self.eatToken(.NewLine);
518 const val = (try self.value()) orelse return error.MalformedYaml;
519 try node.values.append(self.allocator, val);
513520 }
514521
515 node.end = self.token_it.pos - 1;
522 node.base.end = self.token_it.pos - 1;
516523
517 log.debug("List end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] });
524 log.debug("(list) end {s}@{d}", .{ @tagName(self.tree.tokens[node.base.end].id), node.base.end });
518525
519 return node;
526 return &node.base;
520527 }
521528
522 fn list_bracketed(self: *Parser, start: TokenIndex) ParseError!*Node.List {
529 fn list_bracketed(self: *Parser) ParseError!*Node {
523530 const node = try self.allocator.create(Node.List);
524531 errdefer self.allocator.destroy(node);
525 node.* = .{ .start = start };
532 node.* = .{};
526533 node.base.tree = self.tree;
534 node.base.start = self.token_it.pos;
535 errdefer {
536 for (node.values.items) |val| {
537 val.deinit(self.allocator);
538 self.allocator.destroy(val);
539 }
540 node.values.deinit(self.allocator);
541 }
527542
528 self.token_it.seekTo(start);
529
530 log.debug("List start: {}, {}", .{ start, self.tree.tokens[start] });
543 log.debug("(list) begin {s}@{d}", .{ @tagName(self.tree.tokens[node.base.start].id), node.base.start });
531544
532 _ = try self.expectToken(.FlowSeqStart);
545 _ = try self.expectToken(.flow_seq_start, &.{});
533546
534547 while (true) {
535 _ = self.eatToken(.NewLine);
536 self.eatCommentsAndSpace();
548 self.eatCommentsAndSpace(&.{.comment});
537549
538 const pos = self.token_it.pos;
539 const token = self.token_it.next();
540
541 log.debug("Next token: {}, {}", .{ pos, token });
550 if (self.eatToken(.flow_seq_end, &.{.comment})) |pos| {
551 node.base.end = pos;
552 break;
553 }
554 _ = self.eatToken(.comma, &.{.comment});
542555
543 const value: *Node = value: {
544 switch (token.id) {
545 .FlowSeqStart => {
546 const list_node = try self.list_bracketed(pos);
547 break :value &list_node.base;
548 },
549 .FlowSeqEnd => {
550 break;
551 },
552 .Literal, .SingleQuote, .DoubleQuote => {
553 const leaf_node = try self.leaf_value(pos);
554 _ = self.eatToken(.Comma);
555 // TODO newline
556 break :value &leaf_node.base;
557 },
558 else => {
559 log.err("{}", .{token});
560 return error.Unhandled;
561 },
562 }
563 };
564 try node.values.append(self.allocator, value);
556 const val = (try self.value()) orelse return error.MalformedYaml;
557 try node.values.append(self.allocator, val);
565558 }
566559
567 node.end = self.token_it.pos - 1;
568
569 log.debug("List end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] });
560 log.debug("(list) end {s}@{d}", .{ @tagName(self.tree.tokens[node.base.end].id), node.base.end });
570561
571 return node;
562 return &node.base;
572563 }
573564
574 fn leaf_value(self: *Parser, start: TokenIndex) ParseError!*Node.Value {
565 fn leaf_value(self: *Parser) ParseError!*Node {
575566 const node = try self.allocator.create(Node.Value);
576567 errdefer self.allocator.destroy(node);
577 node.* = .{ .start = start };
568 node.* = .{ .string_value = .{} };
578569 node.base.tree = self.tree;
579
580 self.token_it.seekTo(start);
581
582 log.debug("Leaf start: {}, {}", .{ node.start.?, self.tree.tokens[node.start.?] });
583
584 parse: {
585 if (self.eatToken(.SingleQuote)) |_| {
586 node.start = node.start.? + 1;
587 while (true) {
588 const tok = self.token_it.next();
589 switch (tok.id) {
590 .SingleQuote => {
591 node.end = self.token_it.pos - 2;
592 break :parse;
593 },
594 .NewLine => return error.UnexpectedToken,
595 else => {},
596 }
597 }
598 }
599
600 if (self.eatToken(.DoubleQuote)) |_| {
601 node.start = node.start.? + 1;
602 while (true) {
603 const tok = self.token_it.next();
604 switch (tok.id) {
605 .DoubleQuote => {
606 node.end = self.token_it.pos - 2;
607 break :parse;
608 },
609 .NewLine => return error.UnexpectedToken,
610 else => {},
611 }
612 }
613 }
614
615 // TODO handle multiline strings in new block scope
616 while (true) {
617 const tok = self.token_it.next();
618 switch (tok.id) {
619 .Literal => {},
620 .Space => {
621 const trailing = self.token_it.pos - 2;
622 self.eatCommentsAndSpace();
623 if (self.token_it.peek()) |peek| {
624 if (peek.id != .Literal) {
625 node.end = trailing;
626 break;
627 }
570 node.base.start = self.token_it.pos;
571 errdefer node.string_value.deinit(self.allocator);
572
573 // TODO handle multiline strings in new block scope
574 while (self.token_it.next()) |tok| {
575 switch (tok.id) {
576 .single_quoted => {
577 node.base.end = self.token_it.pos - 1;
578 const raw = self.tree.getRaw(node.base.start, node.base.end);
579 try self.parseSingleQuoted(node, raw);
580 break;
581 },
582 .double_quoted => {
583 node.base.end = self.token_it.pos - 1;
584 const raw = self.tree.getRaw(node.base.start, node.base.end);
585 try self.parseDoubleQuoted(node, raw);
586 break;
587 },
588 .literal => {},
589 .space => {
590 const trailing = self.token_it.pos - 2;
591 self.eatCommentsAndSpace(&.{});
592 if (self.token_it.peek()) |peek| {
593 if (peek.id != .literal) {
594 node.base.end = trailing;
595 const raw = self.tree.getRaw(node.base.start, node.base.end);
596 try node.string_value.appendSlice(self.allocator, raw);
597 break;
628598 }
629 },
630 else => {
631 self.token_it.seekBy(-1);
632 node.end = self.token_it.pos - 1;
633 break;
634 },
635 }
599 }
600 },
601 else => {
602 self.token_it.seekBy(-1);
603 node.base.end = self.token_it.pos - 1;
604 const raw = self.tree.getRaw(node.base.start, node.base.end);
605 try node.string_value.appendSlice(self.allocator, raw);
606 break;
607 },
636608 }
637609 }
638610
639 log.debug("Leaf end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] });
611 log.debug("(leaf) {s}", .{self.tree.getRaw(node.base.start, node.base.end)});
640612
641 return node;
613 return &node.base;
642614 }
643615
644 fn eatCommentsAndSpace(self: *Parser) void {
645 while (true) {
646 _ = self.token_it.peek() orelse return;
647 const token = self.token_it.next();
616 fn eatCommentsAndSpace(self: *Parser, comptime exclusions: []const Token.Id) void {
617 log.debug("eatCommentsAndSpace", .{});
618 outer: while (self.token_it.next()) |token| {
619 log.debug(" (token '{s}')", .{@tagName(token.id)});
648620 switch (token.id) {
649 .Comment, .Space => {},
621 .comment, .space, .new_line => |space| {
622 inline for (exclusions) |excl| {
623 if (excl == space) {
624 self.token_it.seekBy(-1);
625 break :outer;
626 }
627 } else continue;
628 },
650629 else => {
651630 self.token_it.seekBy(-1);
652631 break;
......@@ -655,25 +634,24 @@ const Parser = struct {
655634 }
656635 }
657636
658 fn eatToken(self: *Parser, id: Token.Id) ?TokenIndex {
659 while (true) {
660 const pos = self.token_it.pos;
661 _ = self.token_it.peek() orelse return null;
662 const token = self.token_it.next();
663 switch (token.id) {
664 .Comment, .Space => continue,
665 else => |next_id| if (next_id == id) {
666 return pos;
667 } else {
668 self.token_it.seekTo(pos);
669 return null;
670 },
671 }
637 fn eatToken(self: *Parser, id: Token.Id, comptime exclusions: []const Token.Id) ?TokenIndex {
638 log.debug("eatToken('{s}')", .{@tagName(id)});
639 self.eatCommentsAndSpace(exclusions);
640 const pos = self.token_it.pos;
641 const token = self.token_it.next() orelse return null;
642 if (token.id == id) {
643 log.debug(" (found at {d})", .{pos});
644 return pos;
645 } else {
646 log.debug(" (not found)", .{});
647 self.token_it.seekBy(-1);
648 return null;
672649 }
673650 }
674651
675 fn expectToken(self: *Parser, id: Token.Id) ParseError!TokenIndex {
676 return self.eatToken(id) orelse error.UnexpectedToken;
652 fn expectToken(self: *Parser, id: Token.Id, comptime exclusions: []const Token.Id) ParseError!TokenIndex {
653 log.debug("expectToken('{s}')", .{@tagName(id)});
654 return self.eatToken(id, exclusions) orelse error.UnexpectedToken;
677655 }
678656
679657 fn getLine(self: *Parser, index: TokenIndex) usize {
......@@ -683,8 +661,85 @@ const Parser = struct {
683661 fn getCol(self: *Parser, index: TokenIndex) usize {
684662 return self.line_cols.get(index).?.col;
685663 }
664
665 fn parseSingleQuoted(self: *Parser, node: *Node.Value, raw: []const u8) ParseError!void {
666 assert(raw[0] == '\'' and raw[raw.len - 1] == '\'');
667
668 const raw_no_quotes = raw[1 .. raw.len - 1];
669 try node.string_value.ensureTotalCapacity(self.allocator, raw_no_quotes.len);
670
671 var state: enum {
672 start,
673 escape,
674 } = .start;
675 var index: usize = 0;
676
677 while (index < raw_no_quotes.len) : (index += 1) {
678 const c = raw_no_quotes[index];
679 switch (state) {
680 .start => switch (c) {
681 '\'' => {
682 state = .escape;
683 },
684 else => {
685 node.string_value.appendAssumeCapacity(c);
686 },
687 },
688 .escape => switch (c) {
689 '\'' => {
690 state = .start;
691 node.string_value.appendAssumeCapacity(c);
692 },
693 else => return error.InvalidEscapeSequence,
694 },
695 }
696 }
697 }
698
699 fn parseDoubleQuoted(self: *Parser, node: *Node.Value, raw: []const u8) ParseError!void {
700 assert(raw[0] == '"' and raw[raw.len - 1] == '"');
701
702 const raw_no_quotes = raw[1 .. raw.len - 1];
703 try node.string_value.ensureTotalCapacity(self.allocator, raw_no_quotes.len);
704
705 var state: enum {
706 start,
707 escape,
708 } = .start;
709
710 var index: usize = 0;
711 while (index < raw_no_quotes.len) : (index += 1) {
712 const c = raw_no_quotes[index];
713 switch (state) {
714 .start => switch (c) {
715 '\\' => {
716 state = .escape;
717 },
718 else => {
719 node.string_value.appendAssumeCapacity(c);
720 },
721 },
722 .escape => switch (c) {
723 'n' => {
724 state = .start;
725 node.string_value.appendAssumeCapacity('\n');
726 },
727 't' => {
728 state = .start;
729 node.string_value.appendAssumeCapacity('\t');
730 },
731 '"' => {
732 state = .start;
733 node.string_value.appendAssumeCapacity('"');
734 },
735 else => return error.InvalidEscapeSequence,
736 },
737 }
738 }
739 }
686740};
687741
688742test {
743 std.testing.refAllDecls(@This());
689744 _ = @import("parse/test.zig");
690745}
src/link/tapi/parse/test.zig+385-179
......@@ -21,45 +21,45 @@ test "explicit doc" {
2121 try testing.expectEqual(tree.docs.items.len, 1);
2222
2323 const doc = tree.docs.items[0].cast(Node.Doc).?;
24 try testing.expectEqual(doc.start.?, 0);
25 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
24 try testing.expectEqual(doc.base.start, 0);
25 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
2626
2727 const directive = tree.tokens[doc.directive.?];
28 try testing.expectEqual(directive.id, .Literal);
29 try testing.expect(mem.eql(u8, "tapi-tbd", tree.source[directive.start..directive.end]));
28 try testing.expectEqual(directive.id, .literal);
29 try testing.expectEqualStrings("tapi-tbd", tree.source[directive.start..directive.end]);
3030
3131 try testing.expect(doc.value != null);
3232 try testing.expectEqual(doc.value.?.tag, .map);
3333
3434 const map = doc.value.?.cast(Node.Map).?;
35 try testing.expectEqual(map.start.?, 5);
36 try testing.expectEqual(map.end.?, 14);
35 try testing.expectEqual(map.base.start, 5);
36 try testing.expectEqual(map.base.end, 14);
3737 try testing.expectEqual(map.values.items.len, 2);
3838
3939 {
4040 const entry = map.values.items[0];
4141
4242 const key = tree.tokens[entry.key];
43 try testing.expectEqual(key.id, .Literal);
44 try testing.expect(mem.eql(u8, "tbd-version", tree.source[key.start..key.end]));
43 try testing.expectEqual(key.id, .literal);
44 try testing.expectEqualStrings("tbd-version", tree.source[key.start..key.end]);
4545
46 const value = entry.value.cast(Node.Value).?;
47 const value_tok = tree.tokens[value.start.?];
48 try testing.expectEqual(value_tok.id, .Literal);
49 try testing.expect(mem.eql(u8, "4", tree.source[value_tok.start..value_tok.end]));
46 const value = entry.value.?.cast(Node.Value).?;
47 const value_tok = tree.tokens[value.base.start];
48 try testing.expectEqual(value_tok.id, .literal);
49 try testing.expectEqualStrings("4", tree.source[value_tok.start..value_tok.end]);
5050 }
5151
5252 {
5353 const entry = map.values.items[1];
5454
5555 const key = tree.tokens[entry.key];
56 try testing.expectEqual(key.id, .Literal);
57 try testing.expect(mem.eql(u8, "abc-version", tree.source[key.start..key.end]));
56 try testing.expectEqual(key.id, .literal);
57 try testing.expectEqualStrings("abc-version", tree.source[key.start..key.end]);
5858
59 const value = entry.value.cast(Node.Value).?;
60 const value_tok = tree.tokens[value.start.?];
61 try testing.expectEqual(value_tok.id, .Literal);
62 try testing.expect(mem.eql(u8, "5", tree.source[value_tok.start..value_tok.end]));
59 const value = entry.value.?.cast(Node.Value).?;
60 const value_tok = tree.tokens[value.base.start];
61 try testing.expectEqual(value_tok.id, .literal);
62 try testing.expectEqualStrings("5", tree.source[value_tok.start..value_tok.end]);
6363 }
6464}
6565
......@@ -77,39 +77,31 @@ test "leaf in quotes" {
7777 try testing.expectEqual(tree.docs.items.len, 1);
7878
7979 const doc = tree.docs.items[0].cast(Node.Doc).?;
80 try testing.expectEqual(doc.start.?, 0);
81 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
80 try testing.expectEqual(doc.base.start, 0);
81 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
8282 try testing.expect(doc.directive == null);
8383
8484 try testing.expect(doc.value != null);
8585 try testing.expectEqual(doc.value.?.tag, .map);
8686
8787 const map = doc.value.?.cast(Node.Map).?;
88 try testing.expectEqual(map.start.?, 0);
89 try testing.expectEqual(map.end.?, tree.tokens.len - 2);
88 try testing.expectEqual(map.base.start, 0);
89 try testing.expectEqual(map.base.end, tree.tokens.len - 2);
9090 try testing.expectEqual(map.values.items.len, 3);
9191
9292 {
9393 const entry = map.values.items[0];
9494
9595 const key = tree.tokens[entry.key];
96 try testing.expectEqual(key.id, .Literal);
97 try testing.expect(mem.eql(
98 u8,
99 "key1",
100 tree.source[key.start..key.end],
101 ));
102
103 const value = entry.value.cast(Node.Value).?;
104 const start = tree.tokens[value.start.?];
105 const end = tree.tokens[value.end.?];
106 try testing.expectEqual(start.id, .Literal);
107 try testing.expectEqual(end.id, .Literal);
108 try testing.expect(mem.eql(
109 u8,
110 "no quotes",
111 tree.source[start.start..end.end],
112 ));
96 try testing.expectEqual(key.id, .literal);
97 try testing.expectEqualStrings("key1", tree.source[key.start..key.end]);
98
99 const value = entry.value.?.cast(Node.Value).?;
100 const start = tree.tokens[value.base.start];
101 const end = tree.tokens[value.base.end];
102 try testing.expectEqual(start.id, .literal);
103 try testing.expectEqual(end.id, .literal);
104 try testing.expectEqualStrings("no quotes", tree.source[start.start..end.end]);
113105 }
114106}
115107
......@@ -128,70 +120,60 @@ test "nested maps" {
128120 try testing.expectEqual(tree.docs.items.len, 1);
129121
130122 const doc = tree.docs.items[0].cast(Node.Doc).?;
131 try testing.expectEqual(doc.start.?, 0);
132 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
123 try testing.expectEqual(doc.base.start, 0);
124 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
133125 try testing.expect(doc.directive == null);
134126
135127 try testing.expect(doc.value != null);
136128 try testing.expectEqual(doc.value.?.tag, .map);
137129
138130 const map = doc.value.?.cast(Node.Map).?;
139 try testing.expectEqual(map.start.?, 0);
140 try testing.expectEqual(map.end.?, tree.tokens.len - 2);
131 try testing.expectEqual(map.base.start, 0);
132 try testing.expectEqual(map.base.end, tree.tokens.len - 2);
141133 try testing.expectEqual(map.values.items.len, 2);
142134
143135 {
144136 const entry = map.values.items[0];
145137
146138 const key = tree.tokens[entry.key];
147 try testing.expectEqual(key.id, .Literal);
148 try testing.expect(mem.eql(u8, "key1", tree.source[key.start..key.end]));
139 try testing.expectEqual(key.id, .literal);
140 try testing.expectEqualStrings("key1", tree.source[key.start..key.end]);
149141
150 const nested_map = entry.value.cast(Node.Map).?;
151 try testing.expectEqual(nested_map.start.?, 4);
152 try testing.expectEqual(nested_map.end.?, 16);
142 const nested_map = entry.value.?.cast(Node.Map).?;
143 try testing.expectEqual(nested_map.base.start, 4);
144 try testing.expectEqual(nested_map.base.end, 16);
153145 try testing.expectEqual(nested_map.values.items.len, 2);
154146
155147 {
156148 const nested_entry = nested_map.values.items[0];
157149
158150 const nested_key = tree.tokens[nested_entry.key];
159 try testing.expectEqual(nested_key.id, .Literal);
160 try testing.expect(mem.eql(
161 u8,
162 "key1_1",
163 tree.source[nested_key.start..nested_key.end],
164 ));
165
166 const nested_value = nested_entry.value.cast(Node.Value).?;
167 const nested_value_tok = tree.tokens[nested_value.start.?];
168 try testing.expectEqual(nested_value_tok.id, .Literal);
169 try testing.expect(mem.eql(
170 u8,
151 try testing.expectEqual(nested_key.id, .literal);
152 try testing.expectEqualStrings("key1_1", tree.source[nested_key.start..nested_key.end]);
153
154 const nested_value = nested_entry.value.?.cast(Node.Value).?;
155 const nested_value_tok = tree.tokens[nested_value.base.start];
156 try testing.expectEqual(nested_value_tok.id, .literal);
157 try testing.expectEqualStrings(
171158 "value1_1",
172159 tree.source[nested_value_tok.start..nested_value_tok.end],
173 ));
160 );
174161 }
175162
176163 {
177164 const nested_entry = nested_map.values.items[1];
178165
179166 const nested_key = tree.tokens[nested_entry.key];
180 try testing.expectEqual(nested_key.id, .Literal);
181 try testing.expect(mem.eql(
182 u8,
183 "key1_2",
184 tree.source[nested_key.start..nested_key.end],
185 ));
186
187 const nested_value = nested_entry.value.cast(Node.Value).?;
188 const nested_value_tok = tree.tokens[nested_value.start.?];
189 try testing.expectEqual(nested_value_tok.id, .Literal);
190 try testing.expect(mem.eql(
191 u8,
167 try testing.expectEqual(nested_key.id, .literal);
168 try testing.expectEqualStrings("key1_2", tree.source[nested_key.start..nested_key.end]);
169
170 const nested_value = nested_entry.value.?.cast(Node.Value).?;
171 const nested_value_tok = tree.tokens[nested_value.base.start];
172 try testing.expectEqual(nested_value_tok.id, .literal);
173 try testing.expectEqualStrings(
192174 "value1_2",
193175 tree.source[nested_value_tok.start..nested_value_tok.end],
194 ));
176 );
195177 }
196178 }
197179
......@@ -199,17 +181,13 @@ test "nested maps" {
199181 const entry = map.values.items[1];
200182
201183 const key = tree.tokens[entry.key];
202 try testing.expectEqual(key.id, .Literal);
203 try testing.expect(mem.eql(u8, "key2", tree.source[key.start..key.end]));
204
205 const value = entry.value.cast(Node.Value).?;
206 const value_tok = tree.tokens[value.start.?];
207 try testing.expectEqual(value_tok.id, .Literal);
208 try testing.expect(mem.eql(
209 u8,
210 "value2",
211 tree.source[value_tok.start..value_tok.end],
212 ));
184 try testing.expectEqual(key.id, .literal);
185 try testing.expectEqualStrings("key2", tree.source[key.start..key.end]);
186
187 const value = entry.value.?.cast(Node.Value).?;
188 const value_tok = tree.tokens[value.base.start];
189 try testing.expectEqual(value_tok.id, .literal);
190 try testing.expectEqualStrings("value2", tree.source[value_tok.start..value_tok.end]);
213191 }
214192}
215193
......@@ -227,46 +205,46 @@ test "map of list of values" {
227205 try testing.expectEqual(tree.docs.items.len, 1);
228206
229207 const doc = tree.docs.items[0].cast(Node.Doc).?;
230 try testing.expectEqual(doc.start.?, 0);
231 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
208 try testing.expectEqual(doc.base.start, 0);
209 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
232210
233211 try testing.expect(doc.value != null);
234212 try testing.expectEqual(doc.value.?.tag, .map);
235213
236214 const map = doc.value.?.cast(Node.Map).?;
237 try testing.expectEqual(map.start.?, 0);
238 try testing.expectEqual(map.end.?, tree.tokens.len - 2);
215 try testing.expectEqual(map.base.start, 0);
216 try testing.expectEqual(map.base.end, tree.tokens.len - 2);
239217 try testing.expectEqual(map.values.items.len, 1);
240218
241219 const entry = map.values.items[0];
242220 const key = tree.tokens[entry.key];
243 try testing.expectEqual(key.id, .Literal);
244 try testing.expect(mem.eql(u8, "ints", tree.source[key.start..key.end]));
221 try testing.expectEqual(key.id, .literal);
222 try testing.expectEqualStrings("ints", tree.source[key.start..key.end]);
245223
246 const value = entry.value.cast(Node.List).?;
247 try testing.expectEqual(value.start.?, 4);
248 try testing.expectEqual(value.end.?, tree.tokens.len - 2);
224 const value = entry.value.?.cast(Node.List).?;
225 try testing.expectEqual(value.base.start, 4);
226 try testing.expectEqual(value.base.end, tree.tokens.len - 2);
249227 try testing.expectEqual(value.values.items.len, 3);
250228
251229 {
252230 const elem = value.values.items[0].cast(Node.Value).?;
253 const leaf = tree.tokens[elem.start.?];
254 try testing.expectEqual(leaf.id, .Literal);
255 try testing.expect(mem.eql(u8, "0", tree.source[leaf.start..leaf.end]));
231 const leaf = tree.tokens[elem.base.start];
232 try testing.expectEqual(leaf.id, .literal);
233 try testing.expectEqualStrings("0", tree.source[leaf.start..leaf.end]);
256234 }
257235
258236 {
259237 const elem = value.values.items[1].cast(Node.Value).?;
260 const leaf = tree.tokens[elem.start.?];
261 try testing.expectEqual(leaf.id, .Literal);
262 try testing.expect(mem.eql(u8, "1", tree.source[leaf.start..leaf.end]));
238 const leaf = tree.tokens[elem.base.start];
239 try testing.expectEqual(leaf.id, .literal);
240 try testing.expectEqualStrings("1", tree.source[leaf.start..leaf.end]);
263241 }
264242
265243 {
266244 const elem = value.values.items[2].cast(Node.Value).?;
267 const leaf = tree.tokens[elem.start.?];
268 try testing.expectEqual(leaf.id, .Literal);
269 try testing.expect(mem.eql(u8, "2", tree.source[leaf.start..leaf.end]));
245 const leaf = tree.tokens[elem.base.start];
246 try testing.expectEqual(leaf.id, .literal);
247 try testing.expectEqualStrings("2", tree.source[leaf.start..leaf.end]);
270248 }
271249}
272250
......@@ -285,64 +263,64 @@ test "map of list of maps" {
285263 try testing.expectEqual(tree.docs.items.len, 1);
286264
287265 const doc = tree.docs.items[0].cast(Node.Doc).?;
288 try testing.expectEqual(doc.start.?, 0);
289 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
266 try testing.expectEqual(doc.base.start, 0);
267 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
290268
291269 try testing.expect(doc.value != null);
292270 try testing.expectEqual(doc.value.?.tag, .map);
293271
294272 const map = doc.value.?.cast(Node.Map).?;
295 try testing.expectEqual(map.start.?, 0);
296 try testing.expectEqual(map.end.?, tree.tokens.len - 2);
273 try testing.expectEqual(map.base.start, 0);
274 try testing.expectEqual(map.base.end, tree.tokens.len - 2);
297275 try testing.expectEqual(map.values.items.len, 1);
298276
299277 const entry = map.values.items[0];
300278 const key = tree.tokens[entry.key];
301 try testing.expectEqual(key.id, .Literal);
302 try testing.expect(mem.eql(u8, "key1", tree.source[key.start..key.end]));
279 try testing.expectEqual(key.id, .literal);
280 try testing.expectEqualStrings("key1", tree.source[key.start..key.end]);
303281
304 const value = entry.value.cast(Node.List).?;
305 try testing.expectEqual(value.start.?, 3);
306 try testing.expectEqual(value.end.?, tree.tokens.len - 2);
282 const value = entry.value.?.cast(Node.List).?;
283 try testing.expectEqual(value.base.start, 3);
284 try testing.expectEqual(value.base.end, tree.tokens.len - 2);
307285 try testing.expectEqual(value.values.items.len, 3);
308286
309287 {
310288 const elem = value.values.items[0].cast(Node.Map).?;
311289 const nested = elem.values.items[0];
312290 const nested_key = tree.tokens[nested.key];
313 try testing.expectEqual(nested_key.id, .Literal);
314 try testing.expect(mem.eql(u8, "key2", tree.source[nested_key.start..nested_key.end]));
291 try testing.expectEqual(nested_key.id, .literal);
292 try testing.expectEqualStrings("key2", tree.source[nested_key.start..nested_key.end]);
315293
316 const nested_v = nested.value.cast(Node.Value).?;
317 const leaf = tree.tokens[nested_v.start.?];
318 try testing.expectEqual(leaf.id, .Literal);
319 try testing.expect(mem.eql(u8, "value2", tree.source[leaf.start..leaf.end]));
294 const nested_v = nested.value.?.cast(Node.Value).?;
295 const leaf = tree.tokens[nested_v.base.start];
296 try testing.expectEqual(leaf.id, .literal);
297 try testing.expectEqualStrings("value2", tree.source[leaf.start..leaf.end]);
320298 }
321299
322300 {
323301 const elem = value.values.items[1].cast(Node.Map).?;
324302 const nested = elem.values.items[0];
325303 const nested_key = tree.tokens[nested.key];
326 try testing.expectEqual(nested_key.id, .Literal);
327 try testing.expect(mem.eql(u8, "key3", tree.source[nested_key.start..nested_key.end]));
304 try testing.expectEqual(nested_key.id, .literal);
305 try testing.expectEqualStrings("key3", tree.source[nested_key.start..nested_key.end]);
328306
329 const nested_v = nested.value.cast(Node.Value).?;
330 const leaf = tree.tokens[nested_v.start.?];
331 try testing.expectEqual(leaf.id, .Literal);
332 try testing.expect(mem.eql(u8, "value3", tree.source[leaf.start..leaf.end]));
307 const nested_v = nested.value.?.cast(Node.Value).?;
308 const leaf = tree.tokens[nested_v.base.start];
309 try testing.expectEqual(leaf.id, .literal);
310 try testing.expectEqualStrings("value3", tree.source[leaf.start..leaf.end]);
333311 }
334312
335313 {
336314 const elem = value.values.items[2].cast(Node.Map).?;
337315 const nested = elem.values.items[0];
338316 const nested_key = tree.tokens[nested.key];
339 try testing.expectEqual(nested_key.id, .Literal);
340 try testing.expect(mem.eql(u8, "key4", tree.source[nested_key.start..nested_key.end]));
317 try testing.expectEqual(nested_key.id, .literal);
318 try testing.expectEqualStrings("key4", tree.source[nested_key.start..nested_key.end]);
341319
342 const nested_v = nested.value.cast(Node.Value).?;
343 const leaf = tree.tokens[nested_v.start.?];
344 try testing.expectEqual(leaf.id, .Literal);
345 try testing.expect(mem.eql(u8, "value4", tree.source[leaf.start..leaf.end]));
320 const nested_v = nested.value.?.cast(Node.Value).?;
321 const leaf = tree.tokens[nested_v.base.start];
322 try testing.expectEqual(leaf.id, .literal);
323 try testing.expectEqualStrings("value4", tree.source[leaf.start..leaf.end]);
346324 }
347325}
348326
......@@ -360,15 +338,15 @@ test "list of lists" {
360338 try testing.expectEqual(tree.docs.items.len, 1);
361339
362340 const doc = tree.docs.items[0].cast(Node.Doc).?;
363 try testing.expectEqual(doc.start.?, 0);
364 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
341 try testing.expectEqual(doc.base.start, 0);
342 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
365343
366344 try testing.expect(doc.value != null);
367345 try testing.expectEqual(doc.value.?.tag, .list);
368346
369347 const list = doc.value.?.cast(Node.List).?;
370 try testing.expectEqual(list.start.?, 0);
371 try testing.expectEqual(list.end.?, tree.tokens.len - 2);
348 try testing.expectEqual(list.base.start, 0);
349 try testing.expectEqual(list.base.end, tree.tokens.len - 2);
372350 try testing.expectEqual(list.values.items.len, 3);
373351
374352 {
......@@ -379,22 +357,22 @@ test "list of lists" {
379357 {
380358 try testing.expectEqual(nested.values.items[0].tag, .value);
381359 const value = nested.values.items[0].cast(Node.Value).?;
382 const leaf = tree.tokens[value.start.?];
383 try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end]));
360 const leaf = tree.tokens[value.base.start];
361 try testing.expectEqualStrings("name", tree.source[leaf.start..leaf.end]);
384362 }
385363
386364 {
387365 try testing.expectEqual(nested.values.items[1].tag, .value);
388366 const value = nested.values.items[1].cast(Node.Value).?;
389 const leaf = tree.tokens[value.start.?];
390 try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end]));
367 const leaf = tree.tokens[value.base.start];
368 try testing.expectEqualStrings("hr", tree.source[leaf.start..leaf.end]);
391369 }
392370
393371 {
394372 try testing.expectEqual(nested.values.items[2].tag, .value);
395373 const value = nested.values.items[2].cast(Node.Value).?;
396 const leaf = tree.tokens[value.start.?];
397 try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end]));
374 const leaf = tree.tokens[value.base.start];
375 try testing.expectEqualStrings("avg", tree.source[leaf.start..leaf.end]);
398376 }
399377 }
400378
......@@ -406,23 +384,23 @@ test "list of lists" {
406384 {
407385 try testing.expectEqual(nested.values.items[0].tag, .value);
408386 const value = nested.values.items[0].cast(Node.Value).?;
409 const start = tree.tokens[value.start.?];
410 const end = tree.tokens[value.end.?];
411 try testing.expect(mem.eql(u8, "Mark McGwire", tree.source[start.start..end.end]));
387 const start = tree.tokens[value.base.start];
388 const end = tree.tokens[value.base.end];
389 try testing.expectEqualStrings("Mark McGwire", tree.source[start.start..end.end]);
412390 }
413391
414392 {
415393 try testing.expectEqual(nested.values.items[1].tag, .value);
416394 const value = nested.values.items[1].cast(Node.Value).?;
417 const leaf = tree.tokens[value.start.?];
418 try testing.expect(mem.eql(u8, "65", tree.source[leaf.start..leaf.end]));
395 const leaf = tree.tokens[value.base.start];
396 try testing.expectEqualStrings("65", tree.source[leaf.start..leaf.end]);
419397 }
420398
421399 {
422400 try testing.expectEqual(nested.values.items[2].tag, .value);
423401 const value = nested.values.items[2].cast(Node.Value).?;
424 const leaf = tree.tokens[value.start.?];
425 try testing.expect(mem.eql(u8, "0.278", tree.source[leaf.start..leaf.end]));
402 const leaf = tree.tokens[value.base.start];
403 try testing.expectEqualStrings("0.278", tree.source[leaf.start..leaf.end]);
426404 }
427405 }
428406
......@@ -434,23 +412,23 @@ test "list of lists" {
434412 {
435413 try testing.expectEqual(nested.values.items[0].tag, .value);
436414 const value = nested.values.items[0].cast(Node.Value).?;
437 const start = tree.tokens[value.start.?];
438 const end = tree.tokens[value.end.?];
439 try testing.expect(mem.eql(u8, "Sammy Sosa", tree.source[start.start..end.end]));
415 const start = tree.tokens[value.base.start];
416 const end = tree.tokens[value.base.end];
417 try testing.expectEqualStrings("Sammy Sosa", tree.source[start.start..end.end]);
440418 }
441419
442420 {
443421 try testing.expectEqual(nested.values.items[1].tag, .value);
444422 const value = nested.values.items[1].cast(Node.Value).?;
445 const leaf = tree.tokens[value.start.?];
446 try testing.expect(mem.eql(u8, "63", tree.source[leaf.start..leaf.end]));
423 const leaf = tree.tokens[value.base.start];
424 try testing.expectEqualStrings("63", tree.source[leaf.start..leaf.end]);
447425 }
448426
449427 {
450428 try testing.expectEqual(nested.values.items[2].tag, .value);
451429 const value = nested.values.items[2].cast(Node.Value).?;
452 const leaf = tree.tokens[value.start.?];
453 try testing.expect(mem.eql(u8, "0.288", tree.source[leaf.start..leaf.end]));
430 const leaf = tree.tokens[value.base.start];
431 try testing.expectEqualStrings("0.288", tree.source[leaf.start..leaf.end]);
454432 }
455433 }
456434}
......@@ -467,36 +445,36 @@ test "inline list" {
467445 try testing.expectEqual(tree.docs.items.len, 1);
468446
469447 const doc = tree.docs.items[0].cast(Node.Doc).?;
470 try testing.expectEqual(doc.start.?, 0);
471 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
448 try testing.expectEqual(doc.base.start, 0);
449 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
472450
473451 try testing.expect(doc.value != null);
474452 try testing.expectEqual(doc.value.?.tag, .list);
475453
476454 const list = doc.value.?.cast(Node.List).?;
477 try testing.expectEqual(list.start.?, 0);
478 try testing.expectEqual(list.end.?, tree.tokens.len - 2);
455 try testing.expectEqual(list.base.start, 0);
456 try testing.expectEqual(list.base.end, tree.tokens.len - 2);
479457 try testing.expectEqual(list.values.items.len, 3);
480458
481459 {
482460 try testing.expectEqual(list.values.items[0].tag, .value);
483461 const value = list.values.items[0].cast(Node.Value).?;
484 const leaf = tree.tokens[value.start.?];
485 try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end]));
462 const leaf = tree.tokens[value.base.start];
463 try testing.expectEqualStrings("name", tree.source[leaf.start..leaf.end]);
486464 }
487465
488466 {
489467 try testing.expectEqual(list.values.items[1].tag, .value);
490468 const value = list.values.items[1].cast(Node.Value).?;
491 const leaf = tree.tokens[value.start.?];
492 try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end]));
469 const leaf = tree.tokens[value.base.start];
470 try testing.expectEqualStrings("hr", tree.source[leaf.start..leaf.end]);
493471 }
494472
495473 {
496474 try testing.expectEqual(list.values.items[2].tag, .value);
497475 const value = list.values.items[2].cast(Node.Value).?;
498 const leaf = tree.tokens[value.start.?];
499 try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end]));
476 const leaf = tree.tokens[value.base.start];
477 try testing.expectEqualStrings("avg", tree.source[leaf.start..leaf.end]);
500478 }
501479}
502480
......@@ -514,45 +492,273 @@ test "inline list as mapping value" {
514492 try testing.expectEqual(tree.docs.items.len, 1);
515493
516494 const doc = tree.docs.items[0].cast(Node.Doc).?;
517 try testing.expectEqual(doc.start.?, 0);
518 try testing.expectEqual(doc.end.?, tree.tokens.len - 2);
495 try testing.expectEqual(doc.base.start, 0);
496 try testing.expectEqual(doc.base.end, tree.tokens.len - 2);
519497
520498 try testing.expect(doc.value != null);
521499 try testing.expectEqual(doc.value.?.tag, .map);
522500
523501 const map = doc.value.?.cast(Node.Map).?;
524 try testing.expectEqual(map.start.?, 0);
525 try testing.expectEqual(map.end.?, tree.tokens.len - 2);
502 try testing.expectEqual(map.base.start, 0);
503 try testing.expectEqual(map.base.end, tree.tokens.len - 2);
526504 try testing.expectEqual(map.values.items.len, 1);
527505
528506 const entry = map.values.items[0];
529507 const key = tree.tokens[entry.key];
530 try testing.expectEqual(key.id, .Literal);
531 try testing.expect(mem.eql(u8, "key", tree.source[key.start..key.end]));
508 try testing.expectEqual(key.id, .literal);
509 try testing.expectEqualStrings("key", tree.source[key.start..key.end]);
532510
533 const list = entry.value.cast(Node.List).?;
534 try testing.expectEqual(list.start.?, 4);
535 try testing.expectEqual(list.end.?, tree.tokens.len - 2);
511 const list = entry.value.?.cast(Node.List).?;
512 try testing.expectEqual(list.base.start, 4);
513 try testing.expectEqual(list.base.end, tree.tokens.len - 2);
536514 try testing.expectEqual(list.values.items.len, 3);
537515
538516 {
539517 try testing.expectEqual(list.values.items[0].tag, .value);
540518 const value = list.values.items[0].cast(Node.Value).?;
541 const leaf = tree.tokens[value.start.?];
542 try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end]));
519 const leaf = tree.tokens[value.base.start];
520 try testing.expectEqualStrings("name", tree.source[leaf.start..leaf.end]);
543521 }
544522
545523 {
546524 try testing.expectEqual(list.values.items[1].tag, .value);
547525 const value = list.values.items[1].cast(Node.Value).?;
548 const leaf = tree.tokens[value.start.?];
549 try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end]));
526 const leaf = tree.tokens[value.base.start];
527 try testing.expectEqualStrings("hr", tree.source[leaf.start..leaf.end]);
550528 }
551529
552530 {
553531 try testing.expectEqual(list.values.items[2].tag, .value);
554532 const value = list.values.items[2].cast(Node.Value).?;
555 const leaf = tree.tokens[value.start.?];
556 try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end]));
533 const leaf = tree.tokens[value.base.start];
534 try testing.expectEqualStrings("avg", tree.source[leaf.start..leaf.end]);
557535 }
558536}
537
538fn parseSuccess(comptime source: []const u8) !void {
539 var tree = Tree.init(testing.allocator);
540 defer tree.deinit();
541 try tree.parse(source);
542}
543
544fn parseError(comptime source: []const u8, err: parse.ParseError) !void {
545 var tree = Tree.init(testing.allocator);
546 defer tree.deinit();
547 try testing.expectError(err, tree.parse(source));
548}
549
550test "empty doc with spaces and comments" {
551 try parseSuccess(
552 \\
553 \\
554 \\ # this is a comment in a weird place
555 \\# and this one is too
556 );
557}
558
559test "comment between --- and ! in document start" {
560 try parseError(
561 \\--- # what is it?
562 \\!
563 , error.UnexpectedToken);
564}
565
566test "correct doc start with tag" {
567 try parseSuccess(
568 \\--- !some-tag
569 \\
570 );
571}
572
573test "doc close without explicit doc open" {
574 try parseError(
575 \\
576 \\
577 \\# something cool
578 \\...
579 , error.UnexpectedToken);
580}
581
582test "doc open and close are ok" {
583 try parseSuccess(
584 \\---
585 \\# first doc
586 \\
587 \\
588 \\---
589 \\# second doc
590 \\
591 \\
592 \\...
593 );
594}
595
596test "doc with a single string is ok" {
597 try parseSuccess(
598 \\a string of some sort
599 \\
600 );
601}
602
603test "explicit doc with a single string is ok" {
604 try parseSuccess(
605 \\--- !anchor
606 \\# nothing to see here except one string
607 \\ # not a lot to go on with
608 \\a single string
609 \\...
610 );
611}
612
613test "doc with two string is bad" {
614 try parseError(
615 \\first
616 \\second
617 \\# this should fail already
618 , error.UnexpectedToken);
619}
620
621test "single quote string can have new lines" {
622 try parseSuccess(
623 \\'what is this
624 \\ thing?'
625 );
626}
627
628test "single quote string on one line is fine" {
629 try parseSuccess(
630 \\'here''s an apostrophe'
631 );
632}
633
634test "double quote string can have new lines" {
635 try parseSuccess(
636 \\"what is this
637 \\ thing?"
638 );
639}
640
641test "double quote string on one line is fine" {
642 try parseSuccess(
643 \\"a newline\nand a\ttab"
644 );
645}
646
647test "map with key and value literals" {
648 try parseSuccess(
649 \\key1: val1
650 \\key2 : val2
651 );
652}
653
654test "map of maps" {
655 try parseSuccess(
656 \\
657 \\# the first key
658 \\key1:
659 \\ # the first subkey
660 \\ key1_1: 0
661 \\ key1_2: 1
662 \\# the second key
663 \\key2:
664 \\ key2_1: -1
665 \\ key2_2: -2
666 \\# the end of map
667 );
668}
669
670test "map value indicator needs to be on the same line" {
671 try parseError(
672 \\a
673 \\ : b
674 , error.UnexpectedToken);
675}
676
677test "value needs to be indented" {
678 try parseError(
679 \\a:
680 \\b
681 , error.MalformedYaml);
682}
683
684test "comment between a key and a value is fine" {
685 try parseSuccess(
686 \\a:
687 \\ # this is a value
688 \\ b
689 );
690}
691
692test "simple list" {
693 try parseSuccess(
694 \\# first el
695 \\- a
696 \\# second el
697 \\- b
698 \\# third el
699 \\- c
700 );
701}
702
703test "list indentation matters" {
704 try parseSuccess(
705 \\ - a
706 \\- b
707 );
708
709 try parseSuccess(
710 \\- a
711 \\ - b
712 );
713}
714
715test "unindented list is fine too" {
716 try parseSuccess(
717 \\a:
718 \\- 0
719 \\- 1
720 );
721}
722
723test "empty values in a map" {
724 try parseSuccess(
725 \\a:
726 \\b:
727 \\- 0
728 );
729}
730
731test "weirdly nested map of maps of lists" {
732 try parseSuccess(
733 \\a:
734 \\ b:
735 \\ - 0
736 \\ - 1
737 );
738}
739
740test "square brackets denote a list" {
741 try parseSuccess(
742 \\[ a,
743 \\ b, c ]
744 );
745}
746
747test "empty list" {
748 try parseSuccess(
749 \\[ ]
750 );
751}
752
753test "comment within a bracketed list is an error" {
754 try parseError(
755 \\[ # something
756 \\]
757 , error.MalformedYaml);
758}
759
760test "mixed ints with floats in a list" {
761 try parseSuccess(
762 \\[0, 1.0]
763 );
764}
src/link/tapi/yaml.zig+176-396
......@@ -2,8 +2,7 @@ const std = @import("std");
22const assert = std.debug.assert;
33const math = std.math;
44const mem = std.mem;
5const testing = std.testing;
6const log = std.log.scoped(.tapi);
5const log = std.log.scoped(.yaml);
76
87const Allocator = mem.Allocator;
98const ArenaAllocator = std.heap.ArenaAllocator;
......@@ -17,22 +16,15 @@ const ParseError = parse.ParseError;
1716
1817pub const YamlError = error{
1918 UnexpectedNodeType,
19 DuplicateMapKey,
2020 OutOfMemory,
21 CannotEncodeValue,
2122} || ParseError || std.fmt.ParseIntError;
2223
23pub const ValueType = enum {
24 empty,
25 int,
26 float,
27 string,
28 list,
29 map,
30};
31
3224pub const List = []Value;
33pub const Map = std.StringArrayHashMap(Value);
25pub const Map = std.StringHashMap(Value);
3426
35pub const Value = union(ValueType) {
27pub const Value = union(enum) {
3628 empty,
3729 int: i64,
3830 float: f64,
......@@ -70,9 +62,7 @@ pub const Value = union(ValueType) {
7062 should_inline_first_key: bool = false,
7163 };
7264
73 pub const StringifyError = std.os.WriteError;
74
75 pub fn stringify(self: Value, writer: anytype, args: StringifyArgs) StringifyError!void {
65 pub fn stringify(self: Value, writer: anytype, args: StringifyArgs) anyerror!void {
7666 switch (self) {
7767 .empty => return,
7868 .int => |int| return writer.print("{}", .{int}),
......@@ -83,7 +73,7 @@ pub const Value = union(ValueType) {
8373 if (len == 0) return;
8474
8575 const first = list[0];
86 if (first.is_compound()) {
76 if (first.isCompound()) {
8777 for (list, 0..) |elem, i| {
8878 try writer.writeByteNTimes(' ', args.indentation);
8979 try writer.writeAll("- ");
......@@ -108,20 +98,23 @@ pub const Value = union(ValueType) {
10898 try writer.writeAll(" ]");
10999 },
110100 .map => |map| {
111 const keys = map.keys();
112 const len = keys.len;
101 const len = map.count();
113102 if (len == 0) return;
114103
115 for (keys, 0..) |key, i| {
104 var i: usize = 0;
105 var it = map.iterator();
106 while (it.next()) |entry| {
107 const key = entry.key_ptr.*;
108 const value = entry.value_ptr.*;
109
116110 if (!args.should_inline_first_key or i != 0) {
117111 try writer.writeByteNTimes(' ', args.indentation);
118112 }
119113 try writer.print("{s}: ", .{key});
120114
121 const value = map.get(key) orelse unreachable;
122115 const should_inline = blk: {
123 if (!value.is_compound()) break :blk true;
124 if (value == .list and value.list.len > 0 and !value.list[0].is_compound()) break :blk true;
116 if (!value.isCompound()) break :blk true;
117 if (value == .list and value.list.len > 0 and !value.list[0].isCompound()) break :blk true;
125118 break :blk false;
126119 };
127120
......@@ -137,35 +130,44 @@ pub const Value = union(ValueType) {
137130 if (i < len - 1) {
138131 try writer.writeByte('\n');
139132 }
133
134 i += 1;
140135 }
141136 },
142137 }
143138 }
144139
145 fn is_compound(self: Value) bool {
140 fn isCompound(self: Value) bool {
146141 return switch (self) {
147142 .list, .map => true,
148143 else => false,
149144 };
150145 }
151146
152 fn fromNode(arena: Allocator, tree: *const Tree, node: *const Node, type_hint: ?ValueType) YamlError!Value {
147 fn fromNode(arena: Allocator, tree: *const Tree, node: *const Node) YamlError!Value {
153148 if (node.cast(Node.Doc)) |doc| {
154149 const inner = doc.value orelse {
155150 // empty doc
156151 return Value{ .empty = {} };
157152 };
158 return Value.fromNode(arena, tree, inner, null);
153 return Value.fromNode(arena, tree, inner);
159154 } else if (node.cast(Node.Map)) |map| {
160 var out_map = std.StringArrayHashMap(Value).init(arena);
161 try out_map.ensureUnusedCapacity(map.values.items.len);
155 // TODO use ContextAdapted HashMap and do not duplicate keys, intern
156 // in a contiguous string buffer.
157 var out_map = std.StringHashMap(Value).init(arena);
158 try out_map.ensureUnusedCapacity(math.cast(u32, map.values.items.len) orelse return error.Overflow);
162159
163160 for (map.values.items) |entry| {
164 const key_tok = tree.tokens[entry.key];
165 const key = try arena.dupe(u8, tree.source[key_tok.start..key_tok.end]);
166 const value = try Value.fromNode(arena, tree, entry.value, null);
167
168 out_map.putAssumeCapacityNoClobber(key, value);
161 const key = try arena.dupe(u8, tree.getRaw(entry.key, entry.key));
162 const gop = out_map.getOrPutAssumeCapacity(key);
163 if (gop.found_existing) {
164 return error.DuplicateMapKey;
165 }
166 const value = if (entry.value) |value|
167 try Value.fromNode(arena, tree, value)
168 else
169 .empty;
170 gop.value_ptr.* = value;
169171 }
170172
171173 return Value{ .map = out_map };
......@@ -173,56 +175,124 @@ pub const Value = union(ValueType) {
173175 var out_list = std.ArrayList(Value).init(arena);
174176 try out_list.ensureUnusedCapacity(list.values.items.len);
175177
176 if (list.values.items.len > 0) {
177 const hint = if (list.values.items[0].cast(Node.Value)) |value| hint: {
178 const start = tree.tokens[value.start.?];
179 const end = tree.tokens[value.end.?];
180 const raw = tree.source[start.start..end.end];
181 _ = std.fmt.parseInt(i64, raw, 10) catch {
182 _ = std.fmt.parseFloat(f64, raw) catch {
183 break :hint ValueType.string;
184 };
185 break :hint ValueType.float;
186 };
187 break :hint ValueType.int;
188 } else null;
189
190 for (list.values.items) |elem| {
191 const value = try Value.fromNode(arena, tree, elem, hint);
192 out_list.appendAssumeCapacity(value);
193 }
178 for (list.values.items) |elem| {
179 const value = try Value.fromNode(arena, tree, elem);
180 out_list.appendAssumeCapacity(value);
194181 }
195182
196183 return Value{ .list = try out_list.toOwnedSlice() };
197184 } else if (node.cast(Node.Value)) |value| {
198 const start = tree.tokens[value.start.?];
199 const end = tree.tokens[value.end.?];
200 const raw = tree.source[start.start..end.end];
201
202 if (type_hint) |hint| {
203 return switch (hint) {
204 .int => Value{ .int = try std.fmt.parseInt(i64, raw, 10) },
205 .float => Value{ .float = try std.fmt.parseFloat(f64, raw) },
206 .string => Value{ .string = try arena.dupe(u8, raw) },
207 else => unreachable,
208 };
209 }
185 const raw = tree.getRaw(node.start, node.end);
210186
211187 try_int: {
212188 // TODO infer base for int
213189 const int = std.fmt.parseInt(i64, raw, 10) catch break :try_int;
214190 return Value{ .int = int };
215191 }
192
216193 try_float: {
217194 const float = std.fmt.parseFloat(f64, raw) catch break :try_float;
218195 return Value{ .float = float };
219196 }
220 return Value{ .string = try arena.dupe(u8, raw) };
197
198 return Value{ .string = try arena.dupe(u8, value.string_value.items) };
221199 } else {
222200 log.err("Unexpected node type: {}", .{node.tag});
223201 return error.UnexpectedNodeType;
224202 }
225203 }
204
205 fn encode(arena: Allocator, input: anytype) YamlError!?Value {
206 switch (@typeInfo(@TypeOf(input))) {
207 .ComptimeInt,
208 .Int,
209 => return Value{ .int = math.cast(i64, input) orelse return error.Overflow },
210
211 .Float => return Value{ .float = math.lossyCast(f64, input) },
212
213 .Struct => |info| if (info.is_tuple) {
214 var list = std.ArrayList(Value).init(arena);
215 errdefer list.deinit();
216 try list.ensureTotalCapacityPrecise(info.fields.len);
217
218 inline for (info.fields) |field| {
219 if (try encode(arena, @field(input, field.name))) |value| {
220 list.appendAssumeCapacity(value);
221 }
222 }
223
224 return Value{ .list = try list.toOwnedSlice() };
225 } else {
226 var map = Map.init(arena);
227 errdefer map.deinit();
228 try map.ensureTotalCapacity(info.fields.len);
229
230 inline for (info.fields) |field| {
231 if (try encode(arena, @field(input, field.name))) |value| {
232 const key = try arena.dupe(u8, field.name);
233 map.putAssumeCapacityNoClobber(key, value);
234 }
235 }
236
237 return Value{ .map = map };
238 },
239
240 .Union => |info| if (info.tag_type) |tag_type| {
241 inline for (info.fields) |field| {
242 if (@field(tag_type, field.name) == input) {
243 return try encode(arena, @field(input, field.name));
244 }
245 } else unreachable;
246 } else return error.UntaggedUnion,
247
248 .Array => return encode(arena, &input),
249
250 .Pointer => |info| switch (info.size) {
251 .One => switch (@typeInfo(info.child)) {
252 .Array => |child_info| {
253 const Slice = []const child_info.child;
254 return encode(arena, @as(Slice, input));
255 },
256 else => {
257 @compileError("Unhandled type: {s}" ++ @typeName(info.child));
258 },
259 },
260 .Slice => {
261 if (info.child == u8) {
262 return Value{ .string = try arena.dupe(u8, input) };
263 }
264
265 var list = std.ArrayList(Value).init(arena);
266 errdefer list.deinit();
267 try list.ensureTotalCapacityPrecise(input.len);
268
269 for (input) |elem| {
270 if (try encode(arena, elem)) |value| {
271 list.appendAssumeCapacity(value);
272 } else {
273 log.err("Could not encode value in a list: {any}", .{elem});
274 return error.CannotEncodeValue;
275 }
276 }
277
278 return Value{ .list = try list.toOwnedSlice() };
279 },
280 else => {
281 @compileError("Unhandled type: {s}" ++ @typeName(@TypeOf(input)));
282 },
283 },
284
285 // TODO we should probably have an option to encode `null` and also
286 // allow for some default value too.
287 .Optional => return if (input) |val| encode(arena, val) else null,
288
289 .Null => return null,
290
291 else => {
292 @compileError("Unhandled type: {s}" ++ @typeName(@TypeOf(input)));
293 },
294 }
295 }
226296};
227297
228298pub const Yaml = struct {
......@@ -234,30 +304,18 @@ pub const Yaml = struct {
234304 self.arena.deinit();
235305 }
236306
237 pub fn stringify(self: Yaml, writer: anytype) !void {
238 for (self.docs.items) |doc| {
239 // if (doc.directive) |directive| {
240 // try writer.print("--- !{s}\n", .{directive});
241 // }
242 try doc.stringify(writer, .{});
243 // if (doc.directive != null) {
244 // try writer.writeAll("...\n");
245 // }
246 }
247 }
248
249307 pub fn load(allocator: Allocator, source: []const u8) !Yaml {
250308 var arena = ArenaAllocator.init(allocator);
251 const arena_allocator = arena.allocator();
309 errdefer arena.deinit();
252310
253 var tree = Tree.init(arena_allocator);
311 var tree = Tree.init(arena.allocator());
254312 try tree.parse(source);
255313
256 var docs = std.ArrayList(Value).init(arena_allocator);
257 try docs.ensureUnusedCapacity(tree.docs.items.len);
314 var docs = std.ArrayList(Value).init(arena.allocator());
315 try docs.ensureTotalCapacityPrecise(tree.docs.items.len);
258316
259317 for (tree.docs.items) |node| {
260 const value = try Value.fromNode(arena_allocator, &tree, node, null);
318 const value = try Value.fromNode(arena.allocator(), &tree, node);
261319 docs.appendAssumeCapacity(value);
262320 }
263321
......@@ -316,17 +374,19 @@ pub const Yaml = struct {
316374
317375 fn parseValue(self: *Yaml, comptime T: type, value: Value) Error!T {
318376 return switch (@typeInfo(T)) {
319 .Int => math.cast(T, try value.asInt()) orelse error.Overflow,
320 .Float => math.lossyCast(T, try value.asFloat()),
377 .Int => math.cast(T, try value.asInt()) orelse return error.Overflow,
378 .Float => if (value.asFloat()) |float| {
379 return math.lossyCast(T, float);
380 } else |_| {
381 return math.lossyCast(T, try value.asInt());
382 },
321383 .Struct => self.parseStruct(T, try value.asMap()),
322384 .Union => self.parseUnion(T, value),
323385 .Array => self.parseArray(T, try value.asList()),
324 .Pointer => {
325 if (value.asList()) |list| {
326 return self.parsePointer(T, .{ .list = list });
327 } else |_| {
328 return self.parsePointer(T, .{ .string = try value.asString() });
329 }
386 .Pointer => if (value.asList()) |list| {
387 return self.parsePointer(T, .{ .list = list });
388 } else |_| {
389 return self.parsePointer(T, .{ .string = try value.asString() });
330390 },
331391 .Void => error.TypeMismatch,
332392 .Optional => unreachable,
......@@ -372,7 +432,7 @@ pub const Yaml = struct {
372432 }
373433
374434 const unwrapped = value orelse {
375 log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.type) });
435 log.err("missing struct field: {s}: {s}", .{ field.name, @typeName(field.type) });
376436 return error.StructFieldMissing;
377437 };
378438 @field(parsed, field.name) = try self.parseValue(field.type, unwrapped);
......@@ -387,8 +447,7 @@ pub const Yaml = struct {
387447
388448 switch (ptr_info.size) {
389449 .Slice => {
390 const child_info = @typeInfo(ptr_info.child);
391 if (child_info == .Int and child_info.Int.bits == 8) {
450 if (ptr_info.child == u8) {
392451 return value.asString();
393452 }
394453
......@@ -413,315 +472,36 @@ pub const Yaml = struct {
413472
414473 return parsed;
415474 }
416};
417
418test {
419 testing.refAllDecls(@This());
420}
421
422test "simple list" {
423 const source =
424 \\- a
425 \\- b
426 \\- c
427 ;
428
429 var yaml = try Yaml.load(testing.allocator, source);
430 defer yaml.deinit();
431475
432 try testing.expectEqual(yaml.docs.items.len, 1);
433
434 const list = yaml.docs.items[0].list;
435 try testing.expectEqual(list.len, 3);
436
437 try testing.expect(mem.eql(u8, list[0].string, "a"));
438 try testing.expect(mem.eql(u8, list[1].string, "b"));
439 try testing.expect(mem.eql(u8, list[2].string, "c"));
440}
441
442test "simple list typed as array of strings" {
443 const source =
444 \\- a
445 \\- b
446 \\- c
447 ;
448
449 var yaml = try Yaml.load(testing.allocator, source);
450 defer yaml.deinit();
451
452 try testing.expectEqual(yaml.docs.items.len, 1);
453
454 const arr = try yaml.parse([3][]const u8);
455 try testing.expectEqual(arr.len, 3);
456 try testing.expect(mem.eql(u8, arr[0], "a"));
457 try testing.expect(mem.eql(u8, arr[1], "b"));
458 try testing.expect(mem.eql(u8, arr[2], "c"));
459}
460
461test "simple list typed as array of ints" {
462 const source =
463 \\- 0
464 \\- 1
465 \\- 2
466 ;
467
468 var yaml = try Yaml.load(testing.allocator, source);
469 defer yaml.deinit();
470
471 try testing.expectEqual(yaml.docs.items.len, 1);
472
473 const arr = try yaml.parse([3]u8);
474 try testing.expectEqual(arr.len, 3);
475 try testing.expectEqual(arr[0], 0);
476 try testing.expectEqual(arr[1], 1);
477 try testing.expectEqual(arr[2], 2);
478}
479
480test "list of mixed sign integer" {
481 const source =
482 \\- 0
483 \\- -1
484 \\- 2
485 ;
486
487 var yaml = try Yaml.load(testing.allocator, source);
488 defer yaml.deinit();
489
490 try testing.expectEqual(yaml.docs.items.len, 1);
491
492 const arr = try yaml.parse([3]i8);
493 try testing.expectEqual(arr.len, 3);
494 try testing.expectEqual(arr[0], 0);
495 try testing.expectEqual(arr[1], -1);
496 try testing.expectEqual(arr[2], 2);
497}
498
499test "simple map untyped" {
500 const source =
501 \\a: 0
502 ;
503
504 var yaml = try Yaml.load(testing.allocator, source);
505 defer yaml.deinit();
506
507 try testing.expectEqual(yaml.docs.items.len, 1);
508
509 const map = yaml.docs.items[0].map;
510 try testing.expect(map.contains("a"));
511 try testing.expectEqual(map.get("a").?.int, 0);
512}
513
514test "simple map untyped with a list of maps" {
515 const source =
516 \\a: 0
517 \\b:
518 \\ - foo: 1
519 \\ bar: 2
520 \\ - foo: 3
521 \\ bar: 4
522 \\c: 1
523 ;
524
525 var yaml = try Yaml.load(testing.allocator, source);
526 defer yaml.deinit();
527
528 try testing.expectEqual(yaml.docs.items.len, 1);
529
530 const map = yaml.docs.items[0].map;
531 try testing.expect(map.contains("a"));
532 try testing.expect(map.contains("b"));
533 try testing.expect(map.contains("c"));
534 try testing.expectEqual(map.get("a").?.int, 0);
535 try testing.expectEqual(map.get("c").?.int, 1);
536 try testing.expectEqual(map.get("b").?.list[0].map.get("foo").?.int, 1);
537 try testing.expectEqual(map.get("b").?.list[0].map.get("bar").?.int, 2);
538 try testing.expectEqual(map.get("b").?.list[1].map.get("foo").?.int, 3);
539 try testing.expectEqual(map.get("b").?.list[1].map.get("bar").?.int, 4);
540}
541
542test "simple map untyped with a list of maps. no indent" {
543 const source =
544 \\b:
545 \\- foo: 1
546 \\c: 1
547 ;
548
549 var yaml = try Yaml.load(testing.allocator, source);
550 defer yaml.deinit();
551
552 try testing.expectEqual(yaml.docs.items.len, 1);
553
554 const map = yaml.docs.items[0].map;
555 try testing.expect(map.contains("b"));
556 try testing.expect(map.contains("c"));
557 try testing.expectEqual(map.get("c").?.int, 1);
558 try testing.expectEqual(map.get("b").?.list[0].map.get("foo").?.int, 1);
559}
560
561test "simple map untyped with a list of maps. no indent 2" {
562 const source =
563 \\a: 0
564 \\b:
565 \\- foo: 1
566 \\ bar: 2
567 \\- foo: 3
568 \\ bar: 4
569 \\c: 1
570 ;
571
572 var yaml = try Yaml.load(testing.allocator, source);
573 defer yaml.deinit();
574
575 try testing.expectEqual(yaml.docs.items.len, 1);
576
577 const map = yaml.docs.items[0].map;
578 try testing.expect(map.contains("a"));
579 try testing.expect(map.contains("b"));
580 try testing.expect(map.contains("c"));
581 try testing.expectEqual(map.get("a").?.int, 0);
582 try testing.expectEqual(map.get("c").?.int, 1);
583 try testing.expectEqual(map.get("b").?.list[0].map.get("foo").?.int, 1);
584 try testing.expectEqual(map.get("b").?.list[0].map.get("bar").?.int, 2);
585 try testing.expectEqual(map.get("b").?.list[1].map.get("foo").?.int, 3);
586 try testing.expectEqual(map.get("b").?.list[1].map.get("bar").?.int, 4);
587}
588
589test "simple map typed" {
590 const source =
591 \\a: 0
592 \\b: hello there
593 \\c: 'wait, what?'
594 ;
595
596 var yaml = try Yaml.load(testing.allocator, source);
597 defer yaml.deinit();
598
599 const simple = try yaml.parse(struct { a: usize, b: []const u8, c: []const u8 });
600 try testing.expectEqual(simple.a, 0);
601 try testing.expect(mem.eql(u8, simple.b, "hello there"));
602 try testing.expect(mem.eql(u8, simple.c, "wait, what?"));
603}
604
605test "typed nested structs" {
606 const source =
607 \\a:
608 \\ b: hello there
609 \\ c: 'wait, what?'
610 ;
611
612 var yaml = try Yaml.load(testing.allocator, source);
613 defer yaml.deinit();
614
615 const simple = try yaml.parse(struct {
616 a: struct {
617 b: []const u8,
618 c: []const u8,
619 },
620 });
621 try testing.expect(mem.eql(u8, simple.a.b, "hello there"));
622 try testing.expect(mem.eql(u8, simple.a.c, "wait, what?"));
623}
624
625test "multidoc typed as a slice of structs" {
626 const source =
627 \\---
628 \\a: 0
629 \\---
630 \\a: 1
631 \\...
632 ;
633
634 var yaml = try Yaml.load(testing.allocator, source);
635 defer yaml.deinit();
636
637 {
638 const result = try yaml.parse([2]struct { a: usize });
639 try testing.expectEqual(result.len, 2);
640 try testing.expectEqual(result[0].a, 0);
641 try testing.expectEqual(result[1].a, 1);
642 }
643
644 {
645 const result = try yaml.parse([]struct { a: usize });
646 try testing.expectEqual(result.len, 2);
647 try testing.expectEqual(result[0].a, 0);
648 try testing.expectEqual(result[1].a, 1);
476 pub fn stringify(self: Yaml, writer: anytype) !void {
477 for (self.docs.items, 0..) |doc, i| {
478 try writer.writeAll("---");
479 if (self.tree.?.getDirective(i)) |directive| {
480 try writer.print(" !{s}", .{directive});
481 }
482 try writer.writeByte('\n');
483 try doc.stringify(writer, .{});
484 try writer.writeByte('\n');
485 }
486 try writer.writeAll("...\n");
649487 }
650}
651
652test "multidoc typed as a struct is an error" {
653 const source =
654 \\---
655 \\a: 0
656 \\---
657 \\b: 1
658 \\...
659 ;
660
661 var yaml = try Yaml.load(testing.allocator, source);
662 defer yaml.deinit();
663
664 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize }));
665 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { b: usize }));
666 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize, b: usize }));
667}
668
669test "multidoc typed as a slice of structs with optionals" {
670 const source =
671 \\---
672 \\a: 0
673 \\c: 1.0
674 \\---
675 \\a: 1
676 \\b: different field
677 \\...
678 ;
679
680 var yaml = try Yaml.load(testing.allocator, source);
681 defer yaml.deinit();
682
683 const result = try yaml.parse([]struct { a: usize, b: ?[]const u8, c: ?f16 });
684 try testing.expectEqual(result.len, 2);
685
686 try testing.expectEqual(result[0].a, 0);
687 try testing.expect(result[0].b == null);
688 try testing.expect(result[0].c != null);
689 try testing.expectEqual(result[0].c.?, 1.0);
690
691 try testing.expectEqual(result[1].a, 1);
692 try testing.expect(result[1].b != null);
693 try testing.expect(mem.eql(u8, result[1].b.?, "different field"));
694 try testing.expect(result[1].c == null);
695}
696
697test "empty yaml can be represented as void" {
698 const source = "";
699 var yaml = try Yaml.load(testing.allocator, source);
700 defer yaml.deinit();
701 const result = try yaml.parse(void);
702 try testing.expect(@TypeOf(result) == void);
703}
488};
704489
705test "nonempty yaml cannot be represented as void" {
706 const source =
707 \\a: b
708 ;
490pub fn stringify(allocator: Allocator, input: anytype, writer: anytype) !void {
491 var arena = ArenaAllocator.init(allocator);
492 defer arena.deinit();
709493
710 var yaml = try Yaml.load(testing.allocator, source);
711 defer yaml.deinit();
494 var maybe_value = try Value.encode(arena.allocator(), input);
712495
713 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(void));
496 if (maybe_value) |value| {
497 // TODO should we output as an explicit doc?
498 // How can allow the user to specify?
499 try value.stringify(writer, .{});
500 }
714501}
715502
716test "typed array size mismatch" {
717 const source =
718 \\- 0
719 \\- 0
720 ;
721
722 var yaml = try Yaml.load(testing.allocator, source);
723 defer yaml.deinit();
724
725 try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([1]usize));
726 try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([5]usize));
503test {
504 std.testing.refAllDecls(Tokenizer);
505 std.testing.refAllDecls(parse);
506 _ = @import("yaml/test.zig");
727507}
src/link/tapi/yaml/test.zig created+475
......@@ -0,0 +1,475 @@
1const std = @import("std");
2const mem = std.mem;
3const testing = std.testing;
4
5const yaml_mod = @import("../yaml.zig");
6const Yaml = yaml_mod.Yaml;
7
8test "simple list" {
9 const source =
10 \\- a
11 \\- b
12 \\- c
13 ;
14
15 var yaml = try Yaml.load(testing.allocator, source);
16 defer yaml.deinit();
17
18 try testing.expectEqual(yaml.docs.items.len, 1);
19
20 const list = yaml.docs.items[0].list;
21 try testing.expectEqual(list.len, 3);
22
23 try testing.expectEqualStrings("a", list[0].string);
24 try testing.expectEqualStrings("b", list[1].string);
25 try testing.expectEqualStrings("c", list[2].string);
26}
27
28test "simple list typed as array of strings" {
29 const source =
30 \\- a
31 \\- b
32 \\- c
33 ;
34
35 var yaml = try Yaml.load(testing.allocator, source);
36 defer yaml.deinit();
37
38 try testing.expectEqual(yaml.docs.items.len, 1);
39
40 const arr = try yaml.parse([3][]const u8);
41 try testing.expectEqual(3, arr.len);
42 try testing.expectEqualStrings("a", arr[0]);
43 try testing.expectEqualStrings("b", arr[1]);
44 try testing.expectEqualStrings("c", arr[2]);
45}
46
47test "simple list typed as array of ints" {
48 const source =
49 \\- 0
50 \\- 1
51 \\- 2
52 ;
53
54 var yaml = try Yaml.load(testing.allocator, source);
55 defer yaml.deinit();
56
57 try testing.expectEqual(yaml.docs.items.len, 1);
58
59 const arr = try yaml.parse([3]u8);
60 try testing.expectEqualSlices(u8, &[_]u8{ 0, 1, 2 }, &arr);
61}
62
63test "list of mixed sign integer" {
64 const source =
65 \\- 0
66 \\- -1
67 \\- 2
68 ;
69
70 var yaml = try Yaml.load(testing.allocator, source);
71 defer yaml.deinit();
72
73 try testing.expectEqual(yaml.docs.items.len, 1);
74
75 const arr = try yaml.parse([3]i8);
76 try testing.expectEqualSlices(i8, &[_]i8{ 0, -1, 2 }, &arr);
77}
78
79test "simple map untyped" {
80 const source =
81 \\a: 0
82 ;
83
84 var yaml = try Yaml.load(testing.allocator, source);
85 defer yaml.deinit();
86
87 try testing.expectEqual(yaml.docs.items.len, 1);
88
89 const map = yaml.docs.items[0].map;
90 try testing.expect(map.contains("a"));
91 try testing.expectEqual(@as(i64, 0), map.get("a").?.int);
92}
93
94test "simple map untyped with a list of maps" {
95 const source =
96 \\a: 0
97 \\b:
98 \\ - foo: 1
99 \\ bar: 2
100 \\ - foo: 3
101 \\ bar: 4
102 \\c: 1
103 ;
104
105 var yaml = try Yaml.load(testing.allocator, source);
106 defer yaml.deinit();
107
108 try testing.expectEqual(yaml.docs.items.len, 1);
109
110 const map = yaml.docs.items[0].map;
111 try testing.expect(map.contains("a"));
112 try testing.expect(map.contains("b"));
113 try testing.expect(map.contains("c"));
114 try testing.expectEqual(@as(i64, 0), map.get("a").?.int);
115 try testing.expectEqual(@as(i64, 1), map.get("c").?.int);
116 try testing.expectEqual(@as(i64, 1), map.get("b").?.list[0].map.get("foo").?.int);
117 try testing.expectEqual(@as(i64, 2), map.get("b").?.list[0].map.get("bar").?.int);
118 try testing.expectEqual(@as(i64, 3), map.get("b").?.list[1].map.get("foo").?.int);
119 try testing.expectEqual(@as(i64, 4), map.get("b").?.list[1].map.get("bar").?.int);
120}
121
122test "simple map untyped with a list of maps. no indent" {
123 const source =
124 \\b:
125 \\- foo: 1
126 \\c: 1
127 ;
128
129 var yaml = try Yaml.load(testing.allocator, source);
130 defer yaml.deinit();
131
132 try testing.expectEqual(yaml.docs.items.len, 1);
133
134 const map = yaml.docs.items[0].map;
135 try testing.expect(map.contains("b"));
136 try testing.expect(map.contains("c"));
137 try testing.expectEqual(@as(i64, 1), map.get("c").?.int);
138 try testing.expectEqual(@as(i64, 1), map.get("b").?.list[0].map.get("foo").?.int);
139}
140
141test "simple map untyped with a list of maps. no indent 2" {
142 const source =
143 \\a: 0
144 \\b:
145 \\- foo: 1
146 \\ bar: 2
147 \\- foo: 3
148 \\ bar: 4
149 \\c: 1
150 ;
151
152 var yaml = try Yaml.load(testing.allocator, source);
153 defer yaml.deinit();
154
155 try testing.expectEqual(yaml.docs.items.len, 1);
156
157 const map = yaml.docs.items[0].map;
158 try testing.expect(map.contains("a"));
159 try testing.expect(map.contains("b"));
160 try testing.expect(map.contains("c"));
161 try testing.expectEqual(@as(i64, 0), map.get("a").?.int);
162 try testing.expectEqual(@as(i64, 1), map.get("c").?.int);
163 try testing.expectEqual(@as(i64, 1), map.get("b").?.list[0].map.get("foo").?.int);
164 try testing.expectEqual(@as(i64, 2), map.get("b").?.list[0].map.get("bar").?.int);
165 try testing.expectEqual(@as(i64, 3), map.get("b").?.list[1].map.get("foo").?.int);
166 try testing.expectEqual(@as(i64, 4), map.get("b").?.list[1].map.get("bar").?.int);
167}
168
169test "simple map typed" {
170 const source =
171 \\a: 0
172 \\b: hello there
173 \\c: 'wait, what?'
174 ;
175
176 var yaml = try Yaml.load(testing.allocator, source);
177 defer yaml.deinit();
178
179 const simple = try yaml.parse(struct { a: usize, b: []const u8, c: []const u8 });
180 try testing.expectEqual(@as(usize, 0), simple.a);
181 try testing.expectEqualStrings("hello there", simple.b);
182 try testing.expectEqualStrings("wait, what?", simple.c);
183}
184
185test "typed nested structs" {
186 const source =
187 \\a:
188 \\ b: hello there
189 \\ c: 'wait, what?'
190 ;
191
192 var yaml = try Yaml.load(testing.allocator, source);
193 defer yaml.deinit();
194
195 const simple = try yaml.parse(struct {
196 a: struct {
197 b: []const u8,
198 c: []const u8,
199 },
200 });
201 try testing.expectEqualStrings("hello there", simple.a.b);
202 try testing.expectEqualStrings("wait, what?", simple.a.c);
203}
204
205test "single quoted string" {
206 const source =
207 \\- 'hello'
208 \\- 'here''s an escaped quote'
209 \\- 'newlines and tabs\nare not\tsupported'
210 ;
211
212 var yaml = try Yaml.load(testing.allocator, source);
213 defer yaml.deinit();
214
215 const arr = try yaml.parse([3][]const u8);
216 try testing.expectEqual(arr.len, 3);
217 try testing.expectEqualStrings("hello", arr[0]);
218 try testing.expectEqualStrings("here's an escaped quote", arr[1]);
219 try testing.expectEqualStrings("newlines and tabs\\nare not\\tsupported", arr[2]);
220}
221
222test "double quoted string" {
223 const source =
224 \\- "hello"
225 \\- "\"here\" are some escaped quotes"
226 \\- "newlines and tabs\nare\tsupported"
227 \\- "let's have
228 \\some fun!"
229 ;
230
231 var yaml = try Yaml.load(testing.allocator, source);
232 defer yaml.deinit();
233
234 const arr = try yaml.parse([4][]const u8);
235 try testing.expectEqual(arr.len, 4);
236 try testing.expectEqualStrings("hello", arr[0]);
237 try testing.expectEqualStrings(
238 \\"here" are some escaped quotes
239 , arr[1]);
240 try testing.expectEqualStrings(
241 \\newlines and tabs
242 \\are supported
243 , arr[2]);
244 try testing.expectEqualStrings(
245 \\let's have
246 \\some fun!
247 , arr[3]);
248}
249
250test "multidoc typed as a slice of structs" {
251 const source =
252 \\---
253 \\a: 0
254 \\---
255 \\a: 1
256 \\...
257 ;
258
259 var yaml = try Yaml.load(testing.allocator, source);
260 defer yaml.deinit();
261
262 {
263 const result = try yaml.parse([2]struct { a: usize });
264 try testing.expectEqual(result.len, 2);
265 try testing.expectEqual(result[0].a, 0);
266 try testing.expectEqual(result[1].a, 1);
267 }
268
269 {
270 const result = try yaml.parse([]struct { a: usize });
271 try testing.expectEqual(result.len, 2);
272 try testing.expectEqual(result[0].a, 0);
273 try testing.expectEqual(result[1].a, 1);
274 }
275}
276
277test "multidoc typed as a struct is an error" {
278 const source =
279 \\---
280 \\a: 0
281 \\---
282 \\b: 1
283 \\...
284 ;
285
286 var yaml = try Yaml.load(testing.allocator, source);
287 defer yaml.deinit();
288
289 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize }));
290 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { b: usize }));
291 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize, b: usize }));
292}
293
294test "multidoc typed as a slice of structs with optionals" {
295 const source =
296 \\---
297 \\a: 0
298 \\c: 1.0
299 \\---
300 \\a: 1
301 \\b: different field
302 \\...
303 ;
304
305 var yaml = try Yaml.load(testing.allocator, source);
306 defer yaml.deinit();
307
308 const result = try yaml.parse([]struct { a: usize, b: ?[]const u8, c: ?f16 });
309 try testing.expectEqual(result.len, 2);
310
311 try testing.expectEqual(result[0].a, 0);
312 try testing.expect(result[0].b == null);
313 try testing.expect(result[0].c != null);
314 try testing.expectEqual(result[0].c.?, 1.0);
315
316 try testing.expectEqual(result[1].a, 1);
317 try testing.expect(result[1].b != null);
318 try testing.expectEqualStrings("different field", result[1].b.?);
319 try testing.expect(result[1].c == null);
320}
321
322test "empty yaml can be represented as void" {
323 const source = "";
324 var yaml = try Yaml.load(testing.allocator, source);
325 defer yaml.deinit();
326 const result = try yaml.parse(void);
327 try testing.expect(@TypeOf(result) == void);
328}
329
330test "nonempty yaml cannot be represented as void" {
331 const source =
332 \\a: b
333 ;
334
335 var yaml = try Yaml.load(testing.allocator, source);
336 defer yaml.deinit();
337
338 try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(void));
339}
340
341test "typed array size mismatch" {
342 const source =
343 \\- 0
344 \\- 0
345 ;
346
347 var yaml = try Yaml.load(testing.allocator, source);
348 defer yaml.deinit();
349
350 try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([1]usize));
351 try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([5]usize));
352}
353
354test "comments" {
355 const source =
356 \\
357 \\key: # this is the key
358 \\# first value
359 \\
360 \\- val1
361 \\
362 \\# second value
363 \\- val2
364 ;
365
366 var yaml = try Yaml.load(testing.allocator, source);
367 defer yaml.deinit();
368
369 const simple = try yaml.parse(struct {
370 key: []const []const u8,
371 });
372 try testing.expect(simple.key.len == 2);
373 try testing.expectEqualStrings("val1", simple.key[0]);
374 try testing.expectEqualStrings("val2", simple.key[1]);
375}
376
377test "promote ints to floats in a list mixed numeric types" {
378 const source =
379 \\a_list: [0, 1.0]
380 ;
381
382 var yaml = try Yaml.load(testing.allocator, source);
383 defer yaml.deinit();
384
385 const simple = try yaml.parse(struct {
386 a_list: []const f64,
387 });
388 try testing.expectEqualSlices(f64, &[_]f64{ 0.0, 1.0 }, simple.a_list);
389}
390
391test "demoting floats to ints in a list is an error" {
392 const source =
393 \\a_list: [0, 1.0]
394 ;
395
396 var yaml = try Yaml.load(testing.allocator, source);
397 defer yaml.deinit();
398
399 try testing.expectError(error.TypeMismatch, yaml.parse(struct {
400 a_list: []const u64,
401 }));
402}
403
404test "duplicate map keys" {
405 const source =
406 \\a: b
407 \\a: c
408 ;
409 try testing.expectError(error.DuplicateMapKey, Yaml.load(testing.allocator, source));
410}
411
412fn testStringify(expected: []const u8, input: anytype) !void {
413 var output = std.ArrayList(u8).init(testing.allocator);
414 defer output.deinit();
415
416 try yaml_mod.stringify(testing.allocator, input, output.writer());
417 try testing.expectEqualStrings(expected, output.items);
418}
419
420test "stringify an int" {
421 try testStringify("128", @as(u32, 128));
422}
423
424test "stringify a simple struct" {
425 try testStringify(
426 \\a: 1
427 \\b: 2
428 \\c: 2.5
429 , struct { a: i64, b: f64, c: f64 }{ .a = 1, .b = 2.0, .c = 2.5 });
430}
431
432test "stringify a struct with an optional" {
433 try testStringify(
434 \\a: 1
435 \\b: 2
436 \\c: 2.5
437 , struct { a: i64, b: ?f64, c: f64 }{ .a = 1, .b = 2.0, .c = 2.5 });
438
439 try testStringify(
440 \\a: 1
441 \\c: 2.5
442 , struct { a: i64, b: ?f64, c: f64 }{ .a = 1, .b = null, .c = 2.5 });
443}
444
445test "stringify a struct with all optionals" {
446 try testStringify("", struct { a: ?i64, b: ?f64 }{ .a = null, .b = null });
447}
448
449test "stringify an optional" {
450 try testStringify("", null);
451 try testStringify("", @as(?u64, null));
452}
453
454test "stringify a union" {
455 const Dummy = union(enum) {
456 x: u64,
457 y: f64,
458 };
459 try testStringify("a: 1", struct { a: Dummy }{ .a = .{ .x = 1 } });
460 try testStringify("a: 2.1", struct { a: Dummy }{ .a = .{ .y = 2.1 } });
461}
462
463test "stringify a string" {
464 try testStringify("a: name", struct { a: []const u8 }{ .a = "name" });
465 try testStringify("name", "name");
466}
467
468test "stringify a list" {
469 try testStringify("[ 1, 2, 3 ]", @as([]const u64, &.{ 1, 2, 3 }));
470 try testStringify("[ 1, 2, 3 ]", .{ @as(i64, 1), 2, 3 });
471 try testStringify("[ 1, name, 3 ]", .{ 1, "name", 3 });
472
473 const arr: [3]i64 = .{ 1, 2, 3 };
474 try testStringify("[ 1, 2, 3 ]", arr);
475}