|
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)
|
Defines enum ruby_fl_type. More...
#include "ruby/internal/config.h"#include "ruby/internal/attr/artificial.h"#include "ruby/internal/attr/deprecated.h"#include "ruby/internal/attr/flag_enum.h"#include "ruby/internal/attr/forceinline.h"#include "ruby/internal/attr/noalias.h"#include "ruby/internal/attr/pure.h"#include "ruby/internal/cast.h"#include "ruby/internal/compiler_since.h"#include "ruby/internal/core/rbasic.h"#include "ruby/internal/dllexport.h"#include "ruby/internal/has/extension.h"#include "ruby/internal/special_consts.h"#include "ruby/internal/stdbool.h"#include "ruby/internal/value.h"#include "ruby/internal/value_type.h"#include "ruby/assert.h"#include "ruby/defines.h"Go to the source code of this file.
Enumerations | |
| enum | ruby_fl_ushift { RUBY_FL_USHIFT = 12 } |
| This is an enum because GDB wants it (rather than a macro). More... | |
| enum | ruby_fl_type { RUBY_FL_WB_PROTECTED = (1<<5) , RUBY_FL_PROMOTED = (1<<5) , RUBY_FL_USERPRIV0 = (1<<6) , RUBY_FL_FINALIZE = (1<<7) , RUBY_FL_TAINT = 0 , RUBY_FL_EXIVAR = 0 , RUBY_FL_SHAREABLE = (1<<8) , RUBY_FL_UNTRUSTED = 0 , RUBY_FL_UNUSED9 = (1<<9) , RUBY_FL_UNUSED10 = (1<<10) , RUBY_FL_FREEZE = (1<<11) , RUBY_FL_USER0 = (1<<(RUBY_FL_USHIFT+0)) , RUBY_FL_USER1 = (1<<(RUBY_FL_USHIFT+1)) , RUBY_FL_USER2 = (1<<(RUBY_FL_USHIFT+2)) , RUBY_FL_USER3 = (1<<(RUBY_FL_USHIFT+3)) , RUBY_FL_USER4 = (1<<(RUBY_FL_USHIFT+4)) , RUBY_FL_USER5 = (1<<(RUBY_FL_USHIFT+5)) , RUBY_FL_USER6 = (1<<(RUBY_FL_USHIFT+6)) , RUBY_FL_USER7 = (1<<(RUBY_FL_USHIFT+7)) , RUBY_FL_USER8 = (1<<(RUBY_FL_USHIFT+8)) , RUBY_FL_USER9 = (1<<(RUBY_FL_USHIFT+9)) , RUBY_FL_USER10 = (1<<(RUBY_FL_USHIFT+10)) , RUBY_FL_USER11 = (1<<(RUBY_FL_USHIFT+11)) , RUBY_FL_USER12 = (1<<(RUBY_FL_USHIFT+12)) , RUBY_FL_USER13 = (1<<(RUBY_FL_USHIFT+13)) , RUBY_FL_USER14 = (1<<(RUBY_FL_USHIFT+14)) , RUBY_FL_USER15 = (1<<(RUBY_FL_USHIFT+15)) , RUBY_FL_USER16 = (1<<(RUBY_FL_USHIFT+16)) , RUBY_FL_USER17 = (1<<(RUBY_FL_USHIFT+17)) , RUBY_FL_USER18 = (1<<(RUBY_FL_USHIFT+18)) , RUBY_FL_USER19 = (1<<(RUBY_FL_USHIFT+19)) , RUBY_ELTS_SHARED = RUBY_FL_USER0 , RUBY_FL_SINGLETON = RUBY_FL_USER1 } |
| The flags. More... | |
| enum | { RUBY_FL_DUPPED = (int)RUBY_T_MASK } |
Functions | |
| void | rb_freeze_singleton_class (VALUE klass) |
| This is an implementation detail of RB_OBJ_FREEZE(). | |
| static bool | RB_FL_ABLE (VALUE obj) |
| Checks if the object is flaggable. | |
| static VALUE | RB_FL_TEST_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_TEST(). | |
| static VALUE | RB_FL_TEST (VALUE obj, VALUE flags) |
| Tests if the given flag(s) are set or not. | |
| static bool | RB_FL_ANY_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_ANY(). | |
| static bool | RB_FL_ANY (VALUE obj, VALUE flags) |
| Identical to RB_FL_TEST(), except it returns bool. | |
| static bool | RB_FL_ALL_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_ALL(). | |
| static bool | RB_FL_ALL (VALUE obj, VALUE flags) |
| Identical to RB_FL_ANY(), except it mandates all passed flags be set. | |
| static void | RB_FL_SET_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_SET(). | |
| static void | RB_FL_SET (VALUE obj, VALUE flags) |
| Sets the given flag(s). | |
| static void | RB_FL_UNSET_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_UNSET(). | |
| static void | RB_FL_UNSET (VALUE obj, VALUE flags) |
| Clears the given flag(s). | |
| static void | RB_FL_REVERSE_RAW (VALUE obj, VALUE flags) |
| This is an implementation detail of RB_FL_REVERSE(). | |
| static void | RB_FL_REVERSE (VALUE obj, VALUE flags) |
| Reverses the flags. | |
| static bool | RB_OBJ_TAINTABLE (VALUE obj) |
| static VALUE | RB_OBJ_TAINTED_RAW (VALUE obj) |
| static bool | RB_OBJ_TAINTED (VALUE obj) |
| static void | RB_OBJ_TAINT_RAW (VALUE obj) |
| static void | RB_OBJ_TAINT (VALUE obj) |
| static void | RB_OBJ_INFECT_RAW (VALUE dst, VALUE src) |
| static void | RB_OBJ_INFECT (VALUE dst, VALUE src) |
| static VALUE | RB_OBJ_FROZEN_RAW (VALUE obj) |
| This is an implementation detail of RB_OBJ_FROZEN(). | |
| static bool | RB_OBJ_FROZEN (VALUE obj) |
| Checks if an object is frozen. | |
| void | rb_obj_freeze_inline (VALUE obj) |
| Prevents further modifications to the given object. | |
| static void | RB_OBJ_FREEZE_RAW (VALUE obj) |
| This is an implementation detail of RB_OBJ_FREEZE(). | |
Defines enum ruby_fl_type.
Definition in file fl_type.h.
| #define RB_OBJ_FREEZE rb_obj_freeze_inline |
Just another name of rb_obj_freeze_inline.
| #define RBIMPL_FL_USER_N | ( | n | ) |
(@shyouhei doesn't know how to excude this macro from doxygen).
| anonymous enum |
| Enumerator | |
|---|---|
| RUBY_FL_DUPPED |
|
| enum ruby_fl_type |
The flags.
Each ruby objects have their own characteristics apart from their classes. For instance whether an object is frozen or not is not controlled by its class. This is the type that represents such properties.
| Enumerator | |
|---|---|
| RUBY_FL_WB_PROTECTED |
|
| RUBY_FL_PROMOTED | Ruby objects are "generational". There are young objects & old objects. Young objects are prone to die & monitored relatively extensively by the garbage collector. Old objects tend to live longer & are monitored less frequently. When an object survives a GC, its age is incremented. When age is equal to RVALUE_OLD_AGE, the object becomes Old. This flag is set when an object becomes old, and is used by the write barrier to check if an old object should be considered for marking more frequently - as old objects that have references added between major GCs need to be remarked to prevent the referred object being mistakenly swept. |
| RUBY_FL_USERPRIV0 | This flag meaning is type dependent, currently only used by T_DATA. |
| RUBY_FL_FINALIZE | This flag has something to do with finalisers. A ruby object can have its finaliser, which is another object that evaluates when the target object is about to die. This flag is used to denote that there is an attached finaliser. |
| RUBY_FL_TAINT |
|
| RUBY_FL_EXIVAR |
|
| RUBY_FL_SHAREABLE | This flag has something to do with Ractor. Multiple Ractors run without protecting each other. Sharing an object among Ractors are basically dangerous, disabled by default. This flag is used to bypass that restriction. Of course, you have to manually prevent race conditions then. This flag needs deep understanding of multithreaded programming. You would better not use it. |
| RUBY_FL_UNTRUSTED |
|
| RUBY_FL_UNUSED9 | This flag is no longer in use. |
| RUBY_FL_UNUSED10 | This flag is no longer in use. |
| RUBY_FL_FREEZE | This flag has something to do with data immutability. When this flag is set an object is considered "frozen". No modification are expected to happen beyond that point for the particular object. Immutability is basically considered to be a good property these days. Library authors are expected to obey. Test this bit before you touch a data structure.
|
| RUBY_FL_USER0 | User-defined flag. |
| RUBY_FL_USER1 | User-defined flag. |
| RUBY_FL_USER2 | User-defined flag. |
| RUBY_FL_USER3 | User-defined flag. |
| RUBY_FL_USER4 | User-defined flag. |
| RUBY_FL_USER5 | User-defined flag. |
| RUBY_FL_USER6 | User-defined flag. |
| RUBY_FL_USER7 | User-defined flag. |
| RUBY_FL_USER8 | User-defined flag. |
| RUBY_FL_USER9 | User-defined flag. |
| RUBY_FL_USER10 | User-defined flag. |
| RUBY_FL_USER11 | User-defined flag. |
| RUBY_FL_USER12 | User-defined flag. |
| RUBY_FL_USER13 | User-defined flag. |
| RUBY_FL_USER14 | User-defined flag. |
| RUBY_FL_USER15 | User-defined flag. |
| RUBY_FL_USER16 | User-defined flag. |
| RUBY_FL_USER17 | User-defined flag. |
| RUBY_FL_USER18 | User-defined flag. |
| RUBY_FL_USER19 | User-defined flag. |
| RUBY_ELTS_SHARED | This flag has something to do with data structures. Over time, ruby evolved to reduce memory footprints. One of such attempt is so-called copy-on-write, which delays duplication of resources until ultimately necessary. Some data structures share this scheme. For example multiple instances of struct RArray could point identical memory region in common, as long as they don't differ. As people favour immutable style of programming than before, this situation is getting more and more common. Because such "shared" memory regions have nuanced ownership by nature, each structures need special care for them. This flag is used to distinguish such shared constructs. |
| RUBY_FL_SINGLETON | This flag has something to do with an object's class. There are kind of classes called "singleton class", each of which have exactly one instance. What is interesting about singleton classes is that they are created after their instance were instantiated, like this: foo = Object.new # foo is an instance of Object...
bar = foo.singleton_class # foo is now an instance of bar.
Here as you see bar is a singleton class of foo, which is injected into foo's inheritance tree in a different statement (== distinct sequence point). In order to achieve this property singleton classes are special-cased in the interpreter. There is one bit flag that distinguishes if a class is a singleton class or not, and this is it. |
| enum ruby_fl_ushift |
This is an enum because GDB wants it (rather than a macro).
People need not bother.
| Enumerator | |
|---|---|
| RUBY_FL_USHIFT | Number of bits in ruby_fl_type that are not open to users. This is an implementation detail. Please ignore. |
|
static |
Checks if the object is flaggable.
There are some special cases (most notably RUBY_Qfalse) where appending a flag to an object is not possible. This function can detect that.
| [in] | obj | Object in question |
| true | It is flaggable. |
| false | No it isn't. |
Definition at line 440 of file fl_type.h.
Referenced by RB_FL_ABLE(), RB_FL_REVERSE(), RB_FL_REVERSE_RAW(), RB_FL_SET(), RB_FL_SET_RAW(), RB_FL_TEST(), RB_FL_TEST_RAW(), RB_FL_UNSET(), RB_FL_UNSET_RAW(), rb_obj_freeze_inline(), RB_OBJ_FROZEN(), RB_OBJ_PROMOTED(), and RB_OBJ_PROMOTED_RAW().
Identical to RB_FL_ANY(), except it mandates all passed flags be set.
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
| true | The object has all of the flags set. |
| false | The object lacks any of the flags. |
Definition at line 562 of file fl_type.h.
Referenced by RB_FL_ALL().
This is an implementation detail of RB_FL_ALL().
3rd parties need not use this. Just always use RB_FL_ALL().
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
| true | The object has all of the flags set. |
| false | The object lacks any of the flags. |
Definition at line 546 of file fl_type.h.
Referenced by RB_FL_ALL_RAW().
Identical to RB_FL_TEST(), except it returns bool.
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
| true | The object has any of the flags set. |
| false | No it doesn't at all. |
Definition at line 528 of file fl_type.h.
Referenced by RB_FL_ANY().
This is an implementation detail of RB_FL_ANY().
3rd parties need not use this. Just always use RB_FL_ANY().
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
| true | The object has any of the flags set. |
| false | No it doesn't at all. |
Definition at line 512 of file fl_type.h.
Referenced by RARRAY_EMBED_LEN(), rb_array_len(), RB_FL_ANY_RAW(), RB_OBJ_PROMOTED_RAW(), and ROBJECT_FIELDS().
Reverses the flags.
This function is here mainly for symmetry on set/unset. Rarely used in practice.
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 731 of file fl_type.h.
Referenced by RB_FL_REVERSE().
This is an implementation detail of RB_FL_REVERSE().
3rd parties need not use this. Just always use RB_FL_REVERSE().
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 715 of file fl_type.h.
Referenced by RB_FL_REVERSE(), and RB_FL_REVERSE_RAW().
Sets the given flag(s).
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 620 of file fl_type.h.
Referenced by RB_FL_SET().
This is an implementation detail of RB_FL_SET().
3rd parties need not use this. Just always use RB_FL_SET().
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 600 of file fl_type.h.
Referenced by RB_ENC_CODERANGE_SET(), RB_ENCODING_SET_INLINED(), RB_FL_SET(), RB_FL_SET_RAW(), and rb_obj_freeze_inline().
Tests if the given flag(s) are set or not.
You can pass multiple flags at once:
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 489 of file fl_type.h.
Referenced by RB_FL_ALL(), RB_FL_ANY(), and RB_FL_TEST().
This is an implementation detail of RB_FL_TEST().
3rd parties need not use this. Just always use RB_FL_TEST().
| [in] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 463 of file fl_type.h.
Referenced by RB_ENC_CODERANGE(), RB_ENCODING_GET_INLINED(), RB_FL_ALL_RAW(), RB_FL_ANY_RAW(), RB_FL_TEST(), RB_FL_TEST_RAW(), RB_OBJ_FROZEN_RAW(), rb_str_new_frozen(), RSTRING_END(), and RSTRING_PTR().
Clears the given flag(s).
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 675 of file fl_type.h.
Referenced by RB_FL_UNSET().
This is an implementation detail of RB_FL_UNSET().
3rd parties need not use this. Just always use RB_FL_UNSET().
| [out] | obj | Object in question. |
| [in] | flags | A set of enum ruby_fl_type. |
Definition at line 660 of file fl_type.h.
Referenced by RB_ENC_CODERANGE_CLEAR(), RB_ENC_CODERANGE_SET(), RB_ENCODING_SET_INLINED(), RB_FL_UNSET(), RB_FL_UNSET_RAW(), and rb_obj_freeze_inline().
| void rb_obj_freeze_inline | ( | VALUE | obj | ) |
Prevents further modifications to the given object.
rb_eFrozenError shall be raised if modification is attempted.
| [out] | x | Object in question. |
| rb_eNoMemError | Failed to allocate memory for the frozen representation of the object. |
Definition at line 1991 of file variable.c.
Referenced by RB_OBJ_FREEZE_RAW().
|
inlinestatic |
This is an implementation detail of RB_OBJ_FREEZE().
3rd parties need not use this. Just always use RB_OBJ_FREEZE().
| [out] | obj | Object in question. |
Definition at line 922 of file fl_type.h.
Referenced by RB_OBJ_FREEZE_RAW().
|
inlinestatic |
Checks if an object is frozen.
| [in] | obj | Object in question. |
| true | Yes it is. |
| false | No it isn't. |
Definition at line 892 of file fl_type.h.
Referenced by rb_check_frozen_inline(), and RB_OBJ_FROZEN().
This is an implementation detail of RB_OBJ_FROZEN().
3rd parties need not use this. Just always use RB_OBJ_FROZEN().
| [in] | obj | Object in question. |
| RUBY_FL_FREEZE | Yes it is. |
| 0 | No it isn't. |
Definition at line 877 of file fl_type.h.
Referenced by RB_OBJ_FROZEN(), and RB_OBJ_FROZEN_RAW().
| [in] | dst | Victim object. |
| [in] | src | Infectant object. |
Definition at line 853 of file fl_type.h.
Referenced by RB_OBJ_INFECT().
| [in] | dst | Victim object. |
| [in] | src | Infectant object. |
Definition at line 835 of file fl_type.h.
Referenced by RB_OBJ_INFECT_RAW().
|
inlinestatic |
| [in] | obj | Object in question. |
Definition at line 818 of file fl_type.h.
Referenced by RB_OBJ_TAINT().
|
inlinestatic |
| [in] | obj | Object in question. |
Definition at line 802 of file fl_type.h.
Referenced by RB_OBJ_TAINT_RAW().
|
inlinestatic |
| [in] | obj | Object in question. |
Definition at line 750 of file fl_type.h.
Referenced by RB_OBJ_TAINTABLE().
|
inlinestatic |
| [in] | obj | Object in question. |
Definition at line 786 of file fl_type.h.
Referenced by RB_OBJ_TAINTED().
| [in] | obj | Object in question. |
Definition at line 768 of file fl_type.h.
Referenced by RB_OBJ_TAINTED_RAW().