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

Side by Side Diff: src/d8.cc

Issue 2746053006: NOT FOR COMMIT: test that interceptors work with the inspector.
Patch Set: Created 3 years, 9 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 | test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 <errno.h> 5 #include <errno.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 isolate, script->Run(context).ToLocalChecked().As<Function>()); 1430 isolate, script->Run(context).ToLocalChecked().As<Function>());
1431 } 1431 }
1432 Local<Function> fun = Local<Function>::New(isolate, stringify_function_); 1432 Local<Function> fun = Local<Function>::New(isolate, stringify_function_);
1433 Local<Value> argv[1] = {value}; 1433 Local<Value> argv[1] = {value};
1434 v8::TryCatch try_catch(isolate); 1434 v8::TryCatch try_catch(isolate);
1435 MaybeLocal<Value> result = fun->Call(context, Undefined(isolate), 1, argv); 1435 MaybeLocal<Value> result = fun->Call(context, Undefined(isolate), 1, argv);
1436 if (result.IsEmpty()) return String::Empty(isolate); 1436 if (result.IsEmpty()) return String::Empty(isolate);
1437 return result.ToLocalChecked().As<String>(); 1437 return result.ToLocalChecked().As<String>();
1438 } 1438 }
1439 1439
1440 void NamedGetter(Local<String> property,
1441 const PropertyCallbackInfo<Value>& info) {
1442 Isolate* isolate = Isolate::GetCurrent();
1443 EscapableHandleScope scope(isolate);
1444 Local<Object> selfObj = info.Holder();
1445 info.GetReturnValue().Set(
1446 scope.Escape(String::NewFromUtf8(isolate, "value")));
1447 }
1448
1449 void NamedSetter(Local<String> property, Local<Value> value,
1450 const PropertyCallbackInfo<Value>& info) {
1451 Isolate* isolate = Isolate::GetCurrent();
1452 EscapableHandleScope scope(isolate);
1453 Local<Object> selfObj = info.Holder();
1454 }
1455
1456 void NamedEnumerator(const PropertyCallbackInfo<Array>& info) {
1457 Isolate* isolate = Isolate::GetCurrent();
1458 EscapableHandleScope scope(isolate);
1459 Local<Object> selfObj = info.Holder();
1460 Handle<Array> array = Array::New(isolate);
1461 array->Set(0, String::NewFromUtf8(isolate, "one"));
1462 array->Set(1, String::NewFromUtf8(isolate, "two"));
1463 array->Set(2, String::NewFromUtf8(isolate, "three"));
1464 array->Set(3, String::NewFromUtf8(isolate, "four"));
1465 info.GetReturnValue().Set(scope.Escape(array));
1466 }
1440 1467
1441 Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { 1468 Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
1442 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); 1469 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
1443 global_template->Set( 1470 global_template->Set(
1444 String::NewFromUtf8(isolate, "print", NewStringType::kNormal) 1471 String::NewFromUtf8(isolate, "print", NewStringType::kNormal)
1445 .ToLocalChecked(), 1472 .ToLocalChecked(),
1446 FunctionTemplate::New(isolate, Print)); 1473 FunctionTemplate::New(isolate, Print));
1447 global_template->Set( 1474 global_template->Set(
1448 String::NewFromUtf8(isolate, "printErr", NewStringType::kNormal) 1475 String::NewFromUtf8(isolate, "printErr", NewStringType::kNormal)
1449 .ToLocalChecked(), 1476 .ToLocalChecked(),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 .ToLocalChecked(), 1600 .ToLocalChecked(),
1574 worker_fun_template); 1601 worker_fun_template);
1575 1602
1576 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); 1603 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
1577 AddOSMethods(isolate, os_templ); 1604 AddOSMethods(isolate, os_templ);
1578 global_template->Set( 1605 global_template->Set(
1579 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) 1606 String::NewFromUtf8(isolate, "os", NewStringType::kNormal)
1580 .ToLocalChecked(), 1607 .ToLocalChecked(),
1581 os_templ); 1608 os_templ);
1582 1609
1610 Local<FunctionTemplate> funTem = FunctionTemplate::New(isolate);
1611 Local<ObjectTemplate> inst = funTem->InstanceTemplate();
1612 inst->SetNamedPropertyHandler(NamedGetter, NamedSetter, 0, 0,
1613 NamedEnumerator);
1614
1615 global_template->Set(String::NewFromUtf8(isolate, "NamedObject"), funTem,
1616 v8::PropertyAttribute(v8::DontDelete | v8::ReadOnly));
1617
1583 return global_template; 1618 return global_template;
1584 } 1619 }
1585 1620
1586 static void PrintNonErrorsMessageCallback(Local<Message> message, 1621 static void PrintNonErrorsMessageCallback(Local<Message> message,
1587 Local<Value> error) { 1622 Local<Value> error) {
1588 // Nothing to do here for errors, exceptions thrown up to the shell will be 1623 // Nothing to do here for errors, exceptions thrown up to the shell will be
1589 // reported 1624 // reported
1590 // separately by {Shell::ReportException} after they are caught. 1625 // separately by {Shell::ReportException} after they are caught.
1591 // Do print other kinds of messages. 1626 // Do print other kinds of messages.
1592 switch (message->ErrorLevel()) { 1627 switch (message->ErrorLevel()) {
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
3043 } 3078 }
3044 3079
3045 } // namespace v8 3080 } // namespace v8
3046 3081
3047 3082
3048 #ifndef GOOGLE3 3083 #ifndef GOOGLE3
3049 int main(int argc, char* argv[]) { 3084 int main(int argc, char* argv[]) {
3050 return v8::Shell::Main(argc, argv); 3085 return v8::Shell::Main(argc, argv);
3051 } 3086 }
3052 #endif 3087 #endif
OLDNEW
« no previous file with comments | « no previous file | test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698