| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 * dereferencing the handle (for instance, to extract the Object* from | 204 * dereferencing the handle (for instance, to extract the Object* from |
| 205 * a Handle<Object>); the value will still be governed by a handle | 205 * a Handle<Object>); the value will still be governed by a handle |
| 206 * behind the scenes and the same rules apply to these values as to | 206 * behind the scenes and the same rules apply to these values as to |
| 207 * their handles. | 207 * their handles. |
| 208 */ | 208 */ |
| 209 template <class T> class Handle { | 209 template <class T> class Handle { |
| 210 public: | 210 public: |
| 211 /** | 211 /** |
| 212 * Creates an empty handle. | 212 * Creates an empty handle. |
| 213 */ | 213 */ |
| 214 V8_INLINE(Handle()) : val_(0) {} | 214 V8_INLINE Handle() : val_(0) {} |
| 215 | 215 |
| 216 /** | 216 /** |
| 217 * Creates a handle for the contents of the specified handle. This | 217 * Creates a handle for the contents of the specified handle. This |
| 218 * constructor allows you to pass handles as arguments by value and | 218 * constructor allows you to pass handles as arguments by value and |
| 219 * to assign between handles. However, if you try to assign between | 219 * to assign between handles. However, if you try to assign between |
| 220 * incompatible handles, for instance from a Handle<String> to a | 220 * incompatible handles, for instance from a Handle<String> to a |
| 221 * Handle<Number> it will cause a compile-time error. Assigning | 221 * Handle<Number> it will cause a compile-time error. Assigning |
| 222 * between compatible handles, for instance assigning a | 222 * between compatible handles, for instance assigning a |
| 223 * Handle<String> to a variable declared as Handle<Value>, is legal | 223 * Handle<String> to a variable declared as Handle<Value>, is legal |
| 224 * because String is a subclass of Value. | 224 * because String is a subclass of Value. |
| 225 */ | 225 */ |
| 226 template <class S> V8_INLINE(Handle(Handle<S> that)) | 226 template <class S> V8_INLINE Handle(Handle<S> that) |
| 227 : val_(reinterpret_cast<T*>(*that)) { | 227 : val_(reinterpret_cast<T*>(*that)) { |
| 228 /** | 228 /** |
| 229 * This check fails when trying to convert between incompatible | 229 * This check fails when trying to convert between incompatible |
| 230 * handles. For example, converting from a Handle<String> to a | 230 * handles. For example, converting from a Handle<String> to a |
| 231 * Handle<Number>. | 231 * Handle<Number>. |
| 232 */ | 232 */ |
| 233 TYPE_CHECK(T, S); | 233 TYPE_CHECK(T, S); |
| 234 } | 234 } |
| 235 | 235 |
| 236 /** | 236 /** |
| 237 * Returns true if the handle is empty. | 237 * Returns true if the handle is empty. |
| 238 */ | 238 */ |
| 239 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } | 239 V8_INLINE bool IsEmpty() const { return val_ == 0; } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Sets the handle to be empty. IsEmpty() will then return true. | 242 * Sets the handle to be empty. IsEmpty() will then return true. |
| 243 */ | 243 */ |
| 244 V8_INLINE(void Clear()) { val_ = 0; } | 244 V8_INLINE void Clear() { val_ = 0; } |
| 245 | 245 |
| 246 V8_INLINE(T* operator->() const) { return val_; } | 246 V8_INLINE T* operator->() const { return val_; } |
| 247 | 247 |
| 248 V8_INLINE(T* operator*() const) { return val_; } | 248 V8_INLINE T* operator*() const { return val_; } |
| 249 | 249 |
| 250 /** | 250 /** |
| 251 * Checks whether two handles are the same. | 251 * Checks whether two handles are the same. |
| 252 * Returns true if both are empty, or if the objects | 252 * Returns true if both are empty, or if the objects |
| 253 * to which they refer are identical. | 253 * to which they refer are identical. |
| 254 * The handles' references are not checked. | 254 * The handles' references are not checked. |
| 255 */ | 255 */ |
| 256 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { | 256 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { |
| 257 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 257 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 258 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 258 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 259 if (a == 0) return b == 0; | 259 if (a == 0) return b == 0; |
| 260 if (b == 0) return false; | 260 if (b == 0) return false; |
| 261 return *a == *b; | 261 return *a == *b; |
| 262 } | 262 } |
| 263 | 263 |
| 264 template <class S> V8_INLINE( | 264 template <class S> V8_INLINE bool operator==( |
| 265 bool operator==(const Persistent<S>& that) const) { | 265 const Persistent<S>& that) const { |
| 266 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 266 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 267 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 267 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 268 if (a == 0) return b == 0; | 268 if (a == 0) return b == 0; |
| 269 if (b == 0) return false; | 269 if (b == 0) return false; |
| 270 return *a == *b; | 270 return *a == *b; |
| 271 } | 271 } |
| 272 | 272 |
| 273 /** | 273 /** |
| 274 * Checks whether two handles are different. | 274 * Checks whether two handles are different. |
| 275 * Returns true if only one of the handles is empty, or if | 275 * Returns true if only one of the handles is empty, or if |
| 276 * the objects to which they refer are different. | 276 * the objects to which they refer are different. |
| 277 * The handles' references are not checked. | 277 * The handles' references are not checked. |
| 278 */ | 278 */ |
| 279 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { | 279 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const { |
| 280 return !operator==(that); | 280 return !operator==(that); |
| 281 } | 281 } |
| 282 | 282 |
| 283 template <class S> V8_INLINE( | 283 template <class S> V8_INLINE bool operator!=( |
| 284 bool operator!=(const Persistent<S>& that) const) { | 284 const Persistent<S>& that) const { |
| 285 return !operator==(that); | 285 return !operator==(that); |
| 286 } | 286 } |
| 287 | 287 |
| 288 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { | 288 template <class S> V8_INLINE static Handle<T> Cast(Handle<S> that) { |
| 289 #ifdef V8_ENABLE_CHECKS | 289 #ifdef V8_ENABLE_CHECKS |
| 290 // If we're going to perform the type check then we have to check | 290 // If we're going to perform the type check then we have to check |
| 291 // that the handle isn't empty before doing the checked cast. | 291 // that the handle isn't empty before doing the checked cast. |
| 292 if (that.IsEmpty()) return Handle<T>(); | 292 if (that.IsEmpty()) return Handle<T>(); |
| 293 #endif | 293 #endif |
| 294 return Handle<T>(T::Cast(*that)); | 294 return Handle<T>(T::Cast(*that)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 template <class S> V8_INLINE(Handle<S> As()) { | 297 template <class S> V8_INLINE Handle<S> As() { |
| 298 return Handle<S>::Cast(*this); | 298 return Handle<S>::Cast(*this); |
| 299 } | 299 } |
| 300 | 300 |
| 301 V8_INLINE(static Handle<T> New(Isolate* isolate, Handle<T> that)) { | 301 V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) { |
| 302 return New(isolate, that.val_); | 302 return New(isolate, that.val_); |
| 303 } | 303 } |
| 304 V8_INLINE(static Handle<T> New(Isolate* isolate, const Persistent<T>& that)) { | 304 V8_INLINE static Handle<T> New(Isolate* isolate, const Persistent<T>& that) { |
| 305 return New(isolate, that.val_); | 305 return New(isolate, that.val_); |
| 306 } | 306 } |
| 307 | 307 |
| 308 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 308 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 309 | 309 |
| 310 private: | 310 private: |
| 311 #endif | 311 #endif |
| 312 /** | 312 /** |
| 313 * Creates a new handle for the specified value. | 313 * Creates a new handle for the specified value. |
| 314 */ | 314 */ |
| 315 V8_INLINE(explicit Handle(T* val)) : val_(val) {} | 315 V8_INLINE explicit Handle(T* val) : val_(val) {} |
| 316 | 316 |
| 317 private: | 317 private: |
| 318 friend class Utils; | 318 friend class Utils; |
| 319 template<class F, class M> friend class Persistent; | 319 template<class F, class M> friend class Persistent; |
| 320 template<class F> friend class Local; | 320 template<class F> friend class Local; |
| 321 template<class F> friend class FunctionCallbackInfo; | 321 template<class F> friend class FunctionCallbackInfo; |
| 322 template<class F> friend class PropertyCallbackInfo; | 322 template<class F> friend class PropertyCallbackInfo; |
| 323 template<class F> friend class internal::CustomArguments; | 323 template<class F> friend class internal::CustomArguments; |
| 324 friend Handle<Primitive> Undefined(Isolate* isolate); | 324 friend Handle<Primitive> Undefined(Isolate* isolate); |
| 325 friend Handle<Primitive> Null(Isolate* isolate); | 325 friend Handle<Primitive> Null(Isolate* isolate); |
| 326 friend Handle<Boolean> True(Isolate* isolate); | 326 friend Handle<Boolean> True(Isolate* isolate); |
| 327 friend Handle<Boolean> False(Isolate* isolate); | 327 friend Handle<Boolean> False(Isolate* isolate); |
| 328 friend class Context; | 328 friend class Context; |
| 329 friend class HandleScope; | 329 friend class HandleScope; |
| 330 | 330 |
| 331 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); | 331 V8_INLINE static Handle<T> New(Isolate* isolate, T* that); |
| 332 | 332 |
| 333 T* val_; | 333 T* val_; |
| 334 }; | 334 }; |
| 335 | 335 |
| 336 | 336 |
| 337 /** | 337 /** |
| 338 * A light-weight stack-allocated object handle. All operations | 338 * A light-weight stack-allocated object handle. All operations |
| 339 * that return objects from within v8 return them in local handles. They | 339 * that return objects from within v8 return them in local handles. They |
| 340 * are created within HandleScopes, and all local handles allocated within a | 340 * are created within HandleScopes, and all local handles allocated within a |
| 341 * handle scope are destroyed when the handle scope is destroyed. Hence it | 341 * handle scope are destroyed when the handle scope is destroyed. Hence it |
| 342 * is not necessary to explicitly deallocate local handles. | 342 * is not necessary to explicitly deallocate local handles. |
| 343 */ | 343 */ |
| 344 template <class T> class Local : public Handle<T> { | 344 template <class T> class Local : public Handle<T> { |
| 345 public: | 345 public: |
| 346 V8_INLINE(Local()); | 346 V8_INLINE Local(); |
| 347 template <class S> V8_INLINE(Local(Local<S> that)) | 347 template <class S> V8_INLINE Local(Local<S> that) |
| 348 : Handle<T>(reinterpret_cast<T*>(*that)) { | 348 : Handle<T>(reinterpret_cast<T*>(*that)) { |
| 349 /** | 349 /** |
| 350 * This check fails when trying to convert between incompatible | 350 * This check fails when trying to convert between incompatible |
| 351 * handles. For example, converting from a Handle<String> to a | 351 * handles. For example, converting from a Handle<String> to a |
| 352 * Handle<Number>. | 352 * Handle<Number>. |
| 353 */ | 353 */ |
| 354 TYPE_CHECK(T, S); | 354 TYPE_CHECK(T, S); |
| 355 } | 355 } |
| 356 | 356 |
| 357 | 357 |
| 358 template <class S> V8_INLINE(static Local<T> Cast(Local<S> that)) { | 358 template <class S> V8_INLINE static Local<T> Cast(Local<S> that) { |
| 359 #ifdef V8_ENABLE_CHECKS | 359 #ifdef V8_ENABLE_CHECKS |
| 360 // If we're going to perform the type check then we have to check | 360 // If we're going to perform the type check then we have to check |
| 361 // that the handle isn't empty before doing the checked cast. | 361 // that the handle isn't empty before doing the checked cast. |
| 362 if (that.IsEmpty()) return Local<T>(); | 362 if (that.IsEmpty()) return Local<T>(); |
| 363 #endif | 363 #endif |
| 364 return Local<T>(T::Cast(*that)); | 364 return Local<T>(T::Cast(*that)); |
| 365 } | 365 } |
| 366 template <class S> V8_INLINE(Local(Handle<S> that)) | 366 template <class S> V8_INLINE Local(Handle<S> that) |
| 367 : Handle<T>(reinterpret_cast<T*>(*that)) { | 367 : Handle<T>(reinterpret_cast<T*>(*that)) { |
| 368 TYPE_CHECK(T, S); | 368 TYPE_CHECK(T, S); |
| 369 } | 369 } |
| 370 | 370 |
| 371 template <class S> V8_INLINE(Local<S> As()) { | 371 template <class S> V8_INLINE Local<S> As() { |
| 372 return Local<S>::Cast(*this); | 372 return Local<S>::Cast(*this); |
| 373 } | 373 } |
| 374 | 374 |
| 375 /** | 375 /** |
| 376 * Create a local handle for the content of another handle. | 376 * Create a local handle for the content of another handle. |
| 377 * The referee is kept alive by the local handle even when | 377 * The referee is kept alive by the local handle even when |
| 378 * the original handle is destroyed/disposed. | 378 * the original handle is destroyed/disposed. |
| 379 */ | 379 */ |
| 380 V8_INLINE(static Local<T> New(Handle<T> that)); | 380 V8_INLINE static Local<T> New(Handle<T> that); |
| 381 V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); | 381 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); |
| 382 template<class M> | 382 template<class M> |
| 383 V8_INLINE(static Local<T> New(Isolate* isolate, | 383 V8_INLINE static Local<T> New(Isolate* isolate, |
| 384 const Persistent<T, M>& that)); | 384 const Persistent<T, M>& that); |
| 385 | 385 |
| 386 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 386 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 387 | 387 |
| 388 private: | 388 private: |
| 389 #endif | 389 #endif |
| 390 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } | 390 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } |
| 391 | 391 |
| 392 private: | 392 private: |
| 393 friend class Utils; | 393 friend class Utils; |
| 394 template<class F> friend class Eternal; | 394 template<class F> friend class Eternal; |
| 395 template<class F, class M> friend class Persistent; | 395 template<class F, class M> friend class Persistent; |
| 396 template<class F> friend class Handle; | 396 template<class F> friend class Handle; |
| 397 template<class F> friend class FunctionCallbackInfo; | 397 template<class F> friend class FunctionCallbackInfo; |
| 398 template<class F> friend class PropertyCallbackInfo; | 398 template<class F> friend class PropertyCallbackInfo; |
| 399 friend class String; | 399 friend class String; |
| 400 friend class Object; | 400 friend class Object; |
| 401 friend class Context; | 401 friend class Context; |
| 402 template<class F> friend class internal::CustomArguments; | 402 template<class F> friend class internal::CustomArguments; |
| 403 friend class HandleScope; | 403 friend class HandleScope; |
| 404 | 404 |
| 405 V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); | 405 V8_INLINE static Local<T> New(Isolate* isolate, T* that); |
| 406 }; | 406 }; |
| 407 | 407 |
| 408 | 408 |
| 409 // Eternal handles are set-once handles that live for the life of the isolate. | 409 // Eternal handles are set-once handles that live for the life of the isolate. |
| 410 template <class T> class Eternal { | 410 template <class T> class Eternal { |
| 411 public: | 411 public: |
| 412 V8_INLINE(Eternal()) : index_(kInitialValue) { } | 412 V8_INLINE Eternal() : index_(kInitialValue) { } |
| 413 template<class S> | 413 template<class S> |
| 414 V8_INLINE(Eternal(Isolate* isolate, Local<S> handle)) | 414 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { |
| 415 : index_(kInitialValue) { | |
| 416 Set(isolate, handle); | 415 Set(isolate, handle); |
| 417 } | 416 } |
| 418 // Can only be safely called if already set. | 417 // Can only be safely called if already set. |
| 419 V8_INLINE(Local<T> Get(Isolate* isolate)); | 418 V8_INLINE Local<T> Get(Isolate* isolate); |
| 420 V8_INLINE(bool IsEmpty()) { return index_ == kInitialValue; } | 419 V8_INLINE bool IsEmpty() { return index_ == kInitialValue; } |
| 421 template<class S> | 420 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle); |
| 422 V8_INLINE(void Set(Isolate* isolate, Local<S> handle)); | |
| 423 | 421 |
| 424 private: | 422 private: |
| 425 static const int kInitialValue = -1; | 423 static const int kInitialValue = -1; |
| 426 int index_; | 424 int index_; |
| 427 }; | 425 }; |
| 428 | 426 |
| 429 | 427 |
| 430 template<class T, class P> | 428 template<class T, class P> |
| 431 class WeakCallbackData { | 429 class WeakCallbackData { |
| 432 public: | 430 public: |
| 433 typedef void (*Callback)(const WeakCallbackData<T, P>& data); | 431 typedef void (*Callback)(const WeakCallbackData<T, P>& data); |
| 434 | 432 |
| 435 V8_INLINE(Isolate* GetIsolate()) const { return isolate_; } | 433 V8_INLINE Isolate* GetIsolate() const { return isolate_; } |
| 436 V8_INLINE(Local<T> GetValue()) const { return handle_; } | 434 V8_INLINE Local<T> GetValue() const { return handle_; } |
| 437 V8_INLINE(P* GetParameter()) const { return parameter_; } | 435 V8_INLINE P* GetParameter() const { return parameter_; } |
| 438 | 436 |
| 439 private: | 437 private: |
| 440 friend class internal::GlobalHandles; | 438 friend class internal::GlobalHandles; |
| 441 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) | 439 WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) |
| 442 : isolate_(isolate), handle_(handle), parameter_(parameter) { } | 440 : isolate_(isolate), handle_(handle), parameter_(parameter) { } |
| 443 Isolate* isolate_; | 441 Isolate* isolate_; |
| 444 Local<T> handle_; | 442 Local<T> handle_; |
| 445 P* parameter_; | 443 P* parameter_; |
| 446 }; | 444 }; |
| 447 | 445 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 463 * use of the copy constructor or assignment operator. | 461 * use of the copy constructor or assignment operator. |
| 464 * At present kResetInDestructor is not set, but that will change in a future | 462 * At present kResetInDestructor is not set, but that will change in a future |
| 465 * version. | 463 * version. |
| 466 */ | 464 */ |
| 467 template<class T> | 465 template<class T> |
| 468 class NonCopyablePersistentTraits { | 466 class NonCopyablePersistentTraits { |
| 469 public: | 467 public: |
| 470 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; | 468 typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; |
| 471 static const bool kResetInDestructor = false; | 469 static const bool kResetInDestructor = false; |
| 472 template<class S, class M> | 470 template<class S, class M> |
| 473 V8_INLINE(static void Copy(const Persistent<S, M>& source, | 471 V8_INLINE static void Copy(const Persistent<S, M>& source, |
| 474 NonCopyablePersistent* dest)) { | 472 NonCopyablePersistent* dest) { |
| 475 Uncompilable<Object>(); | 473 Uncompilable<Object>(); |
| 476 } | 474 } |
| 477 // TODO(dcarney): come up with a good compile error here. | 475 // TODO(dcarney): come up with a good compile error here. |
| 478 template<class O> | 476 template<class O> V8_INLINE static void Uncompilable() { |
| 479 V8_INLINE(static void Uncompilable()) { | |
| 480 TYPE_CHECK(O, Primitive); | 477 TYPE_CHECK(O, Primitive); |
| 481 } | 478 } |
| 482 }; | 479 }; |
| 483 | 480 |
| 484 | 481 |
| 485 /** | 482 /** |
| 486 * An object reference that is independent of any handle scope. Where | 483 * An object reference that is independent of any handle scope. Where |
| 487 * a Local handle only lives as long as the HandleScope in which it was | 484 * a Local handle only lives as long as the HandleScope in which it was |
| 488 * allocated, a Persistent handle remains valid until it is explicitly | 485 * allocated, a Persistent handle remains valid until it is explicitly |
| 489 * disposed. | 486 * disposed. |
| 490 * | 487 * |
| 491 * A persistent handle contains a reference to a storage cell within | 488 * A persistent handle contains a reference to a storage cell within |
| 492 * the v8 engine which holds an object value and which is updated by | 489 * the v8 engine which holds an object value and which is updated by |
| 493 * the garbage collector whenever the object is moved. A new storage | 490 * the garbage collector whenever the object is moved. A new storage |
| 494 * cell can be created using the constructor or Persistent::Reset and | 491 * cell can be created using the constructor or Persistent::Reset and |
| 495 * existing handles can be disposed using Persistent::Reset. | 492 * existing handles can be disposed using Persistent::Reset. |
| 496 * | 493 * |
| 497 * Copy, assignment and destructor bevavior is controlled by the traits | 494 * Copy, assignment and destructor bevavior is controlled by the traits |
| 498 * class M. | 495 * class M. |
| 499 */ | 496 */ |
| 500 template <class T, class M> class Persistent { | 497 template <class T, class M> class Persistent { |
| 501 public: | 498 public: |
| 502 /** | 499 /** |
| 503 * A Persistent with no storage cell. | 500 * A Persistent with no storage cell. |
| 504 */ | 501 */ |
| 505 V8_INLINE(Persistent()) : val_(0) { } | 502 V8_INLINE Persistent() : val_(0) { } |
| 506 /** | 503 /** |
| 507 * Construct a Persistent from a Handle. | 504 * Construct a Persistent from a Handle. |
| 508 * When the Handle is non-empty, a new storage cell is created | 505 * When the Handle is non-empty, a new storage cell is created |
| 509 * pointing to the same object, and no flags are set. | 506 * pointing to the same object, and no flags are set. |
| 510 */ | 507 */ |
| 511 template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that)) | 508 template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that) |
| 512 : val_(New(isolate, *that)) { | 509 : val_(New(isolate, *that)) { |
| 513 TYPE_CHECK(T, S); | 510 TYPE_CHECK(T, S); |
| 514 } | 511 } |
| 515 /** | 512 /** |
| 516 * Construct a Persistent from a Persistent. | 513 * Construct a Persistent from a Persistent. |
| 517 * When the Persistent is non-empty, a new storage cell is created | 514 * When the Persistent is non-empty, a new storage cell is created |
| 518 * pointing to the same object, and no flags are set. | 515 * pointing to the same object, and no flags are set. |
| 519 */ | 516 */ |
| 520 template <class S, class M2> | 517 template <class S, class M2> |
| 521 V8_INLINE(Persistent(Isolate* isolate, const Persistent<S, M2>& that)) | 518 V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that) |
| 522 : val_(New(isolate, *that)) { | 519 : val_(New(isolate, *that)) { |
| 523 TYPE_CHECK(T, S); | 520 TYPE_CHECK(T, S); |
| 524 } | 521 } |
| 525 /** | 522 /** |
| 526 * The copy constructors and assignment operator create a Persistent | 523 * The copy constructors and assignment operator create a Persistent |
| 527 * exactly as the Persistent constructor, but the Copy function from the | 524 * exactly as the Persistent constructor, but the Copy function from the |
| 528 * traits class is called, allowing the setting of flags based on the | 525 * traits class is called, allowing the setting of flags based on the |
| 529 * copied Persistent. | 526 * copied Persistent. |
| 530 */ | 527 */ |
| 531 V8_INLINE(Persistent(const Persistent& that)) : val_(0) { | 528 V8_INLINE Persistent(const Persistent& that) : val_(0) { |
| 532 Copy(that); | 529 Copy(that); |
| 533 } | 530 } |
| 534 template <class S, class M2> | 531 template <class S, class M2> |
| 535 V8_INLINE(Persistent(const Persistent<S, M2>& that)) : val_(0) { | 532 V8_INLINE Persistent(const Persistent<S, M2>& that) : val_(0) { |
| 536 Copy(that); | 533 Copy(that); |
| 537 } | 534 } |
| 538 V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | 535 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT |
| 539 Copy(that); | 536 Copy(that); |
| 540 return *this; | 537 return *this; |
| 541 } | 538 } |
| 542 template <class S, class M2> | 539 template <class S, class M2> |
| 543 V8_INLINE(Persistent& operator=(const Persistent<S, M2>& that)) { // NOLINT | 540 V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT |
| 544 Copy(that); | 541 Copy(that); |
| 545 return *this; | 542 return *this; |
| 546 } | 543 } |
| 544 /** |
| 545 * The destructor will dispose the Persistent based on the |
| 546 * kResetInDestructor flags in the traits class. Since not calling dispose |
| 547 * can result in a memory leak, it is recommended to always set this flag. |
| 548 */ |
| 549 V8_INLINE ~Persistent() { |
| 550 if (M::kResetInDestructor) Reset(); |
| 551 } |
| 547 | 552 |
| 548 /** | 553 /** |
| 549 * If non-empty, destroy the underlying storage cell | 554 * If non-empty, destroy the underlying storage cell |
| 550 * IsEmpty() will return true after this call. | 555 * IsEmpty() will return true after this call. |
| 551 */ | 556 */ |
| 552 V8_INLINE(void Reset()); | 557 V8_INLINE void Reset(); |
| 553 template <class S> | |
| 554 /** | 558 /** |
| 555 * If non-empty, destroy the underlying storage cell | 559 * If non-empty, destroy the underlying storage cell |
| 556 * and create a new one with the contents of other if other is non empty | 560 * and create a new one with the contents of other if other is non empty |
| 557 */ | 561 */ |
| 558 V8_INLINE(void Reset(Isolate* isolate, const Handle<S>& other)); | 562 template <class S> |
| 563 V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other); |
| 559 /** | 564 /** |
| 560 * If non-empty, destroy the underlying storage cell | 565 * If non-empty, destroy the underlying storage cell |
| 561 * and create a new one with the contents of other if other is non empty | 566 * and create a new one with the contents of other if other is non empty |
| 562 */ | 567 */ |
| 563 template <class S, class M2> | 568 template <class S, class M2> |
| 564 V8_INLINE(void Reset(Isolate* isolate, const Persistent<S, M2>& other)); | 569 V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other); |
| 565 // TODO(dcarney): deprecate | 570 // TODO(dcarney): deprecate |
| 566 V8_INLINE(void Dispose()) { Reset(); } | 571 V8_INLINE void Dispose() { Reset(); } |
| 567 V8_DEPRECATED(V8_INLINE(void Dispose(Isolate* isolate))) { Reset(); } | 572 V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); } |
| 568 | 573 |
| 569 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } | 574 V8_INLINE bool IsEmpty() const { return val_ == 0; } |
| 570 | 575 |
| 571 // TODO(dcarney): this is pretty useless, fix or remove | 576 // TODO(dcarney): this is pretty useless, fix or remove |
| 572 template <class S> | 577 template <class S> |
| 573 V8_INLINE(static Persistent<T>& Cast(Persistent<S>& that)) { // NOLINT | 578 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT |
| 574 #ifdef V8_ENABLE_CHECKS | 579 #ifdef V8_ENABLE_CHECKS |
| 575 // If we're going to perform the type check then we have to check | 580 // If we're going to perform the type check then we have to check |
| 576 // that the handle isn't empty before doing the checked cast. | 581 // that the handle isn't empty before doing the checked cast. |
| 577 if (!that.IsEmpty()) T::Cast(*that); | 582 if (!that.IsEmpty()) T::Cast(*that); |
| 578 #endif | 583 #endif |
| 579 return reinterpret_cast<Persistent<T>&>(that); | 584 return reinterpret_cast<Persistent<T>&>(that); |
| 580 } | 585 } |
| 581 | 586 |
| 582 // TODO(dcarney): this is pretty useless, fix or remove | 587 // TODO(dcarney): this is pretty useless, fix or remove |
| 583 template <class S> V8_INLINE(Persistent<S>& As()) { // NOLINT | 588 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT |
| 584 return Persistent<S>::Cast(*this); | 589 return Persistent<S>::Cast(*this); |
| 585 } | 590 } |
| 586 | 591 |
| 587 template <class S, class M2> V8_INLINE( | 592 template <class S, class M2> |
| 588 bool operator==(const Persistent<S, M2>& that) const) { | 593 V8_INLINE bool operator==(const Persistent<S, M2>& that) const { |
| 589 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 594 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 590 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 595 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 591 if (a == 0) return b == 0; | 596 if (a == 0) return b == 0; |
| 592 if (b == 0) return false; | 597 if (b == 0) return false; |
| 593 return *a == *b; | 598 return *a == *b; |
| 594 } | 599 } |
| 595 | 600 |
| 596 template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const) { | 601 template <class S> V8_INLINE bool operator==(const Handle<S>& that) const { |
| 597 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 602 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
| 598 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 603 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
| 599 if (a == 0) return b == 0; | 604 if (a == 0) return b == 0; |
| 600 if (b == 0) return false; | 605 if (b == 0) return false; |
| 601 return *a == *b; | 606 return *a == *b; |
| 602 } | 607 } |
| 603 | 608 |
| 604 template <class S, class M2> V8_INLINE( | 609 template <class S, class M2> |
| 605 bool operator!=(const Persistent<S, M2>& that) const) { | 610 V8_INLINE bool operator!=(const Persistent<S, M2>& that) const { |
| 606 return !operator==(that); | 611 return !operator==(that); |
| 607 } | 612 } |
| 608 | 613 |
| 609 template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const) { | 614 template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const { |
| 610 return !operator==(that); | 615 return !operator==(that); |
| 611 } | 616 } |
| 612 | 617 |
| 613 template<typename P> | 618 template<typename P> |
| 614 V8_INLINE(void SetWeak( | 619 V8_INLINE void SetWeak( |
| 615 P* parameter, | 620 P* parameter, |
| 616 typename WeakCallbackData<T, P>::Callback callback)); | 621 typename WeakCallbackData<T, P>::Callback callback); |
| 617 | 622 |
| 618 template<typename S, typename P> | 623 template<typename S, typename P> |
| 619 V8_INLINE(void SetWeak( | 624 V8_INLINE void SetWeak( |
| 620 P* parameter, | 625 P* parameter, |
| 621 typename WeakCallbackData<S, P>::Callback callback)); | 626 typename WeakCallbackData<S, P>::Callback callback); |
| 622 | 627 |
| 623 // TODO(dcarney): deprecate | 628 // TODO(dcarney): deprecate |
| 624 template<typename S, typename P> | 629 template<typename S, typename P> |
| 625 V8_INLINE(void MakeWeak( | 630 V8_INLINE void MakeWeak( |
| 626 P* parameter, | 631 P* parameter, |
| 627 typename WeakReferenceCallbacks<S, P>::Revivable callback)); | 632 typename WeakReferenceCallbacks<S, P>::Revivable callback); |
| 628 | 633 |
| 629 // TODO(dcarney): deprecate | 634 // TODO(dcarney): deprecate |
| 630 template<typename P> | 635 template<typename P> |
| 631 V8_INLINE(void MakeWeak( | 636 V8_INLINE void MakeWeak( |
| 632 P* parameter, | 637 P* parameter, |
| 633 typename WeakReferenceCallbacks<T, P>::Revivable callback)); | 638 typename WeakReferenceCallbacks<T, P>::Revivable callback); |
| 634 | 639 |
| 635 V8_INLINE(void ClearWeak()); | 640 V8_INLINE void ClearWeak(); |
| 636 | 641 |
| 637 V8_DEPRECATED(V8_INLINE(void ClearWeak(Isolate* isolate))) { ClearWeak(); } | 642 V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); } |
| 638 | 643 |
| 639 /** | 644 /** |
| 640 * Marks the reference to this object independent. Garbage collector is free | 645 * Marks the reference to this object independent. Garbage collector is free |
| 641 * to ignore any object groups containing this object. Weak callback for an | 646 * to ignore any object groups containing this object. Weak callback for an |
| 642 * independent handle should not assume that it will be preceded by a global | 647 * independent handle should not assume that it will be preceded by a global |
| 643 * GC prologue callback or followed by a global GC epilogue callback. | 648 * GC prologue callback or followed by a global GC epilogue callback. |
| 644 */ | 649 */ |
| 645 V8_INLINE(void MarkIndependent()); | 650 V8_INLINE void MarkIndependent(); |
| 646 | 651 |
| 647 V8_DEPRECATED(V8_INLINE(void MarkIndependent(Isolate* isolate))) { | 652 V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) { |
| 648 MarkIndependent(); | 653 MarkIndependent(); |
| 649 } | 654 } |
| 650 | 655 |
| 651 /** | 656 /** |
| 652 * Marks the reference to this object partially dependent. Partially dependent | 657 * Marks the reference to this object partially dependent. Partially dependent |
| 653 * handles only depend on other partially dependent handles and these | 658 * handles only depend on other partially dependent handles and these |
| 654 * dependencies are provided through object groups. It provides a way to build | 659 * dependencies are provided through object groups. It provides a way to build |
| 655 * smaller object groups for young objects that represent only a subset of all | 660 * smaller object groups for young objects that represent only a subset of all |
| 656 * external dependencies. This mark is automatically cleared after each | 661 * external dependencies. This mark is automatically cleared after each |
| 657 * garbage collection. | 662 * garbage collection. |
| 658 */ | 663 */ |
| 659 V8_INLINE(void MarkPartiallyDependent()); | 664 V8_INLINE void MarkPartiallyDependent(); |
| 660 | 665 |
| 661 V8_DEPRECATED(V8_INLINE(void MarkPartiallyDependent(Isolate* isolate))) { | 666 V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) { |
| 662 MarkPartiallyDependent(); | 667 MarkPartiallyDependent(); |
| 663 } | 668 } |
| 664 | 669 |
| 665 V8_INLINE(bool IsIndependent() const); | 670 V8_INLINE bool IsIndependent() const; |
| 666 | 671 |
| 667 V8_DEPRECATED(V8_INLINE(bool IsIndependent(Isolate* isolate)) const) { | 672 V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) { |
| 668 return IsIndependent(); | 673 return IsIndependent(); |
| 669 } | 674 } |
| 670 | 675 |
| 671 /** Checks if the handle holds the only reference to an object. */ | 676 /** Checks if the handle holds the only reference to an object. */ |
| 672 V8_INLINE(bool IsNearDeath() const); | 677 V8_INLINE bool IsNearDeath() const; |
| 673 | 678 |
| 674 V8_DEPRECATED(V8_INLINE(bool IsNearDeath(Isolate* isolate)) const) { | 679 V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) { |
| 675 return IsNearDeath(); | 680 return IsNearDeath(); |
| 676 } | 681 } |
| 677 | 682 |
| 678 /** Returns true if the handle's reference is weak. */ | 683 /** Returns true if the handle's reference is weak. */ |
| 679 V8_INLINE(bool IsWeak() const); | 684 V8_INLINE bool IsWeak() const; |
| 680 | 685 |
| 681 V8_DEPRECATED(V8_INLINE(bool IsWeak(Isolate* isolate)) const) { | 686 V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) { |
| 682 return IsWeak(); | 687 return IsWeak(); |
| 683 } | 688 } |
| 684 | 689 |
| 685 /** | 690 /** |
| 686 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface | 691 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface |
| 687 * description in v8-profiler.h for details. | 692 * description in v8-profiler.h for details. |
| 688 */ | 693 */ |
| 689 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); | 694 V8_INLINE void SetWrapperClassId(uint16_t class_id); |
| 690 | 695 |
| 691 V8_DEPRECATED( | 696 V8_DEPRECATED( |
| 692 V8_INLINE(void SetWrapperClassId(Isolate * isolate, uint16_t class_id))) { | 697 V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id)) { |
| 693 SetWrapperClassId(class_id); | 698 SetWrapperClassId(class_id); |
| 694 } | 699 } |
| 695 | 700 |
| 696 /** | 701 /** |
| 697 * Returns the class ID previously assigned to this handle or 0 if no class ID | 702 * Returns the class ID previously assigned to this handle or 0 if no class ID |
| 698 * was previously assigned. | 703 * was previously assigned. |
| 699 */ | 704 */ |
| 700 V8_INLINE(uint16_t WrapperClassId() const); | 705 V8_INLINE uint16_t WrapperClassId() const; |
| 701 | 706 |
| 702 V8_DEPRECATED(V8_INLINE(uint16_t WrapperClassId(Isolate* isolate)) const) { | 707 V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) { |
| 703 return WrapperClassId(); | 708 return WrapperClassId(); |
| 704 } | 709 } |
| 705 | 710 |
| 706 // TODO(dcarney): remove | 711 // TODO(dcarney): remove |
| 707 V8_INLINE(T* ClearAndLeak()); | 712 V8_INLINE T* ClearAndLeak(); |
| 708 | 713 |
| 709 // TODO(dcarney): remove | 714 // TODO(dcarney): remove |
| 710 V8_INLINE(void Clear()) { val_ = 0; } | 715 V8_INLINE void Clear() { val_ = 0; } |
| 711 | 716 |
| 712 // TODO(dcarney): remove | 717 // TODO(dcarney): remove |
| 713 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 718 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 714 | 719 |
| 715 private: | 720 private: |
| 716 #endif | 721 #endif |
| 717 template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } | 722 template <class S> V8_INLINE Persistent(S* that) : val_(that) { } |
| 718 | 723 |
| 719 V8_INLINE(T* operator*() const) { return val_; } | 724 V8_INLINE T* operator*() const { return val_; } |
| 720 | 725 |
| 721 private: | 726 private: |
| 722 friend class Utils; | 727 friend class Utils; |
| 723 template<class F> friend class Handle; | 728 template<class F> friend class Handle; |
| 724 template<class F> friend class Local; | 729 template<class F> friend class Local; |
| 725 template<class F1, class F2> friend class Persistent; | 730 template<class F1, class F2> friend class Persistent; |
| 726 template<class F> friend class ReturnValue; | 731 template<class F> friend class ReturnValue; |
| 727 | 732 |
| 728 V8_INLINE(static T* New(Isolate* isolate, T* that)); | 733 V8_INLINE static T* New(Isolate* isolate, T* that); |
| 729 template<class S, class M2> | 734 template<class S, class M2> |
| 730 V8_INLINE(void Copy(const Persistent<S, M2>& that)); | 735 V8_INLINE void Copy(const Persistent<S, M2>& that); |
| 731 | 736 |
| 732 T* val_; | 737 T* val_; |
| 733 }; | 738 }; |
| 734 | 739 |
| 735 /** | 740 /** |
| 736 * A stack-allocated class that governs a number of local handles. | 741 * A stack-allocated class that governs a number of local handles. |
| 737 * After a handle scope has been created, all local handles will be | 742 * After a handle scope has been created, all local handles will be |
| 738 * allocated within that handle scope until either the handle scope is | 743 * allocated within that handle scope until either the handle scope is |
| 739 * deleted or another handle scope is created. If there is already a | 744 * deleted or another handle scope is created. If there is already a |
| 740 * handle scope and a new one is created, all allocations will take | 745 * handle scope and a new one is created, all allocations will take |
| 741 * place in the new handle scope until it is deleted. After that, | 746 * place in the new handle scope until it is deleted. After that, |
| 742 * new handles will again be allocated in the original handle scope. | 747 * new handles will again be allocated in the original handle scope. |
| 743 * | 748 * |
| 744 * After the handle scope of a local handle has been deleted the | 749 * After the handle scope of a local handle has been deleted the |
| 745 * garbage collector will no longer track the object stored in the | 750 * garbage collector will no longer track the object stored in the |
| 746 * handle and may deallocate it. The behavior of accessing a handle | 751 * handle and may deallocate it. The behavior of accessing a handle |
| 747 * for which the handle scope has been deleted is undefined. | 752 * for which the handle scope has been deleted is undefined. |
| 748 */ | 753 */ |
| 749 class V8_EXPORT HandleScope { | 754 class V8_EXPORT HandleScope { |
| 750 public: | 755 public: |
| 751 // TODO(svenpanne) Deprecate me when Chrome is fixed! | |
| 752 HandleScope(); | |
| 753 | |
| 754 HandleScope(Isolate* isolate); | 756 HandleScope(Isolate* isolate); |
| 755 | 757 |
| 756 ~HandleScope(); | 758 ~HandleScope(); |
| 757 | 759 |
| 758 /** | 760 /** |
| 759 * Closes the handle scope and returns the value as a handle in the | 761 * Closes the handle scope and returns the value as a handle in the |
| 760 * previous scope, which is the new current scope after the call. | 762 * previous scope, which is the new current scope after the call. |
| 761 */ | 763 */ |
| 762 template <class T> Local<T> Close(Handle<T> value); | 764 template <class T> Local<T> Close(Handle<T> value); |
| 763 | 765 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 783 void* operator new(size_t size); | 785 void* operator new(size_t size); |
| 784 void operator delete(void*, size_t); | 786 void operator delete(void*, size_t); |
| 785 | 787 |
| 786 // This Data class is accessible internally as HandleScopeData through a | 788 // This Data class is accessible internally as HandleScopeData through a |
| 787 // typedef in the ImplementationUtilities class. | 789 // typedef in the ImplementationUtilities class. |
| 788 class V8_EXPORT Data { | 790 class V8_EXPORT Data { |
| 789 public: | 791 public: |
| 790 internal::Object** next; | 792 internal::Object** next; |
| 791 internal::Object** limit; | 793 internal::Object** limit; |
| 792 int level; | 794 int level; |
| 793 V8_INLINE(void Initialize()) { | 795 V8_INLINE void Initialize() { |
| 794 next = limit = NULL; | 796 next = limit = NULL; |
| 795 level = 0; | 797 level = 0; |
| 796 } | 798 } |
| 797 }; | 799 }; |
| 798 | 800 |
| 799 void Initialize(Isolate* isolate); | 801 void Initialize(Isolate* isolate); |
| 800 void Leave(); | 802 void Leave(); |
| 801 | 803 |
| 802 internal::Isolate* isolate_; | 804 internal::Isolate* isolate_; |
| 803 internal::Object** prev_next_; | 805 internal::Object** prev_next_; |
| 804 internal::Object** prev_limit_; | 806 internal::Object** prev_limit_; |
| 805 | 807 |
| 806 // Allow for the active closing of HandleScopes which allows to pass a handle | 808 // Allow for the active closing of HandleScopes which allows to pass a handle |
| 807 // from the HandleScope being closed to the next top most HandleScope. | 809 // from the HandleScope being closed to the next top most HandleScope. |
| 808 bool is_closed_; | 810 bool is_closed_; |
| 809 internal::Object** RawClose(internal::Object** value); | 811 internal::Object** RawClose(internal::Object** value); |
| 810 | 812 |
| 811 friend class ImplementationUtilities; | 813 friend class ImplementationUtilities; |
| 812 }; | 814 }; |
| 813 | 815 |
| 814 | 816 |
| 817 /** |
| 818 * A simple Maybe type, representing an object which may or may not have a |
| 819 * value. |
| 820 */ |
| 821 template<class T> |
| 822 struct Maybe { |
| 823 Maybe() : has_value(false) {} |
| 824 explicit Maybe(T t) : has_value(true), value(t) {} |
| 825 Maybe(bool has, T t) : has_value(has), value(t) {} |
| 826 |
| 827 bool has_value; |
| 828 T value; |
| 829 }; |
| 830 |
| 831 |
| 815 // --- Special objects --- | 832 // --- Special objects --- |
| 816 | 833 |
| 817 | 834 |
| 818 /** | 835 /** |
| 819 * The superclass of values and API object templates. | 836 * The superclass of values and API object templates. |
| 820 */ | 837 */ |
| 821 class V8_EXPORT Data { | 838 class V8_EXPORT Data { |
| 822 private: | 839 private: |
| 823 Data(); | 840 Data(); |
| 824 }; | 841 }; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 */ | 894 */ |
| 878 virtual bool HasError() = 0; | 895 virtual bool HasError() = 0; |
| 879 }; | 896 }; |
| 880 | 897 |
| 881 | 898 |
| 882 /** | 899 /** |
| 883 * The origin, within a file, of a script. | 900 * The origin, within a file, of a script. |
| 884 */ | 901 */ |
| 885 class ScriptOrigin { | 902 class ScriptOrigin { |
| 886 public: | 903 public: |
| 887 V8_INLINE(ScriptOrigin( | 904 V8_INLINE ScriptOrigin( |
| 888 Handle<Value> resource_name, | 905 Handle<Value> resource_name, |
| 889 Handle<Integer> resource_line_offset = Handle<Integer>(), | 906 Handle<Integer> resource_line_offset = Handle<Integer>(), |
| 890 Handle<Integer> resource_column_offset = Handle<Integer>(), | 907 Handle<Integer> resource_column_offset = Handle<Integer>(), |
| 891 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>())) | 908 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>()) |
| 892 : resource_name_(resource_name), | 909 : resource_name_(resource_name), |
| 893 resource_line_offset_(resource_line_offset), | 910 resource_line_offset_(resource_line_offset), |
| 894 resource_column_offset_(resource_column_offset), | 911 resource_column_offset_(resource_column_offset), |
| 895 resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { } | 912 resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { } |
| 896 V8_INLINE(Handle<Value> ResourceName() const); | 913 V8_INLINE Handle<Value> ResourceName() const; |
| 897 V8_INLINE(Handle<Integer> ResourceLineOffset() const); | 914 V8_INLINE Handle<Integer> ResourceLineOffset() const; |
| 898 V8_INLINE(Handle<Integer> ResourceColumnOffset() const); | 915 V8_INLINE Handle<Integer> ResourceColumnOffset() const; |
| 899 V8_INLINE(Handle<Boolean> ResourceIsSharedCrossOrigin() const); | 916 V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const; |
| 900 private: | 917 private: |
| 901 Handle<Value> resource_name_; | 918 Handle<Value> resource_name_; |
| 902 Handle<Integer> resource_line_offset_; | 919 Handle<Integer> resource_line_offset_; |
| 903 Handle<Integer> resource_column_offset_; | 920 Handle<Integer> resource_column_offset_; |
| 904 Handle<Boolean> resource_is_shared_cross_origin_; | 921 Handle<Boolean> resource_is_shared_cross_origin_; |
| 905 }; | 922 }; |
| 906 | 923 |
| 907 | 924 |
| 908 /** | 925 /** |
| 909 * A compiled JavaScript script. | 926 * A compiled JavaScript script. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 | 1247 |
| 1231 /** | 1248 /** |
| 1232 * The superclass of all JavaScript values and objects. | 1249 * The superclass of all JavaScript values and objects. |
| 1233 */ | 1250 */ |
| 1234 class V8_EXPORT Value : public Data { | 1251 class V8_EXPORT Value : public Data { |
| 1235 public: | 1252 public: |
| 1236 /** | 1253 /** |
| 1237 * Returns true if this value is the undefined value. See ECMA-262 | 1254 * Returns true if this value is the undefined value. See ECMA-262 |
| 1238 * 4.3.10. | 1255 * 4.3.10. |
| 1239 */ | 1256 */ |
| 1240 V8_INLINE(bool IsUndefined() const); | 1257 V8_INLINE bool IsUndefined() const; |
| 1241 | 1258 |
| 1242 /** | 1259 /** |
| 1243 * Returns true if this value is the null value. See ECMA-262 | 1260 * Returns true if this value is the null value. See ECMA-262 |
| 1244 * 4.3.11. | 1261 * 4.3.11. |
| 1245 */ | 1262 */ |
| 1246 V8_INLINE(bool IsNull() const); | 1263 V8_INLINE bool IsNull() const; |
| 1247 | 1264 |
| 1248 /** | 1265 /** |
| 1249 * Returns true if this value is true. | 1266 * Returns true if this value is true. |
| 1250 */ | 1267 */ |
| 1251 bool IsTrue() const; | 1268 bool IsTrue() const; |
| 1252 | 1269 |
| 1253 /** | 1270 /** |
| 1254 * Returns true if this value is false. | 1271 * Returns true if this value is false. |
| 1255 */ | 1272 */ |
| 1256 bool IsFalse() const; | 1273 bool IsFalse() const; |
| 1257 | 1274 |
| 1258 /** | 1275 /** |
| 1259 * Returns true if this value is an instance of the String type. | 1276 * Returns true if this value is an instance of the String type. |
| 1260 * See ECMA-262 8.4. | 1277 * See ECMA-262 8.4. |
| 1261 */ | 1278 */ |
| 1262 V8_INLINE(bool IsString() const); | 1279 V8_INLINE bool IsString() const; |
| 1263 | 1280 |
| 1264 /** | 1281 /** |
| 1265 * Returns true if this value is a symbol. | 1282 * Returns true if this value is a symbol. |
| 1266 * This is an experimental feature. | 1283 * This is an experimental feature. |
| 1267 */ | 1284 */ |
| 1268 bool IsSymbol() const; | 1285 bool IsSymbol() const; |
| 1269 | 1286 |
| 1270 /** | 1287 /** |
| 1271 * Returns true if this value is a function. | 1288 * Returns true if this value is a function. |
| 1272 */ | 1289 */ |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 bool BooleanValue() const; | 1457 bool BooleanValue() const; |
| 1441 double NumberValue() const; | 1458 double NumberValue() const; |
| 1442 int64_t IntegerValue() const; | 1459 int64_t IntegerValue() const; |
| 1443 uint32_t Uint32Value() const; | 1460 uint32_t Uint32Value() const; |
| 1444 int32_t Int32Value() const; | 1461 int32_t Int32Value() const; |
| 1445 | 1462 |
| 1446 /** JS == */ | 1463 /** JS == */ |
| 1447 bool Equals(Handle<Value> that) const; | 1464 bool Equals(Handle<Value> that) const; |
| 1448 bool StrictEquals(Handle<Value> that) const; | 1465 bool StrictEquals(Handle<Value> that) const; |
| 1449 | 1466 |
| 1450 template <class T> V8_INLINE(static Value* Cast(T* value)); | 1467 template <class T> V8_INLINE static Value* Cast(T* value); |
| 1451 | 1468 |
| 1452 private: | 1469 private: |
| 1453 V8_INLINE(bool QuickIsUndefined() const); | 1470 V8_INLINE bool QuickIsUndefined() const; |
| 1454 V8_INLINE(bool QuickIsNull() const); | 1471 V8_INLINE bool QuickIsNull() const; |
| 1455 V8_INLINE(bool QuickIsString() const); | 1472 V8_INLINE bool QuickIsString() const; |
| 1456 bool FullIsUndefined() const; | 1473 bool FullIsUndefined() const; |
| 1457 bool FullIsNull() const; | 1474 bool FullIsNull() const; |
| 1458 bool FullIsString() const; | 1475 bool FullIsString() const; |
| 1459 }; | 1476 }; |
| 1460 | 1477 |
| 1461 | 1478 |
| 1462 /** | 1479 /** |
| 1463 * The superclass of primitive values. See ECMA-262 4.3.2. | 1480 * The superclass of primitive values. See ECMA-262 4.3.2. |
| 1464 */ | 1481 */ |
| 1465 class V8_EXPORT Primitive : public Value { }; | 1482 class V8_EXPORT Primitive : public Value { }; |
| 1466 | 1483 |
| 1467 | 1484 |
| 1468 /** | 1485 /** |
| 1469 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 1486 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
| 1470 * or false value. | 1487 * or false value. |
| 1471 */ | 1488 */ |
| 1472 class V8_EXPORT Boolean : public Primitive { | 1489 class V8_EXPORT Boolean : public Primitive { |
| 1473 public: | 1490 public: |
| 1474 bool Value() const; | 1491 bool Value() const; |
| 1475 V8_INLINE(static Handle<Boolean> New(bool value)); | 1492 V8_INLINE static Handle<Boolean> New(bool value); |
| 1476 }; | 1493 }; |
| 1477 | 1494 |
| 1478 | 1495 |
| 1479 /** | 1496 /** |
| 1480 * A JavaScript string value (ECMA-262, 4.3.17). | 1497 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1481 */ | 1498 */ |
| 1482 class V8_EXPORT String : public Primitive { | 1499 class V8_EXPORT String : public Primitive { |
| 1483 public: | 1500 public: |
| 1484 enum Encoding { | 1501 enum Encoding { |
| 1485 UNKNOWN_ENCODING = 0x1, | 1502 UNKNOWN_ENCODING = 0x1, |
| 1486 TWO_BYTE_ENCODING = 0x0, | 1503 TWO_BYTE_ENCODING = 0x0, |
| 1487 ASCII_ENCODING = 0x4, | 1504 ASCII_ENCODING = 0x4, |
| 1488 ONE_BYTE_ENCODING = 0x4 | 1505 ONE_BYTE_ENCODING = 0x4 |
| 1489 }; | 1506 }; |
| 1490 /** | 1507 /** |
| 1491 * Returns the number of characters in this string. | 1508 * Returns the number of characters in this string. |
| 1492 */ | 1509 */ |
| 1493 int Length() const; | 1510 int Length() const; |
| 1494 | 1511 |
| 1495 /** | 1512 /** |
| 1496 * Returns the number of bytes in the UTF-8 encoded | 1513 * Returns the number of bytes in the UTF-8 encoded |
| 1497 * representation of this string. | 1514 * representation of this string. |
| 1498 */ | 1515 */ |
| 1499 int Utf8Length() const; | 1516 int Utf8Length() const; |
| 1500 | 1517 |
| 1501 /** | 1518 /** |
| 1502 * This function is no longer useful. | 1519 * This function is no longer useful. |
| 1503 */ | 1520 */ |
| 1504 V8_DEPRECATED(V8_INLINE(bool MayContainNonAscii()) const) { return true; } | 1521 V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; } |
| 1505 | 1522 |
| 1506 /** | 1523 /** |
| 1507 * Returns whether this string is known to contain only one byte data. | 1524 * Returns whether this string is known to contain only one byte data. |
| 1508 * Does not read the string. | 1525 * Does not read the string. |
| 1509 * False negatives are possible. | 1526 * False negatives are possible. |
| 1510 */ | 1527 */ |
| 1511 bool IsOneByte() const; | 1528 bool IsOneByte() const; |
| 1512 | 1529 |
| 1513 /** | 1530 /** |
| 1514 * Returns whether this string contain only one byte data. | 1531 * Returns whether this string contain only one byte data. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 // UTF-8 encoded characters. | 1583 // UTF-8 encoded characters. |
| 1567 int WriteUtf8(char* buffer, | 1584 int WriteUtf8(char* buffer, |
| 1568 int length = -1, | 1585 int length = -1, |
| 1569 int* nchars_ref = NULL, | 1586 int* nchars_ref = NULL, |
| 1570 int options = NO_OPTIONS) const; | 1587 int options = NO_OPTIONS) const; |
| 1571 | 1588 |
| 1572 /** | 1589 /** |
| 1573 * A zero length string. | 1590 * A zero length string. |
| 1574 */ | 1591 */ |
| 1575 static v8::Local<v8::String> Empty(); | 1592 static v8::Local<v8::String> Empty(); |
| 1576 V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); | 1593 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); |
| 1577 | 1594 |
| 1578 /** | 1595 /** |
| 1579 * Returns true if the string is external | 1596 * Returns true if the string is external |
| 1580 */ | 1597 */ |
| 1581 bool IsExternal() const; | 1598 bool IsExternal() const; |
| 1582 | 1599 |
| 1583 /** | 1600 /** |
| 1584 * Returns true if the string is both external and ASCII | 1601 * Returns true if the string is both external and ASCII |
| 1585 */ | 1602 */ |
| 1586 bool IsExternalAscii() const; | 1603 bool IsExternalAscii() const; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 ExternalAsciiStringResource() {} | 1681 ExternalAsciiStringResource() {} |
| 1665 }; | 1682 }; |
| 1666 | 1683 |
| 1667 typedef ExternalAsciiStringResource ExternalOneByteStringResource; | 1684 typedef ExternalAsciiStringResource ExternalOneByteStringResource; |
| 1668 | 1685 |
| 1669 /** | 1686 /** |
| 1670 * If the string is an external string, return the ExternalStringResourceBase | 1687 * If the string is an external string, return the ExternalStringResourceBase |
| 1671 * regardless of the encoding, otherwise return NULL. The encoding of the | 1688 * regardless of the encoding, otherwise return NULL. The encoding of the |
| 1672 * string is returned in encoding_out. | 1689 * string is returned in encoding_out. |
| 1673 */ | 1690 */ |
| 1674 V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( | 1691 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( |
| 1675 Encoding* encoding_out) const); | 1692 Encoding* encoding_out) const; |
| 1676 | 1693 |
| 1677 /** | 1694 /** |
| 1678 * Get the ExternalStringResource for an external string. Returns | 1695 * Get the ExternalStringResource for an external string. Returns |
| 1679 * NULL if IsExternal() doesn't return true. | 1696 * NULL if IsExternal() doesn't return true. |
| 1680 */ | 1697 */ |
| 1681 V8_INLINE(ExternalStringResource* GetExternalStringResource() const); | 1698 V8_INLINE ExternalStringResource* GetExternalStringResource() const; |
| 1682 | 1699 |
| 1683 /** | 1700 /** |
| 1684 * Get the ExternalAsciiStringResource for an external ASCII string. | 1701 * Get the ExternalAsciiStringResource for an external ASCII string. |
| 1685 * Returns NULL if IsExternalAscii() doesn't return true. | 1702 * Returns NULL if IsExternalAscii() doesn't return true. |
| 1686 */ | 1703 */ |
| 1687 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1704 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; |
| 1688 | 1705 |
| 1689 V8_INLINE(static String* Cast(v8::Value* obj)); | 1706 V8_INLINE static String* Cast(v8::Value* obj); |
| 1690 | 1707 |
| 1691 // TODO(dcarney): deprecate | 1708 // TODO(dcarney): deprecate |
| 1692 /** | 1709 /** |
| 1693 * Allocates a new string from either UTF-8 encoded or ASCII data. | 1710 * Allocates a new string from either UTF-8 encoded or ASCII data. |
| 1694 * The second parameter 'length' gives the buffer length. If omitted, | 1711 * The second parameter 'length' gives the buffer length. If omitted, |
| 1695 * the function calls 'strlen' to determine the buffer length. | 1712 * the function calls 'strlen' to determine the buffer length. |
| 1696 */ | 1713 */ |
| 1697 V8_INLINE(static Local<String> New(const char* data, int length = -1)); | 1714 V8_INLINE static Local<String> New(const char* data, int length = -1); |
| 1698 | 1715 |
| 1699 // TODO(dcarney): deprecate | 1716 // TODO(dcarney): deprecate |
| 1700 /** Allocates a new string from 16-bit character codes.*/ | 1717 /** Allocates a new string from 16-bit character codes.*/ |
| 1701 V8_INLINE(static Local<String> New(const uint16_t* data, int length = -1)); | 1718 V8_INLINE static Local<String> New(const uint16_t* data, int length = -1); |
| 1702 | 1719 |
| 1703 // TODO(dcarney): deprecate | 1720 // TODO(dcarney): deprecate |
| 1704 /** | 1721 /** |
| 1705 * Creates an internalized string (historically called a "symbol", | 1722 * Creates an internalized string (historically called a "symbol", |
| 1706 * not to be confused with ES6 symbols). Returns one if it exists already. | 1723 * not to be confused with ES6 symbols). Returns one if it exists already. |
| 1707 */ | 1724 */ |
| 1708 V8_INLINE(static Local<String> NewSymbol(const char* data, int length = -1)); | 1725 V8_INLINE static Local<String> NewSymbol(const char* data, int length = -1); |
| 1709 | 1726 |
| 1710 enum NewStringType { | 1727 enum NewStringType { |
| 1711 kNormalString, kInternalizedString, kUndetectableString | 1728 kNormalString, kInternalizedString, kUndetectableString |
| 1712 }; | 1729 }; |
| 1713 | 1730 |
| 1714 /** Allocates a new string from UTF-8 data.*/ | 1731 /** Allocates a new string from UTF-8 data.*/ |
| 1715 static Local<String> NewFromUtf8(Isolate* isolate, | 1732 static Local<String> NewFromUtf8(Isolate* isolate, |
| 1716 const char* data, | 1733 const char* data, |
| 1717 NewStringType type = kNormalString, | 1734 NewStringType type = kNormalString, |
| 1718 int length = -1); | 1735 int length = -1); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 */ | 1796 */ |
| 1780 bool MakeExternal(ExternalAsciiStringResource* resource); | 1797 bool MakeExternal(ExternalAsciiStringResource* resource); |
| 1781 | 1798 |
| 1782 /** | 1799 /** |
| 1783 * Returns true if this string can be made external. | 1800 * Returns true if this string can be made external. |
| 1784 */ | 1801 */ |
| 1785 bool CanMakeExternal(); | 1802 bool CanMakeExternal(); |
| 1786 | 1803 |
| 1787 // TODO(dcarney): deprecate | 1804 // TODO(dcarney): deprecate |
| 1788 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ | 1805 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ |
| 1789 V8_INLINE( | 1806 V8_INLINE static Local<String> NewUndetectable(const char* data, |
| 1790 static Local<String> NewUndetectable(const char* data, int length = -1)); | 1807 int length = -1); |
| 1791 | 1808 |
| 1792 // TODO(dcarney): deprecate | 1809 // TODO(dcarney): deprecate |
| 1793 /** Creates an undetectable string from the supplied 16-bit character codes.*/ | 1810 /** Creates an undetectable string from the supplied 16-bit character codes.*/ |
| 1794 V8_INLINE(static Local<String> NewUndetectable( | 1811 V8_INLINE static Local<String> NewUndetectable(const uint16_t* data, |
| 1795 const uint16_t* data, int length = -1)); | 1812 int length = -1); |
| 1796 | 1813 |
| 1797 /** | 1814 /** |
| 1798 * Converts an object to a UTF-8-encoded character array. Useful if | 1815 * Converts an object to a UTF-8-encoded character array. Useful if |
| 1799 * you want to print the object. If conversion to a string fails | 1816 * you want to print the object. If conversion to a string fails |
| 1800 * (e.g. due to an exception in the toString() method of the object) | 1817 * (e.g. due to an exception in the toString() method of the object) |
| 1801 * then the length() method returns 0 and the * operator returns | 1818 * then the length() method returns 0 and the * operator returns |
| 1802 * NULL. | 1819 * NULL. |
| 1803 */ | 1820 */ |
| 1804 class V8_EXPORT Utf8Value { | 1821 class V8_EXPORT Utf8Value { |
| 1805 public: | 1822 public: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 public: | 1897 public: |
| 1881 // Returns the print name string of the symbol, or undefined if none. | 1898 // Returns the print name string of the symbol, or undefined if none. |
| 1882 Local<Value> Name() const; | 1899 Local<Value> Name() const; |
| 1883 | 1900 |
| 1884 // Create a symbol without a print name. | 1901 // Create a symbol without a print name. |
| 1885 static Local<Symbol> New(Isolate* isolate); | 1902 static Local<Symbol> New(Isolate* isolate); |
| 1886 | 1903 |
| 1887 // Create a symbol with a print name. | 1904 // Create a symbol with a print name. |
| 1888 static Local<Symbol> New(Isolate *isolate, const char* data, int length = -1); | 1905 static Local<Symbol> New(Isolate *isolate, const char* data, int length = -1); |
| 1889 | 1906 |
| 1890 V8_INLINE(static Symbol* Cast(v8::Value* obj)); | 1907 V8_INLINE static Symbol* Cast(v8::Value* obj); |
| 1891 private: | 1908 private: |
| 1892 Symbol(); | 1909 Symbol(); |
| 1893 static void CheckCast(v8::Value* obj); | 1910 static void CheckCast(v8::Value* obj); |
| 1894 }; | 1911 }; |
| 1895 | 1912 |
| 1896 | 1913 |
| 1897 /** | 1914 /** |
| 1898 * A JavaScript number value (ECMA-262, 4.3.20) | 1915 * A JavaScript number value (ECMA-262, 4.3.20) |
| 1899 */ | 1916 */ |
| 1900 class V8_EXPORT Number : public Primitive { | 1917 class V8_EXPORT Number : public Primitive { |
| 1901 public: | 1918 public: |
| 1902 double Value() const; | 1919 double Value() const; |
| 1903 static Local<Number> New(double value); | 1920 static Local<Number> New(double value); |
| 1904 static Local<Number> New(Isolate* isolate, double value); | 1921 static Local<Number> New(Isolate* isolate, double value); |
| 1905 V8_INLINE(static Number* Cast(v8::Value* obj)); | 1922 V8_INLINE static Number* Cast(v8::Value* obj); |
| 1906 private: | 1923 private: |
| 1907 Number(); | 1924 Number(); |
| 1908 static void CheckCast(v8::Value* obj); | 1925 static void CheckCast(v8::Value* obj); |
| 1909 }; | 1926 }; |
| 1910 | 1927 |
| 1911 | 1928 |
| 1912 /** | 1929 /** |
| 1913 * A JavaScript value representing a signed integer. | 1930 * A JavaScript value representing a signed integer. |
| 1914 */ | 1931 */ |
| 1915 class V8_EXPORT Integer : public Number { | 1932 class V8_EXPORT Integer : public Number { |
| 1916 public: | 1933 public: |
| 1917 static Local<Integer> New(int32_t value); | 1934 static Local<Integer> New(int32_t value); |
| 1918 static Local<Integer> NewFromUnsigned(uint32_t value); | 1935 static Local<Integer> NewFromUnsigned(uint32_t value); |
| 1919 static Local<Integer> New(int32_t value, Isolate*); | 1936 static Local<Integer> New(int32_t value, Isolate*); |
| 1920 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | 1937 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); |
| 1921 int64_t Value() const; | 1938 int64_t Value() const; |
| 1922 V8_INLINE(static Integer* Cast(v8::Value* obj)); | 1939 V8_INLINE static Integer* Cast(v8::Value* obj); |
| 1923 private: | 1940 private: |
| 1924 Integer(); | 1941 Integer(); |
| 1925 static void CheckCast(v8::Value* obj); | 1942 static void CheckCast(v8::Value* obj); |
| 1926 }; | 1943 }; |
| 1927 | 1944 |
| 1928 | 1945 |
| 1929 /** | 1946 /** |
| 1930 * A JavaScript value representing a 32-bit signed integer. | 1947 * A JavaScript value representing a 32-bit signed integer. |
| 1931 */ | 1948 */ |
| 1932 class V8_EXPORT Int32 : public Integer { | 1949 class V8_EXPORT Int32 : public Integer { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 | 2130 |
| 2114 /** | 2131 /** |
| 2115 * Returns the name of the function invoked as a constructor for this object. | 2132 * Returns the name of the function invoked as a constructor for this object. |
| 2116 */ | 2133 */ |
| 2117 Local<String> GetConstructorName(); | 2134 Local<String> GetConstructorName(); |
| 2118 | 2135 |
| 2119 /** Gets the number of internal fields for this Object. */ | 2136 /** Gets the number of internal fields for this Object. */ |
| 2120 int InternalFieldCount(); | 2137 int InternalFieldCount(); |
| 2121 | 2138 |
| 2122 /** Gets the value from an internal field. */ | 2139 /** Gets the value from an internal field. */ |
| 2123 V8_INLINE(Local<Value> GetInternalField(int index)); | 2140 V8_INLINE Local<Value> GetInternalField(int index); |
| 2124 | 2141 |
| 2125 /** Sets the value in an internal field. */ | 2142 /** Sets the value in an internal field. */ |
| 2126 void SetInternalField(int index, Handle<Value> value); | 2143 void SetInternalField(int index, Handle<Value> value); |
| 2127 | 2144 |
| 2128 /** | 2145 /** |
| 2129 * Gets a 2-byte-aligned native pointer from an internal field. This field | 2146 * Gets a 2-byte-aligned native pointer from an internal field. This field |
| 2130 * must have been set by SetAlignedPointerInInternalField, everything else | 2147 * must have been set by SetAlignedPointerInInternalField, everything else |
| 2131 * leads to undefined behavior. | 2148 * leads to undefined behavior. |
| 2132 */ | 2149 */ |
| 2133 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); | 2150 V8_INLINE void* GetAlignedPointerFromInternalField(int index); |
| 2134 | 2151 |
| 2135 /** | 2152 /** |
| 2136 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such | 2153 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such |
| 2137 * a field, GetAlignedPointerFromInternalField must be used, everything else | 2154 * a field, GetAlignedPointerFromInternalField must be used, everything else |
| 2138 * leads to undefined behavior. | 2155 * leads to undefined behavior. |
| 2139 */ | 2156 */ |
| 2140 void SetAlignedPointerInInternalField(int index, void* value); | 2157 void SetAlignedPointerInInternalField(int index, void* value); |
| 2141 | 2158 |
| 2142 // Testers for local properties. | 2159 // Testers for local properties. |
| 2143 bool HasOwnProperty(Handle<String> key); | 2160 bool HasOwnProperty(Handle<String> key); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 Handle<Value> argv[]); | 2270 Handle<Value> argv[]); |
| 2254 | 2271 |
| 2255 /** | 2272 /** |
| 2256 * Call an Object as a constructor if a callback is set by the | 2273 * Call an Object as a constructor if a callback is set by the |
| 2257 * ObjectTemplate::SetCallAsFunctionHandler method. | 2274 * ObjectTemplate::SetCallAsFunctionHandler method. |
| 2258 * Note: This method behaves like the Function::NewInstance method. | 2275 * Note: This method behaves like the Function::NewInstance method. |
| 2259 */ | 2276 */ |
| 2260 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); | 2277 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); |
| 2261 | 2278 |
| 2262 static Local<Object> New(); | 2279 static Local<Object> New(); |
| 2263 V8_INLINE(static Object* Cast(Value* obj)); | 2280 V8_INLINE static Object* Cast(Value* obj); |
| 2264 | 2281 |
| 2265 private: | 2282 private: |
| 2266 Object(); | 2283 Object(); |
| 2267 static void CheckCast(Value* obj); | 2284 static void CheckCast(Value* obj); |
| 2268 Local<Value> SlowGetInternalField(int index); | 2285 Local<Value> SlowGetInternalField(int index); |
| 2269 void* SlowGetAlignedPointerFromInternalField(int index); | 2286 void* SlowGetAlignedPointerFromInternalField(int index); |
| 2270 }; | 2287 }; |
| 2271 | 2288 |
| 2272 | 2289 |
| 2273 /** | 2290 /** |
| 2274 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 2291 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
| 2275 */ | 2292 */ |
| 2276 class V8_EXPORT Array : public Object { | 2293 class V8_EXPORT Array : public Object { |
| 2277 public: | 2294 public: |
| 2278 uint32_t Length() const; | 2295 uint32_t Length() const; |
| 2279 | 2296 |
| 2280 /** | 2297 /** |
| 2281 * Clones an element at index |index|. Returns an empty | 2298 * Clones an element at index |index|. Returns an empty |
| 2282 * handle if cloning fails (for any reason). | 2299 * handle if cloning fails (for any reason). |
| 2283 */ | 2300 */ |
| 2284 Local<Object> CloneElementAt(uint32_t index); | 2301 Local<Object> CloneElementAt(uint32_t index); |
| 2285 | 2302 |
| 2286 /** | 2303 /** |
| 2287 * Creates a JavaScript array with the given length. If the length | 2304 * Creates a JavaScript array with the given length. If the length |
| 2288 * is negative the returned array will have length 0. | 2305 * is negative the returned array will have length 0. |
| 2289 */ | 2306 */ |
| 2290 static Local<Array> New(int length = 0); | 2307 static Local<Array> New(int length = 0); |
| 2291 | 2308 |
| 2292 V8_INLINE(static Array* Cast(Value* obj)); | 2309 V8_INLINE static Array* Cast(Value* obj); |
| 2293 private: | 2310 private: |
| 2294 Array(); | 2311 Array(); |
| 2295 static void CheckCast(Value* obj); | 2312 static void CheckCast(Value* obj); |
| 2296 }; | 2313 }; |
| 2297 | 2314 |
| 2298 | 2315 |
| 2299 template<typename T> | 2316 template<typename T> |
| 2300 class ReturnValue { | 2317 class ReturnValue { |
| 2301 public: | 2318 public: |
| 2302 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that)) | 2319 template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that) |
| 2303 : value_(that.value_) { | 2320 : value_(that.value_) { |
| 2304 TYPE_CHECK(T, S); | 2321 TYPE_CHECK(T, S); |
| 2305 } | 2322 } |
| 2306 // Handle setters | 2323 // Handle setters |
| 2307 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); | 2324 template <typename S> V8_INLINE void Set(const Persistent<S>& handle); |
| 2308 template <typename S> V8_INLINE(void Set(const Handle<S> handle)); | 2325 template <typename S> V8_INLINE void Set(const Handle<S> handle); |
| 2309 // Fast primitive setters | 2326 // Fast primitive setters |
| 2310 V8_INLINE(void Set(bool value)); | 2327 V8_INLINE void Set(bool value); |
| 2311 V8_INLINE(void Set(double i)); | 2328 V8_INLINE void Set(double i); |
| 2312 V8_INLINE(void Set(int32_t i)); | 2329 V8_INLINE void Set(int32_t i); |
| 2313 V8_INLINE(void Set(uint32_t i)); | 2330 V8_INLINE void Set(uint32_t i); |
| 2314 // Fast JS primitive setters | 2331 // Fast JS primitive setters |
| 2315 V8_INLINE(void SetNull()); | 2332 V8_INLINE void SetNull(); |
| 2316 V8_INLINE(void SetUndefined()); | 2333 V8_INLINE void SetUndefined(); |
| 2317 V8_INLINE(void SetEmptyString()); | 2334 V8_INLINE void SetEmptyString(); |
| 2318 // Convenience getter for Isolate | 2335 // Convenience getter for Isolate |
| 2319 V8_INLINE(Isolate* GetIsolate()); | 2336 V8_INLINE Isolate* GetIsolate(); |
| 2320 | 2337 |
| 2321 private: | 2338 private: |
| 2322 template<class F> friend class ReturnValue; | 2339 template<class F> friend class ReturnValue; |
| 2323 template<class F> friend class FunctionCallbackInfo; | 2340 template<class F> friend class FunctionCallbackInfo; |
| 2324 template<class F> friend class PropertyCallbackInfo; | 2341 template<class F> friend class PropertyCallbackInfo; |
| 2325 V8_INLINE(internal::Object* GetDefaultValue()); | 2342 V8_INLINE internal::Object* GetDefaultValue(); |
| 2326 V8_INLINE(explicit ReturnValue(internal::Object** slot)); | 2343 V8_INLINE explicit ReturnValue(internal::Object** slot); |
| 2327 internal::Object** value_; | 2344 internal::Object** value_; |
| 2328 }; | 2345 }; |
| 2329 | 2346 |
| 2330 | 2347 |
| 2331 /** | 2348 /** |
| 2332 * The argument information given to function call callbacks. This | 2349 * The argument information given to function call callbacks. This |
| 2333 * class provides access to information about the context of the call, | 2350 * class provides access to information about the context of the call, |
| 2334 * including the receiver, the number and values of arguments, and | 2351 * including the receiver, the number and values of arguments, and |
| 2335 * the holder of the function. | 2352 * the holder of the function. |
| 2336 */ | 2353 */ |
| 2337 template<typename T> | 2354 template<typename T> |
| 2338 class FunctionCallbackInfo { | 2355 class FunctionCallbackInfo { |
| 2339 public: | 2356 public: |
| 2340 V8_INLINE(int Length() const); | 2357 V8_INLINE int Length() const; |
| 2341 V8_INLINE(Local<Value> operator[](int i) const); | 2358 V8_INLINE Local<Value> operator[](int i) const; |
| 2342 V8_INLINE(Local<Function> Callee() const); | 2359 V8_INLINE Local<Function> Callee() const; |
| 2343 V8_INLINE(Local<Object> This() const); | 2360 V8_INLINE Local<Object> This() const; |
| 2344 V8_INLINE(Local<Object> Holder() const); | 2361 V8_INLINE Local<Object> Holder() const; |
| 2345 V8_INLINE(bool IsConstructCall() const); | 2362 V8_INLINE bool IsConstructCall() const; |
| 2346 V8_INLINE(Local<Value> Data() const); | 2363 V8_INLINE Local<Value> Data() const; |
| 2347 V8_INLINE(Isolate* GetIsolate() const); | 2364 V8_INLINE Isolate* GetIsolate() const; |
| 2348 V8_INLINE(ReturnValue<T> GetReturnValue() const); | 2365 V8_INLINE ReturnValue<T> GetReturnValue() const; |
| 2349 // This shouldn't be public, but the arm compiler needs it. | 2366 // This shouldn't be public, but the arm compiler needs it. |
| 2350 static const int kArgsLength = 6; | 2367 static const int kArgsLength = 6; |
| 2351 | 2368 |
| 2352 protected: | 2369 protected: |
| 2353 friend class internal::FunctionCallbackArguments; | 2370 friend class internal::FunctionCallbackArguments; |
| 2354 friend class internal::CustomArguments<FunctionCallbackInfo>; | 2371 friend class internal::CustomArguments<FunctionCallbackInfo>; |
| 2355 static const int kReturnValueIndex = 0; | 2372 static const int kReturnValueIndex = 0; |
| 2356 static const int kReturnValueDefaultValueIndex = -1; | 2373 static const int kReturnValueDefaultValueIndex = -1; |
| 2357 static const int kIsolateIndex = -2; | 2374 static const int kIsolateIndex = -2; |
| 2358 static const int kDataIndex = -3; | 2375 static const int kDataIndex = -3; |
| 2359 static const int kCalleeIndex = -4; | 2376 static const int kCalleeIndex = -4; |
| 2360 static const int kHolderIndex = -5; | 2377 static const int kHolderIndex = -5; |
| 2361 | 2378 |
| 2362 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, | 2379 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, |
| 2363 internal::Object** values, | 2380 internal::Object** values, |
| 2364 int length, | 2381 int length, |
| 2365 bool is_construct_call)); | 2382 bool is_construct_call); |
| 2366 internal::Object** implicit_args_; | 2383 internal::Object** implicit_args_; |
| 2367 internal::Object** values_; | 2384 internal::Object** values_; |
| 2368 int length_; | 2385 int length_; |
| 2369 bool is_construct_call_; | 2386 bool is_construct_call_; |
| 2370 }; | 2387 }; |
| 2371 | 2388 |
| 2372 | 2389 |
| 2373 /** | 2390 /** |
| 2374 * The information passed to a property callback about the context | 2391 * The information passed to a property callback about the context |
| 2375 * of the property access. | 2392 * of the property access. |
| 2376 */ | 2393 */ |
| 2377 template<typename T> | 2394 template<typename T> |
| 2378 class PropertyCallbackInfo { | 2395 class PropertyCallbackInfo { |
| 2379 public: | 2396 public: |
| 2380 V8_INLINE(Isolate* GetIsolate() const); | 2397 V8_INLINE Isolate* GetIsolate() const; |
| 2381 V8_INLINE(Local<Value> Data() const); | 2398 V8_INLINE Local<Value> Data() const; |
| 2382 V8_INLINE(Local<Object> This() const); | 2399 V8_INLINE Local<Object> This() const; |
| 2383 V8_INLINE(Local<Object> Holder() const); | 2400 V8_INLINE Local<Object> Holder() const; |
| 2384 V8_INLINE(ReturnValue<T> GetReturnValue() const); | 2401 V8_INLINE ReturnValue<T> GetReturnValue() const; |
| 2385 // This shouldn't be public, but the arm compiler needs it. | 2402 // This shouldn't be public, but the arm compiler needs it. |
| 2386 static const int kArgsLength = 6; | 2403 static const int kArgsLength = 6; |
| 2387 | 2404 |
| 2388 protected: | 2405 protected: |
| 2389 friend class MacroAssembler; | 2406 friend class MacroAssembler; |
| 2390 friend class internal::PropertyCallbackArguments; | 2407 friend class internal::PropertyCallbackArguments; |
| 2391 friend class internal::CustomArguments<PropertyCallbackInfo>; | 2408 friend class internal::CustomArguments<PropertyCallbackInfo>; |
| 2392 static const int kThisIndex = 0; | 2409 static const int kThisIndex = 0; |
| 2393 static const int kHolderIndex = -1; | 2410 static const int kHolderIndex = -1; |
| 2394 static const int kDataIndex = -2; | 2411 static const int kDataIndex = -2; |
| 2395 static const int kReturnValueIndex = -3; | 2412 static const int kReturnValueIndex = -3; |
| 2396 static const int kReturnValueDefaultValueIndex = -4; | 2413 static const int kReturnValueDefaultValueIndex = -4; |
| 2397 static const int kIsolateIndex = -5; | 2414 static const int kIsolateIndex = -5; |
| 2398 | 2415 |
| 2399 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | 2416 V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {} |
| 2400 : args_(args) { } | |
| 2401 internal::Object** args_; | 2417 internal::Object** args_; |
| 2402 }; | 2418 }; |
| 2403 | 2419 |
| 2404 | 2420 |
| 2405 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); | 2421 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); |
| 2406 | 2422 |
| 2407 | 2423 |
| 2408 /** | 2424 /** |
| 2409 * A JavaScript function object (ECMA-262, 15.3). | 2425 * A JavaScript function object (ECMA-262, 15.3). |
| 2410 */ | 2426 */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 * DEPRECATED: use ScriptId() instead. | 2465 * DEPRECATED: use ScriptId() instead. |
| 2450 */ | 2466 */ |
| 2451 Handle<Value> GetScriptId() const; | 2467 Handle<Value> GetScriptId() const; |
| 2452 | 2468 |
| 2453 /** | 2469 /** |
| 2454 * Returns scriptId. | 2470 * Returns scriptId. |
| 2455 */ | 2471 */ |
| 2456 int ScriptId() const; | 2472 int ScriptId() const; |
| 2457 | 2473 |
| 2458 ScriptOrigin GetScriptOrigin() const; | 2474 ScriptOrigin GetScriptOrigin() const; |
| 2459 V8_INLINE(static Function* Cast(Value* obj)); | 2475 V8_INLINE static Function* Cast(Value* obj); |
| 2460 static const int kLineOffsetNotFound; | 2476 static const int kLineOffsetNotFound; |
| 2461 | 2477 |
| 2462 private: | 2478 private: |
| 2463 Function(); | 2479 Function(); |
| 2464 static void CheckCast(Value* obj); | 2480 static void CheckCast(Value* obj); |
| 2465 }; | 2481 }; |
| 2466 | 2482 |
| 2467 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 2483 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
| 2468 // The number of required internal fields can be defined by embedder. | 2484 // The number of required internal fields can be defined by embedder. |
| 2469 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 2485 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2489 /** | 2505 /** |
| 2490 * Allocate |length| bytes. Return NULL if allocation is not successful. | 2506 * Allocate |length| bytes. Return NULL if allocation is not successful. |
| 2491 * Memory should be initialized to zeroes. | 2507 * Memory should be initialized to zeroes. |
| 2492 */ | 2508 */ |
| 2493 virtual void* Allocate(size_t length) = 0; | 2509 virtual void* Allocate(size_t length) = 0; |
| 2494 | 2510 |
| 2495 /** | 2511 /** |
| 2496 * Allocate |length| bytes. Return NULL if allocation is not successful. | 2512 * Allocate |length| bytes. Return NULL if allocation is not successful. |
| 2497 * Memory does not have to be initialized. | 2513 * Memory does not have to be initialized. |
| 2498 */ | 2514 */ |
| 2499 virtual void* AllocateUninitialized(size_t length) { | 2515 virtual void* AllocateUninitialized(size_t length) = 0; |
| 2500 // Override with call to |Allocate| for compatibility | |
| 2501 // with legacy version. | |
| 2502 return Allocate(length); | |
| 2503 } | |
| 2504 | |
| 2505 /** | 2516 /** |
| 2506 * Free the memory block of size |length|, pointed to by |data|. | 2517 * Free the memory block of size |length|, pointed to by |data|. |
| 2507 * That memory is guaranteed to be previously allocated by |Allocate|. | 2518 * That memory is guaranteed to be previously allocated by |Allocate|. |
| 2508 */ | 2519 */ |
| 2509 virtual void Free(void* data, size_t length) { | 2520 virtual void Free(void* data, size_t length) = 0; |
| 2510 // Override with call to |Free(void*)| for compatibility | |
| 2511 // with legacy version. | |
| 2512 Free(data); | |
| 2513 } | |
| 2514 | |
| 2515 /** | |
| 2516 * Deprecated. Never called directly by V8. | |
| 2517 * For compatibility with legacy version of this interface. | |
| 2518 */ | |
| 2519 virtual void Free(void* data); | |
| 2520 }; | 2521 }; |
| 2521 | 2522 |
| 2522 /** | 2523 /** |
| 2523 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| | 2524 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| |
| 2524 * returns an instance of this class, populated, with a pointer to data | 2525 * returns an instance of this class, populated, with a pointer to data |
| 2525 * and byte length. | 2526 * and byte length. |
| 2526 * | 2527 * |
| 2527 * The Data pointer of ArrayBuffer::Contents is always allocated with | 2528 * The Data pointer of ArrayBuffer::Contents is always allocated with |
| 2528 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. | 2529 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. |
| 2529 * | 2530 * |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 * Make this ArrayBuffer external. The pointer to underlying memory block | 2584 * Make this ArrayBuffer external. The pointer to underlying memory block |
| 2584 * and byte length are returned as |Contents| structure. After ArrayBuffer | 2585 * and byte length are returned as |Contents| structure. After ArrayBuffer |
| 2585 * had been etxrenalized, it does no longer owns the memory block. The caller | 2586 * had been etxrenalized, it does no longer owns the memory block. The caller |
| 2586 * should take steps to free memory when it is no longer needed. | 2587 * should take steps to free memory when it is no longer needed. |
| 2587 * | 2588 * |
| 2588 * The memory block is guaranteed to be allocated with |Allocator::Allocate| | 2589 * The memory block is guaranteed to be allocated with |Allocator::Allocate| |
| 2589 * that has been set with V8::SetArrayBufferAllocator. | 2590 * that has been set with V8::SetArrayBufferAllocator. |
| 2590 */ | 2591 */ |
| 2591 Contents Externalize(); | 2592 Contents Externalize(); |
| 2592 | 2593 |
| 2593 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); | 2594 V8_INLINE static ArrayBuffer* Cast(Value* obj); |
| 2594 | 2595 |
| 2595 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | 2596 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; |
| 2596 | 2597 |
| 2597 private: | 2598 private: |
| 2598 ArrayBuffer(); | 2599 ArrayBuffer(); |
| 2599 static void CheckCast(Value* obj); | 2600 static void CheckCast(Value* obj); |
| 2600 }; | 2601 }; |
| 2601 | 2602 |
| 2602 | 2603 |
| 2603 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT | 2604 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2624 size_t ByteOffset(); | 2625 size_t ByteOffset(); |
| 2625 /** | 2626 /** |
| 2626 * Size of a view in bytes. | 2627 * Size of a view in bytes. |
| 2627 */ | 2628 */ |
| 2628 size_t ByteLength(); | 2629 size_t ByteLength(); |
| 2629 /** | 2630 /** |
| 2630 * Base address of a view. | 2631 * Base address of a view. |
| 2631 */ | 2632 */ |
| 2632 void* BaseAddress(); | 2633 void* BaseAddress(); |
| 2633 | 2634 |
| 2634 V8_INLINE(static ArrayBufferView* Cast(Value* obj)); | 2635 V8_INLINE static ArrayBufferView* Cast(Value* obj); |
| 2635 | 2636 |
| 2636 static const int kInternalFieldCount = | 2637 static const int kInternalFieldCount = |
| 2637 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; | 2638 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; |
| 2638 | 2639 |
| 2639 private: | 2640 private: |
| 2640 ArrayBufferView(); | 2641 ArrayBufferView(); |
| 2641 static void CheckCast(Value* obj); | 2642 static void CheckCast(Value* obj); |
| 2642 }; | 2643 }; |
| 2643 | 2644 |
| 2644 | 2645 |
| 2645 /** | 2646 /** |
| 2646 * A base class for an instance of TypedArray series of constructors | 2647 * A base class for an instance of TypedArray series of constructors |
| 2647 * (ES6 draft 15.13.6). | 2648 * (ES6 draft 15.13.6). |
| 2648 * This API is experimental and may change significantly. | 2649 * This API is experimental and may change significantly. |
| 2649 */ | 2650 */ |
| 2650 class V8_EXPORT TypedArray : public ArrayBufferView { | 2651 class V8_EXPORT TypedArray : public ArrayBufferView { |
| 2651 public: | 2652 public: |
| 2652 /** | 2653 /** |
| 2653 * Number of elements in this typed array | 2654 * Number of elements in this typed array |
| 2654 * (e.g. for Int16Array, |ByteLength|/2). | 2655 * (e.g. for Int16Array, |ByteLength|/2). |
| 2655 */ | 2656 */ |
| 2656 size_t Length(); | 2657 size_t Length(); |
| 2657 | 2658 |
| 2658 V8_INLINE(static TypedArray* Cast(Value* obj)); | 2659 V8_INLINE static TypedArray* Cast(Value* obj); |
| 2659 | 2660 |
| 2660 private: | 2661 private: |
| 2661 TypedArray(); | 2662 TypedArray(); |
| 2662 static void CheckCast(Value* obj); | 2663 static void CheckCast(Value* obj); |
| 2663 }; | 2664 }; |
| 2664 | 2665 |
| 2665 | 2666 |
| 2666 /** | 2667 /** |
| 2667 * An instance of Uint8Array constructor (ES6 draft 15.13.6). | 2668 * An instance of Uint8Array constructor (ES6 draft 15.13.6). |
| 2668 * This API is experimental and may change significantly. | 2669 * This API is experimental and may change significantly. |
| 2669 */ | 2670 */ |
| 2670 class V8_EXPORT Uint8Array : public TypedArray { | 2671 class V8_EXPORT Uint8Array : public TypedArray { |
| 2671 public: | 2672 public: |
| 2672 static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer, | 2673 static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer, |
| 2673 size_t byte_offset, size_t length); | 2674 size_t byte_offset, size_t length); |
| 2674 V8_INLINE(static Uint8Array* Cast(Value* obj)); | 2675 V8_INLINE static Uint8Array* Cast(Value* obj); |
| 2675 | 2676 |
| 2676 private: | 2677 private: |
| 2677 Uint8Array(); | 2678 Uint8Array(); |
| 2678 static void CheckCast(Value* obj); | 2679 static void CheckCast(Value* obj); |
| 2679 }; | 2680 }; |
| 2680 | 2681 |
| 2681 | 2682 |
| 2682 /** | 2683 /** |
| 2683 * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). | 2684 * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). |
| 2684 * This API is experimental and may change significantly. | 2685 * This API is experimental and may change significantly. |
| 2685 */ | 2686 */ |
| 2686 class V8_EXPORT Uint8ClampedArray : public TypedArray { | 2687 class V8_EXPORT Uint8ClampedArray : public TypedArray { |
| 2687 public: | 2688 public: |
| 2688 static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer, | 2689 static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer, |
| 2689 size_t byte_offset, size_t length); | 2690 size_t byte_offset, size_t length); |
| 2690 V8_INLINE(static Uint8ClampedArray* Cast(Value* obj)); | 2691 V8_INLINE static Uint8ClampedArray* Cast(Value* obj); |
| 2691 | 2692 |
| 2692 private: | 2693 private: |
| 2693 Uint8ClampedArray(); | 2694 Uint8ClampedArray(); |
| 2694 static void CheckCast(Value* obj); | 2695 static void CheckCast(Value* obj); |
| 2695 }; | 2696 }; |
| 2696 | 2697 |
| 2697 /** | 2698 /** |
| 2698 * An instance of Int8Array constructor (ES6 draft 15.13.6). | 2699 * An instance of Int8Array constructor (ES6 draft 15.13.6). |
| 2699 * This API is experimental and may change significantly. | 2700 * This API is experimental and may change significantly. |
| 2700 */ | 2701 */ |
| 2701 class V8_EXPORT Int8Array : public TypedArray { | 2702 class V8_EXPORT Int8Array : public TypedArray { |
| 2702 public: | 2703 public: |
| 2703 static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer, | 2704 static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer, |
| 2704 size_t byte_offset, size_t length); | 2705 size_t byte_offset, size_t length); |
| 2705 V8_INLINE(static Int8Array* Cast(Value* obj)); | 2706 V8_INLINE static Int8Array* Cast(Value* obj); |
| 2706 | 2707 |
| 2707 private: | 2708 private: |
| 2708 Int8Array(); | 2709 Int8Array(); |
| 2709 static void CheckCast(Value* obj); | 2710 static void CheckCast(Value* obj); |
| 2710 }; | 2711 }; |
| 2711 | 2712 |
| 2712 | 2713 |
| 2713 /** | 2714 /** |
| 2714 * An instance of Uint16Array constructor (ES6 draft 15.13.6). | 2715 * An instance of Uint16Array constructor (ES6 draft 15.13.6). |
| 2715 * This API is experimental and may change significantly. | 2716 * This API is experimental and may change significantly. |
| 2716 */ | 2717 */ |
| 2717 class V8_EXPORT Uint16Array : public TypedArray { | 2718 class V8_EXPORT Uint16Array : public TypedArray { |
| 2718 public: | 2719 public: |
| 2719 static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer, | 2720 static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer, |
| 2720 size_t byte_offset, size_t length); | 2721 size_t byte_offset, size_t length); |
| 2721 V8_INLINE(static Uint16Array* Cast(Value* obj)); | 2722 V8_INLINE static Uint16Array* Cast(Value* obj); |
| 2722 | 2723 |
| 2723 private: | 2724 private: |
| 2724 Uint16Array(); | 2725 Uint16Array(); |
| 2725 static void CheckCast(Value* obj); | 2726 static void CheckCast(Value* obj); |
| 2726 }; | 2727 }; |
| 2727 | 2728 |
| 2728 | 2729 |
| 2729 /** | 2730 /** |
| 2730 * An instance of Int16Array constructor (ES6 draft 15.13.6). | 2731 * An instance of Int16Array constructor (ES6 draft 15.13.6). |
| 2731 * This API is experimental and may change significantly. | 2732 * This API is experimental and may change significantly. |
| 2732 */ | 2733 */ |
| 2733 class V8_EXPORT Int16Array : public TypedArray { | 2734 class V8_EXPORT Int16Array : public TypedArray { |
| 2734 public: | 2735 public: |
| 2735 static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer, | 2736 static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer, |
| 2736 size_t byte_offset, size_t length); | 2737 size_t byte_offset, size_t length); |
| 2737 V8_INLINE(static Int16Array* Cast(Value* obj)); | 2738 V8_INLINE static Int16Array* Cast(Value* obj); |
| 2738 | 2739 |
| 2739 private: | 2740 private: |
| 2740 Int16Array(); | 2741 Int16Array(); |
| 2741 static void CheckCast(Value* obj); | 2742 static void CheckCast(Value* obj); |
| 2742 }; | 2743 }; |
| 2743 | 2744 |
| 2744 | 2745 |
| 2745 /** | 2746 /** |
| 2746 * An instance of Uint32Array constructor (ES6 draft 15.13.6). | 2747 * An instance of Uint32Array constructor (ES6 draft 15.13.6). |
| 2747 * This API is experimental and may change significantly. | 2748 * This API is experimental and may change significantly. |
| 2748 */ | 2749 */ |
| 2749 class V8_EXPORT Uint32Array : public TypedArray { | 2750 class V8_EXPORT Uint32Array : public TypedArray { |
| 2750 public: | 2751 public: |
| 2751 static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer, | 2752 static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer, |
| 2752 size_t byte_offset, size_t length); | 2753 size_t byte_offset, size_t length); |
| 2753 V8_INLINE(static Uint32Array* Cast(Value* obj)); | 2754 V8_INLINE static Uint32Array* Cast(Value* obj); |
| 2754 | 2755 |
| 2755 private: | 2756 private: |
| 2756 Uint32Array(); | 2757 Uint32Array(); |
| 2757 static void CheckCast(Value* obj); | 2758 static void CheckCast(Value* obj); |
| 2758 }; | 2759 }; |
| 2759 | 2760 |
| 2760 | 2761 |
| 2761 /** | 2762 /** |
| 2762 * An instance of Int32Array constructor (ES6 draft 15.13.6). | 2763 * An instance of Int32Array constructor (ES6 draft 15.13.6). |
| 2763 * This API is experimental and may change significantly. | 2764 * This API is experimental and may change significantly. |
| 2764 */ | 2765 */ |
| 2765 class V8_EXPORT Int32Array : public TypedArray { | 2766 class V8_EXPORT Int32Array : public TypedArray { |
| 2766 public: | 2767 public: |
| 2767 static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer, | 2768 static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer, |
| 2768 size_t byte_offset, size_t length); | 2769 size_t byte_offset, size_t length); |
| 2769 V8_INLINE(static Int32Array* Cast(Value* obj)); | 2770 V8_INLINE static Int32Array* Cast(Value* obj); |
| 2770 | 2771 |
| 2771 private: | 2772 private: |
| 2772 Int32Array(); | 2773 Int32Array(); |
| 2773 static void CheckCast(Value* obj); | 2774 static void CheckCast(Value* obj); |
| 2774 }; | 2775 }; |
| 2775 | 2776 |
| 2776 | 2777 |
| 2777 /** | 2778 /** |
| 2778 * An instance of Float32Array constructor (ES6 draft 15.13.6). | 2779 * An instance of Float32Array constructor (ES6 draft 15.13.6). |
| 2779 * This API is experimental and may change significantly. | 2780 * This API is experimental and may change significantly. |
| 2780 */ | 2781 */ |
| 2781 class V8_EXPORT Float32Array : public TypedArray { | 2782 class V8_EXPORT Float32Array : public TypedArray { |
| 2782 public: | 2783 public: |
| 2783 static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer, | 2784 static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer, |
| 2784 size_t byte_offset, size_t length); | 2785 size_t byte_offset, size_t length); |
| 2785 V8_INLINE(static Float32Array* Cast(Value* obj)); | 2786 V8_INLINE static Float32Array* Cast(Value* obj); |
| 2786 | 2787 |
| 2787 private: | 2788 private: |
| 2788 Float32Array(); | 2789 Float32Array(); |
| 2789 static void CheckCast(Value* obj); | 2790 static void CheckCast(Value* obj); |
| 2790 }; | 2791 }; |
| 2791 | 2792 |
| 2792 | 2793 |
| 2793 /** | 2794 /** |
| 2794 * An instance of Float64Array constructor (ES6 draft 15.13.6). | 2795 * An instance of Float64Array constructor (ES6 draft 15.13.6). |
| 2795 * This API is experimental and may change significantly. | 2796 * This API is experimental and may change significantly. |
| 2796 */ | 2797 */ |
| 2797 class V8_EXPORT Float64Array : public TypedArray { | 2798 class V8_EXPORT Float64Array : public TypedArray { |
| 2798 public: | 2799 public: |
| 2799 static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer, | 2800 static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer, |
| 2800 size_t byte_offset, size_t length); | 2801 size_t byte_offset, size_t length); |
| 2801 V8_INLINE(static Float64Array* Cast(Value* obj)); | 2802 V8_INLINE static Float64Array* Cast(Value* obj); |
| 2802 | 2803 |
| 2803 private: | 2804 private: |
| 2804 Float64Array(); | 2805 Float64Array(); |
| 2805 static void CheckCast(Value* obj); | 2806 static void CheckCast(Value* obj); |
| 2806 }; | 2807 }; |
| 2807 | 2808 |
| 2808 | 2809 |
| 2809 /** | 2810 /** |
| 2810 * An instance of DataView constructor (ES6 draft 15.13.7). | 2811 * An instance of DataView constructor (ES6 draft 15.13.7). |
| 2811 * This API is experimental and may change significantly. | 2812 * This API is experimental and may change significantly. |
| 2812 */ | 2813 */ |
| 2813 class V8_EXPORT DataView : public ArrayBufferView { | 2814 class V8_EXPORT DataView : public ArrayBufferView { |
| 2814 public: | 2815 public: |
| 2815 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, | 2816 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, |
| 2816 size_t byte_offset, size_t length); | 2817 size_t byte_offset, size_t length); |
| 2817 V8_INLINE(static DataView* Cast(Value* obj)); | 2818 V8_INLINE static DataView* Cast(Value* obj); |
| 2818 | 2819 |
| 2819 private: | 2820 private: |
| 2820 DataView(); | 2821 DataView(); |
| 2821 static void CheckCast(Value* obj); | 2822 static void CheckCast(Value* obj); |
| 2822 }; | 2823 }; |
| 2823 | 2824 |
| 2824 | 2825 |
| 2825 /** | 2826 /** |
| 2826 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 2827 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 2827 */ | 2828 */ |
| 2828 class V8_EXPORT Date : public Object { | 2829 class V8_EXPORT Date : public Object { |
| 2829 public: | 2830 public: |
| 2830 static Local<Value> New(double time); | 2831 static Local<Value> New(double time); |
| 2831 | 2832 |
| 2832 // Deprecated, use Date::ValueOf() instead. | 2833 // Deprecated, use Date::ValueOf() instead. |
| 2833 // TODO(svenpanne) Actually deprecate when Chrome is adapted. | 2834 // TODO(svenpanne) Actually deprecate when Chrome is adapted. |
| 2834 double NumberValue() const { return ValueOf(); } | 2835 double NumberValue() const { return ValueOf(); } |
| 2835 | 2836 |
| 2836 /** | 2837 /** |
| 2837 * A specialization of Value::NumberValue that is more efficient | 2838 * A specialization of Value::NumberValue that is more efficient |
| 2838 * because we know the structure of this object. | 2839 * because we know the structure of this object. |
| 2839 */ | 2840 */ |
| 2840 double ValueOf() const; | 2841 double ValueOf() const; |
| 2841 | 2842 |
| 2842 V8_INLINE(static Date* Cast(v8::Value* obj)); | 2843 V8_INLINE static Date* Cast(v8::Value* obj); |
| 2843 | 2844 |
| 2844 /** | 2845 /** |
| 2845 * Notification that the embedder has changed the time zone, | 2846 * Notification that the embedder has changed the time zone, |
| 2846 * daylight savings time, or other date / time configuration | 2847 * daylight savings time, or other date / time configuration |
| 2847 * parameters. V8 keeps a cache of various values used for | 2848 * parameters. V8 keeps a cache of various values used for |
| 2848 * date / time computation. This notification will reset | 2849 * date / time computation. This notification will reset |
| 2849 * those cached values for the current context so that date / | 2850 * those cached values for the current context so that date / |
| 2850 * time configuration changes would be reflected in the Date | 2851 * time configuration changes would be reflected in the Date |
| 2851 * object. | 2852 * object. |
| 2852 * | 2853 * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2869 | 2870 |
| 2870 // Deprecated, use NumberObject::ValueOf() instead. | 2871 // Deprecated, use NumberObject::ValueOf() instead. |
| 2871 // TODO(svenpanne) Actually deprecate when Chrome is adapted. | 2872 // TODO(svenpanne) Actually deprecate when Chrome is adapted. |
| 2872 double NumberValue() const { return ValueOf(); } | 2873 double NumberValue() const { return ValueOf(); } |
| 2873 | 2874 |
| 2874 /** | 2875 /** |
| 2875 * Returns the Number held by the object. | 2876 * Returns the Number held by the object. |
| 2876 */ | 2877 */ |
| 2877 double ValueOf() const; | 2878 double ValueOf() const; |
| 2878 | 2879 |
| 2879 V8_INLINE(static NumberObject* Cast(v8::Value* obj)); | 2880 V8_INLINE static NumberObject* Cast(v8::Value* obj); |
| 2880 | 2881 |
| 2881 private: | 2882 private: |
| 2882 static void CheckCast(v8::Value* obj); | 2883 static void CheckCast(v8::Value* obj); |
| 2883 }; | 2884 }; |
| 2884 | 2885 |
| 2885 | 2886 |
| 2886 /** | 2887 /** |
| 2887 * A Boolean object (ECMA-262, 4.3.15). | 2888 * A Boolean object (ECMA-262, 4.3.15). |
| 2888 */ | 2889 */ |
| 2889 class V8_EXPORT BooleanObject : public Object { | 2890 class V8_EXPORT BooleanObject : public Object { |
| 2890 public: | 2891 public: |
| 2891 static Local<Value> New(bool value); | 2892 static Local<Value> New(bool value); |
| 2892 | 2893 |
| 2893 // Deprecated, use BooleanObject::ValueOf() instead. | 2894 // Deprecated, use BooleanObject::ValueOf() instead. |
| 2894 // TODO(svenpanne) Actually deprecate when Chrome is adapted. | 2895 // TODO(svenpanne) Actually deprecate when Chrome is adapted. |
| 2895 bool BooleanValue() const { return ValueOf(); } | 2896 bool BooleanValue() const { return ValueOf(); } |
| 2896 | 2897 |
| 2897 /** | 2898 /** |
| 2898 * Returns the Boolean held by the object. | 2899 * Returns the Boolean held by the object. |
| 2899 */ | 2900 */ |
| 2900 bool ValueOf() const; | 2901 bool ValueOf() const; |
| 2901 | 2902 |
| 2902 V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); | 2903 V8_INLINE static BooleanObject* Cast(v8::Value* obj); |
| 2903 | 2904 |
| 2904 private: | 2905 private: |
| 2905 static void CheckCast(v8::Value* obj); | 2906 static void CheckCast(v8::Value* obj); |
| 2906 }; | 2907 }; |
| 2907 | 2908 |
| 2908 | 2909 |
| 2909 /** | 2910 /** |
| 2910 * A String object (ECMA-262, 4.3.18). | 2911 * A String object (ECMA-262, 4.3.18). |
| 2911 */ | 2912 */ |
| 2912 class V8_EXPORT StringObject : public Object { | 2913 class V8_EXPORT StringObject : public Object { |
| 2913 public: | 2914 public: |
| 2914 static Local<Value> New(Handle<String> value); | 2915 static Local<Value> New(Handle<String> value); |
| 2915 | 2916 |
| 2916 // Deprecated, use StringObject::ValueOf() instead. | 2917 // Deprecated, use StringObject::ValueOf() instead. |
| 2917 // TODO(svenpanne) Actually deprecate when Chrome is adapted. | 2918 // TODO(svenpanne) Actually deprecate when Chrome is adapted. |
| 2918 Local<String> StringValue() const { return ValueOf(); } | 2919 Local<String> StringValue() const { return ValueOf(); } |
| 2919 | 2920 |
| 2920 /** | 2921 /** |
| 2921 * Returns the String held by the object. | 2922 * Returns the String held by the object. |
| 2922 */ | 2923 */ |
| 2923 Local<String> ValueOf() const; | 2924 Local<String> ValueOf() const; |
| 2924 | 2925 |
| 2925 V8_INLINE(static StringObject* Cast(v8::Value* obj)); | 2926 V8_INLINE static StringObject* Cast(v8::Value* obj); |
| 2926 | 2927 |
| 2927 private: | 2928 private: |
| 2928 static void CheckCast(v8::Value* obj); | 2929 static void CheckCast(v8::Value* obj); |
| 2929 }; | 2930 }; |
| 2930 | 2931 |
| 2931 | 2932 |
| 2932 /** | 2933 /** |
| 2933 * A Symbol object (ECMA-262 edition 6). | 2934 * A Symbol object (ECMA-262 edition 6). |
| 2934 * | 2935 * |
| 2935 * This is an experimental feature. Use at your own risk. | 2936 * This is an experimental feature. Use at your own risk. |
| 2936 */ | 2937 */ |
| 2937 class V8_EXPORT SymbolObject : public Object { | 2938 class V8_EXPORT SymbolObject : public Object { |
| 2938 public: | 2939 public: |
| 2939 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); | 2940 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); |
| 2940 | 2941 |
| 2941 // Deprecated, use SymbolObject::ValueOf() instead. | 2942 // Deprecated, use SymbolObject::ValueOf() instead. |
| 2942 // TODO(svenpanne) Actually deprecate when Chrome is adapted. | 2943 // TODO(svenpanne) Actually deprecate when Chrome is adapted. |
| 2943 Local<Symbol> SymbolValue() const { return ValueOf(); } | 2944 Local<Symbol> SymbolValue() const { return ValueOf(); } |
| 2944 | 2945 |
| 2945 /** | 2946 /** |
| 2946 * Returns the Symbol held by the object. | 2947 * Returns the Symbol held by the object. |
| 2947 */ | 2948 */ |
| 2948 Local<Symbol> ValueOf() const; | 2949 Local<Symbol> ValueOf() const; |
| 2949 | 2950 |
| 2950 V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); | 2951 V8_INLINE static SymbolObject* Cast(v8::Value* obj); |
| 2951 | 2952 |
| 2952 private: | 2953 private: |
| 2953 static void CheckCast(v8::Value* obj); | 2954 static void CheckCast(v8::Value* obj); |
| 2954 }; | 2955 }; |
| 2955 | 2956 |
| 2956 | 2957 |
| 2957 /** | 2958 /** |
| 2958 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | 2959 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). |
| 2959 */ | 2960 */ |
| 2960 class V8_EXPORT RegExp : public Object { | 2961 class V8_EXPORT RegExp : public Object { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2986 * Returns the value of the source property: a string representing | 2987 * Returns the value of the source property: a string representing |
| 2987 * the regular expression. | 2988 * the regular expression. |
| 2988 */ | 2989 */ |
| 2989 Local<String> GetSource() const; | 2990 Local<String> GetSource() const; |
| 2990 | 2991 |
| 2991 /** | 2992 /** |
| 2992 * Returns the flags bit field. | 2993 * Returns the flags bit field. |
| 2993 */ | 2994 */ |
| 2994 Flags GetFlags() const; | 2995 Flags GetFlags() const; |
| 2995 | 2996 |
| 2996 V8_INLINE(static RegExp* Cast(v8::Value* obj)); | 2997 V8_INLINE static RegExp* Cast(v8::Value* obj); |
| 2997 | 2998 |
| 2998 private: | 2999 private: |
| 2999 static void CheckCast(v8::Value* obj); | 3000 static void CheckCast(v8::Value* obj); |
| 3000 }; | 3001 }; |
| 3001 | 3002 |
| 3002 | 3003 |
| 3003 /** | 3004 /** |
| 3004 * A JavaScript value that wraps a C++ void*. This type of value is mainly used | 3005 * A JavaScript value that wraps a C++ void*. This type of value is mainly used |
| 3005 * to associate C++ data structures with JavaScript objects. | 3006 * to associate C++ data structures with JavaScript objects. |
| 3006 */ | 3007 */ |
| 3007 class V8_EXPORT External : public Value { | 3008 class V8_EXPORT External : public Value { |
| 3008 public: | 3009 public: |
| 3009 static Local<External> New(void* value); | 3010 static Local<External> New(void* value); |
| 3010 V8_INLINE(static External* Cast(Value* obj)); | 3011 V8_INLINE static External* Cast(Value* obj); |
| 3011 void* Value() const; | 3012 void* Value() const; |
| 3012 private: | 3013 private: |
| 3013 static void CheckCast(v8::Value* obj); | 3014 static void CheckCast(v8::Value* obj); |
| 3014 }; | 3015 }; |
| 3015 | 3016 |
| 3016 | 3017 |
| 3017 // --- Templates --- | 3018 // --- Templates --- |
| 3018 | 3019 |
| 3019 | 3020 |
| 3020 /** | 3021 /** |
| 3021 * The superclass of object and function templates. | 3022 * The superclass of object and function templates. |
| 3022 */ | 3023 */ |
| 3023 class V8_EXPORT Template : public Data { | 3024 class V8_EXPORT Template : public Data { |
| 3024 public: | 3025 public: |
| 3025 /** Adds a property to each instance created by this template.*/ | 3026 /** Adds a property to each instance created by this template.*/ |
| 3026 void Set(Handle<String> name, Handle<Data> value, | 3027 void Set(Handle<String> name, Handle<Data> value, |
| 3027 PropertyAttribute attributes = None); | 3028 PropertyAttribute attributes = None); |
| 3028 V8_INLINE(void Set(const char* name, Handle<Data> value)); | 3029 V8_INLINE void Set(const char* name, Handle<Data> value); |
| 3029 | 3030 |
| 3030 void SetAccessorProperty( | 3031 void SetAccessorProperty( |
| 3031 Local<String> name, | 3032 Local<String> name, |
| 3032 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), | 3033 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), |
| 3033 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), | 3034 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), |
| 3034 PropertyAttribute attribute = None, | 3035 PropertyAttribute attribute = None, |
| 3035 AccessControl settings = DEFAULT); | 3036 AccessControl settings = DEFAULT); |
| 3036 | 3037 |
| 3037 /** | 3038 /** |
| 3038 * Whenever the property with the given name is accessed on objects | 3039 * Whenever the property with the given name is accessed on objects |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3695 | 3696 |
| 3696 | 3697 |
| 3697 void V8_EXPORT RegisterExtension(Extension* extension); | 3698 void V8_EXPORT RegisterExtension(Extension* extension); |
| 3698 | 3699 |
| 3699 | 3700 |
| 3700 /** | 3701 /** |
| 3701 * Ignore | 3702 * Ignore |
| 3702 */ | 3703 */ |
| 3703 class V8_EXPORT DeclareExtension { | 3704 class V8_EXPORT DeclareExtension { |
| 3704 public: | 3705 public: |
| 3705 V8_INLINE(DeclareExtension(Extension* extension)) { | 3706 V8_INLINE DeclareExtension(Extension* extension) { |
| 3706 RegisterExtension(extension); | 3707 RegisterExtension(extension); |
| 3707 } | 3708 } |
| 3708 }; | 3709 }; |
| 3709 | 3710 |
| 3710 | 3711 |
| 3711 // --- Statics --- | 3712 // --- Statics --- |
| 3712 | 3713 |
| 3713 | 3714 |
| 3714 Handle<Primitive> V8_EXPORT Undefined(); | 3715 Handle<Primitive> V8_EXPORT Undefined(); |
| 3715 Handle<Primitive> V8_EXPORT Null(); | 3716 Handle<Primitive> V8_EXPORT Null(); |
| 3716 Handle<Boolean> V8_EXPORT True(); | 3717 Handle<Boolean> V8_EXPORT True(); |
| 3717 Handle<Boolean> V8_EXPORT False(); | 3718 Handle<Boolean> V8_EXPORT False(); |
| 3718 | 3719 |
| 3719 V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate)); | 3720 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate); |
| 3720 V8_INLINE(Handle<Primitive> Null(Isolate* isolate)); | 3721 V8_INLINE Handle<Primitive> Null(Isolate* isolate); |
| 3721 V8_INLINE(Handle<Boolean> True(Isolate* isolate)); | 3722 V8_INLINE Handle<Boolean> True(Isolate* isolate); |
| 3722 V8_INLINE(Handle<Boolean> False(Isolate* isolate)); | 3723 V8_INLINE Handle<Boolean> False(Isolate* isolate); |
| 3723 | 3724 |
| 3724 | 3725 |
| 3725 /** | 3726 /** |
| 3726 * A set of constraints that specifies the limits of the runtime's memory use. | 3727 * A set of constraints that specifies the limits of the runtime's memory use. |
| 3727 * You must set the heap size before initializing the VM - the size cannot be | 3728 * You must set the heap size before initializing the VM - the size cannot be |
| 3728 * adjusted after the VM is initialized. | 3729 * adjusted after the VM is initialized. |
| 3729 * | 3730 * |
| 3730 * If you are using threads then you should hold the V8::Locker lock while | 3731 * If you are using threads then you should hold the V8::Locker lock while |
| 3731 * setting the stack limit and you must set a non-default stack limit separately | 3732 * setting the stack limit and you must set a non-default stack limit separately |
| 3732 * for each thread. | 3733 * for each thread. |
| 3733 */ | 3734 */ |
| 3734 class V8_EXPORT ResourceConstraints { | 3735 class V8_EXPORT ResourceConstraints { |
| 3735 public: | 3736 public: |
| 3736 ResourceConstraints(); | 3737 ResourceConstraints(); |
| 3737 int max_young_space_size() const { return max_young_space_size_; } | 3738 int max_young_space_size() const { return max_young_space_size_; } |
| 3738 void set_max_young_space_size(int value) { max_young_space_size_ = value; } | 3739 void set_max_young_space_size(int value) { max_young_space_size_ = value; } |
| 3739 int max_old_space_size() const { return max_old_space_size_; } | 3740 int max_old_space_size() const { return max_old_space_size_; } |
| 3740 void set_max_old_space_size(int value) { max_old_space_size_ = value; } | 3741 void set_max_old_space_size(int value) { max_old_space_size_ = value; } |
| 3741 int max_executable_size() { return max_executable_size_; } | 3742 int max_executable_size() { return max_executable_size_; } |
| 3742 void set_max_executable_size(int value) { max_executable_size_ = value; } | 3743 void set_max_executable_size(int value) { max_executable_size_ = value; } |
| 3743 uint32_t* stack_limit() const { return stack_limit_; } | 3744 uint32_t* stack_limit() const { return stack_limit_; } |
| 3744 // Sets an address beyond which the VM's stack may not grow. | 3745 // Sets an address beyond which the VM's stack may not grow. |
| 3745 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | 3746 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } |
| 3747 Maybe<bool> is_memory_constrained() const { return is_memory_constrained_; } |
| 3748 // If set to true, V8 will limit it's memory usage, at the potential cost of |
| 3749 // lower performance. Note, this option is a tentative addition to the API |
| 3750 // and may be removed or modified without warning. |
| 3751 void set_memory_constrained(bool value) { |
| 3752 is_memory_constrained_ = Maybe<bool>(value); |
| 3753 } |
| 3754 |
| 3746 private: | 3755 private: |
| 3747 int max_young_space_size_; | 3756 int max_young_space_size_; |
| 3748 int max_old_space_size_; | 3757 int max_old_space_size_; |
| 3749 int max_executable_size_; | 3758 int max_executable_size_; |
| 3750 uint32_t* stack_limit_; | 3759 uint32_t* stack_limit_; |
| 3760 Maybe<bool> is_memory_constrained_; |
| 3751 }; | 3761 }; |
| 3752 | 3762 |
| 3753 | 3763 |
| 3754 bool V8_EXPORT SetResourceConstraints(ResourceConstraints* constraints); | 3764 bool V8_EXPORT SetResourceConstraints(ResourceConstraints* constraints); |
| 3755 | 3765 |
| 3756 | 3766 |
| 3757 // --- Exceptions --- | 3767 // --- Exceptions --- |
| 3758 | 3768 |
| 3759 | 3769 |
| 3760 typedef void (*FatalErrorCallback)(const char* location, const char* message); | 3770 typedef void (*FatalErrorCallback)(const char* location, const char* message); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 | 3971 |
| 3962 /** | 3972 /** |
| 3963 * Disposes the isolate. The isolate must not be entered by any | 3973 * Disposes the isolate. The isolate must not be entered by any |
| 3964 * thread to be disposable. | 3974 * thread to be disposable. |
| 3965 */ | 3975 */ |
| 3966 void Dispose(); | 3976 void Dispose(); |
| 3967 | 3977 |
| 3968 /** | 3978 /** |
| 3969 * Associate embedder-specific data with the isolate | 3979 * Associate embedder-specific data with the isolate |
| 3970 */ | 3980 */ |
| 3971 V8_INLINE(void SetData(void* data)); | 3981 V8_INLINE void SetData(void* data); |
| 3972 | 3982 |
| 3973 /** | 3983 /** |
| 3974 * Retrieve embedder-specific data from the isolate. | 3984 * Retrieve embedder-specific data from the isolate. |
| 3975 * Returns NULL if SetData has never been called. | 3985 * Returns NULL if SetData has never been called. |
| 3976 */ | 3986 */ |
| 3977 V8_INLINE(void* GetData()); | 3987 V8_INLINE void* GetData(); |
| 3978 | 3988 |
| 3979 /** | 3989 /** |
| 3980 * Get statistics about the heap memory usage. | 3990 * Get statistics about the heap memory usage. |
| 3981 */ | 3991 */ |
| 3982 void GetHeapStatistics(HeapStatistics* heap_statistics); | 3992 void GetHeapStatistics(HeapStatistics* heap_statistics); |
| 3983 | 3993 |
| 3984 /** | 3994 /** |
| 3985 * Adjusts the amount of registered external memory. Used to give V8 an | 3995 * Adjusts the amount of registered external memory. Used to give V8 an |
| 3986 * indication of the amount of externally allocated memory that is kept alive | 3996 * indication of the amount of externally allocated memory that is kept alive |
| 3987 * by JavaScript objects. V8 uses this to decide when to perform global | 3997 * by JavaScript objects. V8 uses this to decide when to perform global |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4239 | 4249 |
| 4240 | 4250 |
| 4241 /** | 4251 /** |
| 4242 * Asserts that no action is performed that could cause a handle's value | 4252 * Asserts that no action is performed that could cause a handle's value |
| 4243 * to be modified. Useful when otherwise unsafe handle operations need to | 4253 * to be modified. Useful when otherwise unsafe handle operations need to |
| 4244 * be performed. | 4254 * be performed. |
| 4245 */ | 4255 */ |
| 4246 class V8_EXPORT AssertNoGCScope { | 4256 class V8_EXPORT AssertNoGCScope { |
| 4247 #ifndef DEBUG | 4257 #ifndef DEBUG |
| 4248 // TODO(yangguo): remove isolate argument. | 4258 // TODO(yangguo): remove isolate argument. |
| 4249 V8_INLINE(AssertNoGCScope(Isolate* isolate)) { } | 4259 V8_INLINE AssertNoGCScope(Isolate* isolate) {} |
| 4250 #else | 4260 #else |
| 4251 AssertNoGCScope(Isolate* isolate); | 4261 AssertNoGCScope(Isolate* isolate); |
| 4252 ~AssertNoGCScope(); | 4262 ~AssertNoGCScope(); |
| 4253 private: | 4263 private: |
| 4254 void* disallow_heap_allocation_; | 4264 void* disallow_heap_allocation_; |
| 4255 #endif | 4265 #endif |
| 4256 }; | 4266 }; |
| 4257 | 4267 |
| 4258 | 4268 |
| 4259 /** | 4269 /** |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4942 static bool InContext(); | 4952 static bool InContext(); |
| 4943 | 4953 |
| 4944 /** Returns an isolate associated with a current context. */ | 4954 /** Returns an isolate associated with a current context. */ |
| 4945 v8::Isolate* GetIsolate(); | 4955 v8::Isolate* GetIsolate(); |
| 4946 | 4956 |
| 4947 /** | 4957 /** |
| 4948 * Gets the embedder data with the given index, which must have been set by a | 4958 * Gets the embedder data with the given index, which must have been set by a |
| 4949 * previous call to SetEmbedderData with the same index. Note that index 0 | 4959 * previous call to SetEmbedderData with the same index. Note that index 0 |
| 4950 * currently has a special meaning for Chrome's debugger. | 4960 * currently has a special meaning for Chrome's debugger. |
| 4951 */ | 4961 */ |
| 4952 V8_INLINE(Local<Value> GetEmbedderData(int index)); | 4962 V8_INLINE Local<Value> GetEmbedderData(int index); |
| 4953 | 4963 |
| 4954 /** | 4964 /** |
| 4955 * Sets the embedder data with the given index, growing the data as | 4965 * Sets the embedder data with the given index, growing the data as |
| 4956 * needed. Note that index 0 currently has a special meaning for Chrome's | 4966 * needed. Note that index 0 currently has a special meaning for Chrome's |
| 4957 * debugger. | 4967 * debugger. |
| 4958 */ | 4968 */ |
| 4959 void SetEmbedderData(int index, Handle<Value> value); | 4969 void SetEmbedderData(int index, Handle<Value> value); |
| 4960 | 4970 |
| 4961 /** | 4971 /** |
| 4962 * Gets a 2-byte-aligned native pointer from the embedder data with the given | 4972 * Gets a 2-byte-aligned native pointer from the embedder data with the given |
| 4963 * index, which must have bees set by a previous call to | 4973 * index, which must have bees set by a previous call to |
| 4964 * SetAlignedPointerInEmbedderData with the same index. Note that index 0 | 4974 * SetAlignedPointerInEmbedderData with the same index. Note that index 0 |
| 4965 * currently has a special meaning for Chrome's debugger. | 4975 * currently has a special meaning for Chrome's debugger. |
| 4966 */ | 4976 */ |
| 4967 V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); | 4977 V8_INLINE void* GetAlignedPointerFromEmbedderData(int index); |
| 4968 | 4978 |
| 4969 /** | 4979 /** |
| 4970 * Sets a 2-byte-aligned native pointer in the embedder data with the given | 4980 * Sets a 2-byte-aligned native pointer in the embedder data with the given |
| 4971 * index, growing the data as needed. Note that index 0 currently has a | 4981 * index, growing the data as needed. Note that index 0 currently has a |
| 4972 * special meaning for Chrome's debugger. | 4982 * special meaning for Chrome's debugger. |
| 4973 */ | 4983 */ |
| 4974 void SetAlignedPointerInEmbedderData(int index, void* value); | 4984 void SetAlignedPointerInEmbedderData(int index, void* value); |
| 4975 | 4985 |
| 4976 /** | 4986 /** |
| 4977 * Control whether code generation from strings is allowed. Calling | 4987 * Control whether code generation from strings is allowed. Calling |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5000 * constructor are called. | 5010 * constructor are called. |
| 5001 */ | 5011 */ |
| 5002 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); | 5012 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); |
| 5003 | 5013 |
| 5004 /** | 5014 /** |
| 5005 * Stack-allocated class which sets the execution context for all | 5015 * Stack-allocated class which sets the execution context for all |
| 5006 * operations executed within a local scope. | 5016 * operations executed within a local scope. |
| 5007 */ | 5017 */ |
| 5008 class Scope { | 5018 class Scope { |
| 5009 public: | 5019 public: |
| 5010 explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) { | 5020 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) { |
| 5011 context_->Enter(); | 5021 context_->Enter(); |
| 5012 } | 5022 } |
| 5013 // TODO(dcarney): deprecate | 5023 // TODO(dcarney): deprecate |
| 5014 V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT | 5024 V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context) // NOLINT |
| 5015 : context_(Handle<Context>::New(isolate, context)) { | 5025 : context_(Handle<Context>::New(isolate, context)) { |
| 5016 context_->Enter(); | 5026 context_->Enter(); |
| 5017 } | 5027 } |
| 5018 V8_INLINE(~Scope()) { context_->Exit(); } | 5028 V8_INLINE ~Scope() { context_->Exit(); } |
| 5019 | 5029 |
| 5020 private: | 5030 private: |
| 5021 Handle<Context> context_; | 5031 Handle<Context> context_; |
| 5022 }; | 5032 }; |
| 5023 | 5033 |
| 5024 private: | 5034 private: |
| 5025 friend class Value; | 5035 friend class Value; |
| 5026 friend class Script; | 5036 friend class Script; |
| 5027 friend class Object; | 5037 friend class Object; |
| 5028 friend class Function; | 5038 friend class Function; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5106 * // V8 still locked (1 level). | 5116 * // V8 still locked (1 level). |
| 5107 * } | 5117 * } |
| 5108 * // V8 Now no longer locked. | 5118 * // V8 Now no longer locked. |
| 5109 * \endcode | 5119 * \endcode |
| 5110 */ | 5120 */ |
| 5111 class V8_EXPORT Unlocker { | 5121 class V8_EXPORT Unlocker { |
| 5112 public: | 5122 public: |
| 5113 /** | 5123 /** |
| 5114 * Initialize Unlocker for a given Isolate. | 5124 * Initialize Unlocker for a given Isolate. |
| 5115 */ | 5125 */ |
| 5116 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } | 5126 V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); } |
| 5117 | 5127 |
| 5118 /** Deprecated. Use Isolate version instead. */ | 5128 /** Deprecated. Use Isolate version instead. */ |
| 5119 V8_DEPRECATED(Unlocker()); | 5129 V8_DEPRECATED(Unlocker()); |
| 5120 | 5130 |
| 5121 ~Unlocker(); | 5131 ~Unlocker(); |
| 5122 private: | 5132 private: |
| 5123 void Initialize(Isolate* isolate); | 5133 void Initialize(Isolate* isolate); |
| 5124 | 5134 |
| 5125 internal::Isolate* isolate_; | 5135 internal::Isolate* isolate_; |
| 5126 }; | 5136 }; |
| 5127 | 5137 |
| 5128 | 5138 |
| 5129 class V8_EXPORT Locker { | 5139 class V8_EXPORT Locker { |
| 5130 public: | 5140 public: |
| 5131 /** | 5141 /** |
| 5132 * Initialize Locker for a given Isolate. | 5142 * Initialize Locker for a given Isolate. |
| 5133 */ | 5143 */ |
| 5134 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } | 5144 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } |
| 5135 | 5145 |
| 5136 /** Deprecated. Use Isolate version instead. */ | 5146 /** Deprecated. Use Isolate version instead. */ |
| 5137 V8_DEPRECATED(Locker()); | 5147 V8_DEPRECATED(Locker()); |
| 5138 | 5148 |
| 5139 ~Locker(); | 5149 ~Locker(); |
| 5140 | 5150 |
| 5141 /** | 5151 /** |
| 5142 * Start preemption. | 5152 * Start preemption. |
| 5143 * | 5153 * |
| 5144 * When preemption is started, a timer is fired every n milliseconds | 5154 * When preemption is started, a timer is fired every n milliseconds |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5253 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; | 5263 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; |
| 5254 | 5264 |
| 5255 // Tag information for Smi. | 5265 // Tag information for Smi. |
| 5256 const int kSmiTag = 0; | 5266 const int kSmiTag = 0; |
| 5257 const int kSmiTagSize = 1; | 5267 const int kSmiTagSize = 1; |
| 5258 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | 5268 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; |
| 5259 | 5269 |
| 5260 template <size_t ptr_size> struct SmiTagging; | 5270 template <size_t ptr_size> struct SmiTagging; |
| 5261 | 5271 |
| 5262 template<int kSmiShiftSize> | 5272 template<int kSmiShiftSize> |
| 5263 V8_INLINE(internal::Object* IntToSmi(int value)) { | 5273 V8_INLINE internal::Object* IntToSmi(int value) { |
| 5264 int smi_shift_bits = kSmiTagSize + kSmiShiftSize; | 5274 int smi_shift_bits = kSmiTagSize + kSmiShiftSize; |
| 5265 intptr_t tagged_value = | 5275 intptr_t tagged_value = |
| 5266 (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; | 5276 (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; |
| 5267 return reinterpret_cast<internal::Object*>(tagged_value); | 5277 return reinterpret_cast<internal::Object*>(tagged_value); |
| 5268 } | 5278 } |
| 5269 | 5279 |
| 5270 // Smi constants for 32-bit systems. | 5280 // Smi constants for 32-bit systems. |
| 5271 template <> struct SmiTagging<4> { | 5281 template <> struct SmiTagging<4> { |
| 5272 static const int kSmiShiftSize = 0; | 5282 static const int kSmiShiftSize = 0; |
| 5273 static const int kSmiValueSize = 31; | 5283 static const int kSmiValueSize = 31; |
| 5274 V8_INLINE(static int SmiToInt(internal::Object* value)) { | 5284 V8_INLINE static int SmiToInt(internal::Object* value) { |
| 5275 int shift_bits = kSmiTagSize + kSmiShiftSize; | 5285 int shift_bits = kSmiTagSize + kSmiShiftSize; |
| 5276 // Throw away top 32 bits and shift down (requires >> to be sign extending). | 5286 // Throw away top 32 bits and shift down (requires >> to be sign extending). |
| 5277 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; | 5287 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; |
| 5278 } | 5288 } |
| 5279 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5289 V8_INLINE static internal::Object* IntToSmi(int value) { |
| 5280 return internal::IntToSmi<kSmiShiftSize>(value); | 5290 return internal::IntToSmi<kSmiShiftSize>(value); |
| 5281 } | 5291 } |
| 5282 V8_INLINE(static bool IsValidSmi(intptr_t value)) { | 5292 V8_INLINE static bool IsValidSmi(intptr_t value) { |
| 5283 // To be representable as an tagged small integer, the two | 5293 // To be representable as an tagged small integer, the two |
| 5284 // most-significant bits of 'value' must be either 00 or 11 due to | 5294 // most-significant bits of 'value' must be either 00 or 11 due to |
| 5285 // sign-extension. To check this we add 01 to the two | 5295 // sign-extension. To check this we add 01 to the two |
| 5286 // most-significant bits, and check if the most-significant bit is 0 | 5296 // most-significant bits, and check if the most-significant bit is 0 |
| 5287 // | 5297 // |
| 5288 // CAUTION: The original code below: | 5298 // CAUTION: The original code below: |
| 5289 // bool result = ((value + 0x40000000) & 0x80000000) == 0; | 5299 // bool result = ((value + 0x40000000) & 0x80000000) == 0; |
| 5290 // may lead to incorrect results according to the C language spec, and | 5300 // may lead to incorrect results according to the C language spec, and |
| 5291 // in fact doesn't work correctly with gcc4.1.1 in some cases: The | 5301 // in fact doesn't work correctly with gcc4.1.1 in some cases: The |
| 5292 // compiler may produce undefined results in case of signed integer | 5302 // compiler may produce undefined results in case of signed integer |
| 5293 // overflow. The computation must be done w/ unsigned ints. | 5303 // overflow. The computation must be done w/ unsigned ints. |
| 5294 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; | 5304 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; |
| 5295 } | 5305 } |
| 5296 }; | 5306 }; |
| 5297 | 5307 |
| 5298 // Smi constants for 64-bit systems. | 5308 // Smi constants for 64-bit systems. |
| 5299 template <> struct SmiTagging<8> { | 5309 template <> struct SmiTagging<8> { |
| 5300 static const int kSmiShiftSize = 31; | 5310 static const int kSmiShiftSize = 31; |
| 5301 static const int kSmiValueSize = 32; | 5311 static const int kSmiValueSize = 32; |
| 5302 V8_INLINE(static int SmiToInt(internal::Object* value)) { | 5312 V8_INLINE static int SmiToInt(internal::Object* value) { |
| 5303 int shift_bits = kSmiTagSize + kSmiShiftSize; | 5313 int shift_bits = kSmiTagSize + kSmiShiftSize; |
| 5304 // Shift down and throw away top 32 bits. | 5314 // Shift down and throw away top 32 bits. |
| 5305 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); | 5315 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); |
| 5306 } | 5316 } |
| 5307 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5317 V8_INLINE static internal::Object* IntToSmi(int value) { |
| 5308 return internal::IntToSmi<kSmiShiftSize>(value); | 5318 return internal::IntToSmi<kSmiShiftSize>(value); |
| 5309 } | 5319 } |
| 5310 V8_INLINE(static bool IsValidSmi(intptr_t value)) { | 5320 V8_INLINE static bool IsValidSmi(intptr_t value) { |
| 5311 // To be representable as a long smi, the value must be a 32-bit integer. | 5321 // To be representable as a long smi, the value must be a 32-bit integer. |
| 5312 return (value == static_cast<int32_t>(value)); | 5322 return (value == static_cast<int32_t>(value)); |
| 5313 } | 5323 } |
| 5314 }; | 5324 }; |
| 5315 | 5325 |
| 5316 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | 5326 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; |
| 5317 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | 5327 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; |
| 5318 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | 5328 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; |
| 5319 V8_INLINE(static bool SmiValuesAre31Bits()) { return kSmiValueSize == 31; } | 5329 V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } |
| 5320 V8_INLINE(static bool SmiValuesAre32Bits()) { return kSmiValueSize == 32; } | 5330 V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } |
| 5321 | 5331 |
| 5322 /** | 5332 /** |
| 5323 * This class exports constants and functionality from within v8 that | 5333 * This class exports constants and functionality from within v8 that |
| 5324 * is necessary to implement inline functions in the v8 api. Don't | 5334 * is necessary to implement inline functions in the v8 api. Don't |
| 5325 * depend on functions and constants defined here. | 5335 * depend on functions and constants defined here. |
| 5326 */ | 5336 */ |
| 5327 class Internals { | 5337 class Internals { |
| 5328 public: | 5338 public: |
| 5329 // These values match non-compiler-dependent values defined within | 5339 // These values match non-compiler-dependent values defined within |
| 5330 // the implementation of v8. | 5340 // the implementation of v8. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5342 static const int kStringEncodingMask = 0x4; | 5352 static const int kStringEncodingMask = 0x4; |
| 5343 static const int kExternalTwoByteRepresentationTag = 0x02; | 5353 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5344 static const int kExternalAsciiRepresentationTag = 0x06; | 5354 static const int kExternalAsciiRepresentationTag = 0x06; |
| 5345 | 5355 |
| 5346 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 5356 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
| 5347 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 5357 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
| 5348 static const int kUndefinedValueRootIndex = 5; | 5358 static const int kUndefinedValueRootIndex = 5; |
| 5349 static const int kNullValueRootIndex = 7; | 5359 static const int kNullValueRootIndex = 7; |
| 5350 static const int kTrueValueRootIndex = 8; | 5360 static const int kTrueValueRootIndex = 8; |
| 5351 static const int kFalseValueRootIndex = 9; | 5361 static const int kFalseValueRootIndex = 9; |
| 5352 static const int kEmptyStringRootIndex = 133; | 5362 static const int kEmptyStringRootIndex = 131; |
| 5353 | 5363 |
| 5354 static const int kNodeClassIdOffset = 1 * kApiPointerSize; | 5364 static const int kNodeClassIdOffset = 1 * kApiPointerSize; |
| 5355 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | 5365 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; |
| 5356 static const int kNodeStateMask = 0xf; | 5366 static const int kNodeStateMask = 0xf; |
| 5357 static const int kNodeStateIsWeakValue = 2; | 5367 static const int kNodeStateIsWeakValue = 2; |
| 5358 static const int kNodeStateIsPendingValue = 3; | 5368 static const int kNodeStateIsPendingValue = 3; |
| 5359 static const int kNodeStateIsNearDeathValue = 4; | 5369 static const int kNodeStateIsNearDeathValue = 4; |
| 5360 static const int kNodeIsIndependentShift = 4; | 5370 static const int kNodeIsIndependentShift = 4; |
| 5361 static const int kNodeIsPartiallyDependentShift = 5; | 5371 static const int kNodeIsPartiallyDependentShift = 5; |
| 5362 | 5372 |
| 5363 static const int kJSObjectType = 0xb1; | 5373 static const int kJSObjectType = 0xb1; |
| 5364 static const int kFirstNonstringType = 0x80; | 5374 static const int kFirstNonstringType = 0x80; |
| 5365 static const int kOddballType = 0x83; | 5375 static const int kOddballType = 0x83; |
| 5366 static const int kForeignType = 0x87; | 5376 static const int kForeignType = 0x87; |
| 5367 | 5377 |
| 5368 static const int kUndefinedOddballKind = 5; | 5378 static const int kUndefinedOddballKind = 5; |
| 5369 static const int kNullOddballKind = 3; | 5379 static const int kNullOddballKind = 3; |
| 5370 | 5380 |
| 5371 static void CheckInitializedImpl(v8::Isolate* isolate); | 5381 static void CheckInitializedImpl(v8::Isolate* isolate); |
| 5372 V8_INLINE(static void CheckInitialized(v8::Isolate* isolate)) { | 5382 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { |
| 5373 #ifdef V8_ENABLE_CHECKS | 5383 #ifdef V8_ENABLE_CHECKS |
| 5374 CheckInitializedImpl(isolate); | 5384 CheckInitializedImpl(isolate); |
| 5375 #endif | 5385 #endif |
| 5376 } | 5386 } |
| 5377 | 5387 |
| 5378 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { | 5388 V8_INLINE static bool HasHeapObjectTag(internal::Object* value) { |
| 5379 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 5389 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
| 5380 kHeapObjectTag); | 5390 kHeapObjectTag); |
| 5381 } | 5391 } |
| 5382 | 5392 |
| 5383 V8_INLINE(static int SmiValue(internal::Object* value)) { | 5393 V8_INLINE static int SmiValue(internal::Object* value) { |
| 5384 return PlatformSmiTagging::SmiToInt(value); | 5394 return PlatformSmiTagging::SmiToInt(value); |
| 5385 } | 5395 } |
| 5386 | 5396 |
| 5387 V8_INLINE(static internal::Object* IntToSmi(int value)) { | 5397 V8_INLINE static internal::Object* IntToSmi(int value) { |
| 5388 return PlatformSmiTagging::IntToSmi(value); | 5398 return PlatformSmiTagging::IntToSmi(value); |
| 5389 } | 5399 } |
| 5390 | 5400 |
| 5391 V8_INLINE(static bool IsValidSmi(intptr_t value)) { | 5401 V8_INLINE static bool IsValidSmi(intptr_t value) { |
| 5392 return PlatformSmiTagging::IsValidSmi(value); | 5402 return PlatformSmiTagging::IsValidSmi(value); |
| 5393 } | 5403 } |
| 5394 | 5404 |
| 5395 V8_INLINE(static int GetInstanceType(internal::Object* obj)) { | 5405 V8_INLINE static int GetInstanceType(internal::Object* obj) { |
| 5396 typedef internal::Object O; | 5406 typedef internal::Object O; |
| 5397 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | 5407 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); |
| 5398 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | 5408 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); |
| 5399 } | 5409 } |
| 5400 | 5410 |
| 5401 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { | 5411 V8_INLINE static int GetOddballKind(internal::Object* obj) { |
| 5402 typedef internal::Object O; | 5412 typedef internal::Object O; |
| 5403 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | 5413 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); |
| 5404 } | 5414 } |
| 5405 | 5415 |
| 5406 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { | 5416 V8_INLINE static bool IsExternalTwoByteString(int instance_type) { |
| 5407 int representation = (instance_type & kFullStringRepresentationMask); | 5417 int representation = (instance_type & kFullStringRepresentationMask); |
| 5408 return representation == kExternalTwoByteRepresentationTag; | 5418 return representation == kExternalTwoByteRepresentationTag; |
| 5409 } | 5419 } |
| 5410 | 5420 |
| 5411 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { | 5421 V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) { |
| 5412 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5422 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5413 return *addr & static_cast<uint8_t>(1U << shift); | 5423 return *addr & static_cast<uint8_t>(1U << shift); |
| 5414 } | 5424 } |
| 5415 | 5425 |
| 5416 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, | 5426 V8_INLINE static void UpdateNodeFlag(internal::Object** obj, |
| 5417 bool value, int shift)) { | 5427 bool value, int shift) { |
| 5418 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5428 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5419 uint8_t mask = static_cast<uint8_t>(1 << shift); | 5429 uint8_t mask = static_cast<uint8_t>(1 << shift); |
| 5420 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); | 5430 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); |
| 5421 } | 5431 } |
| 5422 | 5432 |
| 5423 V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) { | 5433 V8_INLINE static uint8_t GetNodeState(internal::Object** obj) { |
| 5424 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5434 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5425 return *addr & kNodeStateMask; | 5435 return *addr & kNodeStateMask; |
| 5426 } | 5436 } |
| 5427 | 5437 |
| 5428 V8_INLINE(static void UpdateNodeState(internal::Object** obj, | 5438 V8_INLINE static void UpdateNodeState(internal::Object** obj, |
| 5429 uint8_t value)) { | 5439 uint8_t value) { |
| 5430 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5440 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5431 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); | 5441 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); |
| 5432 } | 5442 } |
| 5433 | 5443 |
| 5434 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { | 5444 V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) { |
| 5435 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 5445 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
| 5436 kIsolateEmbedderDataOffset; | 5446 kIsolateEmbedderDataOffset; |
| 5437 *reinterpret_cast<void**>(addr) = data; | 5447 *reinterpret_cast<void**>(addr) = data; |
| 5438 } | 5448 } |
| 5439 | 5449 |
| 5440 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { | 5450 V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) { |
| 5441 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 5451 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
| 5442 kIsolateEmbedderDataOffset; | 5452 kIsolateEmbedderDataOffset; |
| 5443 return *reinterpret_cast<void**>(addr); | 5453 return *reinterpret_cast<void**>(addr); |
| 5444 } | 5454 } |
| 5445 | 5455 |
| 5446 V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, | 5456 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, |
| 5447 int index)) { | 5457 int index) { |
| 5448 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | 5458 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; |
| 5449 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 5459 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
| 5450 } | 5460 } |
| 5451 | 5461 |
| 5452 template <typename T> | 5462 template <typename T> V8_INLINE static T ReadField(Object* ptr, int offset) { |
| 5453 V8_INLINE(static T ReadField(Object* ptr, int offset)) { | |
| 5454 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 5463 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
| 5455 return *reinterpret_cast<T*>(addr); | 5464 return *reinterpret_cast<T*>(addr); |
| 5456 } | 5465 } |
| 5457 | 5466 |
| 5458 template <typename T> | 5467 template <typename T> |
| 5459 V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { | 5468 V8_INLINE static T ReadEmbedderData(Context* context, int index) { |
| 5460 typedef internal::Object O; | 5469 typedef internal::Object O; |
| 5461 typedef internal::Internals I; | 5470 typedef internal::Internals I; |
| 5462 O* ctx = *reinterpret_cast<O**>(context); | 5471 O* ctx = *reinterpret_cast<O**>(context); |
| 5463 int embedder_data_offset = I::kContextHeaderSize + | 5472 int embedder_data_offset = I::kContextHeaderSize + |
| 5464 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | 5473 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); |
| 5465 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | 5474 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); |
| 5466 int value_offset = | 5475 int value_offset = |
| 5467 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | 5476 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); |
| 5468 return I::ReadField<T>(embedder_data, value_offset); | 5477 return I::ReadField<T>(embedder_data, value_offset); |
| 5469 } | 5478 } |
| 5470 | 5479 |
| 5471 V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } | 5480 V8_INLINE static bool CanCastToHeapObject(void* o) { return false; } |
| 5472 V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } | 5481 V8_INLINE static bool CanCastToHeapObject(Context* o) { return true; } |
| 5473 V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } | 5482 V8_INLINE static bool CanCastToHeapObject(String* o) { return true; } |
| 5474 V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } | 5483 V8_INLINE static bool CanCastToHeapObject(Object* o) { return true; } |
| 5475 V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } | 5484 V8_INLINE static bool CanCastToHeapObject(Message* o) { return true; } |
| 5476 V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; } | 5485 V8_INLINE static bool CanCastToHeapObject(StackTrace* o) { return true; } |
| 5477 V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; } | 5486 V8_INLINE static bool CanCastToHeapObject(StackFrame* o) { return true; } |
| 5478 }; | 5487 }; |
| 5479 | 5488 |
| 5480 } // namespace internal | 5489 } // namespace internal |
| 5481 | 5490 |
| 5482 | 5491 |
| 5483 template <class T> | 5492 template <class T> |
| 5484 Local<T>::Local() : Handle<T>() { } | 5493 Local<T>::Local() : Handle<T>() { } |
| 5485 | 5494 |
| 5486 | 5495 |
| 5487 template <class T> | 5496 template <class T> |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6422 */ | 6431 */ |
| 6423 | 6432 |
| 6424 | 6433 |
| 6425 } // namespace v8 | 6434 } // namespace v8 |
| 6426 | 6435 |
| 6427 | 6436 |
| 6428 #undef TYPE_CHECK | 6437 #undef TYPE_CHECK |
| 6429 | 6438 |
| 6430 | 6439 |
| 6431 #endif // V8_H_ | 6440 #endif // V8_H_ |
| OLD | NEW |