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

Side by Side Diff: runtime/lib/byte_array.cc

Issue 10535178: Document the ByteArray types and reconcile with the implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 6 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 | runtime/lib/byte_array.dart » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/native_entry.h" 9 #include "vm/native_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 GETTER_ARGUMENTS(ArrayT, ValueT); \ 54 GETTER_ARGUMENTS(ArrayT, ValueT); \
55 RangeCheck(array, index.Value(), sizeof(ValueT)); \ 55 RangeCheck(array, index.Value(), sizeof(ValueT)); \
56 ValueT result; \ 56 ValueT result; \
57 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \ 57 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \
58 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); 58 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result)));
59 59
60 60
61 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \ 61 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \
62 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ 62 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \
63 RangeCheck(array, index.Value(), sizeof(ValueT)); \ 63 RangeCheck(array, index.Value(), sizeof(ValueT)); \
64 ValueT src = value_object.Getter(); \ 64 ValueT src = value_object.Getter(); \
65 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); 65 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); \
66 Integer& result = Integer::Handle(); \
67 result ^= Integer::New(index.Value() + sizeof(ValueT)); \
68 arguments->SetReturn(result);
66 69
67 70
68 #define UINT64_TO_INTEGER(value, integer) \ 71 #define UINT64_TO_INTEGER(value, integer) \
69 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ 72 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \
70 result = BigintOperations::NewFromUint64(value); \ 73 result = BigintOperations::NewFromUint64(value); \
71 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ 74 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \
72 result = Mint::New(value); \ 75 result = Mint::New(value); \
73 } else { \ 76 } else { \
74 result = Smi::New(value); \ 77 result = Smi::New(value); \
75 } 78 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 uint64_t value; \ 117 uint64_t value; \
115 INTEGER_TO_UINT64(value_object, value); \ 118 INTEGER_TO_UINT64(value_object, value); \
116 array.SetAt(index.Value(), value); 119 array.SetAt(index.Value(), value);
117 120
118 121
119 #define UNALIGNED_SETTER_UINT64(ArrayT) \ 122 #define UNALIGNED_SETTER_UINT64(ArrayT) \
120 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ 123 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \
121 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ 124 RangeCheck(array, index.Value(), sizeof(uint64_t)); \
122 uint64_t value; \ 125 uint64_t value; \
123 INTEGER_TO_UINT64(value_object, value); \ 126 INTEGER_TO_UINT64(value_object, value); \
124 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); 127 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); \
128 Integer& result = Integer::Handle(); \
129 result ^= Integer::New(index.Value() + sizeof(uint64_t)); \
130 arguments->SetReturn(result);
125 131
126 132
127 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) { 133 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) {
128 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0)); 134 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0));
129 const Smi& length = Smi::Handle(Smi::New(array.Length())); 135 const Smi& length = Smi::Handle(Smi::New(array.Length()));
130 arguments->SetReturn(length); 136 arguments->SetReturn(length);
131 } 137 }
132 138
133 139
134 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) { 140 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { 619 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) {
614 GETTER(ExternalFloat64Array, Double, double); 620 GETTER(ExternalFloat64Array, Double, double);
615 } 621 }
616 622
617 623
618 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { 624 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) {
619 SETTER(ExternalFloat64Array, Double, value, double); 625 SETTER(ExternalFloat64Array, Double, value, double);
620 } 626 }
621 627
622 } // namespace dart 628 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/byte_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698