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/logging/dart_invoke.h"
6
7#include "tonic/common/macros.h"
8#include "tonic/logging/dart_error.h"
9
10namespace tonic {
11
12Dart_Handle DartInvokeField(Dart_Handle target,
13 const char* name,
14 std::initializer_list<Dart_Handle> args) {
15 Dart_Handle field = Dart_NewStringFromCString(name);
16 return Dart_Invoke(target, field, args.size(),
17 const_cast<Dart_Handle*>(args.begin()));
18}
19
20Dart_Handle DartInvoke(Dart_Handle closure,
21 std::initializer_list<Dart_Handle> args) {
22 int argc = args.size();
23 Dart_Handle* argv = const_cast<Dart_Handle*>(args.begin());
24 Dart_Handle handle = Dart_InvokeClosure(closure, argc, argv);
25 LogIfError(handle);
26 return handle;
27}
28
29Dart_Handle DartInvokeVoid(Dart_Handle closure) {
30 Dart_Handle handle = Dart_InvokeClosure(closure, 0, nullptr);
31 LogIfError(handle);
32 return handle;
33}
34
35} // namespace tonic
36