Permalink
Browse files

more work, now linking works

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/icu@3564 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent cb8cef0 commit dc4596a7593350a36be6669d2a747ef2d5797d26 @lrz lrz committed Feb 17, 2010
Showing with 54 additions and 20 deletions.
  1. +2 −0 array.c
  2. +1 −3 error.c
  3. +1 −0 include/ruby/intern.h
  4. +3 −5 re.c
  5. +47 −12 string.c
View
@@ -1389,12 +1389,14 @@ sort_2(void *dummy, const void *ap, const void *bp)
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);
View
@@ -848,12 +848,10 @@ nometh_err_args(VALUE self, SEL sel)
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));
}
View
@@ -596,6 +596,7 @@ VALUE rb_str_associated(VALUE);
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
View
8 re.c
@@ -2018,8 +2018,6 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
*
*/
-VALUE rb_str_inspect(VALUE, SEL);
-
static VALUE
match_inspect(VALUE match, SEL sel)
{
@@ -2063,7 +2061,7 @@ match_inspect(VALUE match, SEL sel)
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 @@ rb_reg_match_imp(VALUE re, SEL sel, VALUE str)
if (pos < 0) {
return Qnil;
}
- pos = rb_str_sublen(str, pos);
+ //pos = rb_str_sublen(str, pos);
return LONG2FIX(pos);
}
@@ -3004,7 +3002,7 @@ rb_reg_match2(VALUE re, SEL sel)
if (start < 0) {
return Qnil;
}
- start = rb_str_sublen(line, start);
+ //start = rb_str_sublen(line, start);
return LONG2FIX(start);
}
View
@@ -190,11 +190,14 @@ str_must_have_compatible_encoding(rb_str_t *str1, rb_str_t *str2)
}
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 @@ str_replace(rb_str_t *self, VALUE arg)
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,15 +289,15 @@ str_clear(rb_str_t *self)
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;
}
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 @@ str_force_encoding(rb_str_t *self, rb_encoding_t *enc)
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 @@ static rb_str_t *
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 @@ str_plus_string(rb_str_t *str1, rb_str_t *str2)
{
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 @@ mr_enc_s_is_compatible(VALUE klass, SEL sel, VALUE str1, VALUE str2)
static VALUE
mr_str_s_alloc(VALUE klass)
{
- return (VALUE)str_alloc();
+ return (VALUE)str_alloc(klass);
}
static VALUE
@@ -1418,7 +1421,7 @@ bstr_bytes(VALUE str)
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 @@ VALUE
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 @@ rb_str_new2(const char *cstr)
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 @@ rb_memhash(const void *ptr, long len)
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);
+}

0 comments on commit dc4596a

Please sign in to comment.