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

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

rmatch.h
Go to the documentation of this file.
1#ifndef RBIMPL_RMATCH_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RMATCH_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/value.h"
28#include "ruby/internal/value_type.h"
29#include "ruby/assert.h"
30
37#define RMATCH(obj) RBIMPL_CAST((struct RMatch *)(obj))
39#define RMATCH_REGS RMATCH_REGS
42struct re_patter_buffer; /* a.k.a. OnigRegexType, defined in onigmo.h */
43struct re_registers; /* Also in onigmo.h */
44
52 typedef struct re_pattern_buffer Regexp;
53
65 struct rmatch_offset {
66 long beg;
67 long end;
68};
69
71 struct rmatch {
76 struct re_registers regs;
77
79 struct rmatch_offset *char_offset;
80
82 int char_offset_num_allocated;
83};
84
94 struct RMatch {
95
97 struct RBasic basic;
98
102 VALUE str;
103
107 struct rmatch *rmatch;
108
112 VALUE regexp; /* RRegexp */
113};
114
115 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
116 RBIMPL_ATTR_ARTIFICIAL()
138static inline struct re_registers *
139RMATCH_REGS(VALUE match)
140{
141 RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
142 RBIMPL_ASSERT_OR_ASSUME(RMATCH(match)->rmatch != NULL);
143 return &RMATCH(match)->rmatch->regs;
144}
145
146#endif /* RBIMPL_RMATCH_H */
artificial.h
Defines RBIMPL_ATTR_ARTIFICIAL.
RBIMPL_ATTR_ARTIFICIAL
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition artificial.h:43
assert.h
RBIMPL_ASSERT_OR_ASSUME
#define RBIMPL_ASSERT_OR_ASSUME(expr)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Definition assert.h:229
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE_UNLESS_DEBUG
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition pure.h:38
rbasic.h
Defines struct RBasic.
RMATCH
#define RMATCH(obj)
Convenient casting macro.
Definition rmatch.h:37
RMATCH_REGS
static struct re_registers * RMATCH_REGS(VALUE match)
Queries the raw re_registers.
Definition rmatch.h:139
RBasic
Ruby's object's, base components.
Definition rbasic.h:64
RMatch
Regular expression execution context.
Definition rmatch.h:94
RMatch::regexp
VALUE regexp
The expression of this match.
Definition rmatch.h:112
RMatch::rmatch
struct rmatch * rmatch
The result of this match.
Definition rmatch.h:107
RMatch::basic
struct RBasic basic
Basic part, including flags and class.
Definition rmatch.h:97
RMatch::str
VALUE str
The target string that the match was made against.
Definition rmatch.h:102
re_pattern_buffer
Definition onigmo.h:757
re_registers
Definition onigmo.h:716
rmatch_offset
Represents the region of a capture group.
Definition rmatch.h:65
rmatch_offset::beg
long beg
Beginning of a group.
Definition rmatch.h:66
rmatch_offset::end
long end
End of a group.
Definition rmatch.h:67
rmatch
Represents a match.
Definition rmatch.h:71
rmatch::char_offset_num_allocated
int char_offset_num_allocated
Number of rmatch_offset that rmatch::char_offset holds.
Definition rmatch.h:82
rmatch::char_offset
struct rmatch_offset * char_offset
Capture group offsets, in C array.
Definition rmatch.h:79
rmatch::regs
struct re_registers regs
"Registers" of a match.
Definition rmatch.h:76
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
value_type.h
Defines enum ruby_value_type.
RUBY_T_MATCH
@ RUBY_T_MATCH
Definition value_type.h:127