OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 exception_state.RethrowV8Exception(block.Exception()); | 897 exception_state.RethrowV8Exception(block.Exception()); |
898 return v8::Local<v8::Object>(); | 898 return v8::Local<v8::Object>(); |
899 } | 899 } |
900 if (!iterator->IsObject()) { | 900 if (!iterator->IsObject()) { |
901 exception_state.ThrowTypeError("Iterator is not an object."); | 901 exception_state.ThrowTypeError("Iterator is not an object."); |
902 return v8::Local<v8::Object>(); | 902 return v8::Local<v8::Object>(); |
903 } | 903 } |
904 return iterator.As<v8::Object>(); | 904 return iterator.As<v8::Object>(); |
905 } | 905 } |
906 | 906 |
| 907 bool IsV8Sequence(v8::Isolate* isolate, |
| 908 v8::Local<v8::Value> value, |
| 909 ExceptionState& exception_state) { |
| 910 if (!value->IsObject()) |
| 911 return false; |
| 912 v8::TryCatch block(isolate); |
| 913 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 914 v8::Local<v8::Value> iterator_getter; |
| 915 if (!value.As<v8::Object>() |
| 916 ->Get(context, v8::Symbol::GetIterator(isolate)) |
| 917 .ToLocal(&iterator_getter)) { |
| 918 exception_state.RethrowV8Exception(block.Exception()); |
| 919 return false; |
| 920 } |
| 921 return iterator_getter->IsFunction(); |
| 922 } |
| 923 |
907 bool AddHiddenValueToArray(v8::Isolate* isolate, | 924 bool AddHiddenValueToArray(v8::Isolate* isolate, |
908 v8::Local<v8::Object> object, | 925 v8::Local<v8::Object> object, |
909 v8::Local<v8::Value> value, | 926 v8::Local<v8::Value> value, |
910 int array_index) { | 927 int array_index) { |
911 ASSERT(!value.IsEmpty()); | 928 ASSERT(!value.IsEmpty()); |
912 v8::Local<v8::Value> array_value = object->GetInternalField(array_index); | 929 v8::Local<v8::Value> array_value = object->GetInternalField(array_index); |
913 if (array_value->IsNull() || array_value->IsUndefined()) { | 930 if (array_value->IsNull() || array_value->IsUndefined()) { |
914 array_value = v8::Array::New(isolate); | 931 array_value = v8::Array::New(isolate); |
915 object->SetInternalField(array_index, array_value); | 932 object->SetInternalField(array_index, array_value); |
916 } | 933 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 if (!V8Call(v8::JSON::Parse(isolate, V8String(isolate, stringified_json)), | 1005 if (!V8Call(v8::JSON::Parse(isolate, V8String(isolate, stringified_json)), |
989 parsed, try_catch)) { | 1006 parsed, try_catch)) { |
990 if (try_catch.HasCaught()) | 1007 if (try_catch.HasCaught()) |
991 exception_state.RethrowV8Exception(try_catch.Exception()); | 1008 exception_state.RethrowV8Exception(try_catch.Exception()); |
992 } | 1009 } |
993 | 1010 |
994 return parsed; | 1011 return parsed; |
995 } | 1012 } |
996 | 1013 |
997 } // namespace blink | 1014 } // namespace blink |
OLD | NEW |