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

Unified Diff: src/api.cc

Issue 1003663002: Add Cast() for Int32 and Uint32 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/objects.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 f285980f6b654d289e82f62bd4963b3c1ccab1a9..2658a8ebb950ef2d4f37fd58fcffb931ad054513 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2675,28 +2675,10 @@ bool Value::IsExternal() const {
}
-bool Value::IsInt32() const {
- i::Handle<i::Object> obj = Utils::OpenHandle(this);
- if (obj->IsSmi()) return true;
- if (obj->IsNumber()) {
- return i::IsInt32Double(obj->Number());
- }
- return false;
-}
+bool Value::IsInt32() const { return Utils::OpenHandle(this)->IsInt32(); }
dcarney 2015/03/12 10:45:58 i don't think v8 cares internally about this disti
bashi 2015/03/12 12:19:19 Right. Reverted.
-bool Value::IsUint32() const {
- i::Handle<i::Object> obj = Utils::OpenHandle(this);
- if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
- if (obj->IsNumber()) {
- double value = obj->Number();
- return !i::IsMinusZero(value) &&
- value >= 0 &&
- value <= i::kMaxUInt32 &&
- value == i::FastUI2D(i::FastD2UI(value));
- }
- return false;
-}
+bool Value::IsUint32() const { return Utils::OpenHandle(this)->IsUint32(); }
dcarney 2015/03/12 10:45:58 same
static bool CheckConstructor(i::Isolate* isolate,
@@ -2973,6 +2955,20 @@ void v8::Integer::CheckCast(v8::Value* that) {
}
+void v8::Int32::CheckCast(v8::Value* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsInt32(), "v8::Int32::Cast()",
dcarney 2015/03/12 10:45:58 just use that->IsInt32()
bashi 2015/03/12 12:19:19 Done.
+ "Could not convert to 32-bit signed integer");
+}
+
+
+void v8::Uint32::CheckCast(v8::Value* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
dcarney 2015/03/12 10:45:58 same
+ Utils::ApiCheck(obj->IsUint32(), "v8::Uint32::Cast()",
+ "Could not convert to 32-bit unsigned integer");
+}
+
+
void v8::Array::CheckCast(Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsJSArray(),
« no previous file with comments | « include/v8.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698