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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 result.uncheckedAppend(TraitsType::nativeValue(element, isolate, excepti
onState)); | 998 result.uncheckedAppend(TraitsType::nativeValue(element, isolate, excepti
onState)); |
999 if (exceptionState.hadException()) | 999 if (exceptionState.hadException()) |
1000 return Vector<T>(); | 1000 return Vector<T>(); |
1001 } | 1001 } |
1002 return result; | 1002 return result; |
1003 } | 1003 } |
1004 | 1004 |
1005 template <class T> | 1005 template <class T> |
1006 Vector<T> toImplArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int s
tartIndex, ExceptionState& exceptionState) | 1006 Vector<T> toImplArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int s
tartIndex, ExceptionState& exceptionState) |
1007 { | 1007 { |
1008 ASSERT(startIndex <= info.Length()); | |
1009 Vector<T> result; | 1008 Vector<T> result; |
1010 typedef NativeValueTraits<T> TraitsType; | 1009 typedef NativeValueTraits<T> TraitsType; |
1011 int length = info.Length(); | 1010 int length = info.Length(); |
1012 result.reserveInitialCapacity(length); | 1011 if (startIndex < length) { |
1013 for (int i = startIndex; i < length; ++i) { | 1012 result.reserveInitialCapacity(length - startIndex); |
1014 result.uncheckedAppend(TraitsType::nativeValue(info[i], info.GetIsolate(
), exceptionState)); | 1013 for (int i = startIndex; i < length; ++i) { |
1015 if (exceptionState.hadException()) | 1014 result.uncheckedAppend(TraitsType::nativeValue(info[i], info.GetIsol
ate(), exceptionState)); |
1016 return Vector<T>(); | 1015 if (exceptionState.hadException()) |
| 1016 return Vector<T>(); |
| 1017 } |
1017 } | 1018 } |
1018 return result; | 1019 return result; |
1019 } | 1020 } |
1020 | 1021 |
1021 // Validates that the passed object is a sequence type per WebIDL spec | 1022 // Validates that the passed object is a sequence type per WebIDL spec |
1022 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence | 1023 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence |
1023 inline bool toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isol
ate* isolate, ExceptionState& exceptionState) | 1024 inline bool toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isol
ate* isolate, ExceptionState& exceptionState) |
1024 { | 1025 { |
1025 // Attempt converting to a sequence if the value is not already an array but
is | 1026 // Attempt converting to a sequence if the value is not already an array but
is |
1026 // any kind of object except for a native Date object or a native RegExp obj
ect. | 1027 // any kind of object except for a native Date object or a native RegExp obj
ect. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) | 1259 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) |
1259 { | 1260 { |
1260 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value(
value, scriptState->context()->Global(), scriptState->isolate())); | 1261 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value(
value, scriptState->context()->Global(), scriptState->isolate())); |
1261 } | 1262 } |
1262 | 1263 |
1263 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is
olate*); | 1264 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is
olate*); |
1264 | 1265 |
1265 } // namespace blink | 1266 } // namespace blink |
1266 | 1267 |
1267 #endif // V8Binding_h | 1268 #endif // V8Binding_h |
OLD | NEW |