Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
coderange.h
Go to the documentation of this file.
1#ifndef RUBY_INTERNAL_ENCODING_CODERANGE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_INTERNAL_ENCODING_CODERANGE_H
28#include "ruby/internal/value.h"
29
31
32
52
64static inline int
65rb_enc_coderange_clean_p(int cr)
66{
67 return (cr ^ (cr >> 1)) & RUBY_ENC_CODERANGE_7BIT;
68}
69
79static inline bool
81{
82 return rb_enc_coderange_clean_p(cr);
83}
84
96{
98
99 return RBIMPL_CAST((enum ruby_coderange_type)ret);
100}
101
113static inline bool
118
128static inline void
134
143static inline void
148
150/* assumed ASCII compatibility */
161static inline enum ruby_coderange_type
163{
164 if (a == RUBY_ENC_CODERANGE_7BIT) {
165 return b;
166 }
167 else if (a != RUBY_ENC_CODERANGE_VALID) {
169 }
170 else if (b == RUBY_ENC_CODERANGE_7BIT) {
172 }
173 else {
174 return b;
175 }
176}
177
178#define ENC_CODERANGE_MASK RUBY_ENC_CODERANGE_MASK
179#define ENC_CODERANGE_UNKNOWN RUBY_ENC_CODERANGE_UNKNOWN
180#define ENC_CODERANGE_7BIT RUBY_ENC_CODERANGE_7BIT
181#define ENC_CODERANGE_VALID RUBY_ENC_CODERANGE_VALID
182#define ENC_CODERANGE_BROKEN RUBY_ENC_CODERANGE_BROKEN
183#define ENC_CODERANGE_CLEAN_P(cr) RB_ENC_CODERANGE_CLEAN_P(cr)
184#define ENC_CODERANGE(obj) RB_ENC_CODERANGE(obj)
185#define ENC_CODERANGE_ASCIIONLY(obj) RB_ENC_CODERANGE_ASCIIONLY(obj)
186#define ENC_CODERANGE_SET(obj,cr) RB_ENC_CODERANGE_SET(obj,cr)
187#define ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_CLEAR(obj)
188#define ENC_CODERANGE_AND(a, b) RB_ENC_CODERANGE_AND(a, b)
189#define ENCODING_CODERANGE_SET(obj, encindex, cr) RB_ENCODING_CODERANGE_SET(obj, encindex, cr)
192#define RB_ENC_CODERANGE RB_ENC_CODERANGE
193#define RB_ENC_CODERANGE_AND RB_ENC_CODERANGE_AND
194#define RB_ENC_CODERANGE_ASCIIONLY RB_ENC_CODERANGE_ASCIIONLY
195#define RB_ENC_CODERANGE_CLEAN_P RB_ENC_CODERANGE_CLEAN_P
196#define RB_ENC_CODERANGE_CLEAR RB_ENC_CODERANGE_CLEAR
197#define RB_ENC_CODERANGE_SET RB_ENC_CODERANGE_SET
201
202#endif /* RUBY_INTERNAL_ENCODING_CODERANGE_H */
static void RB_ENC_CODERANGE_CLEAR(VALUE obj)
Destructively clears the passed object's (inline) code range.
Definition coderange.h:144
ruby_coderange_type
What rb_enc_str_coderange() returns.
Definition coderange.h:33
@ RUBY_ENC_CODERANGE_MASK
Where the coderange resides.
Definition coderange.h:48
@ RUBY_ENC_CODERANGE_VALID
The object's encoding and contents are consistent each other.
Definition coderange.h:42
@ RUBY_ENC_CODERANGE_7BIT
The object holds 0 to 127 inclusive and nothing else.
Definition coderange.h:39
@ RUBY_ENC_CODERANGE_UNKNOWN
The object's coderange is unclear yet.
Definition coderange.h:36
@ RUBY_ENC_CODERANGE_BROKEN
The object holds invalid/malformed/broken character(s).
Definition coderange.h:45
static void RB_ENC_CODERANGE_SET(VALUE obj, enum ruby_coderange_type cr)
Destructively modifies the passed object so that its (inline) code range is the passed one.
Definition coderange.h:129
static enum ruby_coderange_type RB_ENC_CODERANGE(VALUE obj)
Queries the (inline) code range of the passed object.
Definition coderange.h:95
static enum ruby_coderange_type RB_ENC_CODERANGE_AND(enum ruby_coderange_type a, enum ruby_coderange_type b)
"Mix" two code ranges into one.
Definition coderange.h:162
static bool RB_ENC_CODERANGE_CLEAN_P(enum ruby_coderange_type cr)
Queries if a code range is "clean".
Definition coderange.h:80
static bool RB_ENC_CODERANGE_ASCIIONLY(VALUE obj)
Queries the (inline) code range of the passed object is RUBY_ENC_CODERANGE_7BIT.
Definition coderange.h:114
Defines RBIMPL_ATTR_CONST.
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
Defines enum ruby_fl_type.
static VALUE RB_FL_TEST_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_TEST().
Definition fl_type.h:469
static void RB_FL_SET_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_SET().
Definition fl_type.h:606
static void RB_FL_UNSET_RAW(VALUE obj, VALUE flags)
This is an implementation detail of RB_FL_UNSET().
Definition fl_type.h:666
@ RUBY_FL_USER9
User-defined flag.
Definition fl_type.h:337
@ RUBY_FL_USER8
User-defined flag.
Definition fl_type.h:336
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition pure.h:38
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40