Flutter Engine
The Flutter Engine
Enumerations | Functions
FlutterStandardCodecHelper.h File Reference
#include <CoreFoundation/CoreFoundation.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  FlutterStandardField {
  FlutterStandardFieldNil , FlutterStandardFieldTrue , FlutterStandardFieldFalse , FlutterStandardFieldInt32 ,
  FlutterStandardFieldInt64 , FlutterStandardFieldIntHex , FlutterStandardFieldFloat64 , FlutterStandardFieldString ,
  FlutterStandardFieldUInt8Data , FlutterStandardFieldInt32Data , FlutterStandardFieldInt64Data , FlutterStandardFieldFloat64Data ,
  FlutterStandardFieldList , FlutterStandardFieldMap , FlutterStandardFieldFloat32Data
}
 
enum  FlutterStandardCodecObjcType {
  FlutterStandardCodecObjcTypeNil , FlutterStandardCodecObjcTypeNSNumber , FlutterStandardCodecObjcTypeNSString , FlutterStandardCodecObjcTypeFlutterStandardTypedData ,
  FlutterStandardCodecObjcTypeNSData , FlutterStandardCodecObjcTypeNSArray , FlutterStandardCodecObjcTypeNSDictionary , FlutterStandardCodecObjcTypeUnknown
}
 

Functions

static bool FlutterStandardFieldIsStandardType (uint8_t field)
 
Reader Helpers
void FlutterStandardCodecHelperReadAlignment (unsigned long *location, uint8_t alignment)
 
void FlutterStandardCodecHelperReadBytes (unsigned long *location, unsigned long length, void *destination, CFDataRef data)
 
uint8_t FlutterStandardCodecHelperReadByte (unsigned long *location, CFDataRef data)
 
uint32_t FlutterStandardCodecHelperReadSize (unsigned long *location, CFDataRef data)
 
CFStringRef FlutterStandardCodecHelperReadUTF8 (unsigned long *location, CFDataRef data)
 
CFTypeRef FlutterStandardCodecHelperReadValueOfType (unsigned long *location, CFDataRef data, uint8_t type, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)
 
Writer Helpers
void FlutterStandardCodecHelperWriteByte (CFMutableDataRef data, uint8_t value)
 
void FlutterStandardCodecHelperWriteBytes (CFMutableDataRef data, const void *bytes, unsigned long length)
 
void FlutterStandardCodecHelperWriteSize (CFMutableDataRef data, uint32_t size)
 
void FlutterStandardCodecHelperWriteAlignment (CFMutableDataRef data, uint8_t alignment)
 
void FlutterStandardCodecHelperWriteUTF8 (CFMutableDataRef data, CFStringRef value)
 
void FlutterStandardCodecHelperWriteData (CFMutableDataRef data, CFDataRef value)
 
bool FlutterStandardCodecHelperWriteNumber (CFMutableDataRef data, CFNumberRef number)
 

Enumeration Type Documentation

◆ FlutterStandardCodecObjcType

Enumerator
FlutterStandardCodecObjcTypeNil 
FlutterStandardCodecObjcTypeNSNumber 
FlutterStandardCodecObjcTypeNSString 
FlutterStandardCodecObjcTypeFlutterStandardTypedData 
FlutterStandardCodecObjcTypeNSData 
FlutterStandardCodecObjcTypeNSArray 
FlutterStandardCodecObjcTypeNSDictionary 
FlutterStandardCodecObjcTypeUnknown 

Definition at line 44 of file FlutterStandardCodecHelper.h.

44 {
45 // NOLINTBEGIN(readability-identifier-naming)
54 // NOLINTEND(readability-identifier-naming)
FlutterStandardCodecObjcType
@ FlutterStandardCodecObjcTypeNSArray
@ FlutterStandardCodecObjcTypeFlutterStandardTypedData
@ FlutterStandardCodecObjcTypeNSData
@ FlutterStandardCodecObjcTypeNSString
@ FlutterStandardCodecObjcTypeNil
@ FlutterStandardCodecObjcTypeUnknown
@ FlutterStandardCodecObjcTypeNSDictionary
@ FlutterStandardCodecObjcTypeNSNumber

◆ FlutterStandardField

Enumerator
FlutterStandardFieldNil 
FlutterStandardFieldTrue 
FlutterStandardFieldFalse 
FlutterStandardFieldInt32 
FlutterStandardFieldInt64 
FlutterStandardFieldIntHex 
FlutterStandardFieldFloat64 
FlutterStandardFieldString 
FlutterStandardFieldUInt8Data 
FlutterStandardFieldInt32Data 
FlutterStandardFieldInt64Data 
FlutterStandardFieldFloat64Data 
FlutterStandardFieldList 
FlutterStandardFieldMap 
FlutterStandardFieldFloat32Data 

Definition at line 19 of file FlutterStandardCodecHelper.h.

19 {
20 // NOLINTBEGIN(readability-identifier-naming)
36 // NOLINTEND(readability-identifier-naming)
@ FlutterStandardFieldUInt8Data
@ FlutterStandardFieldFloat64
@ FlutterStandardFieldFloat32Data
@ FlutterStandardFieldIntHex
@ FlutterStandardFieldMap
@ FlutterStandardFieldInt64Data
@ FlutterStandardFieldList
@ FlutterStandardFieldInt32
@ FlutterStandardFieldNil
@ FlutterStandardFieldTrue
@ FlutterStandardFieldString
@ FlutterStandardFieldFalse
@ FlutterStandardFieldInt32Data
@ FlutterStandardFieldInt64
@ FlutterStandardFieldFloat64Data

Function Documentation

◆ FlutterStandardCodecHelperReadAlignment()

void FlutterStandardCodecHelperReadAlignment ( unsigned long *  location,
uint8_t  alignment 
)

Definition at line 18 of file FlutterStandardCodecHelper.cc.

19 {
20 uint8_t mod = *location % alignment;
21 if (mod) {
22 *location += (alignment - mod);
23 }
24}

◆ FlutterStandardCodecHelperReadByte()

uint8_t FlutterStandardCodecHelperReadByte ( unsigned long *  location,
CFDataRef  data 
)

Definition at line 42 of file FlutterStandardCodecHelper.cc.

43 {
44 uint8_t value;
46 return value;
47}
void FlutterStandardCodecHelperReadBytes(unsigned long *location, unsigned long length, void *destination, CFDataRef data)
uint8_t value
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ FlutterStandardCodecHelperReadBytes()

void FlutterStandardCodecHelperReadBytes ( unsigned long *  location,
unsigned long  length,
void *  destination,
CFDataRef  data 
)

Definition at line 33 of file FlutterStandardCodecHelper.cc.

36 {
37 CFRange range = CFRangeMake(*location, length);
38 CFDataGetBytes(data, range, static_cast<UInt8*>(destination));
39 *location += length;
40}
size_t length

◆ FlutterStandardCodecHelperReadSize()

uint32_t FlutterStandardCodecHelperReadSize ( unsigned long *  location,
CFDataRef  data 
)

Definition at line 49 of file FlutterStandardCodecHelper.cc.

50 {
51 uint8_t byte = FlutterStandardCodecHelperReadByte(location, data);
52 if (byte < 254) {
53 return (uint32_t)byte;
54 } else if (byte == 254) {
55 UInt16 value;
57 return value;
58 } else {
59 UInt32 value;
61 return value;
62 }
63}
uint8_t FlutterStandardCodecHelperReadByte(unsigned long *location, CFDataRef data)

◆ FlutterStandardCodecHelperReadUTF8()

CFStringRef FlutterStandardCodecHelperReadUTF8 ( unsigned long *  location,
CFDataRef  data 
)

Definition at line 75 of file FlutterStandardCodecHelper.cc.

76 {
77 uint32_t size = FlutterStandardCodecHelperReadSize(location, data);
78 CFDataRef bytes = ReadDataNoCopy(location, size, data);
79 CFStringRef result = CFStringCreateFromExternalRepresentation(
80 kCFAllocatorDefault, bytes, kCFStringEncodingUTF8);
81 return static_cast<CFStringRef>(CFAutorelease(result));
82}
uint32_t FlutterStandardCodecHelperReadSize(unsigned long *location, CFDataRef data)
static CFDataRef ReadDataNoCopy(unsigned long *location, unsigned long length, CFDataRef data)
GAsyncResult * result
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ FlutterStandardCodecHelperReadValueOfType()

CFTypeRef FlutterStandardCodecHelperReadValueOfType ( unsigned long *  location,
CFDataRef  data,
uint8_t  type,
CFTypeRef(*)(CFTypeRef)  ReadValue,
CFTypeRef(*)(FlutterStandardField, CFTypeRef)  ReadTypedDataOfType,
CFTypeRef  user_data 
)

Definition at line 103 of file FlutterStandardCodecHelper.cc.

109 {
111 switch (field) {
113 return nil;
115 return kCFBooleanTrue;
117 return kCFBooleanFalse;
119 int32_t value;
121 return CFAutorelease(
122 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
123 }
125 int64_t value;
127 return CFAutorelease(
128 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
129 }
131 Float64 value;
134 return CFAutorelease(
135 CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
136 }
145 return ReadTypedDataOfType(field, user_data);
148 CFMutableArrayRef array = CFArrayCreateMutable(
149 kCFAllocatorDefault, length, &kCFTypeArrayCallBacks);
150 for (UInt32 i = 0; i < length; i++) {
151 CFTypeRef value = FastReadValue(location, data, ReadValue,
152 ReadTypedDataOfType, user_data);
153 CFArrayAppendValue(array, (value == nil ? kCFNull : value));
154 }
155 return CFAutorelease(array);
156 }
158 UInt32 size = FlutterStandardCodecHelperReadSize(location, data);
159 CFMutableDictionaryRef dict = CFDictionaryCreateMutable(
160 kCFAllocatorDefault, size, &kCFTypeDictionaryKeyCallBacks,
161 &kCFTypeDictionaryValueCallBacks);
162 for (UInt32 i = 0; i < size; i++) {
163 CFTypeRef key = FastReadValue(location, data, ReadValue,
164 ReadTypedDataOfType, user_data);
165 CFTypeRef val = FastReadValue(location, data, ReadValue,
166 ReadTypedDataOfType, user_data);
167 CFDictionaryAddValue(dict, (key == nil ? kCFNull : key),
168 (val == nil ? kCFNull : val));
169 }
170 return CFAutorelease(dict);
171 }
172 default:
173 // Malformed message.
174 FML_DCHECK(false);
175 }
176}
CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long *location, CFDataRef data)
void FlutterStandardCodecHelperReadAlignment(unsigned long *location, uint8_t alignment)
static CFTypeRef FastReadValue(unsigned long *location, CFDataRef data, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)
GLenum type
#define FML_DCHECK(condition)
Definition: logging.h:103
void * user_data

◆ FlutterStandardCodecHelperWriteAlignment()

void FlutterStandardCodecHelperWriteAlignment ( CFMutableDataRef  data,
uint8_t  alignment 
)

Definition at line 201 of file FlutterStandardCodecHelper.cc.

202 {
203 uint8_t mod = CFDataGetLength(data) % alignment;
204 if (mod) {
205 for (int i = 0; i < (alignment - mod); i++) {
207 }
208 }
209}
void FlutterStandardCodecHelperWriteByte(CFMutableDataRef data, uint8_t value)

◆ FlutterStandardCodecHelperWriteByte()

void FlutterStandardCodecHelperWriteByte ( CFMutableDataRef  data,
uint8_t  value 
)

Definition at line 178 of file FlutterStandardCodecHelper.cc.

178 {
179 CFDataAppendBytes(data, &value, 1);
180}

◆ FlutterStandardCodecHelperWriteBytes()

void FlutterStandardCodecHelperWriteBytes ( CFMutableDataRef  data,
const void *  bytes,
unsigned long  length 
)

Definition at line 182 of file FlutterStandardCodecHelper.cc.

184 {
185 CFDataAppendBytes(data, static_cast<const UInt8*>(bytes), length);
186}

◆ FlutterStandardCodecHelperWriteData()

void FlutterStandardCodecHelperWriteData ( CFMutableDataRef  data,
CFDataRef  value 
)

Definition at line 232 of file FlutterStandardCodecHelper.cc.

233 {
234 const UInt8* bytes = CFDataGetBytePtr(value);
235 CFIndex length = CFDataGetLength(value);
237}
void FlutterStandardCodecHelperWriteBytes(CFMutableDataRef data, const void *bytes, unsigned long length)

◆ FlutterStandardCodecHelperWriteNumber()

bool FlutterStandardCodecHelperWriteNumber ( CFMutableDataRef  data,
CFNumberRef  number 
)

Definition at line 239 of file FlutterStandardCodecHelper.cc.

240 {
241 bool success = false;
242 if (CFGetTypeID(number) == CFBooleanGetTypeID()) {
243 bool b = CFBooleanGetValue((CFBooleanRef)number);
246 success = true;
247 } else if (CFNumberIsFloatType(number)) {
248 Float64 f;
249 success = CFNumberGetValue(number, kCFNumberFloat64Type, &f);
250 if (success) {
254 }
255 } else if (CFNumberGetByteSize(number) <= 4) {
256 SInt32 n;
257 success = CFNumberGetValue(number, kCFNumberSInt32Type, &n);
258 if (success) {
261 }
262 } else if (CFNumberGetByteSize(number) <= 8) {
263 SInt64 n;
264 success = CFNumberGetValue(number, kCFNumberSInt64Type, &n);
265 if (success) {
268 }
269 }
270 return success;
271}
void FlutterStandardCodecHelperWriteAlignment(CFMutableDataRef data, uint8_t alignment)
static bool b

◆ FlutterStandardCodecHelperWriteSize()

void FlutterStandardCodecHelperWriteSize ( CFMutableDataRef  data,
uint32_t  size 
)

Definition at line 188 of file FlutterStandardCodecHelper.cc.

188 {
189 if (size < 254) {
191 } else if (size <= 0xffff) {
193 UInt16 value = (UInt16)size;
195 } else {
198 }
199}

◆ FlutterStandardCodecHelperWriteUTF8()

void FlutterStandardCodecHelperWriteUTF8 ( CFMutableDataRef  data,
CFStringRef  value 
)

Definition at line 211 of file FlutterStandardCodecHelper.cc.

212 {
213 const char* utf8 = CFStringGetCStringPtr(value, kCFStringEncodingUTF8);
214 if (utf8) {
215 size_t length = strlen(utf8);
218 } else {
219 CFIndex length = CFStringGetLength(value);
220 CFIndex used_length = 0;
221 // UTF16 length times 3 will fit all UTF8.
222 CFIndex buffer_length = length * 3;
223 std::vector<UInt8> buffer;
224 buffer.resize(buffer_length);
225 CFStringGetBytes(value, CFRangeMake(0, length), kCFStringEncodingUTF8, 0,
226 false, buffer.data(), buffer_length, &used_length);
229 }
230}
void FlutterStandardCodecHelperWriteSize(CFMutableDataRef data, uint32_t size)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ FlutterStandardFieldIsStandardType()

static bool FlutterStandardFieldIsStandardType ( uint8_t  field)
inlinestatic

Definition at line 39 of file FlutterStandardCodecHelper.h.

39 {
40 return field <= FlutterStandardFieldFloat32Data &&
42}