ext/numo/narray/gen/tmpl/cast.c in numo-narray-0.9.1.6 vs ext/numo/narray/gen/tmpl/cast.c in numo-narray-0.9.1.7
- old
+ new
@@ -33,9 +33,16 @@
if (NA_SIZE(na) > 0) {
<%=find_tmpl("store").c_func%>(v,obj);
}
return v;
}
+ if (rb_respond_to(obj,id_to_a)) {
+ obj = rb_funcall(obj,id_to_a,0);
+ if (TYPE(obj)!=T_ARRAY) {
+ rb_raise(rb_eTypeError, "`to_a' did not return Array");
+ }
+ return <%=find_tmpl("cast_array").c_func%>(obj);
+ }
<% if is_object %>
return robject_new_dim0(obj);
<% else %>
rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
return Qnil;