1 /* Marshalling and unmarshalling of C++-specific types.
2 Copyright (C) 2014-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef CC1_PLUGIN_MARSHALL_CXX_HH
21 #define CC1_PLUGIN_MARSHALL_CXX_HH
23 #include "marshall.hh"
24 #include "gcc-cp-interface.h"
29 unmarshall (connection *conn, enum gcc_cp_symbol_kind *result)
32 if (!unmarshall_intlike (conn, &p))
34 *result = (enum gcc_cp_symbol_kind) p;
39 unmarshall (connection *conn, enum gcc_cp_oracle_request *result)
42 if (!unmarshall_intlike (conn, &p))
44 *result = (enum gcc_cp_oracle_request) p;
49 unmarshall (connection *conn, enum gcc_cp_qualifiers *result)
52 if (!unmarshall_intlike (conn, &p))
54 *result = (enum gcc_cp_qualifiers) p;
59 unmarshall (connection *conn, enum gcc_cp_ref_qualifiers *result)
62 if (!unmarshall_intlike (conn, &p))
64 *result = (enum gcc_cp_ref_qualifiers) p;
68 // Send a gcc_vbase_array marker followed by the array.
70 marshall (connection *conn, const gcc_vbase_array *a)
79 if (!marshall_array_start (conn, 'v', len))
85 if (!marshall_array_elmts (conn, len * sizeof (a->elements[0]),
89 return marshall_array_elmts (conn, len * sizeof (a->flags[0]),
93 // Read a gcc_vbase_array marker, followed by a gcc_vbase_array. The
94 // resulting array must be freed by the caller, using 'delete[]' on
95 // elements and virtualp, and 'delete' on the array object itself.
97 unmarshall (connection *conn, struct gcc_vbase_array **result)
101 if (!unmarshall_array_start (conn, 'v', &len))
104 if (len == (size_t)-1)
110 struct gcc_vbase_array *gva = new gcc_vbase_array;
112 gva->n_elements = len;
113 gva->elements = new gcc_type[len];
115 if (!unmarshall_array_elmts (conn,
116 len * sizeof (gva->elements[0]),
119 delete[] gva->elements;
124 gva->flags = new enum gcc_cp_symbol_kind[len];
126 if (!unmarshall_array_elmts (conn,
127 len * sizeof (gva->flags[0]),
131 delete[] gva->elements;
140 // Send a gcc_cp_template_args marker followed by the array.
142 marshall (connection *conn, const gcc_cp_template_args *a)
151 if (!marshall_array_start (conn, 't', len))
157 if (!marshall_array_elmts (conn, len * sizeof (a->kinds[0]),
161 return marshall_array_elmts (conn, len * sizeof (a->elements[0]),
165 // Read a gcc_vbase_array marker, followed by a gcc_vbase_array. The
166 // resulting array must be freed by the caller, using 'delete[]' on
167 // elements and virtualp, and 'delete' on the array object itself.
169 unmarshall (connection *conn, struct gcc_cp_template_args **result)
173 if (!unmarshall_array_start (conn, 't', &len))
176 if (len == (size_t)-1)
182 struct gcc_cp_template_args *gva = new gcc_cp_template_args;
184 gva->n_elements = len;
185 gva->kinds = new char[len];
187 if (!unmarshall_array_elmts (conn,
188 len * sizeof (gva->kinds[0]),
196 gva->elements = new gcc_cp_template_arg[len];
198 if (!unmarshall_array_elmts (conn,
199 len * sizeof (gva->elements[0]),
202 delete[] gva->elements;
212 // Send a gcc_cp_function_args marker followed by the array.
214 marshall (connection *conn, const gcc_cp_function_args *a)
223 if (!marshall_array_start (conn, 'd', len))
229 return marshall_array_elmts (conn, len * sizeof (a->elements[0]),
233 // Read a gcc_cp_function_args marker, followed by a
234 // gcc_cp_function_args. The resulting array must be freed
235 // by the caller, using 'delete[]' on elements and virtualp, and
236 // 'delete' on the array object itself.
238 unmarshall (connection *conn, struct gcc_cp_function_args **result)
242 if (!unmarshall_array_start (conn, 'd', &len))
245 if (len == (size_t)-1)
251 struct gcc_cp_function_args *gva = new gcc_cp_function_args;
253 gva->n_elements = len;
254 gva->elements = new gcc_expr[len];
256 if (!unmarshall_array_elmts (conn,
257 len * sizeof (gva->elements[0]),
260 delete[] gva->elements;
271 #endif // CC1_PLUGIN_MARSHALL_CP_HH