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

Side by Side Diff: include/v8.h

Issue 23494047: Deuglify V8_INLINE and V8_NOINLINE. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | include/v8config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
547 /** 544 /**
548 * The destructor will dispose the Persistent based on the 545 * The destructor will dispose the Persistent based on the
549 * kResetInDestructor flags in the traits class. Since not calling dispose 546 * kResetInDestructor flags in the traits class. Since not calling dispose
550 * can result in a memory leak, it is recommended to always set this flag. 547 * can result in a memory leak, it is recommended to always set this flag.
551 */ 548 */
552 V8_INLINE(~Persistent()) { 549 V8_INLINE ~Persistent() {
553 if (M::kResetInDestructor) Reset(); 550 if (M::kResetInDestructor) Reset();
554 } 551 }
555 552
556 /** 553 /**
557 * If non-empty, destroy the underlying storage cell 554 * If non-empty, destroy the underlying storage cell
558 * IsEmpty() will return true after this call. 555 * IsEmpty() will return true after this call.
559 */ 556 */
560 V8_INLINE(void Reset()); 557 V8_INLINE void Reset();
561 template <class S>
562 /** 558 /**
563 * If non-empty, destroy the underlying storage cell 559 * If non-empty, destroy the underlying storage cell
564 * 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
565 */ 561 */
566 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);
567 /** 564 /**
568 * If non-empty, destroy the underlying storage cell 565 * If non-empty, destroy the underlying storage cell
569 * 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
570 */ 567 */
571 template <class S, class M2> 568 template <class S, class M2>
572 V8_INLINE(void Reset(Isolate* isolate, const Persistent<S, M2>& other)); 569 V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other);
573 // TODO(dcarney): deprecate 570 // TODO(dcarney): deprecate
574 V8_INLINE(void Dispose()) { Reset(); } 571 V8_INLINE void Dispose() { Reset(); }
575 V8_DEPRECATED(V8_INLINE(void Dispose(Isolate* isolate))) { Reset(); } 572 V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); }
576 573
577 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } 574 V8_INLINE bool IsEmpty() const { return val_ == 0; }
578 575
579 // TODO(dcarney): this is pretty useless, fix or remove 576 // TODO(dcarney): this is pretty useless, fix or remove
580 template <class S> 577 template <class S>
581 V8_INLINE(static Persistent<T>& Cast(Persistent<S>& that)) { // NOLINT 578 V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
582 #ifdef V8_ENABLE_CHECKS 579 #ifdef V8_ENABLE_CHECKS
583 // 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
584 // that the handle isn't empty before doing the checked cast. 581 // that the handle isn't empty before doing the checked cast.
585 if (!that.IsEmpty()) T::Cast(*that); 582 if (!that.IsEmpty()) T::Cast(*that);
586 #endif 583 #endif
587 return reinterpret_cast<Persistent<T>&>(that); 584 return reinterpret_cast<Persistent<T>&>(that);
588 } 585 }
589 586
590 // TODO(dcarney): this is pretty useless, fix or remove 587 // TODO(dcarney): this is pretty useless, fix or remove
591 template <class S> V8_INLINE(Persistent<S>& As()) { // NOLINT 588 template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
592 return Persistent<S>::Cast(*this); 589 return Persistent<S>::Cast(*this);
593 } 590 }
594 591
595 template <class S, class M2> V8_INLINE( 592 template <class S, class M2>
596 bool operator==(const Persistent<S, M2>& that) const) { 593 V8_INLINE bool operator==(const Persistent<S, M2>& that) const {
597 internal::Object** a = reinterpret_cast<internal::Object**>(**this); 594 internal::Object** a = reinterpret_cast<internal::Object**>(**this);
598 internal::Object** b = reinterpret_cast<internal::Object**>(*that); 595 internal::Object** b = reinterpret_cast<internal::Object**>(*that);
599 if (a == 0) return b == 0; 596 if (a == 0) return b == 0;
600 if (b == 0) return false; 597 if (b == 0) return false;
601 return *a == *b; 598 return *a == *b;
602 } 599 }
603 600
604 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 {
605 internal::Object** a = reinterpret_cast<internal::Object**>(**this); 602 internal::Object** a = reinterpret_cast<internal::Object**>(**this);
606 internal::Object** b = reinterpret_cast<internal::Object**>(*that); 603 internal::Object** b = reinterpret_cast<internal::Object**>(*that);
607 if (a == 0) return b == 0; 604 if (a == 0) return b == 0;
608 if (b == 0) return false; 605 if (b == 0) return false;
609 return *a == *b; 606 return *a == *b;
610 } 607 }
611 608
612 template <class S, class M2> V8_INLINE( 609 template <class S, class M2>
613 bool operator!=(const Persistent<S, M2>& that) const) { 610 V8_INLINE bool operator!=(const Persistent<S, M2>& that) const {
614 return !operator==(that); 611 return !operator==(that);
615 } 612 }
616 613
617 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 {
618 return !operator==(that); 615 return !operator==(that);
619 } 616 }
620 617
621 template<typename P> 618 template<typename P>
622 V8_INLINE(void SetWeak( 619 V8_INLINE void SetWeak(
623 P* parameter, 620 P* parameter,
624 typename WeakCallbackData<T, P>::Callback callback)); 621 typename WeakCallbackData<T, P>::Callback callback);
625 622
626 template<typename S, typename P> 623 template<typename S, typename P>
627 V8_INLINE(void SetWeak( 624 V8_INLINE void SetWeak(
628 P* parameter, 625 P* parameter,
629 typename WeakCallbackData<S, P>::Callback callback)); 626 typename WeakCallbackData<S, P>::Callback callback);
630 627
631 // TODO(dcarney): deprecate 628 // TODO(dcarney): deprecate
632 template<typename S, typename P> 629 template<typename S, typename P>
633 V8_INLINE(void MakeWeak( 630 V8_INLINE void MakeWeak(
634 P* parameter, 631 P* parameter,
635 typename WeakReferenceCallbacks<S, P>::Revivable callback)); 632 typename WeakReferenceCallbacks<S, P>::Revivable callback);
636 633
637 // TODO(dcarney): deprecate 634 // TODO(dcarney): deprecate
638 template<typename P> 635 template<typename P>
639 V8_INLINE(void MakeWeak( 636 V8_INLINE void MakeWeak(
640 P* parameter, 637 P* parameter,
641 typename WeakReferenceCallbacks<T, P>::Revivable callback)); 638 typename WeakReferenceCallbacks<T, P>::Revivable callback);
642 639
643 V8_INLINE(void ClearWeak()); 640 V8_INLINE void ClearWeak();
644 641
645 V8_DEPRECATED(V8_INLINE(void ClearWeak(Isolate* isolate))) { ClearWeak(); } 642 V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); }
646 643
647 /** 644 /**
648 * Marks the reference to this object independent. Garbage collector is free 645 * Marks the reference to this object independent. Garbage collector is free
649 * 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
650 * 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
651 * GC prologue callback or followed by a global GC epilogue callback. 648 * GC prologue callback or followed by a global GC epilogue callback.
652 */ 649 */
653 V8_INLINE(void MarkIndependent()); 650 V8_INLINE void MarkIndependent();
654 651
655 V8_DEPRECATED(V8_INLINE(void MarkIndependent(Isolate* isolate))) { 652 V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) {
656 MarkIndependent(); 653 MarkIndependent();
657 } 654 }
658 655
659 /** 656 /**
660 * Marks the reference to this object partially dependent. Partially dependent 657 * Marks the reference to this object partially dependent. Partially dependent
661 * handles only depend on other partially dependent handles and these 658 * handles only depend on other partially dependent handles and these
662 * 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
663 * 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
664 * external dependencies. This mark is automatically cleared after each 661 * external dependencies. This mark is automatically cleared after each
665 * garbage collection. 662 * garbage collection.
666 */ 663 */
667 V8_INLINE(void MarkPartiallyDependent()); 664 V8_INLINE void MarkPartiallyDependent();
668 665
669 V8_DEPRECATED(V8_INLINE(void MarkPartiallyDependent(Isolate* isolate))) { 666 V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) {
670 MarkPartiallyDependent(); 667 MarkPartiallyDependent();
671 } 668 }
672 669
673 V8_INLINE(bool IsIndependent() const); 670 V8_INLINE bool IsIndependent() const;
674 671
675 V8_DEPRECATED(V8_INLINE(bool IsIndependent(Isolate* isolate)) const) { 672 V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) {
676 return IsIndependent(); 673 return IsIndependent();
677 } 674 }
678 675
679 /** Checks if the handle holds the only reference to an object. */ 676 /** Checks if the handle holds the only reference to an object. */
680 V8_INLINE(bool IsNearDeath() const); 677 V8_INLINE bool IsNearDeath() const;
681 678
682 V8_DEPRECATED(V8_INLINE(bool IsNearDeath(Isolate* isolate)) const) { 679 V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) {
683 return IsNearDeath(); 680 return IsNearDeath();
684 } 681 }
685 682
686 /** Returns true if the handle's reference is weak. */ 683 /** Returns true if the handle's reference is weak. */
687 V8_INLINE(bool IsWeak() const); 684 V8_INLINE bool IsWeak() const;
688 685
689 V8_DEPRECATED(V8_INLINE(bool IsWeak(Isolate* isolate)) const) { 686 V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) {
690 return IsWeak(); 687 return IsWeak();
691 } 688 }
692 689
693 /** 690 /**
694 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface 691 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
695 * description in v8-profiler.h for details. 692 * description in v8-profiler.h for details.
696 */ 693 */
697 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); 694 V8_INLINE void SetWrapperClassId(uint16_t class_id);
698 695
699 V8_DEPRECATED( 696 V8_DEPRECATED(
700 V8_INLINE(void SetWrapperClassId(Isolate * isolate, uint16_t class_id))) { 697 V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id)) {
701 SetWrapperClassId(class_id); 698 SetWrapperClassId(class_id);
702 } 699 }
703 700
704 /** 701 /**
705 * 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
706 * was previously assigned. 703 * was previously assigned.
707 */ 704 */
708 V8_INLINE(uint16_t WrapperClassId() const); 705 V8_INLINE uint16_t WrapperClassId() const;
709 706
710 V8_DEPRECATED(V8_INLINE(uint16_t WrapperClassId(Isolate* isolate)) const) { 707 V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) {
711 return WrapperClassId(); 708 return WrapperClassId();
712 } 709 }
713 710
714 // TODO(dcarney): remove 711 // TODO(dcarney): remove
715 V8_INLINE(T* ClearAndLeak()); 712 V8_INLINE T* ClearAndLeak();
716 713
717 // TODO(dcarney): remove 714 // TODO(dcarney): remove
718 V8_INLINE(void Clear()) { val_ = 0; } 715 V8_INLINE void Clear() { val_ = 0; }
719 716
720 // TODO(dcarney): remove 717 // TODO(dcarney): remove
721 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 718 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
722 719
723 private: 720 private:
724 #endif 721 #endif
725 template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } 722 template <class S> V8_INLINE Persistent(S* that) : val_(that) { }
726 723
727 V8_INLINE(T* operator*() const) { return val_; } 724 V8_INLINE T* operator*() const { return val_; }
728 725
729 private: 726 private:
730 friend class Utils; 727 friend class Utils;
731 template<class F> friend class Handle; 728 template<class F> friend class Handle;
732 template<class F> friend class Local; 729 template<class F> friend class Local;
733 template<class F1, class F2> friend class Persistent; 730 template<class F1, class F2> friend class Persistent;
734 template<class F> friend class ReturnValue; 731 template<class F> friend class ReturnValue;
735 732
736 V8_INLINE(static T* New(Isolate* isolate, T* that)); 733 V8_INLINE static T* New(Isolate* isolate, T* that);
737 template<class S, class M2> 734 template<class S, class M2>
738 V8_INLINE(void Copy(const Persistent<S, M2>& that)); 735 V8_INLINE void Copy(const Persistent<S, M2>& that);
739 736
740 T* val_; 737 T* val_;
741 }; 738 };
742 739
743 /** 740 /**
744 * A stack-allocated class that governs a number of local handles. 741 * A stack-allocated class that governs a number of local handles.
745 * 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
746 * allocated within that handle scope until either the handle scope is 743 * allocated within that handle scope until either the handle scope is
747 * 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
748 * 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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 void* operator new(size_t size); 785 void* operator new(size_t size);
789 void operator delete(void*, size_t); 786 void operator delete(void*, size_t);
790 787
791 // This Data class is accessible internally as HandleScopeData through a 788 // This Data class is accessible internally as HandleScopeData through a
792 // typedef in the ImplementationUtilities class. 789 // typedef in the ImplementationUtilities class.
793 class V8_EXPORT Data { 790 class V8_EXPORT Data {
794 public: 791 public:
795 internal::Object** next; 792 internal::Object** next;
796 internal::Object** limit; 793 internal::Object** limit;
797 int level; 794 int level;
798 V8_INLINE(void Initialize()) { 795 V8_INLINE void Initialize() {
799 next = limit = NULL; 796 next = limit = NULL;
800 level = 0; 797 level = 0;
801 } 798 }
802 }; 799 };
803 800
804 void Initialize(Isolate* isolate); 801 void Initialize(Isolate* isolate);
805 void Leave(); 802 void Leave();
806 803
807 internal::Isolate* isolate_; 804 internal::Isolate* isolate_;
808 internal::Object** prev_next_; 805 internal::Object** prev_next_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 */ 894 */
898 virtual bool HasError() = 0; 895 virtual bool HasError() = 0;
899 }; 896 };
900 897
901 898
902 /** 899 /**
903 * The origin, within a file, of a script. 900 * The origin, within a file, of a script.
904 */ 901 */
905 class ScriptOrigin { 902 class ScriptOrigin {
906 public: 903 public:
907 V8_INLINE(ScriptOrigin( 904 V8_INLINE ScriptOrigin(
908 Handle<Value> resource_name, 905 Handle<Value> resource_name,
909 Handle<Integer> resource_line_offset = Handle<Integer>(), 906 Handle<Integer> resource_line_offset = Handle<Integer>(),
910 Handle<Integer> resource_column_offset = Handle<Integer>(), 907 Handle<Integer> resource_column_offset = Handle<Integer>(),
911 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>())) 908 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>())
912 : resource_name_(resource_name), 909 : resource_name_(resource_name),
913 resource_line_offset_(resource_line_offset), 910 resource_line_offset_(resource_line_offset),
914 resource_column_offset_(resource_column_offset), 911 resource_column_offset_(resource_column_offset),
915 resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { } 912 resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { }
916 V8_INLINE(Handle<Value> ResourceName() const); 913 V8_INLINE Handle<Value> ResourceName() const;
917 V8_INLINE(Handle<Integer> ResourceLineOffset() const); 914 V8_INLINE Handle<Integer> ResourceLineOffset() const;
918 V8_INLINE(Handle<Integer> ResourceColumnOffset() const); 915 V8_INLINE Handle<Integer> ResourceColumnOffset() const;
919 V8_INLINE(Handle<Boolean> ResourceIsSharedCrossOrigin() const); 916 V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
920 private: 917 private:
921 Handle<Value> resource_name_; 918 Handle<Value> resource_name_;
922 Handle<Integer> resource_line_offset_; 919 Handle<Integer> resource_line_offset_;
923 Handle<Integer> resource_column_offset_; 920 Handle<Integer> resource_column_offset_;
924 Handle<Boolean> resource_is_shared_cross_origin_; 921 Handle<Boolean> resource_is_shared_cross_origin_;
925 }; 922 };
926 923
927 924
928 /** 925 /**
929 * A compiled JavaScript script. 926 * A compiled JavaScript script.
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1247
1251 /** 1248 /**
1252 * The superclass of all JavaScript values and objects. 1249 * The superclass of all JavaScript values and objects.
1253 */ 1250 */
1254 class V8_EXPORT Value : public Data { 1251 class V8_EXPORT Value : public Data {
1255 public: 1252 public:
1256 /** 1253 /**
1257 * 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
1258 * 4.3.10. 1255 * 4.3.10.
1259 */ 1256 */
1260 V8_INLINE(bool IsUndefined() const); 1257 V8_INLINE bool IsUndefined() const;
1261 1258
1262 /** 1259 /**
1263 * 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
1264 * 4.3.11. 1261 * 4.3.11.
1265 */ 1262 */
1266 V8_INLINE(bool IsNull() const); 1263 V8_INLINE bool IsNull() const;
1267 1264
1268 /** 1265 /**
1269 * Returns true if this value is true. 1266 * Returns true if this value is true.
1270 */ 1267 */
1271 bool IsTrue() const; 1268 bool IsTrue() const;
1272 1269
1273 /** 1270 /**
1274 * Returns true if this value is false. 1271 * Returns true if this value is false.
1275 */ 1272 */
1276 bool IsFalse() const; 1273 bool IsFalse() const;
1277 1274
1278 /** 1275 /**
1279 * 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.
1280 * See ECMA-262 8.4. 1277 * See ECMA-262 8.4.
1281 */ 1278 */
1282 V8_INLINE(bool IsString() const); 1279 V8_INLINE bool IsString() const;
1283 1280
1284 /** 1281 /**
1285 * Returns true if this value is a symbol. 1282 * Returns true if this value is a symbol.
1286 * This is an experimental feature. 1283 * This is an experimental feature.
1287 */ 1284 */
1288 bool IsSymbol() const; 1285 bool IsSymbol() const;
1289 1286
1290 /** 1287 /**
1291 * Returns true if this value is a function. 1288 * Returns true if this value is a function.
1292 */ 1289 */
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 bool BooleanValue() const; 1457 bool BooleanValue() const;
1461 double NumberValue() const; 1458 double NumberValue() const;
1462 int64_t IntegerValue() const; 1459 int64_t IntegerValue() const;
1463 uint32_t Uint32Value() const; 1460 uint32_t Uint32Value() const;
1464 int32_t Int32Value() const; 1461 int32_t Int32Value() const;
1465 1462
1466 /** JS == */ 1463 /** JS == */
1467 bool Equals(Handle<Value> that) const; 1464 bool Equals(Handle<Value> that) const;
1468 bool StrictEquals(Handle<Value> that) const; 1465 bool StrictEquals(Handle<Value> that) const;
1469 1466
1470 template <class T> V8_INLINE(static Value* Cast(T* value)); 1467 template <class T> V8_INLINE static Value* Cast(T* value);
1471 1468
1472 private: 1469 private:
1473 V8_INLINE(bool QuickIsUndefined() const); 1470 V8_INLINE bool QuickIsUndefined() const;
1474 V8_INLINE(bool QuickIsNull() const); 1471 V8_INLINE bool QuickIsNull() const;
1475 V8_INLINE(bool QuickIsString() const); 1472 V8_INLINE bool QuickIsString() const;
1476 bool FullIsUndefined() const; 1473 bool FullIsUndefined() const;
1477 bool FullIsNull() const; 1474 bool FullIsNull() const;
1478 bool FullIsString() const; 1475 bool FullIsString() const;
1479 }; 1476 };
1480 1477
1481 1478
1482 /** 1479 /**
1483 * The superclass of primitive values. See ECMA-262 4.3.2. 1480 * The superclass of primitive values. See ECMA-262 4.3.2.
1484 */ 1481 */
1485 class V8_EXPORT Primitive : public Value { }; 1482 class V8_EXPORT Primitive : public Value { };
1486 1483
1487 1484
1488 /** 1485 /**
1489 * 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
1490 * or false value. 1487 * or false value.
1491 */ 1488 */
1492 class V8_EXPORT Boolean : public Primitive { 1489 class V8_EXPORT Boolean : public Primitive {
1493 public: 1490 public:
1494 bool Value() const; 1491 bool Value() const;
1495 V8_INLINE(static Handle<Boolean> New(bool value)); 1492 V8_INLINE static Handle<Boolean> New(bool value);
1496 }; 1493 };
1497 1494
1498 1495
1499 /** 1496 /**
1500 * A JavaScript string value (ECMA-262, 4.3.17). 1497 * A JavaScript string value (ECMA-262, 4.3.17).
1501 */ 1498 */
1502 class V8_EXPORT String : public Primitive { 1499 class V8_EXPORT String : public Primitive {
1503 public: 1500 public:
1504 enum Encoding { 1501 enum Encoding {
1505 UNKNOWN_ENCODING = 0x1, 1502 UNKNOWN_ENCODING = 0x1,
1506 TWO_BYTE_ENCODING = 0x0, 1503 TWO_BYTE_ENCODING = 0x0,
1507 ASCII_ENCODING = 0x4, 1504 ASCII_ENCODING = 0x4,
1508 ONE_BYTE_ENCODING = 0x4 1505 ONE_BYTE_ENCODING = 0x4
1509 }; 1506 };
1510 /** 1507 /**
1511 * Returns the number of characters in this string. 1508 * Returns the number of characters in this string.
1512 */ 1509 */
1513 int Length() const; 1510 int Length() const;
1514 1511
1515 /** 1512 /**
1516 * Returns the number of bytes in the UTF-8 encoded 1513 * Returns the number of bytes in the UTF-8 encoded
1517 * representation of this string. 1514 * representation of this string.
1518 */ 1515 */
1519 int Utf8Length() const; 1516 int Utf8Length() const;
1520 1517
1521 /** 1518 /**
1522 * This function is no longer useful. 1519 * This function is no longer useful.
1523 */ 1520 */
1524 V8_DEPRECATED(V8_INLINE(bool MayContainNonAscii()) const) { return true; } 1521 V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; }
1525 1522
1526 /** 1523 /**
1527 * 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.
1528 * Does not read the string. 1525 * Does not read the string.
1529 * False negatives are possible. 1526 * False negatives are possible.
1530 */ 1527 */
1531 bool IsOneByte() const; 1528 bool IsOneByte() const;
1532 1529
1533 /** 1530 /**
1534 * 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
1586 // UTF-8 encoded characters. 1583 // UTF-8 encoded characters.
1587 int WriteUtf8(char* buffer, 1584 int WriteUtf8(char* buffer,
1588 int length = -1, 1585 int length = -1,
1589 int* nchars_ref = NULL, 1586 int* nchars_ref = NULL,
1590 int options = NO_OPTIONS) const; 1587 int options = NO_OPTIONS) const;
1591 1588
1592 /** 1589 /**
1593 * A zero length string. 1590 * A zero length string.
1594 */ 1591 */
1595 static v8::Local<v8::String> Empty(); 1592 static v8::Local<v8::String> Empty();
1596 V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); 1593 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
1597 1594
1598 /** 1595 /**
1599 * Returns true if the string is external 1596 * Returns true if the string is external
1600 */ 1597 */
1601 bool IsExternal() const; 1598 bool IsExternal() const;
1602 1599
1603 /** 1600 /**
1604 * Returns true if the string is both external and ASCII 1601 * Returns true if the string is both external and ASCII
1605 */ 1602 */
1606 bool IsExternalAscii() const; 1603 bool IsExternalAscii() const;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 ExternalAsciiStringResource() {} 1681 ExternalAsciiStringResource() {}
1685 }; 1682 };
1686 1683
1687 typedef ExternalAsciiStringResource ExternalOneByteStringResource; 1684 typedef ExternalAsciiStringResource ExternalOneByteStringResource;
1688 1685
1689 /** 1686 /**
1690 * If the string is an external string, return the ExternalStringResourceBase 1687 * If the string is an external string, return the ExternalStringResourceBase
1691 * regardless of the encoding, otherwise return NULL. The encoding of the 1688 * regardless of the encoding, otherwise return NULL. The encoding of the
1692 * string is returned in encoding_out. 1689 * string is returned in encoding_out.
1693 */ 1690 */
1694 V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( 1691 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
1695 Encoding* encoding_out) const); 1692 Encoding* encoding_out) const;
1696 1693
1697 /** 1694 /**
1698 * Get the ExternalStringResource for an external string. Returns 1695 * Get the ExternalStringResource for an external string. Returns
1699 * NULL if IsExternal() doesn't return true. 1696 * NULL if IsExternal() doesn't return true.
1700 */ 1697 */
1701 V8_INLINE(ExternalStringResource* GetExternalStringResource() const); 1698 V8_INLINE ExternalStringResource* GetExternalStringResource() const;
1702 1699
1703 /** 1700 /**
1704 * Get the ExternalAsciiStringResource for an external ASCII string. 1701 * Get the ExternalAsciiStringResource for an external ASCII string.
1705 * Returns NULL if IsExternalAscii() doesn't return true. 1702 * Returns NULL if IsExternalAscii() doesn't return true.
1706 */ 1703 */
1707 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; 1704 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
1708 1705
1709 V8_INLINE(static String* Cast(v8::Value* obj)); 1706 V8_INLINE static String* Cast(v8::Value* obj);
1710 1707
1711 // TODO(dcarney): deprecate 1708 // TODO(dcarney): deprecate
1712 /** 1709 /**
1713 * 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.
1714 * The second parameter 'length' gives the buffer length. If omitted, 1711 * The second parameter 'length' gives the buffer length. If omitted,
1715 * the function calls 'strlen' to determine the buffer length. 1712 * the function calls 'strlen' to determine the buffer length.
1716 */ 1713 */
1717 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);
1718 1715
1719 // TODO(dcarney): deprecate 1716 // TODO(dcarney): deprecate
1720 /** Allocates a new string from 16-bit character codes.*/ 1717 /** Allocates a new string from 16-bit character codes.*/
1721 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);
1722 1719
1723 // TODO(dcarney): deprecate 1720 // TODO(dcarney): deprecate
1724 /** 1721 /**
1725 * Creates an internalized string (historically called a "symbol", 1722 * Creates an internalized string (historically called a "symbol",
1726 * 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.
1727 */ 1724 */
1728 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);
1729 1726
1730 enum NewStringType { 1727 enum NewStringType {
1731 kNormalString, kInternalizedString, kUndetectableString 1728 kNormalString, kInternalizedString, kUndetectableString
1732 }; 1729 };
1733 1730
1734 /** Allocates a new string from UTF-8 data.*/ 1731 /** Allocates a new string from UTF-8 data.*/
1735 static Local<String> NewFromUtf8(Isolate* isolate, 1732 static Local<String> NewFromUtf8(Isolate* isolate,
1736 const char* data, 1733 const char* data,
1737 NewStringType type = kNormalString, 1734 NewStringType type = kNormalString,
1738 int length = -1); 1735 int length = -1);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 */ 1796 */
1800 bool MakeExternal(ExternalAsciiStringResource* resource); 1797 bool MakeExternal(ExternalAsciiStringResource* resource);
1801 1798
1802 /** 1799 /**
1803 * Returns true if this string can be made external. 1800 * Returns true if this string can be made external.
1804 */ 1801 */
1805 bool CanMakeExternal(); 1802 bool CanMakeExternal();
1806 1803
1807 // TODO(dcarney): deprecate 1804 // TODO(dcarney): deprecate
1808 /** 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.*/
1809 V8_INLINE( 1806 V8_INLINE static Local<String> NewUndetectable(const char* data,
1810 static Local<String> NewUndetectable(const char* data, int length = -1)); 1807 int length = -1);
1811 1808
1812 // TODO(dcarney): deprecate 1809 // TODO(dcarney): deprecate
1813 /** Creates an undetectable string from the supplied 16-bit character codes.*/ 1810 /** Creates an undetectable string from the supplied 16-bit character codes.*/
1814 V8_INLINE(static Local<String> NewUndetectable( 1811 V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
1815 const uint16_t* data, int length = -1)); 1812 int length = -1);
1816 1813
1817 /** 1814 /**
1818 * 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
1819 * 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
1820 * (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)
1821 * then the length() method returns 0 and the * operator returns 1818 * then the length() method returns 0 and the * operator returns
1822 * NULL. 1819 * NULL.
1823 */ 1820 */
1824 class V8_EXPORT Utf8Value { 1821 class V8_EXPORT Utf8Value {
1825 public: 1822 public:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 public: 1897 public:
1901 // 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.
1902 Local<Value> Name() const; 1899 Local<Value> Name() const;
1903 1900
1904 // Create a symbol without a print name. 1901 // Create a symbol without a print name.
1905 static Local<Symbol> New(Isolate* isolate); 1902 static Local<Symbol> New(Isolate* isolate);
1906 1903
1907 // Create a symbol with a print name. 1904 // Create a symbol with a print name.
1908 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);
1909 1906
1910 V8_INLINE(static Symbol* Cast(v8::Value* obj)); 1907 V8_INLINE static Symbol* Cast(v8::Value* obj);
1911 private: 1908 private:
1912 Symbol(); 1909 Symbol();
1913 static void CheckCast(v8::Value* obj); 1910 static void CheckCast(v8::Value* obj);
1914 }; 1911 };
1915 1912
1916 1913
1917 /** 1914 /**
1918 * A JavaScript number value (ECMA-262, 4.3.20) 1915 * A JavaScript number value (ECMA-262, 4.3.20)
1919 */ 1916 */
1920 class V8_EXPORT Number : public Primitive { 1917 class V8_EXPORT Number : public Primitive {
1921 public: 1918 public:
1922 double Value() const; 1919 double Value() const;
1923 static Local<Number> New(double value); 1920 static Local<Number> New(double value);
1924 static Local<Number> New(Isolate* isolate, double value); 1921 static Local<Number> New(Isolate* isolate, double value);
1925 V8_INLINE(static Number* Cast(v8::Value* obj)); 1922 V8_INLINE static Number* Cast(v8::Value* obj);
1926 private: 1923 private:
1927 Number(); 1924 Number();
1928 static void CheckCast(v8::Value* obj); 1925 static void CheckCast(v8::Value* obj);
1929 }; 1926 };
1930 1927
1931 1928
1932 /** 1929 /**
1933 * A JavaScript value representing a signed integer. 1930 * A JavaScript value representing a signed integer.
1934 */ 1931 */
1935 class V8_EXPORT Integer : public Number { 1932 class V8_EXPORT Integer : public Number {
1936 public: 1933 public:
1937 static Local<Integer> New(int32_t value); 1934 static Local<Integer> New(int32_t value);
1938 static Local<Integer> NewFromUnsigned(uint32_t value); 1935 static Local<Integer> NewFromUnsigned(uint32_t value);
1939 static Local<Integer> New(int32_t value, Isolate*); 1936 static Local<Integer> New(int32_t value, Isolate*);
1940 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); 1937 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
1941 int64_t Value() const; 1938 int64_t Value() const;
1942 V8_INLINE(static Integer* Cast(v8::Value* obj)); 1939 V8_INLINE static Integer* Cast(v8::Value* obj);
1943 private: 1940 private:
1944 Integer(); 1941 Integer();
1945 static void CheckCast(v8::Value* obj); 1942 static void CheckCast(v8::Value* obj);
1946 }; 1943 };
1947 1944
1948 1945
1949 /** 1946 /**
1950 * A JavaScript value representing a 32-bit signed integer. 1947 * A JavaScript value representing a 32-bit signed integer.
1951 */ 1948 */
1952 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
2133 2130
2134 /** 2131 /**
2135 * 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.
2136 */ 2133 */
2137 Local<String> GetConstructorName(); 2134 Local<String> GetConstructorName();
2138 2135
2139 /** Gets the number of internal fields for this Object. */ 2136 /** Gets the number of internal fields for this Object. */
2140 int InternalFieldCount(); 2137 int InternalFieldCount();
2141 2138
2142 /** Gets the value from an internal field. */ 2139 /** Gets the value from an internal field. */
2143 V8_INLINE(Local<Value> GetInternalField(int index)); 2140 V8_INLINE Local<Value> GetInternalField(int index);
2144 2141
2145 /** Sets the value in an internal field. */ 2142 /** Sets the value in an internal field. */
2146 void SetInternalField(int index, Handle<Value> value); 2143 void SetInternalField(int index, Handle<Value> value);
2147 2144
2148 /** 2145 /**
2149 * 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
2150 * must have been set by SetAlignedPointerInInternalField, everything else 2147 * must have been set by SetAlignedPointerInInternalField, everything else
2151 * leads to undefined behavior. 2148 * leads to undefined behavior.
2152 */ 2149 */
2153 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); 2150 V8_INLINE void* GetAlignedPointerFromInternalField(int index);
2154 2151
2155 /** 2152 /**
2156 * 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
2157 * a field, GetAlignedPointerFromInternalField must be used, everything else 2154 * a field, GetAlignedPointerFromInternalField must be used, everything else
2158 * leads to undefined behavior. 2155 * leads to undefined behavior.
2159 */ 2156 */
2160 void SetAlignedPointerInInternalField(int index, void* value); 2157 void SetAlignedPointerInInternalField(int index, void* value);
2161 2158
2162 // Testers for local properties. 2159 // Testers for local properties.
2163 bool HasOwnProperty(Handle<String> key); 2160 bool HasOwnProperty(Handle<String> key);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 Handle<Value> argv[]); 2270 Handle<Value> argv[]);
2274 2271
2275 /** 2272 /**
2276 * 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
2277 * ObjectTemplate::SetCallAsFunctionHandler method. 2274 * ObjectTemplate::SetCallAsFunctionHandler method.
2278 * Note: This method behaves like the Function::NewInstance method. 2275 * Note: This method behaves like the Function::NewInstance method.
2279 */ 2276 */
2280 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); 2277 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
2281 2278
2282 static Local<Object> New(); 2279 static Local<Object> New();
2283 V8_INLINE(static Object* Cast(Value* obj)); 2280 V8_INLINE static Object* Cast(Value* obj);
2284 2281
2285 private: 2282 private:
2286 Object(); 2283 Object();
2287 static void CheckCast(Value* obj); 2284 static void CheckCast(Value* obj);
2288 Local<Value> SlowGetInternalField(int index); 2285 Local<Value> SlowGetInternalField(int index);
2289 void* SlowGetAlignedPointerFromInternalField(int index); 2286 void* SlowGetAlignedPointerFromInternalField(int index);
2290 }; 2287 };
2291 2288
2292 2289
2293 /** 2290 /**
2294 * 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).
2295 */ 2292 */
2296 class V8_EXPORT Array : public Object { 2293 class V8_EXPORT Array : public Object {
2297 public: 2294 public:
2298 uint32_t Length() const; 2295 uint32_t Length() const;
2299 2296
2300 /** 2297 /**
2301 * Clones an element at index |index|. Returns an empty 2298 * Clones an element at index |index|. Returns an empty
2302 * handle if cloning fails (for any reason). 2299 * handle if cloning fails (for any reason).
2303 */ 2300 */
2304 Local<Object> CloneElementAt(uint32_t index); 2301 Local<Object> CloneElementAt(uint32_t index);
2305 2302
2306 /** 2303 /**
2307 * Creates a JavaScript array with the given length. If the length 2304 * Creates a JavaScript array with the given length. If the length
2308 * is negative the returned array will have length 0. 2305 * is negative the returned array will have length 0.
2309 */ 2306 */
2310 static Local<Array> New(int length = 0); 2307 static Local<Array> New(int length = 0);
2311 2308
2312 V8_INLINE(static Array* Cast(Value* obj)); 2309 V8_INLINE static Array* Cast(Value* obj);
2313 private: 2310 private:
2314 Array(); 2311 Array();
2315 static void CheckCast(Value* obj); 2312 static void CheckCast(Value* obj);
2316 }; 2313 };
2317 2314
2318 2315
2319 template<typename T> 2316 template<typename T>
2320 class ReturnValue { 2317 class ReturnValue {
2321 public: 2318 public:
2322 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that)) 2319 template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
2323 : value_(that.value_) { 2320 : value_(that.value_) {
2324 TYPE_CHECK(T, S); 2321 TYPE_CHECK(T, S);
2325 } 2322 }
2326 // Handle setters 2323 // Handle setters
2327 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); 2324 template <typename S> V8_INLINE void Set(const Persistent<S>& handle);
2328 template <typename S> V8_INLINE(void Set(const Handle<S> handle)); 2325 template <typename S> V8_INLINE void Set(const Handle<S> handle);
2329 // Fast primitive setters 2326 // Fast primitive setters
2330 V8_INLINE(void Set(bool value)); 2327 V8_INLINE void Set(bool value);
2331 V8_INLINE(void Set(double i)); 2328 V8_INLINE void Set(double i);
2332 V8_INLINE(void Set(int32_t i)); 2329 V8_INLINE void Set(int32_t i);
2333 V8_INLINE(void Set(uint32_t i)); 2330 V8_INLINE void Set(uint32_t i);
2334 // Fast JS primitive setters 2331 // Fast JS primitive setters
2335 V8_INLINE(void SetNull()); 2332 V8_INLINE void SetNull();
2336 V8_INLINE(void SetUndefined()); 2333 V8_INLINE void SetUndefined();
2337 V8_INLINE(void SetEmptyString()); 2334 V8_INLINE void SetEmptyString();
2338 // Convenience getter for Isolate 2335 // Convenience getter for Isolate
2339 V8_INLINE(Isolate* GetIsolate()); 2336 V8_INLINE Isolate* GetIsolate();
2340 2337
2341 private: 2338 private:
2342 template<class F> friend class ReturnValue; 2339 template<class F> friend class ReturnValue;
2343 template<class F> friend class FunctionCallbackInfo; 2340 template<class F> friend class FunctionCallbackInfo;
2344 template<class F> friend class PropertyCallbackInfo; 2341 template<class F> friend class PropertyCallbackInfo;
2345 V8_INLINE(internal::Object* GetDefaultValue()); 2342 V8_INLINE internal::Object* GetDefaultValue();
2346 V8_INLINE(explicit ReturnValue(internal::Object** slot)); 2343 V8_INLINE explicit ReturnValue(internal::Object** slot);
2347 internal::Object** value_; 2344 internal::Object** value_;
2348 }; 2345 };
2349 2346
2350 2347
2351 /** 2348 /**
2352 * The argument information given to function call callbacks. This 2349 * The argument information given to function call callbacks. This
2353 * class provides access to information about the context of the call, 2350 * class provides access to information about the context of the call,
2354 * including the receiver, the number and values of arguments, and 2351 * including the receiver, the number and values of arguments, and
2355 * the holder of the function. 2352 * the holder of the function.
2356 */ 2353 */
2357 template<typename T> 2354 template<typename T>
2358 class FunctionCallbackInfo { 2355 class FunctionCallbackInfo {
2359 public: 2356 public:
2360 V8_INLINE(int Length() const); 2357 V8_INLINE int Length() const;
2361 V8_INLINE(Local<Value> operator[](int i) const); 2358 V8_INLINE Local<Value> operator[](int i) const;
2362 V8_INLINE(Local<Function> Callee() const); 2359 V8_INLINE Local<Function> Callee() const;
2363 V8_INLINE(Local<Object> This() const); 2360 V8_INLINE Local<Object> This() const;
2364 V8_INLINE(Local<Object> Holder() const); 2361 V8_INLINE Local<Object> Holder() const;
2365 V8_INLINE(bool IsConstructCall() const); 2362 V8_INLINE bool IsConstructCall() const;
2366 V8_INLINE(Local<Value> Data() const); 2363 V8_INLINE Local<Value> Data() const;
2367 V8_INLINE(Isolate* GetIsolate() const); 2364 V8_INLINE Isolate* GetIsolate() const;
2368 V8_INLINE(ReturnValue<T> GetReturnValue() const); 2365 V8_INLINE ReturnValue<T> GetReturnValue() const;
2369 // This shouldn't be public, but the arm compiler needs it. 2366 // This shouldn't be public, but the arm compiler needs it.
2370 static const int kArgsLength = 6; 2367 static const int kArgsLength = 6;
2371 2368
2372 protected: 2369 protected:
2373 friend class internal::FunctionCallbackArguments; 2370 friend class internal::FunctionCallbackArguments;
2374 friend class internal::CustomArguments<FunctionCallbackInfo>; 2371 friend class internal::CustomArguments<FunctionCallbackInfo>;
2375 static const int kReturnValueIndex = 0; 2372 static const int kReturnValueIndex = 0;
2376 static const int kReturnValueDefaultValueIndex = -1; 2373 static const int kReturnValueDefaultValueIndex = -1;
2377 static const int kIsolateIndex = -2; 2374 static const int kIsolateIndex = -2;
2378 static const int kDataIndex = -3; 2375 static const int kDataIndex = -3;
2379 static const int kCalleeIndex = -4; 2376 static const int kCalleeIndex = -4;
2380 static const int kHolderIndex = -5; 2377 static const int kHolderIndex = -5;
2381 2378
2382 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, 2379 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
2383 internal::Object** values, 2380 internal::Object** values,
2384 int length, 2381 int length,
2385 bool is_construct_call)); 2382 bool is_construct_call);
2386 internal::Object** implicit_args_; 2383 internal::Object** implicit_args_;
2387 internal::Object** values_; 2384 internal::Object** values_;
2388 int length_; 2385 int length_;
2389 bool is_construct_call_; 2386 bool is_construct_call_;
2390 }; 2387 };
2391 2388
2392 2389
2393 /** 2390 /**
2394 * The information passed to a property callback about the context 2391 * The information passed to a property callback about the context
2395 * of the property access. 2392 * of the property access.
2396 */ 2393 */
2397 template<typename T> 2394 template<typename T>
2398 class PropertyCallbackInfo { 2395 class PropertyCallbackInfo {
2399 public: 2396 public:
2400 V8_INLINE(Isolate* GetIsolate() const); 2397 V8_INLINE Isolate* GetIsolate() const;
2401 V8_INLINE(Local<Value> Data() const); 2398 V8_INLINE Local<Value> Data() const;
2402 V8_INLINE(Local<Object> This() const); 2399 V8_INLINE Local<Object> This() const;
2403 V8_INLINE(Local<Object> Holder() const); 2400 V8_INLINE Local<Object> Holder() const;
2404 V8_INLINE(ReturnValue<T> GetReturnValue() const); 2401 V8_INLINE ReturnValue<T> GetReturnValue() const;
2405 // This shouldn't be public, but the arm compiler needs it. 2402 // This shouldn't be public, but the arm compiler needs it.
2406 static const int kArgsLength = 6; 2403 static const int kArgsLength = 6;
2407 2404
2408 protected: 2405 protected:
2409 friend class MacroAssembler; 2406 friend class MacroAssembler;
2410 friend class internal::PropertyCallbackArguments; 2407 friend class internal::PropertyCallbackArguments;
2411 friend class internal::CustomArguments<PropertyCallbackInfo>; 2408 friend class internal::CustomArguments<PropertyCallbackInfo>;
2412 static const int kThisIndex = 0; 2409 static const int kThisIndex = 0;
2413 static const int kHolderIndex = -1; 2410 static const int kHolderIndex = -1;
2414 static const int kDataIndex = -2; 2411 static const int kDataIndex = -2;
2415 static const int kReturnValueIndex = -3; 2412 static const int kReturnValueIndex = -3;
2416 static const int kReturnValueDefaultValueIndex = -4; 2413 static const int kReturnValueDefaultValueIndex = -4;
2417 static const int kIsolateIndex = -5; 2414 static const int kIsolateIndex = -5;
2418 2415
2419 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) 2416 V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
2420 : args_(args) { }
2421 internal::Object** args_; 2417 internal::Object** args_;
2422 }; 2418 };
2423 2419
2424 2420
2425 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); 2421 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
2426 2422
2427 2423
2428 /** 2424 /**
2429 * A JavaScript function object (ECMA-262, 15.3). 2425 * A JavaScript function object (ECMA-262, 15.3).
2430 */ 2426 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 * DEPRECATED: use ScriptId() instead. 2465 * DEPRECATED: use ScriptId() instead.
2470 */ 2466 */
2471 Handle<Value> GetScriptId() const; 2467 Handle<Value> GetScriptId() const;
2472 2468
2473 /** 2469 /**
2474 * Returns scriptId. 2470 * Returns scriptId.
2475 */ 2471 */
2476 int ScriptId() const; 2472 int ScriptId() const;
2477 2473
2478 ScriptOrigin GetScriptOrigin() const; 2474 ScriptOrigin GetScriptOrigin() const;
2479 V8_INLINE(static Function* Cast(Value* obj)); 2475 V8_INLINE static Function* Cast(Value* obj);
2480 static const int kLineOffsetNotFound; 2476 static const int kLineOffsetNotFound;
2481 2477
2482 private: 2478 private:
2483 Function(); 2479 Function();
2484 static void CheckCast(Value* obj); 2480 static void CheckCast(Value* obj);
2485 }; 2481 };
2486 2482
2487 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2483 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
2488 // The number of required internal fields can be defined by embedder. 2484 // The number of required internal fields can be defined by embedder.
2489 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 2485 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 * Make this ArrayBuffer external. The pointer to underlying memory block 2599 * Make this ArrayBuffer external. The pointer to underlying memory block
2604 * and byte length are returned as |Contents| structure. After ArrayBuffer 2600 * and byte length are returned as |Contents| structure. After ArrayBuffer
2605 * had been etxrenalized, it does no longer owns the memory block. The caller 2601 * had been etxrenalized, it does no longer owns the memory block. The caller
2606 * should take steps to free memory when it is no longer needed. 2602 * should take steps to free memory when it is no longer needed.
2607 * 2603 *
2608 * The memory block is guaranteed to be allocated with |Allocator::Allocate| 2604 * The memory block is guaranteed to be allocated with |Allocator::Allocate|
2609 * that has been set with V8::SetArrayBufferAllocator. 2605 * that has been set with V8::SetArrayBufferAllocator.
2610 */ 2606 */
2611 Contents Externalize(); 2607 Contents Externalize();
2612 2608
2613 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); 2609 V8_INLINE static ArrayBuffer* Cast(Value* obj);
2614 2610
2615 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; 2611 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
2616 2612
2617 private: 2613 private:
2618 ArrayBuffer(); 2614 ArrayBuffer();
2619 static void CheckCast(Value* obj); 2615 static void CheckCast(Value* obj);
2620 }; 2616 };
2621 2617
2622 2618
2623 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2619 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
(...skipping 20 matching lines...) Expand all
2644 size_t ByteOffset(); 2640 size_t ByteOffset();
2645 /** 2641 /**
2646 * Size of a view in bytes. 2642 * Size of a view in bytes.
2647 */ 2643 */
2648 size_t ByteLength(); 2644 size_t ByteLength();
2649 /** 2645 /**
2650 * Base address of a view. 2646 * Base address of a view.
2651 */ 2647 */
2652 void* BaseAddress(); 2648 void* BaseAddress();
2653 2649
2654 V8_INLINE(static ArrayBufferView* Cast(Value* obj)); 2650 V8_INLINE static ArrayBufferView* Cast(Value* obj);
2655 2651
2656 static const int kInternalFieldCount = 2652 static const int kInternalFieldCount =
2657 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; 2653 V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
2658 2654
2659 private: 2655 private:
2660 ArrayBufferView(); 2656 ArrayBufferView();
2661 static void CheckCast(Value* obj); 2657 static void CheckCast(Value* obj);
2662 }; 2658 };
2663 2659
2664 2660
2665 /** 2661 /**
2666 * A base class for an instance of TypedArray series of constructors 2662 * A base class for an instance of TypedArray series of constructors
2667 * (ES6 draft 15.13.6). 2663 * (ES6 draft 15.13.6).
2668 * This API is experimental and may change significantly. 2664 * This API is experimental and may change significantly.
2669 */ 2665 */
2670 class V8_EXPORT TypedArray : public ArrayBufferView { 2666 class V8_EXPORT TypedArray : public ArrayBufferView {
2671 public: 2667 public:
2672 /** 2668 /**
2673 * Number of elements in this typed array 2669 * Number of elements in this typed array
2674 * (e.g. for Int16Array, |ByteLength|/2). 2670 * (e.g. for Int16Array, |ByteLength|/2).
2675 */ 2671 */
2676 size_t Length(); 2672 size_t Length();
2677 2673
2678 V8_INLINE(static TypedArray* Cast(Value* obj)); 2674 V8_INLINE static TypedArray* Cast(Value* obj);
2679 2675
2680 private: 2676 private:
2681 TypedArray(); 2677 TypedArray();
2682 static void CheckCast(Value* obj); 2678 static void CheckCast(Value* obj);
2683 }; 2679 };
2684 2680
2685 2681
2686 /** 2682 /**
2687 * An instance of Uint8Array constructor (ES6 draft 15.13.6). 2683 * An instance of Uint8Array constructor (ES6 draft 15.13.6).
2688 * This API is experimental and may change significantly. 2684 * This API is experimental and may change significantly.
2689 */ 2685 */
2690 class V8_EXPORT Uint8Array : public TypedArray { 2686 class V8_EXPORT Uint8Array : public TypedArray {
2691 public: 2687 public:
2692 static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer, 2688 static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
2693 size_t byte_offset, size_t length); 2689 size_t byte_offset, size_t length);
2694 V8_INLINE(static Uint8Array* Cast(Value* obj)); 2690 V8_INLINE static Uint8Array* Cast(Value* obj);
2695 2691
2696 private: 2692 private:
2697 Uint8Array(); 2693 Uint8Array();
2698 static void CheckCast(Value* obj); 2694 static void CheckCast(Value* obj);
2699 }; 2695 };
2700 2696
2701 2697
2702 /** 2698 /**
2703 * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). 2699 * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
2704 * This API is experimental and may change significantly. 2700 * This API is experimental and may change significantly.
2705 */ 2701 */
2706 class V8_EXPORT Uint8ClampedArray : public TypedArray { 2702 class V8_EXPORT Uint8ClampedArray : public TypedArray {
2707 public: 2703 public:
2708 static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer, 2704 static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
2709 size_t byte_offset, size_t length); 2705 size_t byte_offset, size_t length);
2710 V8_INLINE(static Uint8ClampedArray* Cast(Value* obj)); 2706 V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
2711 2707
2712 private: 2708 private:
2713 Uint8ClampedArray(); 2709 Uint8ClampedArray();
2714 static void CheckCast(Value* obj); 2710 static void CheckCast(Value* obj);
2715 }; 2711 };
2716 2712
2717 /** 2713 /**
2718 * An instance of Int8Array constructor (ES6 draft 15.13.6). 2714 * An instance of Int8Array constructor (ES6 draft 15.13.6).
2719 * This API is experimental and may change significantly. 2715 * This API is experimental and may change significantly.
2720 */ 2716 */
2721 class V8_EXPORT Int8Array : public TypedArray { 2717 class V8_EXPORT Int8Array : public TypedArray {
2722 public: 2718 public:
2723 static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer, 2719 static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
2724 size_t byte_offset, size_t length); 2720 size_t byte_offset, size_t length);
2725 V8_INLINE(static Int8Array* Cast(Value* obj)); 2721 V8_INLINE static Int8Array* Cast(Value* obj);
2726 2722
2727 private: 2723 private:
2728 Int8Array(); 2724 Int8Array();
2729 static void CheckCast(Value* obj); 2725 static void CheckCast(Value* obj);
2730 }; 2726 };
2731 2727
2732 2728
2733 /** 2729 /**
2734 * An instance of Uint16Array constructor (ES6 draft 15.13.6). 2730 * An instance of Uint16Array constructor (ES6 draft 15.13.6).
2735 * This API is experimental and may change significantly. 2731 * This API is experimental and may change significantly.
2736 */ 2732 */
2737 class V8_EXPORT Uint16Array : public TypedArray { 2733 class V8_EXPORT Uint16Array : public TypedArray {
2738 public: 2734 public:
2739 static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer, 2735 static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
2740 size_t byte_offset, size_t length); 2736 size_t byte_offset, size_t length);
2741 V8_INLINE(static Uint16Array* Cast(Value* obj)); 2737 V8_INLINE static Uint16Array* Cast(Value* obj);
2742 2738
2743 private: 2739 private:
2744 Uint16Array(); 2740 Uint16Array();
2745 static void CheckCast(Value* obj); 2741 static void CheckCast(Value* obj);
2746 }; 2742 };
2747 2743
2748 2744
2749 /** 2745 /**
2750 * An instance of Int16Array constructor (ES6 draft 15.13.6). 2746 * An instance of Int16Array constructor (ES6 draft 15.13.6).
2751 * This API is experimental and may change significantly. 2747 * This API is experimental and may change significantly.
2752 */ 2748 */
2753 class V8_EXPORT Int16Array : public TypedArray { 2749 class V8_EXPORT Int16Array : public TypedArray {
2754 public: 2750 public:
2755 static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer, 2751 static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
2756 size_t byte_offset, size_t length); 2752 size_t byte_offset, size_t length);
2757 V8_INLINE(static Int16Array* Cast(Value* obj)); 2753 V8_INLINE static Int16Array* Cast(Value* obj);
2758 2754
2759 private: 2755 private:
2760 Int16Array(); 2756 Int16Array();
2761 static void CheckCast(Value* obj); 2757 static void CheckCast(Value* obj);
2762 }; 2758 };
2763 2759
2764 2760
2765 /** 2761 /**
2766 * An instance of Uint32Array constructor (ES6 draft 15.13.6). 2762 * An instance of Uint32Array constructor (ES6 draft 15.13.6).
2767 * This API is experimental and may change significantly. 2763 * This API is experimental and may change significantly.
2768 */ 2764 */
2769 class V8_EXPORT Uint32Array : public TypedArray { 2765 class V8_EXPORT Uint32Array : public TypedArray {
2770 public: 2766 public:
2771 static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer, 2767 static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
2772 size_t byte_offset, size_t length); 2768 size_t byte_offset, size_t length);
2773 V8_INLINE(static Uint32Array* Cast(Value* obj)); 2769 V8_INLINE static Uint32Array* Cast(Value* obj);
2774 2770
2775 private: 2771 private:
2776 Uint32Array(); 2772 Uint32Array();
2777 static void CheckCast(Value* obj); 2773 static void CheckCast(Value* obj);
2778 }; 2774 };
2779 2775
2780 2776
2781 /** 2777 /**
2782 * An instance of Int32Array constructor (ES6 draft 15.13.6). 2778 * An instance of Int32Array constructor (ES6 draft 15.13.6).
2783 * This API is experimental and may change significantly. 2779 * This API is experimental and may change significantly.
2784 */ 2780 */
2785 class V8_EXPORT Int32Array : public TypedArray { 2781 class V8_EXPORT Int32Array : public TypedArray {
2786 public: 2782 public:
2787 static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer, 2783 static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
2788 size_t byte_offset, size_t length); 2784 size_t byte_offset, size_t length);
2789 V8_INLINE(static Int32Array* Cast(Value* obj)); 2785 V8_INLINE static Int32Array* Cast(Value* obj);
2790 2786
2791 private: 2787 private:
2792 Int32Array(); 2788 Int32Array();
2793 static void CheckCast(Value* obj); 2789 static void CheckCast(Value* obj);
2794 }; 2790 };
2795 2791
2796 2792
2797 /** 2793 /**
2798 * An instance of Float32Array constructor (ES6 draft 15.13.6). 2794 * An instance of Float32Array constructor (ES6 draft 15.13.6).
2799 * This API is experimental and may change significantly. 2795 * This API is experimental and may change significantly.
2800 */ 2796 */
2801 class V8_EXPORT Float32Array : public TypedArray { 2797 class V8_EXPORT Float32Array : public TypedArray {
2802 public: 2798 public:
2803 static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer, 2799 static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
2804 size_t byte_offset, size_t length); 2800 size_t byte_offset, size_t length);
2805 V8_INLINE(static Float32Array* Cast(Value* obj)); 2801 V8_INLINE static Float32Array* Cast(Value* obj);
2806 2802
2807 private: 2803 private:
2808 Float32Array(); 2804 Float32Array();
2809 static void CheckCast(Value* obj); 2805 static void CheckCast(Value* obj);
2810 }; 2806 };
2811 2807
2812 2808
2813 /** 2809 /**
2814 * An instance of Float64Array constructor (ES6 draft 15.13.6). 2810 * An instance of Float64Array constructor (ES6 draft 15.13.6).
2815 * This API is experimental and may change significantly. 2811 * This API is experimental and may change significantly.
2816 */ 2812 */
2817 class V8_EXPORT Float64Array : public TypedArray { 2813 class V8_EXPORT Float64Array : public TypedArray {
2818 public: 2814 public:
2819 static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer, 2815 static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
2820 size_t byte_offset, size_t length); 2816 size_t byte_offset, size_t length);
2821 V8_INLINE(static Float64Array* Cast(Value* obj)); 2817 V8_INLINE static Float64Array* Cast(Value* obj);
2822 2818
2823 private: 2819 private:
2824 Float64Array(); 2820 Float64Array();
2825 static void CheckCast(Value* obj); 2821 static void CheckCast(Value* obj);
2826 }; 2822 };
2827 2823
2828 2824
2829 /** 2825 /**
2830 * An instance of DataView constructor (ES6 draft 15.13.7). 2826 * An instance of DataView constructor (ES6 draft 15.13.7).
2831 * This API is experimental and may change significantly. 2827 * This API is experimental and may change significantly.
2832 */ 2828 */
2833 class V8_EXPORT DataView : public ArrayBufferView { 2829 class V8_EXPORT DataView : public ArrayBufferView {
2834 public: 2830 public:
2835 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, 2831 static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
2836 size_t byte_offset, size_t length); 2832 size_t byte_offset, size_t length);
2837 V8_INLINE(static DataView* Cast(Value* obj)); 2833 V8_INLINE static DataView* Cast(Value* obj);
2838 2834
2839 private: 2835 private:
2840 DataView(); 2836 DataView();
2841 static void CheckCast(Value* obj); 2837 static void CheckCast(Value* obj);
2842 }; 2838 };
2843 2839
2844 2840
2845 /** 2841 /**
2846 * An instance of the built-in Date constructor (ECMA-262, 15.9). 2842 * An instance of the built-in Date constructor (ECMA-262, 15.9).
2847 */ 2843 */
2848 class V8_EXPORT Date : public Object { 2844 class V8_EXPORT Date : public Object {
2849 public: 2845 public:
2850 static Local<Value> New(double time); 2846 static Local<Value> New(double time);
2851 2847
2852 // Deprecated, use Date::ValueOf() instead. 2848 // Deprecated, use Date::ValueOf() instead.
2853 // TODO(svenpanne) Actually deprecate when Chrome is adapted. 2849 // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2854 double NumberValue() const { return ValueOf(); } 2850 double NumberValue() const { return ValueOf(); }
2855 2851
2856 /** 2852 /**
2857 * A specialization of Value::NumberValue that is more efficient 2853 * A specialization of Value::NumberValue that is more efficient
2858 * because we know the structure of this object. 2854 * because we know the structure of this object.
2859 */ 2855 */
2860 double ValueOf() const; 2856 double ValueOf() const;
2861 2857
2862 V8_INLINE(static Date* Cast(v8::Value* obj)); 2858 V8_INLINE static Date* Cast(v8::Value* obj);
2863 2859
2864 /** 2860 /**
2865 * Notification that the embedder has changed the time zone, 2861 * Notification that the embedder has changed the time zone,
2866 * daylight savings time, or other date / time configuration 2862 * daylight savings time, or other date / time configuration
2867 * parameters. V8 keeps a cache of various values used for 2863 * parameters. V8 keeps a cache of various values used for
2868 * date / time computation. This notification will reset 2864 * date / time computation. This notification will reset
2869 * those cached values for the current context so that date / 2865 * those cached values for the current context so that date /
2870 * time configuration changes would be reflected in the Date 2866 * time configuration changes would be reflected in the Date
2871 * object. 2867 * object.
2872 * 2868 *
(...skipping 16 matching lines...) Expand all
2889 2885
2890 // Deprecated, use NumberObject::ValueOf() instead. 2886 // Deprecated, use NumberObject::ValueOf() instead.
2891 // TODO(svenpanne) Actually deprecate when Chrome is adapted. 2887 // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2892 double NumberValue() const { return ValueOf(); } 2888 double NumberValue() const { return ValueOf(); }
2893 2889
2894 /** 2890 /**
2895 * Returns the Number held by the object. 2891 * Returns the Number held by the object.
2896 */ 2892 */
2897 double ValueOf() const; 2893 double ValueOf() const;
2898 2894
2899 V8_INLINE(static NumberObject* Cast(v8::Value* obj)); 2895 V8_INLINE static NumberObject* Cast(v8::Value* obj);
2900 2896
2901 private: 2897 private:
2902 static void CheckCast(v8::Value* obj); 2898 static void CheckCast(v8::Value* obj);
2903 }; 2899 };
2904 2900
2905 2901
2906 /** 2902 /**
2907 * A Boolean object (ECMA-262, 4.3.15). 2903 * A Boolean object (ECMA-262, 4.3.15).
2908 */ 2904 */
2909 class V8_EXPORT BooleanObject : public Object { 2905 class V8_EXPORT BooleanObject : public Object {
2910 public: 2906 public:
2911 static Local<Value> New(bool value); 2907 static Local<Value> New(bool value);
2912 2908
2913 // Deprecated, use BooleanObject::ValueOf() instead. 2909 // Deprecated, use BooleanObject::ValueOf() instead.
2914 // TODO(svenpanne) Actually deprecate when Chrome is adapted. 2910 // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2915 bool BooleanValue() const { return ValueOf(); } 2911 bool BooleanValue() const { return ValueOf(); }
2916 2912
2917 /** 2913 /**
2918 * Returns the Boolean held by the object. 2914 * Returns the Boolean held by the object.
2919 */ 2915 */
2920 bool ValueOf() const; 2916 bool ValueOf() const;
2921 2917
2922 V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); 2918 V8_INLINE static BooleanObject* Cast(v8::Value* obj);
2923 2919
2924 private: 2920 private:
2925 static void CheckCast(v8::Value* obj); 2921 static void CheckCast(v8::Value* obj);
2926 }; 2922 };
2927 2923
2928 2924
2929 /** 2925 /**
2930 * A String object (ECMA-262, 4.3.18). 2926 * A String object (ECMA-262, 4.3.18).
2931 */ 2927 */
2932 class V8_EXPORT StringObject : public Object { 2928 class V8_EXPORT StringObject : public Object {
2933 public: 2929 public:
2934 static Local<Value> New(Handle<String> value); 2930 static Local<Value> New(Handle<String> value);
2935 2931
2936 // Deprecated, use StringObject::ValueOf() instead. 2932 // Deprecated, use StringObject::ValueOf() instead.
2937 // TODO(svenpanne) Actually deprecate when Chrome is adapted. 2933 // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2938 Local<String> StringValue() const { return ValueOf(); } 2934 Local<String> StringValue() const { return ValueOf(); }
2939 2935
2940 /** 2936 /**
2941 * Returns the String held by the object. 2937 * Returns the String held by the object.
2942 */ 2938 */
2943 Local<String> ValueOf() const; 2939 Local<String> ValueOf() const;
2944 2940
2945 V8_INLINE(static StringObject* Cast(v8::Value* obj)); 2941 V8_INLINE static StringObject* Cast(v8::Value* obj);
2946 2942
2947 private: 2943 private:
2948 static void CheckCast(v8::Value* obj); 2944 static void CheckCast(v8::Value* obj);
2949 }; 2945 };
2950 2946
2951 2947
2952 /** 2948 /**
2953 * A Symbol object (ECMA-262 edition 6). 2949 * A Symbol object (ECMA-262 edition 6).
2954 * 2950 *
2955 * This is an experimental feature. Use at your own risk. 2951 * This is an experimental feature. Use at your own risk.
2956 */ 2952 */
2957 class V8_EXPORT SymbolObject : public Object { 2953 class V8_EXPORT SymbolObject : public Object {
2958 public: 2954 public:
2959 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); 2955 static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
2960 2956
2961 // Deprecated, use SymbolObject::ValueOf() instead. 2957 // Deprecated, use SymbolObject::ValueOf() instead.
2962 // TODO(svenpanne) Actually deprecate when Chrome is adapted. 2958 // TODO(svenpanne) Actually deprecate when Chrome is adapted.
2963 Local<Symbol> SymbolValue() const { return ValueOf(); } 2959 Local<Symbol> SymbolValue() const { return ValueOf(); }
2964 2960
2965 /** 2961 /**
2966 * Returns the Symbol held by the object. 2962 * Returns the Symbol held by the object.
2967 */ 2963 */
2968 Local<Symbol> ValueOf() const; 2964 Local<Symbol> ValueOf() const;
2969 2965
2970 V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); 2966 V8_INLINE static SymbolObject* Cast(v8::Value* obj);
2971 2967
2972 private: 2968 private:
2973 static void CheckCast(v8::Value* obj); 2969 static void CheckCast(v8::Value* obj);
2974 }; 2970 };
2975 2971
2976 2972
2977 /** 2973 /**
2978 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). 2974 * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
2979 */ 2975 */
2980 class V8_EXPORT RegExp : public Object { 2976 class V8_EXPORT RegExp : public Object {
(...skipping 25 matching lines...) Expand all
3006 * Returns the value of the source property: a string representing 3002 * Returns the value of the source property: a string representing
3007 * the regular expression. 3003 * the regular expression.
3008 */ 3004 */
3009 Local<String> GetSource() const; 3005 Local<String> GetSource() const;
3010 3006
3011 /** 3007 /**
3012 * Returns the flags bit field. 3008 * Returns the flags bit field.
3013 */ 3009 */
3014 Flags GetFlags() const; 3010 Flags GetFlags() const;
3015 3011
3016 V8_INLINE(static RegExp* Cast(v8::Value* obj)); 3012 V8_INLINE static RegExp* Cast(v8::Value* obj);
3017 3013
3018 private: 3014 private:
3019 static void CheckCast(v8::Value* obj); 3015 static void CheckCast(v8::Value* obj);
3020 }; 3016 };
3021 3017
3022 3018
3023 /** 3019 /**
3024 * A JavaScript value that wraps a C++ void*. This type of value is mainly used 3020 * A JavaScript value that wraps a C++ void*. This type of value is mainly used
3025 * to associate C++ data structures with JavaScript objects. 3021 * to associate C++ data structures with JavaScript objects.
3026 */ 3022 */
3027 class V8_EXPORT External : public Value { 3023 class V8_EXPORT External : public Value {
3028 public: 3024 public:
3029 static Local<External> New(void* value); 3025 static Local<External> New(void* value);
3030 V8_INLINE(static External* Cast(Value* obj)); 3026 V8_INLINE static External* Cast(Value* obj);
3031 void* Value() const; 3027 void* Value() const;
3032 private: 3028 private:
3033 static void CheckCast(v8::Value* obj); 3029 static void CheckCast(v8::Value* obj);
3034 }; 3030 };
3035 3031
3036 3032
3037 // --- Templates --- 3033 // --- Templates ---
3038 3034
3039 3035
3040 /** 3036 /**
3041 * The superclass of object and function templates. 3037 * The superclass of object and function templates.
3042 */ 3038 */
3043 class V8_EXPORT Template : public Data { 3039 class V8_EXPORT Template : public Data {
3044 public: 3040 public:
3045 /** Adds a property to each instance created by this template.*/ 3041 /** Adds a property to each instance created by this template.*/
3046 void Set(Handle<String> name, Handle<Data> value, 3042 void Set(Handle<String> name, Handle<Data> value,
3047 PropertyAttribute attributes = None); 3043 PropertyAttribute attributes = None);
3048 V8_INLINE(void Set(const char* name, Handle<Data> value)); 3044 V8_INLINE void Set(const char* name, Handle<Data> value);
3049 3045
3050 void SetAccessorProperty( 3046 void SetAccessorProperty(
3051 Local<String> name, 3047 Local<String> name,
3052 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), 3048 Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
3053 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), 3049 Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
3054 PropertyAttribute attribute = None, 3050 PropertyAttribute attribute = None,
3055 AccessControl settings = DEFAULT); 3051 AccessControl settings = DEFAULT);
3056 3052
3057 /** 3053 /**
3058 * Whenever the property with the given name is accessed on objects 3054 * Whenever the property with the given name is accessed on objects
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 3711
3716 3712
3717 void V8_EXPORT RegisterExtension(Extension* extension); 3713 void V8_EXPORT RegisterExtension(Extension* extension);
3718 3714
3719 3715
3720 /** 3716 /**
3721 * Ignore 3717 * Ignore
3722 */ 3718 */
3723 class V8_EXPORT DeclareExtension { 3719 class V8_EXPORT DeclareExtension {
3724 public: 3720 public:
3725 V8_INLINE(DeclareExtension(Extension* extension)) { 3721 V8_INLINE DeclareExtension(Extension* extension) {
3726 RegisterExtension(extension); 3722 RegisterExtension(extension);
3727 } 3723 }
3728 }; 3724 };
3729 3725
3730 3726
3731 // --- Statics --- 3727 // --- Statics ---
3732 3728
3733 3729
3734 Handle<Primitive> V8_EXPORT Undefined(); 3730 Handle<Primitive> V8_EXPORT Undefined();
3735 Handle<Primitive> V8_EXPORT Null(); 3731 Handle<Primitive> V8_EXPORT Null();
3736 Handle<Boolean> V8_EXPORT True(); 3732 Handle<Boolean> V8_EXPORT True();
3737 Handle<Boolean> V8_EXPORT False(); 3733 Handle<Boolean> V8_EXPORT False();
3738 3734
3739 V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate)); 3735 V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
3740 V8_INLINE(Handle<Primitive> Null(Isolate* isolate)); 3736 V8_INLINE Handle<Primitive> Null(Isolate* isolate);
3741 V8_INLINE(Handle<Boolean> True(Isolate* isolate)); 3737 V8_INLINE Handle<Boolean> True(Isolate* isolate);
3742 V8_INLINE(Handle<Boolean> False(Isolate* isolate)); 3738 V8_INLINE Handle<Boolean> False(Isolate* isolate);
3743 3739
3744 3740
3745 /** 3741 /**
3746 * A set of constraints that specifies the limits of the runtime's memory use. 3742 * A set of constraints that specifies the limits of the runtime's memory use.
3747 * You must set the heap size before initializing the VM - the size cannot be 3743 * You must set the heap size before initializing the VM - the size cannot be
3748 * adjusted after the VM is initialized. 3744 * adjusted after the VM is initialized.
3749 * 3745 *
3750 * If you are using threads then you should hold the V8::Locker lock while 3746 * If you are using threads then you should hold the V8::Locker lock while
3751 * setting the stack limit and you must set a non-default stack limit separately 3747 * setting the stack limit and you must set a non-default stack limit separately
3752 * for each thread. 3748 * for each thread.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3990 3986
3991 /** 3987 /**
3992 * Disposes the isolate. The isolate must not be entered by any 3988 * Disposes the isolate. The isolate must not be entered by any
3993 * thread to be disposable. 3989 * thread to be disposable.
3994 */ 3990 */
3995 void Dispose(); 3991 void Dispose();
3996 3992
3997 /** 3993 /**
3998 * Associate embedder-specific data with the isolate 3994 * Associate embedder-specific data with the isolate
3999 */ 3995 */
4000 V8_INLINE(void SetData(void* data)); 3996 V8_INLINE void SetData(void* data);
4001 3997
4002 /** 3998 /**
4003 * Retrieve embedder-specific data from the isolate. 3999 * Retrieve embedder-specific data from the isolate.
4004 * Returns NULL if SetData has never been called. 4000 * Returns NULL if SetData has never been called.
4005 */ 4001 */
4006 V8_INLINE(void* GetData()); 4002 V8_INLINE void* GetData();
4007 4003
4008 /** 4004 /**
4009 * Get statistics about the heap memory usage. 4005 * Get statistics about the heap memory usage.
4010 */ 4006 */
4011 void GetHeapStatistics(HeapStatistics* heap_statistics); 4007 void GetHeapStatistics(HeapStatistics* heap_statistics);
4012 4008
4013 /** 4009 /**
4014 * Adjusts the amount of registered external memory. Used to give V8 an 4010 * Adjusts the amount of registered external memory. Used to give V8 an
4015 * indication of the amount of externally allocated memory that is kept alive 4011 * indication of the amount of externally allocated memory that is kept alive
4016 * by JavaScript objects. V8 uses this to decide when to perform global 4012 * by JavaScript objects. V8 uses this to decide when to perform global
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
4268 4264
4269 4265
4270 /** 4266 /**
4271 * Asserts that no action is performed that could cause a handle's value 4267 * Asserts that no action is performed that could cause a handle's value
4272 * to be modified. Useful when otherwise unsafe handle operations need to 4268 * to be modified. Useful when otherwise unsafe handle operations need to
4273 * be performed. 4269 * be performed.
4274 */ 4270 */
4275 class V8_EXPORT AssertNoGCScope { 4271 class V8_EXPORT AssertNoGCScope {
4276 #ifndef DEBUG 4272 #ifndef DEBUG
4277 // TODO(yangguo): remove isolate argument. 4273 // TODO(yangguo): remove isolate argument.
4278 V8_INLINE(AssertNoGCScope(Isolate* isolate)) { } 4274 V8_INLINE AssertNoGCScope(Isolate* isolate) {}
4279 #else 4275 #else
4280 AssertNoGCScope(Isolate* isolate); 4276 AssertNoGCScope(Isolate* isolate);
4281 ~AssertNoGCScope(); 4277 ~AssertNoGCScope();
4282 private: 4278 private:
4283 void* disallow_heap_allocation_; 4279 void* disallow_heap_allocation_;
4284 #endif 4280 #endif
4285 }; 4281 };
4286 4282
4287 4283
4288 /** 4284 /**
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
4971 static bool InContext(); 4967 static bool InContext();
4972 4968
4973 /** Returns an isolate associated with a current context. */ 4969 /** Returns an isolate associated with a current context. */
4974 v8::Isolate* GetIsolate(); 4970 v8::Isolate* GetIsolate();
4975 4971
4976 /** 4972 /**
4977 * Gets the embedder data with the given index, which must have been set by a 4973 * Gets the embedder data with the given index, which must have been set by a
4978 * previous call to SetEmbedderData with the same index. Note that index 0 4974 * previous call to SetEmbedderData with the same index. Note that index 0
4979 * currently has a special meaning for Chrome's debugger. 4975 * currently has a special meaning for Chrome's debugger.
4980 */ 4976 */
4981 V8_INLINE(Local<Value> GetEmbedderData(int index)); 4977 V8_INLINE Local<Value> GetEmbedderData(int index);
4982 4978
4983 /** 4979 /**
4984 * Sets the embedder data with the given index, growing the data as 4980 * Sets the embedder data with the given index, growing the data as
4985 * needed. Note that index 0 currently has a special meaning for Chrome's 4981 * needed. Note that index 0 currently has a special meaning for Chrome's
4986 * debugger. 4982 * debugger.
4987 */ 4983 */
4988 void SetEmbedderData(int index, Handle<Value> value); 4984 void SetEmbedderData(int index, Handle<Value> value);
4989 4985
4990 /** 4986 /**
4991 * Gets a 2-byte-aligned native pointer from the embedder data with the given 4987 * Gets a 2-byte-aligned native pointer from the embedder data with the given
4992 * index, which must have bees set by a previous call to 4988 * index, which must have bees set by a previous call to
4993 * SetAlignedPointerInEmbedderData with the same index. Note that index 0 4989 * SetAlignedPointerInEmbedderData with the same index. Note that index 0
4994 * currently has a special meaning for Chrome's debugger. 4990 * currently has a special meaning for Chrome's debugger.
4995 */ 4991 */
4996 V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); 4992 V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
4997 4993
4998 /** 4994 /**
4999 * Sets a 2-byte-aligned native pointer in the embedder data with the given 4995 * Sets a 2-byte-aligned native pointer in the embedder data with the given
5000 * index, growing the data as needed. Note that index 0 currently has a 4996 * index, growing the data as needed. Note that index 0 currently has a
5001 * special meaning for Chrome's debugger. 4997 * special meaning for Chrome's debugger.
5002 */ 4998 */
5003 void SetAlignedPointerInEmbedderData(int index, void* value); 4999 void SetAlignedPointerInEmbedderData(int index, void* value);
5004 5000
5005 /** 5001 /**
5006 * Control whether code generation from strings is allowed. Calling 5002 * Control whether code generation from strings is allowed. Calling
(...skipping 22 matching lines...) Expand all
5029 * constructor are called. 5025 * constructor are called.
5030 */ 5026 */
5031 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); 5027 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
5032 5028
5033 /** 5029 /**
5034 * Stack-allocated class which sets the execution context for all 5030 * Stack-allocated class which sets the execution context for all
5035 * operations executed within a local scope. 5031 * operations executed within a local scope.
5036 */ 5032 */
5037 class Scope { 5033 class Scope {
5038 public: 5034 public:
5039 explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) { 5035 explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
5040 context_->Enter(); 5036 context_->Enter();
5041 } 5037 }
5042 // TODO(dcarney): deprecate 5038 // TODO(dcarney): deprecate
5043 V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT 5039 V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context) // NOLINT
5044 : context_(Handle<Context>::New(isolate, context)) { 5040 : context_(Handle<Context>::New(isolate, context)) {
5045 context_->Enter(); 5041 context_->Enter();
5046 } 5042 }
5047 V8_INLINE(~Scope()) { context_->Exit(); } 5043 V8_INLINE ~Scope() { context_->Exit(); }
5048 5044
5049 private: 5045 private:
5050 Handle<Context> context_; 5046 Handle<Context> context_;
5051 }; 5047 };
5052 5048
5053 private: 5049 private:
5054 friend class Value; 5050 friend class Value;
5055 friend class Script; 5051 friend class Script;
5056 friend class Object; 5052 friend class Object;
5057 friend class Function; 5053 friend class Function;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5135 * // V8 still locked (1 level). 5131 * // V8 still locked (1 level).
5136 * } 5132 * }
5137 * // V8 Now no longer locked. 5133 * // V8 Now no longer locked.
5138 * \endcode 5134 * \endcode
5139 */ 5135 */
5140 class V8_EXPORT Unlocker { 5136 class V8_EXPORT Unlocker {
5141 public: 5137 public:
5142 /** 5138 /**
5143 * Initialize Unlocker for a given Isolate. 5139 * Initialize Unlocker for a given Isolate.
5144 */ 5140 */
5145 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } 5141 V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
5146 5142
5147 /** Deprecated. Use Isolate version instead. */ 5143 /** Deprecated. Use Isolate version instead. */
5148 V8_DEPRECATED(Unlocker()); 5144 V8_DEPRECATED(Unlocker());
5149 5145
5150 ~Unlocker(); 5146 ~Unlocker();
5151 private: 5147 private:
5152 void Initialize(Isolate* isolate); 5148 void Initialize(Isolate* isolate);
5153 5149
5154 internal::Isolate* isolate_; 5150 internal::Isolate* isolate_;
5155 }; 5151 };
5156 5152
5157 5153
5158 class V8_EXPORT Locker { 5154 class V8_EXPORT Locker {
5159 public: 5155 public:
5160 /** 5156 /**
5161 * Initialize Locker for a given Isolate. 5157 * Initialize Locker for a given Isolate.
5162 */ 5158 */
5163 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } 5159 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
5164 5160
5165 /** Deprecated. Use Isolate version instead. */ 5161 /** Deprecated. Use Isolate version instead. */
5166 V8_DEPRECATED(Locker()); 5162 V8_DEPRECATED(Locker());
5167 5163
5168 ~Locker(); 5164 ~Locker();
5169 5165
5170 /** 5166 /**
5171 * Start preemption. 5167 * Start preemption.
5172 * 5168 *
5173 * When preemption is started, a timer is fired every n milliseconds 5169 * When preemption is started, a timer is fired every n milliseconds
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5282 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; 5278 const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
5283 5279
5284 // Tag information for Smi. 5280 // Tag information for Smi.
5285 const int kSmiTag = 0; 5281 const int kSmiTag = 0;
5286 const int kSmiTagSize = 1; 5282 const int kSmiTagSize = 1;
5287 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; 5283 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
5288 5284
5289 template <size_t ptr_size> struct SmiTagging; 5285 template <size_t ptr_size> struct SmiTagging;
5290 5286
5291 template<int kSmiShiftSize> 5287 template<int kSmiShiftSize>
5292 V8_INLINE(internal::Object* IntToSmi(int value)) { 5288 V8_INLINE internal::Object* IntToSmi(int value) {
5293 int smi_shift_bits = kSmiTagSize + kSmiShiftSize; 5289 int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
5294 intptr_t tagged_value = 5290 intptr_t tagged_value =
5295 (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; 5291 (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag;
5296 return reinterpret_cast<internal::Object*>(tagged_value); 5292 return reinterpret_cast<internal::Object*>(tagged_value);
5297 } 5293 }
5298 5294
5299 // Smi constants for 32-bit systems. 5295 // Smi constants for 32-bit systems.
5300 template <> struct SmiTagging<4> { 5296 template <> struct SmiTagging<4> {
5301 static const int kSmiShiftSize = 0; 5297 static const int kSmiShiftSize = 0;
5302 static const int kSmiValueSize = 31; 5298 static const int kSmiValueSize = 31;
5303 V8_INLINE(static int SmiToInt(internal::Object* value)) { 5299 V8_INLINE static int SmiToInt(internal::Object* value) {
5304 int shift_bits = kSmiTagSize + kSmiShiftSize; 5300 int shift_bits = kSmiTagSize + kSmiShiftSize;
5305 // Throw away top 32 bits and shift down (requires >> to be sign extending). 5301 // Throw away top 32 bits and shift down (requires >> to be sign extending).
5306 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; 5302 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
5307 } 5303 }
5308 V8_INLINE(static internal::Object* IntToSmi(int value)) { 5304 V8_INLINE static internal::Object* IntToSmi(int value) {
5309 return internal::IntToSmi<kSmiShiftSize>(value); 5305 return internal::IntToSmi<kSmiShiftSize>(value);
5310 } 5306 }
5311 V8_INLINE(static bool IsValidSmi(intptr_t value)) { 5307 V8_INLINE static bool IsValidSmi(intptr_t value) {
5312 // To be representable as an tagged small integer, the two 5308 // To be representable as an tagged small integer, the two
5313 // most-significant bits of 'value' must be either 00 or 11 due to 5309 // most-significant bits of 'value' must be either 00 or 11 due to
5314 // sign-extension. To check this we add 01 to the two 5310 // sign-extension. To check this we add 01 to the two
5315 // most-significant bits, and check if the most-significant bit is 0 5311 // most-significant bits, and check if the most-significant bit is 0
5316 // 5312 //
5317 // CAUTION: The original code below: 5313 // CAUTION: The original code below:
5318 // bool result = ((value + 0x40000000) & 0x80000000) == 0; 5314 // bool result = ((value + 0x40000000) & 0x80000000) == 0;
5319 // may lead to incorrect results according to the C language spec, and 5315 // may lead to incorrect results according to the C language spec, and
5320 // in fact doesn't work correctly with gcc4.1.1 in some cases: The 5316 // in fact doesn't work correctly with gcc4.1.1 in some cases: The
5321 // compiler may produce undefined results in case of signed integer 5317 // compiler may produce undefined results in case of signed integer
5322 // overflow. The computation must be done w/ unsigned ints. 5318 // overflow. The computation must be done w/ unsigned ints.
5323 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; 5319 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
5324 } 5320 }
5325 }; 5321 };
5326 5322
5327 // Smi constants for 64-bit systems. 5323 // Smi constants for 64-bit systems.
5328 template <> struct SmiTagging<8> { 5324 template <> struct SmiTagging<8> {
5329 static const int kSmiShiftSize = 31; 5325 static const int kSmiShiftSize = 31;
5330 static const int kSmiValueSize = 32; 5326 static const int kSmiValueSize = 32;
5331 V8_INLINE(static int SmiToInt(internal::Object* value)) { 5327 V8_INLINE static int SmiToInt(internal::Object* value) {
5332 int shift_bits = kSmiTagSize + kSmiShiftSize; 5328 int shift_bits = kSmiTagSize + kSmiShiftSize;
5333 // Shift down and throw away top 32 bits. 5329 // Shift down and throw away top 32 bits.
5334 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); 5330 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
5335 } 5331 }
5336 V8_INLINE(static internal::Object* IntToSmi(int value)) { 5332 V8_INLINE static internal::Object* IntToSmi(int value) {
5337 return internal::IntToSmi<kSmiShiftSize>(value); 5333 return internal::IntToSmi<kSmiShiftSize>(value);
5338 } 5334 }
5339 V8_INLINE(static bool IsValidSmi(intptr_t value)) { 5335 V8_INLINE static bool IsValidSmi(intptr_t value) {
5340 // To be representable as a long smi, the value must be a 32-bit integer. 5336 // To be representable as a long smi, the value must be a 32-bit integer.
5341 return (value == static_cast<int32_t>(value)); 5337 return (value == static_cast<int32_t>(value));
5342 } 5338 }
5343 }; 5339 };
5344 5340
5345 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; 5341 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
5346 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; 5342 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
5347 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; 5343 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
5348 V8_INLINE(static bool SmiValuesAre31Bits()) { return kSmiValueSize == 31; } 5344 V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
5349 V8_INLINE(static bool SmiValuesAre32Bits()) { return kSmiValueSize == 32; } 5345 V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
5350 5346
5351 /** 5347 /**
5352 * This class exports constants and functionality from within v8 that 5348 * This class exports constants and functionality from within v8 that
5353 * is necessary to implement inline functions in the v8 api. Don't 5349 * is necessary to implement inline functions in the v8 api. Don't
5354 * depend on functions and constants defined here. 5350 * depend on functions and constants defined here.
5355 */ 5351 */
5356 class Internals { 5352 class Internals {
5357 public: 5353 public:
5358 // These values match non-compiler-dependent values defined within 5354 // These values match non-compiler-dependent values defined within
5359 // the implementation of v8. 5355 // the implementation of v8.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5391 5387
5392 static const int kJSObjectType = 0xb1; 5388 static const int kJSObjectType = 0xb1;
5393 static const int kFirstNonstringType = 0x80; 5389 static const int kFirstNonstringType = 0x80;
5394 static const int kOddballType = 0x83; 5390 static const int kOddballType = 0x83;
5395 static const int kForeignType = 0x87; 5391 static const int kForeignType = 0x87;
5396 5392
5397 static const int kUndefinedOddballKind = 5; 5393 static const int kUndefinedOddballKind = 5;
5398 static const int kNullOddballKind = 3; 5394 static const int kNullOddballKind = 3;
5399 5395
5400 static void CheckInitializedImpl(v8::Isolate* isolate); 5396 static void CheckInitializedImpl(v8::Isolate* isolate);
5401 V8_INLINE(static void CheckInitialized(v8::Isolate* isolate)) { 5397 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
5402 #ifdef V8_ENABLE_CHECKS 5398 #ifdef V8_ENABLE_CHECKS
5403 CheckInitializedImpl(isolate); 5399 CheckInitializedImpl(isolate);
5404 #endif 5400 #endif
5405 } 5401 }
5406 5402
5407 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { 5403 V8_INLINE static bool HasHeapObjectTag(internal::Object* value) {
5408 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 5404 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
5409 kHeapObjectTag); 5405 kHeapObjectTag);
5410 } 5406 }
5411 5407
5412 V8_INLINE(static int SmiValue(internal::Object* value)) { 5408 V8_INLINE static int SmiValue(internal::Object* value) {
5413 return PlatformSmiTagging::SmiToInt(value); 5409 return PlatformSmiTagging::SmiToInt(value);
5414 } 5410 }
5415 5411
5416 V8_INLINE(static internal::Object* IntToSmi(int value)) { 5412 V8_INLINE static internal::Object* IntToSmi(int value) {
5417 return PlatformSmiTagging::IntToSmi(value); 5413 return PlatformSmiTagging::IntToSmi(value);
5418 } 5414 }
5419 5415
5420 V8_INLINE(static bool IsValidSmi(intptr_t value)) { 5416 V8_INLINE static bool IsValidSmi(intptr_t value) {
5421 return PlatformSmiTagging::IsValidSmi(value); 5417 return PlatformSmiTagging::IsValidSmi(value);
5422 } 5418 }
5423 5419
5424 V8_INLINE(static int GetInstanceType(internal::Object* obj)) { 5420 V8_INLINE static int GetInstanceType(internal::Object* obj) {
5425 typedef internal::Object O; 5421 typedef internal::Object O;
5426 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); 5422 O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
5427 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); 5423 return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
5428 } 5424 }
5429 5425
5430 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { 5426 V8_INLINE static int GetOddballKind(internal::Object* obj) {
5431 typedef internal::Object O; 5427 typedef internal::Object O;
5432 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); 5428 return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
5433 } 5429 }
5434 5430
5435 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { 5431 V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
5436 int representation = (instance_type & kFullStringRepresentationMask); 5432 int representation = (instance_type & kFullStringRepresentationMask);
5437 return representation == kExternalTwoByteRepresentationTag; 5433 return representation == kExternalTwoByteRepresentationTag;
5438 } 5434 }
5439 5435
5440 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { 5436 V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
5441 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5437 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5442 return *addr & static_cast<uint8_t>(1U << shift); 5438 return *addr & static_cast<uint8_t>(1U << shift);
5443 } 5439 }
5444 5440
5445 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, 5441 V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
5446 bool value, int shift)) { 5442 bool value, int shift) {
5447 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5443 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5448 uint8_t mask = static_cast<uint8_t>(1 << shift); 5444 uint8_t mask = static_cast<uint8_t>(1 << shift);
5449 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); 5445 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
5450 } 5446 }
5451 5447
5452 V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) { 5448 V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
5453 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5449 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5454 return *addr & kNodeStateMask; 5450 return *addr & kNodeStateMask;
5455 } 5451 }
5456 5452
5457 V8_INLINE(static void UpdateNodeState(internal::Object** obj, 5453 V8_INLINE static void UpdateNodeState(internal::Object** obj,
5458 uint8_t value)) { 5454 uint8_t value) {
5459 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5455 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5460 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); 5456 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
5461 } 5457 }
5462 5458
5463 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { 5459 V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) {
5464 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 5460 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
5465 kIsolateEmbedderDataOffset; 5461 kIsolateEmbedderDataOffset;
5466 *reinterpret_cast<void**>(addr) = data; 5462 *reinterpret_cast<void**>(addr) = data;
5467 } 5463 }
5468 5464
5469 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { 5465 V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) {
5470 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 5466 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
5471 kIsolateEmbedderDataOffset; 5467 kIsolateEmbedderDataOffset;
5472 return *reinterpret_cast<void**>(addr); 5468 return *reinterpret_cast<void**>(addr);
5473 } 5469 }
5474 5470
5475 V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, 5471 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
5476 int index)) { 5472 int index) {
5477 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; 5473 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
5478 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); 5474 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
5479 } 5475 }
5480 5476
5481 template <typename T> 5477 template <typename T> V8_INLINE static T ReadField(Object* ptr, int offset) {
5482 V8_INLINE(static T ReadField(Object* ptr, int offset)) {
5483 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; 5478 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
5484 return *reinterpret_cast<T*>(addr); 5479 return *reinterpret_cast<T*>(addr);
5485 } 5480 }
5486 5481
5487 template <typename T> 5482 template <typename T>
5488 V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { 5483 V8_INLINE static T ReadEmbedderData(Context* context, int index) {
5489 typedef internal::Object O; 5484 typedef internal::Object O;
5490 typedef internal::Internals I; 5485 typedef internal::Internals I;
5491 O* ctx = *reinterpret_cast<O**>(context); 5486 O* ctx = *reinterpret_cast<O**>(context);
5492 int embedder_data_offset = I::kContextHeaderSize + 5487 int embedder_data_offset = I::kContextHeaderSize +
5493 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); 5488 (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
5494 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); 5489 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
5495 int value_offset = 5490 int value_offset =
5496 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); 5491 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
5497 return I::ReadField<T>(embedder_data, value_offset); 5492 return I::ReadField<T>(embedder_data, value_offset);
5498 } 5493 }
5499 5494
5500 V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } 5495 V8_INLINE static bool CanCastToHeapObject(void* o) { return false; }
5501 V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } 5496 V8_INLINE static bool CanCastToHeapObject(Context* o) { return true; }
5502 V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } 5497 V8_INLINE static bool CanCastToHeapObject(String* o) { return true; }
5503 V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } 5498 V8_INLINE static bool CanCastToHeapObject(Object* o) { return true; }
5504 V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } 5499 V8_INLINE static bool CanCastToHeapObject(Message* o) { return true; }
5505 V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; } 5500 V8_INLINE static bool CanCastToHeapObject(StackTrace* o) { return true; }
5506 V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; } 5501 V8_INLINE static bool CanCastToHeapObject(StackFrame* o) { return true; }
5507 }; 5502 };
5508 5503
5509 } // namespace internal 5504 } // namespace internal
5510 5505
5511 5506
5512 template <class T> 5507 template <class T>
5513 Local<T>::Local() : Handle<T>() { } 5508 Local<T>::Local() : Handle<T>() { }
5514 5509
5515 5510
5516 template <class T> 5511 template <class T>
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
6451 */ 6446 */
6452 6447
6453 6448
6454 } // namespace v8 6449 } // namespace v8
6455 6450
6456 6451
6457 #undef TYPE_CHECK 6452 #undef TYPE_CHECK
6458 6453
6459 6454
6460 #endif // V8_H_ 6455 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | include/v8config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698