Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
char.h
Go to the documentation of this file.
1#ifndef RBIMPL_ARITHMETIC_CHAR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ARITHMETIC_CHAR_H
23#include "ruby/internal/arithmetic/int.h" /* NUM2INT is here, but */
24#include "ruby/internal/arithmetic/long.h" /* INT2FIX is here.*/
28#include "ruby/internal/cast.h"
31
32#define RB_NUM2CHR rb_num2char_inline
33#define NUM2CHR RB_NUM2CHR
34#define CHR2FIX RB_CHR2FIX
35
37#define RB_CHR2FIX RB_CHR2FIX
43static inline VALUE
44RB_CHR2FIX(unsigned char c)
45{
46 return RB_INT2FIX(c);
47}
48
49static inline char
50rb_num2char_inline(VALUE x)
51{
52 if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
53 return RSTRING_PTR(x)[0];
54 else
55 return RBIMPL_CAST((char)RB_NUM2INT(x));
56}
57
58#endif /* RBIMPL_ARITHMETIC_CHAR_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:43
Defines RBIMPL_CAST.
Defines RBIMPL_ATTR_CONST.
#define RBIMPL_ATTR_CONST_UNLESS_DEBUG()
Enables RBIMPL_ATTR_CONST iff.
Definition: const.h:41
RBIMPL_ATTR_CONSTEXPR.
#define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_)
Enables RBIMPL_ATTR_CONSTEXPR iff.
Definition: constexpr.h:80
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
Arithmetic conversion between C's int and Ruby's.
#define RB_NUM2INT
Definition: int.h:38
Arithmetic conversion between C's long and Ruby's.
Defines struct RString.
unsigned long VALUE
Definition: value.h:38
Defines enum ruby_value_type.
@ RUBY_T_STRING
Definition: value_type.h:117