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

expose objects in the lamest way possible.

This commit is contained in:
Charles Lowell 2012-05-08 16:17:25 -05:00
parent b9b15e8838
commit 26e895bb8d
4 changed files with 16 additions and 8 deletions

View file

@ -28,7 +28,7 @@ VALUE Convert(v8::Handle<v8::Value> value) {
return rb_float_new(value->NumberValue());
}
if (value->IsString()) {
return String::Convert(value->ToString());
return String::convert(value->ToString());
}
if (value->IsFunction()) {
// return Function(value);
@ -40,7 +40,7 @@ VALUE Convert(v8::Handle<v8::Value> value) {
// return rr_reflect_v8_date(value);
}
if (value->IsObject()) {
// return Object(value);
return Object::convert(value->ToObject());
}
return Qnil;
}

View file

@ -2,6 +2,8 @@
namespace rr {
VALUE Object::Class;
void Object::Init() {
ClassBuilder("Object", "Value").
defineSingletonMethod("New", &New).
@ -12,7 +14,8 @@ void Object::Init() {
defineMethod("Has", &Has).
defineMethod("Delete", &Delete).
defineMethod("ForceDelete", &ForceDelete).
defineMethod("SetAccessor", &SetAccessor);
defineMethod("SetAccessor", &SetAccessor).
store(&Class);
ClassBuilder("PropertyAttribute").
defineEnumConst("None", v8::None).
defineEnumConst("ReadOnly", v8::ReadOnly).
@ -25,6 +28,10 @@ void Object::Init() {
defineEnumConst("PROHIBITS_OVERWRITING", v8::PROHIBITS_OVERWRITING);
}
VALUE Object::convert(v8::Handle<v8::Object> object) {
return Object::create(object, Class);
}
VALUE Object::New(VALUE self) {
return Object::create(v8::Object::New(), self);
}

View file

@ -179,8 +179,7 @@ public:
static VALUE New(VALUE self, VALUE value);
static VALUE Utf8Value(VALUE self);
static VALUE Convert(v8::Handle<v8::String> value);
static VALUE convert(v8::Handle<v8::String> value);
inline String(VALUE value) : Ref<v8::String>(value) {}
private:
static VALUE Class;
@ -202,6 +201,8 @@ public:
static VALUE ForceDelete(VALUE self, VALUE key);
static VALUE SetAccessor(int argc, VALUE* argv, VALUE self);
static VALUE Class;
static VALUE convert(v8::Handle<v8::Object> value);
inline Object(VALUE value) : Ref<v8::Object>(value) {}
};

View file

@ -12,7 +12,7 @@ void String::Init() {
}
VALUE String::New(VALUE StringClass, VALUE string) {
return String::Convert(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string)));
return String::convert(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string)));
}
VALUE String::Utf8Value(VALUE self) {
@ -20,8 +20,8 @@ VALUE String::Utf8Value(VALUE self) {
return rb_str_new(*v8::String::Utf8Value(str.GetHandle()), str->Utf8Length());
}
VALUE String::Convert(v8::Handle<v8::String> string) {
return String::create(string, String::Class);
VALUE String::convert(v8::Handle<v8::String> string) {
return String::create(string, Class);
}
} //namespace rr