Index: runtime/lib/typed_data.cc |
=================================================================== |
--- runtime/lib/typed_data.cc (revision 31864) |
+++ runtime/lib/typed_data.cc (working copy) |
@@ -187,7 +187,11 @@ |
} \ |
-#define TYPED_DATA_SETTER(setter, object, get_object_value, access_size) \ |
+#define TYPED_DATA_SETTER(setter, \ |
+ object, \ |
+ get_object_value, \ |
+ access_size, \ |
+ access_type) \ |
DEFINE_NATIVE_ENTRY(TypedData_##setter, 3) { \ |
GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0)); \ |
GET_NON_NULL_NATIVE_ARGUMENT(Smi, offsetInBytes, arguments->NativeArgAt(1)); \ |
@@ -196,12 +200,14 @@ |
const TypedData& array = TypedData::Cast(instance); \ |
RangeCheck(offsetInBytes.Value(), access_size, \ |
array.LengthInBytes(), access_size); \ |
- array.setter(offsetInBytes.Value(), value.get_object_value()); \ |
+ array.setter(offsetInBytes.Value(), \ |
+ static_cast<access_type>(value.get_object_value())); \ |
} else if (instance.IsExternalTypedData()) { \ |
const ExternalTypedData& array = ExternalTypedData::Cast(instance); \ |
RangeCheck(offsetInBytes.Value(), access_size, \ |
array.LengthInBytes(), access_size); \ |
- array.setter(offsetInBytes.Value(), value.get_object_value()); \ |
+ array.setter(offsetInBytes.Value(), \ |
+ static_cast<access_type>(value.get_object_value())); \ |
} else { \ |
const String& error = String::Handle(String::NewFormatted( \ |
"Expected a TypedData object but found %s", instance.ToCString())); \ |
@@ -270,9 +276,10 @@ |
setter, \ |
object, \ |
get_object_value, \ |
- access_size) \ |
+ access_size, \ |
+ access_type) \ |
TYPED_DATA_GETTER(getter, object, access_size) \ |
- TYPED_DATA_SETTER(setter, object, get_object_value, access_size) \ |
+ TYPED_DATA_SETTER(setter, object, get_object_value, access_size, access_type)\ |
#define TYPED_DATA_UINT64_NATIVES(getter, setter, object) \ |
@@ -280,18 +287,19 @@ |
TYPED_DATA_UINT64_SETTER(setter, object) \ |
-TYPED_DATA_NATIVES(GetInt8, SetInt8, Smi, Value, 1) |
-TYPED_DATA_NATIVES(GetUint8, SetUint8, Smi, Value, 1) |
-TYPED_DATA_NATIVES(GetInt16, SetInt16, Smi, Value, 2) |
-TYPED_DATA_NATIVES(GetUint16, SetUint16, Smi, Value, 2) |
-TYPED_DATA_NATIVES(GetInt32, SetInt32, Integer, AsInt64Value, 4) |
-TYPED_DATA_NATIVES(GetUint32, SetUint32, Integer, AsInt64Value, 4) |
-TYPED_DATA_NATIVES(GetInt64, SetInt64, Integer, AsInt64Value, 8) |
+TYPED_DATA_NATIVES(GetInt8, SetInt8, Smi, Value, 1, int8_t) |
+TYPED_DATA_NATIVES(GetUint8, SetUint8, Smi, Value, 1, uint8_t) |
+TYPED_DATA_NATIVES(GetInt16, SetInt16, Smi, Value, 2, int16_t) |
+TYPED_DATA_NATIVES(GetUint16, SetUint16, Smi, Value, 2, uint16_t) |
+TYPED_DATA_NATIVES(GetInt32, SetInt32, Integer, AsInt64Value, 4, int32_t) |
+TYPED_DATA_NATIVES(GetUint32, SetUint32, Integer, AsInt64Value, 4, uint32_t) |
+TYPED_DATA_NATIVES(GetInt64, SetInt64, Integer, AsInt64Value, 8, int64_t) |
TYPED_DATA_UINT64_NATIVES(GetUint64, SetUint64, Integer) |
-TYPED_DATA_NATIVES(GetFloat32, SetFloat32, Double, value, 4) |
-TYPED_DATA_NATIVES(GetFloat64, SetFloat64, Double, value, 8) |
-TYPED_DATA_NATIVES(GetFloat32x4, SetFloat32x4, Float32x4, value, 16) |
-TYPED_DATA_NATIVES(GetInt32x4, SetInt32x4, Int32x4, value, 16) |
+TYPED_DATA_NATIVES(GetFloat32, SetFloat32, Double, value, 4, float) |
+TYPED_DATA_NATIVES(GetFloat64, SetFloat64, Double, value, 8, double) |
+TYPED_DATA_NATIVES( |
+ GetFloat32x4, SetFloat32x4, Float32x4, value, 16, simd128_value_t) |
+TYPED_DATA_NATIVES(GetInt32x4, SetInt32x4, Int32x4, value, 16, simd128_value_t) |
DEFINE_NATIVE_ENTRY(ByteData_ToEndianInt16, 2) { |
@@ -321,8 +329,9 @@ |
DEFINE_NATIVE_ENTRY(ByteData_ToEndianInt32, 2) { |
GET_NON_NULL_NATIVE_ARGUMENT(Integer, host_value, arguments->NativeArgAt(0)); |
GET_NON_NULL_NATIVE_ARGUMENT(Bool, little_endian, arguments->NativeArgAt(1)); |
- ASSERT(host_value.AsInt64Value() <= kMaxInt32); |
- int32_t value = host_value.AsInt64Value(); |
+ ASSERT((host_value.AsInt64Value() >= kMinInt32) || |
+ (host_value.AsInt64Value() <= kMaxInt32)); |
+ int32_t value = static_cast<int32_t>(host_value.AsInt64Value()); |
if (little_endian.value()) { |
value = Utils::HostToLittleEndian32(value); |
} else { |
@@ -336,7 +345,7 @@ |
GET_NON_NULL_NATIVE_ARGUMENT(Integer, host_value, arguments->NativeArgAt(0)); |
GET_NON_NULL_NATIVE_ARGUMENT(Bool, little_endian, arguments->NativeArgAt(1)); |
ASSERT(host_value.AsInt64Value() <= kMaxUint32); |
- uint32_t value = host_value.AsInt64Value(); |
+ uint32_t value = static_cast<uint32_t>(host_value.AsInt64Value()); |
if (little_endian.value()) { |
value = Utils::HostToLittleEndian32(value); |
} else { |