13template <Dart_TypedData_Type kTypeName,
typename ElemType>
15 : data_(nullptr), num_elements_(0), dart_handle_(nullptr) {}
17template <Dart_TypedData_Type kTypeName,
typename ElemType>
19 : data_(nullptr), num_elements_(0), dart_handle_(list) {
20 if (Dart_IsNull(list))
23 Dart_TypedData_Type
type;
24 Dart_TypedDataAcquireData(list, &
type,
reinterpret_cast<void**
>(&data_),
27 if (
type != kTypeName)
28 Dart_ThrowException(
ToDart(
"Non-genuine TypedData passed to engine."));
31template <Dart_TypedData_Type kTypeName,
typename ElemType>
35 num_elements_(other.num_elements_),
36 dart_handle_(other.dart_handle_) {
37 other.data_ =
nullptr;
38 other.num_elements_ = 0;
39 other.dart_handle_ =
nullptr;
42template <Dart_TypedData_Type kTypeName,
typename ElemType>
47template <Dart_TypedData_Type kTypeName,
typename ElemType>
50 Dart_TypedDataReleaseData(dart_handle_);
53 dart_handle_ =
nullptr;
57template <Dart_TypedData_Type kTypeName,
typename ElemType>
60 Dart_NativeArguments
args,
62 Dart_Handle& exception) {
63 Dart_Handle list = Dart_GetNativeArgument(
args, index);
68template <Dart_TypedData_Type kTypeName,
typename ElemType>
70 Dart_NativeArguments
args,
74 Dart_SetReturnValue(
args, result);
77template <Dart_TypedData_Type kTypeName,
typename ElemType>
79 const ElemType* buffer,
81 const intptr_t buffer_length =
static_cast<intptr_t
>(
length);
82 Dart_Handle array = Dart_NewTypedData(kTypeName, buffer_length);
85 Dart_TypedData_Type
type;
87 intptr_t data_length = 0;
88 Dart_TypedDataAcquireData(array, &
type, &data, &data_length);
92 std::memmove(data, buffer, data_length *
sizeof(ElemType));
93 Dart_TypedDataReleaseData(array);
98#define TONIC_TYPED_DATA_DEFINE(name, type) \
99 template class TypedList<Dart_TypedData_k##name, type>; \
100 template struct DartConverter<name##List>;
104#undef TONIC_TYPED_DATA_DEFINE
Dart_Handle dart_handle() const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
impeller::ShaderType type
#define TONIC_CHECK(condition)
#define TONIC_TYPED_DATA_DEFINE(name, type)
#define TONIC_TYPED_DATA_FOREACH(F)