mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
remove Int equivalence class
This commit is contained in:
parent
46cb703e87
commit
e90ef50b0d
10 changed files with 24 additions and 32 deletions
|
@ -137,7 +137,7 @@ namespace rr {
|
|||
|
||||
v8::Handle<v8::Integer> Accessor::Info::query(v8::Local<v8::String> property) {
|
||||
Accessor accessor(info->Data());
|
||||
return v8::Integer::New(Int(rb_funcall(accessor.query, rb_intern("call"), 2, (VALUE)String(property), (VALUE)*this)));
|
||||
return v8::Integer::New(NUM2INT(rb_funcall(accessor.query, rb_intern("call"), 2, (VALUE)String(property), (VALUE)*this)));
|
||||
}
|
||||
|
||||
v8::Handle<v8::Boolean> Accessor::Info::remove(v8::Local<v8::String> property) {
|
||||
|
@ -162,7 +162,7 @@ namespace rr {
|
|||
|
||||
v8::Handle<v8::Integer> Accessor::Info::query(uint32_t index) {
|
||||
Accessor accessor(info->Data());
|
||||
return v8::Integer::New(Int(rb_funcall(accessor.query, rb_intern("call"), 2, UINT2NUM(index), (VALUE)*this)));
|
||||
return v8::Integer::New(NUM2INT(rb_funcall(accessor.query, rb_intern("call"), 2, UINT2NUM(index), (VALUE)*this)));
|
||||
}
|
||||
|
||||
v8::Handle<v8::Boolean> Accessor::Info::remove(uint32_t index) {
|
||||
|
|
|
@ -12,7 +12,7 @@ void Array::Init() {
|
|||
|
||||
VALUE Array::New(int argc, VALUE argv[], VALUE self) {
|
||||
VALUE length; rb_scan_args(argc, argv, "01", &length);
|
||||
return Array(v8::Array::New(Int(length)));
|
||||
return Array(v8::Array::New(RTEST(length) ? NUM2INT(length) : 0));
|
||||
}
|
||||
|
||||
VALUE Array::Length(VALUE self) {
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace rr {
|
|||
} else {
|
||||
VALUE argc; VALUE argv;
|
||||
rb_scan_args(i,v,"2", &argc, &argv);
|
||||
std::vector< v8::Handle<v8::Value> > arguments(Int(argc).toInt());
|
||||
return Object(Function(self)->NewInstance(Int(argc), Value::array(argv, arguments)));
|
||||
std::vector< v8::Handle<v8::Value> > arguments(NUM2INT(argc));
|
||||
return Object(Function(self)->NewInstance(NUM2INT(argc), Value::array(argv, arguments)));
|
||||
}
|
||||
}
|
||||
VALUE Function::Call(VALUE self, VALUE receiver, VALUE argc, VALUE argv) {
|
||||
std::vector< v8::Handle<v8::Value> > arguments(Int(argc).toInt());
|
||||
return Value(Function(self)->Call(Object(receiver), Int(argc), Value::array(argv, arguments)));
|
||||
std::vector< v8::Handle<v8::Value> > arguments(NUM2INT(argc));
|
||||
return Value(Function(self)->Call(Object(receiver), NUM2INT(argc), Value::array(argv, arguments)));
|
||||
}
|
||||
|
||||
VALUE Function::SetName(VALUE self, VALUE name) {
|
||||
|
@ -43,11 +43,11 @@ namespace rr {
|
|||
}
|
||||
|
||||
VALUE Function::GetScriptLineNumber(VALUE self) {
|
||||
return Int(Function(self)->GetScriptLineNumber());
|
||||
return INT2FIX(Function(self)->GetScriptLineNumber());
|
||||
}
|
||||
|
||||
VALUE Function::GetScriptColumnNumber(VALUE self) {
|
||||
return Int(Function(self)->GetScriptColumnNumber());
|
||||
return INT2FIX(Function(self)->GetScriptColumnNumber());
|
||||
}
|
||||
|
||||
VALUE Function::GetScriptId(VALUE self) {
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace rr {
|
|||
}
|
||||
|
||||
VALUE Invocation::Arguments::Length(VALUE self) {
|
||||
return Int(Arguments(self)->Length());
|
||||
return INT2FIX(Arguments(self)->Length());
|
||||
}
|
||||
|
||||
VALUE Invocation::Arguments::Get(VALUE self, VALUE index) {
|
||||
|
|
|
@ -185,15 +185,15 @@ VALUE Object::GetConstructorName(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE Object::InternalFieldCount(VALUE self) {
|
||||
return Int(Object(self)->InternalFieldCount());
|
||||
return INT2FIX(Object(self)->InternalFieldCount());
|
||||
}
|
||||
|
||||
VALUE Object::GetInternalField(VALUE self, VALUE idx) {
|
||||
return Value(Object(self)->GetInternalField(Int(idx)));
|
||||
return Value(Object(self)->GetInternalField(NUM2INT(idx)));
|
||||
}
|
||||
|
||||
VALUE Object::SetInternalField(VALUE self, VALUE idx, VALUE value) {
|
||||
Void(Object(self)->SetInternalField(Int(idx), Value(value)));
|
||||
Void(Object(self)->SetInternalField(NUM2INT(idx), Value(value)));
|
||||
}
|
||||
|
||||
VALUE Object::HasOwnProperty(VALUE self, VALUE key) {
|
||||
|
@ -233,7 +233,7 @@ VALUE Object::TurnOnAccessCheck(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE Object::GetIdentityHash(VALUE self) {
|
||||
return Int(Object(self)->GetIdentityHash());
|
||||
return INT2FIX(Object(self)->GetIdentityHash());
|
||||
}
|
||||
|
||||
VALUE Object::SetHiddenValue(VALUE self, VALUE key, VALUE value) {
|
||||
|
@ -273,7 +273,7 @@ VALUE Object::HasIndexedPropertiesInPixelData(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE Object::GetIndexedPropertiesPixelDataLength(VALUE self) {
|
||||
return Int(Object(self)->GetIndexedPropertiesPixelDataLength());
|
||||
return INT2FIX(Object(self)->GetIndexedPropertiesPixelDataLength());
|
||||
}
|
||||
|
||||
VALUE Object::SetIndexedPropertiesToExternalArrayData(VALUE self) {
|
||||
|
@ -293,7 +293,7 @@ VALUE Object::GetIndexedPropertiesExternalArrayDataType(VALUE self) {
|
|||
}
|
||||
|
||||
VALUE Object::GetIndexedPropertiesExternalArrayDataLength(VALUE self) {
|
||||
return Int(Object(self)->GetIndexedPropertiesExternalArrayDataLength());
|
||||
return INT2FIX(Object(self)->GetIndexedPropertiesExternalArrayDataLength());
|
||||
}
|
||||
|
||||
VALUE Object::IsCallable(VALUE self) {
|
||||
|
@ -302,12 +302,12 @@ VALUE Object::IsCallable(VALUE self) {
|
|||
|
||||
VALUE Object::CallAsFunction(VALUE self, VALUE recv, VALUE argc, VALUE argv) {
|
||||
std::vector< v8::Handle<v8::Value> > v(NUM2INT(argc));
|
||||
return Value(Object(self)->CallAsFunction(Object(recv), Int(argc), Value::array(argv, v)));
|
||||
return Value(Object(self)->CallAsFunction(Object(recv), NUM2INT(argc), Value::array(argv, v)));
|
||||
}
|
||||
|
||||
VALUE Object::CallAsConstructor(VALUE self, VALUE argc, VALUE argv) {
|
||||
std::vector< v8::Handle<v8::Value> > v(NUM2INT(argc));
|
||||
return Value(Object(self)->CallAsConstructor(Int(argc), Value::array(argv, v)));
|
||||
return Value(Object(self)->CallAsConstructor(NUM2INT(argc), Value::array(argv, v)));
|
||||
}
|
||||
|
||||
}
|
|
@ -68,7 +68,7 @@ namespace rr {
|
|||
return *this;
|
||||
}
|
||||
ClassBuilder& ClassBuilder::defineEnumConst(const char* name, int value) {
|
||||
rb_define_const(this->value, name, Int(value));
|
||||
rb_define_const(this->value, name, INT2FIX(value));
|
||||
return *this;
|
||||
}
|
||||
ClassBuilder& ClassBuilder::store(VALUE* storage) {
|
||||
|
|
|
@ -25,14 +25,6 @@ public:
|
|||
inline operator bool() {return RTEST(value);}
|
||||
};
|
||||
|
||||
class Int : public Equiv {
|
||||
public:
|
||||
Int(VALUE val) : Equiv(val) {}
|
||||
Int(int i) : Equiv(INT2FIX(i)) {}
|
||||
inline operator int() {return RTEST(value) ? NUM2INT(value) : 0;}
|
||||
inline int toInt() {return (int)*this;}
|
||||
};
|
||||
|
||||
class UInt32 : public Equiv {
|
||||
public:
|
||||
UInt32(VALUE val) : Equiv(val) {}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace rr {
|
|||
VALUE Signature::New(int length, VALUE args[], VALUE self) {
|
||||
VALUE receiver; VALUE argc; VALUE argv;
|
||||
rb_scan_args(length, args, "03", &receiver, &argc, &argv);
|
||||
std::vector< v8::Handle<v8::FunctionTemplate> > parameters(Int(argc).toInt());
|
||||
return Signature(v8::Signature::New(FunctionTemplate(receiver), Int(argc), FunctionTemplate::array(argv, parameters)));
|
||||
std::vector< v8::Handle<v8::FunctionTemplate> > parameters(NUM2INT(argc));
|
||||
return Signature(v8::Signature::New(FunctionTemplate(receiver), NUM2INT(argc), FunctionTemplate::array(argv, parameters)));
|
||||
}
|
||||
}
|
|
@ -94,11 +94,11 @@ namespace rr {
|
|||
}
|
||||
|
||||
VALUE ObjectTemplate::InternalFieldCount(VALUE self) {
|
||||
return Int(ObjectTemplate(self)->InternalFieldCount());
|
||||
return INT2FIX(ObjectTemplate(self)->InternalFieldCount());
|
||||
}
|
||||
|
||||
VALUE ObjectTemplate::SetInternalFieldCount(VALUE self, VALUE count) {
|
||||
Void(ObjectTemplate(self)->SetInternalFieldCount(Int(count)));
|
||||
Void(ObjectTemplate(self)->SetInternalFieldCount(NUM2INT(count)));
|
||||
}
|
||||
|
||||
void FunctionTemplate::Init() {
|
||||
|
|
|
@ -34,7 +34,7 @@ Value::operator VALUE() {
|
|||
return UInt32(handle->Uint32Value());
|
||||
}
|
||||
if (handle->IsInt32()) {
|
||||
return Int(handle->Int32Value());
|
||||
return INT2FIX(handle->Int32Value());
|
||||
}
|
||||
if (handle->IsBoolean()) {
|
||||
return handle->BooleanValue() ? Qtrue : Qfalse;
|
||||
|
|
Loading…
Reference in a new issue