Repository navigation
Commit 8a510ae
Advance Marshal conformance: Data dump/load and Regexp encoding (#524)
* Marshal: dump and load Data as an 'S' struct container
Data.define instances (Ruby 3.2+ immutable value objects) store their
members in RObject.structVals the same way a Struct does, and MRI marshals
them with the same 'S' container. Emit that on dump and accept it on load
via memberDefNames, reconstructing a frozen Data instance.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Marshal: encode a Regexp's encoding and FIXED/NONE option bits
MRI records a Regexp's encoding the same way it records a String's: bare
(no encoding ivar) for a binary source, an :E => true/false marker for
UTF-8/US-ASCII, and a named :encoding ivar otherwise. The option byte carries
the FIXEDENCODING (0x10) and NOENCODING (0x20) bits, and an ASCII-incompatible
source (UTF-16/UTF-32) is fixed even when its bytes are ASCII-only.
Compute the encoding from the compiled Regexp (via encodingName plus the fixed
source encoding), pick the option byte to match, and restore both on load so a
Regexp round-trips byte-for-byte. A non-ASCII source stays content-fixed (its
fixedEnc field left false) so a loaded /café/ still equals the literal.
Fixes the four encoding examples in core/marshal/dump_spec (binary,
ascii-compatible, UTF-8, another-encoding); the remaining Regexp residuals
need the object model to carry a Regexp subclass identity and ivars.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 5940453 commit 8a510ae
2 files changed
Lines changed: 202 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
256 | 298 | | |
257 | | - | |
258 | 299 | | |
259 | 300 | | |
260 | 301 | | |
| |||
265 | 306 | | |
266 | 307 | | |
267 | 308 | | |
268 | | - | |
269 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
270 | 323 | | |
271 | 324 | | |
272 | 325 | | |
273 | 326 | | |
274 | 327 | | |
275 | | - | |
276 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
277 | 331 | | |
278 | | - | |
| 332 | + | |
| 333 | + | |
279 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
280 | 338 | | |
281 | 339 | | |
282 | 340 | | |
| |||
386 | 444 | | |
387 | 445 | | |
388 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
389 | 461 | | |
390 | 462 | | |
391 | 463 | | |
| |||
792 | 864 | | |
793 | 865 | | |
794 | 866 | | |
795 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
796 | 881 | | |
797 | 882 | | |
798 | 883 | | |
| |||
899 | 984 | | |
900 | 985 | | |
901 | 986 | | |
902 | | - | |
903 | | - | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
904 | 993 | | |
905 | 994 | | |
906 | | - | |
| 995 | + | |
| 996 | + | |
907 | 997 | | |
908 | 998 | | |
909 | 999 | | |
910 | 1000 | | |
911 | 1001 | | |
912 | | - | |
| 1002 | + | |
913 | 1003 | | |
914 | 1004 | | |
915 | 1005 | | |
916 | 1006 | | |
917 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
918 | 1011 | | |
919 | 1012 | | |
920 | 1013 | | |
| |||
992 | 1085 | | |
993 | 1086 | | |
994 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
995 | 1096 | | |
996 | 1097 | | |
997 | 1098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments