1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/v8_value.cpp

137 lines
4.3 KiB
C++
Raw Normal View History

2010-05-11 13:41:07 -04:00
#include "v8_value.h"
#include "v8_ref.h"
2010-05-12 18:30:53 -04:00
#include "converters.h"
2010-05-11 13:41:07 -04:00
using namespace v8;
2010-05-12 18:30:53 -04:00
namespace {
Local<Value> unwrap(VALUE value) {
return V8_Ref_Get<Value>(value);
}
VALUE IsUndefined(VALUE self) {
return rr_v82rb(unwrap(self)->IsUndefined());
}
VALUE IsNull(VALUE self) {
return rr_v82rb(unwrap(self)->IsNull());
}
VALUE IsTrue(VALUE self) {
return rr_v82rb(unwrap(self)->IsTrue());
}
VALUE IsFalse(VALUE self) {
return rr_v82rb(unwrap(self)->IsFalse());
}
VALUE IsString(VALUE self) {
return rr_v82rb(unwrap(self)->IsString());
}
VALUE IsFunction(VALUE self) {
return rr_v82rb(unwrap(self)->IsFunction());
}
VALUE IsArray(VALUE self) {
return rr_v82rb(unwrap(self)->IsArray());
}
VALUE IsObject(VALUE self) {
return rr_v82rb(unwrap(self)->IsObject());
}
VALUE IsBoolean(VALUE self) {
return rr_v82rb(unwrap(self)->IsBoolean());
}
VALUE IsNumber(VALUE self) {
return rr_v82rb(unwrap(self)->IsNumber());
}
VALUE IsExternal(VALUE self) {
return rr_v82rb(unwrap(self)->IsExternal());
}
VALUE IsInt32(VALUE self) {
return rr_v82rb(unwrap(self)->IsInt32());
}
VALUE IsUint32(VALUE self) {
return rr_v82rb(unwrap(self)->IsUint32());
}
VALUE IsDate(VALUE self) {
return rr_v82rb(unwrap(self)->IsDate());
}
2010-05-11 13:41:07 -04:00
2010-05-12 18:30:53 -04:00
VALUE ToBoolean(VALUE self) {
return rr_v82rb(unwrap(self)->ToBoolean());
}
VALUE ToNumber(VALUE self) {
return rr_v82rb(unwrap(self)->ToNumber());
}
VALUE ToString(VALUE self) {
return rr_v82rb(unwrap(self)->ToString());
}
VALUE ToDetailString(VALUE self) {
return rr_v82rb(unwrap(self)->ToDetailString());
}
VALUE ToObject(VALUE self) {
return rr_v82rb(unwrap(self)->ToObject());
}
VALUE ToInteger(VALUE self) {
return rr_v82rb(unwrap(self)->ToInteger());
}
VALUE ToUint32(VALUE self) {
return rr_v82rb(unwrap(self)->ToUint32());
}
VALUE ToInt32(VALUE self) {
return rr_v82rb(unwrap(self)->ToInt32());
}
VALUE ToArrayIndex(VALUE self) {
return rr_v82rb(unwrap(self)->ToArrayIndex());
}
2010-05-11 13:41:07 -04:00
2010-05-12 18:30:53 -04:00
VALUE Equals(VALUE self, VALUE that) {
return rr_v82rb(unwrap(self)->Equals(unwrap(that)));
}
VALUE StrictEquals(VALUE self, VALUE that) {
return rr_v82rb(unwrap(self)->StrictEquals(unwrap(that)));
}
2010-05-11 13:41:07 -04:00
2010-05-12 18:30:53 -04:00
VALUE BooleanValue(VALUE self) {
return rr_v82rb(unwrap(self)->BooleanValue());
}
2010-05-11 13:41:07 -04:00
2010-05-12 18:30:53 -04:00
VALUE NumberValue(VALUE self) {
return rr_v82rb(unwrap(self)->NumberValue());
}
2010-05-11 13:41:07 -04:00
}
VALUE rr_cV8_C_Value;
VALUE rr_cV8_C_Empty;
2010-05-11 13:41:07 -04:00
2010-05-12 18:30:53 -04:00
void rr_init_value() {
2010-05-11 13:41:07 -04:00
rr_cV8_C_Value = rr_define_class("Value");
rr_cV8_C_Empty = rr_define_const("Empty", rr_v8_ref_create(rr_cV8_C_Value, Handle<Value>()));
2010-05-11 13:41:07 -04:00
rr_define_method(rr_cV8_C_Value, "IsUndefined", IsUndefined, 0);
rr_define_method(rr_cV8_C_Value, "IsNull", IsNull, 0);
rr_define_method(rr_cV8_C_Value, "IsTrue", IsTrue, 0);
rr_define_method(rr_cV8_C_Value, "IsFalse", IsFalse, 0);
rr_define_method(rr_cV8_C_Value, "IsString", IsString, 0);
rr_define_method(rr_cV8_C_Value, "IsFunction", IsFunction, 0);
rr_define_method(rr_cV8_C_Value, "IsArray", IsArray, 0);
rr_define_method(rr_cV8_C_Value, "IsObject", IsObject, 0);
rr_define_method(rr_cV8_C_Value, "IsBoolean", IsBoolean, 0);
rr_define_method(rr_cV8_C_Value, "IsNumber", IsNumber, 0);
rr_define_method(rr_cV8_C_Value, "IsExternal", IsExternal, 0);
rr_define_method(rr_cV8_C_Value, "IsInt32", IsInt32, 0);
rr_define_method(rr_cV8_C_Value, "IsUint32", IsUint32, 0);
rr_define_method(rr_cV8_C_Value, "IsDate", IsDate, 0);
rr_define_method(rr_cV8_C_Value, "ToBoolean", ToBoolean, 0);
rr_define_method(rr_cV8_C_Value, "ToNumber", ToNumber, 0);
rr_define_method(rr_cV8_C_Value, "ToString", ToString, 0);
rr_define_method(rr_cV8_C_Value, "ToDetailString", ToDetailString, 0);
rr_define_method(rr_cV8_C_Value, "ToObject", ToObject, 0);
rr_define_method(rr_cV8_C_Value, "ToInteger", ToInteger, 0);
rr_define_method(rr_cV8_C_Value, "ToUint32", ToUint32, 0);
rr_define_method(rr_cV8_C_Value, "ToArrayIndex", ToArrayIndex, 0);
2010-05-11 13:41:07 -04:00
rr_define_method(rr_cV8_C_Value, "Equals", Equals, 1);
rr_define_method(rr_cV8_C_Value, "StrictEquals", StrictEquals, 1);
2010-05-12 18:30:53 -04:00
rr_define_method(rr_cV8_C_Value, "BooleanValue", BooleanValue, 0);
rr_define_method(rr_cV8_C_Value, "NumberValue", NumberValue, 0);
2010-05-11 13:41:07 -04:00
}
VALUE rr_wrap_v8_value(Handle<Value>& value) {
return V8_Ref_Create(rr_cV8_C_Value, value);
}