Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 415b576

Browse files
committed
Use .mm extension for FlutterStandardCodecHelper.c
Even though the file is pure C code, it's useful to use a C++ filename in order to use FML (assertions) in the implementation. No semantic changes so no test changes.
1 parent 42689ea commit 415b576

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCh
24172417
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m + ../../../flutter/LICENSE
24182418
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm + ../../../flutter/LICENSE
24192419
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm + ../../../flutter/LICENSE
2420-
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.c + ../../../flutter/LICENSE
2420+
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc + ../../../flutter/LICENSE
24212421
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h + ../../../flutter/LICENSE
24222422
ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h + ../../../flutter/LICENSE
24232423
ORIGIN: ../../../flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h + ../../../flutter/LICENSE
@@ -4874,7 +4874,7 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChan
48744874
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m
48754875
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm
48764876
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm
4877-
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.c
4877+
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc
48784878
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h
48794879
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h
48804880
FILE: ../../../flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h

shell/platform/darwin/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ source_set("flutter_channels_arc") {
4747
"common/framework/Source/FlutterChannels.mm",
4848
"common/framework/Source/FlutterCodecs.mm",
4949
"common/framework/Source/FlutterStandardCodec.mm",
50-
"common/framework/Source/FlutterStandardCodecHelper.c",
50+
"common/framework/Source/FlutterStandardCodecHelper.cc",
5151
"common/framework/Source/FlutterStandardCodec_Internal.h",
5252
]
5353

shell/platform/darwin/common/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ source_set("framework_shared") {
3737
"framework/Source/FlutterChannels.mm",
3838
"framework/Source/FlutterCodecs.mm",
3939
"framework/Source/FlutterStandardCodec.mm",
40-
"framework/Source/FlutterStandardCodecHelper.c",
40+
"framework/Source/FlutterStandardCodecHelper.cc",
4141
"framework/Source/FlutterStandardCodec_Internal.h",
4242
]
4343

shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.c renamed to shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h"
66
#include <stdint.h>
77

8+
#include <vector>
9+
810
void FlutterStandardCodecHelperReadAlignment(unsigned long* location,
911
uint8_t alignment) {
1012
uint8_t mod = *location % alignment;
@@ -25,7 +27,7 @@ void FlutterStandardCodecHelperReadBytes(unsigned long* location,
2527
void* destination,
2628
CFDataRef data) {
2729
CFRange range = CFRangeMake(*location, length);
28-
CFDataGetBytes(data, range, destination);
30+
CFDataGetBytes(data, range, static_cast<UInt8*>(destination));
2931
*location += length;
3032
}
3133

@@ -59,7 +61,7 @@ static CFDataRef ReadDataNoCopy(unsigned long* location,
5961
kCFAllocatorDefault, CFDataGetBytePtr(data) + *location, length,
6062
kCFAllocatorNull);
6163
*location += length;
62-
return CFAutorelease(result);
64+
return static_cast<CFDataRef>(CFAutorelease(result));
6365
}
6466

6567
CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long* location,
@@ -68,7 +70,7 @@ CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long* location,
6870
CFDataRef bytes = ReadDataNoCopy(location, size, data);
6971
CFStringRef result = CFStringCreateFromExternalRepresentation(
7072
kCFAllocatorDefault, bytes, kCFStringEncodingUTF8);
71-
return CFAutorelease(result);
73+
return static_cast<CFStringRef>(CFAutorelease(result));
7274
}
7375

7476
// Peeks ahead to see if we are reading a standard type. If so, recurse
@@ -172,7 +174,7 @@ void FlutterStandardCodecHelperWriteByte(CFMutableDataRef data, uint8_t value) {
172174
void FlutterStandardCodecHelperWriteBytes(CFMutableDataRef data,
173175
const void* bytes,
174176
unsigned long length) {
175-
CFDataAppendBytes(data, bytes, length);
177+
CFDataAppendBytes(data, static_cast<const UInt8*>(bytes), length);
176178
}
177179

178180
void FlutterStandardCodecHelperWriteSize(CFMutableDataRef data, uint32_t size) {
@@ -210,12 +212,12 @@ void FlutterStandardCodecHelperWriteUTF8(CFMutableDataRef data,
210212
CFIndex used_length = 0;
211213
// UTF16 length times 3 will fit all UTF8.
212214
CFIndex buffer_length = length * 3;
213-
UInt8* buffer = (UInt8*)malloc(buffer_length * sizeof(UInt8));
215+
std::vector<UInt8> buffer;
216+
buffer.reserve(buffer_length);
214217
CFStringGetBytes(value, CFRangeMake(0, length), kCFStringEncodingUTF8, 0,
215-
false, buffer, buffer_length, &used_length);
218+
false, buffer.data(), buffer_length, &used_length);
216219
FlutterStandardCodecHelperWriteSize(data, used_length);
217-
FlutterStandardCodecHelperWriteBytes(data, buffer, used_length);
218-
free(buffer);
220+
FlutterStandardCodecHelperWriteBytes(data, buffer.data(), used_length);
219221
}
220222
}
221223

0 commit comments

Comments
 (0)