--
-$Id: ChangeLog 71 2005-07-16 12:28:17Z tilman $
+$Id: ChangeLog 72 2005-07-16 13:15:42Z tilman $
++
2005-07-16 Tilman Sauerbeck (tilman at code-monkey de)
* ext/ext.c, test/test_stream.rb: Don't raise BadElementError if
Stream#serialize is called on a stream that includes non-Chunk
elements
+ * ext/ext.c, test/test_{chunk,stream}.rb: Internal API update.
+ Instead of using Chunk#serialize and Stream#serialize, rename
+ Chunk#serialize to Chunk#to_s and just use Stream#to_s to
+ serialize the streams
2005-07-15 Tilman Sauerbeck (tilman at code-monkey de)
* ext/ext.c: Code cleanup
/*
- * $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)
*
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;
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)
{
}
static VALUE
-chunk_serialize (VALUE self)
+chunk_to_s (VALUE self)
{
VALUE tmp, ret;
unsigned int size, buf_len;
#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
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);
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");