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

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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
30 RBIMPL_SYMBOL_EXPORT_BEGIN()
31
32#define RUBY_INTEGER_UNIFICATION 1
33
34 RUBY_EXTERN VALUE rb_mKernel;
35 RUBY_EXTERN VALUE rb_mComparable;
36 RUBY_EXTERN VALUE rb_mEnumerable;
37 RUBY_EXTERN VALUE rb_mErrno;
38 RUBY_EXTERN VALUE rb_mFileTest;
39 RUBY_EXTERN VALUE rb_mGC;
40 RUBY_EXTERN VALUE rb_mMath;
41 RUBY_EXTERN VALUE rb_mProcess;
42 RUBY_EXTERN VALUE rb_mWaitReadable;
43 RUBY_EXTERN VALUE rb_mWaitWritable;
44
45 RUBY_EXTERN VALUE rb_cBasicObject;
46 RUBY_EXTERN VALUE rb_cObject;
47 RUBY_EXTERN VALUE rb_cArray;
48 RUBY_EXTERN VALUE rb_cBinding;
49 RUBY_EXTERN VALUE rb_cClass;
50 RUBY_EXTERN VALUE rb_cDir;
51 RUBY_EXTERN VALUE rb_cEncoding;
52 RUBY_EXTERN VALUE rb_cEnumerator;
53 RUBY_EXTERN VALUE rb_cFalseClass;
54 RUBY_EXTERN VALUE rb_cFile;
55 RUBY_EXTERN VALUE rb_cComplex;
56 RUBY_EXTERN VALUE rb_cFloat;
57 RUBY_EXTERN VALUE rb_cHash;
58 RUBY_EXTERN VALUE rb_cIO;
59 RUBY_EXTERN VALUE rb_cInteger;
60 RUBY_EXTERN VALUE rb_cMatch;
61 RUBY_EXTERN VALUE rb_cMethod;
62 RUBY_EXTERN VALUE rb_cModule;
63 RUBY_EXTERN VALUE rb_cNameErrorMesg;
64 RUBY_EXTERN VALUE rb_cNilClass;
65 RUBY_EXTERN VALUE rb_cNumeric;
66 RUBY_EXTERN VALUE rb_cProc;
67 RUBY_EXTERN VALUE rb_cRandom;
68 RUBY_EXTERN VALUE rb_cRange;
69 RUBY_EXTERN VALUE rb_cRational;
70 RUBY_EXTERN VALUE rb_cRegexp;
71 RUBY_EXTERN VALUE rb_cStat;
72 RUBY_EXTERN VALUE rb_cString;
73 RUBY_EXTERN VALUE rb_cStruct;
74 RUBY_EXTERN VALUE rb_cSymbol;
75 RUBY_EXTERN VALUE rb_cThread;
76 RUBY_EXTERN VALUE rb_cTime;
77 RUBY_EXTERN VALUE rb_cTrueClass;
78 RUBY_EXTERN VALUE rb_cUnboundMethod;
79
80 RUBY_EXTERN VALUE rb_eException;
81 RUBY_EXTERN VALUE rb_eStandardError;
82 RUBY_EXTERN VALUE rb_eSystemExit;
83 RUBY_EXTERN VALUE rb_eInterrupt;
84 RUBY_EXTERN VALUE rb_eSignal;
85 RUBY_EXTERN VALUE rb_eFatal;
86 RUBY_EXTERN VALUE rb_eArgError;
87 RUBY_EXTERN VALUE rb_eEOFError;
88 RUBY_EXTERN VALUE rb_eIndexError;
89 RUBY_EXTERN VALUE rb_eStopIteration;
90 RUBY_EXTERN VALUE rb_eKeyError;
91 RUBY_EXTERN VALUE rb_eRangeError;
92 RUBY_EXTERN VALUE rb_eIOError;
93 RUBY_EXTERN VALUE rb_eRuntimeError;
94 RUBY_EXTERN VALUE rb_eFrozenError;
95 RUBY_EXTERN VALUE rb_eSecurityError;
96 RUBY_EXTERN VALUE rb_eSystemCallError;
97 RUBY_EXTERN VALUE rb_eThreadError;
98 RUBY_EXTERN VALUE rb_eTypeError;
99 RUBY_EXTERN VALUE rb_eZeroDivError;
100 RUBY_EXTERN VALUE rb_eNotImpError;
101 RUBY_EXTERN VALUE rb_eNoMemError;
102 RUBY_EXTERN VALUE rb_eNoMethodError;
103 RUBY_EXTERN VALUE rb_eFloatDomainError;
104 RUBY_EXTERN VALUE rb_eLocalJumpError;
105 RUBY_EXTERN VALUE rb_eSysStackError;
106 RUBY_EXTERN VALUE rb_eRegexpError;
107 RUBY_EXTERN VALUE rb_eEncodingError;
108 RUBY_EXTERN VALUE rb_eEncCompatError;
109 RUBY_EXTERN VALUE rb_eNoMatchingPatternError;
110
111 RUBY_EXTERN VALUE rb_eScriptError;
112 RUBY_EXTERN VALUE rb_eNameError;
113 RUBY_EXTERN VALUE rb_eSyntaxError;
114 RUBY_EXTERN VALUE rb_eLoadError;
115
116 RUBY_EXTERN VALUE rb_eMathDomainError;
117
118 RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
119
120 RBIMPL_ATTR_PURE()
121static inline VALUE
122rb_class_of(VALUE obj)
123{
124 if (! RB_SPECIAL_CONST_P(obj)) {
125 return RBASIC_CLASS(obj);
126 }
127 else if (obj == RUBY_Qfalse) {
128 return rb_cFalseClass;
129 }
130 else if (obj == RUBY_Qnil) {
131 return rb_cNilClass;
132 }
133 else if (obj == RUBY_Qtrue) {
134 return rb_cTrueClass;
135 }
136 else if (RB_FIXNUM_P(obj)) {
137 return rb_cInteger;
138 }
139 else if (RB_STATIC_SYM_P(obj)) {
140 return rb_cSymbol;
141 }
142 else if (RB_FLONUM_P(obj)) {
143 return rb_cFloat;
144 }
145
146#if !RUBY_DEBUG
147 RBIMPL_UNREACHABLE_RETURN(Qfalse);
148#else
149 RUBY_ASSERT_FAIL("unexpected type");
150#endif
151}
152
153#define CLASS_OF rb_class_of
154
155 RBIMPL_SYMBOL_EXPORT_END()
156
157#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
Tewaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Definition: dllexport.h:36
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
fl_type.h
Defines enum ruby_fl_type.
rb_cRational
VALUE rb_cRational
Definition: rational.c:43
rb_eLocalJumpError
VALUE rb_eLocalJumpError
Definition: eval.c:48
rb_cUnboundMethod
VALUE rb_cUnboundMethod
Definition: proc.c:43
rb_cTime
VALUE rb_cTime
Definition: time.c:645
rb_cDir
VALUE rb_cDir
Definition: dir.c:450
rb_cComplex
VALUE rb_cComplex
Definition: complex.c:44
rb_cArray
VALUE rb_cArray
Definition: array.c:40
rb_mProcess
VALUE rb_mProcess
Definition: process.c:8608
rb_eZeroDivError
VALUE rb_eZeroDivError
Definition: numeric.c:193
rb_mMath
VALUE rb_mMath
Definition: math.c:36
rb_eIOError
VALUE rb_eIOError
Definition: io.c:185
rb_cIO
VALUE rb_cIO
Definition: io.c:183
rb_mEnumerable
VALUE rb_mEnumerable
Definition: enum.c:27
rb_cMatch
VALUE rb_cMatch
Definition: re.c:940
rb_cStruct
VALUE rb_cStruct
Definition: struct.c:34
rb_eRegexpError
VALUE rb_eRegexpError
Definition: re.c:28
rb_cEnumerator
VALUE rb_cEnumerator
Definition: enumerator.c:126
rb_cInteger
VALUE rb_cInteger
Definition: numeric.c:191
rb_eEOFError
VALUE rb_eEOFError
Definition: io.c:184
rb_stdin
VALUE rb_stdin
Definition: io.c:196
rb_cStat
VALUE rb_cStat
Definition: file.c:176
rb_cBinding
VALUE rb_cBinding
Definition: proc.c:45
rb_cRegexp
VALUE rb_cRegexp
Definition: re.c:2301
rb_mGC
VALUE rb_mGC
Definition: gc.c:981
rb_cHash
VALUE rb_cHash
Definition: hash.c:106
rb_stderr
VALUE rb_stderr
Definition: globals.h:118
rb_cNumeric
VALUE rb_cNumeric
Definition: numeric.c:189
rb_cRandom
VALUE rb_cRandom
Definition: random.c:226
rb_cEncoding
VALUE rb_cEncoding
Definition: encoding.c:57
rb_eStopIteration
VALUE rb_eStopIteration
Definition: enumerator.c:141
rb_eFloatDomainError
VALUE rb_eFloatDomainError
Definition: numeric.c:194
rb_cSymbol
VALUE rb_cSymbol
Definition: string.c:81
rb_cThread
VALUE rb_cThread
Definition: vm.c:374
rb_cRange
VALUE rb_cRange
Definition: range.c:31
rb_mFileTest
VALUE rb_mFileTest
Definition: file.c:175
rb_mWaitReadable
VALUE rb_mWaitReadable
Definition: io.c:186
rb_mWaitWritable
VALUE rb_mWaitWritable
Definition: io.c:187
rb_eSysStackError
VALUE rb_eSysStackError
Definition: eval.c:49
rb_mComparable
VALUE rb_mComparable
Definition: compar.c:19
rb_cFloat
VALUE rb_cFloat
Definition: numeric.c:190
rb_cProc
VALUE rb_cProc
Definition: proc.c:46
rb_cFile
VALUE rb_cFile
Definition: file.c:174
rb_stdout
VALUE rb_stdout
Definition: globals.h:118
rb_eThreadError
VALUE rb_eThreadError
Definition: eval.c:953
rb_cString
VALUE rb_cString
Definition: string.c:80
rb_eMathDomainError
VALUE rb_eMathDomainError
Definition: math.c:37
rb_cMethod
VALUE rb_cMethod
Definition: proc.c:44
rb_eNotImpError
VALUE rb_eNotImpError
Definition: error.c:1067
rb_eScriptError
VALUE rb_eScriptError
Definition: error.c:1072
rb_eKeyError
VALUE rb_eKeyError
Definition: error.c:1060
rb_cNameErrorMesg
VALUE rb_cNameErrorMesg
Definition: error.c:1069
rb_eSystemExit
VALUE rb_eSystemExit
Definition: error.c:1050
rb_eStandardError
VALUE rb_eStandardError
Definition: error.c:1054
rb_mErrno
VALUE rb_mErrno
Definition: error.c:1077
rb_eFrozenError
VALUE rb_eFrozenError
Definition: error.c:1056
rb_eNoMemError
VALUE rb_eNoMemError
Definition: error.c:1068
rb_eRangeError
VALUE rb_eRangeError
Definition: error.c:1061
rb_eLoadError
VALUE rb_eLoadError
Definition: error.c:1074
rb_eTypeError
VALUE rb_eTypeError
Definition: error.c:1057
rb_eNoMatchingPatternError
VALUE rb_eNoMatchingPatternError
Definition: error.c:1070
rb_eEncCompatError
VALUE rb_eEncCompatError
Definition: error.c:1064
rb_eFatal
VALUE rb_eFatal
Definition: error.c:1053
rb_eInterrupt
VALUE rb_eInterrupt
Definition: error.c:1051
rb_eNameError
VALUE rb_eNameError
Definition: error.c:1062
rb_eNoMethodError
VALUE rb_eNoMethodError
Definition: error.c:1065
rb_eRuntimeError
VALUE rb_eRuntimeError
Definition: error.c:1055
rb_eArgError
VALUE rb_eArgError
Definition: error.c:1058
rb_eException
VALUE rb_eException
Definition: error.c:1049
rb_eIndexError
VALUE rb_eIndexError
Definition: error.c:1059
rb_eSyntaxError
VALUE rb_eSyntaxError
Definition: error.c:1073
rb_eEncodingError
VALUE rb_eEncodingError
Definition: error.c:1063
rb_eSecurityError
VALUE rb_eSecurityError
Definition: error.c:1066
rb_eSystemCallError
VALUE rb_eSystemCallError
Definition: error.c:1076
rb_eSignal
VALUE rb_eSignal
Definition: error.c:1052
rb_cClass
VALUE rb_cClass
Class class.
Definition: object.c:51
rb_mKernel
VALUE rb_mKernel
Kernel module.
Definition: object.c:48
rb_cObject
VALUE rb_cObject
Object class.
Definition: object.c:49
rb_cNilClass
VALUE rb_cNilClass
NilClass class.
Definition: object.c:53
rb_cFalseClass
VALUE rb_cFalseClass
FalseClass class.
Definition: object.c:55
rb_cBasicObject
VALUE rb_cBasicObject
BasicObject class.
Definition: object.c:47
rb_cModule
VALUE rb_cModule
Module class.
Definition: object.c:50
rb_cTrueClass
VALUE rb_cTrueClass
TrueClass class.
Definition: object.c:54
RBIMPL_UNREACHABLE_RETURN
#define RBIMPL_UNREACHABLE_RETURN(_)
Wraps (or simulates) __builtin_unreachable.
Definition: assume.h:51
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition: pure.h:33
RBASIC_CLASS
#define RBASIC_CLASS
Definition: rbasic.h:35
special_consts.h
Defines enum ruby_special_consts.
RUBY_Qtrue
@ RUBY_Qtrue
Definition: special_consts.h:88
RUBY_Qnil
@ RUBY_Qnil
Definition: special_consts.h:89
RUBY_Qfalse
@ RUBY_Qfalse
Definition: special_consts.h:87
Qfalse
#define Qfalse
Definition: special_consts.h:50
value.h
Defines VALUE and ID.
VALUE
unsigned long VALUE
Definition: value.h:38
value_type.h
Defines enum ruby_value_type.