2000-05-01 09:42:38 +00:00
|
|
|
/**********************************************************************
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2008-05-31 05:55:34 +00:00
|
|
|
ruby/ruby.h -
|
1998-01-16 12:13:05 +00:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Thu Jun 10 14:26:32 JST 1993
|
|
|
|
|
2008-05-31 05:55:34 +00:00
|
|
|
Copyright (C) 1993-2008 Yukihiro Matsumoto
|
2000-05-01 09:42:38 +00:00
|
|
|
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
2000-05-09 04:53:16 +00:00
|
|
|
Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2000-05-01 09:42:38 +00:00
|
|
|
**********************************************************************/
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2008-05-31 05:55:34 +00:00
|
|
|
#ifndef RUBY_RUBY_H
|
|
|
|
#define RUBY_RUBY_H 1
|
1998-01-16 12:13:05 +00:00
|
|
|
|
1999-01-20 04:59:39 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
2005-09-14 13:41:02 +00:00
|
|
|
#if 0
|
|
|
|
} /* satisfy cc-mode */
|
|
|
|
#endif
|
1999-01-20 04:59:39 +00:00
|
|
|
#endif
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2007-06-10 03:06:15 +00:00
|
|
|
#include "ruby/config.h"
|
2006-05-25 23:44:08 +00:00
|
|
|
#ifdef RUBY_EXTCONF_H
|
|
|
|
#include RUBY_EXTCONF_H
|
|
|
|
#endif
|
2005-07-02 08:11:24 +00:00
|
|
|
|
2016-01-07 13:35:32 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
/* __builtin_choose_expr and __builtin_types_compatible aren't available
|
|
|
|
* on C++. See https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
|
|
|
|
# undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
|
|
|
|
# undef HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P
|
|
|
|
#endif
|
|
|
|
|
2013-03-27 22:13:06 +00:00
|
|
|
#include "defines.h"
|
|
|
|
|
2015-07-22 11:27:46 +00:00
|
|
|
#ifndef ASSUME
|
|
|
|
# ifdef UNREACHABLE
|
2016-04-23 07:15:25 +00:00
|
|
|
# define ASSUME(x) (RB_LIKELY(!!(x)) ? (void)0 : UNREACHABLE)
|
2015-07-22 11:27:46 +00:00
|
|
|
# else
|
2015-09-05 23:14:18 +00:00
|
|
|
# define ASSUME(x) ((void)(x))
|
2015-07-22 11:27:46 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
2012-02-24 06:49:09 +00:00
|
|
|
#ifndef UNREACHABLE
|
2015-07-22 11:27:46 +00:00
|
|
|
# define UNREACHABLE ((void)0) /* unreachable */
|
2012-02-24 06:49:09 +00:00
|
|
|
#endif
|
2005-07-02 08:11:24 +00:00
|
|
|
|
2014-09-28 15:27:24 +00:00
|
|
|
#define RUBY_MACRO_SELECT(base, n) TOKEN_PASTE(base, n)
|
|
|
|
|
2003-12-22 08:23:55 +00:00
|
|
|
#ifdef HAVE_INTRINSICS_H
|
|
|
|
# include <intrinsics.h>
|
|
|
|
#endif
|
|
|
|
|
2010-04-04 01:10:53 +00:00
|
|
|
#include <stdarg.h>
|
2005-12-06 07:52:18 +00:00
|
|
|
|
2013-04-05 10:29:38 +00:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 21:38:25 +00:00
|
|
|
|
2012-11-09 03:34:08 +00:00
|
|
|
/* Make alloca work the best possible way. */
|
|
|
|
#ifdef __GNUC__
|
|
|
|
# ifndef atarist
|
|
|
|
# ifndef alloca
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
# endif
|
|
|
|
# endif /* atarist */
|
2006-08-07 03:37:47 +00:00
|
|
|
#else
|
2012-11-09 03:34:08 +00:00
|
|
|
# ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
# else
|
2006-08-07 03:37:47 +00:00
|
|
|
# ifdef _AIX
|
1998-01-16 12:13:05 +00:00
|
|
|
#pragma alloca
|
2012-11-09 03:34:08 +00:00
|
|
|
# else
|
|
|
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
|
|
|
void *alloca();
|
|
|
|
# endif
|
|
|
|
# endif /* AIX */
|
|
|
|
# endif /* HAVE_ALLOCA_H */
|
|
|
|
#endif /* __GNUC__ */
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2010-10-15 13:47:38 +00:00
|
|
|
#if defined HAVE_UINTPTR_T && 0
|
2009-01-16 02:41:26 +00:00
|
|
|
typedef uintptr_t VALUE;
|
|
|
|
typedef uintptr_t ID;
|
|
|
|
# define SIGNED_VALUE intptr_t
|
|
|
|
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
2009-01-16 09:31:05 +00:00
|
|
|
# undef PRI_VALUE_PREFIX
|
2009-01-16 02:41:26 +00:00
|
|
|
#elif SIZEOF_LONG == SIZEOF_VOIDP
|
1999-01-20 04:59:39 +00:00
|
|
|
typedef unsigned long VALUE;
|
1999-12-14 06:50:43 +00:00
|
|
|
typedef unsigned long ID;
|
2006-07-11 05:00:02 +00:00
|
|
|
# define SIGNED_VALUE long
|
2006-07-11 06:47:09 +00:00
|
|
|
# define SIZEOF_VALUE SIZEOF_LONG
|
2008-07-12 13:17:29 +00:00
|
|
|
# define PRI_VALUE_PREFIX "l"
|
2005-07-26 09:16:37 +00:00
|
|
|
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
2005-07-27 07:27:19 +00:00
|
|
|
typedef unsigned LONG_LONG VALUE;
|
|
|
|
typedef unsigned LONG_LONG ID;
|
2006-07-11 05:00:02 +00:00
|
|
|
# define SIGNED_VALUE LONG_LONG
|
|
|
|
# define LONG_LONG_VALUE 1
|
2006-07-11 06:47:09 +00:00
|
|
|
# define SIZEOF_VALUE SIZEOF_LONG_LONG
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_VALUE_PREFIX PRI_LL_PREFIX
|
2005-07-26 09:16:37 +00:00
|
|
|
#else
|
2011-12-28 16:56:16 +00:00
|
|
|
# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
2005-07-26 09:16:37 +00:00
|
|
|
#endif
|
2009-01-16 02:41:26 +00:00
|
|
|
|
2009-03-13 01:42:21 +00:00
|
|
|
typedef char ruby_check_sizeof_int[SIZEOF_INT == sizeof(int) ? 1 : -1];
|
|
|
|
typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
|
2013-05-14 14:27:25 +00:00
|
|
|
#ifdef HAVE_LONG_LONG
|
2009-03-13 01:42:21 +00:00
|
|
|
typedef char ruby_check_sizeof_long_long[SIZEOF_LONG_LONG == sizeof(LONG_LONG) ? 1 : -1];
|
|
|
|
#endif
|
|
|
|
typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
|
|
|
|
|
2010-11-11 11:49:54 +00:00
|
|
|
#ifndef PRI_INT_PREFIX
|
|
|
|
#define PRI_INT_PREFIX ""
|
|
|
|
#endif
|
|
|
|
#ifndef PRI_LONG_PREFIX
|
|
|
|
#define PRI_LONG_PREFIX "l"
|
|
|
|
#endif
|
|
|
|
|
2013-06-18 09:46:01 +00:00
|
|
|
#if SIZEOF_LONG == 8
|
|
|
|
#define PRI_64_PREFIX PRI_LONG_PREFIX
|
|
|
|
#elif SIZEOF_LONG_LONG == 8
|
|
|
|
#define PRI_64_PREFIX PRI_LL_PREFIX
|
|
|
|
#endif
|
|
|
|
|
2014-11-04 03:51:33 +00:00
|
|
|
#define RUBY_PRI_VALUE_MARK "\v"
|
2009-01-16 09:31:05 +00:00
|
|
|
#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
|
2009-01-16 02:41:26 +00:00
|
|
|
#define PRIdVALUE PRIdPTR
|
|
|
|
#define PRIoVALUE PRIoPTR
|
|
|
|
#define PRIuVALUE PRIuPTR
|
|
|
|
#define PRIxVALUE PRIxPTR
|
|
|
|
#define PRIXVALUE PRIXPTR
|
2014-12-19 11:00:22 +00:00
|
|
|
#define PRIsVALUE PRIiPTR"" RUBY_PRI_VALUE_MARK
|
2009-01-16 02:41:26 +00:00
|
|
|
#else
|
2008-07-12 13:17:29 +00:00
|
|
|
#define PRIdVALUE PRI_VALUE_PREFIX"d"
|
|
|
|
#define PRIoVALUE PRI_VALUE_PREFIX"o"
|
|
|
|
#define PRIuVALUE PRI_VALUE_PREFIX"u"
|
|
|
|
#define PRIxVALUE PRI_VALUE_PREFIX"x"
|
|
|
|
#define PRIXVALUE PRI_VALUE_PREFIX"X"
|
2014-12-19 11:00:22 +00:00
|
|
|
#define PRIsVALUE PRI_VALUE_PREFIX"i" RUBY_PRI_VALUE_MARK
|
2009-01-16 02:41:26 +00:00
|
|
|
#endif
|
2009-01-16 09:31:05 +00:00
|
|
|
#ifndef PRI_VALUE_PREFIX
|
|
|
|
# define PRI_VALUE_PREFIX ""
|
|
|
|
#endif
|
2008-07-12 13:17:29 +00:00
|
|
|
|
2010-04-01 03:06:07 +00:00
|
|
|
#ifndef PRI_TIMET_PREFIX
|
|
|
|
# if SIZEOF_TIME_T == SIZEOF_INT
|
|
|
|
# define PRI_TIMET_PREFIX
|
|
|
|
# elif SIZEOF_TIME_T == SIZEOF_LONG
|
|
|
|
# define PRI_TIMET_PREFIX "l"
|
|
|
|
# elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_TIMET_PREFIX PRI_LL_PREFIX
|
2010-04-01 03:06:07 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2010-10-12 15:03:51 +00:00
|
|
|
#if defined PRI_PTRDIFF_PREFIX
|
2009-01-16 02:41:26 +00:00
|
|
|
#elif SIZEOF_PTRDIFF_T == SIZEOF_INT
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_PTRDIFF_PREFIX ""
|
2008-07-12 13:17:29 +00:00
|
|
|
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
|
2008-07-12 13:41:42 +00:00
|
|
|
# define PRI_PTRDIFF_PREFIX "l"
|
2008-07-12 20:39:02 +00:00
|
|
|
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_PTRDIFF_PREFIX PRI_LL_PREFIX
|
2008-07-12 13:17:29 +00:00
|
|
|
#endif
|
|
|
|
#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
|
|
|
|
#define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i"
|
|
|
|
#define PRIoPTRDIFF PRI_PTRDIFF_PREFIX"o"
|
|
|
|
#define PRIuPTRDIFF PRI_PTRDIFF_PREFIX"u"
|
|
|
|
#define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
|
|
|
|
#define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
|
|
|
|
|
2010-10-12 15:03:51 +00:00
|
|
|
#if defined PRI_SIZE_PREFIX
|
2009-01-16 02:41:26 +00:00
|
|
|
#elif SIZEOF_SIZE_T == SIZEOF_INT
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_SIZE_PREFIX ""
|
2008-07-12 13:17:29 +00:00
|
|
|
#elif SIZEOF_SIZE_T == SIZEOF_LONG
|
2008-07-12 13:41:42 +00:00
|
|
|
# define PRI_SIZE_PREFIX "l"
|
2008-07-12 20:39:02 +00:00
|
|
|
#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
|
2010-11-11 11:49:54 +00:00
|
|
|
# define PRI_SIZE_PREFIX PRI_LL_PREFIX
|
2008-07-12 13:17:29 +00:00
|
|
|
#endif
|
|
|
|
#define PRIdSIZE PRI_SIZE_PREFIX"d"
|
|
|
|
#define PRIiSIZE PRI_SIZE_PREFIX"i"
|
|
|
|
#define PRIoSIZE PRI_SIZE_PREFIX"o"
|
|
|
|
#define PRIuSIZE PRI_SIZE_PREFIX"u"
|
|
|
|
#define PRIxSIZE PRI_SIZE_PREFIX"x"
|
|
|
|
#define PRIXSIZE PRI_SIZE_PREFIX"X"
|
2006-07-11 06:47:09 +00:00
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
#ifdef __STDC__
|
|
|
|
# include <limits.h>
|
|
|
|
#else
|
|
|
|
# ifndef LONG_MAX
|
|
|
|
# ifdef HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
# else
|
2013-10-13 14:53:40 +00:00
|
|
|
/* assuming 32bit(2's complement) long */
|
1999-01-20 04:59:39 +00:00
|
|
|
# define LONG_MAX 2147483647
|
1998-01-16 12:13:05 +00:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# ifndef LONG_MIN
|
1999-01-20 04:59:39 +00:00
|
|
|
# define LONG_MIN (-LONG_MAX-1)
|
1998-01-16 12:13:05 +00:00
|
|
|
# endif
|
|
|
|
# ifndef CHAR_BIT
|
|
|
|
# define CHAR_BIT 8
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2006-07-31 06:34:10 +00:00
|
|
|
#ifdef HAVE_LONG_LONG
|
2002-03-14 06:23:46 +00:00
|
|
|
# ifndef LLONG_MAX
|
|
|
|
# ifdef LONG_LONG_MAX
|
|
|
|
# define LLONG_MAX LONG_LONG_MAX
|
|
|
|
# else
|
* bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
long long.
* numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
* ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-15 08:51:31 +00:00
|
|
|
# ifdef _I64_MAX
|
|
|
|
# define LLONG_MAX _I64_MAX
|
|
|
|
# else
|
2002-03-14 06:23:46 +00:00
|
|
|
/* assuming 64bit(2's complement) long long */
|
* bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
long long.
* numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
* ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-15 08:51:31 +00:00
|
|
|
# define LLONG_MAX 9223372036854775807LL
|
|
|
|
# endif
|
2002-03-14 06:23:46 +00:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# ifndef LLONG_MIN
|
|
|
|
# ifdef LONG_LONG_MIN
|
|
|
|
# define LLONG_MIN LONG_LONG_MIN
|
|
|
|
# else
|
* bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
long long.
* numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
* ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-15 08:51:31 +00:00
|
|
|
# ifdef _I64_MIN
|
2003-07-29 08:28:54 +00:00
|
|
|
# define LLONG_MIN _I64_MIN
|
* bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
long long.
* numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
* ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-15 08:51:31 +00:00
|
|
|
# else
|
|
|
|
# define LLONG_MIN (-LLONG_MAX-1)
|
|
|
|
# endif
|
2002-03-14 06:23:46 +00:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#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
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#define INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
|
2001-05-30 09:12:34 +00:00
|
|
|
#define LONG2FIX(i) INT2FIX(i)
|
2000-02-17 07:11:22 +00:00
|
|
|
#define rb_fix_new(v) INT2FIX(v)
|
2006-07-11 05:00:02 +00:00
|
|
|
VALUE rb_int2inum(SIGNED_VALUE);
|
2008-08-21 18:49:13 +00:00
|
|
|
|
2000-02-17 07:11:22 +00:00
|
|
|
#define rb_int_new(v) rb_int2inum(v)
|
2006-07-11 05:00:02 +00:00
|
|
|
VALUE rb_uint2inum(VALUE);
|
2008-08-21 18:49:13 +00:00
|
|
|
|
2000-02-17 07:11:22 +00:00
|
|
|
#define rb_uint_new(v) rb_uint2inum(v)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2006-07-31 06:34:10 +00:00
|
|
|
#ifdef HAVE_LONG_LONG
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_ll2inum(LONG_LONG);
|
2002-03-14 06:23:46 +00:00
|
|
|
#define LL2NUM(v) rb_ll2inum(v)
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_ull2inum(unsigned LONG_LONG);
|
2002-03-14 06:23:46 +00:00
|
|
|
#define ULL2NUM(v) rb_ull2inum(v)
|
|
|
|
#endif
|
|
|
|
|
2013-05-12 12:13:01 +00:00
|
|
|
#ifndef OFFT2NUM
|
2002-03-27 05:28:00 +00:00
|
|
|
#if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
|
2002-03-14 06:23:46 +00:00
|
|
|
# define OFFT2NUM(v) LL2NUM(v)
|
2006-12-04 08:06:32 +00:00
|
|
|
#elif SIZEOF_OFF_T == SIZEOF_LONG
|
|
|
|
# define OFFT2NUM(v) LONG2NUM(v)
|
2002-03-14 06:23:46 +00:00
|
|
|
#else
|
|
|
|
# define OFFT2NUM(v) INT2NUM(v)
|
|
|
|
#endif
|
2013-05-12 12:13:01 +00:00
|
|
|
#endif
|
2002-03-14 06:23:46 +00:00
|
|
|
|
2008-05-11 05:44:36 +00:00
|
|
|
#if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
|
|
|
|
# define SIZET2NUM(v) ULL2NUM(v)
|
2008-08-15 23:53:07 +00:00
|
|
|
# define SSIZET2NUM(v) LL2NUM(v)
|
2008-05-11 05:44:36 +00:00
|
|
|
#elif SIZEOF_SIZE_T == SIZEOF_LONG
|
|
|
|
# define SIZET2NUM(v) ULONG2NUM(v)
|
2008-08-15 23:53:07 +00:00
|
|
|
# define SSIZET2NUM(v) LONG2NUM(v)
|
2008-05-11 05:44:36 +00:00
|
|
|
#else
|
|
|
|
# define SIZET2NUM(v) UINT2NUM(v)
|
2008-08-15 23:53:07 +00:00
|
|
|
# define SSIZET2NUM(v) INT2NUM(v)
|
|
|
|
#endif
|
|
|
|
|
2011-10-27 00:59:46 +00:00
|
|
|
#ifndef SIZE_MAX
|
|
|
|
# if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
|
|
|
|
# define SIZE_MAX ULLONG_MAX
|
|
|
|
# define SIZE_MIN ULLONG_MIN
|
|
|
|
# elif SIZEOF_SIZE_T == SIZEOF_LONG
|
|
|
|
# define SIZE_MAX ULONG_MAX
|
|
|
|
# define SIZE_MIN ULONG_MIN
|
|
|
|
# elif SIZEOF_SIZE_T == SIZEOF_INT
|
|
|
|
# define SIZE_MAX UINT_MAX
|
|
|
|
# define SIZE_MIN UINT_MIN
|
|
|
|
# else
|
|
|
|
# define SIZE_MAX USHRT_MAX
|
|
|
|
# define SIZE_MIN USHRT_MIN
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2008-08-15 23:53:07 +00:00
|
|
|
#ifndef SSIZE_MAX
|
|
|
|
# if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
|
|
|
|
# define SSIZE_MAX LLONG_MAX
|
|
|
|
# define SSIZE_MIN LLONG_MIN
|
|
|
|
# elif SIZEOF_SIZE_T == SIZEOF_LONG
|
|
|
|
# define SSIZE_MAX LONG_MAX
|
|
|
|
# define SSIZE_MIN LONG_MIN
|
|
|
|
# elif SIZEOF_SIZE_T == SIZEOF_INT
|
|
|
|
# define SSIZE_MAX INT_MAX
|
|
|
|
# define SSIZE_MIN INT_MIN
|
|
|
|
# else
|
|
|
|
# define SSIZE_MAX SHRT_MAX
|
|
|
|
# define SSIZE_MIN SHRT_MIN
|
2008-08-16 00:07:46 +00:00
|
|
|
# endif
|
2008-05-11 05:44:36 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-28 07:45:00 +00:00
|
|
|
#if SIZEOF_INT < SIZEOF_VALUE
|
|
|
|
NORETURN(void rb_out_of_int(SIGNED_VALUE num));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SIZEOF_INT < SIZEOF_LONG
|
|
|
|
static inline int
|
2011-11-15 04:18:43 +00:00
|
|
|
rb_long2int_inline(long n)
|
|
|
|
{
|
|
|
|
int i = (int)n;
|
|
|
|
if ((long)i != n)
|
|
|
|
rb_out_of_int(n);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2011-11-08 08:59:28 +00:00
|
|
|
#define rb_long2int(n) rb_long2int_inline(n)
|
2010-04-28 07:45:00 +00:00
|
|
|
#else
|
|
|
|
#define rb_long2int(n) ((int)(n))
|
|
|
|
#endif
|
|
|
|
|
2007-02-19 13:16:12 +00:00
|
|
|
#ifndef PIDT2NUM
|
|
|
|
#define PIDT2NUM(v) LONG2NUM(v)
|
|
|
|
#endif
|
|
|
|
#ifndef NUM2PIDT
|
|
|
|
#define NUM2PIDT(v) NUM2LONG(v)
|
|
|
|
#endif
|
|
|
|
#ifndef UIDT2NUM
|
|
|
|
#define UIDT2NUM(v) LONG2NUM(v)
|
|
|
|
#endif
|
|
|
|
#ifndef NUM2UIDT
|
|
|
|
#define NUM2UIDT(v) NUM2LONG(v)
|
|
|
|
#endif
|
|
|
|
#ifndef GIDT2NUM
|
|
|
|
#define GIDT2NUM(v) LONG2NUM(v)
|
|
|
|
#endif
|
|
|
|
#ifndef NUM2GIDT
|
|
|
|
#define NUM2GIDT(v) NUM2LONG(v)
|
|
|
|
#endif
|
2011-01-29 16:06:00 +00:00
|
|
|
#ifndef NUM2MODET
|
|
|
|
#define NUM2MODET(v) NUM2INT(v)
|
|
|
|
#endif
|
|
|
|
#ifndef MODET2NUM
|
|
|
|
#define MODET2NUM(v) INT2NUM(v)
|
|
|
|
#endif
|
2007-02-19 13:16:12 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#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 RB_IMMEDIATE_P(x) ((VALUE)(x) & RUBY_IMMEDIATE_MASK)
|
|
|
|
#define IMMEDIATE_P(x) RB_IMMEDIATE_P(x)
|
2000-03-07 08:37:59 +00:00
|
|
|
|
2014-03-26 04:57:47 +00:00
|
|
|
ID rb_sym2id(VALUE);
|
|
|
|
VALUE rb_id2sym(ID);
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2000-03-07 08:37:59 +00:00
|
|
|
|
2012-08-23 07:22:40 +00:00
|
|
|
#ifndef USE_FLONUM
|
|
|
|
#if SIZEOF_VALUE >= SIZEOF_DOUBLE
|
|
|
|
#define USE_FLONUM 1
|
|
|
|
#else
|
|
|
|
#define USE_FLONUM 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_FLONUM
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FLONUM_P(x) ((((int)(SIGNED_VALUE)(x))&RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG)
|
2012-08-23 07:22:40 +00:00
|
|
|
#else
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FLONUM_P(x) 0
|
2012-08-23 07:22:40 +00:00
|
|
|
#endif
|
2015-09-13 02:03:31 +00:00
|
|
|
#define FLONUM_P(x) RB_FLONUM_P(x)
|
2012-08-23 07:22:40 +00:00
|
|
|
|
2009-02-23 01:19:43 +00:00
|
|
|
/* Module#methods, #singleton_methods and so on return Symbols */
|
|
|
|
#define USE_SYMBOL_AS_METHOD_NAME 1
|
|
|
|
|
2008-09-09 11:59:40 +00:00
|
|
|
/* special constants - i.e. non-zero and non-fixnum constants */
|
2007-07-05 01:42:09 +00:00
|
|
|
enum ruby_special_consts {
|
2012-08-23 07:22:40 +00:00
|
|
|
#if USE_FLONUM
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_Qfalse = 0x00, /* ...0000 0000 */
|
|
|
|
RUBY_Qtrue = 0x14, /* ...0001 0100 */
|
|
|
|
RUBY_Qnil = 0x08, /* ...0000 1000 */
|
|
|
|
RUBY_Qundef = 0x34, /* ...0011 0100 */
|
2012-08-23 07:22:40 +00:00
|
|
|
|
|
|
|
RUBY_IMMEDIATE_MASK = 0x07,
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
2012-08-23 07:22:40 +00:00
|
|
|
RUBY_FLONUM_MASK = 0x03,
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_FLONUM_FLAG = 0x02, /* ...xxxx xx10 */
|
|
|
|
RUBY_SYMBOL_FLAG = 0x0c, /* ...0000 1100 */
|
2012-08-23 07:22:40 +00:00
|
|
|
#else
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_Qfalse = 0, /* ...0000 0000 */
|
|
|
|
RUBY_Qtrue = 2, /* ...0000 0010 */
|
|
|
|
RUBY_Qnil = 4, /* ...0000 0100 */
|
|
|
|
RUBY_Qundef = 6, /* ...0000 0110 */
|
2007-07-05 01:42:09 +00:00
|
|
|
|
|
|
|
RUBY_IMMEDIATE_MASK = 0x03,
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
|
2012-09-06 05:49:51 +00:00
|
|
|
RUBY_FLONUM_MASK = 0x00, /* any values ANDed with FLONUM_MASK cannot be FLONUM_FLAG */
|
|
|
|
RUBY_FLONUM_FLAG = 0x02,
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_SYMBOL_FLAG = 0x0e, /* ...0000 1110 */
|
2012-08-23 07:22:40 +00:00
|
|
|
#endif
|
2014-09-12 07:44:10 +00:00
|
|
|
RUBY_SPECIAL_SHIFT = 8
|
2007-07-05 01:42:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define Qfalse ((VALUE)RUBY_Qfalse)
|
|
|
|
#define Qtrue ((VALUE)RUBY_Qtrue)
|
|
|
|
#define Qnil ((VALUE)RUBY_Qnil)
|
|
|
|
#define Qundef ((VALUE)RUBY_Qundef) /* undefined value for placeholder */
|
|
|
|
#define IMMEDIATE_MASK RUBY_IMMEDIATE_MASK
|
|
|
|
#define FIXNUM_FLAG RUBY_FIXNUM_FLAG
|
2012-08-23 07:22:40 +00:00
|
|
|
#if USE_FLONUM
|
|
|
|
#define FLONUM_MASK RUBY_FLONUM_MASK
|
|
|
|
#define FLONUM_FLAG RUBY_FLONUM_FLAG
|
|
|
|
#endif
|
2007-07-05 01:42:09 +00:00
|
|
|
#define SYMBOL_FLAG RUBY_SYMBOL_FLAG
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2012-12-20 09:29:57 +00:00
|
|
|
#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
|
|
|
|
#define NIL_P(v) !((VALUE)(v) != Qnil)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
|
|
|
#define CLASS_OF(v) rb_class_of((VALUE)(v))
|
|
|
|
|
2007-07-05 01:42:09 +00:00
|
|
|
enum ruby_value_type {
|
|
|
|
RUBY_T_NONE = 0x00,
|
|
|
|
|
2008-04-26 08:32:23 +00:00
|
|
|
RUBY_T_OBJECT = 0x01,
|
|
|
|
RUBY_T_CLASS = 0x02,
|
|
|
|
RUBY_T_MODULE = 0x03,
|
|
|
|
RUBY_T_FLOAT = 0x04,
|
|
|
|
RUBY_T_STRING = 0x05,
|
|
|
|
RUBY_T_REGEXP = 0x06,
|
|
|
|
RUBY_T_ARRAY = 0x07,
|
|
|
|
RUBY_T_HASH = 0x08,
|
|
|
|
RUBY_T_STRUCT = 0x09,
|
|
|
|
RUBY_T_BIGNUM = 0x0a,
|
|
|
|
RUBY_T_FILE = 0x0b,
|
|
|
|
RUBY_T_DATA = 0x0c,
|
|
|
|
RUBY_T_MATCH = 0x0d,
|
|
|
|
RUBY_T_COMPLEX = 0x0e,
|
|
|
|
RUBY_T_RATIONAL = 0x0f,
|
|
|
|
|
|
|
|
RUBY_T_NIL = 0x11,
|
|
|
|
RUBY_T_TRUE = 0x12,
|
|
|
|
RUBY_T_FALSE = 0x13,
|
|
|
|
RUBY_T_SYMBOL = 0x14,
|
|
|
|
RUBY_T_FIXNUM = 0x15,
|
2015-03-11 10:36:17 +00:00
|
|
|
RUBY_T_UNDEF = 0x16,
|
2008-04-26 08:32:23 +00:00
|
|
|
|
2015-03-11 10:36:17 +00:00
|
|
|
RUBY_T_IMEMO = 0x1a,
|
|
|
|
RUBY_T_NODE = 0x1b,
|
|
|
|
RUBY_T_ICLASS = 0x1c,
|
|
|
|
RUBY_T_ZOMBIE = 0x1d,
|
2008-04-26 08:32:23 +00:00
|
|
|
|
2008-07-01 08:27:58 +00:00
|
|
|
RUBY_T_MASK = 0x1f
|
2008-04-26 08:32:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define T_NONE RUBY_T_NONE
|
2007-07-05 01:42:09 +00:00
|
|
|
#define T_NIL RUBY_T_NIL
|
|
|
|
#define T_OBJECT RUBY_T_OBJECT
|
|
|
|
#define T_CLASS RUBY_T_CLASS
|
|
|
|
#define T_ICLASS RUBY_T_ICLASS
|
|
|
|
#define T_MODULE RUBY_T_MODULE
|
|
|
|
#define T_FLOAT RUBY_T_FLOAT
|
|
|
|
#define T_STRING RUBY_T_STRING
|
|
|
|
#define T_REGEXP RUBY_T_REGEXP
|
|
|
|
#define T_ARRAY RUBY_T_ARRAY
|
|
|
|
#define T_HASH RUBY_T_HASH
|
|
|
|
#define T_STRUCT RUBY_T_STRUCT
|
|
|
|
#define T_BIGNUM RUBY_T_BIGNUM
|
|
|
|
#define T_FILE RUBY_T_FILE
|
2008-04-26 08:32:23 +00:00
|
|
|
#define T_FIXNUM RUBY_T_FIXNUM
|
2007-07-05 01:42:09 +00:00
|
|
|
#define T_TRUE RUBY_T_TRUE
|
|
|
|
#define T_FALSE RUBY_T_FALSE
|
|
|
|
#define T_DATA RUBY_T_DATA
|
|
|
|
#define T_MATCH RUBY_T_MATCH
|
|
|
|
#define T_SYMBOL RUBY_T_SYMBOL
|
2008-03-16 00:23:43 +00:00
|
|
|
#define T_RATIONAL RUBY_T_RATIONAL
|
|
|
|
#define T_COMPLEX RUBY_T_COMPLEX
|
2015-03-11 10:36:17 +00:00
|
|
|
#define T_IMEMO RUBY_T_IMEMO
|
2007-07-05 01:42:09 +00:00
|
|
|
#define T_UNDEF RUBY_T_UNDEF
|
|
|
|
#define T_NODE RUBY_T_NODE
|
2008-08-29 11:22:42 +00:00
|
|
|
#define T_ZOMBIE RUBY_T_ZOMBIE
|
2007-07-05 01:42:09 +00:00
|
|
|
#define T_MASK RUBY_T_MASK
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
|
|
|
|
#define BUILTIN_TYPE(x) RB_BUILTIN_TYPE(x)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2009-09-18 15:02:21 +00:00
|
|
|
static inline int rb_type(VALUE obj);
|
1998-01-16 12:13:05 +00:00
|
|
|
#define TYPE(x) rb_type((VALUE)(x))
|
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FLOAT_TYPE_P(obj) (\
|
|
|
|
RB_FLONUM_P(obj) || \
|
|
|
|
(!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == RUBY_T_FLOAT))
|
2014-10-30 00:47:58 +00:00
|
|
|
|
|
|
|
#define RB_TYPE_P(obj, type) ( \
|
2015-09-13 02:03:31 +00:00
|
|
|
((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)))
|
2014-10-30 00:47:58 +00:00
|
|
|
|
2009-10-11 00:04:10 +00:00
|
|
|
#ifdef __GNUC__
|
2016-03-17 13:21:36 +00:00
|
|
|
#define RB_GC_GUARD(v) \
|
|
|
|
(*__extension__ ({volatile VALUE *rb_gc_guarded_ptr = &(v); rb_gc_guarded_ptr;}))
|
|
|
|
#elif defined _MSC_VER
|
2010-06-24 16:11:05 +00:00
|
|
|
#pragma optimize("", off)
|
2010-05-09 14:53:16 +00:00
|
|
|
static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}
|
2010-06-24 16:11:05 +00:00
|
|
|
#pragma optimize("", on)
|
2016-03-17 13:21:36 +00:00
|
|
|
#define RB_GC_GUARD(v) (*rb_gc_guarded_ptr(&(v)))
|
2013-05-17 08:35:26 +00:00
|
|
|
#else
|
2014-02-20 23:45:55 +00:00
|
|
|
volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val);
|
|
|
|
#define HAVE_RB_GC_GUARDED_PTR_VAL 1
|
|
|
|
#define RB_GC_GUARD(v) (*rb_gc_guarded_ptr_val(&(v),(v)))
|
2010-06-24 16:11:05 +00:00
|
|
|
#endif
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 08:12:18 +00:00
|
|
|
|
2013-03-21 14:32:17 +00:00
|
|
|
#ifdef __GNUC__
|
2013-03-21 14:14:19 +00:00
|
|
|
#define RB_UNUSED_VAR(x) x __attribute__ ((unused))
|
2012-12-13 03:09:22 +00:00
|
|
|
#else
|
|
|
|
#define RB_UNUSED_VAR(x) x
|
|
|
|
#endif
|
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_check_type(VALUE,int);
|
2011-04-10 13:24:26 +00:00
|
|
|
#define Check_Type(v,t) rb_check_type((VALUE)(v),(t))
|
2001-05-02 04:22:21 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_str_to_str(VALUE);
|
|
|
|
VALUE rb_string_value(volatile VALUE*);
|
|
|
|
char *rb_string_value_ptr(volatile VALUE*);
|
|
|
|
char *rb_string_value_cstr(volatile VALUE*);
|
2001-05-11 05:24:59 +00:00
|
|
|
|
2003-06-23 06:52:39 +00:00
|
|
|
#define StringValue(v) rb_string_value(&(v))
|
2003-03-24 09:38:37 +00:00
|
|
|
#define StringValuePtr(v) rb_string_value_ptr(&(v))
|
2003-07-20 17:17:52 +00:00
|
|
|
#define StringValueCStr(v) rb_string_value_cstr(&(v))
|
2003-03-24 09:38:37 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_check_safe_obj(VALUE);
|
2001-05-02 04:22:21 +00:00
|
|
|
#define SafeStringValue(v) do {\
|
2001-05-11 05:24:59 +00:00
|
|
|
StringValue(v);\
|
2003-03-24 09:38:37 +00:00
|
|
|
rb_check_safe_obj(v);\
|
2001-03-28 08:43:25 +00:00
|
|
|
} while (0)
|
2016-05-12 18:12:47 +00:00
|
|
|
#if GCC_VERSION_SINCE(4,4,0)
|
2014-09-19 02:01:15 +00:00
|
|
|
void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use SafeStringValue() instead")));
|
|
|
|
# define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
|
|
|
|
#else
|
|
|
|
# define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use SafeStringValue() instead">]
|
|
|
|
# define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use SafeStringValue() instead">]
|
|
|
|
#endif
|
2001-05-02 04:22:21 +00:00
|
|
|
|
2008-10-20 08:05:44 +00:00
|
|
|
VALUE rb_str_export(VALUE);
|
|
|
|
#define ExportStringValue(v) do {\
|
|
|
|
SafeStringValue(v);\
|
|
|
|
(v) = rb_str_export(v);\
|
|
|
|
} while (0)
|
2008-11-07 21:42:24 +00:00
|
|
|
VALUE rb_str_export_locale(VALUE);
|
2008-10-20 08:05:44 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_get_path(VALUE);
|
2009-05-25 20:39:30 +00:00
|
|
|
#define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
|
2004-04-07 06:30:15 +00:00
|
|
|
|
2007-12-09 05:12:31 +00:00
|
|
|
VALUE rb_get_path_no_checksafe(VALUE);
|
|
|
|
#define FilePathStringValue(v) ((v) = rb_get_path_no_checksafe(v))
|
|
|
|
|
2015-06-18 14:21:03 +00:00
|
|
|
#define RUBY_SAFE_LEVEL_MAX 1
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_secure(int);
|
2007-03-19 03:58:57 +00:00
|
|
|
int rb_safe_level(void);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_set_safe_level(int);
|
2016-05-12 18:12:47 +00:00
|
|
|
#if GCC_VERSION_SINCE(4,4,0)
|
2015-06-18 14:21:03 +00:00
|
|
|
int ruby_safe_level_2_error(void) __attribute__((error("$SAFE=2 to 4 are obsolete")));
|
2016-05-08 17:44:51 +00:00
|
|
|
int ruby_safe_level_2_warning(void) __attribute__((const,warning("$SAFE=2 to 4 are obsolete")));
|
2013-07-18 06:45:50 +00:00
|
|
|
# ifdef RUBY_EXPORT
|
2015-06-18 14:21:03 +00:00
|
|
|
# define ruby_safe_level_2_warning() ruby_safe_level_2_error()
|
2013-07-18 06:45:50 +00:00
|
|
|
# endif
|
2016-05-12 18:12:47 +00:00
|
|
|
# if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
|
|
|
|
# define RUBY_SAFE_LEVEL_INVALID_P(level) \
|
2014-10-10 14:20:20 +00:00
|
|
|
__extension__(\
|
|
|
|
__builtin_choose_expr(\
|
|
|
|
__builtin_constant_p(level), \
|
|
|
|
((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)), 0))
|
2016-05-12 18:12:47 +00:00
|
|
|
# define RUBY_SAFE_LEVEL_CHECK(level, type) \
|
2015-06-18 14:33:12 +00:00
|
|
|
__extension__(__builtin_choose_expr(RUBY_SAFE_LEVEL_INVALID_P(level), ruby_safe_level_2_##type(), (level)))
|
2016-05-12 18:12:47 +00:00
|
|
|
# else
|
2014-10-10 14:20:20 +00:00
|
|
|
/* in gcc 4.8 or earlier, __builtin_choose_expr() does not consider
|
|
|
|
* __builtin_constant_p(variable) a constant expression.
|
|
|
|
*/
|
2016-05-12 18:12:47 +00:00
|
|
|
# define RUBY_SAFE_LEVEL_INVALID_P(level) \
|
2013-06-13 05:51:14 +00:00
|
|
|
__extension__(__builtin_constant_p(level) && \
|
|
|
|
((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)))
|
2016-05-12 18:12:47 +00:00
|
|
|
# define RUBY_SAFE_LEVEL_CHECK(level, type) \
|
2015-06-18 14:33:12 +00:00
|
|
|
(RUBY_SAFE_LEVEL_INVALID_P(level) ? ruby_safe_level_2_##type() : (level))
|
2016-05-12 18:12:47 +00:00
|
|
|
# endif
|
|
|
|
# define rb_secure(level) rb_secure(RUBY_SAFE_LEVEL_CHECK(level, warning))
|
|
|
|
# define rb_set_safe_level(level) rb_set_safe_level(RUBY_SAFE_LEVEL_CHECK(level, error))
|
2013-06-13 05:51:14 +00:00
|
|
|
#endif
|
2006-12-31 15:02:22 +00:00
|
|
|
void rb_set_safe_level_force(int);
|
2016-05-08 17:44:51 +00:00
|
|
|
CONSTFUNC(void rb_secure_update(VALUE));
|
2009-06-23 12:28:16 +00:00
|
|
|
NORETURN(void rb_insecure_operation(void));
|
2000-02-01 03:12:21 +00:00
|
|
|
|
2006-12-31 15:02:22 +00:00
|
|
|
VALUE rb_errinfo(void);
|
|
|
|
void rb_set_errinfo(VALUE);
|
|
|
|
|
2014-04-18 15:46:32 +00:00
|
|
|
long rb_num2long(VALUE);
|
|
|
|
unsigned long rb_num2ulong(VALUE);
|
2008-08-21 18:49:13 +00:00
|
|
|
static inline long
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_num2long_inline(VALUE x)
|
2008-08-21 18:49:13 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXNUM_P(x))
|
|
|
|
return RB_FIX2LONG(x);
|
2011-11-15 04:18:43 +00:00
|
|
|
else
|
2014-04-18 15:46:32 +00:00
|
|
|
return rb_num2long(x);
|
2008-08-21 18:49:13 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_NUM2LONG(x) rb_num2long_inline(x)
|
|
|
|
#define NUM2LONG(x) RB_NUM2LONG(x)
|
2012-08-05 15:39:26 +00:00
|
|
|
static inline unsigned long
|
|
|
|
rb_num2ulong_inline(VALUE x)
|
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXNUM_P(x))
|
|
|
|
return RB_FIX2ULONG(x);
|
2012-08-05 15:39:26 +00:00
|
|
|
else
|
2014-04-18 15:46:32 +00:00
|
|
|
return rb_num2ulong(x);
|
2012-08-05 15:39:26 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_NUM2ULONG(x) rb_num2ulong_inline(x)
|
|
|
|
#define NUM2ULONG(x) RB_NUM2ULONG(x)
|
1999-01-20 04:59:39 +00:00
|
|
|
#if SIZEOF_INT < SIZEOF_LONG
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
long rb_num2int(VALUE);
|
2008-08-21 19:34:24 +00:00
|
|
|
long rb_fix2int(VALUE);
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FIX2INT(x) ((int)rb_fix2int((VALUE)(x)))
|
2011-11-15 04:18:43 +00:00
|
|
|
|
2008-08-21 18:49:13 +00:00
|
|
|
static inline int
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_num2int_inline(VALUE x)
|
2008-08-21 18:49:13 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXNUM_P(x))
|
|
|
|
return (int)rb_fix2int(x);
|
2011-11-15 04:18:43 +00:00
|
|
|
else
|
|
|
|
return (int)rb_num2int(x);
|
2008-08-21 18:49:13 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_NUM2INT(x) rb_num2int_inline(x)
|
2011-11-15 05:57:34 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
unsigned long rb_num2uint(VALUE);
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_NUM2UINT(x) ((unsigned int)rb_num2uint(x))
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
unsigned long rb_fix2uint(VALUE);
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FIX2UINT(x) ((unsigned int)rb_fix2uint(x))
|
2011-11-14 03:55:40 +00:00
|
|
|
#else /* SIZEOF_INT < SIZEOF_LONG */
|
2015-09-13 02:03:31 +00:00
|
|
|
#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))
|
2011-11-14 03:55:40 +00:00
|
|
|
#endif /* SIZEOF_INT < SIZEOF_LONG */
|
2015-09-13 02:03:31 +00:00
|
|
|
#define NUM2INT(x) RB_NUM2INT(x)
|
|
|
|
#define NUM2UINT(x) RB_NUM2UINT(x)
|
|
|
|
#define FIX2INT(x) RB_FIX2INT(x)
|
|
|
|
#define FIX2UINT(x) RB_FIX2UINT(x)
|
1999-01-20 04:59:39 +00:00
|
|
|
|
2011-11-14 03:54:34 +00:00
|
|
|
short rb_num2short(VALUE);
|
|
|
|
unsigned short rb_num2ushort(VALUE);
|
|
|
|
short rb_fix2short(VALUE);
|
|
|
|
unsigned short rb_fix2ushort(VALUE);
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
|
|
|
|
#define FIX2SHORT(x) RB_FIX2SHORT(x)
|
2011-11-14 03:54:34 +00:00
|
|
|
static inline short
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_num2short_inline(VALUE x)
|
2011-11-14 03:54:34 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXNUM_P(x))
|
|
|
|
return rb_fix2short(x);
|
2011-11-15 04:18:43 +00:00
|
|
|
else
|
|
|
|
return rb_num2short(x);
|
2011-11-14 03:54:34 +00:00
|
|
|
}
|
2011-11-15 05:57:34 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2011-11-14 03:54:34 +00:00
|
|
|
|
2006-07-31 06:34:10 +00:00
|
|
|
#ifdef HAVE_LONG_LONG
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
LONG_LONG rb_num2ll(VALUE);
|
|
|
|
unsigned LONG_LONG rb_num2ull(VALUE);
|
2008-08-21 18:49:13 +00:00
|
|
|
static inline LONG_LONG
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_num2ll_inline(VALUE x)
|
2008-08-21 18:49:13 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXNUM_P(x))
|
|
|
|
return RB_FIX2LONG(x);
|
2011-11-15 04:18:43 +00:00
|
|
|
else
|
|
|
|
return rb_num2ll(x);
|
2008-08-21 18:49:13 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
# 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)
|
2002-03-14 06:23:46 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-12 08:41:24 +00:00
|
|
|
#if !defined(NUM2OFFT)
|
|
|
|
# if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
|
|
|
|
# define NUM2OFFT(x) ((off_t)NUM2LL(x))
|
|
|
|
# else
|
|
|
|
# define NUM2OFFT(x) NUM2LONG(x)
|
|
|
|
# endif
|
2002-03-14 06:23:46 +00:00
|
|
|
#endif
|
|
|
|
|
2008-05-11 05:44:36 +00:00
|
|
|
#if defined(HAVE_LONG_LONG) && SIZEOF_SIZE_T > SIZEOF_LONG
|
|
|
|
# define NUM2SIZET(x) ((size_t)NUM2ULL(x))
|
2012-08-05 15:38:55 +00:00
|
|
|
# define NUM2SSIZET(x) ((ssize_t)NUM2LL(x))
|
2008-05-11 05:44:36 +00:00
|
|
|
#else
|
|
|
|
# define NUM2SIZET(x) NUM2ULONG(x)
|
2008-08-15 23:53:07 +00:00
|
|
|
# define NUM2SSIZET(x) NUM2LONG(x)
|
2008-05-11 05:44:36 +00:00
|
|
|
#endif
|
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
double rb_num2dbl(VALUE);
|
1999-01-20 04:59:39 +00:00
|
|
|
#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
|
|
|
|
|
2008-08-21 18:49:13 +00:00
|
|
|
VALUE rb_uint2big(VALUE);
|
|
|
|
VALUE rb_int2big(SIGNED_VALUE);
|
2008-08-21 20:30:06 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_newobj(void);
|
2012-10-20 06:57:51 +00:00
|
|
|
VALUE rb_newobj_of(VALUE, VALUE);
|
2013-05-13 06:33:48 +00:00
|
|
|
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2015-10-29 07:26:44 +00:00
|
|
|
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags) /* core has special NEWOBJ_OF() in internal.h */
|
2013-05-13 14:41:08 +00:00
|
|
|
#define OBJSETUP(obj,c,t) rb_obj_setup(obj, c, t) /* use NEWOBJ_OF instead of NEWOBJ()+OBJSETUP() */
|
2015-10-06 04:56:16 +00:00
|
|
|
#define CLONESETUP(clone,obj) rb_clone_setup(clone,obj)
|
|
|
|
#define DUPSETUP(dup,obj) rb_dup_setup(dup,obj)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#ifndef USE_RGENGC
|
2013-05-13 18:14:01 +00:00
|
|
|
#define USE_RGENGC 1
|
2014-09-08 04:11:00 +00:00
|
|
|
#ifndef USE_RINCGC
|
|
|
|
#define USE_RINCGC 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_RGENGC == 0
|
|
|
|
#define USE_RINCGC 0
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RGENGC_WB_PROTECTED_ARRAY
|
2013-05-13 18:23:35 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_ARRAY 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
2013-05-26 12:37:11 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_HASH
|
|
|
|
#define RGENGC_WB_PROTECTED_HASH 1
|
|
|
|
#endif
|
2013-06-21 11:22:18 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_STRUCT
|
|
|
|
#define RGENGC_WB_PROTECTED_STRUCT 1
|
|
|
|
#endif
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_STRING
|
2013-05-13 18:22:17 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_STRING 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RGENGC_WB_PROTECTED_OBJECT
|
2013-05-13 18:21:32 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_OBJECT 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
2013-06-21 10:14:04 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_REGEXP
|
|
|
|
#define RGENGC_WB_PROTECTED_REGEXP 1
|
|
|
|
#endif
|
2013-06-14 09:23:54 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_CLASS
|
|
|
|
#define RGENGC_WB_PROTECTED_CLASS 1
|
|
|
|
#endif
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_FLOAT
|
2013-05-13 18:19:30 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_FLOAT 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RGENGC_WB_PROTECTED_COMPLEX
|
2013-05-13 18:19:30 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_COMPLEX 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RGENGC_WB_PROTECTED_RATIONAL
|
2013-05-13 18:19:30 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_RATIONAL 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RGENGC_WB_PROTECTED_BIGNUM
|
2013-05-13 18:19:30 +00:00
|
|
|
#define RGENGC_WB_PROTECTED_BIGNUM 1
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
2013-12-08 02:28:04 +00:00
|
|
|
#ifndef RGENGC_WB_PROTECTED_NODE_CREF
|
|
|
|
#define RGENGC_WB_PROTECTED_NODE_CREF 1
|
|
|
|
#endif
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
enum ruby_fl_type {
|
|
|
|
RUBY_FL_WB_PROTECTED = (1<<5),
|
|
|
|
RUBY_FL_PROMOTED0 = (1<<5),
|
|
|
|
RUBY_FL_PROMOTED1 = (1<<6),
|
|
|
|
RUBY_FL_PROMOTED = RUBY_FL_PROMOTED0|RUBY_FL_PROMOTED1,
|
|
|
|
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),
|
|
|
|
|
|
|
|
RUBY_FL_USHIFT = 12,
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
RUBY_ELTS_SHARED = RUBY_FL_USER2,
|
|
|
|
RUBY_FL_DUPPED = (RUBY_T_MASK|RUBY_FL_EXIVAR|RUBY_FL_TAINT),
|
|
|
|
RUBY_FL_SINGLETON = RUBY_FL_USER0
|
|
|
|
};
|
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RBasic {
|
2006-07-11 06:47:09 +00:00
|
|
|
VALUE flags;
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
|
|
|
const VALUE klass;
|
2013-01-08 17:13:26 +00:00
|
|
|
}
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((aligned(sizeof(VALUE))))
|
|
|
|
#endif
|
|
|
|
;
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
|
|
|
VALUE rb_obj_hide(VALUE obj);
|
|
|
|
VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
|
|
|
|
|
2015-10-06 04:56:16 +00:00
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
|
|
|
|
# define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
|
|
|
|
__extension__( \
|
|
|
|
__builtin_choose_expr( \
|
|
|
|
RGENGC_WB_PROTECTED_##type, \
|
|
|
|
OBJ_WB_UNPROTECT((VALUE)(obj)), ((VALUE)(obj))))
|
|
|
|
#else
|
|
|
|
# define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
|
|
|
|
(RGENGC_WB_PROTECTED_##type ? \
|
|
|
|
OBJ_WB_UNPROTECT((VALUE)(obj)) : ((VALUE)(obj)))
|
|
|
|
#endif
|
|
|
|
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
|
|
|
#define RBASIC_CLASS(obj) (RBASIC(obj)->klass)
|
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
|
|
|
|
#define ROBJECT_EMBED ROBJECT_EMBED
|
|
|
|
enum {
|
|
|
|
ROBJECT_EMBED_LEN_MAX = 3,
|
|
|
|
ROBJECT_EMBED = RUBY_FL_USER1,
|
|
|
|
|
|
|
|
ROBJECT_ENUM_END
|
|
|
|
};
|
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RObject {
|
|
|
|
struct RBasic basic;
|
2007-09-28 06:21:46 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2016-04-22 09:47:34 +00:00
|
|
|
uint32_t numiv;
|
2008-02-25 16:18:18 +00:00
|
|
|
VALUE *ivptr;
|
2015-11-03 21:16:48 +00:00
|
|
|
void *iv_index_tbl; /* shortcut for RCLASS_IV_INDEX_TBL(rb_obj_class(obj)) */
|
2007-09-28 06:21:46 +00:00
|
|
|
} heap;
|
|
|
|
VALUE ary[ROBJECT_EMBED_LEN_MAX];
|
|
|
|
} as;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
2008-02-25 16:18:18 +00:00
|
|
|
#define ROBJECT_NUMIV(o) \
|
2007-09-28 06:21:46 +00:00
|
|
|
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
|
|
|
|
ROBJECT_EMBED_LEN_MAX : \
|
2008-02-25 16:18:18 +00:00
|
|
|
ROBJECT(o)->as.heap.numiv)
|
|
|
|
#define ROBJECT_IVPTR(o) \
|
2007-09-28 06:21:46 +00:00
|
|
|
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
|
|
|
|
ROBJECT(o)->as.ary : \
|
2008-02-25 16:18:18 +00:00
|
|
|
ROBJECT(o)->as.heap.ivptr)
|
2008-02-13 11:52:46 +00:00
|
|
|
#define ROBJECT_IV_INDEX_TBL(o) \
|
|
|
|
((RBASIC(o)->flags & ROBJECT_EMBED) ? \
|
|
|
|
RCLASS_IV_INDEX_TBL(rb_obj_class(o)) : \
|
|
|
|
ROBJECT(o)->as.heap.iv_index_tbl)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-07-28 01:32:15 +00:00
|
|
|
#define RClass RClassDeprecated
|
2015-08-18 07:16:24 +00:00
|
|
|
#ifndef __cplusplus
|
|
|
|
DEPRECATED_TYPE(("RClass is internal use only"),
|
|
|
|
struct RClass {
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RBasic basic;
|
2015-07-28 01:32:15 +00:00
|
|
|
});
|
2015-08-18 07:16:24 +00:00
|
|
|
#endif
|
2011-06-18 03:05:11 +00:00
|
|
|
#define RCLASS_SUPER(c) rb_class_get_superclass(c)
|
2007-09-28 06:21:46 +00:00
|
|
|
#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
|
2010-10-26 17:27:21 +00:00
|
|
|
#define RMODULE_CONST_TBL(m) RCLASS_CONST_TBL(m)
|
2007-09-28 06:21:46 +00:00
|
|
|
#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
|
|
|
|
#define RMODULE_SUPER(m) RCLASS_SUPER(m)
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RMODULE_IS_OVERLAID RMODULE_IS_OVERLAID
|
|
|
|
#define RMODULE_IS_REFINEMENT RMODULE_IS_REFINEMENT
|
|
|
|
#define RMODULE_INCLUDED_INTO_REFINEMENT RMODULE_INCLUDED_INTO_REFINEMENT
|
|
|
|
enum {
|
|
|
|
RMODULE_IS_OVERLAID = RUBY_FL_USER2,
|
|
|
|
RMODULE_IS_REFINEMENT = RUBY_FL_USER3,
|
|
|
|
RMODULE_INCLUDED_INTO_REFINEMENT = RUBY_FL_USER4,
|
|
|
|
|
|
|
|
RMODULE_ENUM_END
|
|
|
|
};
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2016-05-08 17:44:51 +00:00
|
|
|
PUREFUNC(double rb_float_value(VALUE));
|
2013-09-25 07:58:49 +00:00
|
|
|
VALUE rb_float_new(double);
|
2012-08-23 07:22:40 +00:00
|
|
|
VALUE rb_float_new_in_heap(double);
|
|
|
|
|
|
|
|
#define RFLOAT_VALUE(v) rb_float_value(v)
|
2008-09-05 18:24:21 +00:00
|
|
|
#define DBL2NUM(dbl) rb_float_new(dbl)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RUBY_ELTS_SHARED RUBY_ELTS_SHARED
|
2015-09-13 02:03:31 +00:00
|
|
|
#define ELTS_SHARED RUBY_ELTS_SHARED
|
2001-12-10 07:18:16 +00:00
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RSTRING_NOEMBED RSTRING_NOEMBED
|
|
|
|
#define RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK
|
|
|
|
#define RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT
|
|
|
|
#define RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX
|
|
|
|
#define RSTRING_FSTR RSTRING_FSTR
|
|
|
|
enum {
|
|
|
|
RSTRING_NOEMBED = RUBY_FL_USER1,
|
|
|
|
RSTRING_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|
|
|
|
|
RUBY_FL_USER5|RUBY_FL_USER6),
|
|
|
|
RSTRING_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+2),
|
|
|
|
RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*3)/sizeof(char)-1),
|
|
|
|
RSTRING_FSTR = RUBY_FL_USER17,
|
|
|
|
|
|
|
|
RSTRING_ENUM_END
|
|
|
|
};
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RString {
|
|
|
|
struct RBasic basic;
|
2001-12-10 07:18:16 +00:00
|
|
|
union {
|
2006-08-31 10:47:44 +00:00
|
|
|
struct {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 16:26:04 +00:00
|
|
|
long len;
|
|
|
|
char *ptr;
|
|
|
|
union {
|
|
|
|
long capa;
|
|
|
|
VALUE shared;
|
|
|
|
} aux;
|
2006-08-31 10:47:44 +00:00
|
|
|
} heap;
|
2008-07-31 04:19:01 +00:00
|
|
|
char ary[RSTRING_EMBED_LEN_MAX + 1];
|
2006-08-31 10:47:44 +00:00
|
|
|
} as;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
2010-07-20 09:39:22 +00:00
|
|
|
#define RSTRING_EMBED_LEN(str) \
|
|
|
|
(long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
|
|
|
|
(RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT))
|
2006-08-31 10:47:44 +00:00
|
|
|
#define RSTRING_LEN(str) \
|
|
|
|
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
|
2010-07-20 09:39:22 +00:00
|
|
|
RSTRING_EMBED_LEN(str) : \
|
2006-08-31 10:47:44 +00:00
|
|
|
RSTRING(str)->as.heap.len)
|
|
|
|
#define RSTRING_PTR(str) \
|
|
|
|
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
|
|
|
|
RSTRING(str)->as.ary : \
|
|
|
|
RSTRING(str)->as.heap.ptr)
|
2009-10-29 19:47:28 +00:00
|
|
|
#define RSTRING_END(str) \
|
|
|
|
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
|
2010-07-20 09:39:22 +00:00
|
|
|
(RSTRING(str)->as.ary + RSTRING_EMBED_LEN(str)) : \
|
2009-10-29 19:47:28 +00:00
|
|
|
(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len))
|
2010-04-28 07:45:00 +00:00
|
|
|
#define RSTRING_LENINT(str) rb_long2int(RSTRING_LEN(str))
|
2010-07-20 09:39:22 +00:00
|
|
|
#define RSTRING_GETMEM(str, ptrvar, lenvar) \
|
|
|
|
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
|
|
|
|
((ptrvar) = RSTRING(str)->as.ary, (lenvar) = RSTRING_EMBED_LEN(str)) : \
|
|
|
|
((ptrvar) = RSTRING(str)->as.heap.ptr, (lenvar) = RSTRING(str)->as.heap.len))
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RARRAY_EMBED_FLAG RARRAY_EMBED_FLAG
|
|
|
|
#define RARRAY_EMBED_LEN_MASK RARRAY_EMBED_LEN_MASK
|
|
|
|
#define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
|
|
|
|
#define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
|
|
|
|
enum {
|
|
|
|
RARRAY_EMBED_LEN_MAX = 3,
|
|
|
|
RARRAY_EMBED_FLAG = RUBY_FL_USER1,
|
|
|
|
/* RUBY_FL_USER2 is for ELTS_SHARED */
|
|
|
|
RARRAY_EMBED_LEN_MASK = (RUBY_FL_USER4|RUBY_FL_USER3),
|
|
|
|
RARRAY_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+3),
|
|
|
|
|
|
|
|
RARRAY_ENUM_END
|
|
|
|
};
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RArray {
|
|
|
|
struct RBasic basic;
|
2001-12-10 07:18:16 +00:00
|
|
|
union {
|
2008-10-09 05:47:04 +00:00
|
|
|
struct {
|
|
|
|
long len;
|
|
|
|
union {
|
|
|
|
long capa;
|
|
|
|
VALUE shared;
|
|
|
|
} aux;
|
2013-06-21 11:53:33 +00:00
|
|
|
const VALUE *ptr;
|
2008-10-09 05:47:04 +00:00
|
|
|
} heap;
|
2013-06-21 11:53:33 +00:00
|
|
|
const VALUE ary[RARRAY_EMBED_LEN_MAX];
|
2008-10-09 05:47:04 +00:00
|
|
|
} as;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
2015-10-06 04:56:16 +00:00
|
|
|
#define RARRAY_EMBED_LEN(a) \
|
|
|
|
(long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
|
|
|
|
(RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT))
|
|
|
|
#define RARRAY_LEN(a) rb_array_len(a)
|
2009-05-20 16:43:41 +00:00
|
|
|
#define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
|
2015-10-06 04:56:16 +00:00
|
|
|
#define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
|
|
|
#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR(a))
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#define RARRAY_PTR_USE_END(a) /* */
|
|
|
|
|
|
|
|
#define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
|
|
|
|
const VALUE _ary = (ary); \
|
2013-06-21 11:53:33 +00:00
|
|
|
VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START(_ary); \
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
expr; \
|
|
|
|
RARRAY_PTR_USE_END(_ary); \
|
|
|
|
} while (0)
|
|
|
|
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
|
|
|
#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#define RARRAY_ASET(a, i, v) do { \
|
2013-12-24 03:13:52 +00:00
|
|
|
const VALUE _ary = (a); \
|
|
|
|
VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START(_ary); \
|
|
|
|
RB_OBJ_WRITE(_ary, &ptr[i], (v)); \
|
|
|
|
RARRAY_PTR_USE_END(_ary); \
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-10-06 04:56:16 +00:00
|
|
|
#define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(ARRAY, a)))
|
2013-05-13 09:41:48 +00:00
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RRegexp {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct re_pattern_buffer *ptr;
|
2013-06-21 10:14:04 +00:00
|
|
|
const VALUE src;
|
2008-06-28 12:25:45 +00:00
|
|
|
unsigned long usecnt;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
2016-02-02 04:39:44 +00:00
|
|
|
#define RREGEXP_PTR(r) (RREGEXP(r)->ptr)
|
|
|
|
#define RREGEXP_SRC(r) (RREGEXP(r)->src)
|
2008-06-28 12:25:45 +00:00
|
|
|
#define RREGEXP_SRC_PTR(r) RSTRING_PTR(RREGEXP(r)->src)
|
|
|
|
#define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src)
|
2009-12-30 10:44:10 +00:00
|
|
|
#define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2007-08-30 01:54:51 +00:00
|
|
|
/* RHASH_TBL allocates st_table if not available. */
|
2007-08-29 23:12:21 +00:00
|
|
|
#define RHASH_TBL(h) rb_hash_tbl(h)
|
2014-06-23 07:26:03 +00:00
|
|
|
#define RHASH_ITER_LEV(h) rb_hash_iter_lev(h)
|
|
|
|
#define RHASH_IFNONE(h) rb_hash_ifnone(h)
|
|
|
|
#define RHASH_SIZE(h) NUM2SIZET(rb_hash_size(h))
|
2007-08-29 23:12:21 +00:00
|
|
|
#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
|
2013-05-26 12:37:11 +00:00
|
|
|
#define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
|
|
|
struct RFile {
|
|
|
|
struct RBasic basic;
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 10:30:50 +00:00
|
|
|
struct rb_io_t *fptr;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
|
|
|
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
|
|
|
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
|
|
|
|
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
|
2013-05-13 15:55:09 +00:00
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RData {
|
|
|
|
struct RBasic basic;
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void (*dmark)(void*);
|
|
|
|
void (*dfree)(void*);
|
1998-01-16 12:13:05 +00:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2010-07-18 07:31:54 +00:00
|
|
|
typedef struct rb_data_type_struct rb_data_type_t;
|
|
|
|
|
|
|
|
struct rb_data_type_struct {
|
2009-07-07 20:28:27 +00:00
|
|
|
const char *wrap_struct_name;
|
2010-07-18 07:31:54 +00:00
|
|
|
struct {
|
|
|
|
void (*dmark)(void*);
|
|
|
|
void (*dfree)(void*);
|
|
|
|
size_t (*dsize)(const void *);
|
|
|
|
void *reserved[2]; /* For future extension.
|
|
|
|
This array *must* be filled with ZERO. */
|
|
|
|
} function;
|
2014-12-24 03:16:31 +00:00
|
|
|
const rb_data_type_t *parent;
|
2009-09-10 20:02:11 +00:00
|
|
|
void *data; /* This area can be used for any purpose
|
|
|
|
by a programmer who define the type. */
|
2015-09-13 02:03:31 +00:00
|
|
|
VALUE flags; /* RUBY_FL_WB_PROTECTED */
|
2010-07-18 07:31:54 +00:00
|
|
|
};
|
2009-06-16 21:36:50 +00:00
|
|
|
|
2010-07-18 20:46:13 +00:00
|
|
|
#define HAVE_TYPE_RB_DATA_TYPE_T 1
|
|
|
|
#define HAVE_RB_DATA_TYPE_T_FUNCTION 1
|
2014-12-24 03:16:31 +00:00
|
|
|
#define HAVE_RB_DATA_TYPE_T_PARENT 1
|
2010-07-18 20:46:13 +00:00
|
|
|
|
2009-06-16 21:36:50 +00:00
|
|
|
struct RTypedData {
|
|
|
|
struct RBasic basic;
|
|
|
|
const rb_data_type_t *type;
|
|
|
|
VALUE typed_flag; /* 1 or not */
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
#define DATA_PTR(dta) (RDATA(dta)->data)
|
|
|
|
|
2009-06-16 21:36:50 +00:00
|
|
|
#define RTYPEDDATA_P(v) (RTYPEDDATA(v)->typed_flag == 1)
|
|
|
|
#define RTYPEDDATA_TYPE(v) (RTYPEDDATA(v)->type)
|
|
|
|
#define RTYPEDDATA_DATA(v) (RTYPEDDATA(v)->data)
|
|
|
|
|
2000-06-26 15:16:03 +00:00
|
|
|
/*
|
2011-04-10 13:24:26 +00:00
|
|
|
#define RUBY_DATA_FUNC(func) ((void (*)(void*))(func))
|
2000-06-26 15:16:03 +00:00
|
|
|
*/
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
typedef void (*RUBY_DATA_FUNC)(void*);
|
2000-06-26 15:16:03 +00:00
|
|
|
|
2014-09-28 15:27:24 +00:00
|
|
|
#ifndef RUBY_UNTYPED_DATA_WARNING
|
|
|
|
# if defined RUBY_EXPORT
|
|
|
|
# define RUBY_UNTYPED_DATA_WARNING 1
|
2014-09-27 01:28:47 +00:00
|
|
|
# else
|
2014-09-28 15:27:24 +00:00
|
|
|
# define RUBY_UNTYPED_DATA_WARNING 0
|
2014-09-27 01:28:47 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
2015-05-16 12:17:14 +00:00
|
|
|
VALUE rb_data_object_wrap(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
|
2015-05-10 15:20:35 +00:00
|
|
|
VALUE rb_data_object_zalloc(VALUE,size_t,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
|
2015-05-16 12:17:14 +00:00
|
|
|
VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *);
|
2015-05-10 15:20:35 +00:00
|
|
|
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type);
|
2014-12-24 03:16:31 +00:00
|
|
|
int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
|
2009-07-07 20:28:27 +00:00
|
|
|
int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *);
|
|
|
|
void *rb_check_typeddata(VALUE, const rb_data_type_t *);
|
2011-04-10 13:24:26 +00:00
|
|
|
#define Check_TypedStruct(v,t) rb_check_typeddata((VALUE)(v),(t))
|
2010-04-01 00:54:37 +00:00
|
|
|
#define RUBY_DEFAULT_FREE ((RUBY_DATA_FUNC)-1)
|
|
|
|
#define RUBY_NEVER_FREE ((RUBY_DATA_FUNC)0)
|
|
|
|
#define RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE
|
|
|
|
#define RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE
|
2000-06-26 15:16:03 +00:00
|
|
|
|
2013-10-29 09:42:45 +00:00
|
|
|
/* bits for rb_data_type_struct::flags */
|
|
|
|
#define RUBY_TYPED_FREE_IMMEDIATELY 1 /* TYPE field */
|
2015-09-13 02:03:31 +00:00
|
|
|
#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 */
|
2013-10-29 09:42:45 +00:00
|
|
|
|
2002-04-24 04:54:16 +00:00
|
|
|
#define Data_Wrap_Struct(klass,mark,free,sval)\
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_object_wrap((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
|
2000-06-26 15:16:03 +00:00
|
|
|
|
2015-05-19 00:43:58 +00:00
|
|
|
#define Data_Make_Struct0(result, klass, type, size, mark, free, sval) \
|
2015-05-19 00:54:46 +00:00
|
|
|
VALUE result = rb_data_object_zalloc((klass), (size), \
|
|
|
|
(RUBY_DATA_FUNC)(mark), \
|
|
|
|
(RUBY_DATA_FUNC)(free)); \
|
2015-05-19 00:43:58 +00:00
|
|
|
(void)((sval) = (type *)DATA_PTR(result));
|
2015-05-11 00:41:11 +00:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define Data_Make_Struct(klass,type,mark,free,sval) ({\
|
2015-05-19 00:43:58 +00:00
|
|
|
Data_Make_Struct0(data_struct_obj, klass, type, sizeof(type), mark, free, sval); \
|
2015-05-11 00:41:11 +00:00
|
|
|
data_struct_obj; \
|
|
|
|
})
|
|
|
|
#else
|
1999-01-20 04:59:39 +00:00
|
|
|
#define Data_Make_Struct(klass,type,mark,free,sval) (\
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_object_make((klass),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free),(void **)&(sval),sizeof(type)) \
|
1998-01-16 12:13:05 +00:00
|
|
|
)
|
2015-05-11 00:41:11 +00:00
|
|
|
#endif
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2009-07-07 20:28:27 +00:00
|
|
|
#define TypedData_Wrap_Struct(klass,data_type,sval)\
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_typed_object_wrap((klass),(sval),(data_type))
|
2009-06-16 21:36:50 +00:00
|
|
|
|
2015-05-19 00:43:58 +00:00
|
|
|
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval) \
|
2015-05-11 00:41:11 +00:00
|
|
|
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
|
2015-05-19 00:43:58 +00:00
|
|
|
(void)((sval) = (type *)DATA_PTR(result));
|
2015-05-11 00:41:11 +00:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define TypedData_Make_Struct(klass, type, data_type, sval) ({\
|
2015-05-19 00:43:58 +00:00
|
|
|
TypedData_Make_Struct0(data_struct_obj, klass, type, sizeof(type), data_type, sval); \
|
2015-05-11 00:41:11 +00:00
|
|
|
data_struct_obj; \
|
|
|
|
})
|
|
|
|
#else
|
2009-07-07 20:28:27 +00:00
|
|
|
#define TypedData_Make_Struct(klass, type, data_type, sval) (\
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_typed_object_make((klass),(data_type),(void **)&(sval),sizeof(type)) \
|
2009-06-16 21:36:50 +00:00
|
|
|
)
|
2015-05-11 00:41:11 +00:00
|
|
|
#endif
|
2009-06-16 21:36:50 +00:00
|
|
|
|
2014-09-28 15:27:24 +00:00
|
|
|
#define Data_Get_Struct(obj,type,sval) \
|
|
|
|
((sval) = (type*)rb_data_object_get(obj))
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2014-09-28 15:27:24 +00:00
|
|
|
#define TypedData_Get_Struct(obj,type,data_type,sval) \
|
|
|
|
((sval) = (type*)rb_check_typeddata((obj), (data_type)))
|
2009-07-07 04:44:54 +00:00
|
|
|
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RSTRUCT_EMBED_LEN_MAX RSTRUCT_EMBED_LEN_MAX
|
|
|
|
#define RSTRUCT_EMBED_LEN_MASK RSTRUCT_EMBED_LEN_MASK
|
|
|
|
#define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
|
|
|
|
enum {
|
|
|
|
RSTRUCT_EMBED_LEN_MAX = 3,
|
|
|
|
RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
|
|
|
|
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
|
|
|
|
|
|
|
|
RSTRUCT_ENUM_END
|
|
|
|
};
|
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
struct RStruct {
|
|
|
|
struct RBasic basic;
|
2006-02-05 14:40:01 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
long len;
|
2013-06-21 11:22:18 +00:00
|
|
|
const VALUE *ptr;
|
2006-02-05 14:40:01 +00:00
|
|
|
} heap;
|
2013-06-21 11:22:18 +00:00
|
|
|
const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
|
2006-02-05 14:40:01 +00:00
|
|
|
} as;
|
1998-01-16 12:13:05 +00:00
|
|
|
};
|
2015-10-06 04:56:16 +00:00
|
|
|
|
|
|
|
#define RSTRUCT_EMBED_LEN(st) \
|
|
|
|
(long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
|
|
|
|
(RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT))
|
|
|
|
#define RSTRUCT_LEN(st) rb_struct_len(st)
|
2010-04-28 07:45:00 +00:00
|
|
|
#define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
|
2015-10-06 04:56:16 +00:00
|
|
|
#define RSTRUCT_CONST_PTR(st) rb_struct_const_ptr(st)
|
2015-11-06 18:35:29 +00:00
|
|
|
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(STRUCT, st)))
|
2013-06-21 11:22:18 +00:00
|
|
|
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
|
|
|
#define RSTRUCT_SET(st, idx, v) RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
|
|
|
#define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2014-02-16 07:20:23 +00:00
|
|
|
#define RBIGNUM_SIGN(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) >= 0)
|
|
|
|
#define RBIGNUM_POSITIVE_P(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) >= 0)
|
|
|
|
#define RBIGNUM_NEGATIVE_P(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) < 0)
|
2014-02-16 05:34:48 +00:00
|
|
|
|
1999-01-20 04:59:39 +00:00
|
|
|
#define R_CAST(st) (struct st*)
|
1998-01-16 12:13:05 +00:00
|
|
|
#define RBASIC(obj) (R_CAST(RBasic)(obj))
|
|
|
|
#define ROBJECT(obj) (R_CAST(RObject)(obj))
|
|
|
|
#define RCLASS(obj) (R_CAST(RClass)(obj))
|
1999-01-20 04:59:39 +00:00
|
|
|
#define RMODULE(obj) RCLASS(obj)
|
1998-01-16 12:13:05 +00:00
|
|
|
#define RSTRING(obj) (R_CAST(RString)(obj))
|
|
|
|
#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
|
|
|
|
#define RARRAY(obj) (R_CAST(RArray)(obj))
|
|
|
|
#define RDATA(obj) (R_CAST(RData)(obj))
|
2009-06-16 21:36:50 +00:00
|
|
|
#define RTYPEDDATA(obj) (R_CAST(RTypedData)(obj))
|
1998-01-16 12:13:05 +00:00
|
|
|
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
|
|
|
|
#define RFILE(obj) (R_CAST(RFile)(obj))
|
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#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 FL_USHIFT RUBY_FL_USHIFT
|
|
|
|
|
|
|
|
#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))
|
2015-12-04 07:32:05 +00:00
|
|
|
#define RB_FL_SET_RAW(x,f) (void)(RBASIC(x)->flags |= (f))
|
|
|
|
#define RB_FL_SET(x,f) (RB_FL_ABLE(x) ? RB_FL_SET_RAW(x, f) : (void)0)
|
|
|
|
#define RB_FL_UNSET_RAW(x,f) (void)(RBASIC(x)->flags &= ~(f))
|
|
|
|
#define RB_FL_UNSET(x,f) (RB_FL_ABLE(x) ? RB_FL_UNSET_RAW(x, f) : (void)0)
|
|
|
|
#define RB_FL_REVERSE_RAW(x,f) (void)(RBASIC(x)->flags ^= (f))
|
|
|
|
#define RB_FL_REVERSE(x,f) (RB_FL_ABLE(x) ? RB_FL_REVERSE_RAW(x, f) : (void)0)
|
2015-09-13 02:03:31 +00:00
|
|
|
|
|
|
|
#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)
|
2015-12-04 15:59:10 +00:00
|
|
|
#define RB_OBJ_TAINT(x) (RB_OBJ_TAINTABLE(x) ? RB_OBJ_TAINT_RAW(x) : (void)0)
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)) ? \
|
2015-12-04 07:32:05 +00:00
|
|
|
RB_OBJ_INFECT_RAW(x, s) : (void)0)
|
2015-09-13 02:03:31 +00:00
|
|
|
|
2015-10-07 12:40:34 +00:00
|
|
|
#define RB_OBJ_FROZEN_RAW(x) (RBASIC(x)->flags&RUBY_FL_FREEZE)
|
|
|
|
#define RB_OBJ_FROZEN(x) (!RB_FL_ABLE(x) || RB_OBJ_FROZEN_RAW(x))
|
2015-12-04 07:32:05 +00:00
|
|
|
#define RB_OBJ_FREEZE_RAW(x) (void)(RBASIC(x)->flags |= RUBY_FL_FREEZE)
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2015-10-07 12:40:34 +00:00
|
|
|
#define OBJ_FROZEN_RAW(x) RB_OBJ_FROZEN_RAW(x)
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2014-09-12 14:25:01 +00:00
|
|
|
|
2014-09-19 01:45:45 +00:00
|
|
|
void rb_freeze_singleton_class(VALUE klass);
|
|
|
|
|
2014-09-12 14:25:01 +00:00
|
|
|
static inline void
|
|
|
|
rb_obj_freeze_inline(VALUE x)
|
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FL_ABLE(x)) {
|
|
|
|
RB_OBJ_FREEZE_RAW(x);
|
|
|
|
if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
|
2014-09-19 01:45:45 +00:00
|
|
|
rb_freeze_singleton_class(x);
|
2014-09-12 14:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-02-01 03:12:21 +00:00
|
|
|
|
2016-05-12 18:12:47 +00:00
|
|
|
#if GCC_VERSION_SINCE(4,4,0)
|
2014-09-28 15:27:24 +00:00
|
|
|
# define RUBY_UNTYPED_DATA_FUNC(func) func __attribute__((warning("untyped Data is unsafe; use TypedData instead")))
|
|
|
|
#else
|
|
|
|
# define RUBY_UNTYPED_DATA_FUNC(func) DEPRECATED(func)
|
|
|
|
#endif
|
|
|
|
|
2015-10-18 10:21:35 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__NO_INLINE__)
|
2015-03-16 07:49:27 +00:00
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
|
2015-05-16 12:17:14 +00:00
|
|
|
RUBY_UNTYPED_DATA_FUNC(static inline VALUE rb_data_object_wrap_warning(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
|
2015-03-16 07:49:27 +00:00
|
|
|
#endif
|
2014-09-28 15:27:24 +00:00
|
|
|
RUBY_UNTYPED_DATA_FUNC(static inline void *rb_data_object_get_warning(VALUE));
|
|
|
|
|
|
|
|
static inline VALUE
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_object_wrap_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DATA_FUNC free)
|
2014-09-28 15:27:24 +00:00
|
|
|
{
|
2015-05-16 12:17:14 +00:00
|
|
|
return rb_data_object_wrap(klass, ptr, mark, free);
|
2014-09-28 15:27:24 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 03:25:06 +00:00
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
|
2015-05-16 12:17:14 +00:00
|
|
|
#define rb_data_object_wrap_warning(klass, ptr, mark, free) \
|
2014-12-03 03:25:06 +00:00
|
|
|
__extension__( \
|
|
|
|
__builtin_choose_expr( \
|
|
|
|
__builtin_constant_p(klass) && !(klass), \
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_object_wrap(klass, ptr, mark, free), \
|
|
|
|
rb_data_object_wrap_warning(klass, ptr, mark, free)))
|
2014-12-03 03:25:06 +00:00
|
|
|
#endif
|
2015-10-18 05:53:26 +00:00
|
|
|
#endif
|
2014-12-03 03:25:06 +00:00
|
|
|
|
2014-09-28 15:27:24 +00:00
|
|
|
static inline void *
|
|
|
|
rb_data_object_get(VALUE obj)
|
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
Check_Type(obj, RUBY_T_DATA);
|
2014-09-28 15:27:24 +00:00
|
|
|
return ((struct RData *)obj)->data;
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:53:26 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__NO_INLINE__)
|
2014-09-28 15:27:24 +00:00
|
|
|
static inline void *
|
|
|
|
rb_data_object_get_warning(VALUE obj)
|
|
|
|
{
|
|
|
|
return rb_data_object_get(obj);
|
|
|
|
}
|
2015-10-18 05:53:26 +00:00
|
|
|
#endif
|
2014-09-28 15:27:24 +00:00
|
|
|
|
2015-05-10 15:20:35 +00:00
|
|
|
static inline VALUE
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_object_make(VALUE klass, RUBY_DATA_FUNC mark_func, RUBY_DATA_FUNC free_func, void **datap, size_t size)
|
2015-05-10 15:20:35 +00:00
|
|
|
{
|
2015-05-19 00:43:58 +00:00
|
|
|
Data_Make_Struct0(result, klass, void, size, mark_func, free_func, *datap);
|
2015-05-11 00:41:11 +00:00
|
|
|
return result;
|
2015-05-10 15:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
2015-05-16 12:17:14 +00:00
|
|
|
rb_data_typed_object_make(VALUE klass, const rb_data_type_t *type, void **datap, size_t size)
|
2015-05-10 15:20:35 +00:00
|
|
|
{
|
2015-05-19 00:43:58 +00:00
|
|
|
TypedData_Make_Struct0(result, klass, void, size, type, *datap);
|
2015-05-11 00:41:11 +00:00
|
|
|
return result;
|
2015-05-10 15:20:35 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 05:09:00 +00:00
|
|
|
#ifndef rb_data_object_alloc
|
|
|
|
DEPRECATED_BY(rb_data_object_wrap, static inline VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
|
|
|
|
static inline VALUE
|
|
|
|
rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
|
|
|
|
{
|
|
|
|
return rb_data_object_wrap(klass, data, dmark, dfree);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef rb_data_typed_object_alloc
|
|
|
|
DEPRECATED_BY(rb_data_typed_object_wrap, static inline VALUE rb_data_typed_object_alloc(VALUE,void*,const rb_data_type_t*));
|
|
|
|
static inline VALUE
|
|
|
|
rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
|
|
|
|
{
|
|
|
|
return rb_data_typed_object_wrap(klass, datap, type);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-18 05:53:26 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__NO_INLINE__)
|
2015-05-16 12:17:14 +00:00
|
|
|
#define rb_data_object_wrap_0 rb_data_object_wrap
|
|
|
|
#define rb_data_object_wrap_1 rb_data_object_wrap_warning
|
|
|
|
#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
|
2014-09-28 15:27:24 +00:00
|
|
|
#define rb_data_object_get_0 rb_data_object_get
|
|
|
|
#define rb_data_object_get_1 rb_data_object_get_warning
|
|
|
|
#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)
|
2015-05-16 12:17:14 +00:00
|
|
|
#define rb_data_object_make_0 rb_data_object_make
|
|
|
|
#define rb_data_object_make_1 rb_data_object_make_warning
|
|
|
|
#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)
|
2015-10-18 05:53:26 +00:00
|
|
|
#endif
|
2014-09-28 15:27:24 +00:00
|
|
|
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#if USE_RGENGC
|
2015-10-06 04:54:10 +00:00
|
|
|
#define RB_OBJ_PROMOTED_RAW(x) RB_FL_ALL_RAW(x, RUBY_FL_PROMOTED)
|
2015-09-13 02:03:31 +00:00
|
|
|
#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__)
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
2015-03-17 10:26:39 +00:00
|
|
|
void rb_gc_writebarrier(VALUE a, VALUE b);
|
2014-09-08 04:11:00 +00:00
|
|
|
void rb_gc_writebarrier_unprotect(VALUE obj);
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
|
|
|
#else /* USE_RGENGC */
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_OBJ_PROMOTED(x) 0
|
|
|
|
#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
2013-12-20 07:01:52 +00:00
|
|
|
/* Write barrier (WB) interfaces:
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
|
|
|
* - RB_OBJ_WRITE(a, slot, b): WB for new reference from `a' to `b'.
|
2013-12-20 07:01:52 +00:00
|
|
|
* Write `b' into `*slot'. `slot' is a pointer in `a'.
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
|
|
|
* - RB_OBJ_WRITTEN(a, oldv, b): WB for new reference from `a' to `b'.
|
2013-12-20 07:01:52 +00:00
|
|
|
* This doesn't write any values, but only a WB declaration.
|
|
|
|
* `oldv' is replaced value with `b' (not used in current Ruby).
|
2013-12-20 11:20:16 +00:00
|
|
|
*
|
2013-12-20 07:01:52 +00:00
|
|
|
* NOTE: The following core interfaces can be changed in the future.
|
|
|
|
* Please catch up if you want to insert WB into C-extensions
|
|
|
|
* correctly.
|
|
|
|
*/
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
|
|
|
#define RB_OBJ_WRITE(a, slot, b) rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__)
|
|
|
|
#define RB_OBJ_WRITTEN(a, oldv, b) rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__)
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
|
2013-08-08 10:56:52 +00:00
|
|
|
#ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
|
|
|
|
#define USE_RGENGC_LOGGING_WB_UNPROTECT 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_RGENGC_LOGGING_WB_UNPROTECT
|
2013-07-24 09:42:43 +00:00
|
|
|
void rb_gc_unprotect_logging(void *objptr, const char *filename, int line);
|
|
|
|
#define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
|
|
|
|
#endif
|
|
|
|
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
static inline VALUE
|
2013-10-20 04:58:49 +00:00
|
|
|
rb_obj_wb_unprotect(VALUE x, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
{
|
2013-06-22 21:54:10 +00:00
|
|
|
#ifdef RGENGC_LOGGING_WB_UNPROTECT
|
2013-07-24 09:42:43 +00:00
|
|
|
RGENGC_LOGGING_WB_UNPROTECT((void *)x, filename, line);
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
#if USE_RGENGC
|
2014-09-08 04:11:00 +00:00
|
|
|
rb_gc_writebarrier_unprotect(x);
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
2013-10-20 04:58:49 +00:00
|
|
|
rb_obj_written(VALUE a, RB_UNUSED_VAR(VALUE oldv), VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
{
|
|
|
|
#ifdef RGENGC_LOGGING_OBJ_WRITTEN
|
|
|
|
RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_RGENGC
|
2015-09-13 02:03:31 +00:00
|
|
|
if (!RB_SPECIAL_CONST_P(b)) {
|
2015-03-17 10:26:39 +00:00
|
|
|
rb_gc_writebarrier(a, b);
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
2013-10-20 04:58:49 +00:00
|
|
|
rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
{
|
2013-07-18 06:42:28 +00:00
|
|
|
#ifdef RGENGC_LOGGING_WRITE
|
|
|
|
RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
*slot = b;
|
|
|
|
|
|
|
|
#if USE_RGENGC
|
|
|
|
rb_obj_written(a, Qundef /* ignore `oldv' now */, b, filename, line);
|
|
|
|
#endif
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2016-05-18 01:17:43 +00:00
|
|
|
#define RB_INTEGER_TYPE_P(obj) rb_integer_type_p(obj)
|
|
|
|
static inline int
|
|
|
|
rb_integer_type_p(VALUE obj)
|
|
|
|
{
|
|
|
|
return (RB_FIXNUM_P(obj) ||
|
|
|
|
(!RB_SPECIAL_CONST_P(obj) &&
|
|
|
|
RB_BUILTIN_TYPE(obj) == RUBY_T_BIGNUM));
|
|
|
|
}
|
|
|
|
|
2010-08-22 00:10:06 +00:00
|
|
|
#if SIZEOF_INT < SIZEOF_LONG
|
2015-09-13 02:03:31 +00:00
|
|
|
# define RB_INT2NUM(v) INT2FIX((int)(v))
|
|
|
|
# define RB_UINT2NUM(v) LONG2FIX((unsigned int)(v))
|
2009-09-14 01:01:19 +00:00
|
|
|
#else
|
|
|
|
static inline VALUE
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_int2num_inline(int v)
|
2009-09-14 01:01:19 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXABLE(v))
|
2011-11-15 04:18:43 +00:00
|
|
|
return INT2FIX(v);
|
|
|
|
else
|
|
|
|
return rb_int2big(v);
|
2009-09-14 01:01:19 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_INT2NUM(x) rb_int2num_inline(x)
|
2009-09-14 01:01:19 +00:00
|
|
|
|
|
|
|
static inline VALUE
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_uint2num_inline(unsigned int v)
|
2009-09-14 01:01:19 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_POSFIXABLE(v))
|
2011-11-15 04:18:43 +00:00
|
|
|
return LONG2FIX(v);
|
|
|
|
else
|
|
|
|
return rb_uint2big(v);
|
2009-09-14 01:01:19 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_UINT2NUM(x) rb_uint2num_inline(x)
|
2009-09-14 01:01:19 +00:00
|
|
|
#endif
|
2015-09-13 02:03:31 +00:00
|
|
|
#define INT2NUM(x) RB_INT2NUM(x)
|
|
|
|
#define UINT2NUM(x) RB_UINT2NUM(x)
|
2009-09-14 01:01:19 +00:00
|
|
|
|
|
|
|
static inline VALUE
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_long2num_inline(long v)
|
2009-09-14 01:01:19 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FIXABLE(v))
|
2011-11-15 04:18:43 +00:00
|
|
|
return LONG2FIX(v);
|
|
|
|
else
|
|
|
|
return rb_int2big(v);
|
2009-09-14 01:01:19 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_LONG2NUM(x) rb_long2num_inline(x)
|
2009-09-14 01:01:19 +00:00
|
|
|
|
|
|
|
static inline VALUE
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_ulong2num_inline(unsigned long v)
|
2009-09-14 01:01:19 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_POSFIXABLE(v))
|
2011-11-15 04:18:43 +00:00
|
|
|
return LONG2FIX(v);
|
|
|
|
else
|
|
|
|
return rb_uint2big(v);
|
2009-09-14 01:01:19 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_ULONG2NUM(x) rb_ulong2num_inline(x)
|
2009-09-14 01:01:19 +00:00
|
|
|
|
|
|
|
static inline char
|
2011-11-15 05:57:34 +00:00
|
|
|
rb_num2char_inline(VALUE x)
|
2009-09-14 01:01:19 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
|
2011-11-15 04:18:43 +00:00
|
|
|
return RSTRING_PTR(x)[0];
|
|
|
|
else
|
|
|
|
return (char)(NUM2INT(x) & 0xff);
|
2009-09-14 01:01:19 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_NUM2CHR(x) rb_num2char_inline(x)
|
2011-11-15 05:57:34 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RB_CHR2FIX(x) INT2FIX((long)((x)&0xff))
|
2009-09-14 01:01:19 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2011-04-10 13:24:26 +00:00
|
|
|
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2013-05-03 21:03:58 +00:00
|
|
|
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
|
2016-04-21 20:59:40 +00:00
|
|
|
void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3));
|
2011-01-26 23:32:22 +00:00
|
|
|
void rb_free_tmp_buffer(volatile VALUE *store);
|
2015-08-11 06:22:34 +00:00
|
|
|
NORETURN(void ruby_malloc_size_overflow(size_t, size_t));
|
2016-04-22 11:42:31 +00:00
|
|
|
#if HAVE_LONG_LONG && SIZEOF_SIZE_T * 2 <= SIZEOF_LONG_LONG
|
|
|
|
# define DSIZE_T unsigned LONG_LONG
|
|
|
|
#elif defined(HAVE_INT128_T)
|
|
|
|
# define DSIZE_T uint128_t
|
|
|
|
#endif
|
|
|
|
static inline int
|
|
|
|
rb_mul_size_overflow(size_t a, size_t b, size_t max, size_t *c)
|
2015-08-11 06:22:34 +00:00
|
|
|
{
|
2016-04-22 11:42:31 +00:00
|
|
|
#ifdef DSIZE_T
|
|
|
|
DSIZE_T c2 = (DSIZE_T)a * (DSIZE_T)b;
|
2016-04-23 07:15:26 +00:00
|
|
|
if (c2 > max) return 1;
|
2016-04-22 11:42:31 +00:00
|
|
|
*c = (size_t)c2;
|
|
|
|
#else
|
2016-04-23 07:15:26 +00:00
|
|
|
if (b != 0 && a > max / b) return 1;
|
2016-04-22 11:42:31 +00:00
|
|
|
*c = a * b;
|
|
|
|
#endif
|
|
|
|
return 0;
|
2015-08-11 06:22:34 +00:00
|
|
|
}
|
2016-04-21 20:59:40 +00:00
|
|
|
static inline void *
|
|
|
|
rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
|
|
|
|
{
|
|
|
|
size_t cnt = (size_t)count;
|
|
|
|
if (elsize % sizeof(VALUE) == 0) {
|
2016-04-23 07:15:25 +00:00
|
|
|
if (RB_UNLIKELY(cnt > LONG_MAX / sizeof(VALUE))) {
|
2016-04-21 20:59:40 +00:00
|
|
|
ruby_malloc_size_overflow(cnt, elsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2016-04-22 11:42:31 +00:00
|
|
|
size_t size, max = LONG_MAX - sizeof(VALUE) + 1;
|
2016-04-23 07:15:25 +00:00
|
|
|
if (RB_UNLIKELY(rb_mul_size_overflow(count, elsize, max, &size))) {
|
2016-04-22 11:42:31 +00:00
|
|
|
ruby_malloc_size_overflow(cnt, elsize);
|
2016-04-21 20:59:40 +00:00
|
|
|
}
|
2016-04-22 11:42:31 +00:00
|
|
|
cnt = (size + sizeof(VALUE) - 1) / sizeof(VALUE);
|
2016-04-21 20:59:40 +00:00
|
|
|
}
|
|
|
|
return rb_alloc_tmp_buffer_with_count(store, cnt * sizeof(VALUE), cnt);
|
|
|
|
}
|
2011-01-26 23:32:22 +00:00
|
|
|
/* allocates _n_ bytes temporary buffer and stores VALUE including it
|
|
|
|
* in _v_. _n_ may be evaluated twice. */
|
|
|
|
#ifdef C_ALLOCA
|
2015-09-13 02:03:31 +00:00
|
|
|
# define RB_ALLOCV(v, n) rb_alloc_tmp_buffer(&(v), (n))
|
|
|
|
# define RB_ALLOCV_N(type, v, n) \
|
2016-04-21 20:59:40 +00:00
|
|
|
rb_alloc_tmp_buffer2(&(v), (n), sizeof(type))))
|
2011-01-26 23:32:22 +00:00
|
|
|
#else
|
2015-09-13 02:03:31 +00:00
|
|
|
# define RUBY_ALLOCV_LIMIT 1024
|
|
|
|
# define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \
|
2015-08-11 06:22:34 +00:00
|
|
|
(RB_GC_GUARD(v) = 0, alloca(n)) : \
|
|
|
|
rb_alloc_tmp_buffer(&(v), (n)))
|
2015-09-13 02:03:31 +00:00
|
|
|
# define RB_ALLOCV_N(type, v, n) \
|
2016-04-21 20:59:40 +00:00
|
|
|
((type*)(((size_t)(n) < RUBY_ALLOCV_LIMIT / sizeof(type)) ? \
|
2015-08-11 06:22:34 +00:00
|
|
|
(RB_GC_GUARD(v) = 0, alloca((n) * sizeof(type))) : \
|
2016-04-21 20:59:40 +00:00
|
|
|
rb_alloc_tmp_buffer2(&(v), (n), sizeof(type))))
|
2011-01-26 23:32:22 +00:00
|
|
|
#endif
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2011-01-26 23:32:22 +00:00
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
|
|
|
|
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
|
|
|
|
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
|
2000-09-15 06:00:30 +00:00
|
|
|
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_obj_infect(VALUE,VALUE);
|
2003-03-25 03:11:27 +00:00
|
|
|
|
2008-07-08 02:44:12 +00:00
|
|
|
typedef int ruby_glob_func(const char*,VALUE, void*);
|
|
|
|
void rb_glob(const char*,void(*)(const char*,VALUE,void*),VALUE);
|
2005-09-16 13:46:05 +00:00
|
|
|
int ruby_glob(const char*,int,ruby_glob_func*,VALUE);
|
|
|
|
int ruby_brace_glob(const char*,int,ruby_glob_func*,VALUE);
|
2000-05-29 02:10:22 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_define_class(const char*,VALUE);
|
|
|
|
VALUE rb_define_module(const char*);
|
|
|
|
VALUE rb_define_class_under(VALUE, const char*, VALUE);
|
|
|
|
VALUE rb_define_module_under(VALUE, const char*);
|
1998-01-16 12:19:22 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_include_module(VALUE,VALUE);
|
|
|
|
void rb_extend_object(VALUE,VALUE);
|
2012-06-27 07:48:50 +00:00
|
|
|
void rb_prepend_module(VALUE,VALUE);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2008-10-14 11:45:32 +00:00
|
|
|
struct rb_global_variable;
|
|
|
|
|
|
|
|
typedef VALUE rb_gvar_getter_t(ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
typedef void rb_gvar_setter_t(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
typedef void rb_gvar_marker_t(VALUE *var);
|
|
|
|
|
|
|
|
VALUE rb_gvar_undef_getter(ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_undef_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_undef_marker(VALUE *var);
|
|
|
|
|
|
|
|
VALUE rb_gvar_val_getter(ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_val_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_val_marker(VALUE *var);
|
|
|
|
|
|
|
|
VALUE rb_gvar_var_getter(ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_var_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
|
|
|
|
void rb_gvar_var_marker(VALUE *var);
|
|
|
|
|
2016-05-08 00:55:28 +00:00
|
|
|
NORETURN(void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar));
|
2008-10-14 11:45:32 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_define_variable(const char*,VALUE*);
|
|
|
|
void rb_define_virtual_variable(const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
|
|
|
|
void rb_define_hooked_variable(const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
|
2014-06-18 06:16:39 +00:00
|
|
|
void rb_define_readonly_variable(const char*,const VALUE*);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_define_const(VALUE,const char*,VALUE);
|
|
|
|
void rb_define_global_const(const char*,VALUE);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2011-04-10 13:24:26 +00:00
|
|
|
#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func))
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int);
|
|
|
|
void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int);
|
|
|
|
void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int);
|
1998-01-16 12:19:22 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_undef_method(VALUE,const char*);
|
|
|
|
void rb_define_alias(VALUE,const char*,const char*);
|
|
|
|
void rb_define_attr(VALUE,const char*,int,int);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_global_variable(VALUE*);
|
* gc.c, include/ruby/ruby.h: rename rb_register_mark_object()
to rb_gc_register_mark_object().
* eval.c, vm.c: initialize vm->mark_object_ary at
Init_top_self().
* bignum.c, complex.c, encoding.c, ext/win32ole/win32ole.c,
io.c, load.c, marshal.c, rational.c, ruby.c, vm.c:
use rb_gc_register_mark_object() instead of
rb_global_variable() or rb_gc_register_address().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 14:59:14 +00:00
|
|
|
void rb_gc_register_mark_object(VALUE);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_gc_register_address(VALUE*);
|
|
|
|
void rb_gc_unregister_address(VALUE*);
|
2000-02-08 08:54:01 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
ID rb_intern(const char*);
|
2006-09-02 15:05:27 +00:00
|
|
|
ID rb_intern2(const char*, long);
|
* encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
|
|
|
ID rb_intern_str(VALUE str);
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 21:20:17 +00:00
|
|
|
const char *rb_id2name(ID);
|
2011-07-26 16:05:27 +00:00
|
|
|
ID rb_check_id(volatile VALUE *);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
ID rb_to_id(VALUE);
|
2007-02-05 12:28:38 +00:00
|
|
|
VALUE rb_id2str(ID);
|
2014-03-26 04:57:47 +00:00
|
|
|
VALUE rb_sym2str(VALUE);
|
2014-08-03 01:55:10 +00:00
|
|
|
VALUE rb_to_symbol(VALUE name);
|
|
|
|
VALUE rb_check_symbol(volatile VALUE *namep);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-09-13 02:03:31 +00:00
|
|
|
#define RUBY_CONST_ID_CACHE(result, str) \
|
2008-06-10 03:43:33 +00:00
|
|
|
{ \
|
2008-06-09 09:25:32 +00:00
|
|
|
static ID rb_intern_id_cache; \
|
|
|
|
if (!rb_intern_id_cache) \
|
2011-04-10 13:24:26 +00:00
|
|
|
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
|
2008-06-09 09:25:32 +00:00
|
|
|
result rb_intern_id_cache; \
|
2008-06-10 03:43:33 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
#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)
|
2008-01-04 17:21:53 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
/* __builtin_constant_p and statement expression is available
|
|
|
|
* since gcc-2.7.2.3 at least. */
|
|
|
|
#define rb_intern(str) \
|
|
|
|
(__builtin_constant_p(str) ? \
|
2011-04-10 13:24:26 +00:00
|
|
|
__extension__ (CONST_ID_CACHE((ID), (str))) : \
|
2008-01-04 17:21:53 +00:00
|
|
|
rb_intern(str))
|
2008-08-16 00:20:31 +00:00
|
|
|
#define rb_intern_const(str) \
|
|
|
|
(__builtin_constant_p(str) ? \
|
2011-04-10 13:24:26 +00:00
|
|
|
__extension__ (rb_intern2((str), (long)strlen(str))) : \
|
2008-08-16 00:20:31 +00:00
|
|
|
(rb_intern)(str))
|
|
|
|
#else
|
2011-04-10 13:24:26 +00:00
|
|
|
#define rb_intern_const(str) rb_intern2((str), (long)strlen(str))
|
2008-01-04 17:21:53 +00:00
|
|
|
#endif
|
|
|
|
|
2008-05-31 09:28:20 +00:00
|
|
|
const char *rb_class2name(VALUE);
|
|
|
|
const char *rb_obj_classname(VALUE);
|
1998-01-16 12:19:22 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
void rb_p(VALUE);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_eval_string(const char*);
|
|
|
|
VALUE rb_eval_string_protect(const char*, int*);
|
|
|
|
VALUE rb_eval_string_wrap(const char*, int*);
|
|
|
|
VALUE rb_funcall(VALUE, ID, int, ...);
|
2013-05-31 08:27:06 +00:00
|
|
|
VALUE rb_funcallv(VALUE, ID, int, const VALUE*);
|
|
|
|
VALUE rb_funcallv_public(VALUE, ID, int, const VALUE*);
|
|
|
|
#define rb_funcall2 rb_funcallv
|
|
|
|
#define rb_funcall3 rb_funcallv_public
|
2011-03-17 15:54:22 +00:00
|
|
|
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
|
2013-06-17 12:47:26 +00:00
|
|
|
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE);
|
2016-05-21 14:01:23 +00:00
|
|
|
int rb_scan_args(int, const VALUE*, const char*, ...);
|
2008-05-22 16:19:14 +00:00
|
|
|
VALUE rb_call_super(int, const VALUE*);
|
2014-11-16 10:38:15 +00:00
|
|
|
VALUE rb_current_receiver(void);
|
2014-11-26 13:28:15 +00:00
|
|
|
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
|
|
|
|
VALUE rb_extract_keywords(VALUE *orighash);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2013-02-20 10:27:04 +00:00
|
|
|
/* rb_scan_args() format allows ':' for optional hash */
|
|
|
|
#define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH 1
|
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_gv_set(const char*, VALUE);
|
|
|
|
VALUE rb_gv_get(const char*);
|
|
|
|
VALUE rb_iv_get(VALUE, const char*);
|
|
|
|
VALUE rb_iv_set(VALUE, const char*, VALUE);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_equal(VALUE,VALUE);
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2008-06-09 05:18:03 +00:00
|
|
|
VALUE *rb_ruby_verbose_ptr(void);
|
|
|
|
VALUE *rb_ruby_debug_ptr(void);
|
|
|
|
#define ruby_verbose (*rb_ruby_verbose_ptr())
|
|
|
|
#define ruby_debug (*rb_ruby_debug_ptr())
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2015-12-23 14:58:47 +00:00
|
|
|
/* for rb_readwrite_sys_fail first argument */
|
|
|
|
enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
|
|
|
|
#define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
|
|
|
|
#define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
|
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
|
|
|
|
PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
|
|
|
|
PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
|
2009-11-24 11:03:51 +00:00
|
|
|
NORETURN(void rb_bug_errno(const char*, int));
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
NORETURN(void rb_sys_fail(const char*));
|
2012-02-24 07:39:59 +00:00
|
|
|
NORETURN(void rb_sys_fail_str(VALUE));
|
2009-03-19 11:40:38 +00:00
|
|
|
NORETURN(void rb_mod_sys_fail(VALUE, const char*));
|
2012-02-24 07:39:59 +00:00
|
|
|
NORETURN(void rb_mod_sys_fail_str(VALUE, VALUE));
|
2015-12-23 14:58:47 +00:00
|
|
|
NORETURN(void rb_readwrite_sys_fail(enum rb_io_wait_readwrite, const char*));
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
NORETURN(void rb_iter_break(void));
|
2012-01-24 05:20:48 +00:00
|
|
|
NORETURN(void rb_iter_break_value(VALUE));
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
NORETURN(void rb_exit(int));
|
|
|
|
NORETURN(void rb_notimplement(void));
|
2010-11-08 22:30:20 +00:00
|
|
|
VALUE rb_syserr_new(int, const char *);
|
2012-02-24 07:39:59 +00:00
|
|
|
VALUE rb_syserr_new_str(int n, VALUE arg);
|
2010-11-08 22:30:20 +00:00
|
|
|
NORETURN(void rb_syserr_fail(int, const char*));
|
2012-02-24 07:39:59 +00:00
|
|
|
NORETURN(void rb_syserr_fail_str(int, VALUE));
|
2010-11-08 22:30:20 +00:00
|
|
|
NORETURN(void rb_mod_syserr_fail(VALUE, int, const char*));
|
2012-02-24 07:39:59 +00:00
|
|
|
NORETURN(void rb_mod_syserr_fail_str(VALUE, int, VALUE));
|
2015-12-23 14:58:47 +00:00
|
|
|
NORETURN(void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite, int, const char*));
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2010-03-16 21:40:05 +00:00
|
|
|
/* reports if `-W' specified */
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 08:12:18 +00:00
|
|
|
PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
|
2005-09-13 11:26:42 +00:00
|
|
|
/* reports always */
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 08:12:18 +00:00
|
|
|
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
|
2013-11-29 02:26:48 +00:00
|
|
|
#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
|
2013-11-29 07:59:14 +00:00
|
|
|
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
|
2013-11-29 08:02:51 +00:00
|
|
|
VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
|
2013-11-29 07:59:14 +00:00
|
|
|
typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
|
2007-12-21 07:33:31 +00:00
|
|
|
|
2013-11-29 07:55:11 +00:00
|
|
|
#if defined RB_BLOCK_CALL_FUNC_STRICT && RB_BLOCK_CALL_FUNC_STRICT
|
|
|
|
typedef rb_block_call_func *rb_block_call_func_t;
|
|
|
|
#else
|
|
|
|
typedef VALUE (*rb_block_call_func_t)(ANYARGS);
|
|
|
|
#endif
|
|
|
|
|
2008-05-22 16:19:14 +00:00
|
|
|
VALUE rb_each(VALUE);
|
|
|
|
VALUE rb_yield(VALUE);
|
|
|
|
VALUE rb_yield_values(int n, ...);
|
|
|
|
VALUE rb_yield_values2(int n, const VALUE *argv);
|
|
|
|
VALUE rb_yield_splat(VALUE);
|
2013-11-29 08:06:19 +00:00
|
|
|
VALUE rb_yield_block(VALUE, VALUE, int, const VALUE *, VALUE); /* rb_block_call_func */
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
int rb_block_given_p(void);
|
|
|
|
void rb_need_block(void);
|
2008-05-22 16:19:14 +00:00
|
|
|
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
|
2013-11-29 08:02:51 +00:00
|
|
|
VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
|
2008-05-22 16:19:14 +00:00
|
|
|
VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
|
|
|
|
VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
|
|
|
|
VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
|
2007-12-21 11:13:53 +00:00
|
|
|
VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
NORETURN(void rb_throw(const char*,VALUE));
|
2007-12-21 11:13:53 +00:00
|
|
|
NORETURN(void rb_throw_obj(VALUE,VALUE));
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
|
|
|
|
|
|
|
VALUE rb_require(const char*);
|
|
|
|
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_mKernel;
|
|
|
|
RUBY_EXTERN VALUE rb_mComparable;
|
|
|
|
RUBY_EXTERN VALUE rb_mEnumerable;
|
|
|
|
RUBY_EXTERN VALUE rb_mErrno;
|
|
|
|
RUBY_EXTERN VALUE rb_mFileTest;
|
|
|
|
RUBY_EXTERN VALUE rb_mGC;
|
|
|
|
RUBY_EXTERN VALUE rb_mMath;
|
|
|
|
RUBY_EXTERN VALUE rb_mProcess;
|
2009-03-19 11:40:38 +00:00
|
|
|
RUBY_EXTERN VALUE rb_mWaitReadable;
|
|
|
|
RUBY_EXTERN VALUE rb_mWaitWritable;
|
2003-03-04 14:12:19 +00:00
|
|
|
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 21:20:17 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cBasicObject;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cObject;
|
|
|
|
RUBY_EXTERN VALUE rb_cArray;
|
|
|
|
RUBY_EXTERN VALUE rb_cBignum;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cBinding;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cClass;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cCont;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cDir;
|
|
|
|
RUBY_EXTERN VALUE rb_cData;
|
|
|
|
RUBY_EXTERN VALUE rb_cFalseClass;
|
2008-09-18 08:57:33 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cEncoding;
|
2008-04-20 12:01:27 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cEnumerator;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cFile;
|
|
|
|
RUBY_EXTERN VALUE rb_cFixnum;
|
|
|
|
RUBY_EXTERN VALUE rb_cFloat;
|
|
|
|
RUBY_EXTERN VALUE rb_cHash;
|
|
|
|
RUBY_EXTERN VALUE rb_cInteger;
|
|
|
|
RUBY_EXTERN VALUE rb_cIO;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cMatch;
|
2006-07-12 11:10:22 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cMethod;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cModule;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cNameErrorMesg;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cNilClass;
|
|
|
|
RUBY_EXTERN VALUE rb_cNumeric;
|
|
|
|
RUBY_EXTERN VALUE rb_cProc;
|
2010-07-11 10:05:27 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cRandom;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cRange;
|
2008-03-16 00:23:43 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cRational;
|
|
|
|
RUBY_EXTERN VALUE rb_cComplex;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cRegexp;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cStat;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cString;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cStruct;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cSymbol;
|
|
|
|
RUBY_EXTERN VALUE rb_cThread;
|
|
|
|
RUBY_EXTERN VALUE rb_cTime;
|
|
|
|
RUBY_EXTERN VALUE rb_cTrueClass;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_cUnboundMethod;
|
2003-03-04 14:12:19 +00:00
|
|
|
|
|
|
|
RUBY_EXTERN VALUE rb_eException;
|
|
|
|
RUBY_EXTERN VALUE rb_eStandardError;
|
|
|
|
RUBY_EXTERN VALUE rb_eSystemExit;
|
|
|
|
RUBY_EXTERN VALUE rb_eInterrupt;
|
|
|
|
RUBY_EXTERN VALUE rb_eSignal;
|
|
|
|
RUBY_EXTERN VALUE rb_eFatal;
|
|
|
|
RUBY_EXTERN VALUE rb_eArgError;
|
|
|
|
RUBY_EXTERN VALUE rb_eEOFError;
|
|
|
|
RUBY_EXTERN VALUE rb_eIndexError;
|
2007-08-08 07:07:03 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eStopIteration;
|
2004-09-22 04:48:52 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eKeyError;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eRangeError;
|
|
|
|
RUBY_EXTERN VALUE rb_eIOError;
|
|
|
|
RUBY_EXTERN VALUE rb_eRuntimeError;
|
|
|
|
RUBY_EXTERN VALUE rb_eSecurityError;
|
|
|
|
RUBY_EXTERN VALUE rb_eSystemCallError;
|
2006-09-23 21:29:47 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eThreadError;
|
2003-03-04 14:12:19 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eTypeError;
|
|
|
|
RUBY_EXTERN VALUE rb_eZeroDivError;
|
|
|
|
RUBY_EXTERN VALUE rb_eNotImpError;
|
|
|
|
RUBY_EXTERN VALUE rb_eNoMemError;
|
|
|
|
RUBY_EXTERN VALUE rb_eNoMethodError;
|
|
|
|
RUBY_EXTERN VALUE rb_eFloatDomainError;
|
2006-07-20 17:36:36 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eLocalJumpError;
|
|
|
|
RUBY_EXTERN VALUE rb_eSysStackError;
|
|
|
|
RUBY_EXTERN VALUE rb_eRegexpError;
|
2008-09-26 03:53:11 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eEncodingError;
|
2008-08-12 18:17:05 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eEncCompatError;
|
2003-03-04 14:12:19 +00:00
|
|
|
|
|
|
|
RUBY_EXTERN VALUE rb_eScriptError;
|
|
|
|
RUBY_EXTERN VALUE rb_eNameError;
|
|
|
|
RUBY_EXTERN VALUE rb_eSyntaxError;
|
|
|
|
RUBY_EXTERN VALUE rb_eLoadError;
|
|
|
|
|
* math.c (rb_eMathDomainError): new exception class for representing mathematical domain error instead of Errno::EDOM.
* math.c (domain_check, infinity_check): removed, no longer needed.
* math.c (math_atan2, math_acos, math_asin, math_acosh, math_atanh, math_log, math_log2, math_log10, math_sqrt, math_gamma, math_lgamma): mathematical domain errors are checked and raised before calling libm's functions.
* test/ruby/test_math.rb: updated for changes of maht.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-28 10:08:22 +00:00
|
|
|
RUBY_EXTERN VALUE rb_eMathDomainError;
|
|
|
|
|
2003-05-13 05:53:08 +00:00
|
|
|
RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
|
* intern.h: add prototypes.
rb_gc_enable(), rb_gc_disable(), rb_gc_start(), rb_str_new5()
rb_str_buf_append(), rb_str_buf_cat(), rb_str_buf_cat2(),
rb_str_dup_frozen()
* ruby.h: added declaration.
rb_defout, rb_stdin, rb_stdout, rb_stderr, ruby_errinfo
* rubyio.h: changed double include guard macro to RUBYIO_H.
* array.c (inspect_call): make static.
* eval.c (dvar_asgn): ditto.
* io.c (rb_io_close_read): ditto.
* lex.c (rb_reserved_word): ditto.
* ruby.c: (req_list_head, req_list_last): ditto.
* ruby.c (require_libraries): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-17 07:52:35 +00:00
|
|
|
|
2001-03-27 07:10:58 +00:00
|
|
|
static inline VALUE
|
2001-03-26 08:57:16 +00:00
|
|
|
rb_class_of(VALUE obj)
|
1999-01-20 04:59:39 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_IMMEDIATE_P(obj)) {
|
2016-05-17 06:53:48 +00:00
|
|
|
if (RB_FIXNUM_P(obj)) return rb_cInteger;
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_FLONUM_P(obj)) return rb_cFloat;
|
|
|
|
if (obj == RUBY_Qtrue) return rb_cTrueClass;
|
|
|
|
if (RB_STATIC_SYM_P(obj)) return rb_cSymbol;
|
2004-01-13 05:48:59 +00:00
|
|
|
}
|
2005-04-30 02:59:44 +00:00
|
|
|
else if (!RTEST(obj)) {
|
2015-09-13 02:03:31 +00:00
|
|
|
if (obj == RUBY_Qnil) return rb_cNilClass;
|
|
|
|
if (obj == RUBY_Qfalse) return rb_cFalseClass;
|
2004-01-13 05:48:59 +00:00
|
|
|
}
|
2004-01-27 06:05:04 +00:00
|
|
|
return RBASIC(obj)->klass;
|
1999-01-20 04:59:39 +00:00
|
|
|
}
|
|
|
|
|
2001-03-27 07:10:58 +00:00
|
|
|
static inline int
|
2001-03-26 08:57:16 +00:00
|
|
|
rb_type(VALUE obj)
|
1999-01-20 04:59:39 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
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;
|
2004-01-13 05:48:59 +00:00
|
|
|
}
|
2005-04-30 02:59:44 +00:00
|
|
|
else if (!RTEST(obj)) {
|
2015-09-13 02:03:31 +00:00
|
|
|
if (obj == RUBY_Qnil) return RUBY_T_NIL;
|
|
|
|
if (obj == RUBY_Qfalse) return RUBY_T_FALSE;
|
2004-01-13 05:48:59 +00:00
|
|
|
}
|
2015-09-13 02:03:31 +00:00
|
|
|
return RB_BUILTIN_TYPE(obj);
|
1999-01-20 04:59:39 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 03:04:53 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define rb_type_p(obj, type) \
|
2011-04-10 13:24:26 +00:00
|
|
|
__extension__ (__builtin_constant_p(type) ? RB_TYPE_P((obj), (type)) : \
|
2009-09-13 03:04:53 +00:00
|
|
|
rb_type(obj) == (type))
|
|
|
|
#else
|
|
|
|
#define rb_type_p(obj, type) (rb_type(obj) == (type))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define rb_special_const_p(obj) \
|
2015-09-13 02:03:31 +00:00
|
|
|
__extension__ ({ \
|
|
|
|
VALUE special_const_obj = (obj); \
|
|
|
|
(int)(RB_SPECIAL_CONST_P(special_const_obj) ? RUBY_Qtrue : RUBY_Qfalse); \
|
|
|
|
})
|
2009-09-13 03:04:53 +00:00
|
|
|
#else
|
2001-03-27 07:10:58 +00:00
|
|
|
static inline int
|
2001-03-26 08:57:16 +00:00
|
|
|
rb_special_const_p(VALUE obj)
|
1999-01-20 04:59:39 +00:00
|
|
|
{
|
2015-09-13 02:03:31 +00:00
|
|
|
if (RB_SPECIAL_CONST_P(obj)) return (int)RUBY_Qtrue;
|
|
|
|
return (int)RUBY_Qfalse;
|
1999-01-20 04:59:39 +00:00
|
|
|
}
|
2009-09-13 03:04:53 +00:00
|
|
|
#endif
|
2001-03-26 08:57:16 +00:00
|
|
|
|
2007-06-10 03:06:15 +00:00
|
|
|
#include "ruby/intern.h"
|
1998-01-16 12:19:22 +00:00
|
|
|
|
2015-10-06 04:56:16 +00:00
|
|
|
static inline void
|
|
|
|
rb_clone_setup(VALUE clone, VALUE obj)
|
|
|
|
{
|
|
|
|
rb_obj_setup(clone, rb_singleton_class_clone(obj), RBASIC(obj)->flags);
|
|
|
|
rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
|
|
|
|
if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
rb_dup_setup(VALUE dup, VALUE obj)
|
|
|
|
{
|
|
|
|
rb_obj_setup(dup, rb_obj_class(obj), RB_FL_TEST_RAW(obj, RUBY_FL_DUPPED));
|
|
|
|
if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(dup, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
rb_array_len(VALUE a)
|
|
|
|
{
|
|
|
|
return (RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
|
|
|
|
RARRAY_EMBED_LEN(a) : RARRAY(a)->as.heap.len;
|
|
|
|
}
|
|
|
|
|
2015-11-06 09:19:14 +00:00
|
|
|
#if defined(__fcc__) || defined(__fcc_version) || \
|
|
|
|
defined(__FCC__) || defined(__FCC_VERSION)
|
|
|
|
/* workaround for old version of Fujitsu C Compiler (fcc) */
|
|
|
|
# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
|
|
|
|
#else
|
|
|
|
# define FIX_CONST_VALUE_PTR(x) (x)
|
|
|
|
#endif
|
|
|
|
|
2015-10-06 04:56:16 +00:00
|
|
|
static inline const VALUE *
|
|
|
|
rb_array_const_ptr(VALUE a)
|
|
|
|
{
|
2015-11-06 09:19:14 +00:00
|
|
|
return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
|
|
|
|
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
|
2015-10-06 04:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
rb_struct_len(VALUE st)
|
|
|
|
{
|
|
|
|
return (RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
|
|
|
RSTRUCT_EMBED_LEN(st) : RSTRUCT(st)->as.heap.len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const VALUE *
|
|
|
|
rb_struct_const_ptr(VALUE st)
|
|
|
|
{
|
2015-11-06 09:19:14 +00:00
|
|
|
return FIX_CONST_VALUE_PTR((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
|
|
|
RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
|
2015-10-06 04:56:16 +00:00
|
|
|
}
|
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
|
|
|
|
/* hook for external modules */
|
1999-01-20 04:59:39 +00:00
|
|
|
static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
|
1998-01-16 12:13:05 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-25 02:43:43 +00:00
|
|
|
#define RUBY_VM 1 /* YARV */
|
|
|
|
#define HAVE_NATIVETHREAD
|
2007-12-25 07:28:51 +00:00
|
|
|
int ruby_native_thread_p(void);
|
2003-11-20 03:50:32 +00:00
|
|
|
|
2013-01-07 08:38:25 +00:00
|
|
|
/* traditional set_trace_func events */
|
2008-07-01 18:13:22 +00:00
|
|
|
#define RUBY_EVENT_NONE 0x0000
|
|
|
|
#define RUBY_EVENT_LINE 0x0001
|
|
|
|
#define RUBY_EVENT_CLASS 0x0002
|
|
|
|
#define RUBY_EVENT_END 0x0004
|
|
|
|
#define RUBY_EVENT_CALL 0x0008
|
|
|
|
#define RUBY_EVENT_RETURN 0x0010
|
|
|
|
#define RUBY_EVENT_C_CALL 0x0020
|
|
|
|
#define RUBY_EVENT_C_RETURN 0x0040
|
|
|
|
#define RUBY_EVENT_RAISE 0x0080
|
2012-08-16 11:41:24 +00:00
|
|
|
#define RUBY_EVENT_ALL 0x00ff
|
2007-11-16 07:29:44 +00:00
|
|
|
|
2012-11-29 22:28:16 +00:00
|
|
|
/* for TracePoint extended events */
|
2013-05-27 00:21:02 +00:00
|
|
|
#define RUBY_EVENT_B_CALL 0x0100
|
|
|
|
#define RUBY_EVENT_B_RETURN 0x0200
|
|
|
|
#define RUBY_EVENT_THREAD_BEGIN 0x0400
|
|
|
|
#define RUBY_EVENT_THREAD_END 0x0800
|
2015-08-21 09:51:01 +00:00
|
|
|
#define RUBY_EVENT_FIBER_SWITCH 0x1000
|
2013-05-27 00:21:02 +00:00
|
|
|
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff
|
2012-11-29 22:28:16 +00:00
|
|
|
|
2013-01-07 08:38:25 +00:00
|
|
|
/* special events */
|
2013-05-27 00:21:02 +00:00
|
|
|
#define RUBY_EVENT_SPECIFIED_LINE 0x010000
|
|
|
|
#define RUBY_EVENT_COVERAGE 0x020000
|
|
|
|
|
|
|
|
/* internal events */
|
2013-12-05 04:26:04 +00:00
|
|
|
#define RUBY_INTERNAL_EVENT_SWITCH 0x040000
|
|
|
|
#define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */
|
|
|
|
/* 0x080000 */
|
|
|
|
#define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000
|
|
|
|
#define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000
|
|
|
|
#define RUBY_INTERNAL_EVENT_GC_START 0x400000
|
|
|
|
#define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000
|
|
|
|
#define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000
|
2014-09-11 08:46:59 +00:00
|
|
|
#define RUBY_INTERNAL_EVENT_GC_ENTER 0x2000000
|
|
|
|
#define RUBY_INTERNAL_EVENT_GC_EXIT 0x4000000
|
|
|
|
#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x7f00000
|
2013-12-05 04:26:04 +00:00
|
|
|
#define RUBY_INTERNAL_EVENT_MASK 0xfffe0000
|
2013-01-07 08:38:25 +00:00
|
|
|
|
2014-10-01 21:13:30 +00:00
|
|
|
typedef uint32_t rb_event_flag_t;
|
2012-02-12 11:44:06 +00:00
|
|
|
typedef void (*rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass);
|
2007-11-16 07:29:44 +00:00
|
|
|
|
2009-05-21 03:07:45 +00:00
|
|
|
#define RB_EVENT_HOOKS_HAVE_CALLBACK_DATA 1
|
2012-08-16 11:41:24 +00:00
|
|
|
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data);
|
2007-11-16 07:29:44 +00:00
|
|
|
int rb_remove_event_hook(rb_event_hook_func_t func);
|
|
|
|
|
2008-01-03 06:13:31 +00:00
|
|
|
/* locale insensitive functions */
|
2008-01-03 08:44:01 +00:00
|
|
|
|
* include/ruby/ruby.h (rb_isupper, rb_islower, rb_isalpha, rb_isdigit,
rb_isalnum, rb_isxdigit, rb_isblank, rb_isspace, rb_isblank,
rb_iscntrl, rb_isprint, rb_ispunct, rb_isgraph,
rb_tolower, rb_toupper): use inline function to avoid function call.
* include/ruby/ruby.h (rb_isascii): use inline function to clarify
the logic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-29 10:24:05 +00:00
|
|
|
static inline int rb_isascii(int c){ return '\0' <= c && c <= '\x7f'; }
|
|
|
|
static inline int rb_isupper(int c){ return 'A' <= c && c <= 'Z'; }
|
|
|
|
static inline int rb_islower(int c){ return 'a' <= c && c <= 'z'; }
|
|
|
|
static inline int rb_isalpha(int c){ return rb_isupper(c) || rb_islower(c); }
|
|
|
|
static inline int rb_isdigit(int c){ return '0' <= c && c <= '9'; }
|
|
|
|
static inline int rb_isalnum(int c){ return rb_isalpha(c) || rb_isdigit(c); }
|
|
|
|
static inline int rb_isxdigit(int c){ return rb_isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'); }
|
|
|
|
static inline int rb_isblank(int c){ return c == ' ' || c == '\t'; }
|
|
|
|
static inline int rb_isspace(int c){ return c == ' ' || ('\t' <= c && c <= '\r'); }
|
|
|
|
static inline int rb_iscntrl(int c){ return ('\0' <= c && c < ' ') || c == '\x7f'; }
|
|
|
|
static inline int rb_isprint(int c){ return ' ' <= c && c <= '\x7e'; }
|
|
|
|
static inline int rb_ispunct(int c){ return !rb_isalnum(c); }
|
|
|
|
static inline int rb_isgraph(int c){ return '!' <= c && c <= '\x7e'; }
|
|
|
|
static inline int rb_tolower(int c) { return rb_isupper(c) ? (c|0x20) : c; }
|
|
|
|
static inline int rb_toupper(int c) { return rb_islower(c) ? (c&0x5f) : c; }
|
2008-01-03 08:44:01 +00:00
|
|
|
|
2008-01-01 12:24:04 +00:00
|
|
|
#ifndef ISPRINT
|
* include/ruby/ruby.h (rb_isupper, rb_islower, rb_isalpha, rb_isdigit,
rb_isalnum, rb_isxdigit, rb_isblank, rb_isspace, rb_isblank,
rb_iscntrl, rb_isprint, rb_ispunct, rb_isgraph,
rb_tolower, rb_toupper): use inline function to avoid function call.
* include/ruby/ruby.h (rb_isascii): use inline function to clarify
the logic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-29 10:24:05 +00:00
|
|
|
#define ISASCII(c) rb_isascii(c)
|
|
|
|
#define ISPRINT(c) rb_isprint(c)
|
|
|
|
#define ISGRAPH(c) rb_isgraph(c)
|
|
|
|
#define ISSPACE(c) rb_isspace(c)
|
|
|
|
#define ISUPPER(c) rb_isupper(c)
|
|
|
|
#define ISLOWER(c) rb_islower(c)
|
|
|
|
#define ISALNUM(c) rb_isalnum(c)
|
|
|
|
#define ISALPHA(c) rb_isalpha(c)
|
|
|
|
#define ISDIGIT(c) rb_isdigit(c)
|
|
|
|
#define ISXDIGIT(c) rb_isxdigit(c)
|
|
|
|
#endif
|
|
|
|
#define TOUPPER(c) rb_toupper(c)
|
|
|
|
#define TOLOWER(c) rb_tolower(c)
|
2008-01-03 12:57:26 +00:00
|
|
|
|
2013-07-16 23:15:41 +00:00
|
|
|
int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
|
|
|
|
int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
|
|
|
|
#define STRCASECMP(s1, s2) (st_locale_insensitive_strcasecmp((s1), (s2)))
|
|
|
|
#define STRNCASECMP(s1, s2, n) (st_locale_insensitive_strncasecmp((s1), (s2), (n)))
|
2008-01-01 12:24:04 +00:00
|
|
|
|
2008-01-02 06:24:27 +00:00
|
|
|
unsigned long ruby_strtoul(const char *str, char **endptr, int base);
|
2011-04-10 13:24:26 +00:00
|
|
|
#define STRTOUL(str, endptr, base) (ruby_strtoul((str), (endptr), (base)))
|
2008-01-02 06:24:27 +00:00
|
|
|
|
2010-04-01 20:38:38 +00:00
|
|
|
#define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
|
|
|
|
|
2010-08-07 23:55:49 +00:00
|
|
|
PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4);
|
2010-04-04 01:10:53 +00:00
|
|
|
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
|
|
|
|
|
2016-05-22 03:31:22 +00:00
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(__OPTIMIZE__)
|
2016-05-22 02:44:54 +00:00
|
|
|
# define rb_scan_args(argc,argvp,fmt,...) \
|
2016-05-22 03:31:22 +00:00
|
|
|
__builtin_choose_expr(__builtin_constant_p(fmt), \
|
2016-05-27 06:07:34 +00:00
|
|
|
rb_scan_args0(argc,argvp,fmt,\
|
2016-05-26 15:39:43 +00:00
|
|
|
(sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \
|
|
|
|
((VALUE*[]){__VA_ARGS__})), \
|
2016-05-22 03:31:22 +00:00
|
|
|
rb_scan_args(argc,argvp,fmt,__VA_ARGS__))
|
2016-05-24 09:52:14 +00:00
|
|
|
# if HAVE_ATTRIBUTE_ERRORFUNC
|
|
|
|
ERRORFUNC(("bad scan arg format"), int rb_scan_args_bad_format(const char*));
|
2016-05-26 15:39:43 +00:00
|
|
|
ERRORFUNC(("variable argument length doesn't match"), int rb_scan_args_length_mismatch(const char*,int));
|
2016-05-24 09:52:14 +00:00
|
|
|
# else
|
|
|
|
# define rb_scan_args_bad_format(fmt) 0
|
2016-05-26 15:39:43 +00:00
|
|
|
# define rb_scan_args_length_mismatch(fmt, varc) 0
|
2016-05-25 08:11:36 +00:00
|
|
|
# endif
|
2016-05-24 09:52:14 +00:00
|
|
|
|
|
|
|
# define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10)
|
2016-05-26 15:39:43 +00:00
|
|
|
|
2016-05-26 05:13:54 +00:00
|
|
|
# define rb_scan_args_count_end(fmt, ofs, varc, vari) \
|
2016-05-26 15:39:43 +00:00
|
|
|
((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
|
2016-05-26 05:13:54 +00:00
|
|
|
|
|
|
|
# define rb_scan_args_count_block(fmt, ofs, varc, vari) \
|
|
|
|
(fmt[ofs]!='&' ? \
|
|
|
|
rb_scan_args_count_end(fmt, ofs, varc, vari) : \
|
|
|
|
rb_scan_args_count_end(fmt, ofs+1, varc, vari+1))
|
|
|
|
|
|
|
|
# define rb_scan_args_count_hash(fmt, ofs, varc, vari) \
|
|
|
|
(fmt[ofs]!=':' ? \
|
|
|
|
rb_scan_args_count_block(fmt, ofs, varc, vari) : \
|
|
|
|
rb_scan_args_count_block(fmt, ofs+1, varc, vari+1))
|
|
|
|
|
|
|
|
# define rb_scan_args_count_trail(fmt, ofs, varc, vari) \
|
|
|
|
(!rb_scan_args_isdigit(fmt[ofs]) ? \
|
|
|
|
rb_scan_args_count_hash(fmt, ofs, varc, vari) : \
|
|
|
|
rb_scan_args_count_hash(fmt, ofs+1, varc, vari+(fmt[ofs]-'0')))
|
|
|
|
|
|
|
|
# define rb_scan_args_count_var(fmt, ofs, varc, vari) \
|
|
|
|
(fmt[ofs]!='*' ? \
|
|
|
|
rb_scan_args_count_trail(fmt, ofs, varc, vari) : \
|
|
|
|
rb_scan_args_count_trail(fmt, ofs+1, varc, vari+1))
|
|
|
|
|
|
|
|
# define rb_scan_args_count_opt(fmt, ofs, varc, vari) \
|
|
|
|
(!rb_scan_args_isdigit(fmt[1]) ? \
|
|
|
|
rb_scan_args_count_var(fmt, ofs, varc, vari) : \
|
|
|
|
rb_scan_args_count_var(fmt, ofs+1, varc, vari+fmt[ofs]-'0'))
|
|
|
|
|
2016-05-27 06:07:34 +00:00
|
|
|
# define rb_scan_args_count(fmt, varc) \
|
2016-05-26 15:39:43 +00:00
|
|
|
((!rb_scan_args_isdigit(fmt[0]) ? \
|
|
|
|
rb_scan_args_count_var(fmt, 0, varc, 0) : \
|
|
|
|
rb_scan_args_count_opt(fmt, 1, varc, fmt[0]-'0')) \
|
|
|
|
== (varc) || \
|
|
|
|
rb_scan_args_length_mismatch(fmt, varc))
|
|
|
|
|
2016-05-27 06:07:34 +00:00
|
|
|
# define rb_scan_args_verify_count(fmt, varc) \
|
|
|
|
((varc)/(rb_scan_args_count(fmt, varc)))
|
|
|
|
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# define rb_scan_args_verify(fmt, varc) \
|
|
|
|
({ \
|
|
|
|
int verify; \
|
|
|
|
_Pragma("GCC diagnostic push"); \
|
|
|
|
_Pragma("GCC diagnostic ignored \"-Warray-bounds\""); \
|
|
|
|
verify = rb_scan_args_verify_count(fmt, varc); \
|
|
|
|
_Pragma("GCC diagnostic pop"); \
|
|
|
|
verify; \
|
|
|
|
})
|
|
|
|
# else
|
|
|
|
# define rb_scan_args_verify(fmt, varc) \
|
|
|
|
rb_scan_args_verify_count(fmt, varc)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_lead_p(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_lead_p(const char *fmt)
|
|
|
|
{
|
|
|
|
return rb_scan_args_isdigit(fmt[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_n_lead(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_n_lead(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_lead_p(fmt) ? fmt[0]-'0' : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_opt_p(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_opt_p(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_lead_p(fmt) && rb_scan_args_isdigit(fmt[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_n_opt(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_n_opt(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_opt_p(fmt) ? fmt[1]-'0' : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_var_idx(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_var_idx(const char *fmt)
|
|
|
|
{
|
|
|
|
return (!rb_scan_args_lead_p(fmt) ? 0 : !rb_scan_args_isdigit(fmt[1]) ? 1 : 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_f_var(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_f_var(const char *fmt)
|
|
|
|
{
|
|
|
|
return (fmt[rb_scan_args_var_idx(fmt)]=='*');
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_trail_idx(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_trail_idx(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_lead_p(fmt) ?
|
|
|
|
(rb_scan_args_isdigit(fmt[1]) || fmt[1]=='*')+1 :
|
|
|
|
(fmt[0]=='*'));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_trail_p(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_trail_p(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_lead_p(fmt) ?
|
|
|
|
(rb_scan_args_isdigit(fmt[1]) || fmt[1]=='*') &&
|
|
|
|
rb_scan_args_isdigit(fmt[2]) :
|
|
|
|
fmt[0]=='*' && rb_scan_args_isdigit(fmt[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_n_trail(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_n_trail(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_lead_p(fmt) ?
|
|
|
|
((rb_scan_args_isdigit(fmt[1]) || fmt[1]=='*') &&
|
|
|
|
rb_scan_args_isdigit(fmt[2]) ? fmt[2]-'0' : 0) :
|
|
|
|
(fmt[0]=='*' && rb_scan_args_isdigit(fmt[1]) ? fmt[1]-'0' : 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_hash_idx(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_hash_idx(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_trail_idx(fmt)+rb_scan_args_trail_p(fmt));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_f_hash(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_f_hash(const char *fmt)
|
|
|
|
{
|
|
|
|
return (fmt[rb_scan_args_hash_idx(fmt)]==':');
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_block_idx(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_block_idx(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_hash_idx(fmt)+rb_scan_args_f_hash(fmt));
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_f_block(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_f_block(const char *fmt)
|
|
|
|
{
|
|
|
|
return (fmt[rb_scan_args_block_idx(fmt)]=='&');
|
|
|
|
}
|
|
|
|
|
|
|
|
ALWAYS_INLINE(static int rb_scan_args_end_idx(const char *fmt));
|
|
|
|
static inline int
|
|
|
|
rb_scan_args_end_idx(const char *fmt)
|
|
|
|
{
|
|
|
|
return (rb_scan_args_block_idx(fmt)+rb_scan_args_f_block(fmt));
|
|
|
|
}
|
2016-05-25 08:11:36 +00:00
|
|
|
|
2016-05-24 09:52:14 +00:00
|
|
|
# define rb_scan_args0(argc, argv, fmt, varc, vars) \
|
|
|
|
rb_scan_args_set(argc, argv, \
|
|
|
|
rb_scan_args_n_lead(fmt), \
|
|
|
|
rb_scan_args_n_opt(fmt), \
|
|
|
|
rb_scan_args_n_trail(fmt), \
|
|
|
|
rb_scan_args_f_var(fmt), \
|
|
|
|
rb_scan_args_f_hash(fmt), \
|
|
|
|
rb_scan_args_f_block(fmt), \
|
2016-05-27 06:07:34 +00:00
|
|
|
rb_scan_args_verify(fmt, varc), vars)
|
2016-05-22 02:44:54 +00:00
|
|
|
ALWAYS_INLINE(static int
|
2016-05-24 09:52:14 +00:00
|
|
|
rb_scan_args_set(int argc, const VALUE *argv,
|
|
|
|
int n_lead, int n_opt, int n_trail,
|
|
|
|
int f_var, int f_hash, int f_block,
|
|
|
|
int varc, VALUE *vars[]));
|
2016-05-22 02:44:54 +00:00
|
|
|
inline int
|
2016-05-24 09:52:14 +00:00
|
|
|
rb_scan_args_set(int argc, const VALUE *argv,
|
|
|
|
int n_lead, int n_opt, int n_trail,
|
|
|
|
int f_var, int f_hash, int f_block,
|
|
|
|
int varc, VALUE *vars[])
|
2016-05-22 02:44:54 +00:00
|
|
|
{
|
2016-05-24 15:23:06 +00:00
|
|
|
int i, argi = 0, vari = 0;
|
|
|
|
VALUE *var, hash = Qnil;
|
|
|
|
const int n_mand = n_lead + n_trail;
|
2016-05-22 02:44:54 +00:00
|
|
|
|
|
|
|
/* capture an option hash - phase 1: pop */
|
|
|
|
if (f_hash && n_mand < argc) {
|
|
|
|
VALUE last = argv[argc - 1];
|
|
|
|
|
|
|
|
if (NIL_P(last)) {
|
|
|
|
/* nil is taken as an empty option hash only if it is not
|
|
|
|
ambiguous; i.e. '*' is not specified and arguments are
|
|
|
|
given more than sufficient */
|
|
|
|
if (!f_var && n_mand + n_opt < argc)
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hash = rb_check_hash_type(last);
|
|
|
|
if (!NIL_P(hash)) {
|
|
|
|
VALUE opts = rb_extract_keywords(&hash);
|
|
|
|
if (!hash) argc--;
|
|
|
|
hash = opts ? opts : Qnil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-24 15:23:06 +00:00
|
|
|
|
|
|
|
rb_check_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
|
|
|
|
|
2016-05-22 02:44:54 +00:00
|
|
|
/* capture leading mandatory arguments */
|
|
|
|
for (i = n_lead; i-- > 0; ) {
|
|
|
|
var = vars[vari++];
|
|
|
|
if (var) *var = argv[argi];
|
|
|
|
argi++;
|
|
|
|
}
|
|
|
|
/* capture optional arguments */
|
|
|
|
for (i = n_opt; i-- > 0; ) {
|
|
|
|
var = vars[vari++];
|
|
|
|
if (argi < argc - n_trail) {
|
|
|
|
if (var) *var = argv[argi];
|
|
|
|
argi++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (var) *var = Qnil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* capture variable length arguments */
|
|
|
|
if (f_var) {
|
|
|
|
int n_var = argc - argi - n_trail;
|
|
|
|
|
|
|
|
var = vars[vari++];
|
|
|
|
if (0 < n_var) {
|
|
|
|
if (var) *var = rb_ary_new4(n_var, &argv[argi]);
|
|
|
|
argi += n_var;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (var) *var = rb_ary_new();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* capture trailing mandatory arguments */
|
|
|
|
for (i = n_trail; i-- > 0; ) {
|
|
|
|
var = vars[vari++];
|
|
|
|
if (var) *var = argv[argi];
|
|
|
|
argi++;
|
|
|
|
}
|
|
|
|
/* capture an option hash - phase 2: assignment */
|
|
|
|
if (f_hash) {
|
|
|
|
var = vars[vari++];
|
|
|
|
if (var) *var = hash;
|
|
|
|
}
|
|
|
|
/* capture iterator block */
|
|
|
|
if (f_block) {
|
|
|
|
var = vars[vari++];
|
|
|
|
if (rb_block_given_p()) {
|
|
|
|
*var = rb_block_proc();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*var = Qnil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return argc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-07 15:44:27 +00:00
|
|
|
#ifndef RUBY_DONT_SUBST
|
|
|
|
#include "ruby/subst.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-14 02:22:08 +00:00
|
|
|
/**
|
|
|
|
* @defgroup embed CRuby Embedding APIs
|
|
|
|
* CRuby interpreter APIs. These are APIs to embed MRI interpreter into your
|
|
|
|
* program.
|
2013-05-19 03:10:21 +00:00
|
|
|
* These functions are not a part of Ruby extension library API.
|
2012-06-14 02:22:08 +00:00
|
|
|
* Extension libraries of Ruby should not depend on these functions.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @defgroup ruby1 ruby(1) implementation
|
|
|
|
* A part of the implementation of ruby(1) command.
|
|
|
|
* Other programs that embed Ruby interpreter do not always need to use these
|
|
|
|
* functions.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ruby_sysinit(int *argc, char ***argv);
|
|
|
|
void ruby_init(void);
|
2012-07-11 03:25:16 +00:00
|
|
|
void* ruby_options(int argc, char** argv);
|
|
|
|
int ruby_executable_node(void *n, int *status);
|
|
|
|
int ruby_run_node(void *n);
|
2012-06-14 02:22:08 +00:00
|
|
|
|
|
|
|
/* version.c */
|
|
|
|
void ruby_show_version(void);
|
|
|
|
void ruby_show_copyright(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*! A convenience macro to call ruby_init_stack(). Must be placed just after
|
|
|
|
* variable declarations */
|
|
|
|
#define RUBY_INIT_STACK \
|
|
|
|
VALUE variable_in_this_stack_frame; \
|
|
|
|
ruby_init_stack(&variable_in_this_stack_frame);
|
|
|
|
/*! @} */
|
|
|
|
|
|
|
|
#ifdef __ia64
|
|
|
|
void ruby_init_stack(volatile VALUE*, void*);
|
|
|
|
#define ruby_init_stack(addr) ruby_init_stack((addr), rb_ia64_bsp())
|
|
|
|
#else
|
|
|
|
void ruby_init_stack(volatile VALUE*);
|
|
|
|
#endif
|
|
|
|
#define Init_stack(addr) ruby_init_stack(addr)
|
|
|
|
|
|
|
|
int ruby_setup(void);
|
|
|
|
int ruby_cleanup(volatile int);
|
|
|
|
|
|
|
|
void ruby_finalize(void);
|
|
|
|
NORETURN(void ruby_stop(int));
|
|
|
|
|
|
|
|
void ruby_set_stack_size(size_t);
|
|
|
|
int ruby_stack_check(void);
|
|
|
|
size_t ruby_stack_length(VALUE**);
|
|
|
|
|
2012-07-11 03:25:16 +00:00
|
|
|
int ruby_exec_node(void *n);
|
2012-06-14 02:22:08 +00:00
|
|
|
|
|
|
|
void ruby_script(const char* name);
|
|
|
|
void ruby_set_script_name(VALUE name);
|
|
|
|
|
|
|
|
void ruby_prog_init(void);
|
|
|
|
void ruby_set_argv(int, char**);
|
|
|
|
void *ruby_process_options(int, char**);
|
|
|
|
void ruby_init_loadpath(void);
|
|
|
|
void ruby_incpush(const char*);
|
|
|
|
void ruby_sig_finalize(void);
|
|
|
|
|
|
|
|
/*! @} */
|
|
|
|
|
2016-01-07 02:34:33 +00:00
|
|
|
#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
|
|
|
|
# include "ruby/backward.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-05 10:29:38 +00:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2012-06-14 03:03:48 +00:00
|
|
|
|
2008-01-03 12:57:26 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if 0
|
|
|
|
{ /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
} /* extern "C" { */
|
|
|
|
#endif
|
2008-05-31 05:55:34 +00:00
|
|
|
#endif /* RUBY_RUBY_H */
|