Skip to content

feat(stable-api): add accessor methods (RSTRING_END, RDATA_PTR, RB_OBJ_FREEZE, RB_OBJ_PROMOTED)#679

Merged
ianks merged 1 commit into
mainfrom
feat/stable-api-accessors
Apr 20, 2026
Merged

feat(stable-api): add accessor methods (RSTRING_END, RDATA_PTR, RB_OBJ_FREEZE, RB_OBJ_PROMOTED)#679
ianks merged 1 commit into
mainfrom
feat/stable-api-accessors

Conversation

@ianks

@ianks ianks commented Dec 14, 2025

Copy link
Copy Markdown
Collaborator

Summary

Batch 5 of the stable API implementation plan - Adds simple accessor methods to the Stable API:

  • RSTRING_END - Get pointer to end of string contents
  • RDATA_PTR - Get data pointer from RData object
  • RB_OBJ_FREEZE - Freeze an object
  • RB_OBJ_PROMOTED - Check if object is promoted to old GC generation

⚠️ Draft Status: Ready for review but marking as draft to coordinate with other batches.

Changes

  • stable_api.rs: Added rstring_end(), rdata_ptr(), rb_obj_freeze(), rb_obj_promoted(), and rb_obj_promoted_raw() methods
  • Implementations: Version-specific implementations for all 7 Ruby versions (2.7, 3.0-3.4, 4.0)
    • RSTRING_END: Composed from rstring_ptr + rstring_len
    • RDATA_PTR: Direct access to RData.data field
    • RB_OBJ_FREEZE: Calls rb_obj_freeze_inline()
    • RB_OBJ_PROMOTED: Checks RUBY_FL_PROMOTED flag
  • Fallback support: C fallback in compiled.c and Rust wrapper in compiled.rs
  • Public API: Macro wrappers in macros.rs with comprehensive documentation
  • Tests: Parity tests in stable_api_test.rs

Testing

All tests pass successfully ✅

Related Issues

Checklist

  • Code follows project style guide
  • All tests pass
  • Documentation included
  • No breaking changes

@ianks ianks force-pushed the feat/stable-api-accessors branch from bc2d5eb to d314cb2 Compare April 20, 2026 04:20
@ianks ianks marked this pull request as ready for review April 20, 2026 04:20
Implements #670, #666, #672, #673

- Add rstring_end to StableApiDefinition for RSTRING_END
- Add rdata_ptr to StableApiDefinition for DATA_PTR
- Add rb_obj_freeze to StableApiDefinition for RB_OBJ_FREEZE
- Add rb_obj_promoted, rb_obj_promoted_raw for RB_OBJ_PROMOTED
- Implement for Ruby 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0
- Add C fallbacks in compiled.c
- Add FFI wrappers in compiled.rs
- Add public macro wrappers in macros.rs
- Add comprehensive parity tests
@ianks ianks force-pushed the feat/stable-api-accessors branch from d314cb2 to 7d434f5 Compare April 20, 2026 04:28
@ianks ianks merged commit b4c7835 into main Apr 20, 2026
61 checks passed
@ianks ianks deleted the feat/stable-api-accessors branch April 20, 2026 04:43
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