Chromium Code Reviews| Index: sky/engine/tonic/dart_float32list.h |
| diff --git a/sky/engine/tonic/dart_float32list.h b/sky/engine/tonic/dart_float32list.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..51097beb2f331db568a98976289f96f1d6da3036 |
| --- /dev/null |
| +++ b/sky/engine/tonic/dart_float32list.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SKY_ENGINE_TONIC_DART_FLOAT32LIST_H_ |
| +#define SKY_ENGINE_TONIC_DART_FLOAT32LIST_H_ |
| + |
| +#include "dart/runtime/include/dart_api.h" |
| +#include "sky/engine/tonic/dart_converter.h" |
| + |
| +namespace blink { |
| + |
| +// A simple wrapper around a Dart Float32List. It uses Dart_TypedDataAcquireData |
| +// to obtain a raw pointer to the data, which is released when this object is |
| +// destroyed. |
| +// |
| +// This is designed to be used with DartConverter only. |
| +class Float32List { |
| + public: |
| + Float32List(Dart_Handle list); |
|
abarth-chromium
2015/06/04 17:29:28
explicit
Matt Perry
2015/06/04 17:34:36
Done.
|
| + Float32List(Float32List&& other); |
| + ~Float32List(); |
| + |
| + const float* data() const { return data_; } |
| + size_t num_elements() const { return num_elements_; } |
|
abarth-chromium
2015/06/04 17:29:28
Why the change from intptr_t to size_t? We should
Matt Perry
2015/06/04 17:34:35
Done.
|
| + |
| + private: |
| + float* data_; |
| + intptr_t num_elements_; |
| + Dart_Handle dart_handle_; |
| + |
| + Float32List(const Float32List& other) = delete; |
| +}; |
| + |
| +template <> |
| +struct DartConverter<Float32List> { |
| + static Float32List FromArgumentsWithNullCheck(Dart_NativeArguments args, |
| + int index, |
| + Dart_Handle& exception); |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // SKY_ENGINE_TONIC_DART_FLOAT32LIST_H_ |