Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
rstruct.h
Go to the documentation of this file.
1#ifndef RBIMPL_RSTRUCT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RSTRUCT_H
25#include "ruby/internal/value.h"
29#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
30# include "ruby/backward.h"
31#endif
32
33#define RSTRUCT_PTR(st) rb_struct_ptr(st)
35#define RSTRUCT_LEN RSTRUCT_LEN
36#define RSTRUCT_SET RSTRUCT_SET
37#define RSTRUCT_GET RSTRUCT_GET
45
47static inline long
49{
50 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
51
52 return RB_NUM2LONG(rb_struct_size(st));
53}
54
56static inline VALUE
57RSTRUCT_SET(VALUE st, int k, VALUE v)
58{
59 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
60
61 return rb_struct_aset(st, INT2NUM(k), (v));
62}
63
65static inline VALUE
66RSTRUCT_GET(VALUE st, int k)
67{
68 RBIMPL_ASSERT_TYPE(st, RUBY_T_STRUCT);
69
70 return rb_struct_aref(st, INT2NUM(k));
71}
72
73#endif /* RBIMPL_RSTRUCT_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:43
Tewaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
Arithmetic conversion between C's int and Ruby's.
#define INT2NUM
Definition: int.h:43
#define RSTRUCT_GET
Definition: struct.h:54
#define RSTRUCT_LEN
Definition: struct.h:52
#define RSTRUCT_SET
Definition: struct.h:53
Arithmetic conversion between C's long and Ruby's.
#define RB_NUM2LONG
Definition: long.h:57
VALUE rb_struct_size(VALUE s)
Definition: struct.c:1326
VALUE rb_struct_aref(VALUE, VALUE)
Definition: struct.c:1096
VALUE rb_struct_aset(VALUE, VALUE, VALUE)
Definition: struct.c:1123
Defines VALUE and ID.
unsigned long VALUE
Definition: value.h:38
Defines enum ruby_value_type.
@ RUBY_T_STRUCT
Definition: value_type.h:121