mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (Init_IO): $FILENAME and $* must be read-only. [ruby-dev:36698]
* variable.c (*_getter, *_setter, *_marker): made public. * include/ruby/ruby.h (rb_gvar_*_{getter,setter,marker}): declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b968fa97f6
commit
1288965f4e
4 changed files with 55 additions and 25 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Oct 14 20:45:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (Init_IO): $FILENAME and $* must be read-only. [ruby-dev:36698]
|
||||
|
||||
* variable.c (*_getter, *_setter, *_marker): made public.
|
||||
|
||||
* include/ruby/ruby.h (rb_gvar_*_{getter,setter,marker}): declared.
|
||||
|
||||
Tue Oct 14 20:32:09 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* enc/trans/single_byte.trans (transcode_tblgen_singlebyte): renamed
|
||||
|
|
|
@ -846,6 +846,26 @@ VALUE rb_define_module_under(VALUE, const char*);
|
|||
void rb_include_module(VALUE,VALUE);
|
||||
void rb_extend_object(VALUE,VALUE);
|
||||
|
||||
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);
|
||||
|
||||
void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar);
|
||||
|
||||
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));
|
||||
|
|
4
io.c
4
io.c
|
@ -8464,11 +8464,11 @@ Init_IO(void)
|
|||
rb_define_global_const("ARGF", argf);
|
||||
|
||||
rb_define_hooked_variable("$.", &argf, argf_lineno_getter, argf_lineno_setter);
|
||||
rb_define_hooked_variable("$FILENAME", &argf, argf_filename_getter, 0);
|
||||
rb_define_hooked_variable("$FILENAME", &argf, argf_filename_getter, rb_gvar_readonly_setter);
|
||||
ARGF.filename = rb_str_new2("-");
|
||||
|
||||
rb_define_hooked_variable("$-i", &argf, opt_i_get, opt_i_set);
|
||||
rb_define_hooked_variable("$*", &argf, argf_argv_getter, 0);
|
||||
rb_define_hooked_variable("$*", &argf, argf_argv_getter, rb_gvar_readonly_setter);
|
||||
|
||||
#if defined (_WIN32) || defined(__CYGWIN__)
|
||||
atexit(pipe_atexit);
|
||||
|
|
48
variable.c
48
variable.c
|
@ -286,11 +286,11 @@ rb_obj_classname(VALUE obj)
|
|||
return rb_class2name(CLASS_OF(obj));
|
||||
}
|
||||
|
||||
struct global_variable;
|
||||
#define global_variable rb_global_variable
|
||||
|
||||
typedef VALUE gvar_getter_t(ID id, void *data, struct global_variable *gvar);
|
||||
typedef void gvar_setter_t(VALUE val, ID id, void *data, struct global_variable *gvar);
|
||||
typedef void gvar_marker_t(VALUE *var);
|
||||
#define gvar_getter_t rb_gvar_getter_t
|
||||
#define gvar_setter_t rb_gvar_setter_t
|
||||
#define gvar_marker_t rb_gvar_marker_t
|
||||
|
||||
struct trace_var {
|
||||
int removed;
|
||||
|
@ -314,17 +314,19 @@ struct global_entry {
|
|||
ID id;
|
||||
};
|
||||
|
||||
static VALUE undef_getter(ID id, void *data, struct global_variable *gvar);
|
||||
static void undef_setter(VALUE val, ID id, void *data, struct global_variable *gvar);
|
||||
static void undef_marker(VALUE *var);
|
||||
#define undef_getter rb_gvar_undef_getter
|
||||
#define undef_setter rb_gvar_undef_setter
|
||||
#define undef_marker rb_gvar_undef_marker
|
||||
|
||||
static VALUE val_getter(ID id, void *data, struct global_variable *gvar);
|
||||
static void val_setter(VALUE val, ID id, void *data, struct global_variable *gvar);
|
||||
static void val_marker(VALUE *var);
|
||||
#define val_getter rb_gvar_val_getter
|
||||
#define val_setter rb_gvar_val_setter
|
||||
#define val_marker rb_gvar_val_marker
|
||||
|
||||
static VALUE var_getter(ID id, void *data, struct global_variable *gvar);
|
||||
static void var_setter(VALUE val, ID id, void *data, struct global_variable *gvar);
|
||||
static void var_marker(VALUE *var);
|
||||
#define var_getter rb_gvar_var_getter
|
||||
#define var_setter rb_gvar_var_setter
|
||||
#define var_marker rb_gvar_var_marker
|
||||
|
||||
#define readonly_setter rb_gvar_readonly_setter
|
||||
|
||||
struct global_entry*
|
||||
rb_global_entry(ID id)
|
||||
|
@ -354,7 +356,7 @@ rb_global_entry(ID id)
|
|||
return entry;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
undef_getter(ID id, void *data, struct global_variable *var)
|
||||
{
|
||||
rb_warning("global variable `%s' not initialized", rb_id2name(id));
|
||||
|
@ -362,7 +364,7 @@ undef_getter(ID id, void *data, struct global_variable *var)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
undef_setter(VALUE val, ID id, void *data, struct global_variable *var)
|
||||
{
|
||||
var->getter = val_getter;
|
||||
|
@ -372,31 +374,31 @@ undef_setter(VALUE val, ID id, void *data, struct global_variable *var)
|
|||
var->data = (void*)val;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
undef_marker(VALUE *var)
|
||||
{
|
||||
}
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
val_getter(ID id, void *data, struct global_variable *var)
|
||||
{
|
||||
return (VALUE)data;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
val_setter(VALUE val, ID id, void *data, struct global_variable *var)
|
||||
{
|
||||
var->data = (void*)val;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
val_marker(VALUE *var)
|
||||
{
|
||||
VALUE data = (VALUE)var;
|
||||
if (data) rb_gc_mark_maybe(data);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
var_getter(ID id, void *data, struct global_variable *gvar)
|
||||
{
|
||||
VALUE *var = data;
|
||||
|
@ -404,19 +406,19 @@ var_getter(ID id, void *data, struct global_variable *gvar)
|
|||
return *var;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
var_setter(VALUE val, ID id, void *data, struct global_variable *gvar)
|
||||
{
|
||||
*(VALUE *)data = val;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
var_marker(VALUE *var)
|
||||
{
|
||||
if (var) rb_gc_mark_maybe(*var);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
readonly_setter(VALUE val, ID id, void *data, struct global_variable *gvar)
|
||||
{
|
||||
rb_name_error(id, "%s is a read-only variable", rb_id2name(id));
|
||||
|
|
Loading…
Reference in a new issue