mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
RSTRUCT_LEN / RSTRUCT_GET / RSTRUCT_SET all existing in two versions, one public that does type and frozens checks and one private that doesn't. The problem is that this is error prone because the public version is always accessible, but the private one require to include `internal/struct.h`. So you may have some code that rely on the public version, and later on the private header is included and changes the behavior. This already led to introducing a bug in YJIT & ZJIT: https://github.com/ruby/ruby/pull/15835
41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#ifndef INTERNAL_RANGE_H /*-*-C-*-vi:se ft=c:*/
|
|
#define INTERNAL_RANGE_H
|
|
/**
|
|
* @author Ruby developers <ruby-core@ruby-lang.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.
|
|
* @brief Internal header for Range.
|
|
*/
|
|
#include "internal/struct.h" /* for RSTRUCT */
|
|
|
|
/* range.c */
|
|
static inline VALUE RANGE_BEG(VALUE r);
|
|
static inline VALUE RANGE_END(VALUE r);
|
|
static inline VALUE RANGE_EXCL(VALUE r);
|
|
|
|
static inline VALUE
|
|
RANGE_BEG(VALUE r)
|
|
{
|
|
return RSTRUCT_GET_RAW(r, 0);
|
|
}
|
|
|
|
static inline VALUE
|
|
RANGE_END(VALUE r)
|
|
{
|
|
return RSTRUCT_GET_RAW(r, 1);
|
|
}
|
|
|
|
static inline VALUE
|
|
RANGE_EXCL(VALUE r)
|
|
{
|
|
return RSTRUCT_GET_RAW(r, 2);
|
|
}
|
|
|
|
VALUE
|
|
rb_range_component_beg_len(VALUE b, VALUE e, int excl,
|
|
long *begp, long *lenp, long len, int err);
|
|
|
|
#endif /* INTERNAL_RANGE_H */
|