Skip to content

feat: Ruby 3.4 support — migrate to TypedData API#2

Merged
takaokouji merged 1 commit into
masterfrom
smalruby/ruby-3.4-support
Mar 29, 2026
Merged

feat: Ruby 3.4 support — migrate to TypedData API#2
takaokouji merged 1 commit into
masterfrom
smalruby/ruby-3.4-support

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

Migrate all Data_Wrap_Struct / Data_Get_Struct to TypedData_Wrap_Struct / TypedData_Get_Struct for Ruby 3.4 compatibility.

Ruby 3.4 deprecates the old Data_Wrap_Struct / Data_Get_Struct API in favor of TypedData. This PR eliminates all deprecation warnings (previously 90+) while maintaining backward compatibility with Ruby 3.3.x.

Changes

  • rubysdl2_internal.h: Add DEFINE_DATA_TYPE helper macro; update DEFINE_GETTER to use TypedData_Get_Struct
  • video.c.m4: Window, Renderer, Texture, Surface, DisplayMode, Rect, Point + FIELD_ACCESSOR macro
  • event.c: SDL_Event + EVENT_READER/EVENT_WRITER macros
  • mixer.c.m4: Chunk, Music
  • ttf.c.m4: TTF
  • joystick.c.m4: Joystick
  • gamecontroller.c.m4: GameController
  • gl.c.m4: GLContext

Testing

  • Builds with zero deprecation warnings on Ruby 3.4.9
  • Full SDL2 functionality verified (window creation, rendering, event handling)
  • Backward compatible with Ruby 3.3.9

Closes #1

Replace all deprecated Data_Wrap_Struct/Data_Get_Struct with
TypedData_Wrap_Struct/TypedData_Get_Struct across all source files.

Add DEFINE_DATA_TYPE helper macro to rubysdl2_internal.h for easy
rb_data_type_t definition. Eliminates all deprecation warnings on
Ruby 3.4.x while maintaining backward compatibility with Ruby 3.3.x.

Files changed:
- rubysdl2_internal.h: DEFINE_DATA_TYPE macro, DEFINE_GETTER uses TypedData
- video.c.m4: Window, Renderer, Texture, Surface, DisplayMode, Rect, Point
- event.c: SDL_Event (EVENT_READER/EVENT_WRITER macros + all event types)
- mixer.c.m4: Chunk, Music
- ttf.c.m4: TTF
- joystick.c.m4: Joystick
- gamecontroller.c.m4: GameController
- gl.c.m4: GLContext

Closes #1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit 63847aa into master Mar 29, 2026
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.

feat: Ruby 3.4 support — migrate from Data_Wrap_Struct to TypedData

1 participant