diff options
author | Jean Boussier <[email protected]> | 2025-05-27 13:16:50 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-05-27 15:34:02 +0200 |
commit | a80a5000ab9ac08b9b74cfee559bba5c349b1808 (patch) | |
tree | 793b133e7272d2ba55a2e6254aec239cc1ed3ae2 /shape.h | |
parent | 97f44ac54e197bca43b54dd65e116cb9ea22cda0 (diff) |
Refactor `rb_obj_shape` out.
It still exists but only in `shape.c`.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13450
Diffstat (limited to 'shape.h')
-rw-r--r-- | shape.h | 38 |
1 files changed, 31 insertions, 7 deletions
@@ -143,12 +143,6 @@ shape_id_t rb_shape_rebuild(shape_id_t initial_shape_id, shape_id_t dest_shape_i void rb_shape_copy_fields(VALUE dest, VALUE *dest_buf, shape_id_t dest_shape_id, VALUE src, VALUE *src_buf, shape_id_t src_shape_id); void rb_shape_copy_complex_ivars(VALUE dest, VALUE obj, shape_id_t src_shape_id, st_table *fields_table); -static inline rb_shape_t * -rb_obj_shape(VALUE obj) -{ - return RSHAPE(rb_obj_shape_id(obj)); -} - static inline bool rb_shape_id_canonical_p(shape_id_t shape_id) { @@ -161,6 +155,36 @@ rb_shape_root(size_t heap_id) return (shape_id_t)(heap_id + FIRST_T_OBJECT_SHAPE_ID); } +static inline bool +RSHAPE_TYPE_P(shape_id_t shape_id, enum shape_type type) +{ + return RSHAPE(shape_id)->type == type; +} + +static inline attr_index_t +RSHAPE_CAPACITY(shape_id_t shape_id) +{ + return RSHAPE(shape_id)->capacity; +} + +static inline attr_index_t +RSHAPE_LEN(shape_id_t shape_id) +{ + return RSHAPE(shape_id)->next_field_index; +} + +static inline attr_index_t +RSHAPE_INDEX(shape_id_t shape_id) +{ + return RSHAPE_LEN(shape_id) - 1; +} + +static inline ID +RSHAPE_EDGE_NAME(shape_id_t shape_id) +{ + return RSHAPE(shape_id)->edge_name; +} + static inline uint32_t ROBJECT_FIELDS_CAPACITY(VALUE obj) { @@ -213,7 +237,7 @@ bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id); static inline bool rb_shape_obj_has_id(VALUE obj) { - return rb_shape_has_object_id(rb_obj_shape(obj)); + return rb_shape_id_has_object_id(RBASIC_SHAPE_ID(obj)); } // For ext/objspace |