Flutter Engine
FlutterStandardCodec_Internal.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
6 #define SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
7 
8 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
9 
10 typedef NS_ENUM(NSInteger, FlutterStandardField) {
11  FlutterStandardFieldNil,
12  FlutterStandardFieldTrue,
13  FlutterStandardFieldFalse,
14  FlutterStandardFieldInt32,
15  FlutterStandardFieldInt64,
16  FlutterStandardFieldIntHex,
17  FlutterStandardFieldFloat64,
18  FlutterStandardFieldString,
19  // The following must match the corresponding order from `FlutterStandardDataType`.
20  FlutterStandardFieldUInt8Data,
21  FlutterStandardFieldInt32Data,
22  FlutterStandardFieldInt64Data,
23  FlutterStandardFieldFloat64Data,
24  FlutterStandardFieldList,
25  FlutterStandardFieldMap,
26 };
27 
28 namespace flutter {
29 FlutterStandardField FlutterStandardFieldForDataType(FlutterStandardDataType type) {
30  return (FlutterStandardField)(type + FlutterStandardFieldUInt8Data);
31 }
32 FlutterStandardDataType FlutterStandardDataTypeForField(FlutterStandardField field) {
33  return (FlutterStandardDataType)(field - FlutterStandardFieldUInt8Data);
34 }
35 UInt8 elementSizeForFlutterStandardDataType(FlutterStandardDataType type) {
36  switch (type) {
37  case FlutterStandardDataTypeUInt8:
38  return 1;
39  case FlutterStandardDataTypeInt32:
40  return 4;
41  case FlutterStandardDataTypeInt64:
42  return 8;
43  case FlutterStandardDataTypeFloat64:
44  return 8;
45  }
46 }
47 } // namespace flutter
48 
49 #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
FlutterStandardField FlutterStandardFieldForDataType(FlutterStandardDataType type)
FlutterStandardDataType FlutterStandardDataTypeForField(FlutterStandardField field)
typedef NS_ENUM(NSInteger, FlutterStandardField)
UInt8 elementSizeForFlutterStandardDataType(FlutterStandardDataType type)