OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | |
5 #include "tonic/dart_error.h" | 6 #include "tonic/dart_error.h" |
6 #include "tonic/float32_list.h" | 7 #include "tonic/float32_list.h" |
7 | 8 |
8 namespace blink { | 9 namespace blink { |
9 | 10 |
10 Float32List::Float32List(Dart_Handle list) | 11 Float32List::Float32List(Dart_Handle list) |
11 : data_(nullptr), num_elements_(0), dart_handle_(list) { | 12 : data_(nullptr), num_elements_(0), dart_handle_(list) { |
12 if (Dart_IsNull(list)) | 13 if (Dart_IsNull(list)) |
13 return; | 14 return; |
14 | 15 |
15 Dart_TypedData_Type type; | 16 Dart_TypedData_Type type; |
16 Dart_TypedDataAcquireData( | 17 Dart_TypedDataAcquireData( |
17 list, &type, reinterpret_cast<void**>(&data_), &num_elements_); | 18 list, &type, reinterpret_cast<void**>(&data_), &num_elements_); |
18 DCHECK(!LogIfError(list)); | 19 DCHECK(!LogIfError(list)); |
19 ASSERT(type == Dart_TypedData_kFloat32); | 20 CHECK(type == Dart_TypedData_kFloat32); |
abarth-chromium
2015/07/20 22:49:18
DCHECK
Cutch
2015/07/21 13:55:31
Done.
| |
20 } | 21 } |
21 | 22 |
22 Float32List::Float32List(Float32List&& other) | 23 Float32List::Float32List(Float32List&& other) |
23 : data_(other.data_), | 24 : data_(other.data_), |
24 num_elements_(other.num_elements_), | 25 num_elements_(other.num_elements_), |
25 dart_handle_(other.dart_handle_) { | 26 dart_handle_(other.dart_handle_) { |
26 other.data_ = nullptr; | 27 other.data_ = nullptr; |
27 other.dart_handle_ = nullptr; | 28 other.dart_handle_ = nullptr; |
28 } | 29 } |
29 | 30 |
30 Float32List::~Float32List() { | 31 Float32List::~Float32List() { |
31 if (data_) | 32 if (data_) |
32 Dart_TypedDataReleaseData(dart_handle_); | 33 Dart_TypedDataReleaseData(dart_handle_); |
33 } | 34 } |
34 | 35 |
35 Float32List DartConverter<Float32List>::FromArgumentsWithNullCheck( | 36 Float32List DartConverter<Float32List>::FromArgumentsWithNullCheck( |
36 Dart_NativeArguments args, | 37 Dart_NativeArguments args, |
37 int index, | 38 int index, |
38 Dart_Handle& exception) { | 39 Dart_Handle& exception) { |
39 Dart_Handle list = Dart_GetNativeArgument(args, index); | 40 Dart_Handle list = Dart_GetNativeArgument(args, index); |
40 DCHECK(!LogIfError(list)); | 41 DCHECK(!LogIfError(list)); |
41 | 42 |
42 Float32List result(list); | 43 Float32List result(list); |
43 return result; | 44 return result; |
44 } | 45 } |
45 | 46 |
46 } // namespace blink | 47 } // namespace blink |
OLD | NEW |