Internal API update.
[ruby-eet.git] / ext / ext.c
index bf1c4f03572c08089f1df51d823fcaf4efbabedd..4fb3f1e45895a2873f0ed3ee115fa320a6448eef 100644 (file)
--- a/ext/ext.c
+++ b/ext/ext.c
@@ -1,5 +1,5 @@
 /*
- * $Id: ext.c 71 2005-07-16 12:28:17Z tilman $
+ * $Id: ext.c 72 2005-07-16 13:15:42Z tilman $
  *
  * Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -50,7 +50,7 @@ static VALUE cStream, cChunk,
              eEetError, eNameError, ePropError,
              sym_lossy, sym_level, sym_quality, sym_char, sym_short,
              sym_long_long, sym_double;
-static ID id_include, id_serialize, id_keys, id_pack,
+static ID id_include, id_to_s, id_keys, id_pack,
           id_to_eet_chunks, id_to_eet_name, id_to_eet_properties,
           id_tag, id_data;
 
@@ -436,30 +436,6 @@ c_write_image (int argc, VALUE *argv, VALUE self)
                return INT2FIX (n);
 }
 
-static VALUE
-stream_serialize (VALUE self)
-{
-       VALUE ret;
-       struct RArray *stream;
-       long i;
-
-       stream = RARRAY (self);
-       if (!stream->len)
-               return rb_str_new2 ("");
-
-       ret = rb_ary_new ();
-
-       for (i = 0; i < stream->len; i++) {
-               VALUE str;
-
-               str = rb_funcall (stream->ptr[i], id_serialize, 0, NULL);
-
-               rb_ary_push (ret, str);
-       }
-
-       return rb_ary_join (ret, Qnil);
-}
-
 static VALUE
 chunk_init (VALUE self, VALUE tag, VALUE data)
 {
@@ -488,7 +464,7 @@ chunk_init (VALUE self, VALUE tag, VALUE data)
 }
 
 static VALUE
-chunk_serialize (VALUE self)
+chunk_to_s (VALUE self)
 {
        VALUE tmp, ret;
        unsigned int size, buf_len;
@@ -587,13 +563,13 @@ c_to_eet (VALUE self)
 #endif
 
        args[0] = name;
-       args[1] = rb_funcall (stream, id_serialize, 0);
+       args[1] = rb_ary_to_s (stream);
 
        rb_ary_clear (stream); /* give the GC a hand... */
 
        chunk = rb_class_new_instance (2, args, cChunk);
 
-       return rb_funcall (chunk, id_serialize, 0);
+       return rb_funcall (chunk, id_to_s, 0);
 }
 
 static VALUE
@@ -670,11 +646,10 @@ Init_eet_ext ()
        rb_define_method (c, "write_image", c_write_image, -1);
 
        cStream = rb_define_class_under (m, "Stream", rb_cArray);
-       rb_define_method (cStream, "serialize", stream_serialize, 0);
 
        cChunk = rb_define_class_under (m, "Chunk", rb_cObject);
        rb_define_method (cChunk, "initialize", chunk_init, 2);
-       rb_define_method (cChunk, "serialize", chunk_serialize, 0);
+       rb_define_method (cChunk, "to_s", chunk_to_s, 0);
 
        rb_define_attr (cChunk, "tag", 1, 0);
        rb_define_attr (cChunk, "data", 1, 0);
@@ -689,7 +664,7 @@ Init_eet_ext ()
        ePropError = rb_define_class_under (m, "PropertyError", eEetError);
 
        id_include = rb_intern ("include?");
-       id_serialize = rb_intern ("serialize");
+       id_to_s = rb_intern ("to_s");
        id_keys = rb_intern ("keys");
        id_pack = rb_intern ("pack");
        id_to_eet_chunks = rb_intern ("to_eet_chunks");