1 #ifndef INTERNAL_STRING_H
2 #define INTERNAL_STRING_H
11 #include "ruby/internal/config.h"
13 #include "internal/compilers.h"
18 #define STR_NOEMBED FL_USER1
19 #define STR_SHARED FL_USER2
21 #ifdef rb_fstring_cstr
22 # undef rb_fstring_cstr
27 VALUE rb_fstring_cstr(
const char *str);
29 int rb_str_buf_cat_escaped_char(
VALUE result,
unsigned int c,
int unicode_p);
30 int rb_str_symname_p(
VALUE);
32 char *rb_str_fill_terminator(
VALUE str,
const int termlen);
33 void rb_str_change_terminator_length(
VALUE str,
const int oldtermlen,
const int termlen);
37 VALUE rb_str_cat_conv_enc_opts(
VALUE newstr,
long ofs,
const char *ptr,
long len,
41 size_t rb_str_memsize(
VALUE);
42 char *rb_str_to_cstr(
VALUE str);
43 const char *ruby_escaped_char(
int c);
44 void rb_str_make_independent(
VALUE str);
47 static inline bool STR_EMBED_P(
VALUE str);
48 static inline bool STR_SHARED_P(
VALUE str);
50 static inline VALUE QUOTE_ID(
ID v);
51 static inline bool is_ascii_string(
VALUE str);
52 static inline bool is_broken_string(
VALUE str);
53 static inline VALUE rb_str_eql_internal(
const VALUE str1,
const VALUE str2);
55 RUBY_SYMBOL_EXPORT_BEGIN
58 void rb_str_tmp_frozen_release(
VALUE str,
VALUE tmp);
62 RUBY_SYMBOL_EXPORT_END
64 MJIT_SYMBOL_EXPORT_BEGIN
65 VALUE rb_fstring_new(
const char *ptr,
long len);
68 VALUE rb_str_concat_literals(
size_t num,
const VALUE *strary);
70 VALUE rb_id_quote_unprintable(
ID);
71 VALUE rb_sym_proc_call(
ID mid,
int argc,
const VALUE *argv,
int kw_splat,
VALUE passed_proc);
75 MJIT_SYMBOL_EXPORT_END
77 #define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
78 #define rb_fstring_literal(str) rb_fstring_lit(str)
79 #define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
80 #define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
85 return rb_str_quote_unprintable(v);
91 return rb_id_quote_unprintable(i);
95 STR_EMBED_P(
VALUE str)
101 STR_SHARED_P(
VALUE str)
107 is_ascii_string(
VALUE str)
113 is_broken_string(
VALUE str)
121 rb_str_eql_internal(
const VALUE str1,
const VALUE str2)
124 const char *ptr1, *ptr2;
130 if (memcmp(ptr1, ptr2, len) == 0)
135 #if __has_builtin(__builtin_constant_p)
136 # define rb_fstring_cstr(str) \
137 (__builtin_constant_p(str) ? \
138 rb_fstring_new((str), (long)strlen(str)) : \
139 (rb_fstring_cstr)(str))
#define ENC_CODERANGE_7BIT
Old name of RUBY_ENC_CODERANGE_7BIT.
#define ELTS_SHARED
Old name of RUBY_ELTS_SHARED.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define Qtrue
Old name of RUBY_Qtrue.
#define Qfalse
Old name of RUBY_Qfalse.
#define ENC_CODERANGE_BROKEN
Old name of RUBY_ENC_CODERANGE_BROKEN.
#define FL_ALL_RAW
Old name of RB_FL_ALL_RAW.
int rb_enc_str_coderange(VALUE str)
Scans the passed string to collect its code range.
int rb_str_comparable(VALUE str1, VALUE str2)
Checks if two strings are comparable each other or not.
static char * RSTRING_PTR(VALUE str)
Queries the contents pointer of the string.
static long RSTRING_LEN(VALUE str)
Queries the length of the string.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.