Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
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
42 struct re_patter_buffer; /* a.k.a. OnigRegexType, defined in onigmo.h */
43 struct 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 
76  struct re_registers regs;
77 
80 
83 };
84 
85 typedef struct rb_matchext_struct rb_matchext_t;
86 
96 struct RMatch {
97 
99  struct RBasic basic;
100 
105 
109  VALUE regexp; /* RRegexp */
110 };
111 
112 #define RMATCH_EXT(m) ((rb_matchext_t *)((char *)(m) + sizeof(struct RMatch)))
113 
137 static inline struct re_registers *
139 {
140  RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
141  return &RMATCH_EXT(match)->regs;
142 }
143 
144 #endif /* RBIMPL_RMATCH_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:41
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition: defines.h:88
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition: pure.h:38
Defines struct RBasic.
static struct re_registers * RMATCH_REGS(VALUE match)
Queries the raw re_registers.
Definition: rmatch.h:138
Ruby object's base components.
Definition: rbasic.h:63
Regular expression execution context.
Definition: rmatch.h:96
VALUE regexp
The expression of this match.
Definition: rmatch.h:109
struct RBasic basic
Basic part, including flags and class.
Definition: rmatch.h:99
VALUE str
The target string that the match was made against.
Definition: rmatch.h:104
Represents a match.
Definition: rmatch.h:71
struct rmatch_offset * char_offset
Capture group offsets, in C array.
Definition: rmatch.h:79
int char_offset_num_allocated
Number of rmatch_offset that ::rmatch::char_offset holds.
Definition: rmatch.h:82
struct re_registers regs
"Registers" of a match.
Definition: rmatch.h:76
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