Flutter Engine
The Flutter Engine
fl_standard_message_codec.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 FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_STANDARD_MESSAGE_CODEC_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_STANDARD_MESSAGE_CODEC_H_
7
8#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9#error "Only <flutter_linux/flutter_linux.h> can be included directly."
10#endif
11
12#include <gmodule.h>
13
14#include "fl_message_codec.h"
15
16G_BEGIN_DECLS
17
18G_MODULE_EXPORT
19G_DECLARE_DERIVABLE_TYPE(FlStandardMessageCodec,
20 fl_standard_message_codec,
21 FL,
22 STANDARD_MESSAGE_CODEC,
23 FlMessageCodec)
24
25/**
26 * FlStandardMessageCodec:
27 *
28 * #FlStandardMessageCodec is an #FlMessageCodec that implements the Flutter
29 * standard message encoding. This codec encodes and decodes #FlValue of type
30 * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT,
31 * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST,
32 * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST,
33 * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP.
34 *
35 * If other values types are required to be supported create a new subclass that
36 * overrides write_value and read_value_of_type.
37 *
38 * #FlStandardMessageCodec matches the StandardCodec class in the Flutter
39 * services library.
40 */
41
42struct _FlStandardMessageCodecClass {
43 FlMessageCodecClass parent_class;
44
45 /**
46 * FlStandardMessageCodec::write_value:
47 * @codec: an #FlStandardMessageCodec.
48 * @buffer: a buffer to write into.
49 * @value: (allow-none): value to write.
50 * @error: (allow-none): #GError location to store the error occurring, or
51 * %NULL.
52 *
53 * Virtual method to write an #FlValue in Flutter Standard encoding.
54 *
55 * If a codec needs to support custom #FlValue objects it must override this
56 * method to encode those values. For non-custom values the parent method
57 * should be called.
58 *
59 * Returns: %TRUE on success.
60 */
61 gboolean (*write_value)(FlStandardMessageCodec* codec,
62 GByteArray* buffer,
64 GError** error);
65
66 /**
67 * FlStandardMessageCodec::read_value_of_type:
68 * @codec: an #FlStandardMessageCodec.
69 * @buffer: buffer to read from.
70 * @offset: (inout): read position in @buffer.
71 * @type: the type of the value.
72 * @error: (allow-none): #GError location to store the error occurring, or
73 * %NULL.
74 *
75 * Virtual method to read an #FlValue in Flutter Standard encoding.
76 *
77 * If a codec needs to support custom #FlValue objects it must override this
78 * method to decode those values. For non-custom values the parent method
79 * should be called.
80 *
81 * Returns: an #FlValue or %NULL on error.
82 */
83 FlValue* (*read_value_of_type)(FlStandardMessageCodec* codec,
84 GBytes* buffer,
85 size_t* offset,
86 int type,
87 GError** error);
88};
89
90/*
91 * fl_standard_message_codec_new:
92 *
93 * Creates an #FlStandardMessageCodec.
94 *
95 * Returns: a new #FlStandardMessageCodec.
96 */
97FlStandardMessageCodec* fl_standard_message_codec_new();
98
99/**
100 * fl_standard_message_codec_write_size:
101 * @codec: an #FlStandardMessageCodec.
102 * @buffer: buffer to write into.
103 * @size: size value to write.
104 *
105 * Writes a size field in Flutter Standard encoding.
106 */
107void fl_standard_message_codec_write_size(FlStandardMessageCodec* codec,
108 GByteArray* buffer,
109 uint32_t size);
110
111/**
112 * fl_standard_message_codec_read_size:
113 * @codec: an #FlStandardMessageCodec.
114 * @buffer: buffer to read from.
115 * @offset: (inout): read position in @buffer.
116 * @value: location to read size.
117 * @error: (allow-none): #GError location to store the error occurring, or
118 * %NULL.
119 *
120 * Reads a size field in Flutter Standard encoding.
121 *
122 * This method is intended for use by subclasses overriding
123 * FlStandardMessageCodec::read_value_of_type.
124 *
125 * Returns: %TRUE on success.
126 */
127gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec* codec,
128 GBytes* buffer,
129 size_t* offset,
130 uint32_t* value,
131 GError** error);
132
133/**
134 * fl_standard_message_codec_write_value:
135 * @codec: an #FlStandardMessageCodec.
136 * @buffer: buffer to write into.
137 * @value: (allow-none): value to write.
138 * @error: (allow-none): #GError location to store the error occurring, or
139 * %NULL.
140 *
141 * Writes an #FlValue in Flutter Standard encoding.
142 *
143 * This method is intended for use by subclasses overriding
144 * FlStandardMessageCodec::write_value.
145 *
146 * Returns: %TRUE on success.
147 */
148gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec* codec,
149 GByteArray* buffer,
150 FlValue* value,
151 GError** error);
152
153/**
154 * fl_standard_message_codec_read_value:
155 * @codec: an #FlStandardMessageCodec.
156 * @buffer: buffer to read from.
157 * @offset: (inout): read position in @buffer.
158 * @value: location to read size.
159 * @error: (allow-none): #GError location to store the error occurring, or
160 * %NULL.
161 *
162 * Reads an #FlValue in Flutter Standard encoding.
163 *
164 * This method is intended for use by subclasses overriding
165 * FlStandardMessageCodec::read_value_of_type.
166 *
167 * Returns: a new #FlValue or %NULL on error.
168 */
169FlValue* fl_standard_message_codec_read_value(FlStandardMessageCodec* codec,
170 GBytes* buffer,
171 size_t* offset,
172 GError** error);
173
174G_END_DECLS
175
176#endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_STANDARD_MESSAGE_CODEC_H_
GLenum type
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
G_BEGIN_DECLS G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE(FlStandardMessageCodec, fl_standard_message_codec, FL, STANDARD_MESSAGE_CODEC, FlMessageCodec) struct _FlStandardMessageCodecClass
void fl_standard_message_codec_write_size(FlStandardMessageCodec *codec, GByteArray *buffer, uint32_t size)
FlValue * fl_standard_message_codec_read_value(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
FlStandardMessageCodec * fl_standard_message_codec_new()
gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
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
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
SeparatedVector2 offset