2012-05-17 11:30:37 -04:00
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
namespace rr {
|
|
|
|
|
|
|
|
void Array::Init() {
|
|
|
|
ClassBuilder("Array", Object::Class).
|
2012-05-17 12:04:05 -04:00
|
|
|
defineSingletonMethod("New", &New).
|
|
|
|
defineMethod("Length", &Length).
|
|
|
|
defineMethod("CloneElementAt", &CloneElementAt).
|
2012-05-17 11:30:37 -04:00
|
|
|
store(&Class);
|
|
|
|
}
|
|
|
|
|
2012-05-17 12:04:05 -04:00
|
|
|
VALUE Array::New(int argc, VALUE argv[], VALUE self) {
|
|
|
|
VALUE length; rb_scan_args(argc, argv, "01", &length);
|
2012-05-23 00:06:21 -04:00
|
|
|
return Array(v8::Array::New(RTEST(length) ? NUM2INT(length) : 0));
|
2012-05-17 12:04:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Array::Length(VALUE self) {
|
2012-05-22 13:17:31 -04:00
|
|
|
return UInt32(Array(self)->Length());
|
2012-05-17 12:04:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Array::CloneElementAt(VALUE self, VALUE index) {
|
|
|
|
return Object(Array(self)->CloneElementAt(UInt32(index)));
|
|
|
|
}
|
|
|
|
|
2012-05-17 11:30:37 -04:00
|
|
|
}
|