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

Side by Side Diff: src/handles.cc

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 break; 538 break;
539 } 539 }
540 if (source->Get(pos) == '\n') { 540 if (source->Get(pos) == '\n') {
541 line++; 541 line++;
542 } 542 }
543 } 543 }
544 return line; 544 return line;
545 } 545 }
546 546
547 547
548 void CustomArguments::IterateInstance(ObjectVisitor* v) {
549 v->VisitPointers(values_, values_ + ARRAY_SIZE(values_));
550 }
551
552
553 // Compute the property keys from the interceptor. 548 // Compute the property keys from the interceptor.
554 // TODO(rossberg): support symbols in API, and filter here if needed. 549 // TODO(rossberg): support symbols in API, and filter here if needed.
555 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSReceiver> receiver, 550 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSReceiver> receiver,
556 Handle<JSObject> object) { 551 Handle<JSObject> object) {
557 Isolate* isolate = receiver->GetIsolate(); 552 Isolate* isolate = receiver->GetIsolate();
558 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); 553 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor());
559 CustomArguments args(isolate, interceptor->data(), *receiver, *object); 554 PropertyCallbackArguments
560 v8::AccessorInfo info(args.end()); 555 args(isolate, interceptor->data(), *receiver, *object);
556 v8::AccessorInfo info = args.NewInfo();
561 v8::Handle<v8::Array> result; 557 v8::Handle<v8::Array> result;
562 if (!interceptor->enumerator()->IsUndefined()) { 558 if (!interceptor->enumerator()->IsUndefined()) {
563 v8::NamedPropertyEnumerator enum_fun = 559 v8::NamedPropertyEnumerator enum_fun =
564 v8::ToCData<v8::NamedPropertyEnumerator>(interceptor->enumerator()); 560 v8::ToCData<v8::NamedPropertyEnumerator>(interceptor->enumerator());
565 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object)); 561 LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object));
566 { 562 {
567 // Leaving JavaScript. 563 // Leaving JavaScript.
568 VMState<EXTERNAL> state(isolate); 564 VMState<EXTERNAL> state(isolate);
569 result = enum_fun(info); 565 result = args.GetCallbackResult(isolate, enum_fun, enum_fun(info));
570 } 566 }
571 } 567 }
572 #if ENABLE_EXTRA_CHECKS 568 #if ENABLE_EXTRA_CHECKS
573 CHECK(result.IsEmpty() || v8::Utils::OpenHandle(*result)->IsJSObject()); 569 CHECK(result.IsEmpty() || v8::Utils::OpenHandle(*result)->IsJSObject());
574 #endif 570 #endif
575 return result; 571 return result;
576 } 572 }
577 573
578 574
579 // Compute the element keys from the interceptor. 575 // Compute the element keys from the interceptor.
580 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSReceiver> receiver, 576 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSReceiver> receiver,
581 Handle<JSObject> object) { 577 Handle<JSObject> object) {
582 Isolate* isolate = receiver->GetIsolate(); 578 Isolate* isolate = receiver->GetIsolate();
583 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); 579 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor());
584 CustomArguments args(isolate, interceptor->data(), *receiver, *object); 580 PropertyCallbackArguments
585 v8::AccessorInfo info(args.end()); 581 args(isolate, interceptor->data(), *receiver, *object);
582 v8::AccessorInfo info = args.NewInfo();
586 v8::Handle<v8::Array> result; 583 v8::Handle<v8::Array> result;
587 if (!interceptor->enumerator()->IsUndefined()) { 584 if (!interceptor->enumerator()->IsUndefined()) {
588 v8::IndexedPropertyEnumerator enum_fun = 585 v8::IndexedPropertyEnumerator enum_fun =
589 v8::ToCData<v8::IndexedPropertyEnumerator>(interceptor->enumerator()); 586 v8::ToCData<v8::IndexedPropertyEnumerator>(interceptor->enumerator());
590 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object)); 587 LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object));
591 { 588 {
592 // Leaving JavaScript. 589 // Leaving JavaScript.
593 VMState<EXTERNAL> state(isolate); 590 VMState<EXTERNAL> state(isolate);
594 result = enum_fun(info); 591 result = args.GetCallbackResult(isolate, enum_fun, enum_fun(info));
595 #if ENABLE_EXTRA_CHECKS 592 #if ENABLE_EXTRA_CHECKS
596 CHECK(result.IsEmpty() || v8::Utils::OpenHandle(*result)->IsJSObject()); 593 CHECK(result.IsEmpty() || v8::Utils::OpenHandle(*result)->IsJSObject());
597 #endif 594 #endif
598 } 595 }
599 } 596 }
600 return result; 597 return result;
601 } 598 }
602 599
603 600
604 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { 601 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 data->next = prev_next_; 925 data->next = prev_next_;
929 data->limit = prev_limit_; 926 data->limit = prev_limit_;
930 #ifdef DEBUG 927 #ifdef DEBUG
931 handles_detached_ = true; 928 handles_detached_ = true;
932 #endif 929 #endif
933 return deferred; 930 return deferred;
934 } 931 }
935 932
936 933
937 } } // namespace v8::internal 934 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | src/x64/macro-assembler-x64.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698