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

Side by Side Diff: samples/shell.cc

Issue 345903004: Split out libplatform into a separate libary (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <v8.h> 28 #include <include/v8.h>
29
30 #include <include/libplatform/libplatform.h>
29 31
30 #include <assert.h> 32 #include <assert.h>
31 #include <fcntl.h> 33 #include <fcntl.h>
32 #include <stdio.h> 34 #include <stdio.h>
33 #include <stdlib.h> 35 #include <stdlib.h>
34 #include <string.h> 36 #include <string.h>
35 37
36 #ifdef COMPRESS_STARTUP_DATA_BZ2 38 #ifdef COMPRESS_STARTUP_DATA_BZ2
37 #error Using compressed startup data is not supported for this sample 39 #error Using compressed startup data is not supported for this sample
38 #endif 40 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void* data = AllocateUninitialized(length); 74 void* data = AllocateUninitialized(length);
73 return data == NULL ? data : memset(data, 0, length); 75 return data == NULL ? data : memset(data, 0, length);
74 } 76 }
75 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } 77 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
76 virtual void Free(void* data, size_t) { free(data); } 78 virtual void Free(void* data, size_t) { free(data); }
77 }; 79 };
78 80
79 81
80 int main(int argc, char* argv[]) { 82 int main(int argc, char* argv[]) {
81 v8::V8::InitializeICU(); 83 v8::V8::InitializeICU();
84 v8::Platform* platform = v8::platform::CreateDefaultPlatform(0);
85 v8::V8::InitializePlatform(platform);
82 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 86 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
83 ShellArrayBufferAllocator array_buffer_allocator; 87 ShellArrayBufferAllocator array_buffer_allocator;
84 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); 88 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
85 v8::Isolate* isolate = v8::Isolate::New(); 89 v8::Isolate* isolate = v8::Isolate::New();
86 run_shell = (argc == 1); 90 run_shell = (argc == 1);
87 int result; 91 int result;
88 { 92 {
89 v8::Isolate::Scope isolate_scope(isolate); 93 v8::Isolate::Scope isolate_scope(isolate);
90 v8::HandleScope handle_scope(isolate); 94 v8::HandleScope handle_scope(isolate);
91 v8::Handle<v8::Context> context = CreateShellContext(isolate); 95 v8::Handle<v8::Context> context = CreateShellContext(isolate);
92 if (context.IsEmpty()) { 96 if (context.IsEmpty()) {
93 fprintf(stderr, "Error creating context\n"); 97 fprintf(stderr, "Error creating context\n");
94 return 1; 98 return 1;
95 } 99 }
96 v8::Context::Scope context_scope(context); 100 v8::Context::Scope context_scope(context);
97 result = RunMain(isolate, argc, argv); 101 result = RunMain(isolate, argc, argv);
98 if (run_shell) RunShell(context); 102 if (run_shell) RunShell(context);
99 } 103 }
100 v8::V8::Dispose(); 104 v8::V8::Dispose();
105 v8::V8::ShutdownPlatform();
106 delete platform;
101 return result; 107 return result;
102 } 108 }
103 109
104 110
105 // Extracts a C string from a V8 Utf8Value. 111 // Extracts a C string from a V8 Utf8Value.
106 const char* ToCString(const v8::String::Utf8Value& value) { 112 const char* ToCString(const v8::String::Utf8Value& value) {
107 return *value ? *value : "<string conversion failed>"; 113 return *value ? *value : "<string conversion failed>";
108 } 114 }
109 115
110 116
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 fprintf(stderr, "^"); 383 fprintf(stderr, "^");
378 } 384 }
379 fprintf(stderr, "\n"); 385 fprintf(stderr, "\n");
380 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 386 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
381 if (stack_trace.length() > 0) { 387 if (stack_trace.length() > 0) {
382 const char* stack_trace_string = ToCString(stack_trace); 388 const char* stack_trace_string = ToCString(stack_trace);
383 fprintf(stderr, "%s\n", stack_trace_string); 389 fprintf(stderr, "%s\n", stack_trace_string);
384 } 390 }
385 } 391 }
386 } 392 }
OLDNEW
« samples/process.cc ('K') | « samples/samples.gyp ('k') | src/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698