1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

*** empty log message ***

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1998-03-06 10:07:53 +00:00
parent f70ffbee21
commit 6a3fdf70f1
7 changed files with 93 additions and 26 deletions

View file

@ -1,5 +1,18 @@
Fri Mar 6 17:23:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* object.c (obj_alloc): check for allocating instance for the
primitive classes (mostly perfect).
* ext/curses/curses.c (curses_finalize): restore original state at
interpreter temination.
* ext/curses/curses.c (curses_addstr): forgot to check argument
type (caused SEGV). now uses STR2CSTR() macro.
Thu Mar 5 13:47:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (block_pass): accepts method object as block args.
* eval.c (f_missing): use any_to_s() for stringify.
Wed Mar 4 01:39:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>

42
eval.c
View file

@ -44,6 +44,8 @@ static VALUE f_binding _((VALUE));
static void f_END _((void));
static VALUE f_iterator_p _((void));
static VALUE block_pass _((VALUE,NODE*));
static VALUE cMethod;
static VALUE method_proc _((VALUE));
#define SCOPE_PRIVATE FL_USER4
#define SCOPE_MODFUNC FL_USER5
@ -4618,7 +4620,10 @@ block_pass(self, node)
volatile int orphan;
volatile int safe = safe_level;
if (TYPE(block) != T_DATA
if (obj_is_kind_of(block, cMethod)) {
block = method_proc(block);
}
else if (TYPE(block) != T_DATA
|| RDATA(block)->dfree != blk_free
|| !obj_is_kind_of(block, cProc)) {
TypeError("wrong argument type %s (expected Proc)",
@ -4680,8 +4685,6 @@ block_pass(self, node)
return result;
}
static VALUE cMethod;
struct METHOD {
VALUE klass, oklass;
VALUE recv;
@ -4774,6 +4777,38 @@ method_inspect(method)
return str;
}
static VALUE
mproc()
{
VALUE proc;
/* emulate ruby's method call */
PUSH_ITER(ITER_CUR);
PUSH_FRAME();
proc = f_lambda();
POP_FRAME();
POP_ITER();
return proc;
}
static VALUE
mcall(args, method)
VALUE args, method;
{
if (TYPE(args) == T_ARRAY) {
return method_call(RARRAY(args)->len, RARRAY(args)->ptr, method);
}
return method_call(1, &args, method);
}
static VALUE
method_proc(method)
VALUE method;
{
return rb_iterate(mproc, 0, mcall, method);
}
void
Init_Proc()
{
@ -4793,6 +4828,7 @@ Init_Proc()
rb_define_method(cMethod, "call", method_call, -1);
rb_define_method(cMethod, "inspect", method_inspect, 0);
rb_define_method(cMethod, "to_s", method_inspect, 0);
rb_define_method(cMethod, "to_proc", method_proc, 0);
rb_define_method(mKernel, "method", obj_method, 1);
}

View file

@ -1,7 +1,7 @@
#option nodynamic
#GD
#curses
curses
#dbm
#etc
#fcntl

View file

@ -99,15 +99,27 @@ curses_stdscr()
static VALUE
curses_close_screen()
{
#ifdef HAVE_ISENDWIN
if (!isendwin())
#endif
endwin();
return Qnil;
}
static void
curses_finalize()
{
#ifdef HAVE_ISENDWIN
if (!isendwin())
#endif
endwin();
}
/* def closed? */
static VALUE
curses_closed()
{
#ifdef HAVE_ENDWIN
#ifdef HAVE_ISENDWIN
if (isendwin()) {
return TRUE;
}
@ -313,7 +325,7 @@ curses_addstr(obj, str)
VALUE obj;
VALUE str;
{
addstr(RSTRING(str)->ptr);
addstr(STR2CSTR(str));
return Qnil;
}
@ -659,7 +671,7 @@ window_addstr(obj, str)
struct windata *winp;
GetWINDOW(obj, winp);
waddstr(winp->window, RSTRING(str)->ptr);
waddstr(winp->window, STR2CSTR(str));
return Qnil;
}
@ -787,4 +799,6 @@ Init_curses()
rb_define_method(cWindow, "getstr", window_getstr, 0);
rb_define_method(cWindow, "delch", window_delch, 0);
rb_define_method(cWindow, "deleteln", window_deleteln, 0);
rb_set_end_proc(curses_finalize, 0);
}

View file

@ -2251,7 +2251,10 @@ retry:
}
/* fall through */
case '\n':
if (lex_state == EXPR_BEG || lex_state == EXPR_FNAME) {
switch (lex_state) {
case EXPR_BEG:
case EXPR_FNAME:
case EXPR_DOT:
sourceline++;
goto retry;
}

33
ruby.h
View file

@ -127,20 +127,22 @@ extern VALUE cObject;
VALUE rb_class_of _((VALUE));
#define CLASS_OF(v) rb_class_of((VALUE)(v))
#define T_NIL 0x00
#define T_OBJECT 0x01
#define T_CLASS 0x02
#define T_ICLASS 0x03
#define T_MODULE 0x04
#define T_FLOAT 0x05
#define T_STRING 0x06
#define T_REGEXP 0x07
#define T_ARRAY 0x08
#define T_FIXNUM 0x09
#define T_HASH 0x0a
#define T_STRUCT 0x0b
#define T_BIGNUM 0x0c
#define T_FILE 0x0d
#define T_NONE 0x00
#define T_NIL 0x01
#define T_OBJECT 0x02
#define T_CLASS 0x03
#define T_ICLASS 0x04
#define T_MODULE 0x05
#define T_FLOAT 0x06
#define T_STRING 0x07
#define T_REGEXP 0x08
#define T_ARRAY 0x09
#define T_FIXNUM 0x0a
#define T_HASH 0x0b
#define T_STRUCT 0x0c
#define T_BIGNUM 0x0d
#define T_FILE 0x0e
#define T_TRUE 0x20
#define T_FALSE 0x21
@ -295,7 +297,6 @@ struct RBignum {
#define RFILE(obj) (R_CAST(RFile)(obj))
#define FL_SINGLETON FL_USER0
#define FL_PRIMITIVE FL_USER1
#define FL_MARK (1<<8)
#define FL_FINALIZE (1<<9)
@ -318,6 +319,8 @@ struct RBignum {
#define FL_UNSET(x,f) if(FL_ABLE(x)){RBASIC(x)->flags &= ~(f);}
#define FL_REVERSE(x,f) if(FL_ABLE(x)){RBASIC(x)->flags ^= f;}
#define FL_PRIMITIVE FL_USER1
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(RUBY_NO_INLINE)
extern __inline__ int
rb_type(VALUE obj)

View file

@ -149,7 +149,6 @@ make_struct(name, member)
}
rb_define_method_id(nstr, id_attrset(id), struct_set, 1);
}
FL_SET(nstr, FL_PRIMITIVE);
return nstr;
}
@ -430,5 +429,4 @@ Init_Struct()
rb_define_method(cStruct, "[]=", struct_aset, 2);
rb_define_method(cStruct, "members", struct_members, 0);
FL_SET(cStruct, FL_PRIMITIVE);
}