Ruby 3.5.0dev (2025-04-03 revision 1dddc6c78b5f6dc6ae18ee04ebe44abfce3b0433)
globals.h
Go to the documentation of this file.
1#ifndef RBIMPL_GLOBALS_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_GLOBALS_H
27#include "ruby/internal/value.h"
29
46
47
54#define RUBY_INTEGER_UNIFICATION 1
55
171static inline VALUE
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
198#else
199 RUBY_ASSERT_FAIL("unexpected type");
200#endif
201}
202
203#define CLASS_OF rb_class_of
206
207
209#endif /* RBIMPL_GLOBALS_H */
Tweaking visibility of C variables/functions.
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
#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 enum ruby_fl_type.
#define Qfalse
Old name of RUBY_Qfalse.
VALUE rb_eLocalJumpError
LocalJumpError exception.
Definition eval.c:48
VALUE rb_eNotImpError
NotImplementedError exception.
Definition error.c:1440
VALUE rb_eScriptError
ScriptError exception.
Definition error.c:1446
VALUE rb_eKeyError
KeyError exception.
Definition error.c:1433
VALUE rb_eSystemExit
SystemExit exception.
Definition error.c:1423
VALUE rb_eZeroDivError
ZeroDivisionError exception.
Definition numeric.c:200
VALUE rb_eIOError
IOError exception.
Definition io.c:189
VALUE rb_eStandardError
StandardError exception.
Definition error.c:1427
VALUE rb_eRegexpError
RegexpError exception.
Definition re.c:32
VALUE rb_eFrozenError
FrozenError exception.
Definition error.c:1429
VALUE rb_eNoMemError
NoMemoryError exception.
Definition error.c:1441
VALUE rb_eRangeError
RangeError exception.
Definition error.c:1434
VALUE rb_eLoadError
LoadError exception.
Definition error.c:1448
VALUE rb_eTypeError
TypeError exception.
Definition error.c:1430
VALUE rb_eEOFError
EOFError exception.
Definition io.c:188
VALUE rb_eNoMatchingPatternError
NoMatchingPatternError exception.
Definition error.c:1443
VALUE rb_eEncCompatError
Encoding::CompatibilityError exception.
Definition error.c:1437
VALUE rb_eFatal
fatal exception.
Definition error.c:1426
VALUE rb_eInterrupt
Interrupt exception.
Definition error.c:1424
VALUE rb_eNameError
NameError exception.
Definition error.c:1435
VALUE rb_eNoMethodError
NoMethodError exception.
Definition error.c:1438
VALUE rb_eRuntimeError
RuntimeError exception.
Definition error.c:1428
VALUE rb_eStopIteration
StopIteration exception.
Definition enumerator.c:181
VALUE rb_eFloatDomainError
FloatDomainError exception.
Definition numeric.c:201
VALUE rb_eNoMatchingPatternKeyError
NoMatchingPatternKeyError exception.
Definition error.c:1444
VALUE rb_eArgError
ArgumentError exception.
Definition error.c:1431
VALUE rb_eException
Mother of all exceptions.
Definition error.c:1422
VALUE rb_eIndexError
IndexError exception.
Definition error.c:1432
VALUE rb_eSysStackError
SystemStackError exception.
Definition eval.c:49
VALUE rb_eSyntaxError
SyntaxError exception.
Definition error.c:1447
VALUE rb_eEncodingError
EncodingError exception.
Definition error.c:1436
VALUE rb_eSecurityError
SecurityError exception.
Definition error.c:1439
VALUE rb_eThreadError
ThreadError exception.
Definition eval.c:954
VALUE rb_eMathDomainError
Math::DomainError exception.
Definition math.c:30
VALUE rb_eSystemCallError
SystemCallError exception.
Definition error.c:1450
VALUE rb_eSignal
SignalException exception.
Definition error.c:1425
VALUE rb_cClass
Class class.
Definition object.c:68
VALUE rb_cRational
Rational class.
Definition rational.c:53
VALUE rb_cUnboundMethod
UnboundMethod class.
Definition proc.c:41
VALUE rb_cTime
Time class.
Definition time.c:678
VALUE rb_cDir
Dir class.
Definition dir.c:504
VALUE rb_mKernel
Kernel module.
Definition object.c:65
VALUE rb_cComplex
Complex class.
Definition complex.c:39
VALUE rb_cArray
Array class.
Definition array.c:40
VALUE rb_cNameErrorMesg
NameError::Message class.
Definition error.c:1442
VALUE rb_cObject
Object class.
Definition object.c:66
VALUE rb_mProcess
Process module.
Definition process.c:8721
VALUE rb_mMath
Math module.
Definition math.c:29
VALUE rb_cIO
IO class.
Definition io.c:187
VALUE rb_mEnumerable
Enumerable module.
Definition enum.c:27
VALUE rb_cMatch
MatchData class.
Definition re.c:967
VALUE rb_mErrno
Errno module.
Definition error.c:1451
VALUE rb_cStruct
Struct class.
Definition struct.c:33
VALUE rb_cEnumerator
Enumerator class.
Definition enumerator.c:163
VALUE rb_cRefinement
Refinement class.
Definition object.c:69
VALUE rb_cInteger
Module class.
Definition numeric.c:198
VALUE rb_cNilClass
NilClass class.
Definition object.c:71
VALUE rb_stdin
STDIN constant.
Definition io.c:201
VALUE rb_cStat
File::Stat class.
Definition file.c:177
VALUE rb_cBinding
Binding class.
Definition proc.c:43
VALUE rb_cRegexp
Regexp class.
Definition re.c:2661
VALUE rb_mGC
GC module.
Definition gc.c:431
VALUE rb_cHash
Hash class.
Definition hash.c:113
VALUE rb_stderr
STDERR constant.
Definition io.c:201
VALUE rb_cFalseClass
FalseClass class.
Definition object.c:73
VALUE rb_cNumeric
Numeric class.
Definition numeric.c:196
static VALUE rb_class_of(VALUE obj)
Object to class mapping function.
Definition globals.h:172
VALUE rb_cRandom
Random class.
Definition random.c:236
VALUE rb_cEncoding
Encoding class.
Definition encoding.c:57
VALUE rb_cSymbol
Symbol class.
Definition string.c:80
VALUE rb_cBasicObject
BasicObject class.
Definition object.c:64
VALUE rb_cThread
Thread class.
Definition vm.c:530
VALUE rb_cModule
Module class.
Definition object.c:67
VALUE rb_cRange
Range class.
Definition range.c:31
VALUE rb_mFileTest
FileTest module.
Definition file.c:176
VALUE rb_mWaitReadable
IO::WaitReadable module.
Definition io.c:191
VALUE rb_mWaitWritable
IO::WaitReadable module.
Definition io.c:192
VALUE rb_mComparable
Comparable module.
Definition compar.c:19
VALUE rb_cFloat
Float class.
Definition numeric.c:197
VALUE rb_cProc
Proc class.
Definition proc.c:44
VALUE rb_cFile
File class.
Definition file.c:175
VALUE rb_cTrueClass
TrueClass class.
Definition object.c:72
VALUE rb_stdout
STDOUT constant.
Definition io.c:201
VALUE rb_cString
String class.
Definition string.c:79
VALUE rb_cMethod
Method class.
Definition proc.c:42
#define RBIMPL_UNREACHABLE_RETURN(_)
Wraps (or simulates) __builtin_unreachable.
Definition assume.h:48
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
static VALUE RBASIC_CLASS(VALUE obj)
Queries the class of an object.
Definition rbasic.h:150
Defines enum ruby_special_consts.
static bool RB_STATIC_SYM_P(VALUE obj)
Checks if the given object is a static symbol.
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
@ RUBY_Qtrue
@ RUBY_Qnil
@ RUBY_Qfalse
static bool RB_FLONUM_P(VALUE obj)
Checks if the given object is a so-called Flonum.
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
Defines enum ruby_value_type.