34 Commits

Author SHA1 Message Date
stuartmorgan
9db5c3fb62 Fix C++ MethodChannel reply type (flutter/engine#17607)
Makes InvokeMethod's reply a high-level response object, rather than
binary data, matching the abstraction level of the class (and the other
languages' implementations).

In support of that:
- Adds the logic to the codecs to decode response envelopes, which had
  never been implemented.
- Adds a convience implementation of MethodResult that forwards to
  lambdas, so that one-off invocation handlers are easier to write.

Also simplified BinaryMessenger's API so that subclasses only need to
implement one version of Send, rather than two almost-identical versions.

Fixes https://github.com/flutter/flutter/issues/53223
2020-04-11 19:06:37 -07:00
Francisco Magdaleno
c38e7106c0 [windows] Sends complete key data to framework (flutter/engine#17577) 2020-04-09 20:55:02 -07:00
stuartmorgan
b64faf3a69 Reland "Improve C++ plugin lifetime handling" (flutter/engine#17570)
Relands #17489 with a fix for the unit test flake.

The previous unit test relied on the new instance not being created at the same memory address, which isn't guaranteed.
2020-04-07 14:11:56 -07:00
Chris Bracken
4f108b7be1 Revert "Improve C++ plugin lifetime handling (#17489)" (flutter/engine#17563)
Seems to have triggered flaky failures on the Windows bot since landing.
Example failure:

    [ RUN      ] PluginRegistrarTest.ManagerRemovesOnDestruction
    c:\b\s\w\ir\cache\builder\src\flutter\shell\platform\common\cpp\client_wrapper\plugin_registrar_unittests.cc(149): error: Expected: (manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle)) != (first_wrapper), actual: 000002400A90E3D0 vs 000002400A90E3D0

This reverts commit 478a7855943d81a58dd9e9037fb338d3a18bb294.
2020-04-07 10:22:55 -07:00
stuartmorgan
478a785594 Improve C++ plugin lifetime handling (flutter/engine#17489)
This makes two changes:
- Adds a way to register a callback for when a FlutterDesktopPluginRegistrarRef is destroyed, and implements the logic to call it in the Windows and Linux embeddings.
- Adds a class to the C++ wrapper that handles making a singleton owning PluginRegistrar wrappers, and destroying them when the underlying reference goes away, to avoid needing that boilerplate code in every plugin's source.

Fixes https://github.com/flutter/flutter/issues/53496
2020-04-06 09:55:42 -07:00
stuartmorgan
7b222c8310 Remove JSON codec from C++ client wrapper (flutter/engine#17312)
The JSON codec is awkward to use in the wrapper (since the client has to build and link one of the JSON libraries to do so). Since it would be very cumbersome to wrap in a C API, and there's essentially no reason to use it instead of the standard codec, this removes it from the wrapper entirely.

Since some system channels (internal to the engine) still use it, it's moved into common/cpp instead of being eliminated entirely. Internally we always use RapidJSON though, so the jsoncpp implementation is removed. Also adds some unit test coverage, since there wasn't any.

Fixes #30669
2020-04-02 14:57:46 -07:00
stuartmorgan
8c89674d93 Allow relative resource paths in GLFW embedding (flutter/engine#16944)
Currently every Linux runner has this code to allow relative resource paths; this moves it into the framework so that any embedder can get this behavior without that code needing to be in the template.

Rolls buildroot to pick up std::filesystem support in our libc++
2020-03-17 19:04:18 -07:00
stuartmorgan
b86b2a9bee Fix handler unregistration in C++ channels (flutter/engine#16794)
MethodChannel and BasicMessageChannel in the C++ wrapper didn't have the
expected semantics that passing a null handler would remove any existing
handler. This was inconsistent with other platforms and with the
lower-level object APIs in this wrapper, and made unregistration in
cases where that's desirable more difficult due to needing to keep other
object references.

Adds tests for this functionality, and some backfill of missing tests
for basic handler behavior.

See https://github.com/flutter/flutter/issues/51207
2020-02-25 14:09:58 -08:00
stuartmorgan
f9ebc8e2dc Add noexcept annotations to EnableValue moves (flutter/engine#16478)
Fixes a warning when compiling in Visual Studio on Windows.
2020-02-06 14:28:31 -08:00
stuartmorgan
69e4ea885f Suppress some deprecation warnings on Windows (flutter/engine#16416)
Targeted suppression of some deprecation warnings that are build errors under
clang:
- Ignore the deprecation of codecvt's unicode conversion until we decide on
  a replacement strategy.
- Allow the deprecated posix names of functions in third_party/txt.

Part of https://github.com/flutter/flutter/issues/16256
2020-02-05 21:10:25 -08:00
Chinmay Garde
426c48aaac Remove all uses of the redundant flutter_root variable. (flutter/engine#16311)
This was only necessary when the Engine had to build in multiple buildroots
where the sources where checked out at different paths relative to the
buildroot. This is no longer the case and there are already cases GN rules
have been written that mix and match variable usage with the direct
specification of the path to the Flutter sources relative to the sole buildroot.
2020-01-31 21:49:48 -08:00
gaaclarke
43dce83fc1 Refactor to passing functions by const ref (flutter/engine#13975)
Moved our code to passing functions by const ref
2019-11-22 12:20:02 -08:00
Andy Weiss
9b9dd7d20d Support empty strings and vectors in standard codec (flutter/engine#12974)
* Support empty strings and vectors in standard codec

Fixes #41993

Currently an empty string or vector will call through to WriteBytes
which asserts that the number of bytes it is being asked to write is
strictly positive. Instead we should not call WriteBytes if the length
is zero.

Similarly, when we read, we don't need to call out if the length is
zero.

* fix typo in test name

* remove unnecessary length check in ReadValue for List

* we also don't need this check before calling read as memcpy can handle size 0
2019-10-15 08:35:50 -07:00
chunhtai
79ad29854f add windows embedding test (flutter/engine#12423) 2019-10-03 12:42:44 -07:00
stuartmorgan
c66d5e6d17 Adds PluginRegistry to the C++ client wrapper API (flutter/engine#12287)
Makes the plugin registration structure consistent with macOS. This will
be used in generated plugin registrant files rather than a specific
implemenation class, so this helps unblock the creation of generated
registrants on Windows and Linux.
2019-09-17 11:41:22 -07:00
shoryukenn
58c3192c32 Improve Unicode handling on Windows (flutter/engine#11899)
Significantly improves the behavior of non-ASCII text input on Windows. Correctly
processes incoming character events as UTF-16, and for now uses UTF-32 for
the text model so that the existing index-based logic will work much more often.

Future work is still needed, but this will handle far more cases correctly.
2019-09-08 12:13:59 -07:00
Francisco Magdaleno
d00cb9e09e Finish plumbing message responses on method channels (flutter/engine#11877) 2019-09-04 16:17:10 -07:00
Chris Bracken
116b9729ec Ensure trailing newline before EOF in C++ sources (flutter/engine#11489)
In generated text fixture location lookup code:
When the second argument to write_file() is a list, it is written one
item per line to the path specified by the first argument. This ensures
that we emit a trailing newline at EOF to comply with -Wnewline-eof.

Elsewhere:
Lack of a newline at EOF was undefined behaviour prior to C++11. The
Fuchsia tree sets -Wnewline-eof in its buildroot, so we plan to do the
same. This cleans up remaining first-party C++ sources that don't
include a trailing newline.
2019-08-27 00:13:00 -07:00
James Clarke
7dccb1596a [Windows] Alternative Windows shell platform implementation (flutter/engine#9835)
Start work on flutter/flutter#30726 by adding an alternative win32 shell platform implementation for Windows that is not based on GLFW and that uses LIBANGLE for rendering and native win32 windowing and input. This change does not replace the GLFW implementation but rather runs side by side with it producing a secondary flutter_windows_win32.dll artifact. The following items must be added to attain parity with the GLFW implementation:
- Custom task scheduling
- Support for keyboard modifier keys
- Async texture uploads
- Correct high DPI handling on Windows versions < 1703
and will be added in subsequent changes.
2019-08-14 15:52:52 -07:00
Francisco Magdaleno
a05057aede [glfw] Enables replies on binary messenger in glfw embedder (flutter/engine#9948) 2019-07-31 14:27:46 -07:00
stuartmorgan
1299da0e74 Add a macro for prefixing embedder.h symbols (flutter/engine#9851)
embedder.h is a C API, so has no namespace, and only uses 'Flutter' as a
prefix for most symbol names. This creates potential collisions with
other code; for instance, FlutterEngine is the name of a type in
embedder.h, but also an ObjC class in the iOS Flutter API.

This adds a macro that can be set to prefix symbol names, allowing
clients (notably, the macOS embedding) to adjust the names used by the
embedding API internally without breaking ABI or API compatibility for
the standard engine build.

Currently the macro is only applied to FlutterEngine, since that's the
symbol that is currently at issue, but it can be expanded to other
symbols in the future.
2019-07-23 05:48:48 -07:00
stuartmorgan
03ec25fb58 Fix type mismatches in C++ standard codec (flutter/engine#9112)
There were some implicit casts in the standard codec implementation that
didn't show up on Linux, but do on Windows.
2019-05-30 10:17:08 -07:00
Chinmay Garde
cb00aac583 Allow specifying both Dart and non-Dart fixtures in engine unit-tests. (flutter/engine#9113)
* Allow specifying both Dart and non-Dart fixtures in engine unittests.

This fixes numerous issues in the way in which fixtures were managed
in the engine unit-tests.

* Instead of only being able to specify Dart fixtures, unit-tests may specify
  non-Dart fixtures as well. These are simply copied over to the fixtures
  directory known to the unit-test at runtime.
* An issue where numerous Dart files could be given to the kernel snapshotter
  has been addressed. It was anticipated that such a (legal) invocation to the
  kernel snapshotter would produce a snapshot with the contents of all the Dart
  files added to the root library. This is incorrect and the behavior in this
  case is undefined.
* Dart files referenced by the main Dart file are correctly tracked via a
  depfile.
* The snapshotter arguments have been cleaned up to get rid of unused
  arguments (`—strong`) and  the use of the VM product mode argument has been
  corrected to no longer depend on the Flutter product mode.
2019-05-28 19:11:47 -07:00
Chris Bracken
21fd6fb32a Correct typos, adopt US spellings (flutter/engine#9081)
Corects a bnuch of typeos throughout teh engien codebsae. Also makes
a couple minor Commonwealth -> US spelling adjustments for consistency
with the rest of Flutter's codebase.

Made use of `misspell` tool:
https://github.com/client9/misspell
2019-05-25 13:14:46 -07:00
stuartmorgan
f0ab13a0bb Minor fixes/adjustments to the GLFW shell (flutter/engine#8990)
- Makes json_method_codec.cc compatible with the last stable RapidJSON release.
- Allows removing the GTK dependency with a compile flag.
- Fixes a missing break in a switch flagged by some toolchains.
2019-05-20 14:36:59 -04:00
stuartmorgan
71903838b8 Provide access to GLFW window in plugins (flutter/engine#8806)
Plugins may need to be able to access functions affecting the GLFW
window (e.g., a plugin to resize the window). This restructures the API
to create a distinction at both the C and C++ level between the window
controller, which provides access to high-level behaviors driving the
Flutter application, and the window, which provides access to functions
to affect the UI state of the window (i.e., wrapped GLFWwindow
functions).

Also provides a PluginRegistrar extension for plugins that need access
to GLFW-specific functionality.
2019-05-06 15:37:02 -04:00
Shi-Hao Hong
1ead577b35 Fix typo in comment (flutter/engine#8617) 2019-04-17 15:03:50 -07:00
stuartmorgan
e722bba483 Add desktop shell unittests to test script (flutter/engine#8600)
Builds the unit test on all platforms, and adds them to the aggregate test script.
2019-04-16 22:37:39 -07:00
stuartmorgan
922d6df36f Implement StandardMethodCodec for C++ shells (flutter/engine#8598)
Adds StandardMethodCodec support to the C++ client wrapper. This makes it
substantially easier to add Windows and Linux support for existing plugins, as
StandardMethodCodec is the default plugin protocol.

Fixes flutter/flutter#30670

Does not include extensibility for the codec, which will be added later.
2019-04-16 19:49:09 -07:00
stuartmorgan
9b2819a3bb Variant type for C++ client wrapper (flutter/engine#8592)
Adds a type that can hold any of the types corresponding to the Dart types
that are supported by the standard message channel codec. This provides
the foundation for adding standard message codec support for the C++
desktop shells (flutter/flutter#30670).
2019-04-16 16:33:07 -07:00
Diego Ballesteros Villamizar
9d9892d005 Add missing <memory> include to text_input_model.h (flutter/engine#8562)
text_input_model.h uses std::unique_ptr but does not include the memory header.
2019-04-12 10:48:11 -07:00
Chinmay Garde
4dd267959f Rename the shell namespace to flutter. (flutter/engine#8520) 2019-04-09 17:10:46 -07:00
stuartmorgan
ecb9da1446 Build Windows shell (flutter/engine#8331)
Enables the build of the Windows shell, based on the same GLFW code used
by the current Linux shell.
2019-03-27 23:38:44 -04:00
stuartmorgan
c3a14b5501 Initial import of GLFW Linux shell from FDE (flutter/engine#8159)
Changes include:
- File structure
- Header guards
- Include paths
- Namespaces
- Integration with the engine's GN build
- Conversion from jsoncpp to rapidjson
- Style and clang-format adjustment to match engine repository
2019-03-20 17:15:52 -04:00