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

Side by Side Diff: samples/lineprocessor.cc

Issue 18509003: Keep two empty lines between declarations for cpp files (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 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
« no previous file with comments | « PRESUBMIT.py ('k') | samples/process.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 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 } 316 }
317 v8::String::Utf8Value str(result); 317 v8::String::Utf8Value str(result);
318 const char* cstr = ToCString(str); 318 const char* cstr = ToCString(str);
319 printf("%s\n", cstr); 319 printf("%s\n", cstr);
320 } 320 }
321 321
322 return true; 322 return true;
323 } 323 }
324 324
325
325 int main(int argc, char* argv[]) { 326 int main(int argc, char* argv[]) {
326 int result = RunMain(argc, argv); 327 int result = RunMain(argc, argv);
327 v8::V8::Dispose(); 328 v8::V8::Dispose();
328 return result; 329 return result;
329 } 330 }
330 331
331 332
332 // Extracts a C string from a V8 Utf8Value. 333 // Extracts a C string from a V8 Utf8Value.
333 const char* ToCString(const v8::String::Utf8Value& value) { 334 const char* ToCString(const v8::String::Utf8Value& value) {
334 return *value ? *value : "<string conversion failed>"; 335 return *value ? *value : "<string conversion failed>";
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // The callback that is invoked by v8 whenever the JavaScript 'read_line' 415 // The callback that is invoked by v8 whenever the JavaScript 'read_line'
415 // function is called. Reads a string from standard input and returns. 416 // function is called. Reads a string from standard input and returns.
416 void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) { 417 void ReadLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
417 if (args.Length() > 0) { 418 if (args.Length() > 0) {
418 v8::ThrowException(v8::String::New("Unexpected arguments")); 419 v8::ThrowException(v8::String::New("Unexpected arguments"));
419 return; 420 return;
420 } 421 }
421 args.GetReturnValue().Set(ReadLine()); 422 args.GetReturnValue().Set(ReadLine());
422 } 423 }
423 424
425
424 v8::Handle<v8::String> ReadLine() { 426 v8::Handle<v8::String> ReadLine() {
425 const int kBufferSize = 1024 + 1; 427 const int kBufferSize = 1024 + 1;
426 char buffer[kBufferSize]; 428 char buffer[kBufferSize];
427 429
428 char* res; 430 char* res;
429 { 431 {
430 #ifdef ENABLE_DEBUGGER_SUPPORT 432 #ifdef ENABLE_DEBUGGER_SUPPORT
431 v8::Unlocker unlocker(v8::Isolate::GetCurrent()); 433 v8::Unlocker unlocker(v8::Isolate::GetCurrent());
432 #endif // ENABLE_DEBUGGER_SUPPORT 434 #endif // ENABLE_DEBUGGER_SUPPORT
433 res = fgets(buffer, kBufferSize, stdin); 435 res = fgets(buffer, kBufferSize, stdin);
434 } 436 }
435 if (res == NULL) { 437 if (res == NULL) {
436 v8::Handle<v8::Primitive> t = v8::Undefined(); 438 v8::Handle<v8::Primitive> t = v8::Undefined();
437 return v8::Handle<v8::String>::Cast(t); 439 return v8::Handle<v8::String>::Cast(t);
438 } 440 }
439 // Remove newline char 441 // Remove newline char
440 for (char* pos = buffer; *pos != '\0'; pos++) { 442 for (char* pos = buffer; *pos != '\0'; pos++) {
441 if (*pos == '\n') { 443 if (*pos == '\n') {
442 *pos = '\0'; 444 *pos = '\0';
443 break; 445 break;
444 } 446 }
445 } 447 }
446 return v8::String::New(buffer); 448 return v8::String::New(buffer);
447 } 449 }
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | samples/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698