OLD | NEW |
---|---|
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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 array->Set(String::New("length"), Int32::New(length), ReadOnly); | 436 array->Set(String::New("length"), Int32::New(length), ReadOnly); |
437 array->Set(String::New("BYTES_PER_ELEMENT"), Int32::New(element_size)); | 437 array->Set(String::New("BYTES_PER_ELEMENT"), Int32::New(element_size)); |
438 array->Set(String::New("buffer"), buffer, ReadOnly); | 438 array->Set(String::New("buffer"), buffer, ReadOnly); |
439 | 439 |
440 return array; | 440 return array; |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) { | 444 void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) { |
445 HandleScope scope; | 445 HandleScope scope; |
446 Local<Value> length = object->ToObject()->Get(String::New("byteLength")); | 446 int32_t length = |
447 V8::AdjustAmountOfExternalAllocatedMemory(-length->Uint32Value()); | 447 object->ToObject()->Get(String::New("byteLength"))->Uint32Value(); |
Michael Starzinger
2012/06/01 12:00:10
Hmm, this looks strange, it implicitly casts uint3
rossberg
2012/06/01 12:06:20
It's done in other places, too. It's correct becau
| |
448 V8::AdjustAmountOfExternalAllocatedMemory(-length); | |
448 delete[] static_cast<uint8_t*>(data); | 449 delete[] static_cast<uint8_t*>(data); |
449 object.Dispose(); | 450 object.Dispose(); |
450 } | 451 } |
451 | 452 |
452 | 453 |
453 Handle<Value> Shell::ArrayBuffer(const Arguments& args) { | 454 Handle<Value> Shell::ArrayBuffer(const Arguments& args) { |
454 return CreateExternalArrayBuffer(args); | 455 return CreateExternalArrayBuffer(args); |
455 } | 456 } |
456 | 457 |
457 | 458 |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1541 } | 1542 } |
1542 | 1543 |
1543 } // namespace v8 | 1544 } // namespace v8 |
1544 | 1545 |
1545 | 1546 |
1546 #ifndef GOOGLE3 | 1547 #ifndef GOOGLE3 |
1547 int main(int argc, char* argv[]) { | 1548 int main(int argc, char* argv[]) { |
1548 return v8::Shell::Main(argc, argv); | 1549 return v8::Shell::Main(argc, argv); |
1549 } | 1550 } |
1550 #endif | 1551 #endif |
OLD | NEW |