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

Side by Side Diff: samples/shell.cc

Issue 7283039: Fix SConstruct to pass correct defines to samples/preparser when building with library=shared. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | « SConstruct ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 void ExternalArrayWeakCallback(v8::Persistent<v8::Value> object, void* data) { 492 void ExternalArrayWeakCallback(v8::Persistent<v8::Value> object, void* data) {
493 free(data); 493 free(data);
494 object.Dispose(); 494 object.Dispose();
495 } 495 }
496 496
497 497
498 v8::Handle<v8::Value> CreateExternalArray(const v8::Arguments& args, 498 v8::Handle<v8::Value> CreateExternalArray(const v8::Arguments& args,
499 v8::ExternalArrayType type, 499 v8::ExternalArrayType type,
500 size_t element_size) { 500 size_t element_size) {
501 ASSERT(element_size == 1 || element_size == 2 || element_size == 4 || 501 assert(element_size == 1 ||
502 element_size == 2 ||
503 element_size == 4 ||
502 element_size == 8); 504 element_size == 8);
503 if (args.Length() != 1) { 505 if (args.Length() != 1) {
504 return v8::ThrowException( 506 return v8::ThrowException(
505 v8::String::New("Array constructor needs one parameter.")); 507 v8::String::New("Array constructor needs one parameter."));
506 } 508 }
509 static const int kMaxLength = 0x3fffffff;
507 size_t length = 0; 510 size_t length = 0;
508 if (args[0]->IsUint32()) { 511 if (args[0]->IsUint32()) {
509 length = args[0]->Uint32Value(); 512 length = args[0]->Uint32Value();
510 } else if (args[0]->IsNumber()) { 513 } else if (args[0]->IsNumber()) {
511 double raw_length = args[0]->NumberValue(); 514 double raw_length = args[0]->NumberValue();
512 if (raw_length < 0) { 515 if (raw_length < 0) {
513 return v8::ThrowException( 516 return v8::ThrowException(
514 v8::String::New("Array length must not be negative.")); 517 v8::String::New("Array length must not be negative."));
515 } 518 }
516 if (raw_length > v8::internal::ExternalArray::kMaxLength) { 519 if (raw_length > kMaxLength) {
517 return v8::ThrowException( 520 return v8::ThrowException(
518 v8::String::New("Array length exceeds maximum length.")); 521 v8::String::New("Array length exceeds maximum length."));
519 } 522 }
520 length = static_cast<size_t>(raw_length); 523 length = static_cast<size_t>(raw_length);
521 } else { 524 } else {
522 return v8::ThrowException( 525 return v8::ThrowException(
523 v8::String::New("Array length must be a number.")); 526 v8::String::New("Array length must be a number."));
524 } 527 }
525 if (length > static_cast<size_t>(v8::internal::ExternalArray::kMaxLength)) { 528 if (length > static_cast<size_t>(kMaxLength)) {
526 return v8::ThrowException( 529 return v8::ThrowException(
527 v8::String::New("Array length exceeds maximum length.")); 530 v8::String::New("Array length exceeds maximum length."));
528 } 531 }
529 void* data = calloc(length, element_size); 532 void* data = calloc(length, element_size);
530 if (data == NULL) { 533 if (data == NULL) {
531 return v8::ThrowException(v8::String::New("Memory allocation failed.")); 534 return v8::ThrowException(v8::String::New("Memory allocation failed."));
532 } 535 }
533 v8::Handle<v8::Object> array = v8::Object::New(); 536 v8::Handle<v8::Object> array = v8::Object::New();
534 v8::Persistent<v8::Object> persistent_array = 537 v8::Persistent<v8::Object> persistent_array =
535 v8::Persistent<v8::Object>::New(array); 538 v8::Persistent<v8::Object>::New(array);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 printf("^"); 704 printf("^");
702 } 705 }
703 printf("\n"); 706 printf("\n");
704 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 707 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
705 if (stack_trace.length() > 0) { 708 if (stack_trace.length() > 0) {
706 const char* stack_trace_string = ToCString(stack_trace); 709 const char* stack_trace_string = ToCString(stack_trace);
707 printf("%s\n", stack_trace_string); 710 printf("%s\n", stack_trace_string);
708 } 711 }
709 } 712 }
710 } 713 }
OLDNEW
« no previous file with comments | « SConstruct ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698