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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-compiler.cc
===================================================================
--- test/cctest/test-compiler.cc (revision 404)
+++ test/cctest/test-compiler.cc (working copy)
@@ -40,6 +40,51 @@
static v8::Persistent<v8::Context> env;
+// --- P r i n t E x t e n s i o n ---
+
+class PrintExtension : public v8::Extension {
+ public:
+ PrintExtension() : v8::Extension("v8/print", kSource) { }
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
+ v8::Handle<v8::String> name);
+ static v8::Handle<v8::Value> Print(const v8::Arguments& args);
+ private:
+ static const char* kSource;
+};
+
+
+const char* PrintExtension::kSource = "native function print();";
+
+
+v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunction(
+ v8::Handle<v8::String> str) {
+ return v8::FunctionTemplate::New(PrintExtension::Print);
+}
+
+
+v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) {
+ for (int i = 0; i < args.Length(); i++) {
+ if (i != 0) printf(" ");
+ v8::HandleScope scope;
+ v8::Handle<v8::Value> arg = args[i];
+ v8::Handle<v8::String> string_obj = arg->ToString();
+ if (string_obj.IsEmpty()) return string_obj;
+ int length = string_obj->Length();
+ uint16_t* string = NewArray<uint16_t>(length + 1);
+ string_obj->Write(string);
+ for (int j = 0; j < length; j++)
+ printf("%lc", string[j]);
+ DeleteArray(string);
+ }
+ printf("\n");
+ return v8::Undefined();
+}
+
+
+static PrintExtension kPrintExtension;
+v8::DeclareExtension kPrintExtensionDeclaration(&kPrintExtension);
+
+
static void InitializeVM() {
if (env.IsEmpty()) {
v8::HandleScope scope;
« 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