stuartmorgan 3081844cb4
Make EncodableValue a thin std::variant wrapper (#19983)
Instead of a hand-rolled discriminated union (originally used to avoid a C++17
dependency, which is no longer an issue), implement EncodableValue as a
std::variant. Rather than simply changing the internals, this makes EncodableValue
a minimal std::variant subclass with only a handful of added methodS, replacing
the old IsFoo/FooValue APIs with the standard std::holds_alternative/std::get,
so that plugin code will use a standard-based API rather than a Flutter-specific
API for wrapped values.

This is a breaking change for Windows and GLFW plugins. In the short
term USE_LEGACY_ENCODABLE_VALUE can be set in builds to use the old
version, to separate rolling from updating.

Fixes https://github.com/flutter/flutter/issues/61970
2020-08-04 08:53:07 -07:00

67 lines
1.8 KiB
Plaintext

# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//flutter/testing/testing.gni")
import("core_wrapper_files.gni")
# Client library build for internal use by the shell implementation.
source_set("client_wrapper") {
sources = core_cpp_client_wrapper_sources
public = core_cpp_client_wrapper_includes
deps = [ "//flutter/shell/platform/common/cpp:common_cpp_library_headers" ]
configs +=
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
public_configs =
[ "//flutter/shell/platform/common/cpp:relative_flutter_library_headers" ]
}
source_set("client_wrapper_library_stubs") {
sources = [
"testing/stub_flutter_api.cc",
"testing/stub_flutter_api.h",
]
defines = [ "FLUTTER_DESKTOP_LIBRARY" ]
public_deps =
[ "//flutter/shell/platform/common/cpp:common_cpp_library_headers" ]
}
test_fixtures("client_wrapper_fixtures") {
fixtures = []
}
executable("client_wrapper_unittests") {
testonly = true
sources = [
"basic_message_channel_unittests.cc",
"encodable_value_unittests.cc",
"event_channel_unittests.cc",
"method_call_unittests.cc",
"method_channel_unittests.cc",
"method_result_functions_unittests.cc",
"plugin_registrar_unittests.cc",
"standard_message_codec_unittests.cc",
"standard_method_codec_unittests.cc",
]
deps = [
":client_wrapper",
":client_wrapper_fixtures",
":client_wrapper_library_stubs",
"//flutter/testing",
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
# target that doesn't require a Dart runtime to be linked in.
# https://github.com/flutter/flutter/issues/41414.
"//third_party/dart/runtime:libdart_jit",
]
defines = [ "FLUTTER_DESKTOP_LIBRARY" ]
}