Ruby 4.1.0dev (2026-05-15 revision fff4b3ef2e3e309e7a84288de53c189aa3d45fed)
rmatch.h
Go to the documentation of this file.
1#ifndef RBIMPL_RMATCH_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RMATCH_H
25#include "ruby/internal/cast.h"
27#include "ruby/internal/value.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
53
66 long beg;
67 long end;
68};
69
79struct RMatch {
80
82 struct RBasic basic;
83
88
92 VALUE regexp; /* RRegexp */
93
96
99
102
104 int capa;
105
110 union {
111 OnigPosition embed[1];
112 struct re_registers onig;
113 } as;
114};
115
125void rb_match_ensure_onig(VALUE match);
127
149static inline struct re_registers *
151{
152 RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
153 rb_match_ensure_onig(match);
154 return &RMATCH(match)->as.onig;
155}
156
157#endif /* RBIMPL_RMATCH_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#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 RBIMPL_ATTR_PURE.
Defines struct RBasic.
#define RMATCH(obj)
Convenient casting macro.
Definition rmatch.h:37
static struct re_registers * RMATCH_REGS(VALUE match)
Queries the raw re_registers.
Definition rmatch.h:150
Ruby object's base components.
Definition rbasic.h:69
Regular expression execution context.
Definition rmatch.h:79
VALUE regexp
The expression of this match.
Definition rmatch.h:92
union RMatch::@55 as
"Registers" of a match.
struct rmatch_offset * char_offset
Capture group offsets, in C array.
Definition rmatch.h:98
int char_offset_num_allocated
Number of rmatch_offset that ::rmatch::char_offset holds.
Definition rmatch.h:95
int num_regs
Number of capture-group registers.
Definition rmatch.h:101
int capa
Capacity of as.embed, in OnigPosition slots.
Definition rmatch.h:104
struct RBasic basic
Basic part, including flags and class.
Definition rmatch.h:82
VALUE str
The target string that the match was made against.
Definition rmatch.h:87
Represents the region of a capture group.
Definition rmatch.h:65
long beg
Beginning of a group.
Definition rmatch.h:66
long end
End of a group.
Definition rmatch.h:67
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
Defines enum ruby_value_type.
@ RUBY_T_MATCH
Definition value_type.h:128