Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 0c9acc1

Browse files
committed
Merge remote-tracking branch 'origin/upgrade-to-v8-4.5' into 4.5/object-template
Conflicts: ext/v8/function-callback.h
2 parents 4f9137c + 905037e commit 0c9acc1

13 files changed

Lines changed: 173 additions & 86 deletions

File tree

ext/v8/boolean.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// -*- mode: c++ -*-
2+
3+
#ifndef RR_BOOLEAN_H
4+
#define RR_BOOLEAN_H
5+
6+
namespace rr {
7+
class Boolean : public Ref<v8::Boolean> {
8+
public:
9+
Boolean(v8::Isolate* isolate, v8::Local<v8::Boolean> handle) :
10+
Ref<v8::Boolean>(isolate, handle) {}
11+
Boolean(VALUE value) : Ref<v8::Boolean>(value) {}
12+
13+
static void Init() {
14+
ClassBuilder("Boolean", Value::Class).
15+
defineSingletonMethod("New", &New).
16+
defineMethod("Value", &Value).
17+
store(&Class);
18+
}
19+
20+
static VALUE New(VALUE self, VALUE r_isolate, VALUE boolean) {
21+
Isolate isolate(r_isolate);
22+
Locker lock(isolate);
23+
24+
return Boolean(isolate, v8::Boolean::New(isolate, RTEST(boolean)));
25+
}
26+
27+
static VALUE Value(VALUE self) {
28+
Boolean boolean(self);
29+
Locker lock(boolean);
30+
31+
if (boolean->Value()) {
32+
return Qtrue;
33+
} else {
34+
return Qfalse;
35+
}
36+
}
37+
};
38+
}
39+
40+
#endif /* RR_BOOLEAN_H */

ext/v8/function-callback.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace rr {
2727
static VALUE at(VALUE self, VALUE i) {
2828
FunctionCallbackInfo info(self);
2929
Locker lock(info->GetIsolate());
30-
return Value::handleToRubyObject(info->GetIsolate(), info[NUM2INT(i)]);
30+
return Value(info->GetIsolate(), info[NUM2INT(i)]);
3131
}
3232

3333
static VALUE Callee(VALUE self) {
@@ -56,7 +56,8 @@ namespace rr {
5656
v8::Local<v8::Object> holder = v8::Local<v8::Object>::Cast<v8::Value>(info->Data());
5757
v8::Local<v8::String> data_key = v8::String::NewFromUtf8(isolate, "rr::data");
5858
v8::Local<v8::Value> data(holder->GetHiddenValue(data_key));
59-
return Value::handleToRubyObject(isolate, data);
59+
60+
return Value(info->GetIsolate(), data);
6061
}
6162

6263
static VALUE GetIsolate(VALUE self) {

ext/v8/function.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace rr {
5858

5959
std::vector< v8::Handle<v8::Value> > vector(Value::convertRubyArray(isolate, argv));
6060

61-
return Value::handleToRubyObject(isolate, function->Call(Value(receiver), RARRAY_LENINT(argv), &vector[0]));
61+
return Value(isolate, function->Call(Value(receiver), RARRAY_LENINT(argv), &vector[0]));
6262
}
6363

6464
VALUE Function::SetName(VALUE self, VALUE name) {
@@ -74,14 +74,14 @@ namespace rr {
7474
Function function(self);
7575
Locker lock(function.getIsolate());
7676

77-
return Value::handleToRubyObject(function.getIsolate(), function->GetName());
77+
return Value(function.getIsolate(), function->GetName());
7878
}
7979

8080
VALUE Function::GetInferredName(VALUE self) {
8181
Function function(self);
8282
Locker lock(function.getIsolate());
8383

84-
return Value::handleToRubyObject(function.getIsolate(), function->GetInferredName());
84+
return Value(function.getIsolate(), function->GetInferredName());
8585
}
8686

8787
VALUE Function::GetScriptLineNumber(VALUE self) {

ext/v8/init.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ extern "C" {
1818
Value::Init();
1919
Object::Init();
2020
Primitive::Init();
21+
Null::Init();
22+
Undefined::Init();
23+
Boolean::Init();
2124
Number::Init();
2225
Integer::Init();
2326
Name::Init();

ext/v8/name.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace rr {
99
static VALUE GetIdentityHash(VALUE self);
1010

1111
Name(VALUE self) : Ref<v8::Name>(self) {}
12+
Name(v8::Isolate* isolate, v8::Local<v8::Name> name) :
13+
Ref<v8::Name>(isolate, name) {}
1214
};
1315
}
1416

ext/v8/null.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// -*- mode: c++ -*-
2+
#ifndef RR_NULL_H
3+
#define RR_NULL_H
4+
5+
namespace rr {
6+
class Null : public Ref<v8::Value> {
7+
public:
8+
Null(v8::Isolate* isolate, v8::Local<v8::Value> undefined) :
9+
Ref<v8::Value>(isolate, undefined) {}
10+
11+
static inline void Init() {
12+
ClassBuilder("Null", Primitive::Class).
13+
store(&Class);
14+
}
15+
};
16+
}
17+
18+
#endif /* RR_NULL_H */

ext/v8/rr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ inline VALUE not_implemented(const char* message) {
3333
#include "context.h"
3434

3535
#include "value.h"
36+
#include "boolean.h"
3637
#include "object.h"
3738
#include "array.h"
3839
#include "primitive.h"
40+
#include "undefined.h"
41+
#include "null.h"
3942
#include "number.h"
4043
#include "integer.h"
4144

ext/v8/script.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ namespace rr {
3737
Context context(rb_context);
3838
Locker lock(context->GetIsolate());
3939

40-
return Value::handleToRubyObject(context->GetIsolate(), Script(self)->Run());
40+
return Value(context->GetIsolate(), Script(self)->Run());
4141
}
4242
}

ext/v8/symbol.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ namespace rr {
6969
Isolate isolate(symbol.getIsolate());
7070
Locker lock(isolate);
7171

72-
return Value::handleToRubyObject(isolate, symbol->Name());
72+
return Value(isolate, symbol->Name());
7373
}
7474
}

ext/v8/undefined.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// -*- mode: c++ -*-
2+
#ifndef RR_UNDEFINED_H
3+
#define RR_UNDEFINED_H
4+
5+
namespace rr {
6+
class Undefined : public Ref<v8::Value> {
7+
public:
8+
Undefined(v8::Isolate* isolate, v8::Local<v8::Value> undefined) :
9+
Ref<v8::Value>(isolate, undefined) {}
10+
11+
static inline void Init() {
12+
ClassBuilder("Undefined", Primitive::Class).
13+
store(&Class);
14+
}
15+
};
16+
}
17+
18+
#endif /* RR_UNDEFINED_H */

0 commit comments

Comments
 (0)