Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 6f6fb42a32484b588e986429f2e3b47b125be8b4..a1ed3d887aaacbaaa166650072179ff108327efc 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2383,12 +2383,26 @@ bool Value::IsNumber() const { |
} |
-bool Value::IsArgumentsObject() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->Arguments_string()); |
-} |
+#define VALUE_IS_SPECIFIC_TYPE(Type, Class) \ |
+ bool Value::Is##Type() const { \ |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); \ |
+ if (!obj->IsHeapObject()) return false; \ |
+ i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); \ |
+ return obj->HasSpecificClassOf(isolate->heap()->Class##_string()); \ |
+ } |
+ |
+VALUE_IS_SPECIFIC_TYPE(ArgumentsObject, Arguments) |
+VALUE_IS_SPECIFIC_TYPE(BooleanObject, Boolean) |
+VALUE_IS_SPECIFIC_TYPE(NumberObject, Number) |
+VALUE_IS_SPECIFIC_TYPE(StringObject, String) |
+VALUE_IS_SPECIFIC_TYPE(SymbolObject, Symbol) |
+VALUE_IS_SPECIFIC_TYPE(Date, Date) |
+VALUE_IS_SPECIFIC_TYPE(Map, Map) |
+VALUE_IS_SPECIFIC_TYPE(Set, Set) |
+VALUE_IS_SPECIFIC_TYPE(WeakMap, WeakMap) |
+VALUE_IS_SPECIFIC_TYPE(WeakSet, WeakSet) |
+ |
+#undef VALUE_IS_SPECIFIC_TYPE |
bool Value::IsBoolean() const { |
@@ -2425,38 +2439,6 @@ bool Value::IsUint32() const { |
} |
-bool Value::IsDate() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->Date_string()); |
-} |
- |
- |
-bool Value::IsStringObject() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->String_string()); |
-} |
- |
- |
-bool Value::IsSymbolObject() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->Symbol_string()); |
-} |
- |
- |
-bool Value::IsNumberObject() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->Number_string()); |
-} |
- |
- |
static bool CheckConstructor(i::Isolate* isolate, |
i::Handle<i::JSObject> obj, |
const char* class_name) { |
@@ -2488,14 +2470,6 @@ bool Value::IsNativeError() const { |
} |
-bool Value::IsBooleanObject() const { |
- i::Handle<i::Object> obj = Utils::OpenHandle(this); |
- if (!obj->IsHeapObject()) return false; |
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
- return obj->HasSpecificClassOf(isolate->heap()->Boolean_string()); |
-} |
- |
- |
bool Value::IsRegExp() const { |
i::Handle<i::Object> obj = Utils::OpenHandle(this); |
return obj->IsJSRegExp(); |