Ruby: include/ruby/ruby.h Source File

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

ruby.h
Go to the documentation of this file.
1#ifndef RUBY_RUBY_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_RUBY_H 1
15#include "ruby/internal/config.h"
16
17#ifdef HAVE_INTRINSICS_H
18# include <intrinsics.h>
19#endif
20
21#include <stdarg.h>
22
23#include "defines.h"
24#include "ruby/internal/anyargs.h"
25#include "ruby/internal/arithmetic.h"
26#include "ruby/internal/core.h"
27#include "ruby/internal/ctype.h"
28#include "ruby/internal/dllexport.h"
29#include "ruby/internal/error.h"
30#include "ruby/internal/eval.h"
31#include "ruby/internal/event.h"
32#include "ruby/internal/fl_type.h"
33#include "ruby/internal/gc.h"
34#include "ruby/internal/glob.h"
35#include "ruby/internal/globals.h"
36#include "ruby/internal/has/warning.h"
37#include "ruby/internal/interpreter.h"
38#include "ruby/internal/iterator.h"
39#include "ruby/internal/memory.h"
40#include "ruby/internal/method.h"
41#include "ruby/internal/module.h"
42#include "ruby/internal/newobj.h"
43#include "ruby/internal/rgengc.h"
44#include "ruby/internal/scan_args.h"
45#include "ruby/internal/special_consts.h"
46#include "ruby/internal/symbol.h"
47#include "ruby/internal/value.h"
48#include "ruby/internal/value_type.h"
49#include "ruby/internal/variable.h"
50#include "ruby/assert.h"
51#include "ruby/backward/2/assume.h"
52#include "ruby/backward/2/inttypes.h"
53#include "ruby/backward/2/limits.h"
54
55 RBIMPL_SYMBOL_EXPORT_BEGIN()
56
57/* Module#methods, #singleton_methods and so on return Symbols */
58#define USE_SYMBOL_AS_METHOD_NAME 1
59
60 VALUE rb_get_path(VALUE);
61#define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
62
63 VALUE rb_get_path_no_checksafe(VALUE);
64#define FilePathStringValue(v) ((v) = rb_get_path(v))
65
66#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
67# define rb_varargs_argc_check_runtime(argc, vargc) \
68 (((argc) <= (vargc)) ? (argc) : \
69 (rb_fatal("argc(%d) exceeds actual arguments(%d)", \
70 argc, vargc), 0))
71# define rb_varargs_argc_valid_p(argc, vargc) \
72 ((argc) == 0 ? (vargc) <= 1 : /* [ruby-core:85266] [Bug #14425] */ \
73 (argc) == (vargc))
74# if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
75# if HAVE_ATTRIBUTE_ERRORFUNC
76 ERRORFUNC((" argument length doesn't match"), int rb_varargs_bad_length(int,int));
77# else
78# define rb_varargs_bad_length(argc, vargc) \
79 ((argc)/rb_varargs_argc_valid_p(argc, vargc))
80# endif
81# define rb_varargs_argc_check(argc, vargc) \
82 __builtin_choose_expr(__builtin_constant_p(argc), \
83 (rb_varargs_argc_valid_p(argc, vargc) ? (argc) : \
84 rb_varargs_bad_length(argc, vargc)), \
85 rb_varargs_argc_check_runtime(argc, vargc))
86# else
87# define rb_varargs_argc_check(argc, vargc) \
88 rb_varargs_argc_check_runtime(argc, vargc)
89# endif
90#endif
91
92const char *rb_class2name(VALUE);
93const char *rb_obj_classname(VALUE);
94
95void rb_p(VALUE);
96
97 VALUE rb_equal(VALUE,VALUE);
98
99 VALUE rb_require(const char*);
100
101#include "ruby/intern.h"
102
103#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
104/* hook for external modules */
105static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
106#endif
107
108#define RUBY_VM 1 /* YARV */
109#define HAVE_NATIVETHREAD
110int ruby_native_thread_p(void);
111
112#define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
113
114 PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4);
115int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
116
117#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
118# /* Skip it; clang -pedantic doesn't like the following */
119#elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
120# define rb_yield_values(argc, ...) \
121__extension__({ \
122 const int rb_yield_values_argc = (argc); \
123 const VALUE rb_yield_values_args[] = {__VA_ARGS__}; \
124 const int rb_yield_values_nargs = \
125 (int)(sizeof(rb_yield_values_args) / sizeof(VALUE)); \
126 rb_yield_values2( \
127 rb_varargs_argc_check(rb_yield_values_argc, rb_yield_values_nargs), \
128 rb_yield_values_nargs ? rb_yield_values_args : NULL); \
129 })
130
131# define rb_funcall(recv, mid, argc, ...) \
132__extension__({ \
133 const int rb_funcall_argc = (argc); \
134 const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
135 const int rb_funcall_nargs = \
136 (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \
137 rb_funcallv(recv, mid, \
138 rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
139 rb_funcall_nargs ? rb_funcall_args : NULL); \
140 })
141#endif
142
143#ifndef RUBY_DONT_SUBST
144#include "ruby/subst.h"
145#endif
146
147#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
148# include "ruby/backward.h"
149#endif
150
151 RBIMPL_SYMBOL_EXPORT_END()
152
153#endif /* RUBY_RUBY_H */
anyargs.h
Function overloads to issue warnings around ANYARGS.
arithmetic.h
Conversion between C's arithmtic types and Ruby's numeric types.
assert.h
PRINTF_ARGS
#define PRINTF_ARGS(decl, string_index, first_to_check)
Definition: attributes.h:112
ERRORFUNC
#define ERRORFUNC(mesg, x)
Definition: attributes.h:90
assume.h
Defines ASSUME / RB_LIKELY / UNREACHABLE.
backward.h
core.h
Core data structures, definitions and manupulations.
ctype.h
Our own, locale independent, character handling routines.
defines.h
dllexport.h
Tewaking visibility of C variables/functions.
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
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
event.h
Debugging and tracing APIs.
fl_type.h
Defines enum ruby_fl_type.
glob.h
Declares rb_glob().
globals.h
Ruby-level global variables / constants, visible from C.
rb_equal
VALUE rb_equal(VALUE, VALUE)
This function is an optimized version of calling #==.
Definition: object.c:157
warning.h
Defines RBIMPL_HAS_WARNING.
config.h
Thin wrapper to ruby/config.h.
error.h
Declares rb_raise().
eval.h
Declares rb_eval_string().
gc.h
Registering values to the GC.
method.h
Creation and modification of Ruby methods.
symbol.h
Defines rb_intern.
variable.h
C-function backended Ruby-global variables.
intern.h
interpreter.h
Interpreter embedding APIs.
inttypes.h
C99 shim for <inttypes.h>
iterator.h
Block related APIs.
limits.h
Historical shim for <limits.h>.
memory.h
Memory management stuff.
module.h
Creation and modification of Ruby modules.
newobj.h
Defines NEWOBJ.
rgengc.h
RGENGC write-barrier APIs.
rb_p
void rb_p(VALUE)
Definition: io.c:7964
rb_obj_classname
const char * rb_obj_classname(VALUE)
Definition: variable.c:308
ruby_vsnprintf
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
Definition: sprintf.c:1010
rb_require
VALUE rb_require(const char *)
Definition: load.c:1199
rb_get_path
VALUE rb_get_path(VALUE)
Definition: file.c:245
rb_get_path_no_checksafe
VALUE rb_get_path_no_checksafe(VALUE)
Definition: file.c:239
ruby_native_thread_p
int ruby_native_thread_p(void)
Definition: thread.c:5564
rb_class2name
const char * rb_class2name(VALUE)
Definition: variable.c:299
ruby_snprintf
int ruby_snprintf(char *str, size_t n, char const *fmt,...)
Definition: sprintf.c:1037
scan_args.h
Compile-time static implementation of rb_scan_args().
special_consts.h
Defines enum ruby_special_consts.
stdarg.h
Defines old _.
subst.h
value.h
Defines VALUE and ID.
VALUE
unsigned long VALUE
Definition: value.h:38
value_type.h
Defines enum ruby_value_type.