Sha256: 543e6e49dc65671c8aa8de56ed85296aa310c79bb13730e934fecabb2b0a79e5

Contents?: true

Size: 1.17 KB

Versions: 77

Compression:

Stored size: 1.17 KB

Contents

#include "v8_handle.h"
#include "v8_array.h"
#include "v8_object.h"

using namespace v8;


namespace {
  
  VALUE ArrayClass;
  
  Persistent<Array>& unwrap(VALUE self) {
    return rr_v8_handle<Array>(self);
  }
  
  VALUE New(int argc, VALUE *argv, VALUE self) {
    if (!Context::InContext()) {
      rb_raise(rb_eScriptError, "must be in a context to call Array::New()");
      return Qnil;
    }
    VALUE length;
    rb_scan_args(argc, argv, "01", &length);
    if (NIL_P(length)) {
      length = INT2FIX(0);
    }
    HandleScope scope;
    return rr_v8_handle_new(self, Array::New(NUM2INT(length)));
  }
  
  VALUE Length(VALUE self) {
    return rr_v82rb(unwrap(self)->Length());
  }
  
  VALUE CloneElementAt(VALUE self, VALUE index) {
    return rr_v82rb(unwrap(self)->CloneElementAt(NUM2UINT(index)));
  }
}

void rr_init_v8_array() {
  ArrayClass = rr_define_class("Array", rr_v8_object_class());
  rr_define_singleton_method(ArrayClass, "New", New, -1);
  rr_define_method(ArrayClass, "Length", Length, 0);
  rr_define_method(ArrayClass, "CloneElementAt", CloneElementAt, 1);
}

VALUE rr_reflect_v8_array(Handle<Value> value) {
  return rr_reflect_v8_object_as(value, ArrayClass);
}

Version data entries

77 entries across 77 versions & 5 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.7.4 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.7.3 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.7.2 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.7.1 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.7.0 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.9 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.8 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.7 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.6 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.5 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.4 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.3 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.2 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.1 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.6.0 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.5.17 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.5.16 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.5.15 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp
classiccms-0.5.14 vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp