Ruby
3.4.0dev (2024-11-05 revision e440268d51fe02b303e3817a7a733a0dac1c5091)
|
Defines struct RMatch. More...
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/value.h"
#include "ruby/internal/value_type.h"
#include "ruby/assert.h"
Go to the source code of this file.
Data Structures | |
struct | rmatch_offset |
Represents the region of a capture group. More... | |
struct | rb_matchext_struct |
Represents a match. More... | |
struct | RMatch |
Regular expression execution context. More... | |
Macros | |
#define | RMATCH(obj) RBIMPL_CAST((struct RMatch *)(obj)) |
Convenient casting macro. More... | |
#define | RMATCH_EXT(m) ((rb_matchext_t *)((char *)(m) + sizeof(struct RMatch))) |
Typedefs | |
typedef struct re_pattern_buffer | Regexp |
Old name of re_pattern_buffer. More... | |
typedef struct rb_matchext_struct | rb_matchext_t |
Functions | |
static struct re_registers * | RMATCH_REGS (VALUE match) |
Queries the raw re_registers. More... | |
Defines struct RMatch.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. Definition in file rmatch.h.
#define RMATCH | ( | obj | ) | RBIMPL_CAST((struct RMatch *)(obj)) |
|
inlinestatic |
Queries the raw re_registers.
[in] | match | A match object |
match
must be of RMatch. String#gsub
and its family. They take strings as arguments, like "foo".sub("bar", "baz")
. On such situations, in order to optimise memory allocations, these methods do not involve regular expressions at all. They just sequentially scan the receiver. Okay. The story begins here. Even when they do not kick our regexp engine, there must be backref objects e.g. $&
. But how? You know what? Ruby fakes them. It allocates an empty RMatch and behaves as if there were execution contexts. In reality there weren't. No re_registers are allocated then. There is no way for this function but to return NULL for those fake RMatch. This is the reason for the nullability of this function. Definition at line 138 of file rmatch.h.
Referenced by rb_reg_match_last(), rb_reg_match_post(), rb_reg_match_pre(), rb_reg_nth_defined(), and rb_reg_nth_match().