Class: QML::JSArray
- Inherits:
-
JSObject
- Object
- JSObject
- QML::JSArray
- Defined in:
- lib/qml/js_array.rb,
ext/qml/js_array.c
Instance Method Summary collapse
Instance Method Details
#each ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'ext/qml/js_array.c', line 21
static VALUE js_array_each(VALUE self)
{
RETURN_SIZED_ENUMERATOR(self, 0, 0, &js_array_length);
qmlbind_value array = rbqml_js_object_get(self);
qmlbind_value lenValue = qmlbind_value_get_property(array, "length");
int len = qmlbind_value_get_number(lenValue);
qmlbind_value_release(lenValue);
for (int i = 0; i < len; ++i) {
qmlbind_value elem = qmlbind_value_get_array_item(array, i);
VALUE rubyElem = rb_ensure(&rbqml_to_ruby, (VALUE)elem, (VALUE (*)())&qmlbind_value_release, (VALUE)elem);
rb_yield(rubyElem);
}
return self;
}
|
#length ⇒ Integer
10 11 12 13 14 15 16 17 18 19 |
# File 'ext/qml/js_array.c', line 10
static VALUE js_array_length(VALUE self)
{
qmlbind_value array = rbqml_js_object_get(self);
qmlbind_value lenValue = qmlbind_value_get_property(array, "length");
int len = qmlbind_value_get_number(lenValue);
qmlbind_value_release(lenValue);
return INT2NUM(len);
}
|