Ruby: include/ruby/internal/arithmetic/char.h Source File

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.*/
25#include "ruby/internal/attr/artificial.h"
26#include "ruby/internal/attr/const.h"
27#include "ruby/internal/attr/constexpr.h"
28#include "ruby/internal/cast.h"
29#include "ruby/internal/core/rstring.h"
30#include "ruby/internal/value_type.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
40 RBIMPL_ATTR_CONST_UNLESS_DEBUG()
41 RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(CXX14)
42 RBIMPL_ATTR_ARTIFICIAL()
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 */
artificial.h
Defines RBIMPL_ATTR_ARTIFICIAL.
RBIMPL_ATTR_ARTIFICIAL
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:43
cast.h
Defines RBIMPL_CAST.
const.h
Defines RBIMPL_ATTR_CONST.
RBIMPL_ATTR_CONST_UNLESS_DEBUG
#define RBIMPL_ATTR_CONST_UNLESS_DEBUG()
Enables RBIMPL_ATTR_CONST iff.
Definition: const.h:41
constexpr.h
RBIMPL_ATTR_CONSTEXPR.
RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG
#define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_)
Enables RBIMPL_ATTR_CONSTEXPR iff.
Definition: constexpr.h:80
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
int.h
Arithmetic conversion between C's int and Ruby's.
RB_NUM2INT
#define RB_NUM2INT
Definition: int.h:38
long.h
Arithmetic conversion between C's long and Ruby's.
rstring.h
Defines struct RString.
VALUE
unsigned long VALUE
Definition: value.h:38
value_type.h
Defines enum ruby_value_type.
RUBY_T_STRING
@ RUBY_T_STRING
Definition: value_type.h:117