Ruby: include/ruby/internal/special_consts.h File Reference

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

Macros | Enumerations | Functions
special_consts.h File Reference

Defines enum ruby_special_consts. More...

`#include "ruby/internal/attr/artificial.h"`
`#include "ruby/internal/attr/const.h"`
`#include "ruby/internal/attr/constexpr.h"`
`#include "ruby/internal/attr/enum_extensibility.h"`
`#include "ruby/internal/stdbool.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Macros
#define | USE_FLONUM 1
#define | RTEST RB_TEST
| This is an old name of RB_TEST.
#define | FIXNUM_P RB_FIXNUM_P
| Old name of RB_FIXNUM_P.
#define | IMMEDIATE_P RB_IMMEDIATE_P
| Old name of RB_IMMEDIATE_P.
#define | NIL_P RB_NIL_P
| Old name of RB_NIL_P.
#define | SPECIAL_CONST_P RB_SPECIAL_CONST_P
| Old name of RB_SPECIAL_CONST_P.
#define | STATIC_SYM_P RB_STATIC_SYM_P
| Old name of RB_STATIC_SYM_P.
#define | Qfalse RUBY_Qfalse
| Old name of RUBY_Qfalse.
#define | Qnil RUBY_Qnil
| Old name of RUBY_Qnil.
#define | Qtrue RUBY_Qtrue
| Old name of RUBY_Qtrue.
#define | Qundef RUBY_Qundef
| Old name of RUBY_Qundef.
#define | FIXNUM_FLAG RUBY_FIXNUM_FLAG
| Old name of RUBY_FIXNUM_FLAG.
#define | FLONUM_FLAG RUBY_FLONUM_FLAG
| Old name of RUBY_FLONUM_FLAG.
#define | FLONUM_MASK RUBY_FLONUM_MASK
| Old name of RUBY_FLONUM_MASK.
#define | FLONUM_P RB_FLONUM_P
| Old name of RB_FLONUM_P.
#define | IMMEDIATE_MASK RUBY_IMMEDIATE_MASK
| Old name of RUBY_IMMEDIATE_MASK.
#define | SYMBOL_FLAG RUBY_SYMBOL_FLAG
| Old name of RUBY_SYMBOL_FLAG.

## Enumerations
enum | ruby_special_consts { RUBY_Qfalse , RUBY_Qtrue , RUBY_Qnil , RUBY_Qundef , RUBY_IMMEDIATE_MASK , RUBY_FIXNUM_FLAG , RUBY_FLONUM_MASK , RUBY_FLONUM_FLAG , RUBY_SYMBOL_FLAG , RUBY_SPECIAL_SHIFT = 8 }
| special constants - i.e. More...

## Functions
static bool | RB_TEST (VALUE obj)
| Emulates Ruby's "if" statement.
static bool | RB_NIL_P (VALUE obj)
| Checks if the given object is nil.
static bool | RB_UNDEF_P (VALUE obj)
| Checks if the given object is undef.
static bool | RB_NIL_OR_UNDEF_P (VALUE obj)
| Checks if the given object is nil or undef.
static bool | RB_FIXNUM_P (VALUE obj)
| Checks if the given object is a so-called Fixnum.
static bool | RB_STATIC_SYM_P (VALUE obj)
| Checks if the given object is a static symbol.
static bool | RB_FLONUM_P (VALUE obj)
| Checks if the given object is a so-called Flonum.
static bool | RB_IMMEDIATE_P (VALUE obj)
| Checks if the given object is an immediate i.e.
static bool | RB_SPECIAL_CONST_P (VALUE obj)
| Checks if the given object is of enum ruby_special_consts.
static VALUE | rb_special_const_p (VALUE obj)
| Identical to RB_SPECIAL_CONST_P, except it returns a VALUE.

## Detailed Description

Defines enum ruby_special_consts.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

See also
  Sasada, K., "A Lightweight Representation of Floating-Point Numbers on Ruby Interpreter", in proceedings of 10th JSSST SIGPPL Workshop on Programming and Programming Languages (PPL2008), pp. 9-16, 2008.

Definition in file special_consts.h.

## Macro Definition Documentation

## ◆ RTEST

#define RTEST RB_TEST

This is an old name of RB_TEST.

Not sure which name is preferred.

Definition at line 51 of file special_consts.h.

Referenced by rb_category_warning(), rb_cmpint(), rb_compile_warning(), rb_debug_inspector_frame_iseq_get(), rb_econv_has_convpath_p(), rb_enumeratorize_with_size_kw(), rb_eql(), rb_equal(), rb_f_global_variables(), rb_io_maybe_wait_readable(), rb_io_maybe_wait_writable(), rb_io_set_timeout(), rb_io_set_write_io(), rb_io_wait_readable(), rb_io_wait_writable(), rb_mod_class_variables(), rb_mod_constants(), rb_obj_singleton_methods(), rb_range_values(), rb_str_format(), rb_sys_warning(), rb_thread_wakeup(), rb_tracepoint_new(), rb_warning(), and ruby_init().

## ◆ USE_FLONUM

#define USE_FLONUM 1

Warning
  Do not touch this macro.
  It is an implementation detail.
  The value of this macro must match for ruby itself and all extension libraries, otherwise serious memory corruption shall occur.

Definition at line 45 of file special_consts.h.

## Enumeration Type Documentation

## ◆ ruby_special_consts

enum ruby_special_consts

special constants - i.e.

non-zero and non-fixnum constants

Enumerator
RUBY_Qfalse | See also rb_cFalseClass
RUBY_Qtrue | See also rb_cTrueClass
RUBY_Qnil | See also rb_cNilClass
RUBY_Qundef | Represents so-called undef.
RUBY_IMMEDIATE_MASK | Bit mask detecting special consts.
RUBY_FIXNUM_FLAG | Flag to denote a fixnum.
RUBY_FLONUM_MASK | Bit mask detecting a flonum.
RUBY_FLONUM_FLAG | Flag to denote a flonum.
RUBY_SYMBOL_FLAG | Flag to denote a static symbol.
RUBY_SPECIAL_SHIFT | Least significant 8 bits are reserved.

Definition at line 84 of file special_consts.h.

## Function Documentation

## ◆ RB_FIXNUM_P()

bool RB_FIXNUM_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is a so-called Fixnum.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is a Fixnum.
  false | Anything else.

Note
  Fixnum was a thing in the 20th century, but it is rather an implementation detail today.

Definition at line 247 of file special_consts.h.

Referenced by rb_class_of(), rb_fiber_scheduler_io_result_apply(), RB_FIX2INT(), RB_FIX2UINT(), rb_fix2ulong(), RB_FIXNUM_P(), RB_INT2FIX(), rb_integer_type_p(), rb_num2int_inline(), rb_num2ll_inline(), rb_num2long_inline(), rb_num2short_inline(), rb_num2ull_inline(), rb_num2ulong_inline(), and rb_type().

## ◆ RB_FLONUM_P()

bool RB_FLONUM_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is a so-called Flonum.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is a Flonum.
  false | Anything else.

See also
  RB_FLOAT_TYPE_P()

Note
  These days there are Flonums and non-Flonum floats, just like we once had Fixnum/Bignum back in the old days.

Definition at line 288 of file special_consts.h.

Referenced by rb_class_of(), RB_FLOAT_TYPE_P(), RB_FLONUM_P(), and rb_type().

## ◆ RB_IMMEDIATE_P()

bool RB_IMMEDIATE_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is an immediate i.e.

an object which has no corresponding storage inside of the object space.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is a Flonum.
  false | Anything else.

See also
  RB_FLOAT_TYPE_P()

Note
  The concept of "immediate" is purely C specific.

Definition at line 311 of file special_consts.h.

Referenced by RB_IMMEDIATE_P(), and RB_SPECIAL_CONST_P().

## ◆ RB_NIL_OR_UNDEF_P()

bool RB_NIL_OR_UNDEF_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is nil or undef.

Can be used to see if a keyword argument is not given or given nil.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is RUBY_Qnil or RUBY_Qundef.
  false | Anything else.

Definition at line 206 of file special_consts.h.

Referenced by RB_NIL_OR_UNDEF_P().

## ◆ RB_NIL_P()

bool RB_NIL_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is nil.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is RUBY_Qnil.
  false | Anything else.

Definition at line 173 of file special_consts.h.

Referenced by RB_NIL_P().

## ◆ RB_SPECIAL_CONST_P()

bool RB_SPECIAL_CONST_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is of enum ruby_special_consts.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is a special constant.
  false | Anything else.

Definition at line 327 of file special_consts.h.

Referenced by RB_BUILTIN_TYPE(), rb_class_of(), rb_define_const(), RB_DYNAMIC_SYM_P(), RB_FL_ABLE(), RB_FLOAT_TYPE_P(), rb_integer_type_p(), rb_ractor_shareable_p(), RB_SPECIAL_CONST_P(), rb_special_const_p(), rb_type(), and RBASIC_CLASS().

## ◆ rb_special_const_p()

VALUE rb_special_const_p | ( | VALUE | obj | ) |
| inlinestatic

Identical to RB_SPECIAL_CONST_P, except it returns a VALUE.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  RUBY_Qtrue | obj is a special constant.
  RUBY_Qfalse | Anything else.

Definition at line 347 of file special_consts.h.

Referenced by rb_special_const_p().

## ◆ RB_STATIC_SYM_P()

bool RB_STATIC_SYM_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is a static symbol.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is a static symbol
  false | Anything else.

See also
  RB_DYNAMIC_SYM_P()
  RB_SYMBOL_P()

Note
  These days there are static and dynamic symbols, just like we once had Fixnum/Bignum back in the old days.

Definition at line 267 of file special_consts.h.

Referenced by rb_class_of(), RB_STATIC_SYM_P(), RB_SYMBOL_P(), and rb_type().

## ◆ RB_TEST()

bool RB_TEST | ( | VALUE | obj | ) |
| inlinestatic

Emulates Ruby's "if" statement.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  false | obj is either RUBY_Qfalse or RUBY_Qnil.
  true | Anything else.

Definition at line 138 of file special_consts.h.

Referenced by RB_TEST().

## ◆ RB_UNDEF_P()

bool RB_UNDEF_P | ( | VALUE | obj | ) |
| inlinestatic

Checks if the given object is undef.

Parameters

  [in] | obj | An arbitrary ruby object.

Return values

  true | obj is RUBY_Qundef.
  false | Anything else.

Definition at line 189 of file special_consts.h.

Referenced by RB_UNDEF_P().