[macruby-changes] [3564] MacRuby/branches/icu

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 16 18:54:37 PST 2010


Revision: 3564
          http://trac.macosforge.org/projects/ruby/changeset/3564
Author:   lsansonetti at apple.com
Date:     2010-02-16 18:54:37 -0800 (Tue, 16 Feb 2010)
Log Message:
-----------
more work, now linking works

Modified Paths:
--------------
    MacRuby/branches/icu/array.c
    MacRuby/branches/icu/error.c
    MacRuby/branches/icu/include/ruby/intern.h
    MacRuby/branches/icu/re.c
    MacRuby/branches/icu/string.c

Modified: MacRuby/branches/icu/array.c
===================================================================
--- MacRuby/branches/icu/array.c	2010-02-17 01:55:10 UTC (rev 3563)
+++ MacRuby/branches/icu/array.c	2010-02-17 02:54:37 UTC (rev 3564)
@@ -1389,12 +1389,14 @@
 	return 0;
     }
 
+#if 0 // TODO
     /* FIXME optimize!!! */
     if (TYPE(a) == T_STRING) {
 	if (TYPE(b) == T_STRING) {
 	    return rb_str_cmp(a, b);
 	}
     }
+#endif
 
     VALUE retval = rb_objs_cmp(a, b);
     return rb_cmpint(retval, a, b);

Modified: MacRuby/branches/icu/error.c
===================================================================
--- MacRuby/branches/icu/error.c	2010-02-17 01:55:10 UTC (rev 3563)
+++ MacRuby/branches/icu/error.c	2010-02-17 02:54:37 UTC (rev 3564)
@@ -848,12 +848,10 @@
     return rb_attr_get(self, rb_intern("args"));
 }
 
-VALUE rb_str_inspect(VALUE, SEL);
-
 void
 rb_invalid_str(const char *str, const char *type)
 {
-    VALUE s = rb_str_inspect(rb_str_new2(str), 0);
+    VALUE s = rb_str_inspect(rb_str_new2(str));
 
     rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
 }

Modified: MacRuby/branches/icu/include/ruby/intern.h
===================================================================
--- MacRuby/branches/icu/include/ruby/intern.h	2010-02-17 01:55:10 UTC (rev 3563)
+++ MacRuby/branches/icu/include/ruby/intern.h	2010-02-17 02:54:37 UTC (rev 3564)
@@ -596,6 +596,7 @@
 void rb_str_setter(VALUE, ID, VALUE*);
 VALUE rb_sym_to_s(VALUE);
 VALUE rb_str_length(VALUE);
+VALUE rb_str_inspect(VALUE);
 #if WITH_OBJC
 bool rb_objc_str_is_pure(VALUE);
 #endif

Modified: MacRuby/branches/icu/re.c
===================================================================
--- MacRuby/branches/icu/re.c	2010-02-17 01:55:10 UTC (rev 3563)
+++ MacRuby/branches/icu/re.c	2010-02-17 02:54:37 UTC (rev 3564)
@@ -2018,8 +2018,6 @@
  *
  */
 
-VALUE rb_str_inspect(VALUE, SEL);
-
 static VALUE
 match_inspect(VALUE match, SEL sel)
 {
@@ -2063,7 +2061,7 @@
             rb_str_buf_cat2(str, "nil");
 	}
         else {
-            rb_str_buf_append(str, rb_str_inspect(v, 0));
+            rb_str_buf_append(str, rb_str_inspect(v));
 	}
     }
     rb_str_buf_cat2(str, ">");
@@ -2932,7 +2930,7 @@
     if (pos < 0) {
 	return Qnil;
     }
-    pos = rb_str_sublen(str, pos);
+    //pos = rb_str_sublen(str, pos);
     return LONG2FIX(pos);
 }
 
@@ -3004,7 +3002,7 @@
     if (start < 0) {
 	return Qnil;
     }
-    start = rb_str_sublen(line, start);
+    //start = rb_str_sublen(line, start);
     return LONG2FIX(start);
 }
 

Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c	2010-02-17 01:55:10 UTC (rev 3563)
+++ MacRuby/branches/icu/string.c	2010-02-17 02:54:37 UTC (rev 3564)
@@ -190,11 +190,14 @@
 }
 
 static rb_str_t *
-str_alloc(void)
+str_alloc(VALUE klass)
 {
+    assert(rb_klass_is_rstr(klass));
+    assert(klass != 0);
+
     NEWOBJ(str, rb_str_t);
     str->basic.flags = 0;
-    str->basic.klass = rb_cRubyString;
+    str->basic.klass = klass;
     str->encoding = rb_encodings[ENCODING_BINARY];
     str->capacity_in_bytes = 0;
     str->length_in_bytes = 0;
@@ -272,7 +275,7 @@
 static rb_str_t *
 str_dup(VALUE source)
 {
-    rb_str_t *destination = str_alloc();
+    rb_str_t *destination = str_alloc(rb_cRubyString);
     str_replace(destination, source);
     return destination;
 }
@@ -286,7 +289,7 @@
 static rb_str_t *
 str_new_from_string(rb_str_t *source)
 {
-    rb_str_t *destination = str_alloc();
+    rb_str_t *destination = str_alloc(rb_cRubyString);
     str_replace_with_string(destination, source);
     return destination;
 }
@@ -294,7 +297,7 @@
 static rb_str_t *
 str_new_from_cfstring(CFStringRef source)
 {
-    rb_str_t *destination = str_alloc();
+    rb_str_t *destination = str_alloc(rb_cRubyString);
     str_replace_with_cfstring(destination, source);
     return destination;
 }
@@ -490,7 +493,7 @@
 static rb_str_t *
 str_new_similar_empty_string(rb_str_t *self)
 {
-    rb_str_t *str = str_alloc();
+    rb_str_t *str = str_alloc(rb_cRubyString);
     str->encoding = self->encoding;
     str->flags = self->flags & STRING_REQUIRED_FLAGS;
     return str;
@@ -500,7 +503,7 @@
 str_new_copy_of_part(rb_str_t *self, long offset_in_bytes,
 	long length_in_bytes)
 {
-    rb_str_t *str = str_alloc();
+    rb_str_t *str = str_alloc(rb_cRubyString);
     str->encoding = self->encoding;
     str->capacity_in_bytes = str->length_in_bytes = length_in_bytes;
     str->flags = self->flags & STRING_REQUIRED_FLAGS;
@@ -741,7 +744,7 @@
 {
     rb_encoding_t *new_encoding = str_must_have_compatible_encoding(str1, str2);
 
-    rb_str_t *new_str = str_alloc();
+    rb_str_t *new_str = str_alloc(rb_cRubyString);
     new_str->encoding = new_encoding;
     if ((str1->length_in_bytes == 0) && (str2->length_in_bytes == 0)) {
 	return new_str;
@@ -1028,7 +1031,7 @@
 static VALUE
 mr_str_s_alloc(VALUE klass)
 {
-    return (VALUE)str_alloc();
+    return (VALUE)str_alloc(klass);
 }
 
 static VALUE
@@ -1418,7 +1421,7 @@
 VALUE
 bstr_new_with_data(const uint8_t *bytes, long len)
 {
-    rb_str_t *str = str_alloc();
+    rb_str_t *str = str_alloc(rb_cRubyString);
     str_replace_with_bytes(str, (char *)bytes, len, ENCODING_BINARY);
     return (VALUE)str;
 }
@@ -1458,7 +1461,7 @@
 rb_enc_str_new(const char *cstr, long len, rb_encoding_t *enc)
 {
     // XXX should we assert that enc is single byte?
-    rb_str_t *str = str_alloc();
+    rb_str_t *str = str_alloc(rb_cRubyString);
     str_replace_with_bytes(str, cstr, len, enc);
     return (VALUE)str;
 }
@@ -1484,7 +1487,7 @@
 VALUE
 rb_str_new3(VALUE source)
 {
-    rb_str_t *str = str_alloc();
+    rb_str_t *str = str_alloc(rb_cRubyString);
     str_replace(str, source);
     return (VALUE)str;
 }
@@ -1760,3 +1763,35 @@
     return code;
 }
 
+VALUE
+rb_str_inspect(VALUE rcv)
+{
+    // TODO
+    return rcv;
+}
+
+VALUE
+rb_str_subseq(VALUE str, long beg, long len)
+{
+    abort(); // TODO
+}
+
+VALUE
+rb_str_substr(VALUE str, long beg, long len)
+{
+    return rb_str_subseq(str, beg, len);
+}
+
+void
+rb_str_update(VALUE str, long beg, long len, VALUE val)
+{
+    abort(); // TODO
+}
+
+// Symbols (TODO: move me outside)
+
+VALUE
+rb_sym_to_s(VALUE sym)
+{
+    return rb_str_new2(RSYMBOL(sym)->str);
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100216/64f045f3/attachment.html>


More information about the macruby-changes mailing list