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

Side by Side Diff: src/api-natives.cc

Issue 2407313003: Use arraysize() instead of hardcoded kSize constants in api-natives.cc (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api-natives.h" 5 #include "src/api-natives.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/lookup.h" 9 #include "src/lookup.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 Handle<JSObject> object = isolate->factory()->NewJSObject(object_function); 527 Handle<JSObject> object = isolate->factory()->NewJSObject(object_function);
528 JSObject::ForceSetPrototype(object, isolate->factory()->null_value()); 528 JSObject::ForceSetPrototype(object, isolate->factory()->null_value());
529 529
530 return object; 530 return object;
531 } 531 }
532 532
533 void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, 533 void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
534 Handle<Name> name, Handle<Object> value, 534 Handle<Name> name, Handle<Object> value,
535 PropertyAttributes attributes) { 535 PropertyAttributes attributes) {
536 const int kSize = 3;
537 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 536 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
538 auto details_handle = handle(details.AsSmi(), isolate); 537 auto details_handle = handle(details.AsSmi(), isolate);
539 Handle<Object> data[kSize] = {name, details_handle, value}; 538 Handle<Object> data[] = {name, details_handle, value};
540 AddPropertyToPropertyList(isolate, info, kSize, data); 539 AddPropertyToPropertyList(isolate, info, arraysize(data), data);
541 } 540 }
542 541
543 542
544 void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, 543 void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
545 Handle<Name> name, v8::Intrinsic intrinsic, 544 Handle<Name> name, v8::Intrinsic intrinsic,
546 PropertyAttributes attributes) { 545 PropertyAttributes attributes) {
547 const int kSize = 4;
548 auto value = handle(Smi::FromInt(intrinsic), isolate); 546 auto value = handle(Smi::FromInt(intrinsic), isolate);
549 auto intrinsic_marker = isolate->factory()->true_value(); 547 auto intrinsic_marker = isolate->factory()->true_value();
550 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 548 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
551 auto details_handle = handle(details.AsSmi(), isolate); 549 auto details_handle = handle(details.AsSmi(), isolate);
552 Handle<Object> data[kSize] = {name, intrinsic_marker, details_handle, value}; 550 Handle<Object> data[] = {name, intrinsic_marker, details_handle, value};
553 AddPropertyToPropertyList(isolate, info, kSize, data); 551 AddPropertyToPropertyList(isolate, info, arraysize(data), data);
554 } 552 }
555 553
556 554
557 void ApiNatives::AddAccessorProperty(Isolate* isolate, 555 void ApiNatives::AddAccessorProperty(Isolate* isolate,
558 Handle<TemplateInfo> info, 556 Handle<TemplateInfo> info,
559 Handle<Name> name, 557 Handle<Name> name,
560 Handle<FunctionTemplateInfo> getter, 558 Handle<FunctionTemplateInfo> getter,
561 Handle<FunctionTemplateInfo> setter, 559 Handle<FunctionTemplateInfo> setter,
562 PropertyAttributes attributes) { 560 PropertyAttributes attributes) {
563 const int kSize = 4;
564 PropertyDetails details(attributes, ACCESSOR, 0, PropertyCellType::kNoCell); 561 PropertyDetails details(attributes, ACCESSOR, 0, PropertyCellType::kNoCell);
565 auto details_handle = handle(details.AsSmi(), isolate); 562 auto details_handle = handle(details.AsSmi(), isolate);
566 Handle<Object> data[kSize] = {name, details_handle, getter, setter}; 563 Handle<Object> data[] = {name, details_handle, getter, setter};
567 AddPropertyToPropertyList(isolate, info, kSize, data); 564 AddPropertyToPropertyList(isolate, info, arraysize(data), data);
568 } 565 }
569 566
570 567
571 void ApiNatives::AddNativeDataProperty(Isolate* isolate, 568 void ApiNatives::AddNativeDataProperty(Isolate* isolate,
572 Handle<TemplateInfo> info, 569 Handle<TemplateInfo> info,
573 Handle<AccessorInfo> property) { 570 Handle<AccessorInfo> property) {
574 Object* maybe_list = info->property_accessors(); 571 Object* maybe_list = info->property_accessors();
575 Handle<TemplateList> list; 572 Handle<TemplateList> list;
576 if (maybe_list->IsUndefined(isolate)) { 573 if (maybe_list->IsUndefined(isolate)) {
577 list = TemplateList::New(isolate, 1); 574 list = TemplateList::New(isolate, 1);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (!obj->instance_call_handler()->IsUndefined(isolate)) { 676 if (!obj->instance_call_handler()->IsUndefined(isolate)) {
680 map->set_is_callable(); 677 map->set_is_callable();
681 map->set_is_constructor(true); 678 map->set_is_constructor(true);
682 } 679 }
683 680
684 return result; 681 return result;
685 } 682 }
686 683
687 } // namespace internal 684 } // namespace internal
688 } // namespace v8 685 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698