Ruby: include/ruby/internal/core/rregexp.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

rregexp.h
Go to the documentation of this file.
1#ifndef RBIMPL_RREGEXP_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RREGEXP_H
23#include "ruby/internal/attr/artificial.h"
24#include "ruby/internal/attr/pure.h"
25#include "ruby/internal/cast.h"
26#include "ruby/internal/core/rbasic.h"
27#include "ruby/internal/core/rstring.h"
28#include "ruby/internal/value.h"
29#include "ruby/internal/value_type.h"
30
31#define RREGEXP(obj) RBIMPL_CAST((struct RRegexp *)(obj))
32#define RREGEXP_PTR(obj) (RREGEXP(obj)->ptr)
34#define RREGEXP_SRC RREGEXP_SRC
35#define RREGEXP_SRC_PTR RREGEXP_SRC_PTR
36#define RREGEXP_SRC_LEN RREGEXP_SRC_LEN
37#define RREGEXP_SRC_END RREGEXP_SRC_END
40struct re_patter_buffer; /* a.k.a. OnigRegexType, defined in onigmo.h */
41
42 struct RRegexp {
43 struct RBasic basic;
44 struct re_pattern_buffer *ptr;
45 const VALUE src;
46 unsigned long usecnt;
47};
48
49 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
50 RBIMPL_ATTR_ARTIFICIAL()
51static inline VALUE
52RREGEXP_SRC(VALUE rexp)
53{
54 RBIMPL_ASSERT_TYPE(rexp, RUBY_T_REGEXP);
55 VALUE ret = RREGEXP(rexp)->src;
56 RBIMPL_ASSERT_TYPE(ret, RUBY_T_STRING);
57 return ret;
58}
59
60 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
61 RBIMPL_ATTR_ARTIFICIAL()
62static inline char *
63RREGEXP_SRC_PTR(VALUE rexp)
64{
65 return RSTRING_PTR(RREGEXP_SRC(rexp));
66}
67
68 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
69 RBIMPL_ATTR_ARTIFICIAL()
70static inline long
71RREGEXP_SRC_LEN(VALUE rexp)
72{
73 return RSTRING_LEN(RREGEXP_SRC(rexp));
74}
75
76 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
77 RBIMPL_ATTR_ARTIFICIAL()
78static inline char *
79RREGEXP_SRC_END(VALUE rexp)
80{
81 return RSTRING_END(RREGEXP_SRC(rexp));
82}
83
84#endif /* RBIMPL_RREGEXP_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.
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE_UNLESS_DEBUG
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE iff.
Definition: pure.h:38
rbasic.h
Defines struct RBasic.
RREGEXP
#define RREGEXP(obj)
Definition: rregexp.h:31
rstring.h
Defines struct RString.
RBasic
Definition: rbasic.h:47
RRegexp
Definition: rregexp.h:42
RRegexp::basic
struct RBasic basic
Definition: rregexp.h:43
RRegexp::src
const VALUE src
Definition: rregexp.h:45
RRegexp::usecnt
unsigned long usecnt
Definition: rregexp.h:46
RRegexp::ptr
struct re_pattern_buffer * ptr
Definition: rregexp.h:44
re_pattern_buffer
Definition: onigmo.h:755
value.h
Defines VALUE and ID.
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
RUBY_T_REGEXP
@ RUBY_T_REGEXP
Definition: value_type.h:118