OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 * This check fails when trying to convert between incompatible | 370 * This check fails when trying to convert between incompatible |
371 * handles. For example, converting from a Handle<String> to a | 371 * handles. For example, converting from a Handle<String> to a |
372 * Handle<Number>. | 372 * Handle<Number>. |
373 */ | 373 */ |
374 TYPE_CHECK(T, S); | 374 TYPE_CHECK(T, S); |
375 } | 375 } |
376 | 376 |
377 template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } | 377 template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } |
378 | 378 |
379 /** | 379 /** |
| 380 * A constructor that creates a new global cell pointing to that. In contrast |
| 381 * to the copy constructor, this creates a new persistent handle which needs |
| 382 * to be separately disposed. |
| 383 */ |
| 384 template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that)) |
| 385 : Handle<T>(New(isolate, that)) { } |
| 386 |
| 387 /** |
380 * "Casts" a plain handle which is known to be a persistent handle | 388 * "Casts" a plain handle which is known to be a persistent handle |
381 * to a persistent handle. | 389 * to a persistent handle. |
382 */ | 390 */ |
383 template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) | 391 template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) |
384 : Handle<T>(*that) { } | 392 : Handle<T>(*that) { } |
385 | 393 |
386 template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) { | 394 template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) { |
387 #ifdef V8_ENABLE_CHECKS | 395 #ifdef V8_ENABLE_CHECKS |
388 // If we're going to perform the type check then we have to check | 396 // If we're going to perform the type check then we have to check |
389 // that the handle isn't empty before doing the checked cast. | 397 // that the handle isn't empty before doing the checked cast. |
(...skipping 4831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5221 | 5229 |
5222 | 5230 |
5223 } // namespace v8 | 5231 } // namespace v8 |
5224 | 5232 |
5225 | 5233 |
5226 #undef V8EXPORT | 5234 #undef V8EXPORT |
5227 #undef TYPE_CHECK | 5235 #undef TYPE_CHECK |
5228 | 5236 |
5229 | 5237 |
5230 #endif // V8_H_ | 5238 #endif // V8_H_ |
OLD | NEW |