* object.c (rb_mod_attr): make Module#attr to be an alias to

attr_reader.  [RCR#331]

* ruby.h: export classes/modules to implement sandbox.
  [ruby-core:08283]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-07-20 17:36:36 +00:00
parent b5d9cbe8e8
commit c09cea5e1b
18 changed files with 44 additions and 41 deletions

View File

@ -255,7 +255,7 @@ VALUE rb_eNoMethodError;
VALUE rb_eSecurityError; VALUE rb_eSecurityError;
VALUE rb_eNotImpError; VALUE rb_eNotImpError;
VALUE rb_eNoMemError; VALUE rb_eNoMemError;
static VALUE rb_cNameErrorMesg; VALUE rb_cNameErrorMesg;
VALUE rb_eScriptError; VALUE rb_eScriptError;
VALUE rb_eSyntaxError; VALUE rb_eSyntaxError;

View File

@ -41,7 +41,7 @@ class Othello
[ 1, -1], [ 1, 0], [ 1, 1] [ 1, -1], [ 1, 0], [ 1, 1]
] ]
attr :com_disk, TRUE attr_accessor :com_disk
def initialize(othello) def initialize(othello)
@othello = othello @othello = othello

4
file.c
View File

@ -93,7 +93,7 @@ be_fchown(int fd, uid_t owner, gid_t group)
VALUE rb_cFile; VALUE rb_cFile;
VALUE rb_mFileTest; VALUE rb_mFileTest;
static VALUE rb_cStat; VALUE rb_cStat;
VALUE VALUE
rb_get_path(VALUE obj) rb_get_path(VALUE obj)
@ -3991,7 +3991,7 @@ rb_stat_sticky(VALUE obj)
return Qfalse; return Qfalse;
} }
static VALUE rb_mFConst; VALUE rb_mFConst;
void void
rb_file_const(const char *name, VALUE value) rb_file_const(const char *name, VALUE value)

View File

@ -964,11 +964,11 @@ class CGI
end end
# Get the cookies as a hash of cookie-name=>Cookie pairs. # Get the cookies as a hash of cookie-name=>Cookie pairs.
attr_accessor("cookies") attr_accessor :cookies
# Get the parameters as a hash of name=>values pairs, where # Get the parameters as a hash of name=>values pairs, where
# values is an Array. # values is an Array.
attr("params") attr_reader :params
# Set all the parameters. # Set all the parameters.
def params=(hash) def params=(hash)

View File

@ -400,10 +400,10 @@ class Complex < Numeric
I = Complex(0,1) I = Complex(0,1)
# The real part of a complex number. # The real part of a complex number.
attr :real attr_reader :real
# The imaginary part of a complex number. # The imaginary part of a complex number.
attr :image attr_reader :image
alias imag image alias imag image
end end

View File

@ -972,7 +972,7 @@ module DRb
def initialize(option) def initialize(option)
@option = option.to_s @option = option.to_s
end end
attr :option attr_reader :option
def to_s; @option; end def to_s; @option; end
def ==(other) def ==(other)

View File

@ -84,7 +84,7 @@ class IPAddr
IN6FORMAT = (["%.4x"] * 8).join(':') IN6FORMAT = (["%.4x"] * 8).join(':')
# Returns the address family of this IP address. # Returns the address family of this IP address.
attr :family attr_reader :family
# Creates a new ipaddr containing the given network byte ordered # Creates a new ipaddr containing the given network byte ordered
# string form of an IP address. # string form of an IP address.

View File

@ -29,9 +29,7 @@ module RubyToken
@line_no = line_no @line_no = line_no
@char_no = char_no @char_no = char_no
end end
attr :seek attr :seek, :line_no, :char_no
attr :line_no
attr :char_no
end end
class TkNode < Token class TkNode < Token
@ -58,7 +56,7 @@ module RubyToken
end end
class TkOp < Token class TkOp < Token
attr :name, true attr_accessor :name
end end
class TkOPASGN < TkOp class TkOPASGN < TkOp

View File

@ -466,11 +466,10 @@ class RubyLex
@exception_on_syntax_error = true @exception_on_syntax_error = true
end end
attr :skip_space, true attr_accessor :skip_space
attr :read_auto_clean_up, true attr_accessor :read_auto_clean_up
attr :exception_on_syntax_error, true attr_accessor :exception_on_syntax_error
attr_reader :indent
attr :indent
# io functions # io functions
def line_no def line_no

View File

@ -31,9 +31,7 @@ class Shell
@verbose = true @verbose = true
class << Shell class << Shell
attr :cascade, true attr_accessor :cascade, :debug, :verbose
attr :debug, true
attr :verbose, true
# alias cascade? cascade # alias cascade? cascade
alias debug? debug alias debug? debug
@ -98,11 +96,8 @@ class Shell
rehash rehash
end end
attr :umask, true attr_accessor :umask, :record_separator
attr :record_separator, true attr_accessor :verbose, :debug
attr :verbose, true
attr :debug, true
def debug=(val) def debug=(val)
@debug = val @debug = val

View File

@ -522,7 +522,7 @@ private
list = (class << obj; self; end).ancestors - obj.class.ancestors list = (class << obj; self; end).ancestors - obj.class.ancestors
unless list.empty? unless list.empty?
node.extraattr[RubyExtendName] = list.collect { |c| node.extraattr[RubyExtendName] = list.collect { |c|
if c.name.empty? unless c.name
raise TypeError.new("singleton can't be dumped #{ obj }") raise TypeError.new("singleton can't be dumped #{ obj }")
end end
c.name c.name

View File

@ -262,7 +262,7 @@ private
end end
def unknownobj2soap(soap_class, obj, info, map) def unknownobj2soap(soap_class, obj, info, map)
if obj.class.name.empty? unless obj.class.name
raise TypeError.new("can't dump anonymous class #{obj}") raise TypeError.new("can't dump anonymous class #{obj}")
end end
singleton_class = class << obj; self; end singleton_class = class << obj; self; end

View File

@ -232,13 +232,13 @@ module Sync_m
end end
end end
attr :sync_mode, true attr_accessor :sync_mode
attr :sync_waiting, true attr_accessor :sync_waiting
attr :sync_upgrade_waiting, true attr_accessor :sync_upgrade_waiting
attr :sync_sh_locker, true attr_accessor :sync_sh_locker
attr :sync_ex_locker, true attr_accessor :sync_ex_locker
attr :sync_ex_count, true attr_accessor :sync_ex_count
private private

View File

@ -19,9 +19,9 @@ class Tracer
@stdout = STDOUT @stdout = STDOUT
@verbose = false @verbose = false
class << self class << self
attr :verbose, true attr_accessor :verbose
alias verbose? verbose alias verbose? verbose
attr :stdout, true attr_accessor :stdout
end end
EVENT_SYMBOL = { EVENT_SYMBOL = {

4
re.c
View File

@ -19,7 +19,7 @@
#define MBCTYPE_SJIS 2 #define MBCTYPE_SJIS 2
#define MBCTYPE_UTF8 3 #define MBCTYPE_UTF8 3
static VALUE rb_eRegexpError; VALUE rb_eRegexpError;
#define BEG(no) regs->beg[no] #define BEG(no) regs->beg[no]
#define END(no) regs->end[no] #define END(no) regs->end[no]
@ -730,7 +730,7 @@ make_regexp(const char *s, long len, int flags, int ce)
* *
*/ */
static VALUE rb_cMatch; VALUE rb_cMatch;
static VALUE static VALUE
match_alloc(VALUE klass) match_alloc(VALUE klass)

11
ruby.h
View File

@ -644,7 +644,9 @@ RUBY_EXTERN VALUE rb_cBasicObject;
RUBY_EXTERN VALUE rb_cObject; RUBY_EXTERN VALUE rb_cObject;
RUBY_EXTERN VALUE rb_cArray; RUBY_EXTERN VALUE rb_cArray;
RUBY_EXTERN VALUE rb_cBignum; RUBY_EXTERN VALUE rb_cBignum;
RUBY_EXTERN VALUE rb_cBinding;
RUBY_EXTERN VALUE rb_cClass; RUBY_EXTERN VALUE rb_cClass;
RUBY_EXTERN VALUE rb_cCont;
RUBY_EXTERN VALUE rb_cDir; RUBY_EXTERN VALUE rb_cDir;
RUBY_EXTERN VALUE rb_cData; RUBY_EXTERN VALUE rb_cData;
RUBY_EXTERN VALUE rb_cFalseClass; RUBY_EXTERN VALUE rb_cFalseClass;
@ -654,19 +656,23 @@ RUBY_EXTERN VALUE rb_cFloat;
RUBY_EXTERN VALUE rb_cHash; RUBY_EXTERN VALUE rb_cHash;
RUBY_EXTERN VALUE rb_cInteger; RUBY_EXTERN VALUE rb_cInteger;
RUBY_EXTERN VALUE rb_cIO; RUBY_EXTERN VALUE rb_cIO;
RUBY_EXTERN VALUE rb_cMatch;
RUBY_EXTERN VALUE rb_cMethod; RUBY_EXTERN VALUE rb_cMethod;
RUBY_EXTERN VALUE rb_cModule; RUBY_EXTERN VALUE rb_cModule;
RUBY_EXTERN VALUE rb_cNameErrorMesg;
RUBY_EXTERN VALUE rb_cNilClass; RUBY_EXTERN VALUE rb_cNilClass;
RUBY_EXTERN VALUE rb_cNumeric; RUBY_EXTERN VALUE rb_cNumeric;
RUBY_EXTERN VALUE rb_cProc; RUBY_EXTERN VALUE rb_cProc;
RUBY_EXTERN VALUE rb_cRange; RUBY_EXTERN VALUE rb_cRange;
RUBY_EXTERN VALUE rb_cRegexp; RUBY_EXTERN VALUE rb_cRegexp;
RUBY_EXTERN VALUE rb_cStat;
RUBY_EXTERN VALUE rb_cString; RUBY_EXTERN VALUE rb_cString;
RUBY_EXTERN VALUE rb_cStruct;
RUBY_EXTERN VALUE rb_cSymbol; RUBY_EXTERN VALUE rb_cSymbol;
RUBY_EXTERN VALUE rb_cThread; RUBY_EXTERN VALUE rb_cThread;
RUBY_EXTERN VALUE rb_cTime; RUBY_EXTERN VALUE rb_cTime;
RUBY_EXTERN VALUE rb_cTrueClass; RUBY_EXTERN VALUE rb_cTrueClass;
RUBY_EXTERN VALUE rb_cStruct; RUBY_EXTERN VALUE rb_cUnboundMethod;
RUBY_EXTERN VALUE rb_eException; RUBY_EXTERN VALUE rb_eException;
RUBY_EXTERN VALUE rb_eStandardError; RUBY_EXTERN VALUE rb_eStandardError;
@ -689,6 +695,9 @@ RUBY_EXTERN VALUE rb_eNotImpError;
RUBY_EXTERN VALUE rb_eNoMemError; RUBY_EXTERN VALUE rb_eNoMemError;
RUBY_EXTERN VALUE rb_eNoMethodError; RUBY_EXTERN VALUE rb_eNoMethodError;
RUBY_EXTERN VALUE rb_eFloatDomainError; RUBY_EXTERN VALUE rb_eFloatDomainError;
RUBY_EXTERN VALUE rb_eLocalJumpError;
RUBY_EXTERN VALUE rb_eSysStackError;
RUBY_EXTERN VALUE rb_eRegexpError;
RUBY_EXTERN VALUE rb_eScriptError; RUBY_EXTERN VALUE rb_eScriptError;
RUBY_EXTERN VALUE rb_eNameError; RUBY_EXTERN VALUE rb_eNameError;

View File

@ -74,10 +74,12 @@ module RSS
:media => "printer", :charset => "UTF-8", :media => "printer", :charset => "UTF-8",
:alternate => "yes"},], :alternate => "yes"},],
].each do |xsss| ].each do |xsss|
p xsss
doc = REXML::Document.new(make_sample_RDF) doc = REXML::Document.new(make_sample_RDF)
root = doc.root root = doc.root
xsss.each do |xss| xsss.each do |xss|
content = xss.collect do |key, name| content = xss.collect do |key, name|
p [key, name]
%Q[#{key}="#{name}"] %Q[#{key}="#{name}"]
end.join(" ") end.join(" ")
pi = REXML::Instruction.new("xml-stylesheet", content) pi = REXML::Instruction.new("xml-stylesheet", content)

View File

@ -18,7 +18,7 @@
#include "st.h" #include "st.h"
#include "util.h" #include "util.h"
static st_table *rb_global_tbl; st_table *rb_global_tbl;
st_table *rb_class_tbl; st_table *rb_class_tbl;
static ID autoload, classpath, tmp_classpath; static ID autoload, classpath, tmp_classpath;