GNU Binutils with patches for OS216
Revisión | a9921622de0a7332a333c5206ce8cd632803df97 (tree) |
---|---|
Tiempo | 2017-09-12 07:15:09 |
Autor | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
Replace clear_hook_in_cleanup with scoped_restore_hook_in
This removes clear_hook_in_cleanup in favor of a scoped_restore-like
class. scoped_restore itself can't be used because hook_in is a
bitfield.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* cli/cli-script.c (class scoped_restore_hook_in): New.
(clear_hook_in_cleanup): Remove.
(execute_cmd_pre_hook, execute_cmd_post_hook): Use
scoped_restore_hook_in.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2017-09-11 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * cli/cli-script.c (class scoped_restore_hook_in): New. | |
4 | + (clear_hook_in_cleanup): Remove. | |
5 | + (execute_cmd_pre_hook, execute_cmd_post_hook): Use | |
6 | + scoped_restore_hook_in. | |
7 | + | |
8 | +2017-09-11 Tom Tromey <tom@tromey.com> | |
9 | + | |
3 | 10 | * cli/cli-script.c (restore_interp): Remove. |
4 | 11 | (read_command_lines): Use scoped_restore_interp. |
5 | 12 | * interps.c (scoped_restore_interp::set_temp): Rename from |
@@ -340,23 +340,36 @@ print_command_lines (struct ui_out *uiout, struct command_line *cmd, | ||
340 | 340 | |
341 | 341 | /* Handle pre-post hooks. */ |
342 | 342 | |
343 | -static void | |
344 | -clear_hook_in_cleanup (void *data) | |
343 | +class scoped_restore_hook_in | |
345 | 344 | { |
346 | - struct cmd_list_element *c = (struct cmd_list_element *) data; | |
345 | +public: | |
347 | 346 | |
348 | - c->hook_in = 0; /* Allow hook to work again once it is complete. */ | |
349 | -} | |
347 | + scoped_restore_hook_in (struct cmd_list_element *c) | |
348 | + : m_cmd (c) | |
349 | + { | |
350 | + } | |
351 | + | |
352 | + ~scoped_restore_hook_in () | |
353 | + { | |
354 | + m_cmd->hook_in = 0; | |
355 | + } | |
356 | + | |
357 | + scoped_restore_hook_in (const scoped_restore_hook_in &) = delete; | |
358 | + scoped_restore_hook_in &operator= (const scoped_restore_hook_in &) = delete; | |
359 | + | |
360 | +private: | |
361 | + | |
362 | + struct cmd_list_element *m_cmd; | |
363 | +}; | |
350 | 364 | |
351 | 365 | void |
352 | 366 | execute_cmd_pre_hook (struct cmd_list_element *c) |
353 | 367 | { |
354 | 368 | if ((c->hook_pre) && (!c->hook_in)) |
355 | 369 | { |
356 | - struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c); | |
370 | + scoped_restore_hook_in restore_hook (c); | |
357 | 371 | c->hook_in = 1; /* Prevent recursive hooking. */ |
358 | 372 | execute_user_command (c->hook_pre, (char *) 0); |
359 | - do_cleanups (cleanups); | |
360 | 373 | } |
361 | 374 | } |
362 | 375 |
@@ -365,11 +378,9 @@ execute_cmd_post_hook (struct cmd_list_element *c) | ||
365 | 378 | { |
366 | 379 | if ((c->hook_post) && (!c->hook_in)) |
367 | 380 | { |
368 | - struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c); | |
369 | - | |
381 | + scoped_restore_hook_in restore_hook (c); | |
370 | 382 | c->hook_in = 1; /* Prevent recursive hooking. */ |
371 | 383 | execute_user_command (c->hook_post, (char *) 0); |
372 | - do_cleanups (cleanups); | |
373 | 384 | } |
374 | 385 | } |
375 | 386 |