OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 // This is incredibly unsafe: the handle is valid only when this | 83 // This is incredibly unsafe: the handle is valid only when this |
84 // UnsafePersistent is alive and valid (see class level comment). | 84 // UnsafePersistent is alive and valid (see class level comment). |
85 v8::Persistent<T>* persistent() | 85 v8::Persistent<T>* persistent() |
86 { | 86 { |
87 v8::Persistent<T>* handle = reinterpret_cast<v8::Persistent<T>*>(&m_valu
e); | 87 v8::Persistent<T>* handle = reinterpret_cast<v8::Persistent<T>*>(&m_valu
e); |
88 return handle; | 88 return handle; |
89 } | 89 } |
90 | 90 |
| 91 void setReferenceFrom(const v8::Persistent<v8::Object>& parent, v8::Isolate*
isolate) |
| 92 { |
| 93 isolate->SetReference(parent, *persistent()); |
| 94 } |
| 95 |
91 void dispose() | 96 void dispose() |
92 { | 97 { |
93 persistent()->Dispose(); | 98 persistent()->Dispose(); |
94 m_value = 0; | 99 m_value = 0; |
95 } | 100 } |
96 | 101 |
97 void clear() | 102 void clear() |
98 { | 103 { |
99 m_value = 0; | 104 m_value = 0; |
100 } | 105 } |
(...skipping 14 matching lines...) Expand all Loading... |
115 v8::Handle<T>* handle = reinterpret_cast<v8::Handle<T>*>(&m_value); | 120 v8::Handle<T>* handle = reinterpret_cast<v8::Handle<T>*>(&m_value); |
116 return *handle; | 121 return *handle; |
117 } | 122 } |
118 | 123 |
119 T* m_value; | 124 T* m_value; |
120 }; | 125 }; |
121 | 126 |
122 } // namespace WebCore | 127 } // namespace WebCore |
123 | 128 |
124 #endif // UnsafePersistent_h | 129 #endif // UnsafePersistent_h |
OLD | NEW |