Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DartRuntimeHooks Class Reference

#include <dart_runtime_hooks.h>

Static Public Member Functions

static void Install (bool is_ui_isolate, bool enable_microtask_profiling, const std::string &script_uri)
 
static void Logger_PrintDebugString (const std::string &message)
 
static void Logger_PrintString (const std::string &message)
 
static void ScheduleMicrotask (Dart_Handle closure)
 
static Dart_Handle GetCallbackHandle (Dart_Handle func)
 
static Dart_Handle GetCallbackFromHandle (int64_t handle)
 

Detailed Description

Definition at line 14 of file dart_runtime_hooks.h.

Member Function Documentation

◆ GetCallbackFromHandle()

Dart_Handle flutter::DartRuntimeHooks::GetCallbackFromHandle ( int64_t  handle)
static

Definition at line 289 of file dart_runtime_hooks.cc.

289 {
290 Dart_Handle result = DartCallbackCache::GetCallback(handle);
291 PropagateIfError(result);
292 return result;
293}
static Dart_Handle GetCallback(int64_t handle)
static void PropagateIfError(Dart_Handle result)

References flutter::DartCallbackCache::GetCallback(), and flutter::PropagateIfError().

◆ GetCallbackHandle()

Dart_Handle flutter::DartRuntimeHooks::GetCallbackHandle ( Dart_Handle  func)
static

Definition at line 273 of file dart_runtime_hooks.cc.

273 {
274 std::string name = GetFunctionName(func);
275 std::string class_name = GetFunctionClassName(func);
276 std::string library_path = GetFunctionLibraryUrl(func);
277
278 // `name` is empty if `func` can't be used as a callback. This is the case
279 // when `func` is not a function object or is not a static function. Anonymous
280 // closures (e.g. `(int a, int b) => a + b;`) also cannot be used as
281 // callbacks, so `func` must be a tear-off of a named static function.
282 if (!Dart_IsTearOff(func) || name.empty()) {
283 return Dart_Null();
284 }
286 DartCallbackCache::GetCallbackHandle(name, class_name, library_path));
287}
static int64_t GetCallbackHandle(const std::string &name, const std::string &class_name, const std::string &library_path)
static std::string GetFunctionClassName(Dart_Handle closure)
static std::string GetFunctionName(Dart_Handle func)
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
static std::string GetFunctionLibraryUrl(Dart_Handle closure)

References flutter::DartCallbackCache::GetCallbackHandle(), flutter::GetFunctionClassName(), flutter::GetFunctionLibraryUrl(), flutter::GetFunctionName(), and flutter::name.

◆ Install()

void flutter::DartRuntimeHooks::Install ( bool  is_ui_isolate,
bool  enable_microtask_profiling,
const std::string &  script_uri 
)
static

Definition at line 159 of file dart_runtime_hooks.cc.

161 {
162 Dart_Handle builtin = Dart_LookupLibrary(ToDart("dart:ui"));
163 InitDartInternal(builtin, is_ui_isolate);
164 InitDartCore(builtin, script_uri);
165 InitDartAsync(builtin, is_ui_isolate, enable_microtask_profiling);
166 InitDartIO(builtin, script_uri);
167}
static void InitDartIO(Dart_Handle builtin_library, const std::string &script_uri)
static void InitDartInternal(Dart_Handle builtin_library, bool is_ui_isolate)
static void InitDartAsync(Dart_Handle builtin_library, bool is_ui_isolate, bool enable_microtask_profiling)
static void InitDartCore(Dart_Handle builtin, const std::string &script_uri)
Dart_Handle ToDart(const T &object)

References flutter::InitDartAsync(), flutter::InitDartCore(), flutter::InitDartInternal(), and flutter::InitDartIO().

◆ Logger_PrintDebugString()

void flutter::DartRuntimeHooks::Logger_PrintDebugString ( const std::string &  message)
static

Definition at line 169 of file dart_runtime_hooks.cc.

169 {
170#ifndef NDEBUG
172#endif
173}
static void Logger_PrintString(const std::string &message)
G_BEGIN_DECLS GBytes * message

References Logger_PrintString(), and message.

◆ Logger_PrintString()

void flutter::DartRuntimeHooks::Logger_PrintString ( const std::string &  message)
static

Definition at line 175 of file dart_runtime_hooks.cc.

175 {
176 const auto& tag = UIDartState::Current()->logger_prefix();
178
179 if (dart::bin::ShouldCaptureStdout()) {
180 std::stringstream stream;
181 if (!tag.empty()) {
182 stream << tag << ": ";
183 }
184 stream << message;
185 std::string log = stream.str();
186
187 // For now we report print output on the Stdout stream.
188 uint8_t newline[] = {'\n'};
189 Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
190 reinterpret_cast<const uint8_t*>(log.c_str()),
191 log.size());
192 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", newline, sizeof(newline));
193 }
194}
const std::string & logger_prefix() const
void LogMessage(const std::string &tag, const std::string &message) const
static UIDartState * Current()

References flutter::UIDartState::Current(), flutter::UIDartState::logger_prefix(), flutter::UIDartState::LogMessage(), and message.

Referenced by Logger_PrintDebugString().

◆ ScheduleMicrotask()

void flutter::DartRuntimeHooks::ScheduleMicrotask ( Dart_Handle  closure)
static

Definition at line 196 of file dart_runtime_hooks.cc.

196 {
198}
void ScheduleMicrotask(Dart_Handle handle)

References flutter::UIDartState::Current(), and flutter::UIDartState::ScheduleMicrotask().


The documentation for this class was generated from the following files: