Ruby 3.2.1p31 (2023-02-08 revision 31819e82c88c6f8ecfaeb162519bfa26a14b21fd)
rbasic.h
Go to the documentation of this file.
1#ifndef RBIMPL_RBASIC_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RBASIC_H
28#include "ruby/internal/cast.h"
31#include "ruby/internal/value.h"
32#include "ruby/assert.h"
33
40#define RBASIC(obj) RBIMPL_CAST((struct RBasic *)(obj))
42#define RBASIC_CLASS RBASIC_CLASS
43#define RBIMPL_RVALUE_EMBED_LEN_MAX 3
44#define RVALUE_EMBED_LEN_MAX RVALUE_EMBED_LEN_MAX
45#define RBIMPL_EMBED_LEN_MAX_OF(T) \
46 RBIMPL_CAST((int)(sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]) / (sizeof(T))))
55 RVALUE_EMBED_LEN_MAX = RBIMPL_RVALUE_EMBED_LEN_MAX
56};
57
62struct
64RBasic {
65
78
88 const VALUE klass;
89
90#ifdef __cplusplus
91 public:
103 flags(RBIMPL_VALUE_NULL),
104 klass(RBIMPL_VALUE_NULL)
105 {
106 }
107#endif
108};
109
126
140VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
142
151static inline VALUE
152RBASIC_CLASS(VALUE obj)
153{
154 RBIMPL_ASSERT_OR_ASSUME(! RB_SPECIAL_CONST_P(obj));
155 return RBASIC(obj)->klass;
156}
157
158#endif /* RBIMPL_RBASIC_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:43
#define RBIMPL_ASSERT_OR_ASSUME(expr)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Definition: assert.h:229
#define RUBY_ALIGNAS
Wraps (or simulates) alignas.
Definition: stdalign.h:27
RBIMPL_ATTR_CONSTEXPR.
#define RBIMPL_ATTR_CONSTEXPR(_)
Wraps (or simulates) C++11 constexpr.
Definition: constexpr.h:74
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
Defines RBIMPL_ATTR_FORCEINLINE.
#define RBIMPL_ATTR_FORCEINLINE()
Wraps (or simulates) __forceinline.
Definition: forceinline.h:37
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
Make a hidden object visible again.
Definition: object.c:93
VALUE rb_obj_hide(VALUE obj)
Make the object invisible from Ruby code.
Definition: object.c:84
Defines RBIMPL_ATTR_NOALIAS.
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition: noalias.h:66
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition: pure.h:38
#define RBASIC(obj)
Convenient casting macro.
Definition: rbasic.h:40
ruby_rvalue_flags
This is an enum because GDB wants it (rather than a macro).
Definition: rbasic.h:53
@ RVALUE_EMBED_LEN_MAX
Max possible number of objects that can be embedded.
Definition: rbasic.h:55
Defines enum ruby_special_consts.
Ruby's object's, base components.
Definition: rbasic.h:64
const VALUE klass
Class of an object.
Definition: rbasic.h:88
VALUE flags
Per-object flags.
Definition: rbasic.h:77
Defines VALUE and ID.
#define RBIMPL_VALUE_NULL
A compile-time constant of type VALUE whose value is 0.
Definition: value.h:76
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40
#define SIZEOF_VALUE
Identical to sizeof(VALUE), except it is a macro that can also be used inside of preprocessor directi...
Definition: value.h:69