Skip to content

Support S4 objects - #55

Merged
shikokuchuo merged 3 commits into
mainfrom
s4
Aug 25, 2026
Merged

shikokuchuo merged 3 commits into
mainfrom
s4

Conversation

@shikokuchuo

Copy link
Copy Markdown
Member

Preserve the S4 object bit in the shared memory layouts

Before this change, share() silently dropped the S4 object bit. A shared S4 vector kept its class attribute, but isS4() returned FALSE, and S4 method dispatch did not work.

This change stores the bit in the layouts and restores it on open:

  • The MORH, MORS, and MORL headers have a new flags word at byte 32.
  • A MORL directory entry flags an S4 leaf in bit 30 of sexptype.
  • The open path sets the bit with Rf_asS4() after it restores the attributes. A read never consults a class definition.
  • The embedder layout oracle no longer rejects S4 objects.

Not changed: S4 objects without a data part and S4 pairlists are returned unchanged and stay unshared.

Slots are serialised with the attributes. A slot that holds a non-vector object, for example an environment, is restored as a copy.

@shikokuchuo
shikokuchuo merged commit be26632 into main Aug 25, 2026
30 of 31 checks passed
@shikokuchuo
shikokuchuo deleted the s4 branch August 25, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant