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  FlutterStandardFieldUInt8Data,
20  FlutterStandardFieldInt32Data,
21  FlutterStandardFieldInt64Data,
22  FlutterStandardFieldFloat64Data,
23  FlutterStandardFieldList,
24  FlutterStandardFieldMap,
25  FlutterStandardFieldFloat32Data,
26 };
27 
28 namespace flutter {
29 FlutterStandardField FlutterStandardFieldForDataType(FlutterStandardDataType type) {
30  switch (type) {
31  case FlutterStandardDataTypeUInt8:
32  return FlutterStandardFieldUInt8Data;
33  case FlutterStandardDataTypeInt32:
34  return FlutterStandardFieldInt32Data;
35  case FlutterStandardDataTypeInt64:
36  return FlutterStandardFieldInt64Data;
37  case FlutterStandardDataTypeFloat32:
38  return FlutterStandardFieldFloat32Data;
39  case FlutterStandardDataTypeFloat64:
40  return FlutterStandardFieldFloat64Data;
41  }
42 }
43 FlutterStandardDataType FlutterStandardDataTypeForField(FlutterStandardField field) {
44  switch (field) {
45  case FlutterStandardFieldUInt8Data:
46  return FlutterStandardDataTypeUInt8;
47  case FlutterStandardFieldInt32Data:
48  return FlutterStandardDataTypeInt32;
49  case FlutterStandardFieldInt64Data:
50  return FlutterStandardDataTypeInt64;
51  case FlutterStandardFieldFloat32Data:
52  return FlutterStandardDataTypeFloat32;
53  case FlutterStandardFieldFloat64Data:
54  return FlutterStandardDataTypeFloat64;
55  default:
56  return FlutterStandardDataTypeUInt8;
57  }
58 }
59 
60 UInt8 elementSizeForFlutterStandardDataType(FlutterStandardDataType type) {
61  switch (type) {
62  case FlutterStandardDataTypeUInt8:
63  return 1;
64  case FlutterStandardDataTypeInt32:
65  return 4;
66  case FlutterStandardDataTypeInt64:
67  return 8;
68  case FlutterStandardDataTypeFloat32:
69  return 4;
70  case FlutterStandardDataTypeFloat64:
71  return 8;
72  }
73 }
74 } // namespace flutter
75 
76 #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
KeyCallType type
FlutterStandardField FlutterStandardFieldForDataType(FlutterStandardDataType type)
FlutterStandardDataType FlutterStandardDataTypeForField(FlutterStandardField field)
typedef NS_ENUM(NSInteger, FlutterStandardField)
UInt8 elementSizeForFlutterStandardDataType(FlutterStandardDataType type)