-
Notifications
You must be signed in to change notification settings - Fork 6k
Add a separate target for Dart coverter on FML types. #14011
Conversation
| DestroyShell(std::move(shell)); | ||
| } | ||
|
|
||
| static bool MemsetPatternSetOrCheck(uint8_t* buffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a short doc comment, since it's a utility. Particularly, document that if set_or_checkis true, you set, otherwise you check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Made the bool an enum.
shell/common/shell_unittests.cc
Outdated
| uint8_t* start = buffer; | ||
| uint8_t* p = buffer; | ||
|
|
||
| while ((start + size) - p >= 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Pretty obvious what this is, but maybe pattern and a constexpr size_t pattern_len = 4;?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
shell/common/shell_unittests.cc
Outdated
|
|
||
| uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size)); | ||
| ASSERT_NE(buffer, nullptr); | ||
| ASSERT_TRUE(MemsetPatternSetOrCheck(buffer, buffer_size, true /* set */)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if you should just chuck in an two-valued enum instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| fml::UniqueFD OpenFixture(std::string fixture_name); | ||
|
|
||
| std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(std::string fixture_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider documenting this (and the surrounding prototypes while you're in here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| return nullptr; | ||
| } | ||
|
|
||
| auto mapping_buffer = ::malloc(length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a zero-length list this can return null, in which case we'll handle as an OOM below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Good catch. Returns a valid zero sized mapping now.
cbracken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with minor nits.
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed all comments. PTAL.
| DestroyShell(std::move(shell)); | ||
| } | ||
|
|
||
| static bool MemsetPatternSetOrCheck(uint8_t* buffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Made the bool an enum.
shell/common/shell_unittests.cc
Outdated
| uint8_t* start = buffer; | ||
| uint8_t* p = buffer; | ||
|
|
||
| while ((start + size) - p >= 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
shell/common/shell_unittests.cc
Outdated
|
|
||
| uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size)); | ||
| ASSERT_NE(buffer, nullptr); | ||
| ASSERT_TRUE(MemsetPatternSetOrCheck(buffer, buffer_size, true /* set */)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| fml::UniqueFD OpenFixture(std::string fixture_name); | ||
|
|
||
| std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(std::string fixture_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| return nullptr; | ||
| } | ||
|
|
||
| auto mapping_buffer = ::malloc(length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Good catch. Returns a valid zero sized mapping now.
The converters are still in a separate target that must be included manually. This allows targets that depend on FML but not Dart runtime not have to depend on the runtime. Adds a test that includes this target and tests image decompression from assets. There is also a test for the standalone DartConvertor in shell_unittests but not in fml_unittests be cause FML uni-tests cannot yet launch a VM. I will work on adding fixtures for those.
af15f56 to
39b6912
Compare
This is more-or-less a revert of #14011 This code never ended up being used outside of tests, and it's not how we handle asset loading at this point anyway. I was hopeful we could kill off all runtime dependencies on Dart in `FML` when looking at this, but it looks like trace_event.h still wants to import dart_api_tools.h for some Dart enum types. This may or may not matter if we ever want to build FML for web/wasm. /cc @eyebrowsoffire. If we really need to do that, we can refactor the trace event stuff so that it has a web and Dart implementation that's selected at build time.

The converters are still in a separate target that must be included manually. This allows targets that depend on FML but not Dart runtime not have to depend on the runtime.
Adds a test that includes this target and tests image decompression from assets. There is also a test for the standalone DartConvertor in shell_unittests but not in fml_unittests be cause FML unit-tests cannot yet launch a VM. I will work on adding fixtures for those.
A potential future improvement could be that we start using typed data buffer on mapping that are given to us so that there are no copies.