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

Side by Side Diff: include/v8.h

Issue 11885019: Removed deprecated functions from v8's external API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 11 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 | src/api.cc » ('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 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 /** Gets the number of internal fields for this Object. */ 1629 /** Gets the number of internal fields for this Object. */
1630 int InternalFieldCount(); 1630 int InternalFieldCount();
1631 1631
1632 /** Gets the value from an internal field. */ 1632 /** Gets the value from an internal field. */
1633 V8_INLINE(Local<Value> GetInternalField(int index)); 1633 V8_INLINE(Local<Value> GetInternalField(int index));
1634 1634
1635 /** Sets the value in an internal field. */ 1635 /** Sets the value in an internal field. */
1636 void SetInternalField(int index, Handle<Value> value); 1636 void SetInternalField(int index, Handle<Value> value);
1637 1637
1638 /** 1638 /**
1639 * Gets a native pointer from an internal field. Deprecated. If the pointer is
1640 * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead,
1641 * otherwise use a combination of GetInternalField, External::Cast and
1642 * External::Value.
1643 */
1644 V8_DEPRECATED(void* GetPointerFromInternalField(int index));
1645
1646 /**
1647 * Sets a native pointer in an internal field. Deprecated. If the pointer is
1648 * always 2-byte aligned, use SetAlignedPointerInInternalField instead,
1649 * otherwise use a combination of External::New and SetInternalField.
1650 */
1651 V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index,
1652 void* value)));
1653
1654 /**
1655 * Gets a 2-byte-aligned native pointer from an internal field. This field 1639 * Gets a 2-byte-aligned native pointer from an internal field. This field
1656 * must have been set by SetAlignedPointerInInternalField, everything else 1640 * must have been set by SetAlignedPointerInInternalField, everything else
1657 * leads to undefined behavior. 1641 * leads to undefined behavior.
1658 */ 1642 */
1659 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); 1643 V8_INLINE(void* GetAlignedPointerFromInternalField(int index));
1660 1644
1661 /** 1645 /**
1662 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such 1646 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
1663 * a field, GetAlignedPointerFromInternalField must be used, everything else 1647 * a field, GetAlignedPointerFromInternalField must be used, everything else
1664 * leads to undefined behavior. 1648 * leads to undefined behavior.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 static void CheckCast(v8::Value* obj); 1982 static void CheckCast(v8::Value* obj);
1999 }; 1983 };
2000 1984
2001 1985
2002 /** 1986 /**
2003 * A JavaScript value that wraps a C++ void*. This type of value is mainly used 1987 * A JavaScript value that wraps a C++ void*. This type of value is mainly used
2004 * to associate C++ data structures with JavaScript objects. 1988 * to associate C++ data structures with JavaScript objects.
2005 */ 1989 */
2006 class V8EXPORT External : public Value { 1990 class V8EXPORT External : public Value {
2007 public: 1991 public:
2008 /** Deprecated, use New instead. */
2009 V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value)));
2010
2011 /** Deprecated, use a combination of Cast and Value instead. */
2012 V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj)));
2013
2014 static Local<External> New(void* value); 1992 static Local<External> New(void* value);
2015 V8_INLINE(static External* Cast(Value* obj)); 1993 V8_INLINE(static External* Cast(Value* obj));
2016 void* Value() const; 1994 void* Value() const;
2017 private: 1995 private:
2018 static void CheckCast(v8::Value* obj); 1996 static void CheckCast(v8::Value* obj);
2019 }; 1997 };
2020 1998
2021 1999
2022 // --- Templates --- 2000 // --- Templates ---
2023 2001
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 */ 3790 */
3813 void Exit(); 3791 void Exit();
3814 3792
3815 /** Returns true if the context has experienced an out of memory situation. */ 3793 /** Returns true if the context has experienced an out of memory situation. */
3816 bool HasOutOfMemoryException(); 3794 bool HasOutOfMemoryException();
3817 3795
3818 /** Returns true if V8 has a current context. */ 3796 /** Returns true if V8 has a current context. */
3819 static bool InContext(); 3797 static bool InContext();
3820 3798
3821 /** 3799 /**
3822 * Gets embedder data with index 0. Deprecated, use GetEmbedderData with index
3823 * 0 instead.
3824 */
3825 V8_DEPRECATED(V8_INLINE(Local<Value> GetData()));
3826
3827 /**
3828 * Sets embedder data with index 0. Deprecated, use SetEmbedderData with index
3829 * 0 instead.
3830 */
3831 V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value)));
3832
3833 /**
3834 * Gets the embedder data with the given index, which must have been set by a 3800 * Gets the embedder data with the given index, which must have been set by a
3835 * previous call to SetEmbedderData with the same index. Note that index 0 3801 * previous call to SetEmbedderData with the same index. Note that index 0
3836 * currently has a special meaning for Chrome's debugger. 3802 * currently has a special meaning for Chrome's debugger.
3837 */ 3803 */
3838 V8_INLINE(Local<Value> GetEmbedderData(int index)); 3804 V8_INLINE(Local<Value> GetEmbedderData(int index));
3839 3805
3840 /** 3806 /**
3841 * Sets the embedder data with the given index, growing the data as 3807 * Sets the embedder data with the given index, growing the data as
3842 * needed. Note that index 0 currently has a special meaning for Chrome's 3808 * needed. Note that index 0 currently has a special meaning for Chrome's
3843 * debugger. 3809 * debugger.
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4517 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); 4483 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4518 O* value = I::ReadField<O*>(obj, offset); 4484 O* value = I::ReadField<O*>(obj, offset);
4519 O** result = HandleScope::CreateHandle(value); 4485 O** result = HandleScope::CreateHandle(value);
4520 return Local<Value>(reinterpret_cast<Value*>(result)); 4486 return Local<Value>(reinterpret_cast<Value*>(result));
4521 } 4487 }
4522 #endif 4488 #endif
4523 return SlowGetInternalField(index); 4489 return SlowGetInternalField(index);
4524 } 4490 }
4525 4491
4526 4492
4527 void Object::SetPointerInInternalField(int index, void* value) {
4528 SetInternalField(index, External::New(value));
4529 }
4530
4531
4532 void* Object::GetAlignedPointerFromInternalField(int index) { 4493 void* Object::GetAlignedPointerFromInternalField(int index) {
4533 #ifndef V8_ENABLE_CHECKS 4494 #ifndef V8_ENABLE_CHECKS
4534 typedef internal::Object O; 4495 typedef internal::Object O;
4535 typedef internal::Internals I; 4496 typedef internal::Internals I;
4536 O* obj = *reinterpret_cast<O**>(this); 4497 O* obj = *reinterpret_cast<O**>(this);
4537 // Fast path: If the object is a plain JSObject, which is the common case, we 4498 // Fast path: If the object is a plain JSObject, which is the common case, we
4538 // know where to find the internal fields and can return the value directly. 4499 // know where to find the internal fields and can return the value directly.
4539 if (I::GetInstanceType(obj) == I::kJSObjectType) { 4500 if (I::GetInstanceType(obj) == I::kJSObjectType) {
4540 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); 4501 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4541 return I::ReadField<void*>(obj, offset); 4502 return I::ReadField<void*>(obj, offset);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 4687
4727 4688
4728 Function* Function::Cast(v8::Value* value) { 4689 Function* Function::Cast(v8::Value* value) {
4729 #ifdef V8_ENABLE_CHECKS 4690 #ifdef V8_ENABLE_CHECKS
4730 CheckCast(value); 4691 CheckCast(value);
4731 #endif 4692 #endif
4732 return static_cast<Function*>(value); 4693 return static_cast<Function*>(value);
4733 } 4694 }
4734 4695
4735 4696
4736 Local<Value> External::Wrap(void* value) {
4737 return External::New(value);
4738 }
4739
4740
4741 void* External::Unwrap(Handle<v8::Value> obj) {
4742 return External::Cast(*obj)->Value();
4743 }
4744
4745
4746 External* External::Cast(v8::Value* value) { 4697 External* External::Cast(v8::Value* value) {
4747 #ifdef V8_ENABLE_CHECKS 4698 #ifdef V8_ENABLE_CHECKS
4748 CheckCast(value); 4699 CheckCast(value);
4749 #endif 4700 #endif
4750 return static_cast<External*>(value); 4701 return static_cast<External*>(value);
4751 } 4702 }
4752 4703
4753 4704
4754 Isolate* AccessorInfo::GetIsolate() const { 4705 Isolate* AccessorInfo::GetIsolate() const {
4755 return *reinterpret_cast<Isolate**>(&args_[-3]); 4706 return *reinterpret_cast<Isolate**>(&args_[-3]);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4812 I::SetEmbedderData(this, data); 4763 I::SetEmbedderData(this, data);
4813 } 4764 }
4814 4765
4815 4766
4816 void* Isolate::GetData() { 4767 void* Isolate::GetData() {
4817 typedef internal::Internals I; 4768 typedef internal::Internals I;
4818 return I::GetEmbedderData(this); 4769 return I::GetEmbedderData(this);
4819 } 4770 }
4820 4771
4821 4772
4822 Local<Value> Context::GetData() {
4823 return GetEmbedderData(0);
4824 }
4825
4826 void Context::SetData(Handle<Value> data) {
4827 SetEmbedderData(0, data);
4828 }
4829
4830
4831 Local<Value> Context::GetEmbedderData(int index) { 4773 Local<Value> Context::GetEmbedderData(int index) {
4832 #ifndef V8_ENABLE_CHECKS 4774 #ifndef V8_ENABLE_CHECKS
4833 typedef internal::Object O; 4775 typedef internal::Object O;
4834 typedef internal::Internals I; 4776 typedef internal::Internals I;
4835 O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index)); 4777 O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index));
4836 return Local<Value>(reinterpret_cast<Value*>(result)); 4778 return Local<Value>(reinterpret_cast<Value*>(result));
4837 #else 4779 #else
4838 return SlowGetEmbedderData(index); 4780 return SlowGetEmbedderData(index);
4839 #endif 4781 #endif
4840 } 4782 }
(...skipping 22 matching lines...) Expand all
4863 4805
4864 4806
4865 } // namespace v8 4807 } // namespace v8
4866 4808
4867 4809
4868 #undef V8EXPORT 4810 #undef V8EXPORT
4869 #undef TYPE_CHECK 4811 #undef TYPE_CHECK
4870 4812
4871 4813
4872 #endif // V8_H_ 4814 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698