[macruby-changes] [722] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 10 07:04:22 PST 2008


Revision: 722
          http://trac.macosforge.org/projects/ruby/changeset/722
Author:   ben at tanjero.com
Date:     2008-11-10 07:04:22 -0800 (Mon, 10 Nov 2008)
Log Message:
-----------
First basic working bits of set; missing a lot of the critical methods as well as the subclassed versions.

Modified Paths:
--------------
    MacRuby/trunk/Rakefile
    MacRuby/trunk/include/ruby/ruby.h
    MacRuby/trunk/inits.c
    MacRuby/trunk/lib/set.rb
    MacRuby/trunk/objc.m
    MacRuby/trunk/object.c

Added Paths:
-----------
    MacRuby/trunk/set.c

Modified: MacRuby/trunk/Rakefile
===================================================================
--- MacRuby/trunk/Rakefile	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/Rakefile	2008-11-10 15:04:22 UTC (rev 722)
@@ -87,7 +87,7 @@
   array bignum class compar complex dir enum enumerator error eval load proc 
   file gc hash inits io marshal math numeric object pack parse process prec 
   random range rational re regcomp regenc regerror regexec regparse regsyntax
-  ruby signal sprintf st string struct time transcode util variable version
+  ruby set signal sprintf st string struct time transcode util variable version
   blockinlining compile debug iseq vm vm_dump thread cont id objc bs encoding
   main dln dmyext enc/ascii missing/lgamma_r prelude miniprelude gc-stub
 }

Modified: MacRuby/trunk/include/ruby/ruby.h
===================================================================
--- MacRuby/trunk/include/ruby/ruby.h	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/include/ruby/ruby.h	2008-11-10 15:04:22 UTC (rev 722)
@@ -1062,6 +1062,9 @@
 RUBY_EXTERN VALUE rb_cCFHash;
 RUBY_EXTERN VALUE rb_cNSHash;
 RUBY_EXTERN VALUE rb_cNSMutableHash;
+RUBY_EXTERN VALUE rb_cCFSet;
+RUBY_EXTERN VALUE rb_cNSSet;
+RUBY_EXTERN VALUE rb_cNSMutableSet;
 RUBY_EXTERN VALUE rb_cCFNumber;
 #endif
 

Modified: MacRuby/trunk/inits.c
===================================================================
--- MacRuby/trunk/inits.c	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/inits.c	2008-11-10 15:04:22 UTC (rev 722)
@@ -45,6 +45,7 @@
 void Init_signal(void);
 void Init_String(void);
 void Init_Struct(void);
+void Init_Set(void);
 void Init_Time(void);
 void Init_var_tables(void);
 void Init_version(void);
@@ -80,6 +81,7 @@
     Init_syserr();
     Init_Array();
     Init_Hash();
+    Init_Set();
     Init_Struct();
     Init_Regexp();
     Init_pack();

Modified: MacRuby/trunk/lib/set.rb
===================================================================
--- MacRuby/trunk/lib/set.rb	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/lib/set.rb	2008-11-10 15:04:22 UTC (rev 722)
@@ -64,76 +64,37 @@
   #
   # If a block is given, the elements of enum are preprocessed by the
   # given block.
-  def initialize(enum = nil, &block) # :yields: o
-    @hash ||= Hash.new
+#  def initialize(enum = nil, &block) # :yields: o
+#    @hash ||= Hash.new
+#
+#    enum.nil? and return
+#
+#    if block
+#      enum.each { |o| add(block[o]) }
+#    else
+#      merge(enum)
+#    end
+#  end
 
-    enum.nil? and return
-
-    if block
-      enum.each { |o| add(block[o]) }
-    else
-      merge(enum)
-    end
-  end
-
   # Copy internal hash.
-  def initialize_copy(orig)
-    @hash = orig.instance_eval{@hash}.dup
-  end
+#  def initialize_copy(orig)
+#    @hash = orig.instance_eval{@hash}.dup
+#  end
 
-  def freeze	# :nodoc:
-    super
-    @hash.freeze
-    self
-  end
-
-  def taint	# :nodoc:
-    super
-    @hash.taint
-    self
-  end
-
-  def untaint	# :nodoc:
-    super
-    @hash.untaint
-    self
-  end
-
-  # Returns the number of elements.
-  def size
-    @hash.size
-  end
-  alias length size
-
   # Returns true if the set contains no elements.
   def empty?
-    @hash.empty?
+    size == 0
   end
 
-  # Removes all elements and returns self.
-  def clear
-    @hash.clear
-    self
-  end
-
   # Replaces the contents of the set with the contents of the given
   # enumerable object and returns self.
   def replace(enum)
-    if enum.class == self.class
-      @hash.replace(enum.instance_eval { @hash })
-    else
-      clear
-      enum.each { |o| add(o) }
-    end
+    clear
+    enum.each { |o| add(o) }
 
     self
   end
 
-  # Converts the set to an array.  The order of elements is uncertain.
-  def to_a
-    @hash.keys
-  end
-
   def flatten_merge(set, seen = Set.new)
     set.each { |e|
       if e.is_a?(Set)
@@ -169,12 +130,6 @@
     end
   end
 
-  # Returns true if the set contains the given object.
-  def include?(o)
-    @hash.include?(o)
-  end
-  alias member? include?
-
   # Returns true if the set is a superset of the given set.
   def superset?(set)
     set.is_a?(Set) or raise ArgumentError, "value must be a set"
@@ -203,116 +158,22 @@
     all? { |o| set.include?(o) }
   end
 
-  # Calls the given block once for each element in the set, passing
-  # the element as parameter.  Returns an enumerator if no block is
-  # given.
-  def each
-    block_given? or return enum_for(__method__)
-    @hash.each_key { |o| yield(o) }
-    self
-  end
+#  # Do collect() destructively.
+#  def collect!
+#    set = self.class.new
+#    each { |o| set << yield(o) }
+#    replace(set)
+#  end
+#  alias map! collect!
 
-  # Adds the given object to the set and returns self.  Use +merge+ to
-  # add many elements at once.
-  def add(o)
-    @hash[o] = true
-    self
-  end
-  alias << add
+#  # Equivalent to Set#delete_if, but returns nil if no changes were
+#  # made.
+#  def reject!
+#    n = size
+#    delete_if { |o| yield(o) }
+#    size == n ? nil : self
+#  end
 
-  # Adds the given object to the set and returns self.  If the
-  # object is already in the set, returns nil.
-  def add?(o)
-    if include?(o)
-      nil
-    else
-      add(o)
-    end
-  end
-
-  # Deletes the given object from the set and returns self.  Use +subtract+ to
-  # delete many items at once.
-  def delete(o)
-    @hash.delete(o)
-    self
-  end
-
-  # Deletes the given object from the set and returns self.  If the
-  # object is not in the set, returns nil.
-  def delete?(o)
-    if include?(o)
-      delete(o)
-    else
-      nil
-    end
-  end
-
-  # Deletes every element of the set for which block evaluates to
-  # true, and returns self.
-  def delete_if
-    @hash.delete_if { |o,| yield(o) }
-    self
-  end
-
-  # Do collect() destructively.
-  def collect!
-    set = self.class.new
-    each { |o| set << yield(o) }
-    replace(set)
-  end
-  alias map! collect!
-
-  # Equivalent to Set#delete_if, but returns nil if no changes were
-  # made.
-  def reject!
-    n = size
-    delete_if { |o| yield(o) }
-    size == n ? nil : self
-  end
-
-  # Merges the elements of the given enumerable object to the set and
-  # returns self.
-  def merge(enum)
-    if enum.is_a?(Set)
-      @hash.update(enum.instance_eval { @hash })
-    else
-      enum.each { |o| add(o) }
-    end
-
-    self
-  end
-
-  # Deletes every element that appears in the given enumerable object
-  # and returns self.
-  def subtract(enum)
-    enum.each { |o| delete(o) }
-    self
-  end
-
-  # Returns a new set built by merging the set and the elements of the
-  # given enumerable object.
-  def |(enum)
-    dup.merge(enum)
-  end
-  alias + |		##
-  alias union |		##
-
-  # Returns a new set built by duplicating the set, removing every
-  # element that appears in the given enumerable object.
-  def -(enum)
-    dup.subtract(enum)
-  end
-  alias difference -	##
-
-  # Returns a new set containing elements common to the set and the
-  # given enumerable object.
-  def &(enum)
-    n = self.class.new
-    enum.each { |o| n.add(o) if include?(o) }
-    n
-  end
-  alias intersection &	##
-
   # Returns a new set containing elements exclusive between the set
   # and the given enumerable object.  (set ^ enum) is equivalent to
   # ((set | enum) - (set & enum)).
@@ -322,24 +183,9 @@
     n
   end
 
-  # Returns true if two sets are equal.  The equality of each couple
-  # of elements is defined according to Object#eql?.
-  def ==(set)
-    equal?(set) and return true
-
-    set.is_a?(Set) && size == set.size or return false
-
-    hash = @hash.dup
-    set.all? { |o| hash.include?(o) }
-  end
-
-  def hash	# :nodoc:
-    @hash.hash
-  end
-
   def eql?(o)	# :nodoc:
     return false unless o.is_a?(Set)
-    @hash.eql?(o.instance_eval{@hash})
+    hash.eql?(o.hash)
   end
 
   # Classifies the set by the return value of the given block and
@@ -445,95 +291,95 @@
 end
 
 # SortedSet implements a set which elements are sorted in order.  See Set.
-class SortedSet < Set
-  @@setup = false
+#class SortedSet < Set
+#  @@setup = false
+#
+#  class << self
+#    def [](*ary)	# :nodoc:
+#      new(ary)
+#    end
+#
+#    def setup	# :nodoc:
+#      @@setup and return
+#
+#      module_eval {
+#        # a hack to shut up warning
+#        alias old_init initialize
+#        remove_method :old_init
+#      }
+#      begin
+#	require 'rbtree'
+#
+#	module_eval %{
+#	  def initialize(*args, &block)
+#	    @hash = RBTree.new
+#	    super
+#	  end
+#	}
+#      rescue LoadError
+#	module_eval %{
+#	  def initialize(*args, &block)
+#	    @keys = nil
+#	    super
+#	  end
+#
+#	  def clear
+#	    @keys = nil
+#	    super
+#	  end
+#
+#	  def replace(enum)
+#	    @keys = nil
+#	    super
+#	  end
+#
+#	  def add(o)
+#	    @keys = nil
+#	    @hash[o] = true
+#	    self
+#	  end
+#	  alias << add
+#
+#	  def delete(o)
+#	    @keys = nil
+#	    @hash.delete(o)
+#	    self
+#	  end
+#
+#	  def delete_if
+#	    n = @hash.size
+#	    @hash.delete_if { |o,| yield(o) }
+#	    @keys = nil if @hash.size != n
+#	    self
+#	  end
+#
+#	  def merge(enum)
+#	    @keys = nil
+#	    super
+#	  end
+#
+#	  def each
+#	    block_given? or return enum_for(__method__)
+#	    to_a.each { |o| yield(o) }
+#	  end
+#
+#	  def to_a
+#	    (@keys = @hash.keys).sort! unless @keys
+#	    @keys
+#	  end
+#	}
+#      end
+#
+#      @@setup = true
+#    end
+#  end
+#
+#  def initialize(*args, &block)	# :nodoc:
+#    SortedSet.setup
+#    initialize(*args, &block)
+#  end
+#end
 
-  class << self
-    def [](*ary)	# :nodoc:
-      new(ary)
-    end
-
-    def setup	# :nodoc:
-      @@setup and return
-
-      module_eval {
-        # a hack to shut up warning
-        alias old_init initialize
-        remove_method :old_init
-      }
-      begin
-	require 'rbtree'
-
-	module_eval %{
-	  def initialize(*args, &block)
-	    @hash = RBTree.new
-	    super
-	  end
-	}
-      rescue LoadError
-	module_eval %{
-	  def initialize(*args, &block)
-	    @keys = nil
-	    super
-	  end
-
-	  def clear
-	    @keys = nil
-	    super
-	  end
-
-	  def replace(enum)
-	    @keys = nil
-	    super
-	  end
-
-	  def add(o)
-	    @keys = nil
-	    @hash[o] = true
-	    self
-	  end
-	  alias << add
-
-	  def delete(o)
-	    @keys = nil
-	    @hash.delete(o)
-	    self
-	  end
-
-	  def delete_if
-	    n = @hash.size
-	    @hash.delete_if { |o,| yield(o) }
-	    @keys = nil if @hash.size != n
-	    self
-	  end
-
-	  def merge(enum)
-	    @keys = nil
-	    super
-	  end
-
-	  def each
-	    block_given? or return enum_for(__method__)
-	    to_a.each { |o| yield(o) }
-	  end
-
-	  def to_a
-	    (@keys = @hash.keys).sort! unless @keys
-	    @keys
-	  end
-	}
-      end
-
-      @@setup = true
-    end
-  end
-
-  def initialize(*args, &block)	# :nodoc:
-    SortedSet.setup
-    initialize(*args, &block)
-  end
-end
-
 module Enumerable
   # Makes a set from the enumerable object with given arguments.
   # Needs to +require "set"+ to use this method.

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/objc.m	2008-11-10 15:04:22 UTC (rev 722)
@@ -1154,6 +1154,11 @@
 	    return _CFDictionaryIsMutable((void *)recv)
 		? rb_cNSMutableHash : rb_cNSHash;
 	}
+	else if (klass == rb_cCFSet) {
+	    bool _CFSetIsMutable(void *);
+	    return _CFSetIsMutable((void *)recv)
+		? rb_cNSMutableSet : rb_cNSSet;
+	}
     }
 
     ocrcv = RB2OC(recv);

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2008-11-08 05:06:25 UTC (rev 721)
+++ MacRuby/trunk/object.c	2008-11-10 15:04:22 UTC (rev 722)
@@ -139,6 +139,8 @@
 	return rb_cNSMutableArray;
     if (cl == rb_cCFHash)
 	return rb_cNSMutableHash;
+    if (cl == rb_cCFSet)
+	return rb_cNSMutableSet;
     return cl;
 }
 

Added: MacRuby/trunk/set.c
===================================================================
--- MacRuby/trunk/set.c	                        (rev 0)
+++ MacRuby/trunk/set.c	2008-11-10 15:04:22 UTC (rev 722)
@@ -0,0 +1,307 @@
+/*
+ * MacRuby CFSet-based--implementation of Ruby 1.9's lib/set.rb
+ *
+ * This file is covered by the Ruby license. See COPYING for more details.
+ *
+ * Copyright (C) 2007-2008, Apple Inc. All rights reserved.
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ * Copyright (C) 2000 Information-technology Promotion Agency, Japan
+ */
+
+#include "ruby/ruby.h"
+
+VALUE rb_cSet;
+VALUE rb_cNSSet, rb_cNSMutableSet, rb_cCFSet;
+
+static inline void
+rb_set_modify_check(VALUE set)
+{
+    long mask;
+    mask = rb_objc_flag_get_mask((void *)set);
+    if (mask == 0) {
+	bool _CFSetIsMutable(void *);
+	if (!_CFSetIsMutable((void *)set))
+	    mask |= FL_FREEZE;
+    }
+    if ((mask & FL_FREEZE) == FL_FREEZE)
+	rb_raise(rb_eRuntimeError, "can't modify frozen/immutable set");
+    if ((mask & FL_TAINT) == FL_TAINT && rb_safe_level() >= 4)
+	rb_raise(rb_eSecurityError, "Insecure: can't modify set");
+}
+
+static VALUE
+set_alloc(VALUE klass)
+{
+    CFMutableSetRef set;
+
+    set = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
+    if (klass != 0 && klass != rb_cNSSet && klass != rb_cNSMutableSet)
+	*(Class *)set = (Class)klass;
+
+    CFMakeCollectable(set);
+
+    return (VALUE)set;
+}
+
+VALUE
+rb_set_dup(VALUE rcv)
+{
+    VALUE dup = (VALUE)CFSetCreateMutableCopy(NULL, 0, (CFSetRef)rcv);
+    if (OBJ_TAINTED(rcv))
+	OBJ_TAINT(dup);
+    CFMakeCollectable((CFTypeRef)dup);
+    return dup;
+}
+
+static VALUE
+rb_set_clone(VALUE rcv)
+{
+    VALUE clone = rb_set_dup(rcv);
+    if (OBJ_FROZEN(rcv))
+	OBJ_FREEZE(clone);
+    return clone;
+}
+
+VALUE
+rb_set_new(void)
+{
+    return set_alloc(0);
+}
+
+static VALUE
+rb_set_s_create(int argc, VALUE *argv, VALUE klass)
+{
+    int i;
+
+    VALUE set = set_alloc(klass);
+
+    for (i = 0; i < argc; i++)
+	CFSetAddValue((CFMutableSetRef)set, RB2OC(argv[i]));
+
+    return set;
+}
+
+static VALUE
+rb_set_size(VALUE set)
+{
+    return INT2FIX(CFSetGetCount((CFSetRef)set));
+}
+
+static void
+rb_set_intersect_callback(const void *value, void *context)
+{
+    CFMutableSetRef *sets = (CFMutableSetRef *)context;
+    if (CFSetContainsValue(sets[0], RB2OC(value)))
+	CFSetAddValue(sets[1], RB2OC(value));
+}
+
+static VALUE
+rb_set_intersect(VALUE set, VALUE other)
+{
+    rb_set_modify_check(set);
+
+    VALUE new_set = rb_set_new();
+    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)new_set };
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_intersect_callback, sets);
+
+    return new_set;
+}
+
+static void
+rb_set_union_callback(const void *value, void *context)
+{
+    CFMutableSetRef *sets = context;
+    if (!CFSetContainsValue(sets[0], RB2OC(value)))
+	CFSetAddValue(sets[1], RB2OC(value));
+}
+
+static VALUE
+rb_set_union(VALUE set, VALUE other)
+{
+    VALUE new_set = rb_set_new();
+    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)new_set };
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_union_callback, sets);
+
+    return new_set;
+}
+
+static VALUE
+rb_set_merge(VALUE set, VALUE other)
+{
+    rb_set_modify_check(set);
+
+    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)set };
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_union_callback, sets);
+
+    return set;
+}
+
+static void
+rb_set_subtract_callback(const void *value, void *context)
+{
+    CFMutableSetRef *sets = context;
+    if (CFSetContainsValue(sets[0], RB2OC(value)))
+	CFSetRemoveValue(sets[1], RB2OC(value));
+}
+
+static VALUE
+rb_set_subtract(VALUE set, VALUE other)
+{
+    VALUE new_set = rb_set_dup(set);
+    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)new_set };
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_subtract_callback, sets);
+
+    return new_set;
+}
+
+static VALUE
+rb_set_add(VALUE set, VALUE obj)
+{
+    rb_set_modify_check(set);
+
+    CFSetAddValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
+
+    return set;
+}
+
+static VALUE
+rb_set_add2(VALUE set, VALUE obj)
+{
+    rb_set_modify_check(set);
+
+    if (CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj)))
+	return Qnil;
+    else {
+	CFSetAddValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
+	return set;
+    }
+}
+
+static VALUE
+rb_set_clear(VALUE set)
+{
+    rb_set_modify_check(set);
+
+    CFSetRemoveAllValues((CFMutableSetRef)set);
+    return set;
+}
+
+static VALUE
+rb_set_delete(VALUE set, VALUE obj)
+{
+    rb_set_modify_check(set);
+
+    CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
+    return set;
+}
+
+static VALUE
+rb_set_delete2(VALUE set, VALUE obj)
+{
+    rb_set_modify_check(set);
+
+    if (CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj))) {
+	CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj));
+	return set;
+    } else
+	return Qnil;
+}
+
+static void
+rb_set_delete_if_callback(const void *value, void *context)
+{
+    if (rb_yield(OC2RB(value)) == Qtrue)
+	rb_set_delete((VALUE)context, (VALUE)value);
+}
+
+static VALUE
+rb_set_delete_if(VALUE set)
+{
+    rb_set_modify_check(set);
+
+    VALUE new_set = rb_set_dup(set);
+    CFSetApplyFunction((CFMutableSetRef)new_set, rb_set_delete_if_callback, (void *)set);
+
+    return set;
+}
+
+static void
+rb_set_each_callback(const void *value, void *context)
+{
+    rb_yield((VALUE)OC2RB(value));
+}
+
+static VALUE
+rb_set_each(VALUE set)
+{
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_each_callback, NULL);
+    return Qnil;
+}
+
+static VALUE
+rb_set_include(VALUE set, VALUE obj)
+{
+    return CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj)) ? Qtrue : Qfalse;
+}
+
+static void
+rb_set_to_a_callback(const void *value, void *context)
+{
+    rb_ary_push((VALUE)context, (VALUE)value);
+}
+
+static VALUE
+rb_set_to_a(VALUE set)
+{
+    VALUE ary = rb_ary_new();
+    CFSetApplyFunction((CFMutableSetRef)set, rb_set_to_a_callback, (void *)ary);
+
+    return ary;
+}
+
+static VALUE
+rb_set_equal(VALUE set, VALUE other)
+{
+    return CFEqual((CFTypeRef)set, (CFTypeRef)RB2OC(other)) ? Qtrue : Qfalse;
+}
+
+void
+Init_Set(void)
+{
+    rb_cSet = rb_cNSSet = (VALUE)objc_getClass("NSSet");
+    rb_cNSMutableSet = (VALUE)objc_getClass("NSMutableSet");
+    rb_cCFSet = (VALUE)objc_getClass("NSCFSet");
+    rb_set_class_path(rb_cNSMutableSet, rb_cObject, "NSMutableSet");
+    rb_const_set(rb_cObject, rb_intern("Set"), rb_cNSMutableSet);
+
+    rb_include_module(rb_cSet, rb_mEnumerable);
+
+    rb_define_singleton_method(rb_cSet, "[]", rb_set_s_create, -1);
+
+    rb_define_method(rb_cSet, "dup", rb_set_dup, 0);
+    rb_define_method(rb_cSet, "clone", rb_set_clone, 0);
+
+    rb_define_method(rb_cSet, "to_a", rb_set_to_a, 0);
+    rb_define_method(rb_cSet, "==", rb_set_equal, 1);
+    rb_define_method(rb_cSet, "size", rb_set_size, 0);
+    rb_define_alias(rb_cSet, "length", "size");
+    rb_define_method(rb_cSet, "&", rb_set_intersect, 1);
+    rb_define_alias(rb_cSet, "intersect", "&");
+    rb_define_method(rb_cSet, "|", rb_set_union, 1);
+    rb_define_alias(rb_cSet, "union", "|");
+    rb_define_alias(rb_cSet, "+", "|");
+    rb_define_method(rb_cSet, "merge", rb_set_merge, 1);
+    rb_define_method(rb_cSet, "-", rb_set_subtract, 1);
+    rb_define_method(rb_cSet, "add", rb_set_add, 1);
+    rb_define_alias(rb_cSet, "<<", "add");
+    rb_define_method(rb_cSet, "add?", rb_set_add2, 1);
+    rb_define_method(rb_cSet, "clear", rb_set_clear, 0);
+    rb_define_method(rb_cSet, "delete", rb_set_delete, 1);
+    rb_define_method(rb_cSet, "delete?", rb_set_delete2, 1);
+    rb_define_method(rb_cSet, "delete_if", rb_set_delete_if, 0);
+    rb_define_method(rb_cSet, "each", rb_set_each, 0);
+    rb_define_method(rb_cSet, "include?", rb_set_include, 1);
+    rb_define_alias(rb_cSet, "member?", "include?");
+    rb_define_method(rb_cSet, "to_a", rb_set_to_a, 0);
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081110/710133dd/attachment-0001.html>


More information about the macruby-changes mailing list