Ruby  3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
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 
61 struct
63 RBasic {
64 
76 
86  const VALUE klass;
87 
88 #ifdef __cplusplus
89  public:
100  RBasic() :
101  flags(RBIMPL_VALUE_NULL),
102  klass(RBIMPL_VALUE_NULL)
103  {
104  }
105 #endif
106 };
107 
123 VALUE rb_obj_hide(VALUE obj);
124 
138 VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
140 
149 static inline VALUE
151 {
153  return RBASIC(obj)->klass;
154 }
155 
156 #endif /* RBIMPL_RBASIC_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:41
#define RBIMPL_ASSERT_OR_ASSUME(...)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Definition: assert.h:311
#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:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
Defines RBIMPL_ATTR_FORCEINLINE.
#define RBIMPL_ATTR_FORCEINLINE()
Wraps (or simulates) __forceinline.
Definition: forceinline.h:35
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
Make a hidden object visible again.
Definition: object.c:113
VALUE rb_obj_hide(VALUE obj)
Make the object invisible from Ruby code.
Definition: object.c:104
Defines RBIMPL_ATTR_NOALIAS.
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition: noalias.h:62
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition: defines.h:88
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition: pure.h:38
static VALUE RBASIC_CLASS(VALUE obj)
Queries the class of an object.
Definition: rbasic.h:150
#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.
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
Ruby object's base components.
Definition: rbasic.h:63
const VALUE klass
Class of an object.
Definition: rbasic.h:86
VALUE flags
Per-object flags.
Definition: rbasic.h:75
Defines VALUE and ID.
#define RBIMPL_VALUE_NULL
A compile-time constant of type VALUE whose value is 0.
Definition: value.h:76
#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
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40