| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( | 284 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( |
| 285 v8::HandleScope* scope) { | 285 v8::HandleScope* scope) { |
| 286 v8::internal::Handle<T> handle; | 286 v8::internal::Handle<T> handle; |
| 287 if (!is_null()) { | 287 if (!is_null()) { |
| 288 handle = *this; | 288 handle = *this; |
| 289 } | 289 } |
| 290 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(handle)), true); | 290 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(handle)), true); |
| 291 } | 291 } |
| 292 | 292 |
| 293 | 293 |
| 294 class InternalHandleHelper { |
| 295 public: |
| 296 template<class From, class To> |
| 297 static inline Local<To> Convert(v8::internal::Handle<From> obj) { |
| 298 return Local<To>(reinterpret_cast<To*>(obj.location())); |
| 299 } |
| 300 }; |
| 301 |
| 302 |
| 294 // Implementations of ToLocal | 303 // Implementations of ToLocal |
| 295 | 304 |
| 296 #define MAKE_TO_LOCAL(Name, From, To) \ | 305 #define MAKE_TO_LOCAL(Name, From, To) \ |
| 297 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ | 306 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ |
| 298 ASSERT(obj.is_null() || !obj->IsTheHole()); \ | 307 ASSERT(obj.is_null() || !obj->IsTheHole()); \ |
| 299 return Local<To>(reinterpret_cast<To*>(obj.location())); \ | 308 return InternalHandleHelper::Convert<v8::internal::From, v8::To>(obj); \ |
| 300 } | 309 } |
| 301 | 310 |
| 302 | 311 |
| 303 #define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \ | 312 #define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \ |
| 304 Local<v8::TypedArray> Utils::ToLocal##TypedArray( \ | 313 Local<v8::TypedArray> Utils::ToLocal##TypedArray( \ |
| 305 v8::internal::Handle<v8::internal::JSTypedArray> obj) { \ | 314 v8::internal::Handle<v8::internal::JSTypedArray> obj) { \ |
| 306 ASSERT(obj.is_null() || !obj->IsTheHole()); \ | 315 ASSERT(obj.is_null() || !obj->IsTheHole()); \ |
| 307 ASSERT(obj->type() == typeConst); \ | 316 ASSERT(obj->type() == typeConst); \ |
| 308 return Local<v8::TypedArray>( \ | 317 return InternalHandleHelper:: \ |
| 309 reinterpret_cast<v8::TypedArray*>(obj.location())); \ | 318 Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \ |
| 310 } | 319 } |
| 311 | 320 |
| 312 | 321 |
| 313 MAKE_TO_LOCAL(ToLocal, Context, Context) | 322 MAKE_TO_LOCAL(ToLocal, Context, Context) |
| 314 MAKE_TO_LOCAL(ToLocal, Object, Value) | 323 MAKE_TO_LOCAL(ToLocal, Object, Value) |
| 315 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) | 324 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) |
| 316 MAKE_TO_LOCAL(ToLocal, String, String) | 325 MAKE_TO_LOCAL(ToLocal, String, String) |
| 317 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol) | 326 MAKE_TO_LOCAL(ToLocal, Symbol, Symbol) |
| 318 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) | 327 MAKE_TO_LOCAL(ToLocal, JSRegExp, RegExp) |
| 319 MAKE_TO_LOCAL(ToLocal, JSObject, Object) | 328 MAKE_TO_LOCAL(ToLocal, JSObject, Object) |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 stress_type_ = stress_type; | 661 stress_type_ = stress_type; |
| 653 } | 662 } |
| 654 | 663 |
| 655 private: | 664 private: |
| 656 static v8::Testing::StressType stress_type_; | 665 static v8::Testing::StressType stress_type_; |
| 657 }; | 666 }; |
| 658 | 667 |
| 659 } } // namespace v8::internal | 668 } } // namespace v8::internal |
| 660 | 669 |
| 661 #endif // V8_API_H_ | 670 #endif // V8_API_H_ |
| OLD | NEW |