From 569fb985ce05c0e011d78da2eb8a3cc596cf1afa Mon Sep 17 00:00:00 2001 From: "christian.plesner.hansen@gmail.com" Date: Thu, 8 Jan 2009 11:35:34 +0000 Subject: [PATCH] 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 --- include/v8.h | 136 +++++++++++++++++++++++++++++------------------------------ src/api.cc | 115 +++++++++++++++++++++++++------------------------- src/api.h | 32 +++++++------- 3 files changed, 142 insertions(+), 141 deletions(-) diff --git a/include/v8.h b/include/v8.h index 2a8f86d..1876a54 100644 --- a/include/v8.h +++ b/include/v8.h @@ -200,11 +200,11 @@ template 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 EXPORT_INLINE Handle { * to which they refer are identical. * The handles' references are not checked. */ - template bool operator==(Handle that) { + template bool operator==(Handle that) const { void** a = reinterpret_cast(**this); void** b = reinterpret_cast(*that); if (a == 0) return b == 0; @@ -231,7 +231,7 @@ template class EXPORT_INLINE Handle { * the objects to which they refer are different. * The handles' references are not checked. */ - template bool operator!=(Handle that) { + template bool operator!=(Handle that) const { return !operator==(that); } @@ -367,12 +367,12 @@ template class EXPORT_INLINE Persistent : public Handle { /** *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 Get(); - Local GetSourceLine(); + Local Get() const; + Local GetSourceLine() const; - Handle GetScriptResourceName(); + Handle 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 ToBoolean(); - Local ToNumber(); - Local ToString(); - Local ToDetailString(); - Local ToObject(); - Local ToInteger(); - Local ToUint32(); - Local ToInt32(); + Local ToBoolean() const; + Local ToNumber() const; + Local ToString() const; + Local ToDetailString() const; + Local ToObject() const; + Local ToInteger() const; + Local ToUint32() const; + Local ToInt32() const; /** * Attempts to convert a string to an array index. * Returns an empty handle if the conversion fails. */ - Local ToArrayIndex(); + Local 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 that); - bool StrictEquals(Handle that); + bool Equals(Handle that) const; + bool StrictEquals(Handle 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 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 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 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 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 NewInstance(); - Local NewInstance(int argc, Handle argv[]); + Local NewInstance() const; + Local NewInstance(int argc, Handle argv[]) const; Local Call(Handle recv, int argc, Handle argv[]); void SetName(Handle name); - Handle GetName(); + Handle GetName() const; static Function* Cast(Value* obj); private: Function(); @@ -1121,7 +1121,7 @@ class EXPORT External : public Value { public: static Local New(void* value); static External* Cast(Value* obj); - void* Value(); + void* Value() const; private: External(); }; @@ -2322,14 +2322,14 @@ Persistent Persistent::New(Handle that) { template -bool Persistent::IsNearDeath() { +bool Persistent::IsNearDeath() const { if (this->IsEmpty()) return false; return V8::IsGlobalNearDeath(reinterpret_cast(**this)); } template -bool Persistent::IsWeak() { +bool Persistent::IsWeak() const { if (this->IsEmpty()) return false; return V8::IsGlobalWeak(reinterpret_cast(**this)); } @@ -2356,13 +2356,13 @@ void Persistent::ClearWeak() { } template -T* Handle::operator->() { +T* Handle::operator->() const { return val_; } template -T* Handle::operator*() { +T* Handle::operator*() const { return val_; } diff --git a/src/api.cc b/src/api.cc index f3a74ac..92ee573 100644 --- a/src/api.cc +++ b/src/api.cc @@ -174,7 +174,7 @@ static inline bool EmptyCheck(const char* location, v8::Handle 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 Message::Get() { +Local Message::Get() const { ON_BAILOUT("v8::Message::Get()", return Local()); HandleScope scope; i::Handle obj = Utils::OpenHandle(this); @@ -1147,7 +1147,7 @@ Local Message::Get() { } -v8::Handle Message::GetScriptResourceName() { +v8::Handle Message::GetScriptResourceName() const { if (IsDeadCheck("v8::Message::GetScriptResourceName()")) { return Local(); } @@ -1189,7 +1189,7 @@ static i::Handle 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 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 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 data_obj = Utils::OpenHandle(this); @@ -1248,7 +1248,7 @@ int Message::GetEndColumn() { } -Local Message::GetSourceLine() { +Local Message::GetSourceLine() const { ON_BAILOUT("v8::Message::GetSourceLine()", return Local()); 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 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 obj = Utils::OpenHandle(this); return obj->HasSpecificClassOf(i::Heap::Date_symbol()); } -Local Value::ToString() { +Local Value::ToString() const { if (IsDeadCheck("v8::Value::ToString()")) return Local(); LOG_API("ToString"); i::Handle obj = Utils::OpenHandle(this); @@ -1373,7 +1373,7 @@ Local Value::ToString() { } -Local Value::ToDetailString() { +Local Value::ToDetailString() const { if (IsDeadCheck("v8::Value::ToDetailString()")) return Local(); LOG_API("ToDetailString"); i::Handle obj = Utils::OpenHandle(this); @@ -1389,7 +1389,7 @@ Local Value::ToDetailString() { } -Local Value::ToObject() { +Local Value::ToObject() const { if (IsDeadCheck("v8::Value::ToObject()")) return Local(); LOG_API("ToObject"); i::Handle obj = Utils::OpenHandle(this); @@ -1405,7 +1405,7 @@ Local Value::ToObject() { } -Local Value::ToBoolean() { +Local Value::ToBoolean() const { if (IsDeadCheck("v8::Value::ToBoolean()")) return Local(); LOG_API("ToBoolean"); i::Handle obj = Utils::OpenHandle(this); @@ -1415,7 +1415,7 @@ Local Value::ToBoolean() { } -Local Value::ToNumber() { +Local Value::ToNumber() const { if (IsDeadCheck("v8::Value::ToNumber()")) return Local(); LOG_API("ToNumber"); i::Handle obj = Utils::OpenHandle(this); @@ -1431,7 +1431,7 @@ Local Value::ToNumber() { } -Local Value::ToInteger() { +Local Value::ToInteger() const { if (IsDeadCheck("v8::Value::ToInteger()")) return Local(); LOG_API("ToInteger"); i::Handle 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 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 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 obj = Utils::OpenHandle(this); @@ -1573,7 +1573,7 @@ int64_t Value::IntegerValue() { } -Local Value::ToInt32() { +Local Value::ToInt32() const { if (IsDeadCheck("v8::Value::ToInt32()")) return Local(); LOG_API("ToInt32"); i::Handle obj = Utils::OpenHandle(this); @@ -1589,7 +1589,7 @@ Local Value::ToInt32() { } -Local Value::ToUint32() { +Local Value::ToUint32() const { if (IsDeadCheck("v8::Value::ToUint32()")) return Local(); LOG_API("ToUInt32"); i::Handle obj = Utils::OpenHandle(this); @@ -1605,7 +1605,7 @@ Local Value::ToUint32() { } -Local Value::ToArrayIndex() { +Local Value::ToArrayIndex() const { if (IsDeadCheck("v8::Value::ToArrayIndex()")) return Local(); LOG_API("ToArrayIndex"); i::Handle obj = Utils::OpenHandle(this); @@ -1632,7 +1632,7 @@ Local Value::ToArrayIndex() { } -int32_t Value::Int32Value() { +int32_t Value::Int32Value() const { if (IsDeadCheck("v8::Value::Int32Value()")) return 0; LOG_API("Int32Value"); i::Handle obj = Utils::OpenHandle(this); @@ -1653,7 +1653,7 @@ int32_t Value::Int32Value() { } -bool Value::Equals(Handle that) { +bool Value::Equals(Handle 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 that) { } -bool Value::StrictEquals(Handle that) { +bool Value::StrictEquals(Handle 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 that) { } -uint32_t Value::Uint32Value() { +uint32_t Value::Uint32Value() const { if (IsDeadCheck("v8::Value::Uint32Value()")) return 0; LOG_API("Uint32Value"); i::Handle obj = Utils::OpenHandle(this); @@ -1922,13 +1922,13 @@ void v8::Object::TurnOnAccessCheck() { } -Local Function::NewInstance() { +Local Function::NewInstance() const { return NewInstance(0, NULL); } Local Function::NewInstance(int argc, - v8::Handle argv[]) { + v8::Handle argv[]) const { ON_BAILOUT("v8::Function::NewInstance()", return Local()); LOG_API("Function::NewInstance"); HandleScope scope; @@ -1971,25 +1971,25 @@ void Function::SetName(v8::Handle name) { } -Handle Function::GetName() { +Handle Function::GetName() const { i::Handle func = Utils::OpenHandle(this); return Utils::ToLocal(i::Handle(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 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 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 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 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 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 obj = Utils::OpenHandle(this); return obj->Number(); } -bool Boolean::Value() { +bool Boolean::Value() const { if (IsDeadCheck("v8::Boolean::Value()")) return false; i::Handle 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 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 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 obj = Utils::OpenHandle(this); return reinterpret_cast(i::Proxy::cast(*obj)->proxy()); @@ -2529,7 +2530,7 @@ Local 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 obj = Utils::OpenHandle(this); @@ -2546,7 +2547,7 @@ Local 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 obj = Utils::OpenHandle(this); i::Object* length = obj->length(); diff --git a/src/api.h b/src/api.h index 4843926..b6fdbd3 100644 --- a/src/api.h +++ b/src/api.h @@ -237,33 +237,33 @@ class Utils { v8::internal::Handle obj); static inline v8::internal::Handle - OpenHandle(Template* that); + OpenHandle(const Template* that); static inline v8::internal::Handle - OpenHandle(FunctionTemplate* that); + OpenHandle(const FunctionTemplate* that); static inline v8::internal::Handle - OpenHandle(ObjectTemplate* that); + OpenHandle(const ObjectTemplate* that); static inline v8::internal::Handle - OpenHandle(Data* data); + OpenHandle(const Data* data); static inline v8::internal::Handle - OpenHandle(v8::Object* data); + OpenHandle(const v8::Object* data); static inline v8::internal::Handle - OpenHandle(v8::Array* data); + OpenHandle(const v8::Array* data); static inline v8::internal::Handle - OpenHandle(String* data); + OpenHandle(const String* data); static inline v8::internal::Handle - OpenHandle(Script* data); + OpenHandle(const Script* data); static inline v8::internal::Handle - OpenHandle(Function* data); + OpenHandle(const Function* data); static inline v8::internal::Handle - OpenHandle(Message* message); + OpenHandle(const Message* message); static inline v8::internal::Handle - OpenHandle(v8::Context* context); + OpenHandle(const v8::Context* context); static inline v8::internal::Handle - OpenHandle(v8::Signature* sig); + OpenHandle(const v8::Signature* sig); static inline v8::internal::Handle - OpenHandle(v8::TypeSwitch* that); + OpenHandle(const v8::TypeSwitch* that); static inline v8::internal::Handle - 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 Utils::OpenHandle(v8::From* that) { \ + v8::internal::Handle Utils::OpenHandle(const v8::From* that) { \ return v8::internal::Handle( \ - reinterpret_cast(that)); \ + reinterpret_cast(const_cast(that))); \ } MAKE_OPEN_HANDLE(Template, TemplateInfo) -- 2.7.4