Ruby: include/ruby/internal/globals.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

globals.h
Go to the documentation of this file.
1#ifndef RBIMPL_GLOBALS_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_GLOBALS_H
23#include "ruby/internal/attr/pure.h"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/fl_type.h"
26#include "ruby/internal/special_consts.h"
27#include "ruby/internal/value.h"
28#include "ruby/internal/value_type.h"
29
45 RBIMPL_SYMBOL_EXPORT_BEGIN()
46
47
54#define RUBY_INTEGER_UNIFICATION 1
55
56 RUBY_EXTERN VALUE rb_mKernel;
57 RUBY_EXTERN VALUE rb_mComparable;
58 RUBY_EXTERN VALUE rb_mEnumerable;
59 RUBY_EXTERN VALUE rb_mErrno;
60 RUBY_EXTERN VALUE rb_mFileTest;
61 RUBY_EXTERN VALUE rb_mGC;
62 RUBY_EXTERN VALUE rb_mMath;
63 RUBY_EXTERN VALUE rb_mProcess;
64 RUBY_EXTERN VALUE rb_mWaitReadable;
65 RUBY_EXTERN VALUE rb_mWaitWritable;
67 RUBY_EXTERN VALUE rb_cBasicObject;
68 RUBY_EXTERN VALUE rb_cObject;
69 RUBY_EXTERN VALUE rb_cArray;
70 RUBY_EXTERN VALUE rb_cBinding;
71 RUBY_EXTERN VALUE rb_cClass;
72 RUBY_EXTERN VALUE rb_cDir;
73 RUBY_EXTERN VALUE rb_cEncoding;
74 RUBY_EXTERN VALUE rb_cEnumerator;
75 RUBY_EXTERN VALUE rb_cFalseClass;
76 RUBY_EXTERN VALUE rb_cFile;
77 RUBY_EXTERN VALUE rb_cComplex;
78 RUBY_EXTERN VALUE rb_cFloat;
79 RUBY_EXTERN VALUE rb_cHash;
80 RUBY_EXTERN VALUE rb_cIO;
81 RUBY_EXTERN VALUE rb_cInteger;
82 RUBY_EXTERN VALUE rb_cMatch;
83 RUBY_EXTERN VALUE rb_cMethod;
84 RUBY_EXTERN VALUE rb_cModule;
85 RUBY_EXTERN VALUE rb_cRefinement;
86 RUBY_EXTERN VALUE rb_cNameErrorMesg;
87 RUBY_EXTERN VALUE rb_cNilClass;
88 RUBY_EXTERN VALUE rb_cNumeric;
89 RUBY_EXTERN VALUE rb_cProc;
90 RUBY_EXTERN VALUE rb_cRandom;
91 RUBY_EXTERN VALUE rb_cRange;
92 RUBY_EXTERN VALUE rb_cRational;
93 RUBY_EXTERN VALUE rb_cRegexp;
94 RUBY_EXTERN VALUE rb_cStat;
95 RUBY_EXTERN VALUE rb_cString;
96 RUBY_EXTERN VALUE rb_cStruct;
97 RUBY_EXTERN VALUE rb_cSymbol;
98 RUBY_EXTERN VALUE rb_cThread;
99 RUBY_EXTERN VALUE rb_cTime;
100 RUBY_EXTERN VALUE rb_cTrueClass;
101 RUBY_EXTERN VALUE rb_cUnboundMethod;
109 RUBY_EXTERN VALUE rb_eException;
110 RUBY_EXTERN VALUE rb_eStandardError;
111 RUBY_EXTERN VALUE rb_eSystemExit;
112 RUBY_EXTERN VALUE rb_eInterrupt;
113 RUBY_EXTERN VALUE rb_eSignal;
114 RUBY_EXTERN VALUE rb_eFatal;
115 RUBY_EXTERN VALUE rb_eArgError;
116 RUBY_EXTERN VALUE rb_eEOFError;
117 RUBY_EXTERN VALUE rb_eIndexError;
118 RUBY_EXTERN VALUE rb_eStopIteration;
119 RUBY_EXTERN VALUE rb_eKeyError;
120 RUBY_EXTERN VALUE rb_eRangeError;
121 RUBY_EXTERN VALUE rb_eIOError;
122 RUBY_EXTERN VALUE rb_eRuntimeError;
123 RUBY_EXTERN VALUE rb_eFrozenError;
124 RUBY_EXTERN VALUE rb_eSecurityError;
125 RUBY_EXTERN VALUE rb_eSystemCallError;
126 RUBY_EXTERN VALUE rb_eThreadError;
127 RUBY_EXTERN VALUE rb_eTypeError;
128 RUBY_EXTERN VALUE rb_eZeroDivError;
129 RUBY_EXTERN VALUE rb_eNotImpError;
130 RUBY_EXTERN VALUE rb_eNoMemError;
131 RUBY_EXTERN VALUE rb_eNoMethodError;
132 RUBY_EXTERN VALUE rb_eFloatDomainError;
133 RUBY_EXTERN VALUE rb_eLocalJumpError;
134 RUBY_EXTERN VALUE rb_eSysStackError;
135 RUBY_EXTERN VALUE rb_eRegexpError;
136 RUBY_EXTERN VALUE rb_eEncodingError;
137 RUBY_EXTERN VALUE rb_eEncCompatError;
138 RUBY_EXTERN VALUE rb_eNoMatchingPatternError;
139 RUBY_EXTERN VALUE rb_eNoMatchingPatternKeyError;
141 RUBY_EXTERN VALUE rb_eScriptError;
142 RUBY_EXTERN VALUE rb_eNameError;
143 RUBY_EXTERN VALUE rb_eSyntaxError;
144 RUBY_EXTERN VALUE rb_eLoadError;
146 RUBY_EXTERN VALUE rb_eMathDomainError;
154 RUBY_EXTERN VALUE rb_stdin;
155 RUBY_EXTERN VALUE rb_stdout;
156 RUBY_EXTERN VALUE rb_stderr;
158 RBIMPL_ATTR_PURE()
171static inline VALUE
172rb_class_of(VALUE obj)
173{
174 if (! RB_SPECIAL_CONST_P(obj)) {
175 return RBASIC_CLASS(obj);
176 }
177 else if (obj == RUBY_Qfalse) {
178 return rb_cFalseClass;
179 }
180 else if (obj == RUBY_Qnil) {
181 return rb_cNilClass;
182 }
183 else if (obj == RUBY_Qtrue) {
184 return rb_cTrueClass;
185 }
186 else if (RB_FIXNUM_P(obj)) {
187 return rb_cInteger;
188 }
189 else if (RB_STATIC_SYM_P(obj)) {
190 return rb_cSymbol;
191 }
192 else if (RB_FLONUM_P(obj)) {
193 return rb_cFloat;
194 }
195
196#if !RUBY_DEBUG
197 RBIMPL_UNREACHABLE_RETURN(Qfalse);
198#else
199 RUBY_ASSERT_FAIL("unexpected type");
200#endif
201}
202
203#define CLASS_OF rb_class_of
205 RBIMPL_SYMBOL_EXPORT_END()
206
207
209#endif /* RBIMPL_GLOBALS_H */
RUBY_ASSERT_FAIL
#define RUBY_ASSERT_FAIL(mesg)
Prints the given message, and terminates the entire process abnormally.
Definition assert.h:150
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:47
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
fl_type.h
Defines enum ruby_fl_type.
Qfalse
#define Qfalse
Old name of RUBY_Qfalse.
Definition special_consts.h:59
rb_eLocalJumpError
VALUE rb_eLocalJumpError
LocalJumpError exception.
Definition eval.c:49
rb_eNotImpError
VALUE rb_eNotImpError
NotImplementedError exception.
Definition error.c:1101
rb_eScriptError
VALUE rb_eScriptError
ScriptError exception.
Definition error.c:1107
rb_eKeyError
VALUE rb_eKeyError
KeyError exception.
Definition error.c:1094
rb_eSystemExit
VALUE rb_eSystemExit
SystemExit exception.
Definition error.c:1084
rb_eZeroDivError
VALUE rb_eZeroDivError
ZeroDivisionError exception.
Definition numeric.c:194
rb_eIOError
VALUE rb_eIOError
IOError exception.
Definition io.c:182
rb_eStandardError
VALUE rb_eStandardError
StandardError exception.
Definition error.c:1088
rb_eRegexpError
VALUE rb_eRegexpError
RegexpError exception.
Definition re.c:32
rb_eFrozenError
VALUE rb_eFrozenError
FrozenError exception.
Definition error.c:1090
rb_eNoMemError
VALUE rb_eNoMemError
NoMemoryError exception.
Definition error.c:1102
rb_eRangeError
VALUE rb_eRangeError
RangeError exception.
Definition error.c:1095
rb_eLoadError
VALUE rb_eLoadError
LoadError exception.
Definition error.c:1109
rb_eTypeError
VALUE rb_eTypeError
TypeError exception.
Definition error.c:1091
rb_eEOFError
VALUE rb_eEOFError
EOFError exception.
Definition io.c:181
rb_eNoMatchingPatternError
VALUE rb_eNoMatchingPatternError
NoMatchingPatternError exception.
Definition error.c:1104
rb_eEncCompatError
VALUE rb_eEncCompatError
Encoding::CompatibilityError exception.
Definition error.c:1098
rb_eFatal
VALUE rb_eFatal
fatal exception.
Definition error.c:1087
rb_eInterrupt
VALUE rb_eInterrupt
Interrupt exception.
Definition error.c:1085
rb_eNameError
VALUE rb_eNameError
NameError exception.
Definition error.c:1096
rb_eNoMethodError
VALUE rb_eNoMethodError
NoMethodError exception.
Definition error.c:1099
rb_eRuntimeError
VALUE rb_eRuntimeError
RuntimeError exception.
Definition error.c:1089
rb_eStopIteration
VALUE rb_eStopIteration
StopIteration exception.
Definition enumerator.c:176
rb_eFloatDomainError
VALUE rb_eFloatDomainError
FloatDomainError exception.
Definition numeric.c:195
rb_eNoMatchingPatternKeyError
VALUE rb_eNoMatchingPatternKeyError
NoMatchingPatternKeyError exception.
Definition error.c:1105
rb_eArgError
VALUE rb_eArgError
ArgumentError exception.
Definition error.c:1092
rb_eException
VALUE rb_eException
Mother of all exceptions.
Definition error.c:1083
rb_eIndexError
VALUE rb_eIndexError
IndexError exception.
Definition error.c:1093
rb_eSysStackError
VALUE rb_eSysStackError
SystemStackError exception.
Definition eval.c:50
rb_eSyntaxError
VALUE rb_eSyntaxError
SyntaxError exception.
Definition error.c:1108
rb_eEncodingError
VALUE rb_eEncodingError
EncodingError exception.
Definition error.c:1097
rb_eSecurityError
VALUE rb_eSecurityError
SecurityError exception.
Definition error.c:1100
rb_eThreadError
VALUE rb_eThreadError
ThreadError exception.
Definition eval.c:886
rb_eMathDomainError
VALUE rb_eMathDomainError
Math::DomainError exception.
Definition math.c:30
rb_eSystemCallError
VALUE rb_eSystemCallError
SystemCallError exception.
Definition error.c:1111
rb_eSignal
VALUE rb_eSignal
SignalException exception.
Definition error.c:1086
rb_cClass
VALUE rb_cClass
Class class.
Definition object.c:54
rb_cRational
VALUE rb_cRational
Rational class.
Definition rational.c:47
rb_cUnboundMethod
VALUE rb_cUnboundMethod
UnboundMethod class.
Definition proc.c:49
rb_cTime
VALUE rb_cTime
Time class.
Definition time.c:672
rb_cDir
VALUE rb_cDir
Dir class.
Definition dir.c:458
rb_mKernel
VALUE rb_mKernel
Kernel module.
Definition object.c:51
rb_cComplex
VALUE rb_cComplex
Complex class.
Definition complex.c:38
rb_cArray
VALUE rb_cArray
Array class.
Definition array.c:40
rb_cNameErrorMesg
VALUE rb_cNameErrorMesg
NameError::Message class.
Definition error.c:1103
rb_cObject
VALUE rb_cObject
Object class.
Definition object.c:52
rb_mProcess
VALUE rb_mProcess
Process module.
Definition process.c:8784
rb_mMath
VALUE rb_mMath
Math module.
Definition math.c:29
rb_cIO
VALUE rb_cIO
IO class.
Definition io.c:180
rb_mEnumerable
VALUE rb_mEnumerable
Enumerable module.
Definition enum.c:27
rb_cMatch
VALUE rb_cMatch
MatchData class.
Definition re.c:960
rb_mErrno
VALUE rb_mErrno
Errno module.
Definition error.c:1112
rb_cStruct
VALUE rb_cStruct
Struct class.
Definition struct.c:34
rb_cEnumerator
VALUE rb_cEnumerator
Enumerator class.
Definition enumerator.c:158
rb_cRefinement
VALUE rb_cRefinement
Refinement class.
Definition object.c:55
rb_cInteger
VALUE rb_cInteger
Module class.
Definition numeric.c:192
rb_cNilClass
VALUE rb_cNilClass
NilClass class.
Definition object.c:57
rb_stdin
VALUE rb_stdin
STDIN constant.
Definition io.c:194
rb_cStat
VALUE rb_cStat
File::Stat class.
Definition file.c:178
rb_cBinding
VALUE rb_cBinding
Binding class.
Definition proc.c:51
rb_cRegexp
VALUE rb_cRegexp
Regexp class.
Definition re.c:2544
rb_mGC
VALUE rb_mGC
GC module.
Definition gc.c:1209
rb_cHash
VALUE rb_cHash
Hash class.
Definition hash.c:94
rb_stderr
VALUE rb_stderr
STDERR constant.
Definition io.c:194
rb_cFalseClass
VALUE rb_cFalseClass
FalseClass class.
Definition object.c:59
rb_cNumeric
VALUE rb_cNumeric
Numeric class.
Definition numeric.c:190
rb_class_of
static VALUE rb_class_of(VALUE obj)
Object to class mapping function.
Definition globals.h:172
rb_cRandom
VALUE rb_cRandom
Random class.
Definition random.c:229
rb_cEncoding
VALUE rb_cEncoding
Encoding class.
Definition encoding.c:57
rb_cSymbol
VALUE rb_cSymbol
Sumbol class.
Definition string.c:80
rb_cBasicObject
VALUE rb_cBasicObject
BasicObject class.
Definition object.c:50
rb_cThread
VALUE rb_cThread
Thread class.
Definition vm.c:466
rb_cModule
VALUE rb_cModule
Module class.
Definition object.c:53
rb_cRange
VALUE rb_cRange
Range class.
Definition range.c:31
rb_mFileTest
VALUE rb_mFileTest
FileTest module.
Definition file.c:177
rb_mWaitReadable
VALUE rb_mWaitReadable
IO::WaitReadable module.
Definition io.c:184
rb_mWaitWritable
VALUE rb_mWaitWritable
IO::WaitReadable module.
Definition io.c:185
rb_mComparable
VALUE rb_mComparable
Comparable module.
Definition compar.c:19
rb_cFloat
VALUE rb_cFloat
Float class.
Definition numeric.c:191
rb_cProc
VALUE rb_cProc
Proc class.
Definition proc.c:52
rb_cFile
VALUE rb_cFile
File class.
Definition file.c:176
rb_cTrueClass
VALUE rb_cTrueClass
TrueClass class.
Definition object.c:58
rb_stdout
VALUE rb_stdout
STDOUT constant.
Definition io.c:194
rb_cString
VALUE rb_cString
String class.
Definition string.c:79
rb_cMethod
VALUE rb_cMethod
Method class.
Definition proc.c:50
RBIMPL_UNREACHABLE_RETURN
#define RBIMPL_UNREACHABLE_RETURN(_)
Wraps (or simulates) __builtin_unreachable.
Definition assume.h:48
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
RBASIC_CLASS
static VALUE RBASIC_CLASS(VALUE obj)
Queries the class of an object.
Definition rbasic.h:152
special_consts.h
Defines enum ruby_special_consts.
RB_STATIC_SYM_P
static bool RB_STATIC_SYM_P(VALUE obj)
Checks if the given object is a static symbol.
Definition special_consts.h:267
RB_FIXNUM_P
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Definition special_consts.h:247
RB_SPECIAL_CONST_P
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
Definition special_consts.h:327
RUBY_Qtrue
@ RUBY_Qtrue
Definition special_consts.h:89
RUBY_Qnil
@ RUBY_Qnil
Definition special_consts.h:90
RUBY_Qfalse
@ RUBY_Qfalse
Definition special_consts.h:88
RB_FLONUM_P
static bool RB_FLONUM_P(VALUE obj)
Checks if the given object is a so-called Flonum.
Definition special_consts.h:288
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
value_type.h
Defines enum ruby_value_type.