Added more constness to the api. There are still some methods back

that could be const but aren't, but now at least all the obvious ones
should be.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1045 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 741bf3b6
......@@ -200,11 +200,11 @@ template <class T> class EXPORT_INLINE Handle {
/**
* Returns true if the handle is empty.
*/
bool IsEmpty() { return val_ == 0; }
bool IsEmpty() const { return val_ == 0; }
T* operator->();
T* operator->() const;
T* operator*();
T* operator*() const;
/**
* Sets the handle to be empty. IsEmpty() will then return true.
......@@ -217,7 +217,7 @@ template <class T> class EXPORT_INLINE Handle {
* to which they refer are identical.
* The handles' references are not checked.
*/
template <class S> bool operator==(Handle<S> that) {
template <class S> bool operator==(Handle<S> that) const {
void** a = reinterpret_cast<void**>(**this);
void** b = reinterpret_cast<void**>(*that);
if (a == 0) return b == 0;
......@@ -231,7 +231,7 @@ template <class T> class EXPORT_INLINE Handle {
* the objects to which they refer are different.
* The handles' references are not checked.
*/
template <class S> bool operator!=(Handle<S> that) {
template <class S> bool operator!=(Handle<S> that) const {
return !operator==(that);
}
......@@ -367,12 +367,12 @@ template <class T> class EXPORT_INLINE Persistent : public Handle<T> {
/**
*Checks if the handle holds the only reference to an object.
*/
bool IsNearDeath();
bool IsNearDeath() const;
/**
* Returns true if the handle's reference is weak.
*/
bool IsWeak();
bool IsWeak() const;
private:
friend class ImplementationUtilities;
......@@ -556,39 +556,39 @@ class EXPORT Script {
*/
class EXPORT Message {
public:
Local<String> Get();
Local<String> GetSourceLine();
Local<String> Get() const;
Local<String> GetSourceLine() const;
Handle<Value> GetScriptResourceName();
Handle<Value> GetScriptResourceName() const;
/**
* Returns the number, 1-based, of the line where the error occurred.
*/
int GetLineNumber();
int GetLineNumber() const;
/**
* Returns the index within the script of the first character where
* the error occurred.
*/
int GetStartPosition();
int GetStartPosition() const;
/**
* Returns the index within the script of the last character where
* the error occurred.
*/
int GetEndPosition();
int GetEndPosition() const;
/**
* Returns the index within the line of the first character where
* the error occurred.
*/
int GetStartColumn();
int GetStartColumn() const;
/**
* Returns the index within the line of the last character where
* the error occurred.
*/
int GetEndColumn();
int GetEndColumn() const;
// TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(FILE* out);
......@@ -608,94 +608,94 @@ class EXPORT Value : public Data {
* Returns true if this value is the undefined value. See ECMA-262
* 4.3.10.
*/
bool IsUndefined();
bool IsUndefined() const;
/**
* Returns true if this value is the null value. See ECMA-262
* 4.3.11.
*/
bool IsNull();
bool IsNull() const;
/**
* Returns true if this value is true.
*/
bool IsTrue();
bool IsTrue() const;
/**
* Returns true if this value is false.
*/
bool IsFalse();
bool IsFalse() const;
/**
* Returns true if this value is an instance of the String type.
* See ECMA-262 8.4.
*/
bool IsString();
bool IsString() const;
/**
* Returns true if this value is a function.
*/
bool IsFunction();
bool IsFunction() const;
/**
* Returns true if this value is an array.
*/
bool IsArray();
bool IsArray() const;
/**
* Returns true if this value is an object.
*/
bool IsObject();
bool IsObject() const;
/**
* Returns true if this value is boolean.
*/
bool IsBoolean();
bool IsBoolean() const;
/**
* Returns true if this value is a number.
*/
bool IsNumber();
bool IsNumber() const;
/**
* Returns true if this value is external.
*/
bool IsExternal();
bool IsExternal() const;
/**
* Returns true if this value is a 32-bit signed integer.
*/
bool IsInt32();
bool IsInt32() const;
/**
* Returns true if this value is a Date.
*/
bool IsDate();
bool IsDate() const;
Local<Boolean> ToBoolean();
Local<Number> ToNumber();
Local<String> ToString();
Local<String> ToDetailString();
Local<Object> ToObject();
Local<Integer> ToInteger();
Local<Uint32> ToUint32();
Local<Int32> ToInt32();
Local<Boolean> ToBoolean() const;
Local<Number> ToNumber() const;
Local<String> ToString() const;
Local<String> ToDetailString() const;
Local<Object> ToObject() const;
Local<Integer> ToInteger() const;
Local<Uint32> ToUint32() const;
Local<Int32> ToInt32() const;
/**
* Attempts to convert a string to an array index.
* Returns an empty handle if the conversion fails.
*/
Local<Uint32> ToArrayIndex();
Local<Uint32> ToArrayIndex() const;
bool BooleanValue();
double NumberValue();
int64_t IntegerValue();
uint32_t Uint32Value();
int32_t Int32Value();
bool BooleanValue() const;
double NumberValue() const;
int64_t IntegerValue() const;
uint32_t Uint32Value() const;
int32_t Int32Value() const;
/** JS == */
bool Equals(Handle<Value> that);
bool StrictEquals(Handle<Value> that);
bool Equals(Handle<Value> that) const;
bool StrictEquals(Handle<Value> that) const;
};
......@@ -711,7 +711,7 @@ class EXPORT Primitive : public Value { };
*/
class EXPORT Boolean : public Primitive {
public:
bool Value();
bool Value() const;
static inline Handle<Boolean> New(bool value);
};
......@@ -725,13 +725,13 @@ class EXPORT String : public Primitive {
/**
* Returns the number of characters in this string.
*/
int Length();
int Length() const;
/**
* Returns the number of bytes in the UTF-8 encoded
* representation of this string.
*/
int Utf8Length();
int Utf8Length() const;
/**
* Write the contents of the string to an external buffer.
......@@ -750,19 +750,19 @@ class EXPORT String : public Primitive {
* \return The number of characters copied to the buffer
* excluding the NULL terminator.
*/
int Write(uint16_t* buffer, int start = 0, int length = -1); // UTF-16
int WriteAscii(char* buffer, int start = 0, int length = -1); // ASCII
int WriteUtf8(char* buffer, int length = -1); // UTF-8
int Write(uint16_t* buffer, int start = 0, int length = -1) const; // UTF-16
int WriteAscii(char* buffer, int start = 0, int length = -1) const; // ASCII
int WriteUtf8(char* buffer, int length = -1) const; // UTF-8
/**
* Returns true if the string is external
*/
bool IsExternal();
bool IsExternal() const;
/**
* Returns true if the string is both external and ascii
*/
bool IsExternalAscii();
bool IsExternalAscii() const;
/**
* An ExternalStringResource is a wrapper around a two-byte string
* buffer that resides outside V8's heap. Implement an
......@@ -822,13 +822,13 @@ class EXPORT String : public Primitive {
* Get the ExternalStringResource for an external string. Only
* valid if IsExternal() returns true.
*/
ExternalStringResource* GetExternalStringResource();
ExternalStringResource* GetExternalStringResource() const;
/**
* Get the ExternalAsciiStringResource for an external ascii string.
* Only valid if IsExternalAscii() returns true.
*/
ExternalAsciiStringResource* GetExternalAsciiStringResource();
ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
static String* Cast(v8::Value* obj);
......@@ -938,7 +938,7 @@ class EXPORT String : public Primitive {
*/
class EXPORT Number : public Primitive {
public:
double Value();
double Value() const;
static Local<Number> New(double value);
static Number* Cast(v8::Value* obj);
private:
......@@ -952,7 +952,7 @@ class EXPORT Number : public Primitive {
class EXPORT Integer : public Number {
public:
static Local<Integer> New(int32_t value);
int64_t Value();
int64_t Value() const;
static Integer* Cast(v8::Value* obj);
private:
Integer();
......@@ -964,7 +964,7 @@ class EXPORT Integer : public Number {
*/
class EXPORT Int32 : public Integer {
public:
int32_t Value();
int32_t Value() const;
private:
Int32();
};
......@@ -975,7 +975,7 @@ class EXPORT Int32 : public Integer {
*/
class EXPORT Uint32 : public Integer {
public:
uint32_t Value();
uint32_t Value() const;
private:
Uint32();
};
......@@ -992,7 +992,7 @@ class EXPORT Date : public Value {
* A specialization of Value::NumberValue that is more efficient
* because we know the structure of this object.
*/
double NumberValue();
double NumberValue() const;
static Date* Cast(v8::Value* obj);
};
......@@ -1087,7 +1087,7 @@ class EXPORT Object : public Value {
*/
class EXPORT Array : public Object {
public:
uint32_t Length();
uint32_t Length() const;
static Local<Array> New(int length = 0);
static Array* Cast(Value* obj);
......@@ -1101,11 +1101,11 @@ class EXPORT Array : public Object {
*/
class EXPORT Function : public Object {
public:
Local<Object> NewInstance();
Local<Object> NewInstance(int argc, Handle<Value> argv[]);
Local<Object> NewInstance() const;
Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
void SetName(Handle<String> name);
Handle<Value> GetName();
Handle<Value> GetName() const;
static Function* Cast(Value* obj);
private:
Function();
......@@ -1121,7 +1121,7 @@ class EXPORT External : public Value {
public:
static Local<External> New(void* value);
static External* Cast(Value* obj);
void* Value();
void* Value() const;
private:
External();
};
......@@ -2322,14 +2322,14 @@ Persistent<T> Persistent<T>::New(Handle<T> that) {
template <class T>
bool Persistent<T>::IsNearDeath() {
bool Persistent<T>::IsNearDeath() const {
if (this->IsEmpty()) return false;
return V8::IsGlobalNearDeath(reinterpret_cast<void**>(**this));
}
template <class T>
bool Persistent<T>::IsWeak() {
bool Persistent<T>::IsWeak() const {
if (this->IsEmpty()) return false;
return V8::IsGlobalWeak(reinterpret_cast<void**>(**this));
}
......@@ -2356,13 +2356,13 @@ void Persistent<T>::ClearWeak() {
}
template <class T>
T* Handle<T>::operator->() {
T* Handle<T>::operator->() const {
return val_;
}
template <class T>
T* Handle<T>::operator*() {
T* Handle<T>::operator*() const {
return val_;
}
......
......@@ -174,7 +174,7 @@ static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) {
}
static inline bool EmptyCheck(const char* location, v8::Data* obj) {
static inline bool EmptyCheck(const char* location, const v8::Data* obj) {
return (obj == 0) ? ReportEmptyHandle(location) : false;
}
......@@ -1137,7 +1137,7 @@ void v8::TryCatch::SetCaptureMessage(bool value) {
// --- M e s s a g e ---
Local<String> Message::Get() {
Local<String> Message::Get() const {
ON_BAILOUT("v8::Message::Get()", return Local<String>());
HandleScope scope;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1147,7 +1147,7 @@ Local<String> Message::Get() {
}
v8::Handle<Value> Message::GetScriptResourceName() {
v8::Handle<Value> Message::GetScriptResourceName() const {
if (IsDeadCheck("v8::Message::GetScriptResourceName()")) {
return Local<String>();
}
......@@ -1189,7 +1189,7 @@ static i::Handle<i::Object> CallV8HeapFunction(const char* name,
}
int Message::GetLineNumber() {
int Message::GetLineNumber() const {
ON_BAILOUT("v8::Message::GetLineNumber()", return -1);
HandleScope scope;
EXCEPTION_PREAMBLE();
......@@ -1201,7 +1201,7 @@ int Message::GetLineNumber() {
}
int Message::GetStartPosition() {
int Message::GetStartPosition() const {
if (IsDeadCheck("v8::Message::GetStartPosition()")) return 0;
HandleScope scope;
......@@ -1210,7 +1210,7 @@ int Message::GetStartPosition() {
}
int Message::GetEndPosition() {
int Message::GetEndPosition() const {
if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
......@@ -1218,7 +1218,7 @@ int Message::GetEndPosition() {
}
int Message::GetStartColumn() {
int Message::GetStartColumn() const {
if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
......@@ -1232,7 +1232,7 @@ int Message::GetStartColumn() {
}
int Message::GetEndColumn() {
int Message::GetEndColumn() const {
if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
......@@ -1248,7 +1248,7 @@ int Message::GetEndColumn() {
}
Local<String> Message::GetSourceLine() {
Local<String> Message::GetSourceLine() const {
ON_BAILOUT("v8::Message::GetSourceLine()", return Local<String>());
HandleScope scope;
EXCEPTION_PREAMBLE();
......@@ -1272,73 +1272,73 @@ void Message::PrintCurrentStackTrace(FILE* out) {
// --- D a t a ---
bool Value::IsUndefined() {
bool Value::IsUndefined() const {
if (IsDeadCheck("v8::Value::IsUndefined()")) return false;
return Utils::OpenHandle(this)->IsUndefined();
}
bool Value::IsNull() {
bool Value::IsNull() const {
if (IsDeadCheck("v8::Value::IsNull()")) return false;
return Utils::OpenHandle(this)->IsNull();
}
bool Value::IsTrue() {
bool Value::IsTrue() const {
if (IsDeadCheck("v8::Value::IsTrue()")) return false;
return Utils::OpenHandle(this)->IsTrue();
}
bool Value::IsFalse() {
bool Value::IsFalse() const {
if (IsDeadCheck("v8::Value::IsFalse()")) return false;
return Utils::OpenHandle(this)->IsFalse();
}
bool Value::IsFunction() {
bool Value::IsFunction() const {
if (IsDeadCheck("v8::Value::IsFunction()")) return false;
return Utils::OpenHandle(this)->IsJSFunction();
}
bool Value::IsString() {
bool Value::IsString() const {
if (IsDeadCheck("v8::Value::IsString()")) return false;
return Utils::OpenHandle(this)->IsString();
}
bool Value::IsArray() {
bool Value::IsArray() const {
if (IsDeadCheck("v8::Value::IsArray()")) return false;
return Utils::OpenHandle(this)->IsJSArray();
}
bool Value::IsObject() {
bool Value::IsObject() const {
if (IsDeadCheck("v8::Value::IsObject()")) return false;
return Utils::OpenHandle(this)->IsJSObject();
}
bool Value::IsNumber() {
bool Value::IsNumber() const {
if (IsDeadCheck("v8::Value::IsNumber()")) return false;
return Utils::OpenHandle(this)->IsNumber();
}
bool Value::IsBoolean() {
bool Value::IsBoolean() const {
if (IsDeadCheck("v8::Value::IsBoolean()")) return false;
return Utils::OpenHandle(this)->IsBoolean();
}
bool Value::IsExternal() {
bool Value::IsExternal() const {
if (IsDeadCheck("v8::Value::IsExternal()")) return false;
return Utils::OpenHandle(this)->IsProxy();
}
bool Value::IsInt32() {
bool Value::IsInt32() const {
if (IsDeadCheck("v8::Value::IsInt32()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) return true;
......@@ -1350,14 +1350,14 @@ bool Value::IsInt32() {
}
bool Value::IsDate() {
bool Value::IsDate() const {
if (IsDeadCheck("v8::Value::IsDate()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->HasSpecificClassOf(i::Heap::Date_symbol());
}
Local<String> Value::ToString() {
Local<String> Value::ToString() const {
if (IsDeadCheck("v8::Value::ToString()")) return Local<String>();
LOG_API("ToString");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1373,7 +1373,7 @@ Local<String> Value::ToString() {
}
Local<String> Value::ToDetailString() {
Local<String> Value::ToDetailString() const {
if (IsDeadCheck("v8::Value::ToDetailString()")) return Local<String>();
LOG_API("ToDetailString");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1389,7 +1389,7 @@ Local<String> Value::ToDetailString() {
}
Local<v8::Object> Value::ToObject() {
Local<v8::Object> Value::ToObject() const {
if (IsDeadCheck("v8::Value::ToObject()")) return Local<v8::Object>();
LOG_API("ToObject");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1405,7 +1405,7 @@ Local<v8::Object> Value::ToObject() {
}
Local<Boolean> Value::ToBoolean() {
Local<Boolean> Value::ToBoolean() const {
if (IsDeadCheck("v8::Value::ToBoolean()")) return Local<Boolean>();
LOG_API("ToBoolean");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1415,7 +1415,7 @@ Local<Boolean> Value::ToBoolean() {
}
Local<Number> Value::ToNumber() {
Local<Number> Value::ToNumber() const {
if (IsDeadCheck("v8::Value::ToNumber()")) return Local<Number>();
LOG_API("ToNumber");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1431,7 +1431,7 @@ Local<Number> Value::ToNumber() {
}
Local<Integer> Value::ToInteger() {
Local<Integer> Value::ToInteger() const {
if (IsDeadCheck("v8::Value::ToInteger()")) return Local<Integer>();
LOG_API("ToInteger");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1527,7 +1527,7 @@ v8::Date* v8::Date::Cast(v8::Value* that) {
}
bool Value::BooleanValue() {
bool Value::BooleanValue() const {
if (IsDeadCheck("v8::Value::BooleanValue()")) return false;
LOG_API("BooleanValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1537,7 +1537,7 @@ bool Value::BooleanValue() {
}
double Value::NumberValue() {
double Value::NumberValue() const {
if (IsDeadCheck("v8::Value::NumberValue()")) return i::OS::nan_value();
LOG_API("NumberValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1553,7 +1553,7 @@ double Value::NumberValue() {
}
int64_t Value::IntegerValue() {
int64_t Value::IntegerValue() const {
if (IsDeadCheck("v8::Value::IntegerValue()")) return 0;
LOG_API("IntegerValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1573,7 +1573,7 @@ int64_t Value::IntegerValue() {
}
Local<Int32> Value::ToInt32() {
Local<Int32> Value::ToInt32() const {
if (IsDeadCheck("v8::Value::ToInt32()")) return Local<Int32>();
LOG_API("ToInt32");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1589,7 +1589,7 @@ Local<Int32> Value::ToInt32() {
}
Local<Uint32> Value::ToUint32() {
Local<Uint32> Value::ToUint32() const {
if (IsDeadCheck("v8::Value::ToUint32()")) return Local<Uint32>();
LOG_API("ToUInt32");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1605,7 +1605,7 @@ Local<Uint32> Value::ToUint32() {
}
Local<Uint32> Value::ToArrayIndex() {
Local<Uint32> Value::ToArrayIndex() const {
if (IsDeadCheck("v8::Value::ToArrayIndex()")) return Local<Uint32>();
LOG_API("ToArrayIndex");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1632,7 +1632,7 @@ Local<Uint32> Value::ToArrayIndex() {
}
int32_t Value::Int32Value() {
int32_t Value::Int32Value() const {
if (IsDeadCheck("v8::Value::Int32Value()")) return 0;
LOG_API("Int32Value");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1653,7 +1653,7 @@ int32_t Value::Int32Value() {
}
bool Value::Equals(Handle<Value> that) {
bool Value::Equals(Handle<Value> that) const {
if (IsDeadCheck("v8::Value::Equals()")
|| EmptyCheck("v8::Value::Equals()", this)
|| EmptyCheck("v8::Value::Equals()", that))
......@@ -1670,7 +1670,7 @@ bool Value::Equals(Handle<Value> that) {
}
bool Value::StrictEquals(Handle<Value> that) {
bool Value::StrictEquals(Handle<Value> that) const {
if (IsDeadCheck("v8::Value::StrictEquals()")
|| EmptyCheck("v8::Value::StrictEquals()", this)
|| EmptyCheck("v8::Value::StrictEquals()", that))
......@@ -1700,7 +1700,7 @@ bool Value::StrictEquals(Handle<Value> that) {
}
uint32_t Value::Uint32Value() {
uint32_t Value::Uint32Value() const {
if (IsDeadCheck("v8::Value::Uint32Value()")) return 0;
LOG_API("Uint32Value");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -1922,13 +1922,13 @@ void v8::Object::TurnOnAccessCheck() {
}
Local<v8::Object> Function::NewInstance() {
Local<v8::Object> Function::NewInstance() const {
return NewInstance(0, NULL);
}
Local<v8::Object> Function::NewInstance(int argc,
v8::Handle<v8::Value> argv[]) {
v8::Handle<v8::Value> argv[]) const {
ON_BAILOUT("v8::Function::NewInstance()", return Local<v8::Object>());
LOG_API("Function::NewInstance");
HandleScope scope;
......@@ -1971,25 +1971,25 @@ void Function::SetName(v8::Handle<v8::String> name) {
}
Handle<Value> Function::GetName() {
Handle<Value> Function::GetName() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name()));
}
int String::Length() {
int String::Length() const {
if (IsDeadCheck("v8::String::Length()")) return 0;
return Utils::OpenHandle(this)->length();
}
int String::Utf8Length() {
int String::Utf8Length() const {
if (IsDeadCheck("v8::String::Utf8Length()")) return 0;
return Utils::OpenHandle(this)->Utf8Length();
}
int String::WriteUtf8(char* buffer, int capacity) {
int String::WriteUtf8(char* buffer, int capacity) const {
if (IsDeadCheck("v8::String::WriteUtf8()")) return 0;
LOG_API("String::WriteUtf8");
i::Handle<i::String> str = Utils::OpenHandle(this);
......@@ -2030,7 +2030,7 @@ int String::WriteUtf8(char* buffer, int capacity) {
}
int String::WriteAscii(char* buffer, int start, int length) {
int String::WriteAscii(char* buffer, int start, int length) const {
if (IsDeadCheck("v8::String::WriteAscii()")) return 0;
LOG_API("String::WriteAscii");
ASSERT(start >= 0 && length >= -1);
......@@ -2055,7 +2055,7 @@ int String::WriteAscii(char* buffer, int start, int length) {
}
int String::Write(uint16_t* buffer, int start, int length) {
int String::Write(uint16_t* buffer, int start, int length) const {
if (IsDeadCheck("v8::String::Write()")) return 0;
LOG_API("String::Write");
ASSERT(start >= 0 && length >= -1);
......@@ -2077,7 +2077,7 @@ int String::Write(uint16_t* buffer, int start, int length) {
}
bool v8::String::IsExternal() {
bool v8::String::IsExternal() const {
EnsureInitialized("v8::String::IsExternal()");
i::Handle<i::String> str = Utils::OpenHandle(this);
i::StringShape shape(*str);
......@@ -2085,7 +2085,7 @@ bool v8::String::IsExternal() {
}
bool v8::String::IsExternalAscii() {
bool v8::String::IsExternalAscii() const {
EnsureInitialized("v8::String::IsExternalAscii()");
i::Handle<i::String> str = Utils::OpenHandle(this);
i::StringShape shape(*str);
......@@ -2093,7 +2093,8 @@ bool v8::String::IsExternalAscii() {
}
v8::String::ExternalStringResource* v8::String::GetExternalStringResource() {
v8::String::ExternalStringResource*
v8::String::GetExternalStringResource() const {
EnsureInitialized("v8::String::GetExternalStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalTwoByteString());
......@@ -2103,7 +2104,7 @@ v8::String::ExternalStringResource* v8::String::GetExternalStringResource() {
v8::String::ExternalAsciiStringResource*
v8::String::GetExternalAsciiStringResource() {
v8::String::GetExternalAsciiStringResource() const {
EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
i::Handle<i::String> str = Utils::OpenHandle(this);
ASSERT(str->IsExternalAsciiString());
......@@ -2112,21 +2113,21 @@ v8::String::ExternalAsciiStringResource*
}
double Number::Value() {
double Number::Value() const {
if (IsDeadCheck("v8::Number::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->Number();
}
bool Boolean::Value() {
bool Boolean::Value() const {
if (IsDeadCheck("v8::Boolean::Value()")) return false;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->IsTrue();
}
int64_t Integer::Value() {
int64_t Integer::Value() const {
if (IsDeadCheck("v8::Integer::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) {
......@@ -2137,7 +2138,7 @@ int64_t Integer::Value() {
}
int32_t Int32::Value() {
int32_t Int32::Value() const {
if (IsDeadCheck("v8::Int32::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsSmi()) {
......@@ -2148,7 +2149,7 @@ int32_t Int32::Value() {
}
void* External::Value() {
void* External::Value() const {
if (IsDeadCheck("v8::External::Value()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy());
......@@ -2529,7 +2530,7 @@ Local<v8::Value> v8::Date::New(double time) {
}
double v8::Date::NumberValue() {
double v8::Date::NumberValue() const {
if (IsDeadCheck("v8::Date::NumberValue()")) return 0;
LOG_API("Date::NumberValue");
i::Handle<i::Object> obj = Utils::OpenHandle(this);
......@@ -2546,7 +2547,7 @@ Local<v8::Array> v8::Array::New(int length) {
}
uint32_t v8::Array::Length() {
uint32_t v8::Array::Length() const {
if (IsDeadCheck("v8::Array::Length()")) return 0;
i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
i::Object* length = obj->length();
......
......@@ -237,33 +237,33 @@ class Utils {
v8::internal::Handle<v8::internal::TypeSwitchInfo> obj);
static inline v8::internal::Handle<v8::internal::TemplateInfo>
OpenHandle(Template* that);
OpenHandle(const Template* that);
static inline v8::internal::Handle<v8::internal::FunctionTemplateInfo>
OpenHandle(FunctionTemplate* that);
OpenHandle(const FunctionTemplate* that);
static inline v8::internal::Handle<v8::internal::ObjectTemplateInfo>
OpenHandle(ObjectTemplate* that);
OpenHandle(const ObjectTemplate* that);
static inline v8::internal::Handle<v8::internal::Object>
OpenHandle(Data* data);
OpenHandle(const Data* data);
static inline v8::internal::Handle<v8::internal::JSObject>
OpenHandle(v8::Object* data);
OpenHandle(const v8::Object* data);
static inline v8::internal::Handle<v8::internal::JSArray>
OpenHandle(v8::Array* data);
OpenHandle(const v8::Array* data);
static inline v8::internal::Handle<v8::internal::String>
OpenHandle(String* data);
OpenHandle(const String* data);
static inline v8::internal::Handle<v8::internal::JSFunction>
OpenHandle(Script* data);
OpenHandle(const Script* data);
static inline v8::internal::Handle<v8::internal::JSFunction>
OpenHandle(Function* data);
OpenHandle(const Function* data);
static inline v8::internal::Handle<v8::internal::JSObject>
OpenHandle(Message* message);
OpenHandle(const Message* message);
static inline v8::internal::Handle<v8::internal::Context>
OpenHandle(v8::Context* context);
OpenHandle(const v8::Context* context);
static inline v8::internal::Handle<v8::internal::SignatureInfo>
OpenHandle(v8::Signature* sig);
OpenHandle(const v8::Signature* sig);
static inline v8::internal::Handle<v8::internal::TypeSwitchInfo>
OpenHandle(v8::TypeSwitch* that);
OpenHandle(const v8::TypeSwitch* that);
static inline v8::internal::Handle<v8::internal::Proxy>
OpenHandle(v8::External* that);
OpenHandle(const v8::External* that);
};
......@@ -309,9 +309,9 @@ MAKE_TO_LOCAL(Uint32ToLocal, Object, Uint32)
// Implementations of OpenHandle
#define MAKE_OPEN_HANDLE(From, To) \
v8::internal::Handle<v8::internal::To> Utils::OpenHandle(v8::From* that) { \
v8::internal::Handle<v8::internal::To> Utils::OpenHandle(const v8::From* that) { \
return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::To**>(that)); \
reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \
}
MAKE_OPEN_HANDLE(Template, TemplateInfo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment