Flutter Engine
The Flutter Engine
dart_list.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "tonic/dart_list.h"
6
8
9namespace tonic {
10
11DartList::DartList(Dart_Handle dart_handle) : dart_handle_(dart_handle) {
12 TONIC_DCHECK(Dart_IsList(dart_handle_));
13
14 intptr_t length;
15 is_valid_ = !CheckAndHandleError(Dart_ListLength(dart_handle_, &length));
16 size_ = length;
17}
18
19DartList::DartList() {
20 dart_handle_ = Dart_Null();
21 size_ = 0;
22 is_valid_ = false;
23}
24
25DartList::DartList(DartList&& other)
26 : dart_handle_(other.dart_handle_),
27 size_(other.size_),
28 is_valid_(other.is_valid_) {
29 other.dart_handle_ = nullptr;
30 other.size_ = 0;
31 other.is_valid_ = false;
32}
33
34void DartList::Set(size_t index, Dart_Handle value) {
35 CheckAndHandleError(Dart_ListSetAt(dart_handle_, index, value));
36}
37
39 int index,
40 Dart_Handle& exception) {
42 if (CheckAndHandleError(list) || !Dart_IsList(list)) {
43 exception = Dart_NewApiError("Invalid Argument");
44 return DartList();
45 }
46
47 return DartList(list);
48}
49
50} // namespace tonic
void Set(size_t index, Dart_Handle value)
Definition: dart_list.cc:34
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t *length)
DART_EXPORT bool Dart_IsList(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint8_t value
size_t length
bool CheckAndHandleError(Dart_Handle handle)
Definition: dart_error.cc:33
#define TONIC_DCHECK
Definition: macros.h:32