Ruby 3.2.1p31 (2023-02-08 revision 31819e82c88c6f8ecfaeb162519bfa26a14b21fd)
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
45#define RSTRUCT_PTR(st) rb_struct_ptr(st)
47#define RSTRUCT_LEN RSTRUCT_LEN
48#define RSTRUCT_SET RSTRUCT_SET
49#define RSTRUCT_GET RSTRUCT_GET
61
74
90
93static inline long
94RSTRUCT_LEN(VALUE st)
95{
96 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
97
98 return RB_NUM2LONG(rb_struct_size(st));
99}
100
103static inline VALUE
104RSTRUCT_SET(VALUE st, int k, VALUE v)
105{
106 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
107
108 return rb_struct_aset(st, INT2NUM(k), (v));
109}
110
113static inline VALUE
114RSTRUCT_GET(VALUE st, int k)
115{
116 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
117
118 return rb_struct_aref(st, INT2NUM(k));
119}
120
121#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:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
#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
VALUE rb_struct_aset(VALUE st, VALUE k, VALUE v)
Resembles Struct#[]=.
Definition: struct.c:1292
VALUE rb_struct_size(VALUE st)
Returns the number of struct members.
Definition: struct.c:1545
VALUE rb_struct_aref(VALUE st, VALUE k)
Resembles Struct#[].
Definition: struct.c:1254
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:123