Chromium Code Reviews| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( | 252 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( |
| 253 v8::HandleScope* scope) { | 253 v8::HandleScope* scope) { |
| 254 v8::internal::Handle<T> handle; | 254 v8::internal::Handle<T> handle; |
| 255 if (!is_null()) { | 255 if (!is_null()) { |
| 256 handle = *this; | 256 handle = *this; |
| 257 } | 257 } |
| 258 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(handle)), true); | 258 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(handle)), true); |
| 259 } | 259 } |
| 260 | 260 |
| 261 | 261 |
| 262 class InternalHandleHelper { | |
|
Sven Panne
2013/04/30 07:31:22
Why do we need to stuff this template into a helpe
dcarney
2013/04/30 07:43:21
I made this helper class a friend of Persistent an
| |
| 263 public: | |
| 264 template<class From, class To> | |
| 265 static inline Local<To> Convert(v8::internal::Handle<From> obj) { | |
| 266 return Local<To>(reinterpret_cast<To*>(obj.location())); | |
| 267 } | |
| 268 }; | |
| 269 | |
| 270 | |
| 262 // Implementations of ToLocal | 271 // Implementations of ToLocal |
| 263 | 272 |
| 264 #define MAKE_TO_LOCAL(Name, From, To) \ | 273 #define MAKE_TO_LOCAL(Name, From, To) \ |
| 265 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ | 274 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ |
| 266 ASSERT(obj.is_null() || !obj->IsTheHole()); \ | 275 ASSERT(obj.is_null() || !obj->IsTheHole()); \ |
| 267 return Local<To>(reinterpret_cast<To*>(obj.location())); \ | 276 return InternalHandleHelper::Convert<v8::internal::From, v8::To>(obj); \ |
| 268 } | 277 } |
| 269 | 278 |
| 270 MAKE_TO_LOCAL(ToLocal, Context, Context) | 279 MAKE_TO_LOCAL(ToLocal, Context, Context) |
| 271 MAKE_TO_LOCAL(ToLocal, Object, Value) | 280 MAKE_TO_LOCAL(ToLocal, Object, Value) |
| 272 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) | 281 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) |
| 273 MAKE_TO_LOCAL(ToLocal, String, String) | 282 MAKE_TO_LOCAL(ToLocal, String, String) |
| 274 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol) | 283 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol) |
| 275 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) | 284 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) |
| 276 MAKE_TO_LOCAL(ToLocal, JSObject, Object) | 285 MAKE_TO_LOCAL(ToLocal, JSObject, Object) |
| 277 MAKE_TO_LOCAL(ToLocal, JSArray, Array) | 286 MAKE_TO_LOCAL(ToLocal, JSArray, Array) |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 stress_type_ = stress_type; | 605 stress_type_ = stress_type; |
| 597 } | 606 } |
| 598 | 607 |
| 599 private: | 608 private: |
| 600 static v8::Testing::StressType stress_type_; | 609 static v8::Testing::StressType stress_type_; |
| 601 }; | 610 }; |
| 602 | 611 |
| 603 } } // namespace v8::internal | 612 } } // namespace v8::internal |
| 604 | 613 |
| 605 #endif // V8_API_H_ | 614 #endif // V8_API_H_ |
| OLD | NEW |