Ruby: include/ruby/internal/intern/error.h Source File

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

error.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_ERROR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_ERROR_H
23#include "ruby/internal/dllexport.h"
24#include "ruby/internal/value.h"
25#include "ruby/internal/fl_type.h"
26#include "ruby/backward/2/assume.h"
27#include "ruby/backward/2/attributes.h"
28
29#define UNLIMITED_ARGUMENTS (-1)
30#define rb_exc_new2 rb_exc_new_cstr
31#define rb_exc_new3 rb_exc_new_str
32#define rb_check_trusted rb_check_trusted
33#define rb_check_trusted_inline rb_check_trusted
34#define rb_check_arity rb_check_arity
35
36 RBIMPL_SYMBOL_EXPORT_BEGIN()
37
38/* error.c */
39 VALUE rb_exc_new(VALUE, const char*, long);
40 VALUE rb_exc_new_cstr(VALUE, const char*);
41 VALUE rb_exc_new_str(VALUE, VALUE);
42 PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
43 PRINTF_ARGS(NORETURN(void rb_loaderror_with_path(VALUE path, const char*, ...)), 2, 3);
44 PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
45 PRINTF_ARGS(NORETURN(void rb_name_error_str(VALUE, const char*, ...)), 2, 3);
46 PRINTF_ARGS(NORETURN(void rb_frozen_error_raise(VALUE, const char*, ...)), 2, 3);
47 NORETURN(void rb_invalid_str(const char*, const char*));
48 NORETURN(void rb_error_frozen(const char*));
49 NORETURN(void rb_error_frozen_object(VALUE));
50void rb_error_untrusted(VALUE);
51void rb_check_frozen(VALUE);
52void rb_check_trusted(VALUE);
53void rb_check_copyable(VALUE obj, VALUE orig);
54 NORETURN(MJIT_STATIC void rb_error_arity(int, int, int));
55 RBIMPL_SYMBOL_EXPORT_END()
56
57/* Does anyone use this? Remain not deleted for compatibility. */
58#define rb_check_frozen_internal(obj) do { \
59 VALUE frozen_obj = (obj); \
60 if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
61 rb_error_frozen_object(frozen_obj); \
62 } \
63 } while (0)
64
65static inline void
66rb_check_frozen_inline(VALUE obj)
67{
68 if (RB_UNLIKELY(RB_OBJ_FROZEN(obj))) {
69 rb_error_frozen_object(obj);
70 }
71}
72#define rb_check_frozen rb_check_frozen_inline
73
74static inline int
75 rb_check_arity(int argc, int min, int max)
76{
77 if ((argc < min) || (max != UNLIMITED_ARGUMENTS && argc > max))
78 rb_error_arity(argc, min, max);
79 return argc;
80}
81
82#endif /* RBIMPL_INTERN_ERROR_H */
attributes.h
Various attribute-related macros.
NORETURN
#define NORETURN(x)
Definition: attributes.h:152
PRINTF_ARGS
#define PRINTF_ARGS(decl, string_index, first_to_check)
Definition: attributes.h:112
assume.h
Defines ASSUME / RB_LIKELY / UNREACHABLE.
RB_UNLIKELY
#define RB_UNLIKELY(x)
Definition: assume.h:40
dllexport.h
Tewaking visibility of C variables/functions.
MJIT_STATIC
#define MJIT_STATIC
Definition: dllexport.h:71
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
max
int max
Definition: enough.c:225
fl_type.h
Defines enum ruby_fl_type.
rb_name_error
void rb_name_error(ID, const char *,...)
Definition: error.c:1649
rb_check_copyable
void rb_check_copyable(VALUE obj, VALUE orig)
Definition: error.c:3301
rb_error_frozen
void rb_error_frozen(const char *)
Definition: error.c:3228
rb_error_untrusted
void rb_error_untrusted(VALUE)
Definition: error.c:3288
rb_name_error_str
void rb_name_error_str(VALUE, const char *,...)
Definition: error.c:1664
rb_frozen_error_raise
void rb_frozen_error_raise(VALUE, const char *,...)
Definition: error.c:3234
rb_invalid_str
void rb_invalid_str(const char *, const char *)
Definition: error.c:2045
rb_exc_new
VALUE rb_exc_new(VALUE, const char *, long)
Definition: error.c:1094
rb_error_frozen_object
void rb_error_frozen_object(VALUE)
Definition: error.c:3260
rb_exc_new_str
VALUE rb_exc_new_str(VALUE, VALUE)
Definition: error.c:1107
rb_loaderror
void rb_loaderror(const char *,...)
Definition: error.c:2936
rb_loaderror_with_path
void rb_loaderror_with_path(VALUE path, const char *,...)
Definition: error.c:2948
UNLIMITED_ARGUMENTS
#define UNLIMITED_ARGUMENTS
Definition: error.h:29
rb_check_frozen
#define rb_check_frozen
Definition: error.h:72
rb_check_trusted
#define rb_check_trusted
Definition: error.h:32
rb_error_arity
void rb_error_arity(int, int, int)
Definition: vm_insnhelper.c:442
rb_check_arity
#define rb_check_arity
Definition: error.h:34
rb_exc_new_cstr
#define rb_exc_new_cstr(exc, str)
Definition: string.h:271
argc
int argc
Definition: ruby.c:240
const
#define const
Definition: strftime.c:108
value.h
Defines VALUE and ID.
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39