Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
15b20ee5
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
15b20ee5
编写于
3月 25, 2021
作者:
Z
Zachary Anderson
提交者:
GitHub
3月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Call Dart plugin registrant if available (#23813)" (#25221)
上级
cba595c1
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
6 addition
and
88 deletion
+6
-88
lib/ui/hooks.dart
lib/ui/hooks.dart
+0
-4
runtime/dart_isolate.cc
runtime/dart_isolate.cc
+4
-28
runtime/dart_isolate_unittests.cc
runtime/dart_isolate_unittests.cc
+0
-34
runtime/fixtures/runtime_test.dart
runtime/fixtures/runtime_test.dart
+2
-22
未找到文件。
lib/ui/hooks.dart
浏览文件 @
15b20ee5
...
@@ -132,14 +132,10 @@ typedef _ListStringArgFunction(List<String> args);
...
@@ -132,14 +132,10 @@ typedef _ListStringArgFunction(List<String> args);
@pragma
(
'vm:entry-point'
)
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
// ignore: unused_element
void
_runMainZoned
(
Function
startMainIsolateFunction
,
void
_runMainZoned
(
Function
startMainIsolateFunction
,
Function
?
dartPluginRegistrant
,
Function
userMainFunction
,
Function
userMainFunction
,
List
<
String
>
args
)
{
List
<
String
>
args
)
{
startMainIsolateFunction
(()
{
startMainIsolateFunction
(()
{
runZonedGuarded
<
void
>(()
{
runZonedGuarded
<
void
>(()
{
if
(
dartPluginRegistrant
!=
null
)
{
dartPluginRegistrant
();
}
if
(
userMainFunction
is
_ListStringArgFunction
)
{
if
(
userMainFunction
is
_ListStringArgFunction
)
{
(
userMainFunction
as
dynamic
)(
args
);
(
userMainFunction
as
dynamic
)(
args
);
}
else
{
}
else
{
...
...
runtime/dart_isolate.cc
浏览文件 @
15b20ee5
...
@@ -695,7 +695,6 @@ bool DartIsolate::MarkIsolateRunnable() {
...
@@ -695,7 +695,6 @@ bool DartIsolate::MarkIsolateRunnable() {
[[
nodiscard
]]
static
bool
InvokeMainEntrypoint
(
[[
nodiscard
]]
static
bool
InvokeMainEntrypoint
(
Dart_Handle
user_entrypoint_function
,
Dart_Handle
user_entrypoint_function
,
Dart_Handle
plugin_registrant_function
,
Dart_Handle
args
)
{
Dart_Handle
args
)
{
if
(
tonic
::
LogIfError
(
user_entrypoint_function
))
{
if
(
tonic
::
LogIfError
(
user_entrypoint_function
))
{
FML_LOG
(
ERROR
)
<<
"Could not resolve main entrypoint function."
;
FML_LOG
(
ERROR
)
<<
"Could not resolve main entrypoint function."
;
...
@@ -713,8 +712,7 @@ bool DartIsolate::MarkIsolateRunnable() {
...
@@ -713,8 +712,7 @@ bool DartIsolate::MarkIsolateRunnable() {
if
(
tonic
::
LogIfError
(
tonic
::
DartInvokeField
(
if
(
tonic
::
LogIfError
(
tonic
::
DartInvokeField
(
Dart_LookupLibrary
(
tonic
::
ToDart
(
"dart:ui"
)),
"_runMainZoned"
,
Dart_LookupLibrary
(
tonic
::
ToDart
(
"dart:ui"
)),
"_runMainZoned"
,
{
start_main_isolate_function
,
plugin_registrant_function
,
{
start_main_isolate_function
,
user_entrypoint_function
,
args
})))
{
user_entrypoint_function
,
args
})))
{
FML_LOG
(
ERROR
)
<<
"Could not invoke the main entrypoint."
;
FML_LOG
(
ERROR
)
<<
"Could not invoke the main entrypoint."
;
return
false
;
return
false
;
}
}
...
@@ -739,34 +737,12 @@ bool DartIsolate::RunFromLibrary(std::optional<std::string> library_name,
...
@@ -739,34 +737,12 @@ bool DartIsolate::RunFromLibrary(std::optional<std::string> library_name,
auto
entrypoint_handle
=
entrypoint
.
has_value
()
&&
!
entrypoint
.
value
().
empty
()
auto
entrypoint_handle
=
entrypoint
.
has_value
()
&&
!
entrypoint
.
value
().
empty
()
?
tonic
::
ToDart
(
entrypoint
.
value
().
c_str
())
?
tonic
::
ToDart
(
entrypoint
.
value
().
c_str
())
:
tonic
::
ToDart
(
"main"
);
:
tonic
::
ToDart
(
"main"
);
auto
entrypoint_args
=
tonic
::
ToDart
(
args
);
auto
user_entrypoint_function
=
auto
user_entrypoint_function
=
::
Dart_GetField
(
library_handle
,
entrypoint_handle
);
::
Dart_GetField
(
library_handle
,
entrypoint_handle
);
// The Dart plugin registrant is a function named `_registerPlugins`
auto
entrypoint_args
=
tonic
::
ToDart
(
args
);
// generated by the Flutter tool.
//
if
(
!
InvokeMainEntrypoint
(
user_entrypoint_function
,
entrypoint_args
))
{
// This function binds a plugin implementation to their platform
// interface based on the configuration of the app's pubpec.yaml, and the
// plugin's pubspec.yaml.
//
// Since this function may or may not be defined. Check that it is a top
// level function, and call it in hooks.dart before the main entrypoint
// function.
//
// If it's not defined, then just call the main entrypoint function
// as usual.
//
// This allows embeddings to change the name of the entrypoint function.
auto
plugin_registrant_function
=
::
Dart_GetField
(
library_handle
,
tonic
::
ToDart
(
"_registerPlugins"
));
if
(
Dart_IsError
(
plugin_registrant_function
))
{
plugin_registrant_function
=
Dart_Null
();
}
if
(
!
InvokeMainEntrypoint
(
user_entrypoint_function
,
plugin_registrant_function
,
entrypoint_args
))
{
return
false
;
return
false
;
}
}
...
...
runtime/dart_isolate_unittests.cc
浏览文件 @
15b20ee5
...
@@ -613,39 +613,5 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
...
@@ -613,39 +613,5 @@ TEST_F(DartIsolateTest, DISABLED_ValidLoadingUnitSucceeds) {
Wait
();
Wait
();
}
}
TEST_F
(
DartIsolateTest
,
DartPluginRegistrantIsCalled
)
{
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
std
::
vector
<
std
::
string
>
messages
;
fml
::
AutoResetWaitableEvent
latch
;
AddNativeCallback
(
"PassMessage"
,
CREATE_NATIVE_ENTRY
(([
&
latch
,
&
messages
](
Dart_NativeArguments
args
)
{
auto
message
=
tonic
::
DartConverter
<
std
::
string
>::
FromDart
(
Dart_GetNativeArgument
(
args
,
0
));
messages
.
push_back
(
message
);
latch
.
Signal
();
})));
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
thread
=
CreateNewThread
();
TaskRunners
task_runners
(
GetCurrentTestName
(),
//
thread
,
//
thread
,
//
thread
,
//
thread
//
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
task_runners
,
"mainForPluginRegistrantTest"
,
{},
GetFixturesPath
());
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
latch
.
Wait
();
ASSERT_EQ
(
messages
.
size
(),
1u
);
ASSERT_EQ
(
messages
[
0
],
"_registerPlugins was called"
);
}
}
// namespace testing
}
// namespace testing
}
// namespace flutter
}
// namespace flutter
runtime/fixtures/runtime_test.dart
浏览文件 @
15b20ee5
...
@@ -10,7 +10,8 @@ import 'dart:ui';
...
@@ -10,7 +10,8 @@ import 'dart:ui';
import
'split_lib_test.dart'
deferred
as
splitlib
;
import
'split_lib_test.dart'
deferred
as
splitlib
;
void
main
(
)
{}
void
main
(
)
{
}
@pragma
(
'vm:entry-point'
)
@pragma
(
'vm:entry-point'
)
void
sayHi
(
)
{
void
sayHi
(
)
{
...
@@ -114,24 +115,3 @@ void testCanConvertListOfInts(List<int> args){
...
@@ -114,24 +115,3 @@ void testCanConvertListOfInts(List<int> args){
args
[
2
]
==
3
&&
args
[
2
]
==
3
&&
args
[
3
]
==
4
);
args
[
3
]
==
4
);
}
}
bool
didCallRegistrantBeforeEntrypoint
=
false
;
// Test the Dart plugin registrant.
// _registerPlugins requires the entrypoint annotation, so the compiler doesn't tree shake it.
@pragma
(
'vm:entry-point'
)
void
_registerPlugins
(
)
{
// ignore: unused_element
if
(
didCallRegistrantBeforeEntrypoint
)
{
throw
'_registerPlugins is being called twice'
;
}
didCallRegistrantBeforeEntrypoint
=
true
;
}
@pragma
(
'vm:entry-point'
)
void
mainForPluginRegistrantTest
(
)
{
// ignore: unused_element
if
(
didCallRegistrantBeforeEntrypoint
)
{
passMessage
(
'_registerPlugins was called'
);
}
else
{
passMessage
(
'_registerPlugins was not called'
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录