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

Unified Diff: include/v8.h

Issue 7344013: Expose APIs for detecting boxed primitives, native errors and Math. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Get rid of unclear 'box' comments/strings. Created 9 years, 5 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 | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index fb10c71576da0a92963b4decfe4dde60067a34fb..435486a147b6030ede454847c8bcb10ac3cf8cd5 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -80,9 +80,11 @@ namespace v8 {
class Context;
class String;
+class StringObject;
class Value;
class Utils;
class Number;
+class NumberObject;
class Object;
class Array;
class Int32;
@@ -90,6 +92,7 @@ class Uint32;
class External;
class Primitive;
class Boolean;
+class BooleanObject;
class Integer;
class Function;
class Date;
@@ -929,6 +932,26 @@ class Value : public Data {
V8EXPORT bool IsDate() const;
/**
+ * Returns true if this value is an instance of the Boolean constructor.
Vyacheslav Egorov (Chromium) 2011/07/13 09:10:17 I suggest clearer wording: "Returns true if this
+ */
+ V8EXPORT bool IsBooleanObject() const;
+
+ /**
+ * Returns true if this value is an instance of the Number constructor.
+ */
+ V8EXPORT bool IsNumberObject() const;
+
+ /**
+ * Returns true if this value is an instance of the String constructor.
+ */
+ V8EXPORT bool IsStringObject() const;
+
+ /**
+ * Returns true if this value is a NativeError.
+ */
+ V8EXPORT bool IsNativeError() const;
+
+ /**
* Returns true if this value is a RegExp.
*/
V8EXPORT bool IsRegExp() const;
@@ -1745,6 +1768,65 @@ class Date : public Object {
/**
+ * An instance of the built-in Number constructor (ECMA-262, 15.7).
+ */
+class NumberObject : public Object {
+ public:
+ V8EXPORT static Local<Value> New(double value);
+
+ /**
+ * A specialization of Value::NumberValue that is more efficient
+ * because we know the structure of this object.
+ */
+ V8EXPORT double NumberValue() const;
+
+ static inline NumberObject* Cast(v8::Value* obj);
+
+ private:
+ V8EXPORT static void CheckCast(v8::Value* obj);
+};
+
+
+/**
+ * An instance of the built-in Boolean constructor (ECMA-262, 15.6).
+ */
+class BooleanObject : public Object {
+ public:
+ V8EXPORT static Local<Value> New(bool value);
+
+ /**
+ * A specialization of Value::BooleanValue that is more efficient
+ * because we know the structure of this object.
+ */
+ V8EXPORT bool BooleanValue() const;
+
+ static inline BooleanObject* Cast(v8::Value* obj);
+
+ private:
+ V8EXPORT static void CheckCast(v8::Value* obj);
+};
+
+
+/**
+ * An instance of the built-in String constructor (ECMA-262, 15.5).
+ */
+class StringObject : public Object {
+ public:
+ V8EXPORT static Local<Value> New(Handle<String> value);
+
+ /**
+ * Returns the String held by the object.
+ */
+ V8EXPORT Local<String> StringValue() const;
+
+ static inline StringObject* Cast(v8::Value* obj);
+
+ private:
+ V8EXPORT static void CheckCast(v8::Value* obj);
+};
+
+
+/**
* An instance of the built-in RegExp constructor (ECMA-262, 15.10).
*/
class RegExp : public Object {
@@ -4035,6 +4117,30 @@ Date* Date::Cast(v8::Value* value) {
}
+StringObject* StringObject::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<StringObject*>(value);
+}
+
+
+NumberObject* NumberObject::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<NumberObject*>(value);
+}
+
+
+BooleanObject* BooleanObject::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<BooleanObject*>(value);
+}
+
+
RegExp* RegExp::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698