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

Side by Side Diff: test/cctest/test-compiler.cc

Issue 6233: Removed the print, load, quit and version extensions from the VM. Moved the p... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 22 matching lines...) Expand all
33 #include "execution.h" 33 #include "execution.h"
34 #include "factory.h" 34 #include "factory.h"
35 #include "platform.h" 35 #include "platform.h"
36 #include "top.h" 36 #include "top.h"
37 #include "cctest.h" 37 #include "cctest.h"
38 38
39 using namespace v8::internal; 39 using namespace v8::internal;
40 40
41 static v8::Persistent<v8::Context> env; 41 static v8::Persistent<v8::Context> env;
42 42
43 // --- P r i n t E x t e n s i o n ---
44
45 class PrintExtension : public v8::Extension {
46 public:
47 PrintExtension() : v8::Extension("v8/print", kSource) { }
48 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
49 v8::Handle<v8::String> name);
50 static v8::Handle<v8::Value> Print(const v8::Arguments& args);
51 private:
52 static const char* kSource;
53 };
54
55
56 const char* PrintExtension::kSource = "native function print();";
57
58
59 v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunction(
60 v8::Handle<v8::String> str) {
61 return v8::FunctionTemplate::New(PrintExtension::Print);
62 }
63
64
65 v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) {
66 for (int i = 0; i < args.Length(); i++) {
67 if (i != 0) printf(" ");
68 v8::HandleScope scope;
69 v8::Handle<v8::Value> arg = args[i];
70 v8::Handle<v8::String> string_obj = arg->ToString();
71 if (string_obj.IsEmpty()) return string_obj;
72 int length = string_obj->Length();
73 uint16_t* string = NewArray<uint16_t>(length + 1);
74 string_obj->Write(string);
75 for (int j = 0; j < length; j++)
76 printf("%lc", string[j]);
77 DeleteArray(string);
78 }
79 printf("\n");
80 return v8::Undefined();
81 }
82
83
84 static PrintExtension kPrintExtension;
85 v8::DeclareExtension kPrintExtensionDeclaration(&kPrintExtension);
86
87
43 static void InitializeVM() { 88 static void InitializeVM() {
44 if (env.IsEmpty()) { 89 if (env.IsEmpty()) {
45 v8::HandleScope scope; 90 v8::HandleScope scope;
46 const char* extensions[] = { "v8/print", "v8/gc" }; 91 const char* extensions[] = { "v8/print", "v8/gc" };
47 v8::ExtensionConfiguration config(2, extensions); 92 v8::ExtensionConfiguration config(2, extensions);
48 env = v8::Context::New(&config); 93 env = v8::Context::New(&config);
49 } 94 }
50 v8::HandleScope scope; 95 v8::HandleScope scope;
51 env->Enter(); 96 env->Enter();
52 } 97 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 *Factory::LookupAsciiSymbol("foo"))); 295 *Factory::LookupAsciiSymbol("foo")));
251 CHECK(fun1->IsJSFunction()); 296 CHECK(fun1->IsJSFunction());
252 297
253 Object** argv[1] = { 298 Object** argv[1] = {
254 Handle<Object>::cast(Factory::LookupAsciiSymbol("hello")).location() 299 Handle<Object>::cast(Factory::LookupAsciiSymbol("hello")).location()
255 }; 300 };
256 Execution::Call(Handle<JSFunction>::cast(fun1), global, 1, argv, 301 Execution::Call(Handle<JSFunction>::cast(fun1), global, 1, argv,
257 &has_pending_exception); 302 &has_pending_exception);
258 CHECK(!has_pending_exception); 303 CHECK(!has_pending_exception);
259 } 304 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698