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

thunk down values and objects

This commit is contained in:
Charles Lowell 2012-05-15 16:37:22 -05:00
parent e21bedf3a9
commit e4184c97f9
3 changed files with 31 additions and 1 deletions

View file

@ -279,5 +279,28 @@ VALUE Object::SetAccessor(int argc, VALUE* argv, VALUE self) {
// V8EXPORT Local<Value> CallAsConstructor(int argc,
// Handle<Value> argv[]);
Object::operator VALUE() {
if (handle->IsFunction()) {
// return Function(handle);
}
if (handle->IsArray()) {
// return Array(handle);
}
if (handle->IsDate()) {
// return Date(handle);
}
if (handle->IsBooleanObject()) {
// return BooleanObject(handle);
}
if (handle->IsNumberObject()) {
// return NumberObject(handle);
}
if (handle->IsStringObject()) {
// return StringObject(handle);
}
if (handle->IsRegExp()) {
// return RegExp(handle);
}
return Ref<v8::Object>::operator VALUE();
}
}

View file

@ -256,6 +256,7 @@ public:
inline Object(VALUE value) : Ref<v8::Object>(value) {}
inline Object(v8::Handle<v8::Object> object) : Ref<v8::Object>(object) {}
virtual operator VALUE();
};
class V8 {

View file

@ -21,6 +21,12 @@ Value::operator VALUE() {
if (handle.IsEmpty() || handle->IsUndefined() || handle->IsNull()) {
return Qnil;
}
if (handle->IsTrue()) {
return Qtrue;
}
if (handle->IsFalse()) {
return Qfalse;
}
if (handle->IsExternal()) {
return External((v8::Handle<v8::External>)v8::External::Cast(*handle));
}