Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions lib/ui/dart_runtime_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,20 @@ static void InitDartAsync(Dart_Handle builtin_library,
&schedule_microtask));
}

static void InitDartIO(const std::string& script_uri) {
static void InitDartIO(Dart_Handle builtin_library,
const std::string& script_uri) {
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
DART_CHECK_VALID(io_lib);
Dart_Handle platform_type =
Dart_GetType(io_lib, ToDart("_Platform"), 0, nullptr);
DART_CHECK_VALID(platform_type);
if (!script_uri.empty()) {
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
DART_CHECK_VALID(io_lib);
Dart_Handle platform_type =
Dart_GetType(io_lib, ToDart("_Platform"), 0, nullptr);
DART_CHECK_VALID(platform_type);
DART_CHECK_VALID(Dart_SetField(platform_type, ToDart("_nativeScript"),
ToDart(script_uri)));
}
Dart_Handle locale_closure = GetClosure(builtin_library, "_getLocaleClosure");
DART_CHECK_VALID(
Dart_SetField(platform_type, ToDart("_localeClosure"), locale_closure));
}

void DartRuntimeHooks::Install(IsolateType isolate_type,
Expand All @@ -131,7 +135,7 @@ void DartRuntimeHooks::Install(IsolateType isolate_type,
InitDartInternal(builtin, isolate_type);
InitDartCore(builtin, script_uri);
InitDartAsync(builtin, isolate_type);
InitDartIO(script_uri);
InitDartIO(builtin, script_uri);
}

// Implementation of native functions which are used for some
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ void _updateWindowMetrics(double devicePixelRatio,
_invoke(window.onMetricsChanged, window._onMetricsChangedZone);
}

typedef String LocaleClosure();

String _localeClosure() => window._locale.toString();

LocaleClosure _getLocaleClosure() => _localeClosure;

void _updateLocale(String languageCode, String countryCode) {
window._locale = new Locale(languageCode, countryCode);
_invoke(window.onLocaleChanged, window._onLocaleChangedZone);
Expand Down
2 changes: 2 additions & 0 deletions runtime/dart_vm_entry_points.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dart:_internal,::,_printClosure
dart:async,::,_setScheduleImmediateClosure
dart:io,::,_setupHooks
dart:io,_Platform,_localeClosure
dart:io,_Platform,set:_nativeScript
dart:isolate,::,_getIsolateScheduleImmediateClosure
dart:isolate,::,_setupHooks
Expand All @@ -12,6 +13,7 @@ dart:ui,::,_dispatchSemanticsAction
dart:ui,::,_drawFrame
dart:ui,::,_getGetBaseURLClosure
dart:ui,::,_baseURL
dart:ui,::,_getLocaleClosure
dart:ui,::,_getMainClosure
dart:ui,::,_getPrintClosure
dart:ui,::,_getScheduleMicrotaskClosure
Expand Down