diff options
author | Tom Tromey <tom@tromey.com> | 2021-05-04 15:26:58 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-05-05 00:06:18 -0600 |
commit | 8fdffa48c57f13b90556bc179150d24efdeeeef5 (patch) | |
tree | 6b946a1fe949ce299c120d384e8d844eeab0ad87 /libcc1/libcc1plugin.cc | |
parent | ee75ca6b72e4235aa48d6fb30c5cd274f2ff6b67 (diff) | |
download | gcc-8fdffa48c57f13b90556bc179150d24efdeeeef5.zip gcc-8fdffa48c57f13b90556bc179150d24efdeeeef5.tar.gz gcc-8fdffa48c57f13b90556bc179150d24efdeeeef5.tar.bz2 |
libcc1: use variadic templates for callbacks
This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions. This is how I had wanted it to work from the very
beginning, and is possible now with C++11.
I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.
libcc1
* rpc.hh (argument_wrapper) <get>: Replace cast operator.
(argument_wrapper<T *>) <get>: Likewise.
(unmarshall): Add std::tuple overloads.
(callback): Remove.
(class invoker): New.
* libcp1plugin.cc (plugin_init): Update.
* libcp1.cc (libcp1::add_callbacks): Update.
* libcc1plugin.cc (plugin_init): Update.
* libcc1.cc (libcc1::add_callbacks): Update.
* connection.cc (cc1_plugin::connection::do_wait): Update.
Diffstat (limited to 'libcc1/libcc1plugin.cc')
-rw-r--r-- | libcc1/libcc1plugin.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index d6951ab..4d6a3a1 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -762,46 +762,46 @@ plugin_init (struct plugin_name_args *plugin_info, #define GCC_METHOD0(R, N) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, plugin_ ## N>; \ + = cc1_plugin::invoker<R>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD1(R, N, A) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, plugin_ ## N>; \ + = cc1_plugin::invoker<R, A>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD2(R, N, A, B) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, B, plugin_ ## N>; \ + = cc1_plugin::invoker<R, A, B>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD3(R, N, A, B, C) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, B, C, plugin_ ## N>; \ + = cc1_plugin::invoker<R, A, B, C>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD4(R, N, A, B, C, D) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, B, C, D, \ - plugin_ ## N>; \ + = cc1_plugin::invoker<R, A, B, C, \ + D>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD5(R, N, A, B, C, D, E) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, B, C, D, E, \ - plugin_ ## N>; \ + = cc1_plugin::invoker<R, A, B, C, D, \ + E>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \ { \ cc1_plugin::callback_ftype *fun \ - = cc1_plugin::callback<R, A, B, C, D, E, F, G, \ - plugin_ ## N>; \ + = cc1_plugin::invoker<R, A, B, C, D, \ + E, F, G>::invoke<plugin_ ## N>; \ current_context->add_callback (# N, fun); \ } |