mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This patch applies the following changes: * Rename a stray .cc file to .mm (connection_collection.cc). * Migrate Objective-C #includes to #import as per the style guide. * #include/#import order updated to reflect the style guide order: associated header, system/standard library headers, library headers, platform-specific includes. * Include cstring where we're using strlen. * Add a missing copyright header in SemanticsObjectTest.mm. Bugs: https://github.com/flutter/flutter/issues/60025
27 lines
902 B
Plaintext
27 lines
902 B
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/shell/platform/darwin/common/buffer_conversions.h"
|
|
|
|
namespace flutter {
|
|
|
|
std::vector<uint8_t> GetVectorFromNSData(NSData* data) {
|
|
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data.bytes);
|
|
return std::vector<uint8_t>(bytes, bytes + data.length);
|
|
}
|
|
|
|
NSData* GetNSDataFromVector(const std::vector<uint8_t>& buffer) {
|
|
return [NSData dataWithBytes:buffer.data() length:buffer.size()];
|
|
}
|
|
|
|
std::unique_ptr<fml::Mapping> GetMappingFromNSData(NSData* data) {
|
|
return std::make_unique<fml::DataMapping>(GetVectorFromNSData(data));
|
|
}
|
|
|
|
NSData* GetNSDataFromMapping(std::unique_ptr<fml::Mapping> mapping) {
|
|
return [NSData dataWithBytes:mapping->GetMapping() length:mapping->GetSize()];
|
|
}
|
|
|
|
} // namespace flutter
|