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

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

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/attr/returns_nonnull.h"
26#include "ruby/internal/cast.h"
27#include "ruby/internal/core/rbasic.h"
28#include "ruby/internal/value.h"
29#include "ruby/internal/value_type.h"
30#include "ruby/assert.h"
31
32#define RMATCH(obj) RBIMPL_CAST((struct RMatch *)(obj))
34#define RMATCH_REGS RMATCH_REGS
37struct re_patter_buffer; /* a.k.a. OnigRegexType, defined in onigmo.h */
38struct re_registers; /* Also in onigmo.h */
39
40/* @shyouhei wonders: is anyone actively using this typedef ...? */
41 typedef struct re_pattern_buffer Regexp;
42
43 struct rmatch_offset {
44 long beg;
45 long end;
46};
47
48 struct rmatch {
49 struct re_registers regs;
50
51 struct rmatch_offset *char_offset;
52 int char_offset_num_allocated;
53};
54
55 struct RMatch {
56 struct RBasic basic;
57 VALUE str;
58 struct rmatch *rmatch;
59 VALUE regexp; /* RRegexp */
60};
61
62 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
63 RBIMPL_ATTR_RETURNS_NONNULL()
64 RBIMPL_ATTR_ARTIFICIAL()
65static inline struct re_registers *
66RMATCH_REGS(VALUE match)
67{
68 RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
69 RBIMPL_ASSERT_OR_ASSUME(RMATCH(match)->rmatch != NULL);
70 return &RMATCH(match)->rmatch->regs;
71}
72
73#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
cast.h
Defines RBIMPL_CAST.
match
unsigned char match[65280+2]
Definition: gun.c:165
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.
NULL
#define NULL
Definition: regenc.h:69
returns_nonnull.h
Defines RBIMPL_ATTR_RETURNS_NONNULL.
RBIMPL_ATTR_RETURNS_NONNULL
#define RBIMPL_ATTR_RETURNS_NONNULL()
Wraps (or simulates) __attribute__((returns_nonnull))
Definition: returns_nonnull.h:34
RMATCH
#define RMATCH(obj)
Definition: rmatch.h:32
RBasic
Definition: rbasic.h:47
RMatch
Definition: rmatch.h:55
RMatch::regexp
VALUE regexp
Definition: rmatch.h:59
RMatch::rmatch
struct rmatch * rmatch
Definition: rmatch.h:58
RMatch::basic
struct RBasic basic
Definition: rmatch.h:56
RMatch::str
VALUE str
Definition: rmatch.h:57
re_pattern_buffer
Definition: onigmo.h:755
re_registers
Definition: onigmo.h:716
rmatch_offset
Definition: rmatch.h:43
rmatch_offset::beg
long beg
Definition: rmatch.h:44
rmatch_offset::end
long end
Definition: rmatch.h:45
rmatch
Definition: rmatch.h:48
rmatch::char_offset_num_allocated
int char_offset_num_allocated
Definition: rmatch.h:52
rmatch::char_offset
struct rmatch_offset * char_offset
Definition: rmatch.h:51
rmatch::regs
struct re_registers regs
Definition: rmatch.h:49
value.h
Defines VALUE and ID.
VALUE
unsigned long VALUE
Definition: value.h:38
value_type.h
Defines enum ruby_value_type.
RUBY_T_MATCH
@ RUBY_T_MATCH
Definition: value_type.h:125