Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/api.cc

Issue 464413002: Expose Value::IsMap, IsSet, IsWeakMap, IsWeakSet in V8 API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698