struct.c: split make_struct
* struct.c (anonymous_struct, new_struct, setup_struct): split make_struct() for each purpose. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b47138580c
commit
5e5690781c
232
ChangeLog
232
ChangeLog
@ -1,231 +1,9 @@
|
|||||||
Sat Apr 13 09:34:31 2013 Tanaka Akira <akr@fsij.org>
|
Sat Apr 13 10:20:32 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb: Add ruby/ruby.h, ruby/missing.h, ruby/intern.h,
|
* struct.c (anonymous_struct, new_struct, setup_struct): split
|
||||||
ruby/st.h and ruby/subst.h for ruby_headers in generated Makefile.
|
make_struct() for each purpose.
|
||||||
|
|
||||||
* ext/-test-/old_thread_select/depend: Update dependencies.
|
make_struct() for each purpose.
|
||||||
|
|
||||||
* ext/-test-/wait_for_single_fd/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/bigdecimal/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/curses/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/bubblebabble/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/md5/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/rmd160/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/sha1/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/digest/sha2/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/dl/callback/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/dl/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/etc/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/nkf/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/objspace/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/pty/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/readline/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/ripper/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/sdbm/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/socket/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/stringio/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/strscan/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/syslog/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/-test-/num2int/depend: Removed.
|
|
||||||
|
|
||||||
* ext/dbm/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/fcntl/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/gdbm/depend: Ditto.
|
|
||||||
|
|
||||||
* ext/racc/cparse/depend: Ditto.
|
|
||||||
|
|
||||||
Sat Apr 13 00:15:54 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* ext/etc/etc.c (Init_etc): move Passwd and Group under Etc namespace
|
|
||||||
as primary names.
|
|
||||||
|
|
||||||
Fri Apr 12 21:06:55 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* common.mk: pack.o depends on internal.h.
|
|
||||||
|
|
||||||
Fri Apr 12 20:59:24 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* bignum.c (ones): Use __builtin_popcountl if available.
|
|
||||||
|
|
||||||
* internal.h (GCC_VERSION_SINCE): Macro moved from pack.c.
|
|
||||||
|
|
||||||
* pack.c: Include internal.h for GCC_VERSION_SINCE.
|
|
||||||
|
|
||||||
Fri Apr 12 18:29:42 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* common.mk: version.o depends on $(srcdir)/include/ruby/version.h
|
|
||||||
instead of {$(VPATH)}version.h to avoid confusion by VPATH between
|
|
||||||
top level version.h and include/ruby/version.h for build in-place.
|
|
||||||
[ruby-dev:47249] [Bug #8256]
|
|
||||||
|
|
||||||
Fri Apr 12 15:21:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_callee_setup_keyword_arg): non-symbol key is not
|
|
||||||
a keyword argument, keep it as an positional argument.
|
|
||||||
|
|
||||||
Fri Apr 12 11:58:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
|
||||||
|
|
||||||
* array.c: Document synonymous methods, by windwiny [GH-277]
|
|
||||||
* bignum.c: ditto
|
|
||||||
* complex.c: ditto
|
|
||||||
* dir.c: ditto
|
|
||||||
* encoding.c: ditto
|
|
||||||
* enumerator.c: ditto
|
|
||||||
* numeric.c: ditto
|
|
||||||
* proc.c: ditto
|
|
||||||
* re.c: ditto
|
|
||||||
* string.c: ditto
|
|
||||||
|
|
||||||
Thu Apr 11 23:41:46 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* common.mk: Add dependencies for include/ruby.h
|
|
||||||
|
|
||||||
* tool/update-deps: Use "make -p all miniruby ruby golf" to extract
|
|
||||||
dependencies in makefiles.
|
|
||||||
|
|
||||||
Thu Apr 11 23:21:17 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* tool/update-deps: Use "make -p all golf" to extract dependencies in
|
|
||||||
makefiles.
|
|
||||||
|
|
||||||
Thu Apr 11 21:02:19 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* common.mk: Dependency updated.
|
|
||||||
|
|
||||||
* tool/update-deps: Rewritten.
|
|
||||||
|
|
||||||
Thu Apr 11 19:59:48 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* common.mk: partially revert r40183, which breaks building on
|
|
||||||
other than source directory. (its commit log also says the same
|
|
||||||
thing, but such failure is not reproducible on my environment
|
|
||||||
and the commit breaks build on my environment)
|
|
||||||
|
|
||||||
Thu Apr 11 16:10:01 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): define 0 on
|
|
||||||
Mac OS X and Linux [Bug #3371]
|
|
||||||
|
|
||||||
Thu Apr 11 13:19:22 2013 NAKAMURA Usaku <usa@ruby-lang.org>
|
|
||||||
|
|
||||||
* test/drb/drbtest.rb (Drb{Core,Ary}#teardown): retry Process.kill
|
|
||||||
if it fails with Errno::EPERM on Windows (workaround).
|
|
||||||
[ruby-dev:47245] [Bug #8251]
|
|
||||||
|
|
||||||
Thu Apr 11 11:11:38 2013 Akinori MUSHA <knu@iDaemons.org>
|
|
||||||
|
|
||||||
* dir.c: Fix a typo.
|
|
||||||
|
|
||||||
Thu Apr 11 10:39:34 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): add missing case:
|
|
||||||
RUBY_LIBFFI_MODVERSION is not defined (usually on Windows).
|
|
||||||
|
|
||||||
Thu Apr 11 09:27:04 2013 Konstantin Haase <me@rkh.im>
|
|
||||||
|
|
||||||
* dir.c (file_s_fnmatch): Document File::FNM_EXTGLOB flag.
|
|
||||||
|
|
||||||
Thu Apr 11 09:17:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
|
||||||
|
|
||||||
* README: Fix typo by Benjamin Winkler [Fixes GH-281]
|
|
||||||
|
|
||||||
Thu Apr 11 06:15:51 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* regint.h: fix typo: _M_AMD86 -> _M_AMD64.
|
|
||||||
|
|
||||||
* siphash.c: ditto.
|
|
||||||
|
|
||||||
* st.c: ditto.
|
|
||||||
|
|
||||||
Thu Apr 11 06:09:57 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* ext/fiddle/extconf.rb: define RUBY_LIBFFI_MODVERSION macro.
|
|
||||||
|
|
||||||
* ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): define 0 or 1
|
|
||||||
with platform and libffi's version. [Bug #3371]
|
|
||||||
|
|
||||||
Thu Apr 11 05:30:43 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* lib/mkmf.rb (pkg_config): Add optional argument "option".
|
|
||||||
If it is given, it returns the result of
|
|
||||||
`pkg-config --<option> <pkgname>`.
|
|
||||||
|
|
||||||
Thu Apr 11 03:33:05 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
|
||||||
|
|
||||||
* ext/fiddle/closure.c (initialize): check mprotect's return value.
|
|
||||||
If mprotect is failed because of PaX or something, its function call
|
|
||||||
will cause SEGV.
|
|
||||||
http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130401T210301Z.diff.html.gz
|
|
||||||
|
|
||||||
Wed Apr 10 17:39:13 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* ext/bigdecimal/bigdecimal.c (VpCtoV): Initialize a local variable
|
|
||||||
even when overflow.
|
|
||||||
|
|
||||||
Wed Apr 10 12:32:37 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* bignum.c (rb_ll2big): Don't overflow on signed integer negation.
|
|
||||||
|
|
||||||
* ext/bigdecimal/bigdecimal.c (MUL_OVERFLOW_SIGNED_VALUE_P): New
|
|
||||||
macro.
|
|
||||||
(AddExponent): Don't overflow on signed integer multiplication.
|
|
||||||
(VpCtoV): Don't overflow on signed integer arithmetic.
|
|
||||||
(VpCtoV): Don't overflow on signed integer arithmetic.
|
|
||||||
|
|
||||||
Wed Apr 10 06:32:12 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* internal.h (MUL_OVERFLOW_INT_P): New macro.
|
|
||||||
|
|
||||||
* sprintf.c (GETNUM): Don't overflow on signed integer multiplication.
|
|
||||||
|
|
||||||
Tue Apr 9 20:38:20 2013 Tanaka Akira <akr@fsij.org>
|
|
||||||
|
|
||||||
* internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.
|
|
||||||
(MUL_OVERFLOW_FIXNUM_P): Ditto.
|
|
||||||
(MUL_OVERFLOW_LONG_P): Ditto.
|
|
||||||
|
|
||||||
* array.c (rb_ary_product): Don't overflow on signed integer
|
|
||||||
multiplication.
|
|
||||||
|
|
||||||
* numeric.c (fix_mul): Ditto.
|
|
||||||
(int_pow): Ditto.
|
|
||||||
|
|
||||||
* rational.c (f_imul): Ditto.
|
|
||||||
|
|
||||||
* insns.def (opt_mult): Ditto.
|
|
||||||
|
|
||||||
* thread.c (sleep_timeval): Don't overflow on signed integer addition.
|
|
||||||
|
|
||||||
* bignum.c (rb_int2big): Don't overflow on signed integer negation.
|
|
||||||
(rb_big2ulong): Ditto.
|
|
||||||
(rb_big2long): Ditto.
|
|
||||||
(rb_big2ull): Ditto.
|
|
||||||
(rb_big2ll): Ditto.
|
|
||||||
|
|
||||||
Tue Apr 9 19:45:44 2013 Tanaka Akira <akr@fsij.org>
|
Tue Apr 9 19:45:44 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
@ -248,7 +26,7 @@ Tue Apr 9 10:02:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||||||
|
|
||||||
Tue Apr 9 04:57:59 JST 2013 Charles Oliver Nutter <headius@headius.com>
|
Tue Apr 9 04:57:59 JST 2013 Charles Oliver Nutter <headius@headius.com>
|
||||||
|
|
||||||
* error.c: Capture EAGAIN, EWOULDBLOCK, EINPROGRESS exceptions and
|
* error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and
|
||||||
export them for use in WaitReadable/Writable exceptions.
|
export them for use in WaitReadable/Writable exceptions.
|
||||||
* io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that
|
* io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that
|
||||||
include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail
|
include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail
|
||||||
|
67
struct.c
67
struct.c
@ -172,32 +172,41 @@ rb_struct_set(VALUE obj, VALUE val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
make_struct(VALUE name, VALUE members, VALUE klass)
|
anonymous_struct(VALUE klass)
|
||||||
{
|
{
|
||||||
VALUE nstr, *ptr_members;
|
VALUE nstr;
|
||||||
ID id;
|
|
||||||
long i, len;
|
|
||||||
|
|
||||||
OBJ_FREEZE(members);
|
|
||||||
if (NIL_P(name)) {
|
|
||||||
nstr = rb_class_new(klass);
|
nstr = rb_class_new(klass);
|
||||||
rb_make_metaclass(nstr, RBASIC(klass)->klass);
|
rb_make_metaclass(nstr, RBASIC(klass)->klass);
|
||||||
rb_class_inherited(klass, nstr);
|
rb_class_inherited(klass, nstr);
|
||||||
|
return nstr;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
static VALUE
|
||||||
|
new_struct(VALUE name, VALUE super)
|
||||||
|
{
|
||||||
/* old style: should we warn? */
|
/* old style: should we warn? */
|
||||||
|
ID id;
|
||||||
name = rb_str_to_str(name);
|
name = rb_str_to_str(name);
|
||||||
if (!rb_is_const_name(name)) {
|
if (!rb_is_const_name(name)) {
|
||||||
rb_name_error_str(name, "identifier %"PRIsVALUE" needs to be constant",
|
rb_name_error_str(name, "identifier %"PRIsVALUE" needs to be constant",
|
||||||
QUOTE(name));
|
QUOTE(name));
|
||||||
}
|
}
|
||||||
id = rb_to_id(name);
|
id = rb_to_id(name);
|
||||||
if (rb_const_defined_at(klass, id)) {
|
if (rb_const_defined_at(super, id)) {
|
||||||
rb_warn("redefining constant Struct::%s", StringValuePtr(name));
|
rb_warn("redefining constant Struct::%s", StringValuePtr(name));
|
||||||
rb_mod_remove_const(klass, ID2SYM(id));
|
rb_mod_remove_const(super, ID2SYM(id));
|
||||||
}
|
}
|
||||||
nstr = rb_define_class_id_under(klass, id, klass);
|
return rb_define_class_id_under(super, id, super);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
setup_struct(VALUE nstr, VALUE members)
|
||||||
|
{
|
||||||
|
VALUE *ptr_members;
|
||||||
|
long i, len;
|
||||||
|
|
||||||
|
OBJ_FREEZE(members);
|
||||||
rb_ivar_set(nstr, id_members, members);
|
rb_ivar_set(nstr, id_members, members);
|
||||||
|
|
||||||
rb_define_alloc_func(nstr, struct_alloc);
|
rb_define_alloc_func(nstr, struct_alloc);
|
||||||
@ -246,9 +255,7 @@ rb_struct_define_without_accessor(const char *class_name, VALUE super, rb_alloc_
|
|||||||
klass = rb_define_class(class_name, super);
|
klass = rb_define_class(class_name, super);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
klass = rb_class_new(super);
|
klass = anonymous_struct(super);
|
||||||
rb_make_metaclass(klass, RBASIC(super)->klass);
|
|
||||||
rb_class_inherited(super, klass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_ivar_set(klass, id_members, members);
|
rb_ivar_set(klass, id_members, members);
|
||||||
@ -265,11 +272,9 @@ VALUE
|
|||||||
rb_struct_define(const char *name, ...)
|
rb_struct_define(const char *name, ...)
|
||||||
{
|
{
|
||||||
va_list ar;
|
va_list ar;
|
||||||
VALUE nm, ary;
|
VALUE st, ary;
|
||||||
char *mem;
|
char *mem;
|
||||||
|
|
||||||
if (!name) nm = Qnil;
|
|
||||||
else nm = rb_str_new2(name);
|
|
||||||
ary = rb_ary_new();
|
ary = rb_ary_new();
|
||||||
|
|
||||||
va_start(ar, name);
|
va_start(ar, name);
|
||||||
@ -279,7 +284,9 @@ rb_struct_define(const char *name, ...)
|
|||||||
}
|
}
|
||||||
va_end(ar);
|
va_end(ar);
|
||||||
|
|
||||||
return make_struct(nm, ary, rb_cStruct);
|
if (!name) st = anonymous_struct(rb_cStruct);
|
||||||
|
else st = new_struct(rb_str_new2(name), rb_cStruct);
|
||||||
|
return setup_struct(st, ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -335,16 +342,28 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
|
|||||||
VALUE st;
|
VALUE st;
|
||||||
ID id;
|
ID id;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "1*", &name, &rest);
|
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||||
if (!NIL_P(name) && SYMBOL_P(name)) {
|
name = argv[0];
|
||||||
rb_ary_unshift(rest, name);
|
if (SYMBOL_P(name)) {
|
||||||
name = Qnil;
|
name = Qnil;
|
||||||
}
|
}
|
||||||
for (i=0; i<RARRAY_LEN(rest); i++) {
|
else {
|
||||||
id = rb_to_id(RARRAY_PTR(rest)[i]);
|
--argc;
|
||||||
RARRAY_PTR(rest)[i] = ID2SYM(id);
|
++argv;
|
||||||
}
|
}
|
||||||
st = make_struct(name, rest, klass);
|
rest = rb_ary_new2(argc);
|
||||||
|
for (i=0; i<argc; i++) {
|
||||||
|
id = rb_to_id(argv[i]);
|
||||||
|
RARRAY_PTR(rest)[i] = ID2SYM(id);
|
||||||
|
rb_ary_set_len(rest, i+1);
|
||||||
|
}
|
||||||
|
if (NIL_P(name)) {
|
||||||
|
st = anonymous_struct(klass);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
st = new_struct(name, klass);
|
||||||
|
}
|
||||||
|
setup_struct(st, rest);
|
||||||
if (rb_block_given_p()) {
|
if (rb_block_given_p()) {
|
||||||
rb_mod_module_eval(0, 0, st);
|
rb_mod_module_eval(0, 0, st);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user