Flutter Engine
dart_invoke.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 
6 
7 #include "tonic/common/macros.h"
9 
10 namespace tonic {
11 
12 Dart_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 
20 Dart_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 
29 Dart_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
G_BEGIN_DECLS FlValue * args
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:20
Dart_Handle DartInvokeField(Dart_Handle target, const char *name, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:12
std::function< void()> closure
Definition: closure.h:14
const char * name
Definition: fuchsia.cc:50
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15
Dart_Handle DartInvokeVoid(Dart_Handle closure)
Definition: dart_invoke.cc:29