Sha256: 38abce7f691b5e00abb3b907a28ae418e733bbc8e4ad8ed087ea6bd8beca0b7b

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

<% children.each do |c|%>
<%= c.result %>

<% end %>
/*
  Store elements to Numo::<%=class_name%> from other.
  @overload store(other)
  @param [Object] other
  @return [Numo::<%=class_name%>] self
*/
static VALUE
<%=c_func(1)%>(VALUE self, VALUE obj)
{
    VALUE r, klass;

    klass = rb_obj_class(obj);

    <% definitions.each do |x| %>
    if (<%=x.condition("klass")%>) {
        <%=x.c_func%>(self,obj);
        return self;
    }
    <% end %>

    if (IsNArray(obj)) {
        r = rb_funcall(obj, rb_intern("coerce_cast"), 1, cT);
        if (rb_obj_class(r)==cT) {
            <%=c_func%>(self,r);
            return self;
        }
    }

    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");
        }
        <%=store_array.c_func%>(self,obj);
        return self;
    }

    <% if is_object %>
    robject_store_numeric(self,obj);
    <% else %>
    rb_raise(nary_eCastError, "unknown conversion from %s to %s",
             rb_class2name(rb_obj_class(obj)),
             rb_class2name(rb_obj_class(self)));
    <% end %>
    return self;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
numo-narray-0.9.1.8 ext/numo/narray/gen/tmpl/store.c
numo-narray-0.9.1.7 ext/numo/narray/gen/tmpl/store.c