| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 { | 202 { |
| 203 ASSERT(isolate); | 203 ASSERT(isolate); |
| 204 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString
, length); | 204 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString
, length); |
| 205 } | 205 } |
| 206 | 206 |
| 207 inline v8::Handle<v8::Value> v8Undefined() | 207 inline v8::Handle<v8::Value> v8Undefined() |
| 208 { | 208 { |
| 209 return v8::Handle<v8::Value>(); | 209 return v8::Handle<v8::Value>(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Converts a DOM object to a v8 value. | 212 // Converts a DOM object to a v8 value. This function is intended to be used |
| 213 // This is a no-inline version of toV8(). If you want to call toV8() | 213 // internally. If you want to convert a DOM object to a V8 value, |
| 214 // without creating #include cycles, you can use this function instead. | 214 // - Use toV8 if you can include V8X.h. |
| 215 // Each specialized implementation will be generated. | 215 // - Use V8ValueTraits<T>::toV8Value if you cannot include V8X.h. |
| 216 // Note: Including bindings/{core, modules}/v8/V8*.h from core and modules |
| 217 // is fine. In such a case, perhaps toV8 is what you want. |
| 218 // Note: toV8NoInline is a non-inline toV8 and V8ValueTraits::toV8Value offers |
| 219 // more: You can handle value conversion generally with it. |
| 216 template<typename T> | 220 template<typename T> |
| 217 v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationConte
xt, v8::Isolate*); | 221 v8::Handle<v8::Value> toV8NoInline(T* impl, v8::Handle<v8::Object> creationConte
xt, v8::Isolate*); |
| 218 | 222 |
| 219 template <typename T> | 223 template <typename T> |
| 220 struct V8ValueTraits { | 224 struct V8ValueTraits { |
| 221 static v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8::Object
> creationContext, v8::Isolate* isolate) | 225 static v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8::Object
> creationContext, v8::Isolate* isolate) |
| 222 { | 226 { |
| 223 if (!WTF::getPtr(value)) | 227 if (!WTF::getPtr(value)) |
| 224 return v8::Null(isolate); | 228 return v8::Null(isolate); |
| 225 return toV8NoInline(WTF::getPtr(value), creationContext, isolate); | 229 return toV8NoInline(WTF::getPtr(value), creationContext, isolate); |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 ~V8RethrowTryCatchScope() | 957 ~V8RethrowTryCatchScope() |
| 954 { | 958 { |
| 955 // ReThrow() is a no-op if no exception has been caught, so always call. | 959 // ReThrow() is a no-op if no exception has been caught, so always call. |
| 956 m_block.ReThrow(); | 960 m_block.ReThrow(); |
| 957 } | 961 } |
| 958 | 962 |
| 959 private: | 963 private: |
| 960 v8::TryCatch& m_block; | 964 v8::TryCatch& m_block; |
| 961 }; | 965 }; |
| 962 | 966 |
| 967 // Returns an object representing {done: true, value: undefined}. |
| 968 v8::Local<v8::Value> v8DoneIteratorResult(v8::Isolate*); |
| 969 |
| 970 // Returns an object representing {done: false, value: |value|}. |
| 971 v8::Local<v8::Value> v8IteratorResult(v8::Isolate*, v8::Handle<v8::Value>); |
| 972 template <typename T> |
| 973 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) |
| 974 { |
| 975 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value(
value, scriptState->context()->Global(), scriptState->isolate())); |
| 976 } |
| 977 |
| 963 } // namespace blink | 978 } // namespace blink |
| 964 | 979 |
| 965 #endif // V8Binding_h | 980 #endif // V8Binding_h |
| OLD | NEW |