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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 uint32_t sequence_length; | 822 uint32_t sequence_length; |
823 if (!V8Call(length_value->Uint32Value(isolate->GetCurrentContext()), | 823 if (!V8Call(length_value->Uint32Value(isolate->GetCurrentContext()), |
824 sequence_length, block)) { | 824 sequence_length, block)) { |
825 exception_state.RethrowV8Exception(block.Exception()); | 825 exception_state.RethrowV8Exception(block.Exception()); |
826 return false; | 826 return false; |
827 } | 827 } |
828 | 828 |
829 length = sequence_length; | 829 length = sequence_length; |
830 return true; | 830 return true; |
831 } | 831 } |
| 832 // Validates that the passed object is a sequence type per the WebIDL spec: it |
| 833 // has a callable @iterator. |
| 834 // https://heycam.github.io/webidl/#es-sequence |
| 835 CORE_EXPORT bool HasCallableIteratorSymbol(v8::Isolate*, |
| 836 v8::Local<v8::Value>, |
| 837 ExceptionState&); |
832 | 838 |
833 // TODO(rakuco): remove the specializations below (and consequently the | 839 // TODO(rakuco): remove the specializations below (and consequently the |
834 // non-IDLBase version of NativeValueTraitsBase) once we manage to convert all | 840 // non-IDLBase version of NativeValueTraitsBase) once we manage to convert all |
835 // uses of NativeValueTraits to types that derive from IDLBase or for generated | 841 // uses of NativeValueTraits to types that derive from IDLBase or for generated |
836 // IDL interfaces/dictionaries/unions. | 842 // IDL interfaces/dictionaries/unions. |
837 template <> | 843 template <> |
838 struct NativeValueTraits<String> { | 844 struct NativeValueTraits<String> { |
839 static inline String NativeValue(v8::Isolate* isolate, | 845 static inline String NativeValue(v8::Isolate* isolate, |
840 v8::Local<v8::Value> value, | 846 v8::Local<v8::Value> value, |
841 ExceptionState& exception_state) { | 847 ExceptionState& exception_state) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 template <> | 894 template <> |
889 struct NativeValueTraits<double> { | 895 struct NativeValueTraits<double> { |
890 static inline double NativeValue(v8::Isolate* isolate, | 896 static inline double NativeValue(v8::Isolate* isolate, |
891 v8::Local<v8::Value> value, | 897 v8::Local<v8::Value> value, |
892 ExceptionState& exception_state) { | 898 ExceptionState& exception_state) { |
893 return ToDouble(isolate, value, exception_state); | 899 return ToDouble(isolate, value, exception_state); |
894 } | 900 } |
895 }; | 901 }; |
896 | 902 |
897 template <> | 903 template <> |
898 struct NativeValueTraits<v8::Local<v8::Value>> { | 904 struct NativeValueTraits<v8::Local<v8::Value>> |
| 905 : public NativeValueTraitsBase<v8::Local<v8::Value>> { |
899 static inline v8::Local<v8::Value> NativeValue( | 906 static inline v8::Local<v8::Value> NativeValue( |
900 v8::Isolate* isolate, | 907 v8::Isolate* isolate, |
901 v8::Local<v8::Value> value, | 908 v8::Local<v8::Value> value, |
902 ExceptionState& exception_state) { | 909 ExceptionState& exception_state) { |
903 return value; | 910 return value; |
904 } | 911 } |
905 }; | 912 }; |
906 | 913 |
907 template <> | |
908 struct NativeValueTraits<ScriptValue> { | |
909 static inline ScriptValue NativeValue(v8::Isolate* isolate, | |
910 v8::Local<v8::Value> value, | |
911 ExceptionState& exception_state) { | |
912 return ScriptValue(ScriptState::Current(isolate), value); | |
913 } | |
914 }; | |
915 | |
916 template <typename T> | 914 template <typename T> |
917 struct NativeValueTraits<Vector<T>> { | 915 struct NativeValueTraits<Vector<T>> { |
918 static inline Vector<T> NativeValue(v8::Isolate* isolate, | 916 static inline Vector<T> NativeValue(v8::Isolate* isolate, |
919 v8::Local<v8::Value> value, | 917 v8::Local<v8::Value> value, |
920 ExceptionState& exception_state) { | 918 ExceptionState& exception_state) { |
921 return ToImplArray<Vector<T>>(value, 0, isolate, exception_state); | 919 return ToImplArray<Vector<T>>(value, 0, isolate, exception_state); |
922 } | 920 } |
923 }; | 921 }; |
924 | 922 |
925 CORE_EXPORT v8::Isolate* ToIsolate(ExecutionContext*); | 923 CORE_EXPORT v8::Isolate* ToIsolate(ExecutionContext*); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 exception_state.ThrowTypeError( | 1115 exception_state.ThrowTypeError( |
1118 "The provided ArrayBufferView value must not be shared."); | 1116 "The provided ArrayBufferView value must not be shared."); |
1119 return NotSharedType(); | 1117 return NotSharedType(); |
1120 } | 1118 } |
1121 return NotSharedType(dom_typed_array); | 1119 return NotSharedType(dom_typed_array); |
1122 } | 1120 } |
1123 | 1121 |
1124 } // namespace blink | 1122 } // namespace blink |
1125 | 1123 |
1126 #endif // V8Binding_h | 1124 #endif // V8Binding_h |
OLD | NEW |