Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 254 of file dart_runtime_hooks.cc.

254 {
255 Dart_Handle result = DartCallbackCache::GetCallback(handle);
256 PropagateIfError(result);
257 return result;
258}
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 238 of file dart_runtime_hooks.cc.

238 {
239 std::string name = GetFunctionName(func);
240 std::string class_name = GetFunctionClassName(func);
241 std::string library_path = GetFunctionLibraryUrl(func);
242
243 // `name` is empty if `func` can't be used as a callback. This is the case
244 // when `func` is not a function object or is not a static function. Anonymous
245 // closures (e.g. `(int a, int b) => a + b;`) also cannot be used as
246 // callbacks, so `func` must be a tear-off of a named static function.
247 if (!Dart_IsTearOff(func) || name.empty()) {
248 return Dart_Null();
249 }
251 DartCallbackCache::GetCallbackHandle(name, class_name, library_path));
252}
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 125 of file dart_runtime_hooks.cc.

127 {
128 Dart_Handle builtin = Dart_LookupLibrary(ToDart("dart:ui"));
129 InitDartInternal(builtin, is_ui_isolate);
130 InitDartCore(builtin, script_uri);
131 InitDartAsync(builtin, is_ui_isolate, enable_microtask_profiling);
132}
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(), and flutter::InitDartInternal().

◆ Logger_PrintDebugString()

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

Definition at line 134 of file dart_runtime_hooks.cc.

134 {
135#ifndef NDEBUG
137#endif
138}
static void Logger_PrintString(const std::string &message)
const char * message

References Logger_PrintString(), and message.

◆ Logger_PrintString()

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

Definition at line 140 of file dart_runtime_hooks.cc.

140 {
141 const auto& tag = UIDartState::Current()->logger_prefix();
143
144 if (dart::bin::ShouldCaptureStdout()) {
145 std::stringstream stream;
146 if (!tag.empty()) {
147 stream << tag << ": ";
148 }
149 stream << message;
150 std::string log = stream.str();
151
152 // For now we report print output on the Stdout stream.
153 uint8_t newline[] = {'\n'};
154 Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
155 reinterpret_cast<const uint8_t*>(log.c_str()),
156 log.size());
157 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", newline, sizeof(newline));
158 }
159}
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 161 of file dart_runtime_hooks.cc.

161 {
163}
void ScheduleMicrotask(Dart_Handle handle)

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


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