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: src/d8.cc

Issue 10718008: ARRAY_SIZE is not available on Linux-shared. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | 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 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 length = convertToUint(args[0], &try_catch); 486 length = convertToUint(args[0], &try_catch);
487 if (try_catch.HasCaught()) return try_catch.Exception(); 487 if (try_catch.HasCaught()) return try_catch.Exception();
488 } 488 }
489 byteLength = length * element_size; 489 byteLength = length * element_size;
490 byteOffset = 0; 490 byteOffset = 0;
491 491
492 Handle<Value> array_buffer = array_buffer_template_->GetFunction(); 492 Handle<Value> array_buffer = array_buffer_template_->GetFunction();
493 ASSERT(!try_catch.HasCaught() && array_buffer->IsFunction()); 493 ASSERT(!try_catch.HasCaught() && array_buffer->IsFunction());
494 Handle<Value> buffer_args[] = { Uint32::New(byteLength) }; 494 Handle<Value> buffer_args[] = { Uint32::New(byteLength) };
495 Handle<Value> result = Handle<Function>::Cast(array_buffer)->NewInstance( 495 Handle<Value> result = Handle<Function>::Cast(array_buffer)->NewInstance(
496 ARRAY_SIZE(buffer_args), buffer_args); 496 1, buffer_args);
497 if (try_catch.HasCaught()) return result; 497 if (try_catch.HasCaught()) return result;
498 buffer = result->ToObject(); 498 buffer = result->ToObject();
499 } 499 }
500 500
501 Handle<Object> array = CreateExternalArray( 501 Handle<Object> array = CreateExternalArray(
502 args.This(), buffer, type, length, byteLength, byteOffset, element_size); 502 args.This(), buffer, type, length, byteLength, byteOffset, element_size);
503 503
504 if (init_from_array) { 504 if (init_from_array) {
505 Handle<Object> init = args[0]->ToObject(); 505 Handle<Object> init = args[0]->ToObject();
506 for (int i = 0; i < length; ++i) array->Set(i, init->Get(i)); 506 for (int i = 0; i < length; ++i) array->Set(i, init->Get(i));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (end < begin) end = begin; 559 if (end < begin) end = begin;
560 } 560 }
561 561
562 length = end - begin; 562 length = end - begin;
563 byteOffset += begin * element_size; 563 byteOffset += begin * element_size;
564 564
565 Local<Function> constructor = Local<Function>::Cast(self->GetConstructor()); 565 Local<Function> constructor = Local<Function>::Cast(self->GetConstructor());
566 Handle<Value> construct_args[] = { 566 Handle<Value> construct_args[] = {
567 buffer, Uint32::New(byteOffset), Uint32::New(length) 567 buffer, Uint32::New(byteOffset), Uint32::New(length)
568 }; 568 };
569 return constructor->NewInstance(ARRAY_SIZE(construct_args), construct_args); 569 return constructor->NewInstance(3, construct_args);
570 } 570 }
571 571
572 572
573 void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) { 573 void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
574 HandleScope scope; 574 HandleScope scope;
575 int32_t length = 575 int32_t length =
576 object->ToObject()->Get(String::New("byteLength"))->Uint32Value(); 576 object->ToObject()->Get(String::New("byteLength"))->Uint32Value();
577 V8::AdjustAmountOfExternalAllocatedMemory(-length); 577 V8::AdjustAmountOfExternalAllocatedMemory(-length);
578 delete[] static_cast<uint8_t*>(data); 578 delete[] static_cast<uint8_t*>(data);
579 object.Dispose(); 579 object.Dispose();
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 } 1679 }
1680 1680
1681 } // namespace v8 1681 } // namespace v8
1682 1682
1683 1683
1684 #ifndef GOOGLE3 1684 #ifndef GOOGLE3
1685 int main(int argc, char* argv[]) { 1685 int main(int argc, char* argv[]) {
1686 return v8::Shell::Main(argc, argv); 1686 return v8::Shell::Main(argc, argv);
1687 } 1687 }
1688 #endif 1688 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698