ruby-changes:52517
From: hsbt <ko1@a...>
Date: Thu, 13 Sep 2018 16:42:39 +0900 (JST)
Subject: [ruby-changes:52517] hsbt:r64722: Move new_gc branch to tags.
hsbt 2018-09-13 16:02:25 +0900 (Thu, 13 Sep 2018) New Revision: 64722 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64722 Log: Move new_gc branch to tags. Added directories: tags/new_gc/ Removed directories: branches/new_gc/ Index: new_gc/djgpp/config.sed =================================================================== --- new_gc/djgpp/config.sed (revision 64721) +++ new_gc/djgpp/config.sed (nonexistent) @@ -1,128 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/new_gc/djgpp/config.sed#L0 -/^SHELL/s,/bin/sh,$(COMSPEC), -;s%/bin/rm%rm% -;s%|| true%% -;/\/dev\/null/ { -;s,/dev/null 2>&1, nul, -;s,2> /dev/null,, -;} -;/^config.status/ { -; N;N;N;N;N;d -;} -:t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@srcdir@,.,g;t t -s,@top_srcdir@,..,;t t -s,@PATH_SEPARATOR@,:,;t t -s,@PACKAGE_NAME@,,;t t -s,@PACKAGE_TARNAME@,,;t t -s,@PACKAGE_VERSION@,,;t t -s,@PACKAGE_STRING@,,;t t -s,@PACKAGE_BUGREPORT@,,;t t -s,@exec_prefix@,${prefix},;t t -s,@prefix@,/dev/env/DJDIR,;t t -s%@program_transform_name@%s,^,,%;t t -s,@bindir@,${exec_prefix}/bin,;t t -s,@sbindir@,${exec_prefix}/sbin,;t t -s,@libexecdir@,${exec_prefix}/libexec,;t t -s,@datadir@,${prefix}/share,;t t -s,@sysconfdir@,${prefix}/etc,;t t -s,@sharedstatedir@,${prefix}/com,;t t -s,@localstatedir@,${prefix}/var,;t t -s,@libdir@,${exec_prefix}/lib,;t t -s,@includedir@,${prefix}/include,;t t -s,@oldincludedir@,/usr/include,;t t -s,@infodir@,${prefix}/info,;t t -s,@mandir@,${prefix}/man,;t t -s,@build_alias@,i586-pc-msdosdjgpp,;t t -s,@host_alias@,i586-pc-msdosdjgpp,;t t -s,@target_alias@,i386-msdosdjgpp,;t t -s,@DEFS@,,;t t -s,@ECHO_C@,,;t t -s,@ECHO_N@,-n,;t t -s,@ECHO_T@,,;t t -s,@LIBS@,-lm ,;t t -s,@MAJOR@,1,;t t -s,@MINOR@,7,;t t -s,@TEENY@,3,;t t -s,@build@,i586-pc-msdosdjgpp,;t t -s,@build_cpu@,i586,;t t -s,@build_vendor@,pc,;t t -s,@build_os@,msdosdjgpp,;t t -s,@host@,i586-pc-msdosdjgpp,;t t -s,@host_cpu@,i586,;t t -s,@host_vendor@,pc,;t t -s,@host_os@,msdosdjgpp,;t t -s,@target@,i386-pc-msdosdjgpp,;t t -s,@target_cpu@,i386,;t t -s,@target_vendor@,pc,;t t -s,@target_os@,msdosdjgpp,;t t -s,@CC@,gcc,;t t -s,@ac_ct_CC@,,;t t -s,@CFLAGS@,-Os,;t t -s,@LDFLAGS@,,;t t -s,@CPPFLAGS@,,;t t -s,@EXEEXT@,.exe,;t t -s,@OBJEXT@,o,;t t -s,@CPP@,gcc -E,;t t -s,@EGREP@,grep -E,;t t -s,@GNU_LD@,yes,;t t -s,@CPPOUTFILE@,-o conftest.i,;t t -s,@OUTFLAG@,-o ,;t t -s,@YACC@,bison -y,;t t -s,@RANLIB@,ranlib,;t t -s,@ac_ct_RANLIB@,,;t t -s,@AR@,ar,;t t -s,@ac_ct_AR@,,;t t -s,@NM@,,;t t -s,@ac_ct_NM@,,;t t -s,@WINDRES@,,;t t -s,@ac_ct_WINDRES@,,;t t -s,@DLLWRAP@,,;t t -s,@ac_ct_DLLWRAP@,,;t t -s,@LN_S@,ln -s,;t t -s,@SET_MAKE@,,;t t -s,@LIBOBJS@,crypt.o flock.o vsnprintf.o,;t t -s,@ALLOCA@,,;t t -s,@XCFLAGS@,,;t t -s,@XLDFLAGS@, -L.,;t t -s,@DLDFLAGS@,,;t t -s,@STATIC@,,;t t -s,@CCDLFLAGS@,,;t t -s,@LDSHARED@,ld,;t t -s,@DLEXT@,so,;t t -s,@DLEXT2@,,;t t -s,@LIBEXT@,a,;t t -s,@LINK_SO@,,;t t -s,@LIBPATHFLAG@, -L%s,;t t -s,@STRIP@,strip,;t t -s,@EXTSTATIC@,,;t t -s,@setup@,Setup.dj,;t t -s,@MINIRUBY@,./miniruby,;t t -s,@PREP@,,;t t -s,@ARCHFILE@,,;t t -s,@LIBRUBY_LDSHARED@,ld,;t t -s,@LIBRUBY_DLDFLAGS@,,;t t -s,@RUBY_INSTALL_NAME@,ruby,;t t -s,@rubyw_install_name@,,;t t -s,@RUBYW_INSTALL_NAME@,,;t t -s,@RUBY_SO_NAME@,$(RUBY_INSTALL_NAME),;t t -s,@LIBRUBY_A@,lib$(RUBY_INSTALL_NAME).a,;t t -s,@LIBRUBY_SO@,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY),;t t -s,@LIBRUBY_ALIASES@,lib$(RUBY_SO_NAME).so,;t t -s,@LIBRUBY@,$(LIBRUBY_A),;t t -s,@LIBRUBYARG@,-l$(RUBY_INSTALL_NAME),;t t -s,@SOLIBS@,,;t t -s,@DLDLIBS@,-lc,;t t -s,@ENABLE_SHARED@,no,;t t -s,@MAINLIBS@,,;t t -s,@COMMON_LIBS@,,;t t -s,@COMMON_MACROS@,,;t t -s,@COMMON_HEADERS@,,;t t -s,@EXPORT_PREFIX@,,;t t -s,@MAKEFILES@,Makefile,;t t -s,@arch@,i386-msdosdjgpp,;t t -s,@sitearch@,i386-msdosdjgpp,;t t -s,@sitedir@,${prefix}/lib/ruby/site_ruby,;t t -s,@configure_args@,,;t t -/^,THIS_IS_DUMMY_PATTERN_/i\ -ac_given_srcdir=. Property changes on: new_gc/djgpp/config.sed ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: new_gc/djgpp/README.djgpp =================================================================== --- new_gc/djgpp/README.djgpp (revision 64721) +++ new_gc/djgpp/README.djgpp (nonexistent) @@ -1,21 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/new_gc/djgpp/README.djgpp#L0 -* How to compile and install on djgpp - -This is what you need to do to compile and install Ruby: - - 1. Run configure.bat, which will generate config.h and Makefile - (GNU sed required). - Message like this is normal: - sed.exe: can't read 123456789: No such file or directory (ENOENT) - - 2. Edit defines.h if you need. Probably this step will not need. - - 3. Remove comment mark(#) before the module names from ext/Setup.dj (or - add module names if not present). - - 4. Run make. - - 5. Optionally, run 'make test' to check whether the compiled Ruby - interpreter works well. If you see the message "test succeeded", - your ruby works as it should (hopefully). - - 6. Run 'make install' Property changes on: new_gc/djgpp/README.djgpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: new_gc/djgpp/config.hin =================================================================== --- new_gc/djgpp/config.hin (revision 64721) +++ new_gc/djgpp/config.hin (nonexistent) @@ -1,114 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/new_gc/djgpp/config.hin#L0 - -#define PACKAGE_NAME "" -#define PACKAGE_TARNAME "" -#define PACKAGE_VERSION "" -#define PACKAGE_STRING "" -#define PACKAGE_BUGREPORT "" -#define USE_BUILTIN_FRAME_ADDRESS 1 -#define STDC_HEADERS 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_LONG_LONG 1 -#define HAVE_OFF_T 1 -#define SIZEOF_INT 4 -#define SIZEOF_SHORT 2 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF___INT64 0 -#define SIZEOF_OFF_T 4 -#define SIZEOF_VOIDP 4 -#define SIZEOF_FLOAT 4 -#define SIZEOF_DOUBLE 8 -#define HAVE_PROTOTYPES 1 -#define TOKEN_PASTE(x,y) x##y -#define HAVE_STDARG_PROTOTYPES 1 -#define NORETURN(x) x __attribute__ ((noreturn)) -#define HAVE_DECL_SYS_NERR 1 -#define HAVE_DIRENT_H 1 -#define STDC_HEADERS 1 -#define HAVE_SYS_WAIT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_SYS_FILE_H 1 -#define HAVE_SYS_IOCTL_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_SYS_FCNTL_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_TIMES_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_PWD_H 1 -#define HAVE_UTIME_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_DIRECT_H 1 -#define HAVE_SYS_RESOURCE_H 1 -#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 -#define HAVE_ST_BLKSIZE 1 -#define HAVE_STRUCT_STAT_ST_RDEV 1 -#define HAVE_ST_RDEV 1 -#define GETGROUPS_T gid_t -#define RETSIGTYPE void -#define HAVE_ALLOCA 1 -#define HAVE_DUP2 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MKDIR 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_STRERROR 1 -#define HAVE_STRFTIME 1 -#define HAVE_STRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOUL 1 -#define HAVE_ISINF 1 -#define HAVE_ISNAN 1 -#define HAVE_FINITE 1 -#define HAVE_HYPOT 1 -#define HAVE_ACOSH 1 -#define HAVE_FMOD 1 -#define HAVE_WAITPID 1 -#define HAVE_FSYNC 1 -#define HAVE_TRUNCATE 1 -#define HAVE_CHSIZE 1 -#define HAVE_TIMES 1 -#define HAVE_UTIMES 1 -#define HAVE_FCNTL 1 -#define HAVE_SYMLINK 1 -#define HAVE_SETITIMER 1 -#define HAVE_PAUSE 1 -#define HAVE_GETPGRP 1 -#define HAVE_SETPGID 1 -#define HAVE_GETGROUPS 1 -#define HAVE_GETRLIMIT 1 -#define HAVE_SIGPROCMASK 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETSID 1 -#define HAVE_TELLDIR 1 -#define HAVE_SEEKDIR 1 -#define HAVE_MKTIME 1 -#define HAVE_COSH 1 -#define HAVE_SINH 1 -#define HAVE_TANH 1 -#define HAVE_STRUCT_TM_TM_ZONE 1 -#define HAVE_TM_ZONE 1 -#define HAVE_STRUCT_TM_TM_GMTOFF 1 -#define POSIX_SIGNAL 1 -#define GETPGRP_VOID 1 -#define SETPGRP_VOID 1 -#define RSHIFT(x,y) ((x)>>(int)y) -#define FILE_COUNT _cnt -#define FILE_READPTR _ptr -#define NEED_IO_FLUSH_BETWEEN_RW 1 -#define DEFAULT_KCODE KCODE_NONE -#define DLEXT ".so" -#define RUBY_LIB "/lib/ruby/@MAJOR@.@MINOR@" -#define RUBY_SITE_LIB "/lib/ruby/site_ruby" -#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/@MAJOR@.@MINOR@" -#define RUBY_PLATFORM "i386-msdosdjgpp" -#define RUBY_ARCHLIB "/lib/ruby/@MAJOR@.@MINOR@/i386-msdosdjgpp" -#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/@MAJOR@.@MINOR@/i386-msdosdjgpp" Property changes on: new_gc/djgpp/config.hin ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: new_gc/djgpp/configure.bat =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: new_gc/djgpp/configure.bat =================================================================== --- new_gc/djgpp/configure.bat (revision 64721) +++ new_gc/djgpp/configure.bat (nonexistent) Property changes on: new_gc/djgpp/configure.bat ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: new_gc/djgpp/GNUmakefile.in =================================================================== --- new_gc/djgpp/GNUmakefile.in (revision 64721) +++ new_gc/djgpp/GNUmakefile.in (nonexistent) @@ -1,2 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/new_gc/djgpp/GNUmakefile.in#L0 -include Makefile -VPATH = $(srcdir) $(srcdir)/missing Property changes on: new_gc/djgpp/GNUmakefile.in ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: new_gc/djgpp/mkver.sed =================================================================== --- new_gc/djgpp/mkver.sed (revision 64721) +++ new_gc/djgpp/mkver.sed (nonexistent) @@ -1 +0,0 @@ -/RUBY_VERSION /s/^.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/s,@MAJOR@,\1,;s,@MINOR@,\2,;s,@TEENY@,\3,/p Property changes on: new_gc/djgpp/mkver.sed ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Author Date Id Revision \ No newline at end of property Index: new_gc/struct.c =================================================================== --- new_gc/struct.c (revision 64721) +++ new_gc/struct.c (nonexistent) @@ -1,921 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/new_gc/struct.c#L0 -/********************************************************************** - - struct.c - - - $Author$ - $Date$ - created at: Tue Mar 22 18:44:30 JST 1995 - - Copyright (C) 1993-2003 Yukihiro Matsumoto - -**********************************************************************/ - -#include "ruby.h" - -VALUE rb_cStruct; - -static VALUE struct_alloc _((VALUE)); - -VALUE -rb_struct_iv_get(c, name) - VALUE c; - char *name; -{ - ID id; - - id = rb_intern(name); - for (;;) { - if (rb_ivar_defined(c, id)) - return rb_ivar_get(c, id); - c = RCLASS(c)->super; - if (c == 0 || c == rb_cStruct) - return Qnil; - } -} - -VALUE -rb_struct_s_members(klass) - VALUE klass; -{ - VALUE members = rb_struct_iv_get(klass, "__members__"); - - if (NIL_P(members)) { - rb_bug("non-initialized struct"); - } - return members; -} - -VALUE -rb_struct_members(s) - VALUE s; -{ - VALUE members = rb_struct_s_members(rb_obj_class(s)); - - if (RSTRUCT(s)->len != RARRAY(members)->len) { - rb_raise(rb_eTypeError, "struct size differs (%d required %d given)", - RARRAY(members)->len, RSTRUCT(s)->len); - } - return members; -} - -static VALUE -rb_struct_s_members_m(klass) - VALUE klass; -{ - VALUE members, ary; - VALUE *p, *pend; - - members = rb_struct_s_members(klass); - ary = rb_ary_new2(RARRAY(members)->len); - p = RARRAY(members)->ptr; pend = p + RARRAY(members)->len; - while (p < pend) { - rb_ary_push(ary, rb_str_new2(rb_id2name(SYM2ID(*p)))); - p++; - } - - return ary; -} - -/* - * call-seq: - * struct.members => array - * - * Returns an array of strings representing the names of the instance - * variables. - * - * Customer = Struct.new(:name, :address, :zip) - * joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) - * joe.members #=> ["name", "address", "zip"] - */ - -static VALUE -rb_struct_members_m(obj) - VALUE obj; -{ - return rb_struct_s_members_m(rb_obj_class(obj)); -} - -VALUE -rb_struct_getmember(obj, id) - VALUE obj; - ID id; -{ - VALUE members, slot; - long i; - - members = rb_struct_members(obj); - slot = ID2SYM(id); - for (i=0; i<RARRAY(members)->len; i++) { - if (RARRAY(members)->ptr[i] == slot) { - return RSTRUCT(obj)->ptr[i]; - } - } - rb_name_error(id, "%s is not struct member", rb_id2name(id)); - return Qnil; /* not reached */ -} - -static VALUE -rb_struct_ref(obj) - VALUE obj; -{ - return rb_struct_getmember(obj, rb_frame_this_func()); -} - -static VALUE rb_struct_ref0(obj) VALUE obj; {return RSTRUCT(obj)->ptr[0];} -static VALUE rb_struct_ref1(obj) VALUE obj; {return RSTRUCT(obj)->ptr[1];} -static VALUE rb_struct_ref2(obj) VALUE obj; {return RSTRUCT(obj)->ptr[2];} -static VALUE rb_struct_ref3(obj) VALUE obj; {return RSTRUCT(obj)->ptr[3];} -static VALUE rb_struct_ref4(obj) VALUE obj; {return RSTRUCT(obj)->ptr[4];} -static VALUE rb_struct_ref5(obj) VALUE obj; {return RSTRUCT(obj)->ptr[5];} -static VALUE rb_struct_ref6(obj) VALUE obj; {return RSTRUCT(obj)->ptr[6];} -static VALUE rb_struct_ref7(obj) VALUE obj; {return RSTRUCT(obj)->ptr[7];} -static VALUE rb_struct_ref8(obj) VALUE obj; {return RSTRUCT(obj)->ptr[8];} -static VALUE rb_struct_ref9(obj) VALUE obj; {return RSTRUCT(obj)->ptr[9];} - -static VALUE (*ref_func[10])() = { - rb_struct_ref0, - rb_struct_ref1, - rb_struct_ref2, - rb_struct_ref3, - rb_struct_ref4, - rb_struct_ref5, - rb_struct_ref6, - rb_struct_ref7, - rb_struct_ref8, - rb_struct_ref9, -}; - -static void -rb_struct_modify(s) - VALUE s; -{ - if (OBJ_FROZEN(s)) rb_error_frozen("Struct"); - if (!OBJ_TAINTED(s) && rb_safe_level() >= 4) - rb_raise(rb_eSecurityError, "Insecure: can't modify Struct"); -} - -static VALUE -rb_struct_set(obj, val) - VALUE obj, val; -{ - VALUE members, slot; - long i; - - members = rb_struct_members(obj); - rb_struct_modify(obj); - for (i=0; i<RARRAY(members)->len; i++) { - slot = RARRAY(members)->ptr[i]; - if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) { - return RSTRUCT(obj)->ptr[i] = val; - } - } - rb_name_error(rb_frame_this_func(), "`%s' is not a struct member", - rb_id2name(rb_frame_this_func())); - return Qnil; /* not reached */ -} - -static VALUE -make_struct(name, members, klass) - VALUE name, members, klass; -{ - VALUE nstr; - ID id; - long i; - - OBJ_FREEZE(members); - if (NIL_P(name)) { - nstr = rb_class_new(klass); - rb_make_metaclass(nstr, RBASIC(klass)->klass); - rb_class_inherited(klass, nstr); - } - else { - char *cname = StringValuePtr(name); - - id = rb_intern(cname); - if (!rb_is_const_id(id)) { - rb_name_error(id, "identifier %s needs to be constant", cname); - } - if (rb_const_defined_at(klass, id)) { - rb_warn("redefining constant Struct::%s", cname); - rb_mod_remove_const(klass, ID2SYM(id)); - } - nstr = rb_define_class_under(klass, rb_id2name(id), klass); - } - rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(members)->len)); - rb_iv_set(nstr, "__members__", members); - - rb_define_alloc_func(nstr, struct_alloc); - rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1); - rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1); - rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0); - for (i=0; i< RARRAY(members)->len; i++) { - ID id = SYM2ID(RARRAY(members)->ptr[i]); - if (rb_is_local_id(id) || rb_is_const_id(id)) { - if (i<sizeof(ref_func)) { - rb_define_method_id(nstr, id, ref_func[i], 0); - } - else { - rb_define_method_id(nstr, id, rb_struct_ref, 0); - } - rb_define_method_id(nstr, rb_id_attrset(id), rb_struct_set, 1); - } - } - - return nstr; -} - -#ifdef HAVE_STDARG_PROTOTYPES -#include <stdarg.h> -#define va_init_list(a,b) va_start(a,b) -#else -#include <varargs.h> -#define va_init_list(a,b) va_start(a) -#endif - -VALUE -#ifdef HAVE_STDARG_PROTOTYPES -rb_struct_define(const char *name, ...) -#else -rb_struct_define(name, va_alist) - const char *name; - va_dcl -#endif -{ - va_list ar; - VALUE nm, ary; - char *mem; - - if (!name) nm = Qnil; - else nm = rb_str_new2(name); - ary = rb_ary_new(); - - va_init_list(ar, name); - while (mem = va_arg(ar, char*)) { - ID slot = rb_intern(mem); - rb_ary_push(ary, ID2SYM(slot)); - } - va_end(ar); - - return make_struct(nm, ary, rb_cStruct); -} - -/* - * call-seq: - * Struct.new( [aString] [, aSym]+> ) => StructClass - * StructClass.new(arg, ...) => obj - * StructClass[arg, ...] => obj - * - * Creates a new class, named by <i>aString</i>, containing accessor - * methods for the given symbols. If the name <i>aString</i> is - * omitted, an anonymous structure class will be created. Otherwise, - * the name of this struct will appear as a constant in class - * <code>Struct</code>, so it must be unique for all - * <code>Struct</code>s in the system and should start with a capital - * letter. Assigning a structure class to a constant effectively gives - * the class the name of the constant. - * - * <code>Struct::new</code> returns a new <code>Class</code> object, - * which can then be used to create specific instances of the new - * structure. The number of actual parameters must be - * less than or equal to the number of attributes defined for this - * class; unset parameters default to \nil{}. Passing too many - * parameters will raise an \E{ArgumentError}. - * - * The remaining methods listed in this section (class and instance) - * are defined for this generated class. - * - * # Create a structure with a name in Struct - * Struct.new("Customer", :name, :address) #=> Struct::Customer - * Struct::Customer.new("Dave", "123 Main") #=> #<Struct::Customer name="Dave", address="123 Main"> - * - * # Create a structure named by its constant - * Customer = Struct.new(:name, :address) #=> Customer - * Customer.new("Dave", "123 Main") #=> #<Customer name="Dave", address="123 Main"> - */ - -static VALUE -rb_struct_s_def(argc, argv, klass) - int argc; - VALUE *argv; - VALUE klass; -{ - VALUE name, rest; - long i; - VALUE st; - ID id; - - rb_scan_args(argc, argv, "1*", &name, &rest); - for (i=0; i<RARRAY(rest)->len; i++) { - id = rb_to_id(RARRAY(rest)->ptr[i]); - RARRAY(rest)->ptr[i] = ID2SYM(id); - } - if (!NIL_P(name)) { - VALUE tmp = rb_check_string_type(name); - - if (NIL_P(tmp)) { - id = rb_to_id(name); - rb_ary_unshift(rest, ID2SYM(id)); - name = Qnil; - } - } - st = make_struct(name, rest, klass); - if (rb_block_given_p()) { - rb_mod_module_eval(0, 0, st); - } - - return st; -} - -/* - */ - -static VALUE -rb_struct_initialize(self, values) - VALUE self, values; -{ - VALUE klass = rb_obj_class(self); - VALUE size; - long n; - - rb_struct_modify(self); - size = rb_struct_iv_get(klass, "__size__"); - n = FIX2LONG(si (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/