Ruby 4.1.0dev (2026-04-04 revision 3b6245536cf55da9e8bfcdb03c845fe9ef931d7f)
rstruct.h
Go to the documentation of this file.
1#ifndef RBIMPL_RSTRUCT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RSTRUCT_H
26#include "ruby/internal/value.h"
30#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
31# include "ruby/backward.h"
32#endif
33
35#define RSTRUCT_LEN RSTRUCT_LEN
36#define RSTRUCT_SET RSTRUCT_SET
37#define RSTRUCT_GET RSTRUCT_GET
49
62
78
81static inline long
83{
84 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
85
86 return RB_NUM2LONG(rb_struct_size(st));
87}
88
91static inline VALUE
92RSTRUCT_SET(VALUE st, int k, VALUE v)
93{
94 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
95
96 return rb_struct_aset(st, INT2NUM(k), (v));
97}
98
101static inline VALUE
103{
104 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
105
106 return rb_struct_aref(st, INT2NUM(k));
107}
108
109#endif /* RBIMPL_RSTRUCT_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition artificial.h:43
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
#define INT2NUM
Old name of RB_INT2NUM.
Definition int.h:43
Arithmetic conversion between C's int and Ruby's.
Arithmetic conversion between C's long and Ruby's.
#define RB_NUM2LONG
Just another name of rb_num2long_inline.
Definition long.h:57
static long RSTRUCT_LEN(VALUE st)
Returns the number of struct members.
Definition rstruct.h:82
static VALUE RSTRUCT_SET(VALUE st, int k, VALUE v)
Resembles Struct#[]=.
Definition rstruct.h:92
static VALUE RSTRUCT_GET(VALUE st, int k)
Resembles Struct#[].
Definition rstruct.h:102
VALUE rb_struct_aset(VALUE st, VALUE k, VALUE v)
Resembles Struct#[]=.
Definition struct.c:1298
VALUE rb_struct_size(VALUE st)
Returns the number of struct members.
Definition struct.c:1548
VALUE rb_struct_aref(VALUE st, VALUE k)
Resembles Struct#[].
Definition struct.c:1260
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
Defines enum ruby_value_type.
@ RUBY_T_STRUCT
Definition value_type.h:124