(71749b882622c03028dfc55f40e5c3cceb24eaaf)
Defines struct RMatch.
More...
Go to the source code of this file.
|
| #define | RMATCH(obj) RBIMPL_CAST((struct RMatch *)(obj)) |
| | Convenient casting macro.
|
| |
Defines struct RMatch.
- Author
- Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
- Copyright
- This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.
- Warning
- Symbols prefixed with either
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.
- Note
- To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance
__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.
◆ RMATCH
| #define RMATCH |
( |
|
obj | ) |
RBIMPL_CAST((struct RMatch *)(obj)) |
Convenient casting macro.
- Parameters
-
| obj | An object, which is in fact an RMatch. |
- Returns
- The passed object casted to RMatch.
Definition at line 37 of file rmatch.h.
◆ RMATCH_REGS()
Queries the raw re_registers.
- Parameters
-
- Precondition
match must be of RMatch.
- Returns
- Its execution result.
- Note
- Good. So you are aware of the fact that it could return NULL. Yes. It actually does. This is a really bizarre thing. The situation is about
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 150 of file rmatch.h.