mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
remove global thunking function Convert().
This commit is contained in:
parent
e4184c97f9
commit
c22dc64910
8 changed files with 26 additions and 71 deletions
|
@ -41,11 +41,11 @@ namespace rr {
|
|||
}
|
||||
|
||||
v8::Handle<v8::Value> Accessor::get(v8::Local<v8::String> property) {
|
||||
return Value(rb_funcall(info->getter, rb_intern("call"), 2, Convert(property), this->value));
|
||||
return Value(rb_funcall(info->getter, rb_intern("call"), 2, (VALUE)String(property), this->value));
|
||||
}
|
||||
|
||||
v8::Handle<v8::Value> Accessor::set(v8::Local<v8::String> property, v8::Local<v8::Value> value) {
|
||||
return Value(rb_funcall(info->setter, rb_intern("call"), 3, Convert(property), Convert(value), this->value));
|
||||
return Value(rb_funcall(info->setter, rb_intern("call"), 3, (VALUE)String(property), (VALUE)Value(value), this->value));
|
||||
}
|
||||
void Accessor::mark(Accessor* acc) {
|
||||
rb_gc_mark(acc->thisObject);
|
||||
|
|
|
@ -26,7 +26,7 @@ void Context::Init() {
|
|||
}
|
||||
|
||||
VALUE Context::Global(VALUE self) {
|
||||
return Convert(Context(self)->Global());
|
||||
return Object(Context(self)->Global());
|
||||
}
|
||||
|
||||
VALUE Context::DetachGlobal(VALUE self) {
|
||||
|
@ -62,15 +62,15 @@ VALUE Context::UseDefaultSecurityToken(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE Context::GetSecurityToken(VALUE self) {
|
||||
return Convert(Context(self)->GetSecurityToken());
|
||||
return Value(Context(self)->GetSecurityToken());
|
||||
}
|
||||
|
||||
VALUE Context::HasOutOfMemoryException(VALUE self) {
|
||||
return Convert(Context(self)->HasOutOfMemoryException());
|
||||
return Bool(Context(self)->HasOutOfMemoryException());
|
||||
}
|
||||
|
||||
VALUE Context::InContext(VALUE self) {
|
||||
return Convert(v8::Context::InContext());
|
||||
return Bool(v8::Context::InContext());
|
||||
}
|
||||
|
||||
VALUE Context::SetData(VALUE self, VALUE data) {
|
||||
|
@ -79,7 +79,7 @@ VALUE Context::SetData(VALUE self, VALUE data) {
|
|||
}
|
||||
|
||||
VALUE Context::GetData(VALUE self) {
|
||||
return Convert(Context(self)->GetData());
|
||||
return Value(Context(self)->GetData());
|
||||
}
|
||||
|
||||
VALUE Context::AllowCodeGenerationFromStrings(VALUE self, VALUE allow) {
|
||||
|
@ -88,7 +88,7 @@ VALUE Context::AllowCodeGenerationFromStrings(VALUE self, VALUE allow) {
|
|||
}
|
||||
|
||||
VALUE Context::IsCodeGenerationFromStringsAllowed(VALUE self) {
|
||||
return Convert(Context(self)->IsCodeGenerationFromStringsAllowed());
|
||||
return Bool(Context(self)->IsCodeGenerationFromStringsAllowed());
|
||||
}
|
||||
|
||||
VALUE Context::New(VALUE ContextClass) {
|
||||
|
|
|
@ -2,46 +2,11 @@
|
|||
|
||||
namespace rr {
|
||||
|
||||
VALUE Convert(bool b) {
|
||||
VALUE Bool(bool b) {
|
||||
return b ? Qtrue : Qfalse;
|
||||
}
|
||||
VALUE Convert(int i) {
|
||||
|
||||
Value Int(int i) {
|
||||
return INT2FIX(i);
|
||||
}
|
||||
VALUE Convert(v8::Handle<v8::Value> value) {
|
||||
if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) {
|
||||
return Qnil;
|
||||
}
|
||||
if (value->IsExternal()) {
|
||||
return Qnil;
|
||||
}
|
||||
if (value->IsUint32()) {
|
||||
return UINT2NUM(value->Uint32Value());
|
||||
}
|
||||
if (value->IsInt32()) {
|
||||
return INT2FIX(value->Int32Value());
|
||||
}
|
||||
if (value->IsBoolean()) {
|
||||
return value->BooleanValue() ? Qtrue : Qfalse;
|
||||
}
|
||||
if (value->IsNumber()) {
|
||||
return rb_float_new(value->NumberValue());
|
||||
}
|
||||
if (value->IsString()) {
|
||||
return String(value->ToString());
|
||||
}
|
||||
if (value->IsFunction()) {
|
||||
// return Function(value);
|
||||
}
|
||||
if (value->IsArray()) {
|
||||
// return Array(value);
|
||||
}
|
||||
if (value->IsDate()) {
|
||||
// return rr_reflect_v8_date(value);
|
||||
}
|
||||
if (value->IsObject()) {
|
||||
return Object(value->ToObject());
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
}
|
|
@ -34,14 +34,14 @@ VALUE Object::New(VALUE self) {
|
|||
//TODO: Allow setting of property attributes
|
||||
VALUE Object::Set(VALUE self, VALUE key, VALUE value) {
|
||||
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
||||
return Convert(Object(self)->Set(NUM2UINT(key), Value(value)));
|
||||
return Bool(Object(self)->Set(NUM2UINT(key), Value(value)));
|
||||
} else {
|
||||
return Convert(Object(self)->Set((v8::Handle<v8::Value>)Value(key), Value(value)));
|
||||
return Bool(Object(self)->Set((v8::Handle<v8::Value>)Value(key), Value(value)));
|
||||
}
|
||||
}
|
||||
|
||||
VALUE Object::ForceSet(VALUE self, VALUE key, VALUE value) {
|
||||
return Convert(Object(self)->ForceSet(Value(key), Value(value)));
|
||||
return Bool(Object(self)->ForceSet(Value(key), Value(value)));
|
||||
}
|
||||
|
||||
VALUE Object::Get(VALUE self, VALUE key) {
|
||||
|
@ -53,29 +53,29 @@ VALUE Object::Get(VALUE self, VALUE key) {
|
|||
}
|
||||
|
||||
VALUE Object::GetPropertyAttributes(VALUE self, VALUE key) {
|
||||
return Convert(Object(self)->GetPropertyAttributes(Value(key)));
|
||||
return PropertyAttribute(Object(self)->GetPropertyAttributes(Value(key)));
|
||||
}
|
||||
|
||||
VALUE Object::Has(VALUE self, VALUE key) {
|
||||
Object obj(self);
|
||||
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
||||
return Convert(obj->Has((uint32_t)NUM2UINT(key)));
|
||||
return Bool(obj->Has((uint32_t)NUM2UINT(key)));
|
||||
} else {
|
||||
return Convert(obj->Has((v8::Handle<v8::String>)String(key)));
|
||||
return Bool(obj->Has((v8::Handle<v8::String>)String(key)));
|
||||
}
|
||||
}
|
||||
|
||||
VALUE Object::Delete(VALUE self, VALUE key) {
|
||||
Object obj(self);
|
||||
if (rb_obj_is_kind_of(key, rb_cNumeric)) {
|
||||
return Convert(obj->Delete((uint32_t)NUM2UINT(key)));
|
||||
return Bool(obj->Delete((uint32_t)NUM2UINT(key)));
|
||||
} else {
|
||||
return Convert(obj->Delete((v8::Handle<v8::String>)String(key)));
|
||||
return Bool(obj->Delete((v8::Handle<v8::String>)String(key)));
|
||||
}
|
||||
}
|
||||
|
||||
VALUE Object::ForceDelete(VALUE self, VALUE key) {
|
||||
return Convert(Object(self)->ForceDelete(Value(key)));
|
||||
return Bool(Object(self)->ForceDelete(Value(key)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ VALUE Object::SetAccessor(int argc, VALUE* argv, VALUE self) {
|
|||
attrs = PropertyAttribute(attribs);
|
||||
}
|
||||
Accessor::Info accessor(get, set, data);
|
||||
return Convert(Object(self)->SetAccessor(String(name), accessor.Getter(), accessor.Setter(), accessor, ac, attrs));
|
||||
return Bool(Object(self)->SetAccessor(String(name), accessor.Getter(), accessor.Setter(), accessor, ac, attrs));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
namespace rr {
|
||||
|
||||
VALUE Convert(bool);
|
||||
VALUE Convert(v8::Handle<v8::Value> handle);
|
||||
VALUE Bool(bool);
|
||||
|
||||
class GC {
|
||||
public:
|
||||
|
|
|
@ -20,7 +20,7 @@ VALUE String::Utf8Value(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE String::Concat(VALUE self, VALUE left, VALUE right) {
|
||||
return Convert(v8::String::Concat(String(left), String(right)));
|
||||
return String(v8::String::Concat(String(left), String(right)));
|
||||
}
|
||||
|
||||
} //namespace rr
|
|
@ -8,7 +8,7 @@ void V8::Init() {
|
|||
}
|
||||
|
||||
VALUE V8::IdleNotification(VALUE self) {
|
||||
return Convert(v8::V8::IdleNotification());
|
||||
return Bool(v8::V8::IdleNotification());
|
||||
}
|
||||
|
||||
}
|
|
@ -10,11 +10,11 @@ void Value::Init() {
|
|||
}
|
||||
|
||||
VALUE Value::Equals(VALUE self, VALUE other) {
|
||||
return Convert(Value(self)->Equals(Value(other)));
|
||||
return Bool(Value(self)->Equals(Value(other)));
|
||||
}
|
||||
|
||||
VALUE Value::StrictEquals(VALUE self, VALUE other) {
|
||||
return Convert(Value(self)->StrictEquals(Value(other)));
|
||||
return Bool(Value(self)->StrictEquals(Value(other)));
|
||||
}
|
||||
|
||||
Value::operator VALUE() {
|
||||
|
@ -45,15 +45,6 @@ Value::operator VALUE() {
|
|||
if (handle->IsString()) {
|
||||
return String(handle->ToString());
|
||||
}
|
||||
// if (handle->IsFunction()) {
|
||||
// // return Function(handle);
|
||||
// }
|
||||
// if (handle->IsArray()) {
|
||||
// // return Array(handle);
|
||||
// }
|
||||
// if (handle->IsDate()) {
|
||||
// // return rr_reflect_v8_date(handle);
|
||||
// }
|
||||
if (handle->IsObject()) {
|
||||
return Object(handle->ToObject());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue