Ruby  3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
Macros | Enumerations | Functions
value_type.h File Reference

(348a53415339076afc4a02fcd09f3ae36e9c4c61)

Defines enum ruby_value_type. More...

#include "ruby/internal/assume.h"
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/cold.h"
#include "ruby/internal/attr/enum_extensibility.h"
#include "ruby/internal/attr/forceinline.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/constant_p.h"
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/error.h"
#include "ruby/internal/has/builtin.h"
#include "ruby/internal/special_consts.h"
#include "ruby/internal/stdbool.h"
#include "ruby/internal/value.h"
#include "ruby/assert.h"
Include dependency graph for value_type.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define T_ARRAY   RUBY_T_ARRAY
 Old name of RUBY_T_ARRAY. More...
 
#define T_BIGNUM   RUBY_T_BIGNUM
 Old name of RUBY_T_BIGNUM. More...
 
#define T_CLASS   RUBY_T_CLASS
 Old name of RUBY_T_CLASS. More...
 
#define T_COMPLEX   RUBY_T_COMPLEX
 Old name of RUBY_T_COMPLEX. More...
 
#define T_DATA   RUBY_T_DATA
 Old name of RUBY_T_DATA. More...
 
#define T_FALSE   RUBY_T_FALSE
 Old name of RUBY_T_FALSE. More...
 
#define T_FILE   RUBY_T_FILE
 Old name of RUBY_T_FILE. More...
 
#define T_FIXNUM   RUBY_T_FIXNUM
 Old name of RUBY_T_FIXNUM. More...
 
#define T_FLOAT   RUBY_T_FLOAT
 Old name of RUBY_T_FLOAT. More...
 
#define T_HASH   RUBY_T_HASH
 Old name of RUBY_T_HASH. More...
 
#define T_ICLASS   RUBY_T_ICLASS
 Old name of RUBY_T_ICLASS. More...
 
#define T_IMEMO   RUBY_T_IMEMO
 Old name of RUBY_T_IMEMO. More...
 
#define T_MASK   RUBY_T_MASK
 Old name of RUBY_T_MASK. More...
 
#define T_MATCH   RUBY_T_MATCH
 Old name of RUBY_T_MATCH. More...
 
#define T_MODULE   RUBY_T_MODULE
 Old name of RUBY_T_MODULE. More...
 
#define T_MOVED   RUBY_T_MOVED
 Old name of RUBY_T_MOVED. More...
 
#define T_NIL   RUBY_T_NIL
 Old name of RUBY_T_NIL. More...
 
#define T_NODE   RUBY_T_NODE
 Old name of RUBY_T_NODE. More...
 
#define T_NONE   RUBY_T_NONE
 Old name of RUBY_T_NONE. More...
 
#define T_OBJECT   RUBY_T_OBJECT
 Old name of RUBY_T_OBJECT. More...
 
#define T_RATIONAL   RUBY_T_RATIONAL
 Old name of RUBY_T_RATIONAL. More...
 
#define T_REGEXP   RUBY_T_REGEXP
 Old name of RUBY_T_REGEXP. More...
 
#define T_STRING   RUBY_T_STRING
 Old name of RUBY_T_STRING. More...
 
#define T_STRUCT   RUBY_T_STRUCT
 Old name of RUBY_T_STRUCT. More...
 
#define T_SYMBOL   RUBY_T_SYMBOL
 Old name of RUBY_T_SYMBOL. More...
 
#define T_TRUE   RUBY_T_TRUE
 Old name of RUBY_T_TRUE. More...
 
#define T_UNDEF   RUBY_T_UNDEF
 Old name of RUBY_T_UNDEF. More...
 
#define T_ZOMBIE   RUBY_T_ZOMBIE
 Old name of RUBY_T_ZOMBIE. More...
 
#define BUILTIN_TYPE   RB_BUILTIN_TYPE
 Old name of RB_BUILTIN_TYPE. More...
 
#define DYNAMIC_SYM_P   RB_DYNAMIC_SYM_P
 Old name of RB_DYNAMIC_SYM_P. More...
 
#define RB_INTEGER_TYPE_P   rb_integer_type_p
 Old name of rb_integer_type_p. More...
 
#define SYMBOL_P   RB_SYMBOL_P
 Old name of RB_SYMBOL_P. More...
 
#define rb_type_p   RB_TYPE_P
 Just another name of RB_TYPE_P. More...
 
#define TYPE(_)   RBIMPL_CAST((int)rb_type(_))
 Old name of rb_type. More...
 

Enumerations

enum  ruby_value_type {
  RUBY_T_NONE = 0x00 , RUBY_T_OBJECT = 0x01 , RUBY_T_CLASS = 0x02 , RUBY_T_MODULE = 0x03 ,
  RUBY_T_FLOAT = 0x04 , RUBY_T_STRING = 0x05 , RUBY_T_REGEXP = 0x06 , RUBY_T_ARRAY = 0x07 ,
  RUBY_T_HASH = 0x08 , RUBY_T_STRUCT = 0x09 , RUBY_T_BIGNUM = 0x0a , RUBY_T_FILE = 0x0b ,
  RUBY_T_DATA = 0x0c , RUBY_T_MATCH = 0x0d , RUBY_T_COMPLEX = 0x0e , RUBY_T_RATIONAL = 0x0f ,
  RUBY_T_NIL = 0x11 , RUBY_T_TRUE = 0x12 , RUBY_T_FALSE = 0x13 , RUBY_T_SYMBOL = 0x14 ,
  RUBY_T_FIXNUM = 0x15 , RUBY_T_UNDEF = 0x16 , RUBY_T_IMEMO = 0x1a , RUBY_T_NODE = 0x1b ,
  RUBY_T_ICLASS = 0x1c , RUBY_T_ZOMBIE = 0x1d , RUBY_T_MOVED = 0x1e , RUBY_T_MASK = 0x1f
}
 C-level type of an object. More...
 

Functions

static enum ruby_value_type RB_BUILTIN_TYPE (VALUE obj)
 Queries the type of the object. More...
 
static bool rb_integer_type_p (VALUE obj)
 Queries if the object is an instance of rb_cInteger. More...
 
static enum ruby_value_type rb_type (VALUE obj)
 Identical to RB_BUILTIN_TYPE(), except it can also accept special constants. More...
 
static bool RB_FLOAT_TYPE_P (VALUE obj)
 Queries if the object is an instance of rb_cFloat. More...
 
static bool RB_DYNAMIC_SYM_P (VALUE obj)
 Queries if the object is a dynamic symbol. More...
 
static bool RB_SYMBOL_P (VALUE obj)
 Queries if the object is an instance of rb_cSymbol. More...
 
static bool RB_TYPE_P (VALUE obj, enum ruby_value_type t)
 Queries if the given object is of given type. More...
 
static void Check_Type (VALUE v, enum ruby_value_type t)
 Identical to RB_TYPE_P(), except it raises exceptions on predication failure. More...
 

Detailed Description

Defines enum ruby_value_type.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
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.

Definition in file value_type.h.

Macro Definition Documentation

◆ rb_type_p

#define rb_type_p   RB_TYPE_P

Just another name of RB_TYPE_P.

Definition at line 89 of file value_type.h.

Enumeration Type Documentation

◆ ruby_value_type

C-level type of an object.

Enumerator
RUBY_T_NONE 

Non-object (swept etc.)

RUBY_T_OBJECT 
See also
struct RObject
RUBY_T_CLASS 
See also
struct RClass and rb_cClass
RUBY_T_MODULE 
See also
struct RClass and rb_cModule
RUBY_T_FLOAT 
See also
struct RFloat
RUBY_T_STRING 
See also
struct RString
RUBY_T_REGEXP 
See also
struct RRegexp
RUBY_T_ARRAY 
See also
struct RArray
RUBY_T_HASH 
See also
struct RHash
RUBY_T_STRUCT 
See also
struct RStruct
RUBY_T_BIGNUM 
See also
struct RBignum
RUBY_T_FILE 
See also
struct RFile
RUBY_T_DATA 
See also
struct RTypedData
RUBY_T_MATCH 
See also
struct RMatch
RUBY_T_COMPLEX 
See also
struct RComplex
RUBY_T_RATIONAL 
See also
struct RRational
RUBY_T_NIL 
See also
RUBY_Qnil
RUBY_T_TRUE 
See also
RUBY_Qfalse
RUBY_T_FALSE 
See also
RUBY_Qtrue
RUBY_T_SYMBOL 
See also
struct RSymbol
RUBY_T_FIXNUM 

Integers formerly known as Fixnums.

RUBY_T_UNDEF 
See also
RUBY_Qundef
RUBY_T_IMEMO 
See also
struct RIMemo
RUBY_T_NODE 
See also
struct RNode
RUBY_T_ICLASS 

Hidden classes known as IClasses.

RUBY_T_ZOMBIE 
See also
struct RZombie
RUBY_T_MOVED 
See also
struct RMoved
RUBY_T_MASK 

Bitmask of ruby_value_type.

Definition at line 111 of file value_type.h.

Function Documentation

◆ Check_Type()

static void Check_Type ( VALUE  v,
enum ruby_value_type  t 
)
inlinestatic

Identical to RB_TYPE_P(), except it raises exceptions on predication failure.

Parameters
[in]vAn object.
[in]tA type.
Exceptions
rb_eTypeErrorobj is not of type t.
rb_eFatalobj is corrupt.
Postcondition
Upon successful return obj is guaranteed to have type t.

Definition at line 433 of file value_type.h.

Referenced by rb_class_modify_check(), rb_class_new(), rb_class_new_instance_kw(), rb_get_alloc_func(), rb_memory_view_register(), rb_mod_include_p(), rb_obj_alloc(), and RTYPEDDATA_P().

◆ RB_BUILTIN_TYPE()

static enum ruby_value_type RB_BUILTIN_TYPE ( VALUE  obj)
inlinestatic

Queries the type of the object.

Parameters
[in]objObject in question.
Precondition
obj must not be a special constant.
Returns
The type of obj.

Definition at line 169 of file value_type.h.

Referenced by RB_DYNAMIC_SYM_P(), RB_FLOAT_TYPE_P(), and rb_integer_type_p().

◆ RB_DYNAMIC_SYM_P()

static bool RB_DYNAMIC_SYM_P ( VALUE  obj)
inlinestatic

Queries if the object is a dynamic symbol.

Parameters
[in]objObject in question.
Return values
trueIt is.
falseIt isn't.

Definition at line 287 of file value_type.h.

Referenced by RB_SYMBOL_P().

◆ RB_FLOAT_TYPE_P()

static bool RB_FLOAT_TYPE_P ( VALUE  obj)
inlinestatic

Queries if the object is an instance of rb_cFloat.

Parameters
[in]objObject in question.
Return values
trueIt is.
falseIt isn't.

Definition at line 264 of file value_type.h.

Referenced by rb_big_cmp(), rb_big_eq(), rb_big_minus(), rb_big_mul(), rb_big_plus(), rb_big_pow(), rb_check_to_float(), rb_complex_abs(), and rb_num2long().

◆ rb_integer_type_p()

static bool rb_integer_type_p ( VALUE  obj)
inlinestatic

Queries if the object is an instance of rb_cInteger.

Parameters
[in]objObject in question.
Return values
trueIt is.
falseIt isn't.

Definition at line 204 of file value_type.h.

◆ RB_SYMBOL_P()

static bool RB_SYMBOL_P ( VALUE  obj)
inlinestatic

Queries if the object is an instance of rb_cSymbol.

Parameters
[in]objObject in question.
Return values
trueIt is.
falseIt isn't.

Definition at line 307 of file value_type.h.

◆ rb_type()

static enum ruby_value_type rb_type ( VALUE  obj)
inlinestatic

Identical to RB_BUILTIN_TYPE(), except it can also accept special constants.

Parameters
[in]objObject in question.
Returns
The type of obj.

Definition at line 204 of file value_type.h.

◆ RB_TYPE_P()

static bool RB_TYPE_P ( VALUE  obj,
enum ruby_value_type  t 
)
inlinestatic