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

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

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 rb_matchext_struct {
76 struct re_registers regs;
77
79 struct rmatch_offset *char_offset;
80
82 int char_offset_num_allocated;
83};
84
85typedef struct rb_matchext_struct rb_matchext_t;
86
96 struct RMatch {
97
99 struct RBasic basic;
100
104 VALUE str;
105
109 VALUE regexp; /* RRegexp */
110};
111
112#define RMATCH_EXT(m) ((rb_matchext_t *)((char *)(m) + sizeof(struct RMatch)))
113
114 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
115 RBIMPL_ATTR_ARTIFICIAL()
137static inline struct re_registers *
138RMATCH_REGS(VALUE match)
139{
140 RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
141 return &RMATCH_EXT(match)->regs;
142}
143
144#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
inline
#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
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_REGS
static struct re_registers * RMATCH_REGS(VALUE match)
Queries the raw re_registers.
Definition rmatch.h:138
RBasic
Ruby object's base components.
Definition rbasic.h:63
RMatch
Regular expression execution context.
Definition rmatch.h:96
RMatch::regexp
VALUE regexp
The expression of this match.
Definition rmatch.h:109
RMatch::basic
struct RBasic basic
Basic part, including flags and class.
Definition rmatch.h:99
RMatch::str
VALUE str
The target string that the match was made against.
Definition rmatch.h:104
rb_matchext_struct
Represents a match.
Definition rmatch.h:71
rb_matchext_struct::char_offset
struct rmatch_offset * char_offset
Capture group offsets, in C array.
Definition rmatch.h:79
rb_matchext_struct::char_offset_num_allocated
int char_offset_num_allocated
Number of rmatch_offset that ::rmatch::char_offset holds.
Definition rmatch.h:82
rb_matchext_struct::regs
struct re_registers regs
"Registers" of a match.
Definition rmatch.h:76
re_pattern_buffer
Definition onigmo.h:756
re_registers
Definition onigmo.h:717
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
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:128