зеркало из https://github.com/github/ruby.git
ruby.h: add prefix
* include/ruby/ruby.h: prefix RUBY or RB to global symbols to get rid of name conflicts with other headers. * include/ruby/encoding.h, include/ruby/intern.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
39dfa2f93f
Коммит
1e3a1bbb66
|
@ -1,3 +1,10 @@
|
|||
Sun Sep 13 11:03:13 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h: prefix RUBY or RB to global symbols to get
|
||||
rid of name conflicts with other headers.
|
||||
|
||||
* include/ruby/encoding.h, include/ruby/intern.h: ditto.
|
||||
|
||||
Sun Sep 13 09:38:51 2015 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/ftp.rb (size, modify, create, type, unique, perm, lang,
|
||||
|
|
41
debug.c
41
debug.c
|
@ -25,42 +25,11 @@ const union {
|
|||
enum node_type node_type;
|
||||
enum ruby_method_ids method_ids;
|
||||
enum ruby_id_types id_types;
|
||||
enum ruby_fl_type fl_types;
|
||||
enum ruby_encoding_consts encoding_consts;
|
||||
enum ruby_coderange_type enc_coderange_types;
|
||||
enum ruby_econv_flag_type econv_flag_types;
|
||||
enum {
|
||||
RUBY_ENCODING_INLINE_MAX = ENCODING_INLINE_MAX,
|
||||
RUBY_ENCODING_SHIFT = ENCODING_SHIFT,
|
||||
RUBY_ENC_CODERANGE_MASK = ENC_CODERANGE_MASK,
|
||||
RUBY_ENC_CODERANGE_UNKNOWN = ENC_CODERANGE_UNKNOWN,
|
||||
RUBY_ENC_CODERANGE_7BIT = ENC_CODERANGE_7BIT,
|
||||
RUBY_ENC_CODERANGE_VALID = ENC_CODERANGE_VALID,
|
||||
RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
|
||||
RUBY_FL_PROMOTED0 = FL_PROMOTED0,
|
||||
RUBY_FL_PROMOTED1 = FL_PROMOTED1,
|
||||
RUBY_FL_PROMOTED = FL_PROMOTED0|FL_PROMOTED1,
|
||||
RUBY_FL_FINALIZE = FL_FINALIZE,
|
||||
RUBY_FL_TAINT = FL_TAINT,
|
||||
RUBY_FL_EXIVAR = FL_EXIVAR,
|
||||
RUBY_FL_FREEZE = FL_FREEZE,
|
||||
RUBY_FL_SINGLETON = FL_SINGLETON,
|
||||
RUBY_FL_USER0 = FL_USER0,
|
||||
RUBY_FL_USER1 = FL_USER1,
|
||||
RUBY_FL_USER2 = FL_USER2,
|
||||
RUBY_FL_USER3 = FL_USER3,
|
||||
RUBY_FL_USER4 = FL_USER4,
|
||||
RUBY_FL_USER5 = FL_USER5,
|
||||
RUBY_FL_USER6 = FL_USER6,
|
||||
RUBY_FL_USER7 = FL_USER7,
|
||||
RUBY_FL_USER8 = FL_USER8,
|
||||
RUBY_FL_USER9 = FL_USER9,
|
||||
RUBY_FL_USER10 = FL_USER10,
|
||||
RUBY_FL_USER11 = FL_USER11,
|
||||
RUBY_FL_USER12 = FL_USER12,
|
||||
RUBY_FL_USER13 = FL_USER13,
|
||||
RUBY_FL_USER14 = FL_USER14,
|
||||
RUBY_FL_USER15 = FL_USER15,
|
||||
RUBY_FL_USER16 = FL_USER16,
|
||||
RUBY_FL_USER17 = FL_USER17,
|
||||
RUBY_FL_USER18 = FL_USER18,
|
||||
RUBY_FL_USHIFT = FL_USHIFT,
|
||||
RUBY_NODE_TYPESHIFT = NODE_TYPESHIFT,
|
||||
RUBY_NODE_TYPEMASK = NODE_TYPEMASK,
|
||||
RUBY_NODE_LSHIFT = NODE_LSHIFT,
|
||||
|
@ -68,9 +37,7 @@ const union {
|
|||
} various;
|
||||
} ruby_dummy_gdb_enums;
|
||||
|
||||
const VALUE RUBY_FL_USER19 = FL_USER19;
|
||||
const SIGNED_VALUE RUBY_NODE_LMASK = NODE_LMASK;
|
||||
const VALUE RUBY_ENCODING_MASK = ENCODING_MASK;
|
||||
|
||||
int
|
||||
ruby_debug_print_indent(int level, int debug_level, int indent_level)
|
||||
|
|
|
@ -24,56 +24,89 @@ extern "C" {
|
|||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
||||
#define ENCODING_INLINE_MAX 127
|
||||
#define ENCODING_SHIFT (FL_USHIFT+10)
|
||||
#define ENCODING_MASK (((VALUE)ENCODING_INLINE_MAX)<<ENCODING_SHIFT) /* FL_USER10|FL_USER11|FL_USER12|FL_USER13|FL_USER14|FL_USER15|FL_USER16 */
|
||||
enum ruby_encoding_consts {
|
||||
RUBY_ENCODING_INLINE_MAX = 127,
|
||||
RUBY_ENCODING_SHIFT = (RUBY_FL_USHIFT+10),
|
||||
RUBY_ENCODING_MASK = (RUBY_ENCODING_INLINE_MAX<<RUBY_ENCODING_SHIFT
|
||||
/* RUBY_FL_USER10..RUBY_FL_USER16 */),
|
||||
RUBY_ENCODING_MAXNAMELEN = 42
|
||||
};
|
||||
|
||||
#define ENCODING_SET_INLINED(obj,i) do {\
|
||||
RBASIC(obj)->flags &= ~ENCODING_MASK;\
|
||||
RBASIC(obj)->flags |= (VALUE)(i) << ENCODING_SHIFT;\
|
||||
#define ENCODING_INLINE_MAX RUBY_ENCODING_INLINE_MAX
|
||||
#define ENCODING_SHIFT RUBY_ENCODING_SHIFT
|
||||
#define ENCODING_MASK RUBY_ENCODING_MASK
|
||||
|
||||
#define RB_ENCODING_SET_INLINED(obj,i) do {\
|
||||
RBASIC(obj)->flags &= ~RUBY_ENCODING_MASK;\
|
||||
RBASIC(obj)->flags |= (VALUE)(i) << RUBY_ENCODING_SHIFT;\
|
||||
} while (0)
|
||||
#define ENCODING_SET(obj,i) rb_enc_set_index((obj), (i))
|
||||
#define RB_ENCODING_SET(obj,i) rb_enc_set_index((obj), (i))
|
||||
|
||||
#define ENCODING_GET_INLINED(obj) (int)((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
|
||||
#define ENCODING_GET(obj) \
|
||||
(ENCODING_GET_INLINED(obj) != ENCODING_INLINE_MAX ? \
|
||||
ENCODING_GET_INLINED(obj) : \
|
||||
#define RB_ENCODING_GET_INLINED(obj) \
|
||||
(int)((RBASIC(obj)->flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT)
|
||||
#define RB_ENCODING_GET(obj) \
|
||||
(RB_ENCODING_GET_INLINED(obj) != RUBY_ENCODING_INLINE_MAX ? \
|
||||
RB_ENCODING_GET_INLINED(obj) : \
|
||||
rb_enc_get_index(obj))
|
||||
|
||||
#define ENCODING_IS_ASCII8BIT(obj) (ENCODING_GET_INLINED(obj) == 0)
|
||||
#define RB_ENCODING_IS_ASCII8BIT(obj) (RB_ENCODING_GET_INLINED(obj) == 0)
|
||||
|
||||
#define ENCODING_MAXNAMELEN 42
|
||||
#define ENCODING_SET_INLINED(obj,i) RB_ENCODING_SET_INLINED(obj,i)
|
||||
#define ENCODING_SET(obj,i) RB_ENCODING_SET(obj,i)
|
||||
#define ENCODING_GET_INLINED(obj) RB_ENCODING_GET_INLINED(obj)
|
||||
#define ENCODING_GET(obj) RB_ENCODING_GET(obj)
|
||||
#define ENCODING_IS_ASCII8BIT(obj) RB_ENCODING_IS_ASCII8BIT(obj)
|
||||
#define ENCODING_MAXNAMELEN RUBY_ENCODING_MAXNAMELEN
|
||||
|
||||
enum ruby_coderange_type {
|
||||
RUBY_ENC_CODERANGE_UNKNOWN = 0,
|
||||
RUBY_ENC_CODERANGE_7BIT = ((int)RUBY_FL_USER8),
|
||||
RUBY_ENC_CODERANGE_VALID = ((int)RUBY_FL_USER9),
|
||||
RUBY_ENC_CODERANGE_BROKEN = ((int)(RUBY_FL_USER8|RUBY_FL_USER9)),
|
||||
RUBY_ENC_CODERANGE_MASK = (RUBY_ENC_CODERANGE_7BIT|
|
||||
RUBY_ENC_CODERANGE_VALID|
|
||||
RUBY_ENC_CODERANGE_BROKEN)
|
||||
};
|
||||
|
||||
#define ENC_CODERANGE_MASK ((int)(FL_USER8|FL_USER9))
|
||||
#define ENC_CODERANGE_UNKNOWN 0
|
||||
#define ENC_CODERANGE_7BIT ((int)FL_USER8)
|
||||
#define ENC_CODERANGE_VALID ((int)FL_USER9)
|
||||
#define ENC_CODERANGE_BROKEN ((int)(FL_USER8|FL_USER9))
|
||||
static inline int
|
||||
rb_enc_coderange_clean_p(int cr)
|
||||
{
|
||||
return (cr ^ (cr >> 1)) & ENC_CODERANGE_7BIT;
|
||||
return (cr ^ (cr >> 1)) & RUBY_ENC_CODERANGE_7BIT;
|
||||
}
|
||||
#define ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
|
||||
#define ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & ENC_CODERANGE_MASK)
|
||||
#define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_7BIT)
|
||||
#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \
|
||||
(RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr))
|
||||
#define ENC_CODERANGE_CLEAR(obj) ENC_CODERANGE_SET((obj),0)
|
||||
#define RB_ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
|
||||
#define RB_ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & RUBY_ENC_CODERANGE_MASK)
|
||||
#define RB_ENC_CODERANGE_ASCIIONLY(obj) (RB_ENC_CODERANGE(obj) == RUBY_ENC_CODERANGE_7BIT)
|
||||
#define RB_ENC_CODERANGE_SET(obj,cr) (\
|
||||
RBASIC(obj)->flags = \
|
||||
(RBASIC(obj)->flags & ~RUBY_ENC_CODERANGE_MASK) | (cr))
|
||||
#define RB_ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_SET((obj),0)
|
||||
|
||||
/* assumed ASCII compatibility */
|
||||
#define ENC_CODERANGE_AND(a, b) \
|
||||
((a) == ENC_CODERANGE_7BIT ? (b) : \
|
||||
(a) == ENC_CODERANGE_VALID ? ((b) == ENC_CODERANGE_7BIT ? ENC_CODERANGE_VALID : (b)) : \
|
||||
ENC_CODERANGE_UNKNOWN)
|
||||
#define RB_ENC_CODERANGE_AND(a, b) \
|
||||
((a) == RUBY_ENC_CODERANGE_7BIT ? (b) : \
|
||||
(a) != RUBY_ENC_CODERANGE_VALID ? RUBY_ENC_CODERANGE_UNKNOWN : \
|
||||
(b) == RUBY_ENC_CODERANGE_7BIT ? RUBY_ENC_CODERANGE_VALID : (b))
|
||||
|
||||
#define ENCODING_CODERANGE_SET(obj, encindex, cr) \
|
||||
#define RB_ENCODING_CODERANGE_SET(obj, encindex, cr) \
|
||||
do { \
|
||||
VALUE rb_encoding_coderange_obj = (obj); \
|
||||
ENCODING_SET(rb_encoding_coderange_obj, (encindex)); \
|
||||
ENC_CODERANGE_SET(rb_encoding_coderange_obj, (cr)); \
|
||||
RB_ENCODING_SET(rb_encoding_coderange_obj, (encindex)); \
|
||||
RB_ENC_CODERANGE_SET(rb_encoding_coderange_obj, (cr)); \
|
||||
} while (0)
|
||||
|
||||
#define ENC_CODERANGE_MASK RUBY_ENC_CODERANGE_MASK
|
||||
#define ENC_CODERANGE_UNKNOWN RUBY_ENC_CODERANGE_UNKNOWN
|
||||
#define ENC_CODERANGE_7BIT RUBY_ENC_CODERANGE_7BIT
|
||||
#define ENC_CODERANGE_VALID RUBY_ENC_CODERANGE_VALID
|
||||
#define ENC_CODERANGE_BROKEN RUBY_ENC_CODERANGE_BROKEN
|
||||
#define ENC_CODERANGE_CLEAN_P(cr) RB_ENC_CODERANGE_CLEAN_P(cr)
|
||||
#define ENC_CODERANGE(obj) RB_ENC_CODERANGE(obj)
|
||||
#define ENC_CODERANGE_ASCIIONLY(obj) RB_ENC_CODERANGE_ASCIIONLY(obj)
|
||||
#define ENC_CODERANGE_SET(obj,cr) RB_ENC_CODERANGE_SET(obj,cr)
|
||||
#define ENC_CODERANGE_CLEAR(obj) RB_ENC_CODERANGE_CLEAR(obj)
|
||||
#define ENC_CODERANGE_AND(a, b) RB_ENC_CODERANGE_AND(a, b)
|
||||
#define ENCODING_CODERANGE_SET(obj, encindex, cr) RB_ENCODING_CODERANGE_SET(obj, encindex, cr)
|
||||
|
||||
typedef const OnigEncodingType rb_encoding;
|
||||
|
||||
int rb_char_to_option_kcode(int c, int *option, int *kcode);
|
||||
|
@ -315,43 +348,64 @@ VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE
|
|||
|
||||
void rb_econv_binmode(rb_econv_t *ec);
|
||||
|
||||
enum ruby_econv_flag_type {
|
||||
/* flags for rb_econv_open */
|
||||
RUBY_ECONV_ERROR_HANDLER_MASK = 0x000000ff,
|
||||
|
||||
#define ECONV_ERROR_HANDLER_MASK 0x000000ff
|
||||
RUBY_ECONV_INVALID_MASK = 0x0000000f,
|
||||
RUBY_ECONV_INVALID_REPLACE = 0x00000002,
|
||||
|
||||
#define ECONV_INVALID_MASK 0x0000000f
|
||||
#define ECONV_INVALID_REPLACE 0x00000002
|
||||
RUBY_ECONV_UNDEF_MASK = 0x000000f0,
|
||||
RUBY_ECONV_UNDEF_REPLACE = 0x00000020,
|
||||
RUBY_ECONV_UNDEF_HEX_CHARREF = 0x00000030,
|
||||
|
||||
#define ECONV_UNDEF_MASK 0x000000f0
|
||||
#define ECONV_UNDEF_REPLACE 0x00000020
|
||||
#define ECONV_UNDEF_HEX_CHARREF 0x00000030
|
||||
RUBY_ECONV_DECORATOR_MASK = 0x0000ff00,
|
||||
RUBY_ECONV_NEWLINE_DECORATOR_MASK = 0x00003f00,
|
||||
RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK = 0x00000f00,
|
||||
RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK = 0x00003000,
|
||||
|
||||
#define ECONV_DECORATOR_MASK 0x0000ff00
|
||||
#define ECONV_NEWLINE_DECORATOR_MASK 0x00003f00
|
||||
#define ECONV_NEWLINE_DECORATOR_READ_MASK 0x00000f00
|
||||
#define ECONV_NEWLINE_DECORATOR_WRITE_MASK 0x00003000
|
||||
RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR = 0x00000100,
|
||||
RUBY_ECONV_CRLF_NEWLINE_DECORATOR = 0x00001000,
|
||||
RUBY_ECONV_CR_NEWLINE_DECORATOR = 0x00002000,
|
||||
RUBY_ECONV_XML_TEXT_DECORATOR = 0x00004000,
|
||||
RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR = 0x00008000,
|
||||
|
||||
#define ECONV_UNIVERSAL_NEWLINE_DECORATOR 0x00000100
|
||||
#define ECONV_CRLF_NEWLINE_DECORATOR 0x00001000
|
||||
#define ECONV_CR_NEWLINE_DECORATOR 0x00002000
|
||||
#define ECONV_XML_TEXT_DECORATOR 0x00004000
|
||||
#define ECONV_XML_ATTR_CONTENT_DECORATOR 0x00008000
|
||||
|
||||
#define ECONV_STATEFUL_DECORATOR_MASK 0x00f00000
|
||||
#define ECONV_XML_ATTR_QUOTE_DECORATOR 0x00100000
|
||||
RUBY_ECONV_STATEFUL_DECORATOR_MASK = 0x00f00000,
|
||||
RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR = 0x00100000,
|
||||
|
||||
RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR =
|
||||
#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32)
|
||||
#define ECONV_DEFAULT_NEWLINE_DECORATOR ECONV_CRLF_NEWLINE_DECORATOR
|
||||
RUBY_ECONV_CRLF_NEWLINE_DECORATOR,
|
||||
#else
|
||||
#define ECONV_DEFAULT_NEWLINE_DECORATOR 0
|
||||
0,
|
||||
#endif
|
||||
|
||||
#define ECONV_ERROR_HANDLER_MASK RUBY_ECONV_ERROR_HANDLER_MASK
|
||||
#define ECONV_INVALID_MASK RUBY_ECONV_INVALID_MASK
|
||||
#define ECONV_INVALID_REPLACE RUBY_ECONV_INVALID_REPLACE
|
||||
#define ECONV_UNDEF_MASK RUBY_ECONV_UNDEF_MASK
|
||||
#define ECONV_UNDEF_REPLACE RUBY_ECONV_UNDEF_REPLACE
|
||||
#define ECONV_UNDEF_HEX_CHARREF RUBY_ECONV_UNDEF_HEX_CHARREF
|
||||
#define ECONV_DECORATOR_MASK RUBY_ECONV_DECORATOR_MASK
|
||||
#define ECONV_NEWLINE_DECORATOR_MASK RUBY_ECONV_NEWLINE_DECORATOR_MASK
|
||||
#define ECONV_NEWLINE_DECORATOR_READ_MASK RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
|
||||
#define ECONV_NEWLINE_DECORATOR_WRITE_MASK RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
|
||||
#define ECONV_UNIVERSAL_NEWLINE_DECORATOR RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
|
||||
#define ECONV_CRLF_NEWLINE_DECORATOR RUBY_ECONV_CRLF_NEWLINE_DECORATOR
|
||||
#define ECONV_CR_NEWLINE_DECORATOR RUBY_ECONV_CR_NEWLINE_DECORATOR
|
||||
#define ECONV_XML_TEXT_DECORATOR RUBY_ECONV_XML_TEXT_DECORATOR
|
||||
#define ECONV_XML_ATTR_CONTENT_DECORATOR RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
|
||||
#define ECONV_STATEFUL_DECORATOR_MASK RUBY_ECONV_STATEFUL_DECORATOR_MASK
|
||||
#define ECONV_XML_ATTR_QUOTE_DECORATOR RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
|
||||
#define ECONV_DEFAULT_NEWLINE_DECORATOR RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
|
||||
/* end of flags for rb_econv_open */
|
||||
|
||||
/* flags for rb_econv_convert */
|
||||
#define ECONV_PARTIAL_INPUT 0x00010000
|
||||
#define ECONV_AFTER_OUTPUT 0x00020000
|
||||
RUBY_ECONV_PARTIAL_INPUT = 0x00010000,
|
||||
RUBY_ECONV_AFTER_OUTPUT = 0x00020000,
|
||||
#define ECONV_PARTIAL_INPUT RUBY_ECONV_PARTIAL_INPUT
|
||||
#define ECONV_AFTER_OUTPUT RUBY_ECONV_AFTER_OUTPUT
|
||||
/* end of flags for rb_econv_convert */
|
||||
RUBY_ECONV_FLAGS_PLACEHOLDER};
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
|
|
|
@ -287,8 +287,9 @@ rb_check_trusted_inline(VALUE obj)
|
|||
#endif
|
||||
void rb_check_copyable(VALUE obj, VALUE orig);
|
||||
|
||||
#define OBJ_INIT_COPY(obj, orig) \
|
||||
#define RB_OBJ_INIT_COPY(obj, orig) \
|
||||
((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))
|
||||
#define OBJ_INIT_COPY(obj, orig) RB_OBJ_INIT_COPY(obj, orig)
|
||||
|
||||
/* eval.c */
|
||||
int rb_sourceline(void);
|
||||
|
|
|
@ -241,10 +241,12 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#define FIXNUM_MAX (LONG_MAX>>1)
|
||||
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
|
||||
#define RUBY_FIXNUM_MAX (LONG_MAX>>1)
|
||||
#define RUBY_FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
|
||||
#define FIXNUM_MAX RUBY_FIXNUM_MAX
|
||||
#define FIXNUM_MIN RUBY_FIXNUM_MIN
|
||||
|
||||
#define INT2FIX(i) (((VALUE)(i))<<1 | FIXNUM_FLAG)
|
||||
#define INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
|
||||
#define LONG2FIX(i) INT2FIX(i)
|
||||
#define rb_fix_new(v) INT2FIX(v)
|
||||
VALUE rb_int2inum(SIGNED_VALUE);
|
||||
|
@ -358,22 +360,44 @@ rb_long2int_inline(long n)
|
|||
#define MODET2NUM(v) INT2NUM(v)
|
||||
#endif
|
||||
|
||||
#define FIX2LONG(x) ((long)RSHIFT((SIGNED_VALUE)(x),1))
|
||||
#define FIX2ULONG(x) ((unsigned long)FIX2LONG(x))
|
||||
#define FIXNUM_P(f) (((int)(SIGNED_VALUE)(f))&FIXNUM_FLAG)
|
||||
#define POSFIXABLE(f) ((f) < FIXNUM_MAX+1)
|
||||
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
|
||||
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
|
||||
#define RB_FIX2LONG(x) ((long)RSHIFT((SIGNED_VALUE)(x),1))
|
||||
static inline long
|
||||
rb_fix2long(VALUE x)
|
||||
{
|
||||
return RB_FIX2LONG(x);
|
||||
}
|
||||
#define RB_FIX2ULONG(x) ((unsigned long)RB_FIX2LONG(x))
|
||||
static inline unsigned long
|
||||
rb_fix2ulong(VALUE x)
|
||||
{
|
||||
return RB_FIX2ULONG(x);
|
||||
}
|
||||
#define RB_FIXNUM_P(f) (((int)(SIGNED_VALUE)(f))&RUBY_FIXNUM_FLAG)
|
||||
#define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
|
||||
#define RB_NEGFIXABLE(f) ((f) >= RUBY_FIXNUM_MIN)
|
||||
#define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
|
||||
#define FIX2LONG(x) RB_FIX2LONG(x)
|
||||
#define FIX2ULONG(x) RB_FIX2ULONG(x)
|
||||
#define FIXNUM_P(f) RB_FIXNUM_P(f)
|
||||
#define POSFIXABLE(f) RB_POSFIXABLE(f)
|
||||
#define NEGFIXABLE(f) RB_NEGFIXABLE(f)
|
||||
#define FIXABLE(f) RB_FIXABLE(f)
|
||||
|
||||
#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
|
||||
#define RB_IMMEDIATE_P(x) ((VALUE)(x) & RUBY_IMMEDIATE_MASK)
|
||||
#define IMMEDIATE_P(x) RB_IMMEDIATE_P(x)
|
||||
|
||||
ID rb_sym2id(VALUE);
|
||||
VALUE rb_id2sym(ID);
|
||||
#define STATIC_SYM_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT))==SYMBOL_FLAG)
|
||||
#define DYNAMIC_SYM_P(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) == (T_SYMBOL))
|
||||
#define SYMBOL_P(x) (STATIC_SYM_P(x)||DYNAMIC_SYM_P(x))
|
||||
#define ID2SYM(x) (rb_id2sym(x))
|
||||
#define SYM2ID(x) (rb_sym2id(x))
|
||||
#define RB_STATIC_SYM_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG)
|
||||
#define RB_DYNAMIC_SYM_P(x) (!RB_SPECIAL_CONST_P(x) && RB_BUILTIN_TYPE(x) == (RUBY_T_SYMBOL))
|
||||
#define RB_SYMBOL_P(x) (RB_STATIC_SYM_P(x)||RB_DYNAMIC_SYM_P(x))
|
||||
#define RB_ID2SYM(x) (rb_id2sym(x))
|
||||
#define RB_SYM2ID(x) (rb_sym2id(x))
|
||||
#define STATIC_SYM_P(x) RB_STATIC_SYM_P(x)
|
||||
#define DYNAMIC_SYM_P(x) RB_DYNAMIC_SYM_P(x)
|
||||
#define SYMBOL_P(x) RB_SYMBOL_P(x)
|
||||
#define ID2SYM(x) RB_ID2SYM(x)
|
||||
#define SYM2ID(x) RB_SYM2ID(x)
|
||||
|
||||
#ifndef USE_FLONUM
|
||||
#if SIZEOF_VALUE >= SIZEOF_DOUBLE
|
||||
|
@ -384,10 +408,11 @@ VALUE rb_id2sym(ID);
|
|||
#endif
|
||||
|
||||
#if USE_FLONUM
|
||||
#define FLONUM_P(x) ((((int)(SIGNED_VALUE)(x))&FLONUM_MASK) == FLONUM_FLAG)
|
||||
#define RB_FLONUM_P(x) ((((int)(SIGNED_VALUE)(x))&RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG)
|
||||
#else
|
||||
#define FLONUM_P(x) 0
|
||||
#define RB_FLONUM_P(x) 0
|
||||
#endif
|
||||
#define FLONUM_P(x) RB_FLONUM_P(x)
|
||||
|
||||
/* Module#methods, #singleton_methods and so on return Symbols */
|
||||
#define USE_SYMBOL_AS_METHOD_NAME 1
|
||||
|
@ -499,22 +524,25 @@ enum ruby_value_type {
|
|||
#define T_ZOMBIE RUBY_T_ZOMBIE
|
||||
#define T_MASK RUBY_T_MASK
|
||||
|
||||
#define BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & T_MASK)
|
||||
#define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
|
||||
#define BUILTIN_TYPE(x) RB_BUILTIN_TYPE(x)
|
||||
|
||||
static inline int rb_type(VALUE obj);
|
||||
#define TYPE(x) rb_type((VALUE)(x))
|
||||
|
||||
#define RB_FLOAT_TYPE_P(obj) (FLONUM_P(obj) || (!SPECIAL_CONST_P(obj) && BUILTIN_TYPE(obj) == T_FLOAT))
|
||||
#define RB_FLOAT_TYPE_P(obj) (\
|
||||
RB_FLONUM_P(obj) || \
|
||||
(!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == RUBY_T_FLOAT))
|
||||
|
||||
#define RB_TYPE_P(obj, type) ( \
|
||||
((type) == T_FIXNUM) ? FIXNUM_P(obj) : \
|
||||
((type) == T_TRUE) ? ((obj) == Qtrue) : \
|
||||
((type) == T_FALSE) ? ((obj) == Qfalse) : \
|
||||
((type) == T_NIL) ? ((obj) == Qnil) : \
|
||||
((type) == T_UNDEF) ? ((obj) == Qundef) : \
|
||||
((type) == T_SYMBOL) ? SYMBOL_P(obj) : \
|
||||
((type) == T_FLOAT) ? RB_FLOAT_TYPE_P(obj) : \
|
||||
(!SPECIAL_CONST_P(obj) && BUILTIN_TYPE(obj) == (type)))
|
||||
((type) == RUBY_T_FIXNUM) ? RB_FIXNUM_P(obj) : \
|
||||
((type) == RUBY_T_TRUE) ? ((obj) == RUBY_Qtrue) : \
|
||||
((type) == RUBY_T_FALSE) ? ((obj) == RUBY_Qfalse) : \
|
||||
((type) == RUBY_T_NIL) ? ((obj) == RUBY_Qnil) : \
|
||||
((type) == RUBY_T_UNDEF) ? ((obj) == RUBY_Qundef) : \
|
||||
((type) == RUBY_T_SYMBOL) ? RB_SYMBOL_P(obj) : \
|
||||
((type) == RUBY_T_FLOAT) ? RB_FLOAT_TYPE_P(obj) : \
|
||||
(!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == (type)))
|
||||
|
||||
/* RB_GC_GUARD_PTR() is an intermediate macro, and has no effect by
|
||||
* itself. don't use it directly */
|
||||
|
@ -625,63 +653,72 @@ unsigned long rb_num2ulong(VALUE);
|
|||
static inline long
|
||||
rb_num2long_inline(VALUE x)
|
||||
{
|
||||
if (FIXNUM_P(x))
|
||||
return FIX2LONG(x);
|
||||
if (RB_FIXNUM_P(x))
|
||||
return RB_FIX2LONG(x);
|
||||
else
|
||||
return rb_num2long(x);
|
||||
}
|
||||
#define NUM2LONG(x) rb_num2long_inline(x)
|
||||
#define RB_NUM2LONG(x) rb_num2long_inline(x)
|
||||
#define NUM2LONG(x) RB_NUM2LONG(x)
|
||||
static inline unsigned long
|
||||
rb_num2ulong_inline(VALUE x)
|
||||
{
|
||||
if (FIXNUM_P(x))
|
||||
return (unsigned long)FIX2LONG(x);
|
||||
if (RB_FIXNUM_P(x))
|
||||
return RB_FIX2ULONG(x);
|
||||
else
|
||||
return rb_num2ulong(x);
|
||||
}
|
||||
#define NUM2ULONG(x) rb_num2ulong_inline(x)
|
||||
#define RB_NUM2ULONG(x) rb_num2ulong_inline(x)
|
||||
#define NUM2ULONG(x) RB_NUM2ULONG(x)
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
long rb_num2int(VALUE);
|
||||
long rb_fix2int(VALUE);
|
||||
#define FIX2INT(x) ((int)rb_fix2int((VALUE)(x)))
|
||||
#define RB_FIX2INT(x) ((int)rb_fix2int((VALUE)(x)))
|
||||
|
||||
static inline int
|
||||
rb_num2int_inline(VALUE x)
|
||||
{
|
||||
if (FIXNUM_P(x))
|
||||
return FIX2INT(x);
|
||||
if (RB_FIXNUM_P(x))
|
||||
return (int)rb_fix2int(x);
|
||||
else
|
||||
return (int)rb_num2int(x);
|
||||
}
|
||||
#define NUM2INT(x) rb_num2int_inline(x)
|
||||
#define RB_NUM2INT(x) rb_num2int_inline(x)
|
||||
|
||||
unsigned long rb_num2uint(VALUE);
|
||||
#define NUM2UINT(x) ((unsigned int)rb_num2uint(x))
|
||||
#define RB_NUM2UINT(x) ((unsigned int)rb_num2uint(x))
|
||||
unsigned long rb_fix2uint(VALUE);
|
||||
#define FIX2UINT(x) ((unsigned int)rb_fix2uint(x))
|
||||
#define RB_FIX2UINT(x) ((unsigned int)rb_fix2uint(x))
|
||||
#else /* SIZEOF_INT < SIZEOF_LONG */
|
||||
#define NUM2INT(x) ((int)NUM2LONG(x))
|
||||
#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
|
||||
#define FIX2INT(x) ((int)FIX2LONG(x))
|
||||
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
|
||||
#define RB_NUM2INT(x) ((int)RB_NUM2LONG(x))
|
||||
#define RB_NUM2UINT(x) ((unsigned int)RB_NUM2ULONG(x))
|
||||
#define RB_FIX2INT(x) ((int)RB_FIX2LONG(x))
|
||||
#define RB_FIX2UINT(x) ((unsigned int)RB_FIX2ULONG(x))
|
||||
#endif /* SIZEOF_INT < SIZEOF_LONG */
|
||||
#define NUM2INT(x) RB_NUM2INT(x)
|
||||
#define NUM2UINT(x) RB_NUM2UINT(x)
|
||||
#define FIX2INT(x) RB_FIX2INT(x)
|
||||
#define FIX2UINT(x) RB_FIX2UINT(x)
|
||||
|
||||
short rb_num2short(VALUE);
|
||||
unsigned short rb_num2ushort(VALUE);
|
||||
short rb_fix2short(VALUE);
|
||||
unsigned short rb_fix2ushort(VALUE);
|
||||
#define FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
|
||||
#define RB_FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
|
||||
#define FIX2SHORT(x) RB_FIX2SHORT(x)
|
||||
static inline short
|
||||
rb_num2short_inline(VALUE x)
|
||||
{
|
||||
if (FIXNUM_P(x))
|
||||
return FIX2SHORT(x);
|
||||
if (RB_FIXNUM_P(x))
|
||||
return rb_fix2short(x);
|
||||
else
|
||||
return rb_num2short(x);
|
||||
}
|
||||
|
||||
#define NUM2SHORT(x) rb_num2short_inline(x)
|
||||
#define NUM2USHORT(x) rb_num2ushort(x)
|
||||
#define RB_NUM2SHORT(x) rb_num2short_inline(x)
|
||||
#define RB_NUM2USHORT(x) rb_num2ushort(x)
|
||||
#define NUM2SHORT(x) RB_NUM2SHORT(x)
|
||||
#define NUM2USHORT(x) RB_NUM2USHORT(x)
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
LONG_LONG rb_num2ll(VALUE);
|
||||
|
@ -689,13 +726,15 @@ unsigned LONG_LONG rb_num2ull(VALUE);
|
|||
static inline LONG_LONG
|
||||
rb_num2ll_inline(VALUE x)
|
||||
{
|
||||
if (FIXNUM_P(x))
|
||||
return FIX2LONG(x);
|
||||
if (RB_FIXNUM_P(x))
|
||||
return RB_FIX2LONG(x);
|
||||
else
|
||||
return rb_num2ll(x);
|
||||
}
|
||||
# define NUM2LL(x) rb_num2ll_inline(x)
|
||||
# define NUM2ULL(x) rb_num2ull(x)
|
||||
# define RB_NUM2LL(x) rb_num2ll_inline(x)
|
||||
# define RB_NUM2ULL(x) rb_num2ull(x)
|
||||
# define NUM2LL(x) RB_NUM2LL(x)
|
||||
# define NUM2ULL(x) RB_NUM2ULL(x)
|
||||
#endif
|
||||
|
||||
#if !defined(NUM2OFFT)
|
||||
|
@ -723,18 +762,22 @@ VALUE rb_int2big(SIGNED_VALUE);
|
|||
VALUE rb_newobj(void);
|
||||
VALUE rb_newobj_of(VALUE, VALUE);
|
||||
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
|
||||
#define NEWOBJ(obj,type) type *(obj) = (type*)rb_newobj()
|
||||
#define NEWOBJ_OF(obj,type,klass,flags) type *(obj) = (type*)rb_newobj_of(klass, flags)
|
||||
#define RB_NEWOBJ(obj,type) type *(obj) = (type*)rb_newobj()
|
||||
#define RB_NEWOBJ_OF(obj,type,klass,flags) type *(obj) = (type*)rb_newobj_of(klass, flags)
|
||||
#define NEWOBJ(obj,type) RB_NEWOBJ(obj,type)
|
||||
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
|
||||
#define OBJSETUP(obj,c,t) rb_obj_setup(obj, c, t) /* use NEWOBJ_OF instead of NEWOBJ()+OBJSETUP() */
|
||||
#define CLONESETUP(clone,obj) do {\
|
||||
OBJSETUP((clone),rb_singleton_class_clone((VALUE)(obj)),RBASIC(obj)->flags);\
|
||||
#define RB_CLONESETUP(clone,obj) do {\
|
||||
rb_obj_setup((clone),rb_singleton_class_clone((VALUE)(obj)),RBASIC(obj)->flags);\
|
||||
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)(clone));\
|
||||
if (FL_TEST((obj), FL_EXIVAR)) rb_copy_generic_ivar((VALUE)(clone),(VALUE)(obj));\
|
||||
if (RB_FL_TEST((obj), RUBY_FL_EXIVAR)) rb_copy_generic_ivar((VALUE)(clone),(VALUE)(obj));\
|
||||
} while (0)
|
||||
#define DUPSETUP(dup,obj) do {\
|
||||
OBJSETUP((dup),rb_obj_class(obj), (RBASIC(obj)->flags)&(T_MASK|FL_EXIVAR|FL_TAINT)); \
|
||||
if (FL_TEST((obj), FL_EXIVAR)) rb_copy_generic_ivar((VALUE)(dup),(VALUE)(obj));\
|
||||
#define RB_DUPSETUP(dup,obj) do {\
|
||||
rb_obj_setup((dup),rb_obj_class(obj), (RBASIC(obj)->flags)&(RUBY_T_MASK|RUBY_FL_EXIVAR|RUBY_FL_TAINT)); \
|
||||
if (RB_FL_TEST((obj), RUBY_FL_EXIVAR)) rb_copy_generic_ivar((VALUE)(dup),(VALUE)(obj));\
|
||||
} while (0)
|
||||
#define CLONESETUP(clone,obj) RB_CLONESETUP(clone,obj)
|
||||
#define DUPSETUP(dup,obj) RB_DUPSETUP(dup,obj)
|
||||
|
||||
#ifndef USE_RGENGC
|
||||
#define USE_RGENGC 1
|
||||
|
@ -810,7 +853,7 @@ struct RObject {
|
|||
VALUE ary[ROBJECT_EMBED_LEN_MAX];
|
||||
} as;
|
||||
};
|
||||
#define ROBJECT_EMBED FL_USER1
|
||||
#define ROBJECT_EMBED RUBY_FL_USER1
|
||||
#define ROBJECT_NUMIV(o) \
|
||||
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
|
||||
ROBJECT_EMBED_LEN_MAX : \
|
||||
|
@ -836,9 +879,9 @@ struct RClass {
|
|||
#define RMODULE_CONST_TBL(m) RCLASS_CONST_TBL(m)
|
||||
#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
|
||||
#define RMODULE_SUPER(m) RCLASS_SUPER(m)
|
||||
#define RMODULE_IS_OVERLAID FL_USER2
|
||||
#define RMODULE_IS_REFINEMENT FL_USER3
|
||||
#define RMODULE_INCLUDED_INTO_REFINEMENT FL_USER4
|
||||
#define RMODULE_IS_OVERLAID RUBY_FL_USER2
|
||||
#define RMODULE_IS_REFINEMENT RUBY_FL_USER3
|
||||
#define RMODULE_INCLUDED_INTO_REFINEMENT RUBY_FL_USER4
|
||||
|
||||
double rb_float_value(VALUE);
|
||||
VALUE rb_float_new(double);
|
||||
|
@ -847,7 +890,8 @@ VALUE rb_float_new_in_heap(double);
|
|||
#define RFLOAT_VALUE(v) rb_float_value(v)
|
||||
#define DBL2NUM(dbl) rb_float_new(dbl)
|
||||
|
||||
#define ELTS_SHARED FL_USER2
|
||||
#define RUBY_ELTS_SHARED RUBY_FL_USER2
|
||||
#define ELTS_SHARED RUBY_ELTS_SHARED
|
||||
|
||||
#define RSTRING_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(char)-1))
|
||||
struct RString {
|
||||
|
@ -864,10 +908,10 @@ struct RString {
|
|||
char ary[RSTRING_EMBED_LEN_MAX + 1];
|
||||
} as;
|
||||
};
|
||||
#define RSTRING_NOEMBED FL_USER1
|
||||
#define RSTRING_FSTR FL_USER17
|
||||
#define RSTRING_EMBED_LEN_MASK (FL_USER2|FL_USER3|FL_USER4|FL_USER5|FL_USER6)
|
||||
#define RSTRING_EMBED_LEN_SHIFT (FL_USHIFT+2)
|
||||
#define RSTRING_NOEMBED RUBY_FL_USER1
|
||||
#define RSTRING_FSTR RUBY_FL_USER17
|
||||
#define RSTRING_EMBED_LEN_MASK (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)
|
||||
#define RSTRING_EMBED_LEN_SHIFT (RUBY_FL_USHIFT+2)
|
||||
#define RSTRING_EMBED_LEN(str) \
|
||||
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
|
||||
(RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT))
|
||||
|
@ -904,10 +948,10 @@ struct RArray {
|
|||
const VALUE ary[RARRAY_EMBED_LEN_MAX];
|
||||
} as;
|
||||
};
|
||||
#define RARRAY_EMBED_FLAG FL_USER1
|
||||
/* FL_USER2 is for ELTS_SHARED */
|
||||
#define RARRAY_EMBED_LEN_MASK (FL_USER4|FL_USER3)
|
||||
#define RARRAY_EMBED_LEN_SHIFT (FL_USHIFT+3)
|
||||
#define RARRAY_EMBED_FLAG RUBY_FL_USER1
|
||||
/* RUBY_FL_USER2 is for ELTS_SHARED */
|
||||
#define RARRAY_EMBED_LEN_MASK (RUBY_FL_USER4|RUBY_FL_USER3)
|
||||
#define RARRAY_EMBED_LEN_SHIFT (RUBY_FL_USHIFT+3)
|
||||
#define RARRAY_LEN(a) \
|
||||
((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
|
||||
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
|
||||
|
@ -989,7 +1033,7 @@ struct rb_data_type_struct {
|
|||
const rb_data_type_t *parent;
|
||||
void *data; /* This area can be used for any purpose
|
||||
by a programmer who define the type. */
|
||||
VALUE flags; /* FL_WB_PROTECTED */
|
||||
VALUE flags; /* RUBY_FL_WB_PROTECTED */
|
||||
};
|
||||
|
||||
#define HAVE_TYPE_RB_DATA_TYPE_T 1
|
||||
|
@ -1036,8 +1080,8 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
|
|||
|
||||
/* bits for rb_data_type_struct::flags */
|
||||
#define RUBY_TYPED_FREE_IMMEDIATELY 1 /* TYPE field */
|
||||
#define RUBY_TYPED_WB_PROTECTED FL_WB_PROTECTED /* THIS FLAG DEPENDS ON Ruby version */
|
||||
#define RUBY_TYPED_PROMOTED1 FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
|
||||
#define RUBY_TYPED_WB_PROTECTED RUBY_FL_WB_PROTECTED /* THIS FLAG DEPENDS ON Ruby version */
|
||||
#define RUBY_TYPED_PROMOTED1 RUBY_FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
|
||||
|
||||
#define Data_Wrap_Struct(klass,mark,free,sval)\
|
||||
rb_data_object_wrap((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
|
||||
|
@ -1094,8 +1138,8 @@ struct RStruct {
|
|||
const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
|
||||
} as;
|
||||
};
|
||||
#define RSTRUCT_EMBED_LEN_MASK (FL_USER2|FL_USER1)
|
||||
#define RSTRUCT_EMBED_LEN_SHIFT (FL_USHIFT+1)
|
||||
#define RSTRUCT_EMBED_LEN_MASK (RUBY_FL_USER2|RUBY_FL_USER1)
|
||||
#define RSTRUCT_EMBED_LEN_SHIFT (RUBY_FL_USHIFT+1)
|
||||
#define RSTRUCT_LEN(st) \
|
||||
((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
|
||||
(long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
|
||||
|
@ -1128,79 +1172,148 @@ struct RStruct {
|
|||
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
|
||||
#define RFILE(obj) (R_CAST(RFile)(obj))
|
||||
|
||||
#define FL_SINGLETON FL_USER0
|
||||
#define FL_WB_PROTECTED (((VALUE)1)<<5)
|
||||
#define FL_PROMOTED0 (((VALUE)1)<<5)
|
||||
#define FL_PROMOTED1 (((VALUE)1)<<6)
|
||||
#define FL_FINALIZE (((VALUE)1)<<7)
|
||||
#define FL_TAINT (((VALUE)1)<<8)
|
||||
#define FL_UNTRUSTED FL_TAINT
|
||||
#define FL_EXIVAR (((VALUE)1)<<10)
|
||||
#define FL_FREEZE (((VALUE)1)<<11)
|
||||
enum ruby_fl_type {
|
||||
RUBY_FL_WB_PROTECTED = (1<<5),
|
||||
RUBY_FL_PROMOTED0 = (1<<5),
|
||||
RUBY_FL_PROMOTED1 = (1<<6),
|
||||
RUBY_FL_FINALIZE = (1<<7),
|
||||
RUBY_FL_TAINT = (1<<8),
|
||||
RUBY_FL_UNTRUSTED = RUBY_FL_TAINT,
|
||||
RUBY_FL_EXIVAR = (1<<10),
|
||||
RUBY_FL_FREEZE = (1<<11),
|
||||
|
||||
#define FL_USHIFT 12
|
||||
RUBY_FL_USHIFT = 12,
|
||||
|
||||
#define FL_USER0 (((VALUE)1)<<(FL_USHIFT+0))
|
||||
#define FL_USER1 (((VALUE)1)<<(FL_USHIFT+1))
|
||||
#define FL_USER2 (((VALUE)1)<<(FL_USHIFT+2))
|
||||
#define FL_USER3 (((VALUE)1)<<(FL_USHIFT+3))
|
||||
#define FL_USER4 (((VALUE)1)<<(FL_USHIFT+4))
|
||||
#define FL_USER5 (((VALUE)1)<<(FL_USHIFT+5))
|
||||
#define FL_USER6 (((VALUE)1)<<(FL_USHIFT+6))
|
||||
#define FL_USER7 (((VALUE)1)<<(FL_USHIFT+7))
|
||||
#define FL_USER8 (((VALUE)1)<<(FL_USHIFT+8))
|
||||
#define FL_USER9 (((VALUE)1)<<(FL_USHIFT+9))
|
||||
#define FL_USER10 (((VALUE)1)<<(FL_USHIFT+10))
|
||||
#define FL_USER11 (((VALUE)1)<<(FL_USHIFT+11))
|
||||
#define FL_USER12 (((VALUE)1)<<(FL_USHIFT+12))
|
||||
#define FL_USER13 (((VALUE)1)<<(FL_USHIFT+13))
|
||||
#define FL_USER14 (((VALUE)1)<<(FL_USHIFT+14))
|
||||
#define FL_USER15 (((VALUE)1)<<(FL_USHIFT+15))
|
||||
#define FL_USER16 (((VALUE)1)<<(FL_USHIFT+16))
|
||||
#define FL_USER17 (((VALUE)1)<<(FL_USHIFT+17))
|
||||
#define FL_USER18 (((VALUE)1)<<(FL_USHIFT+18))
|
||||
#define FL_USER19 (((VALUE)1)<<(FL_USHIFT+19))
|
||||
#define RUBY_FL_USER_N(n) RUBY_FL_USER##n = (1<<(RUBY_FL_USHIFT+n))
|
||||
RUBY_FL_USER_N(0),
|
||||
RUBY_FL_USER_N(1),
|
||||
RUBY_FL_USER_N(2),
|
||||
RUBY_FL_USER_N(3),
|
||||
RUBY_FL_USER_N(4),
|
||||
RUBY_FL_USER_N(5),
|
||||
RUBY_FL_USER_N(6),
|
||||
RUBY_FL_USER_N(7),
|
||||
RUBY_FL_USER_N(8),
|
||||
RUBY_FL_USER_N(9),
|
||||
RUBY_FL_USER_N(10),
|
||||
RUBY_FL_USER_N(11),
|
||||
RUBY_FL_USER_N(12),
|
||||
RUBY_FL_USER_N(13),
|
||||
RUBY_FL_USER_N(14),
|
||||
RUBY_FL_USER_N(15),
|
||||
RUBY_FL_USER_N(16),
|
||||
RUBY_FL_USER_N(17),
|
||||
RUBY_FL_USER_N(18),
|
||||
#if defined ENUM_OVER_INT || SIZEOF_INT*CHAR_BIT>12+19+1
|
||||
RUBY_FL_USER_N(19),
|
||||
#else
|
||||
#define RUBY_FL_USER19 (((VALUE)1)<<(RUBY_FL_USHIFT+19))
|
||||
#endif
|
||||
|
||||
#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
|
||||
RUBY_FL_SINGLETON = RUBY_FL_USER0
|
||||
};
|
||||
|
||||
#define FL_ABLE(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) != T_NODE)
|
||||
#define FL_TEST_RAW(x,f) (RBASIC(x)->flags&(f))
|
||||
#define FL_TEST(x,f) (FL_ABLE(x)?FL_TEST_RAW((x),(f)):0)
|
||||
#define FL_ANY_RAW(x,f) FL_TEST_RAW((x),(f))
|
||||
#define FL_ANY(x,f) FL_TEST((x),(f))
|
||||
#define FL_ALL_RAW(x,f) (FL_TEST_RAW((x),(f)) == (f))
|
||||
#define FL_ALL(x,f) (FL_TEST((x),(f)) == (f))
|
||||
#define FL_SET_RAW(x,f) (RBASIC(x)->flags |= (f))
|
||||
#define FL_SET(x,f) (FL_ABLE(x) ? FL_SET_RAW(x, f) : 0)
|
||||
#define FL_UNSET_RAW(x,f) (RBASIC(x)->flags &= ~(f))
|
||||
#define FL_UNSET(x,f) (FL_ABLE(x) ? FL_UNSET_RAW(x, f) : 0)
|
||||
#define FL_REVERSE_RAW(x,f) (RBASIC(x)->flags ^= (f))
|
||||
#define FL_REVERSE(x,f) (FL_ABLE(x) ? FL_REVERSE_RAW(x, f) : 0)
|
||||
#define FL_SINGLETON RUBY_FL_SINGLETON
|
||||
#define FL_WB_PROTECTED RUBY_FL_WB_PROTECTED
|
||||
#define FL_PROMOTED0 RUBY_FL_PROMOTED0
|
||||
#define FL_PROMOTED1 RUBY_FL_PROMOTED1
|
||||
#define FL_FINALIZE RUBY_FL_FINALIZE
|
||||
#define FL_TAINT RUBY_FL_TAINT
|
||||
#define FL_UNTRUSTED RUBY_FL_UNTRUSTED
|
||||
#define FL_EXIVAR RUBY_FL_EXIVAR
|
||||
#define FL_FREEZE RUBY_FL_FREEZE
|
||||
|
||||
#define OBJ_TAINTABLE(x) (FL_ABLE(x) && BUILTIN_TYPE(x) != T_BIGNUM && BUILTIN_TYPE(x) != T_FLOAT)
|
||||
#define OBJ_TAINTED_RAW(x) FL_TEST_RAW(x, FL_TAINT)
|
||||
#define OBJ_TAINTED(x) (!!FL_TEST((x), FL_TAINT))
|
||||
#define OBJ_TAINT_RAW(x) FL_SET_RAW(x, FL_TAINT)
|
||||
#define OBJ_TAINT(x) (OBJ_TAINTABLE(x) ? OBJ_TAINT_RAW(x) : 0)
|
||||
#define OBJ_UNTRUSTED(x) OBJ_TAINTED(x)
|
||||
#define OBJ_UNTRUST(x) OBJ_TAINT(x)
|
||||
#define OBJ_INFECT_RAW(x,s) FL_SET_RAW(x, OBJ_TAINTED_RAW(s))
|
||||
#define OBJ_INFECT(x,s) ( \
|
||||
(OBJ_TAINTABLE(x) && FL_ABLE(s)) ? \
|
||||
OBJ_INFECT_RAW(x, s) : 0)
|
||||
#define FL_USHIFT RUBY_FL_USHIFT
|
||||
|
||||
#define OBJ_FROZEN(x) (FL_ABLE(x) ? !!(RBASIC(x)->flags&FL_FREEZE) : 1)
|
||||
#define OBJ_FREEZE_RAW(x) (RBASIC(x)->flags |= FL_FREEZE)
|
||||
#define OBJ_FREEZE(x) rb_obj_freeze_inline((VALUE)x)
|
||||
#define FL_USER0 RUBY_FL_USER0
|
||||
#define FL_USER1 RUBY_FL_USER1
|
||||
#define FL_USER2 RUBY_FL_USER2
|
||||
#define FL_USER3 RUBY_FL_USER3
|
||||
#define FL_USER4 RUBY_FL_USER4
|
||||
#define FL_USER5 RUBY_FL_USER5
|
||||
#define FL_USER6 RUBY_FL_USER6
|
||||
#define FL_USER7 RUBY_FL_USER7
|
||||
#define FL_USER8 RUBY_FL_USER8
|
||||
#define FL_USER9 RUBY_FL_USER9
|
||||
#define FL_USER10 RUBY_FL_USER10
|
||||
#define FL_USER11 RUBY_FL_USER11
|
||||
#define FL_USER12 RUBY_FL_USER12
|
||||
#define FL_USER13 RUBY_FL_USER13
|
||||
#define FL_USER14 RUBY_FL_USER14
|
||||
#define FL_USER15 RUBY_FL_USER15
|
||||
#define FL_USER16 RUBY_FL_USER16
|
||||
#define FL_USER17 RUBY_FL_USER17
|
||||
#define FL_USER18 RUBY_FL_USER18
|
||||
#define FL_USER19 RUBY_FL_USER19
|
||||
|
||||
#define RB_SPECIAL_CONST_P(x) (RB_IMMEDIATE_P(x) || !RTEST(x))
|
||||
#define SPECIAL_CONST_P(x) RB_SPECIAL_CONST_P(x)
|
||||
|
||||
#define RB_FL_ABLE(x) (!RB_SPECIAL_CONST_P(x) && RB_BUILTIN_TYPE(x) != RUBY_T_NODE)
|
||||
#define RB_FL_TEST_RAW(x,f) (RBASIC(x)->flags&(f))
|
||||
#define RB_FL_TEST(x,f) (RB_FL_ABLE(x)?RB_FL_TEST_RAW((x),(f)):0)
|
||||
#define RB_FL_ANY_RAW(x,f) RB_FL_TEST_RAW((x),(f))
|
||||
#define RB_FL_ANY(x,f) RB_FL_TEST((x),(f))
|
||||
#define RB_FL_ALL_RAW(x,f) (RB_FL_TEST_RAW((x),(f)) == (f))
|
||||
#define RB_FL_ALL(x,f) (RB_FL_TEST((x),(f)) == (f))
|
||||
#define RB_FL_SET_RAW(x,f) (RBASIC(x)->flags |= (f))
|
||||
#define RB_FL_SET(x,f) (RB_FL_ABLE(x) ? RB_FL_SET_RAW(x, f) : 0)
|
||||
#define RB_FL_UNSET_RAW(x,f) (RBASIC(x)->flags &= ~(f))
|
||||
#define RB_FL_UNSET(x,f) (RB_FL_ABLE(x) ? RB_FL_UNSET_RAW(x, f) : 0)
|
||||
#define RB_FL_REVERSE_RAW(x,f) (RBASIC(x)->flags ^= (f))
|
||||
#define RB_FL_REVERSE(x,f) (RB_FL_ABLE(x) ? RB_FL_REVERSE_RAW(x, f) : 0)
|
||||
|
||||
#define RB_OBJ_TAINTABLE(x) (RB_FL_ABLE(x) && RB_BUILTIN_TYPE(x) != RUBY_T_BIGNUM && RB_BUILTIN_TYPE(x) != RUBY_T_FLOAT)
|
||||
#define RB_OBJ_TAINTED_RAW(x) RB_FL_TEST_RAW(x, RUBY_FL_TAINT)
|
||||
#define RB_OBJ_TAINTED(x) (!!RB_FL_TEST((x), RUBY_FL_TAINT))
|
||||
#define RB_OBJ_TAINT_RAW(x) RB_FL_SET_RAW(x, RUBY_FL_TAINT)
|
||||
#define RB_OBJ_TAINT(x) (RB_OBJ_TAINTABLE(x) ? RB_OBJ_TAINT_RAW(x) : 0)
|
||||
#define RB_OBJ_UNTRUSTED(x) RB_OBJ_TAINTED(x)
|
||||
#define RB_OBJ_UNTRUST(x) RB_OBJ_TAINT(x)
|
||||
#define RB_OBJ_INFECT_RAW(x,s) RB_FL_SET_RAW(x, RB_OBJ_TAINTED_RAW(s))
|
||||
#define RB_OBJ_INFECT(x,s) ( \
|
||||
(RB_OBJ_TAINTABLE(x) && RB_FL_ABLE(s)) ? \
|
||||
RB_OBJ_INFECT_RAW(x, s) : 0)
|
||||
|
||||
#define RB_OBJ_FROZEN(x) (RB_FL_ABLE(x) ? !!(RBASIC(x)->flags&RUBY_FL_FREEZE) : 1)
|
||||
#define RB_OBJ_FREEZE_RAW(x) (RBASIC(x)->flags |= RUBY_FL_FREEZE)
|
||||
#define RB_OBJ_FREEZE(x) rb_obj_freeze_inline((VALUE)x)
|
||||
|
||||
#define FL_ABLE(x) RB_FL_ABLE(x)
|
||||
#define FL_TEST_RAW(x,f) RB_FL_TEST_RAW(x,f)
|
||||
#define FL_TEST(x,f) RB_FL_TEST(x,f)
|
||||
#define FL_ANY_RAW(x,f) RB_FL_ANY_RAW(x,f)
|
||||
#define FL_ANY(x,f) RB_FL_ANY(x,f)
|
||||
#define FL_ALL_RAW(x,f) RB_FL_ALL_RAW(x,f)
|
||||
#define FL_ALL(x,f) RB_FL_ALL(x,f)
|
||||
#define FL_SET_RAW(x,f) RB_FL_SET_RAW(x,f)
|
||||
#define FL_SET(x,f) RB_FL_SET(x,f)
|
||||
#define FL_UNSET_RAW(x,f) RB_FL_UNSET_RAW(x,f)
|
||||
#define FL_UNSET(x,f) RB_FL_UNSET(x,f)
|
||||
#define FL_REVERSE_RAW(x,f) RB_FL_REVERSE_RAW(x,f)
|
||||
#define FL_REVERSE(x,f) RB_FL_REVERSE(x,f)
|
||||
|
||||
#define OBJ_TAINTABLE(x) RB_OBJ_TAINTABLE(x)
|
||||
#define OBJ_TAINTED_RAW(x) RB_OBJ_TAINTED_RAW(x)
|
||||
#define OBJ_TAINTED(x) RB_OBJ_TAINTED(x)
|
||||
#define OBJ_TAINT_RAW(x) RB_OBJ_TAINT_RAW(x)
|
||||
#define OBJ_TAINT(x) RB_OBJ_TAINT(x)
|
||||
#define OBJ_UNTRUSTED(x) RB_OBJ_UNTRUSTED(x)
|
||||
#define OBJ_UNTRUST(x) RB_OBJ_UNTRUST(x)
|
||||
#define OBJ_INFECT_RAW(x,s) RB_OBJ_INFECT_RAW(x,s)
|
||||
#define OBJ_INFECT(x,s) RB_OBJ_INFECT(x,s)
|
||||
#define OBJ_FROZEN(x) RB_OBJ_FROZEN(x)
|
||||
#define OBJ_FREEZE_RAW(x) RB_OBJ_FREEZE_RAW(x)
|
||||
#define OBJ_FREEZE(x) RB_OBJ_FREEZE(x)
|
||||
|
||||
void rb_freeze_singleton_class(VALUE klass);
|
||||
|
||||
static inline void
|
||||
rb_obj_freeze_inline(VALUE x)
|
||||
{
|
||||
if (FL_ABLE(x)) {
|
||||
OBJ_FREEZE_RAW(x);
|
||||
if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & FL_SINGLETON)) {
|
||||
if (RB_FL_ABLE(x)) {
|
||||
RB_OBJ_FREEZE_RAW(x);
|
||||
if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
|
||||
rb_freeze_singleton_class(x);
|
||||
}
|
||||
}
|
||||
|
@ -1235,7 +1348,7 @@ rb_data_object_wrap_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DA
|
|||
static inline void *
|
||||
rb_data_object_get(VALUE obj)
|
||||
{
|
||||
Check_Type(obj, T_DATA);
|
||||
Check_Type(obj, RUBY_T_DATA);
|
||||
return ((struct RData *)obj)->data;
|
||||
}
|
||||
|
||||
|
@ -1288,17 +1401,22 @@ rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
|
|||
#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)
|
||||
|
||||
#if USE_RGENGC
|
||||
#define OBJ_PROMOTED_RAW(x) ((RBASIC(x)->flags & (FL_PROMOTED0|FL_PROMOTED1)) == (FL_PROMOTED0|FL_PROMOTED1))
|
||||
#define OBJ_PROMOTED(x) (SPECIAL_CONST_P(x) ? 0 : OBJ_PROMOTED_RAW(x))
|
||||
#define OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
|
||||
#define RB_OBJ_PROMOTED_RAW(x) (\
|
||||
(RBASIC(x)->flags & (RUBY_FL_PROMOTED0|RUBY_FL_PROMOTED1)) == \
|
||||
(RUBY_FL_PROMOTED0|RUBY_FL_PROMOTED1))
|
||||
#define RB_OBJ_PROMOTED(x) (RB_SPECIAL_CONST_P(x) ? 0 : RB_OBJ_PROMOTED_RAW(x))
|
||||
#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
|
||||
|
||||
void rb_gc_writebarrier(VALUE a, VALUE b);
|
||||
void rb_gc_writebarrier_unprotect(VALUE obj);
|
||||
|
||||
#else /* USE_RGENGC */
|
||||
#define OBJ_PROMOTED(x) 0
|
||||
#define OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
|
||||
#define RB_OBJ_PROMOTED(x) 0
|
||||
#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
|
||||
#endif
|
||||
#define OBJ_PROMOTED_RAW(x) RB_OBJ_PROMOTED_RAW(x)
|
||||
#define OBJ_PROMOTED(x) RB_OBJ_PROMOTED(x)
|
||||
#define OBJ_WB_UNPROTECT(x) RB_OBJ_WB_UNPROTECT(x)
|
||||
|
||||
/* Write barrier (WB) interfaces:
|
||||
* - RB_OBJ_WRITE(a, slot, b): WB for new reference from `a' to `b'.
|
||||
|
@ -1343,7 +1461,7 @@ rb_obj_written(VALUE a, RB_UNUSED_VAR(VALUE oldv), VALUE b, RB_UNUSED_VAR(const
|
|||
#endif
|
||||
|
||||
#if USE_RGENGC
|
||||
if (!SPECIAL_CONST_P(b)) {
|
||||
if (!RB_SPECIAL_CONST_P(b)) {
|
||||
rb_gc_writebarrier(a, b);
|
||||
}
|
||||
#endif
|
||||
|
@ -1367,67 +1485,80 @@ rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename),
|
|||
}
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_LONG
|
||||
# define INT2NUM(v) INT2FIX((int)(v))
|
||||
# define UINT2NUM(v) LONG2FIX((unsigned int)(v))
|
||||
# define RB_INT2NUM(v) INT2FIX((int)(v))
|
||||
# define RB_UINT2NUM(v) LONG2FIX((unsigned int)(v))
|
||||
#else
|
||||
static inline VALUE
|
||||
rb_int2num_inline(int v)
|
||||
{
|
||||
if (FIXABLE(v))
|
||||
if (RB_FIXABLE(v))
|
||||
return INT2FIX(v);
|
||||
else
|
||||
return rb_int2big(v);
|
||||
}
|
||||
#define INT2NUM(x) rb_int2num_inline(x)
|
||||
#define RB_INT2NUM(x) rb_int2num_inline(x)
|
||||
|
||||
static inline VALUE
|
||||
rb_uint2num_inline(unsigned int v)
|
||||
{
|
||||
if (POSFIXABLE(v))
|
||||
if (RB_POSFIXABLE(v))
|
||||
return LONG2FIX(v);
|
||||
else
|
||||
return rb_uint2big(v);
|
||||
}
|
||||
#define UINT2NUM(x) rb_uint2num_inline(x)
|
||||
#define RB_UINT2NUM(x) rb_uint2num_inline(x)
|
||||
#endif
|
||||
#define INT2NUM(x) RB_INT2NUM(x)
|
||||
#define UINT2NUM(x) RB_UINT2NUM(x)
|
||||
|
||||
static inline VALUE
|
||||
rb_long2num_inline(long v)
|
||||
{
|
||||
if (FIXABLE(v))
|
||||
if (RB_FIXABLE(v))
|
||||
return LONG2FIX(v);
|
||||
else
|
||||
return rb_int2big(v);
|
||||
}
|
||||
#define LONG2NUM(x) rb_long2num_inline(x)
|
||||
#define RB_LONG2NUM(x) rb_long2num_inline(x)
|
||||
|
||||
static inline VALUE
|
||||
rb_ulong2num_inline(unsigned long v)
|
||||
{
|
||||
if (POSFIXABLE(v))
|
||||
if (RB_POSFIXABLE(v))
|
||||
return LONG2FIX(v);
|
||||
else
|
||||
return rb_uint2big(v);
|
||||
}
|
||||
#define ULONG2NUM(x) rb_ulong2num_inline(x)
|
||||
#define RB_ULONG2NUM(x) rb_ulong2num_inline(x)
|
||||
|
||||
static inline char
|
||||
rb_num2char_inline(VALUE x)
|
||||
{
|
||||
if (RB_TYPE_P(x, T_STRING) && (RSTRING_LEN(x)>=1))
|
||||
if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
|
||||
return RSTRING_PTR(x)[0];
|
||||
else
|
||||
return (char)(NUM2INT(x) & 0xff);
|
||||
}
|
||||
#define NUM2CHR(x) rb_num2char_inline(x)
|
||||
#define RB_NUM2CHR(x) rb_num2char_inline(x)
|
||||
|
||||
#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
|
||||
#define RB_CHR2FIX(x) INT2FIX((long)((x)&0xff))
|
||||
|
||||
#define ALLOC_N(type,n) ((type*)xmalloc2((n),sizeof(type)))
|
||||
#define ALLOC(type) ((type*)xmalloc(sizeof(type)))
|
||||
#define ZALLOC_N(type,n) ((type*)xcalloc((n),sizeof(type)))
|
||||
#define ZALLOC(type) (ZALLOC_N(type,1))
|
||||
#define REALLOC_N(var,type,n) ((var)=(type*)xrealloc2((char*)(var),(n),sizeof(type)))
|
||||
#define LONG2NUM(x) RB_LONG2NUM(x)
|
||||
#define ULONG2NUM(x) RB_ULONG2NUM(x)
|
||||
#define NUM2CHR(x) RB_NUM2CHR(x)
|
||||
#define CHR2FIX(x) RB_CHR2FIX(x)
|
||||
|
||||
#define RB_ALLOC_N(type,n) ((type*)ruby_xmalloc2((n),sizeof(type)))
|
||||
#define RB_ALLOC(type) ((type*)ruby_xmalloc(sizeof(type)))
|
||||
#define RB_ZALLOC_N(type,n) ((type*)ruby_xcalloc((n),sizeof(type)))
|
||||
#define RB_ZALLOC(type) (RB_ZALLOC_N(type,1))
|
||||
#define RB_REALLOC_N(var,type,n) ((var)=(type*)ruby_xrealloc2((char*)(var),(n),sizeof(type)))
|
||||
|
||||
#define ALLOC_N(type,n) RB_ALLOC_N(type,n)
|
||||
#define ALLOC(type) RB_ALLOC(type)
|
||||
#define ZALLOC_N(type,n) RB_ZALLOC_N(type,n)
|
||||
#define ZALLOC(type) RB_ZALLOC(type)
|
||||
#define REALLOC_N(var,type,n) RB_REALLOC_N(var,type,n)
|
||||
|
||||
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
|
||||
|
||||
|
@ -1445,20 +1576,24 @@ ruby_xmalloc2_size(const size_t count, const size_t elsize)
|
|||
/* allocates _n_ bytes temporary buffer and stores VALUE including it
|
||||
* in _v_. _n_ may be evaluated twice. */
|
||||
#ifdef C_ALLOCA
|
||||
# define ALLOCV(v, n) rb_alloc_tmp_buffer(&(v), (n))
|
||||
# define ALLOCV_N(type, v, n) \
|
||||
((type*)ALLOCV((v), ruby_xmalloc2_size((n), sizeof(type))))
|
||||
# define RB_ALLOCV(v, n) rb_alloc_tmp_buffer(&(v), (n))
|
||||
# define RB_ALLOCV_N(type, v, n) \
|
||||
((type*)RB_ALLOCV((v), ruby_xmalloc2_size((n), sizeof(type))))
|
||||
#else
|
||||
# define ALLOCV_LIMIT 1024
|
||||
# define ALLOCV(v, n) ((n) < ALLOCV_LIMIT ? \
|
||||
# define RUBY_ALLOCV_LIMIT 1024
|
||||
# define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \
|
||||
(RB_GC_GUARD(v) = 0, alloca(n)) : \
|
||||
rb_alloc_tmp_buffer(&(v), (n)))
|
||||
# define ALLOCV_N(type, v, n) \
|
||||
((type*)(ruby_xmalloc2_size((n), sizeof(type)) < ALLOCV_LIMIT ? \
|
||||
# define RB_ALLOCV_N(type, v, n) \
|
||||
((type*)(ruby_xmalloc2_size((n), sizeof(type)) < RUBY_ALLOCV_LIMIT ? \
|
||||
(RB_GC_GUARD(v) = 0, alloca((n) * sizeof(type))) : \
|
||||
rb_alloc_tmp_buffer(&(v), (n) * sizeof(type))))
|
||||
#endif
|
||||
#define ALLOCV_END(v) rb_free_tmp_buffer(&(v))
|
||||
#define RB_ALLOCV_END(v) rb_free_tmp_buffer(&(v))
|
||||
|
||||
#define ALLOCV(v, n) RB_ALLOCV(v, n)
|
||||
#define ALLOCV_N(type, v, n) RB_ALLOCV_N(type, v, n)
|
||||
#define ALLOCV_END(v) RB_ALLOCV_END(v)
|
||||
|
||||
#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
|
||||
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
|
||||
|
@ -1533,15 +1668,17 @@ VALUE rb_sym2str(VALUE);
|
|||
VALUE rb_to_symbol(VALUE name);
|
||||
VALUE rb_check_symbol(volatile VALUE *namep);
|
||||
|
||||
#define CONST_ID_CACHE(result, str) \
|
||||
#define RUBY_CONST_ID_CACHE(result, str) \
|
||||
{ \
|
||||
static ID rb_intern_id_cache; \
|
||||
if (!rb_intern_id_cache) \
|
||||
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
|
||||
result rb_intern_id_cache; \
|
||||
}
|
||||
#define CONST_ID(var, str) \
|
||||
do CONST_ID_CACHE((var) =, (str)) while (0)
|
||||
#define RUBY_CONST_ID(var, str) \
|
||||
do RUBY_CONST_ID_CACHE((var) =, (str)) while (0)
|
||||
#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
|
||||
#define CONST_ID(var, str) RUBY_CONST_ID(var, str)
|
||||
#ifdef __GNUC__
|
||||
/* __builtin_constant_p and statement expression is available
|
||||
* since gcc-2.7.2.3 at least. */
|
||||
|
@ -1747,15 +1884,15 @@ RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
|
|||
static inline VALUE
|
||||
rb_class_of(VALUE obj)
|
||||
{
|
||||
if (IMMEDIATE_P(obj)) {
|
||||
if (FIXNUM_P(obj)) return rb_cFixnum;
|
||||
if (FLONUM_P(obj)) return rb_cFloat;
|
||||
if (obj == Qtrue) return rb_cTrueClass;
|
||||
if (STATIC_SYM_P(obj)) return rb_cSymbol;
|
||||
if (RB_IMMEDIATE_P(obj)) {
|
||||
if (RB_FIXNUM_P(obj)) return rb_cFixnum;
|
||||
if (RB_FLONUM_P(obj)) return rb_cFloat;
|
||||
if (obj == RUBY_Qtrue) return rb_cTrueClass;
|
||||
if (RB_STATIC_SYM_P(obj)) return rb_cSymbol;
|
||||
}
|
||||
else if (!RTEST(obj)) {
|
||||
if (obj == Qnil) return rb_cNilClass;
|
||||
if (obj == Qfalse) return rb_cFalseClass;
|
||||
if (obj == RUBY_Qnil) return rb_cNilClass;
|
||||
if (obj == RUBY_Qfalse) return rb_cFalseClass;
|
||||
}
|
||||
return RBASIC(obj)->klass;
|
||||
}
|
||||
|
@ -1763,18 +1900,18 @@ rb_class_of(VALUE obj)
|
|||
static inline int
|
||||
rb_type(VALUE obj)
|
||||
{
|
||||
if (IMMEDIATE_P(obj)) {
|
||||
if (FIXNUM_P(obj)) return T_FIXNUM;
|
||||
if (FLONUM_P(obj)) return T_FLOAT;
|
||||
if (obj == Qtrue) return T_TRUE;
|
||||
if (STATIC_SYM_P(obj)) return T_SYMBOL;
|
||||
if (obj == Qundef) return T_UNDEF;
|
||||
if (RB_IMMEDIATE_P(obj)) {
|
||||
if (RB_FIXNUM_P(obj)) return RUBY_T_FIXNUM;
|
||||
if (RB_FLONUM_P(obj)) return RUBY_T_FLOAT;
|
||||
if (obj == RUBY_Qtrue) return RUBY_T_TRUE;
|
||||
if (RB_STATIC_SYM_P(obj)) return RUBY_T_SYMBOL;
|
||||
if (obj == RUBY_Qundef) return RUBY_T_UNDEF;
|
||||
}
|
||||
else if (!RTEST(obj)) {
|
||||
if (obj == Qnil) return T_NIL;
|
||||
if (obj == Qfalse) return T_FALSE;
|
||||
if (obj == RUBY_Qnil) return RUBY_T_NIL;
|
||||
if (obj == RUBY_Qfalse) return RUBY_T_FALSE;
|
||||
}
|
||||
return BUILTIN_TYPE(obj);
|
||||
return RB_BUILTIN_TYPE(obj);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -1787,13 +1924,16 @@ rb_type(VALUE obj)
|
|||
|
||||
#ifdef __GNUC__
|
||||
#define rb_special_const_p(obj) \
|
||||
__extension__ ({VALUE special_const_obj = (obj); (int)(SPECIAL_CONST_P(special_const_obj) ? Qtrue : Qfalse);})
|
||||
__extension__ ({ \
|
||||
VALUE special_const_obj = (obj); \
|
||||
(int)(RB_SPECIAL_CONST_P(special_const_obj) ? RUBY_Qtrue : RUBY_Qfalse); \
|
||||
})
|
||||
#else
|
||||
static inline int
|
||||
rb_special_const_p(VALUE obj)
|
||||
{
|
||||
if (SPECIAL_CONST_P(obj)) return (int)Qtrue;
|
||||
return (int)Qfalse;
|
||||
if (RB_SPECIAL_CONST_P(obj)) return (int)RUBY_Qtrue;
|
||||
return (int)RUBY_Qfalse;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче