1
0
Fork 0
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:
Charles Lowell 2012-05-03 23:22:36 -05:00
parent 6902e37787
commit 30af30edee
3 changed files with 18 additions and 13 deletions

View file

@ -2,10 +2,10 @@
namespace rr { namespace rr {
Convert::Convert(v8::Handle<v8::Value> value) { VALUE Convert(bool b) {
this->value = value; return b ? Qtrue : Qfalse;
} }
Convert::operator VALUE() { VALUE Convert(v8::Handle<v8::Value> value) {
if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) { if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) {
return Qnil; return Qnil;
} }

View file

@ -6,14 +6,8 @@
namespace rr { namespace rr {
class Convert { VALUE Convert(bool);
public: VALUE Convert(v8::Handle<v8::Value> handle);
Convert(v8::Handle<v8::Value> handle);
virtual operator VALUE();
private:
v8::Handle<v8::Value> value;
};
class GC { class GC {
public: public:
@ -119,7 +113,8 @@ private:
class Value : public Ref<v8::Value> { class Value : public Ref<v8::Value> {
public: public:
static void Init(); 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) {} inline Value(VALUE value) : Ref<v8::Value>(value) {}
}; };

View file

@ -3,6 +3,16 @@
namespace rr { namespace rr {
void Value::Init() { 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)));
} }
} }