v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
* | * | |||
* For other documentation see http://code.google.com/apis/v8/ | * For other documentation see http://code.google.com/apis/v8/ | |||
*/ | */ | |||
#ifndef V8_H_ | #ifndef V8_H_ | |||
#define V8_H_ | #define V8_H_ | |||
#include <stdio.h> | #include <stdio.h> | |||
#ifdef _WIN32 | #ifdef _WIN32 | |||
// When compiling on MinGW stdint.h is available. | ||||
#ifdef __MINGW32__ | ||||
#include <stdint.h> | ||||
#else // __MINGW32__ | ||||
typedef signed char int8_t; | ||||
typedef unsigned char uint8_t; | ||||
typedef short int16_t; // NOLINT | ||||
typedef unsigned short uint16_t; // NOLINT | ||||
typedef int int32_t; | typedef int int32_t; | |||
typedef unsigned int uint32_t; | typedef unsigned int uint32_t; | |||
typedef unsigned short uint16_t; // NOLINT | typedef __int64 int64_t; | |||
typedef long long int64_t; // NOLINT | typedef unsigned __int64 uint64_t; | |||
// intptr_t and friends are defined in crtdefs.h through stdio.h. | ||||
#endif // __MINGW32__ | ||||
// Setup for Windows DLL export/import. When building the V8 DLL the | // Setup for Windows DLL export/import. When building the V8 DLL the | |||
// BUILDING_V8_SHARED needs to be defined. When building a program which us es | // BUILDING_V8_SHARED needs to be defined. When building a program which us es | |||
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 | // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 | |||
// static library or building a program which uses the V8 static library ne ither | // static library or building a program which uses the V8 static library ne ither | |||
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. | // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. | |||
// The reason for having both V8EXPORT and V8EXPORT_INLINE is that classes which | // The reason for having both V8EXPORT and V8EXPORT_INLINE is that classes which | |||
// have their code inside this header file need to have __declspec(dllexpor t) | // have their code inside this header file need to have __declspec(dllexpor t) | |||
// when building the DLL but cannot have __declspec(dllimport) when buildin g | // when building the DLL but cannot have __declspec(dllimport) when buildin g | |||
// a program which uses the DLL. | // a program which uses the DLL. | |||
skipping to change at line 202 | skipping to change at line 212 | |||
* Handle<Number>. | * Handle<Number>. | |||
*/ | */ | |||
TYPE_CHECK(T, S); | TYPE_CHECK(T, S); | |||
} | } | |||
/** | /** | |||
* Returns true if the handle is empty. | * Returns true if the handle is empty. | |||
*/ | */ | |||
bool IsEmpty() const { return val_ == 0; } | bool IsEmpty() const { return val_ == 0; } | |||
T* operator->() const; | T* operator->() const { return val_; } | |||
T* operator*() const; | T* operator*() const { return val_; } | |||
/** | /** | |||
* Sets the handle to be empty. IsEmpty() will then return true. | * Sets the handle to be empty. IsEmpty() will then return true. | |||
*/ | */ | |||
void Clear() { this->val_ = 0; } | void Clear() { this->val_ = 0; } | |||
/** | /** | |||
* Checks whether two handles are the same. | * Checks whether two handles are the same. | |||
* Returns true if both are empty, or if the objects | * Returns true if both are empty, or if the objects | |||
* to which they refer are identical. | * to which they refer are identical. | |||
skipping to change at line 521 | skipping to change at line 531 | |||
/** | /** | |||
* Runs the script returning the resulting value. | * Runs the script returning the resulting value. | |||
*/ | */ | |||
Local<Value> Run(); | Local<Value> Run(); | |||
/** | /** | |||
* Returns the script id value. | * Returns the script id value. | |||
*/ | */ | |||
Local<Value> Id(); | Local<Value> Id(); | |||
/** | ||||
* Associate an additional data object with the script. This is mainly us | ||||
ed | ||||
* with the debugger as this data object is only available through the | ||||
* debugger API. | ||||
*/ | ||||
void SetData(Handle<Value> data); | ||||
}; | }; | |||
/** | /** | |||
* An error message. | * An error message. | |||
*/ | */ | |||
class V8EXPORT Message { | class V8EXPORT Message { | |||
public: | public: | |||
Local<String> Get() const; | Local<String> Get() const; | |||
Local<String> GetSourceLine() const; | Local<String> GetSourceLine() const; | |||
/** | ||||
* Returns the resource name for the script from where the function causi | ||||
ng | ||||
* the error originates. | ||||
*/ | ||||
Handle<Value> GetScriptResourceName() const; | Handle<Value> GetScriptResourceName() const; | |||
/** | /** | |||
* Returns the resource data for the script from where the function causi | ||||
ng | ||||
* the error originates. | ||||
*/ | ||||
Handle<Value> GetScriptData() const; | ||||
/** | ||||
* Returns the number, 1-based, of the line where the error occurred. | * Returns the number, 1-based, of the line where the error occurred. | |||
*/ | */ | |||
int GetLineNumber() const; | int GetLineNumber() const; | |||
/** | /** | |||
* Returns the index within the script of the first character where | * Returns the index within the script of the first character where | |||
* the error occurred. | * the error occurred. | |||
*/ | */ | |||
int GetStartPosition() const; | int GetStartPosition() const; | |||
skipping to change at line 791 | skipping to change at line 818 | |||
virtual size_t length() const = 0; | virtual size_t length() const = 0; | |||
protected: | protected: | |||
ExternalAsciiStringResource() {} | ExternalAsciiStringResource() {} | |||
private: | private: | |||
// Disallow copying and assigning. | // Disallow copying and assigning. | |||
ExternalAsciiStringResource(const ExternalAsciiStringResource&); | ExternalAsciiStringResource(const ExternalAsciiStringResource&); | |||
void operator=(const ExternalAsciiStringResource&); | void operator=(const ExternalAsciiStringResource&); | |||
}; | }; | |||
/** | /** | |||
* Get the ExternalStringResource for an external string. Only | * Get the ExternalStringResource for an external string. Returns | |||
* valid if IsExternal() returns true. | * NULL if IsExternal() doesn't return true. | |||
*/ | */ | |||
ExternalStringResource* GetExternalStringResource() const; | ExternalStringResource* GetExternalStringResource() const; | |||
/** | /** | |||
* Get the ExternalAsciiStringResource for an external ascii string. | * Get the ExternalAsciiStringResource for an external ascii string. | |||
* Only valid if IsExternalAscii() returns true. | * Returns NULL if IsExternalAscii() doesn't return true. | |||
*/ | */ | |||
ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | |||
static String* Cast(v8::Value* obj); | static String* Cast(v8::Value* obj); | |||
/** | /** | |||
* Allocates a new string from either utf-8 encoded or ascii data. | * Allocates a new string from either utf-8 encoded or ascii data. | |||
* The second parameter 'length' gives the buffer length. | * The second parameter 'length' gives the buffer length. | |||
* If the data is utf-8 encoded, the caller must | * If the data is utf-8 encoded, the caller must | |||
* be careful to supply the length parameter. | * be careful to supply the length parameter. | |||
skipping to change at line 1008 | skipping to change at line 1035 | |||
}; | }; | |||
/** | /** | |||
* A JavaScript object (ECMA-262, 4.3.3) | * A JavaScript object (ECMA-262, 4.3.3) | |||
*/ | */ | |||
class V8EXPORT Object : public Value { | class V8EXPORT Object : public Value { | |||
public: | public: | |||
bool Set(Handle<Value> key, | bool Set(Handle<Value> key, | |||
Handle<Value> value, | Handle<Value> value, | |||
PropertyAttribute attribs = None); | PropertyAttribute attribs = None); | |||
// Sets a local property on this object bypassing interceptors and | ||||
// overriding accessors or read-only properties. | ||||
// | ||||
// Note that if the object has an interceptor the property will be set | ||||
// locally, but since the interceptor takes precedence the local property | ||||
// will only be returned if the interceptor doesn't return a value. | ||||
// | ||||
// Note also that this only works for named properties. | ||||
bool ForceSet(Handle<Value> key, | ||||
Handle<Value> value, | ||||
PropertyAttribute attribs = None); | ||||
Local<Value> Get(Handle<Value> key); | Local<Value> Get(Handle<Value> key); | |||
// TODO(1245389): Replace the type-specific versions of these | // TODO(1245389): Replace the type-specific versions of these | |||
// functions with generic ones that accept a Handle<Value> key. | // functions with generic ones that accept a Handle<Value> key. | |||
bool Has(Handle<String> key); | bool Has(Handle<String> key); | |||
bool Delete(Handle<String> key); | bool Delete(Handle<String> key); | |||
// Delete a property on this object bypassing interceptors and | ||||
// ignoring dont-delete attributes. | ||||
bool ForceDelete(Handle<Value> key); | ||||
bool Has(uint32_t index); | bool Has(uint32_t index); | |||
bool Delete(uint32_t index); | bool Delete(uint32_t index); | |||
/** | /** | |||
* Returns an array containing the names of the enumerable properties | * Returns an array containing the names of the enumerable properties | |||
* of this object, including properties from prototype objects. The | * of this object, including properties from prototype objects. The | |||
* array returned by this method contains the same values as would | * array returned by this method contains the same values as would | |||
* be enumerated by a for-in statement over this object. | * be enumerated by a for-in statement over this object. | |||
*/ | */ | |||
Local<Array> GetPropertyNames(); | Local<Array> GetPropertyNames(); | |||
skipping to change at line 1046 | skipping to change at line 1093 | |||
*/ | */ | |||
Local<String> ObjectProtoToString(); | Local<String> ObjectProtoToString(); | |||
/** Gets the number of internal fields for this Object. */ | /** Gets the number of internal fields for this Object. */ | |||
int InternalFieldCount(); | int InternalFieldCount(); | |||
/** Gets the value in an internal field. */ | /** Gets the value in an internal field. */ | |||
Local<Value> GetInternalField(int index); | Local<Value> GetInternalField(int index); | |||
/** Sets the value in an internal field. */ | /** Sets the value in an internal field. */ | |||
void SetInternalField(int index, Handle<Value> value); | void SetInternalField(int index, Handle<Value> value); | |||
// The two functions below do not perform index bounds checks and | ||||
// they do not check that the VM is still running. Use with caution. | ||||
/** Gets a native pointer from an internal field. */ | ||||
void* GetPointerFromInternalField(int index); | ||||
/** Sets a native pointer in an internal field. */ | ||||
void SetPointerInInternalField(int index, void* value); | ||||
// Testers for local properties. | // Testers for local properties. | |||
bool HasRealNamedProperty(Handle<String> key); | bool HasRealNamedProperty(Handle<String> key); | |||
bool HasRealIndexedProperty(uint32_t index); | bool HasRealIndexedProperty(uint32_t index); | |||
bool HasRealNamedCallbackProperty(Handle<String> key); | bool HasRealNamedCallbackProperty(Handle<String> key); | |||
/** | /** | |||
* If result.IsEmpty() no real property was located in the prototype chai n. | * If result.IsEmpty() no real property was located in the prototype chai n. | |||
* This means interceptors in the prototype chain are not called. | * This means interceptors in the prototype chain are not called. | |||
*/ | */ | |||
Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); | Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); | |||
skipping to change at line 1073 | skipping to change at line 1127 | |||
/** | /** | |||
* Turns on access check on the object if the object is an instance of | * Turns on access check on the object if the object is an instance of | |||
* a template that has access check callbacks. If an object has no | * a template that has access check callbacks. If an object has no | |||
* access check info, the object cannot be accessed by anyone. | * access check info, the object cannot be accessed by anyone. | |||
*/ | */ | |||
void TurnOnAccessCheck(); | void TurnOnAccessCheck(); | |||
/** | /** | |||
* Returns the identity hash for this object. The current implemenation u ses | * Returns the identity hash for this object. The current implemenation u ses | |||
* a hidden property on the object to store the identity hash. | * a hidden property on the object to store the identity hash. | |||
* | ||||
* The return value will never be 0. Also, it is not guaranteed to be | ||||
* unique. | ||||
*/ | */ | |||
int GetIdentityHash(); | int GetIdentityHash(); | |||
/** | /** | |||
* Access hidden properties on JavaScript objects. These properties are | * Access hidden properties on JavaScript objects. These properties are | |||
* hidden from the executing JavaScript and only accessible through the V 8 | * hidden from the executing JavaScript and only accessible through the V 8 | |||
* C++ API. Hidden properties introduced by V8 internally (for example th e | * C++ API. Hidden properties introduced by V8 internally (for example th e | |||
* identity hash) are prefixed with "v8::". | * identity hash) are prefixed with "v8::". | |||
*/ | */ | |||
bool SetHiddenValue(Handle<String> key, Handle<Value> value); | bool SetHiddenValue(Handle<String> key, Handle<Value> value); | |||
Local<Value> GetHiddenValue(Handle<String> key); | Local<Value> GetHiddenValue(Handle<String> key); | |||
bool DeleteHiddenValue(Handle<String> key); | bool DeleteHiddenValue(Handle<String> key); | |||
/** | /** | |||
* Clone this object with a fast but shallow copy. Values will point | * Clone this object with a fast but shallow copy. Values will point | |||
* to the same values as the original object. | * to the same values as the original object. | |||
*/ | */ | |||
Local<Object> Clone(); | Local<Object> Clone(); | |||
/** | ||||
* Set the backing store of the indexed properties to be managed by the | ||||
* embedding layer. Access to the indexed properties will follow the rule | ||||
s | ||||
* spelled out in CanvasPixelArray. | ||||
* Note: The embedding program still owns the data and needs to ensure th | ||||
at | ||||
* the backing store is preserved while V8 has a reference. | ||||
*/ | ||||
void SetIndexedPropertiesToPixelData(uint8_t* data, int length); | ||||
static Local<Object> New(); | static Local<Object> New(); | |||
static Object* Cast(Value* obj); | static Object* Cast(Value* obj); | |||
private: | private: | |||
Object(); | Object(); | |||
}; | }; | |||
/** | /** | |||
* An instance of the built-in array constructor (ECMA-262, 15.4.2). | * An instance of the built-in array constructor (ECMA-262, 15.4.2). | |||
*/ | */ | |||
class V8EXPORT Array : public Object { | class V8EXPORT Array : public Object { | |||
public: | public: | |||
uint32_t Length() const; | uint32_t Length() const; | |||
/** | ||||
* Clones an element at index |index|. Returns an empty | ||||
* handle if cloning fails (for any reason). | ||||
*/ | ||||
Local<Object> CloneElementAt(uint32_t index); | ||||
static Local<Array> New(int length = 0); | static Local<Array> New(int length = 0); | |||
static Array* Cast(Value* obj); | static Array* Cast(Value* obj); | |||
private: | private: | |||
Array(); | Array(); | |||
}; | }; | |||
/** | /** | |||
* A JavaScript function object (ECMA-262, 15.3). | * A JavaScript function object (ECMA-262, 15.3). | |||
*/ | */ | |||
class V8EXPORT Function : public Object { | class V8EXPORT Function : public Object { | |||
skipping to change at line 1983 | skipping to change at line 2055 | |||
*/ | */ | |||
static void PauseProfiler(); | static void PauseProfiler(); | |||
/** | /** | |||
* Resumes recording of tick samples in the profiler. | * Resumes recording of tick samples in the profiler. | |||
* See also PauseProfiler(). | * See also PauseProfiler(). | |||
*/ | */ | |||
static void ResumeProfiler(); | static void ResumeProfiler(); | |||
/** | /** | |||
* Return whether profiler is currently paused. | ||||
*/ | ||||
static bool IsProfilerPaused(); | ||||
/** | ||||
* If logging is performed into a memory buffer (via --logfile=*), allows | ||||
to | ||||
* retrieve previously written messages. This can be used for retrieving | ||||
* profiler log data in the application. This function is thread-safe. | ||||
* | ||||
* Caller provides a destination buffer that must exist during GetLogLine | ||||
s | ||||
* call. Only whole log lines are copied into the buffer. | ||||
* | ||||
* \param from_pos specified a point in a buffer to read from, 0 is the | ||||
* beginning of a buffer. It is assumed that caller updates its current | ||||
* position using returned size value from the previous call. | ||||
* \param dest_buf destination buffer for log data. | ||||
* \param max_size size of the destination buffer. | ||||
* \returns actual size of log data copied into buffer. | ||||
*/ | ||||
static int GetLogLines(int from_pos, char* dest_buf, int max_size); | ||||
/** | ||||
* Releases any resources used by v8 and stops any utility threads | * Releases any resources used by v8 and stops any utility threads | |||
* that may be running. Note that disposing v8 is permanent, it | * that may be running. Note that disposing v8 is permanent, it | |||
* cannot be reinitialized. | * cannot be reinitialized. | |||
* | * | |||
* It should generally not be necessary to dispose v8 before exiting | * It should generally not be necessary to dispose v8 before exiting | |||
* a process, this should happen automatically. It is only necessary | * a process, this should happen automatically. It is only necessary | |||
* to use if the process needs the resources taken up by v8. | * to use if the process needs the resources taken up by v8. | |||
*/ | */ | |||
static bool Dispose(); | static bool Dispose(); | |||
skipping to change at line 2127 | skipping to change at line 2221 | |||
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | |||
Handle<Value> global_object = Handle<Value>()); | Handle<Value> global_object = Handle<Value>()); | |||
/** Returns the last entered context. */ | /** Returns the last entered context. */ | |||
static Local<Context> GetEntered(); | static Local<Context> GetEntered(); | |||
/** Returns the context that is on the top of the stack. */ | /** Returns the context that is on the top of the stack. */ | |||
static Local<Context> GetCurrent(); | static Local<Context> GetCurrent(); | |||
/** | /** | |||
* Returns the context of the calling JavaScript code. That is the | ||||
* context of the top-most JavaScript frame. If there are no | ||||
* JavaScript frames an empty handle is returned. | ||||
*/ | ||||
static Local<Context> GetCalling(); | ||||
/** | ||||
* Sets the security token for the context. To access an object in | * Sets the security token for the context. To access an object in | |||
* another context, the security tokens must match. | * another context, the security tokens must match. | |||
*/ | */ | |||
void SetSecurityToken(Handle<Value> token); | void SetSecurityToken(Handle<Value> token); | |||
/** Restores the security token to the default value. */ | /** Restores the security token to the default value. */ | |||
void UseDefaultSecurityToken(); | void UseDefaultSecurityToken(); | |||
/** Returns the security token of this context.*/ | /** Returns the security token of this context.*/ | |||
Handle<Value> GetSecurityToken(); | Handle<Value> GetSecurityToken(); | |||
skipping to change at line 2159 | skipping to change at line 2260 | |||
*/ | */ | |||
void Exit(); | void Exit(); | |||
/** Returns true if the context has experienced an out of memory situatio n. */ | /** Returns true if the context has experienced an out of memory situatio n. */ | |||
bool HasOutOfMemoryException(); | bool HasOutOfMemoryException(); | |||
/** Returns true if V8 has a current context. */ | /** Returns true if V8 has a current context. */ | |||
static bool InContext(); | static bool InContext(); | |||
/** | /** | |||
* Associate an additional data object with the context. This is mainly u | ||||
sed | ||||
* with the debugger to provide additional information on the context thr | ||||
ough | ||||
* the debugger API. | ||||
*/ | ||||
void SetData(Handle<Value> data); | ||||
Local<Value> GetData(); | ||||
/** | ||||
* Stack-allocated class which sets the execution context for all | * Stack-allocated class which sets the execution context for all | |||
* operations executed within a local scope. | * operations executed within a local scope. | |||
*/ | */ | |||
class V8EXPORT Scope { | class V8EXPORT Scope { | |||
public: | public: | |||
inline Scope(Handle<Context> context) : context_(context) { | inline Scope(Handle<Context> context) : context_(context) { | |||
context_->Enter(); | context_->Enter(); | |||
} | } | |||
inline ~Scope() { context_->Exit(); } | inline ~Scope() { context_->Exit(); } | |||
private: | private: | |||
skipping to change at line 2346 | skipping to change at line 2455 | |||
template <class T> | template <class T> | |||
void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) { | void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) { | |||
V8::MakeWeak(reinterpret_cast<void**>(**this), parameters, callback); | V8::MakeWeak(reinterpret_cast<void**>(**this), parameters, callback); | |||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::ClearWeak() { | void Persistent<T>::ClearWeak() { | |||
V8::ClearWeak(reinterpret_cast<void**>(**this)); | V8::ClearWeak(reinterpret_cast<void**>(**this)); | |||
} | } | |||
template <class T> | ||||
T* Handle<T>::operator->() const { | ||||
return val_; | ||||
} | ||||
template <class T> | ||||
T* Handle<T>::operator*() const { | ||||
return val_; | ||||
} | ||||
Local<Value> Arguments::operator[](int i) const { | Local<Value> Arguments::operator[](int i) const { | |||
if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); | if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); | |||
return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | |||
} | } | |||
Local<Function> Arguments::Callee() const { | Local<Function> Arguments::Callee() const { | |||
return callee_; | return callee_; | |||
} | } | |||
Local<Object> Arguments::This() const { | Local<Object> Arguments::This() const { | |||
End of changes. 21 change blocks. | ||||
17 lines changed or deleted | 125 lines changed or added | |||