1 /* Marshalling and unmarshalling.
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_HH
21 #define CC1_PLUGIN_MARSHALL_HH
24 #include "gcc-c-interface.h"
30 // Only a single kind of integer is ever sent over the wire, and
32 typedef unsigned long long protocol_int
;
34 // Read an integer from the connection and verify that it has the
36 status
unmarshall_check (connection
*, protocol_int v
);
38 // Write an integer, prefixed with the integer type marker, to the
40 status
marshall_intlike (connection
*, protocol_int
);
42 // Read a type marker from the connection and verify that it is an
43 // integer type marker. If not, return FAIL. If so, read an
44 // integer store it in the out argument.
45 status
unmarshall_intlike (connection
*, protocol_int
*);
47 // A template function that can handle marshalling various integer
48 // objects to the connection.
50 status
marshall (connection
*conn
, T scalar
)
52 return marshall_intlike (conn
, scalar
);
55 // A template function that can handle unmarshalling various integer
56 // objects from the connection. Note that this can't be
57 // instantiated for enum types. Note also that there's no way at
58 // the protocol level to distinguish different int types.
60 status
unmarshall (connection
*conn
, T
*scalar
)
64 if (!unmarshall_intlike (conn
, &result
))
70 // Unmarshallers for some specific enum types. With C++11 we
71 // wouldn't need these, as we could add type traits to the scalar
73 status
unmarshall (connection
*, enum gcc_c_symbol_kind
*);
74 status
unmarshall (connection
*, enum gcc_qualifiers
*);
75 status
unmarshall (connection
*, enum gcc_c_oracle_request
*);
77 // Send a string type marker followed by a string.
78 status
marshall (connection
*, const char *);
80 // Read a string type marker followed by a string. The caller is
81 // responsible for freeing the resulting string using 'delete[]'.
82 status
unmarshall (connection
*, char **);
84 // Send a gcc_type_array marker followed by the array.
85 status
marshall (connection
*, const gcc_type_array
*);
87 // Read a gcc_type_array marker, followed by a gcc_type_array. The
88 // resulting array must be freed by the caller, using 'delete[]' on
89 // the elements, and 'delete' on the array object itself.
90 status
unmarshall (connection
*, struct gcc_type_array
**);
93 #endif // CC1_PLUGIN_MARSHALL_HH