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

Side by Side Diff: samples/shell.cc

Issue 6805010: Make "length" and "BYTES_PER_ELEMENT" properties of typed arrays accessible. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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 | test/mjsunit/external-array.js » ('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 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 v8::String::New("Array constructor needs one parameter.")); 459 v8::String::New("Array constructor needs one parameter."));
460 } 460 }
461 int length = args[0]->Int32Value(); 461 int length = args[0]->Int32Value();
462 void* data = malloc(length * element_size); 462 void* data = malloc(length * element_size);
463 memset(data, 0, length * element_size); 463 memset(data, 0, length * element_size);
464 v8::Handle<v8::Object> array = v8::Object::New(); 464 v8::Handle<v8::Object> array = v8::Object::New();
465 v8::Persistent<v8::Object> persistent_array = 465 v8::Persistent<v8::Object> persistent_array =
466 v8::Persistent<v8::Object>::New(array); 466 v8::Persistent<v8::Object>::New(array);
467 persistent_array.MakeWeak(data, ExternalArrayWeakCallback); 467 persistent_array.MakeWeak(data, ExternalArrayWeakCallback);
468 array->SetIndexedPropertiesToExternalArrayData(data, type, length); 468 array->SetIndexedPropertiesToExternalArrayData(data, type, length);
469 array->Set(v8::String::New("length"), v8::Int32::New(length),
470 v8::ReadOnly);
471 array->Set(v8::String::New("BYTES_PER_ELEMENT"),
472 v8::Int32::New(element_size));
469 return array; 473 return array;
470 } 474 }
471 475
472 476
473 v8::Handle<v8::Value> Int8Array(const v8::Arguments& args) { 477 v8::Handle<v8::Value> Int8Array(const v8::Arguments& args) {
474 return CreateExternalArray(args, v8::kExternalByteArray, sizeof(int8_t)); 478 return CreateExternalArray(args, v8::kExternalByteArray, sizeof(int8_t));
475 } 479 }
476 480
477 481
478 v8::Handle<v8::Value> Uint8Array(const v8::Arguments& args) { 482 v8::Handle<v8::Value> Uint8Array(const v8::Arguments& args) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 printf("^"); 625 printf("^");
622 } 626 }
623 printf("\n"); 627 printf("\n");
624 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 628 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
625 if (stack_trace.length() > 0) { 629 if (stack_trace.length() > 0) {
626 const char* stack_trace_string = ToCString(stack_trace); 630 const char* stack_trace_string = ToCString(stack_trace);
627 printf("%s\n", stack_trace_string); 631 printf("%s\n", stack_trace_string);
628 } 632 }
629 } 633 }
630 } 634 }
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/external-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698