--
-$Id: ChangeLog 61 2005-06-09 17:33:48Z tilman $
+$Id: ChangeLog 62 2005-06-09 17:42:34Z tilman $
++
2005-06-09 Tilman Sauerbeck (tilman at code-monkey de)
* ext/ext.c: Object#to_eet: Don't put the final chunk in a stream
again, it's not needed
+ * ext/ext.c, test/test_stream.rb: If Stream#serialize is called on
+ a stream that includes non-Chunk elements, BadElementError is
+ raised
2005-06-08 Tilman Sauerbeck (tilman at code-monkey de)
* ext/ext.c, lib/eet.rb, test/test_basic.rb:
/*
- * $Id: ext.c 61 2005-06-09 17:33:48Z tilman $
+ * $Id: ext.c 62 2005-06-09 17:42:34Z tilman $
*
* Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
*
static VALUE c_close (VALUE self);
static VALUE cStream, cChunk,
- eEetError, eNameError, ePropError,
+ eEetError, eNameError, ePropError, eStreamError,
+ eBadElementError,
sym_lossy, sym_level, sym_quality, sym_char, sym_short,
sym_long_long, sym_double;
static ID id_include, id_serialize, id_push, id_keys,
return ret;
for (i = 0; i < stream->len; i++) {
- VALUE str = rb_funcall (stream->ptr[i], id_serialize, 0, NULL);
+ VALUE str;
+
+ if (rb_obj_is_kind_of (stream->ptr[i], cChunk) == Qfalse)
+ rb_raise (eBadElementError, "stream member is not a Chunk");
+
+ str = rb_funcall (stream->ptr[i], id_serialize, 0, NULL);
rb_str_append (ret, str);
}
eEetError = rb_define_class_under (m, "EetError", rb_eStandardError);
eNameError = rb_define_class_under (m, "NameError", eEetError);
ePropError = rb_define_class_under (m, "PropertyError", eEetError);
+ eStreamError = rb_define_class_under (m, "StreamError", eEetError);
+ eBadElementError = rb_define_class_under (m, "BadElementError",
+ eStreamError);
id_include = rb_intern ("include?");
id_serialize = rb_intern ("serialize");