Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp

Issue 2316263003: Add toImplSequence() (Closed)
Patch Set: style Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 } 898 }
899 return true; 899 return true;
900 } 900 }
901 901
902 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function) 902 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function)
903 { 903 {
904 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); 904 v8::Local<v8::Value> boundFunction = function->GetBoundFunction();
905 return boundFunction->IsFunction() ? v8::Local<v8::Function>::Cast(boundFunc tion) : function; 905 return boundFunction->IsFunction() ? v8::Local<v8::Function>::Cast(boundFunc tion) : function;
906 } 906 }
907 907
908 v8::MaybeLocal<v8::Object> getIterator(v8::Local<v8::Object> object, v8::Isolate * isolate, ExceptionState& exceptionState)
Yuki 2016/09/08 06:24:21 Is it worth doing to make this a general utility a
bashi 2016/09/08 06:30:49 That's a good idea but the point of this CL is to
Yuki 2016/09/08 08:32:21 Oops, I thought this is an accessor property, but
Yuki 2016/09/08 08:32:21 Please make v8::Isolate* as the first argument.
bashi 2016/09/09 00:54:22 Done.
909 {
910 v8::Local<v8::Context> context = isolate->GetCurrentContext();
911 v8::Local<v8::Value> iteratorGetter;
912 if (!object->Get(context, v8::Symbol::GetIterator(isolate)).ToLocal(&iterato rGetter)) {
913 return v8::MaybeLocal<v8::Object>();
haraken 2016/09/08 09:32:08 Don't we need to throw an exception here?
bashi 2016/09/09 00:54:22 No. IIRC, !ToLocal() means that v8 already thrown
914 }
915 if (!iteratorGetter->IsFunction()) {
916 exceptionState.throwTypeError("Iterator getter is not callable.");
917 return v8::MaybeLocal<v8::Object>();
918 }
919
920 v8::Local<v8::Function> getterFunction = iteratorGetter.As<v8::Function>();
921 v8::Local<v8::Value> iterator;
922 if (!getterFunction->Call(context, object, 0, nullptr).ToLocal(&iterator)) {
923 return v8::MaybeLocal<v8::Object>();
haraken 2016/09/08 09:32:08 Ditto.
924 }
925 if (!iterator->IsObject()) {
926 exceptionState.throwTypeError("Iterator is not an object.");
927 return v8::MaybeLocal<v8::Object>();
928 }
929 return v8::MaybeLocal<v8::Object>(iterator.As<v8::Object>());
930 }
931
908 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v 8::Local<v8::Value> value, int arrayIndex) 932 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v 8::Local<v8::Value> value, int arrayIndex)
909 { 933 {
910 ASSERT(!value.IsEmpty()); 934 ASSERT(!value.IsEmpty());
911 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 935 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
912 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { 936 if (arrayValue->IsNull() || arrayValue->IsUndefined()) {
913 arrayValue = v8::Array::New(isolate); 937 arrayValue = v8::Array::New(isolate);
914 object->SetInternalField(arrayIndex, arrayValue); 938 object->SetInternalField(arrayIndex, arrayValue);
915 } 939 }
916 940
917 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); 941 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 return frame->script().isolate(); 987 return frame->script().isolate();
964 } 988 }
965 989
966 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) 990 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late)
967 { 991 {
968 value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8:: IntegrityLevel::kFrozen).ToChecked(); 992 value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8:: IntegrityLevel::kFrozen).ToChecked();
969 return value; 993 return value;
970 } 994 }
971 995
972 } // namespace blink 996 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698