mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
Value::Equals(), Value::StrictEquals()
This commit is contained in:
parent
6902e37787
commit
30af30edee
3 changed files with 18 additions and 13 deletions
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace rr {
|
||||
|
||||
Convert::Convert(v8::Handle<v8::Value> value) {
|
||||
this->value = value;
|
||||
VALUE Convert(bool b) {
|
||||
return b ? Qtrue : Qfalse;
|
||||
}
|
||||
Convert::operator VALUE() {
|
||||
VALUE Convert(v8::Handle<v8::Value> value) {
|
||||
if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) {
|
||||
return Qnil;
|
||||
}
|
||||
|
|
13
ext/v8/rr.h
13
ext/v8/rr.h
|
@ -6,14 +6,8 @@
|
|||
|
||||
namespace rr {
|
||||
|
||||
class Convert {
|
||||
public:
|
||||
Convert(v8::Handle<v8::Value> handle);
|
||||
virtual operator VALUE();
|
||||
|
||||
private:
|
||||
v8::Handle<v8::Value> value;
|
||||
};
|
||||
VALUE Convert(bool);
|
||||
VALUE Convert(v8::Handle<v8::Value> handle);
|
||||
|
||||
class GC {
|
||||
public:
|
||||
|
@ -119,7 +113,8 @@ private:
|
|||
class Value : public Ref<v8::Value> {
|
||||
public:
|
||||
static void Init();
|
||||
|
||||
static VALUE Equals(VALUE self, VALUE other);
|
||||
static VALUE StrictEquals(VALUE self, VALUE other);
|
||||
inline Value(VALUE value) : Ref<v8::Value>(value) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
namespace rr {
|
||||
|
||||
void Value::Init() {
|
||||
ClassBuilder("Value");
|
||||
ClassBuilder("Value").
|
||||
defineMethod("Equals", &Equals).
|
||||
defineMethod("StrictEquals", &StrictEquals);
|
||||
}
|
||||
|
||||
VALUE Value::Equals(VALUE self, VALUE other) {
|
||||
return Convert(Value(self)->Equals(Value(other)));
|
||||
}
|
||||
|
||||
VALUE Value::StrictEquals(VALUE self, VALUE other) {
|
||||
return Convert(Value(self)->StrictEquals(Value(other)));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue