Sha256: db613f7902d5ef5fb5bfa6993f3f5cd5104c9fe692ec1b20a9c7a6c8eeb6324e

Contents?: true

Size: 994 Bytes

Versions: 10

Compression:

Stored size: 994 Bytes

Contents

#include "rr.h"

namespace rr {

  VALUE Backref::Storage;
  ID Backref::_new;
  ID Backref::object;

  void Backref::Init() {
    Storage = rb_eval_string("V8::Weak::Ref");
    rb_gc_register_address(&Storage);
    _new = rb_intern("new");
    object = rb_intern("object");
  }

  Backref::Backref(VALUE initial) {
    set(initial);
    rb_gc_register_address(&storage);
  }

  Backref::~Backref() {
    rb_gc_unregister_address(&storage);
  }

  VALUE Backref::set(VALUE data) {
    this->storage = rb_funcall(Storage, _new, 1, data);
    return data;
  }

  VALUE Backref::get() {
    return rb_funcall(storage, object, 0);
  }

  v8::Handle<v8::Value> Backref::toExternal() {
    v8::Local<v8::Value> wrapper = v8::External::New(this);
    v8::Persistent<v8::Value>::New(wrapper).MakeWeak(this, &release);
    return wrapper;
  }

  void Backref::release(v8::Persistent<v8::Value> handle, void* data) {
    handle.Dispose();
    Backref* backref = (Backref*)data;
    delete backref;
  }
}

Version data entries

10 entries across 10 versions & 6 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/therubyracer-0.12.2/ext/v8/backref.cc
therubyracer-0.12.3 ext/v8/backref.cc
therubyracer-xcode-0.12.3 ext/v8/backref.cc
therubyracer-xcode-0.12.2 ext/v8/backref.cc
therubyracer-tmpfork-0.12.2 ext/v8/backref.cc
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/therubyracer-0.12.2/ext/v8/backref.cc
therubyracer-0.12.2 ext/v8/backref.cc
therubyracer-0.12.1 ext/v8/backref.cc
therubyracer-discourse-0.12.0 ext/v8/backref.cc
therubyracer-0.12.0 ext/v8/backref.cc