Skip to content

Conversation

@ianks
Copy link
Collaborator

@ianks ianks commented Dec 14, 2025

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

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
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.

2 participants