Mercurial > octave
diff liboctave/util/unwind-prot.h @ 25653:b3d357990b52
better use of templates for action_container and derived classes
It should now be possible to add arbitrary lambda functions or
std::function objects to the unwind_protect objects and octave_link
event queues, and to add functions (including member functions) with
any number of parameters.
* action-container.h (action_container::fcn_elem): Define using
variadic template, std::bind, and std::function for more flexibility
and to eliminate code duplication.
(action_container::method_elem, action_container::method_arg_elem,
action_container::method_crefarg_elem,
action_container::method_arg2_elem,
action_container::method_arg3_elem,
action_container::method_arg4_elem): Delete.
(action_container::add_action): Rename from add. Now protected.
(action_container::add): New generic function for adding functions.
(action_container::add_fcn, action_container::add_method): Define
using variadic template for more flexibility and to eliminate code
duplication.
* event-queue.h (event_queue::add_action): Rename from add.
Now protected.
* unwind-prot.h (unwind_protect::add_action): Likewise.
* variable-editor-model.cc: Eliminate template parameters for calls to
octave_link::post_event fucntions.
* octave-link.h (octave_link::post_event, octave_link::do_post_event):
Define using variadic template for more flexibility and to eliminate
code duplication.
* pt-eval.h, pt-eval.cc (tree_evaluator::uwp_set_echo_state):
New function.
(tree_evaluator::set_echo_state, tree_evaluator::set_echo_file_name,
tree_evaluator::set_echo_file_pos): Delete.
(tree_evaluator::push_echo_state_cleanup): Use uwp_set_echo_state
instead of set_echo_state, set_echo_file_name, and set_echo_file_pos.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 20 Jul 2018 18:38:03 -0400 |
parents | 5960fd1b56f1 |
children | 00f796120a6d |
line wrap: on
line diff
--- a/liboctave/util/unwind-prot.h Fri Jul 20 13:09:19 2018 -0700 +++ b/liboctave/util/unwind-prot.h Fri Jul 20 18:38:03 2018 -0400 @@ -55,11 +55,6 @@ ~unwind_protect (void) { run (); } - virtual void add (elem *new_elem) - { - lifo.push (new_elem); - } - operator bool (void) const { return ! empty (); } void run_first (void) @@ -87,6 +82,11 @@ protected: + virtual void add_action (elem *new_elem) + { + lifo.push (new_elem); + } + std::stack<elem *> lifo; };