changeset 16416:169f71c9d9c8

use octave_link instead of hook functions in input.cc * octave-main-thread.cc pre_input_event_hook_fcn, post_input_event_hook_fcn, enter_debugger_event_hook_fcn, exit_debugger_event_hook_fcn): Delete. (octave_main_thread::run): Don't install input and debugging hooks. * input.cc (pre_input_event_hook_functions, post_input_event_hook_functions, enter_debugger_event_hook_functions, exit_debugger_event_hook_functions): Delete. (octave_base_reader::octave_gets, get_debug_input): Use octave_link instead of calling hook functions. (exit_debugger_cleanup): Delete. (Fadd_pre_input_event_hook, Fremove_pre_input_event_hook, Fadd_post_input_event_hook, Fremove_post_input_event_hook, Fadd_enter_debugger_event_hook, Fremove_enter_debugger_event_hook, Fadd_exit_debugger_event_hook, Fremove_exit_debugger_event_hook): Delete.
author John W. Eaton <jwe@octave.org>
date Wed, 03 Apr 2013 18:30:23 -0400
parents 70032fc70bee
children ad070b353e59
files libgui/src/octave-main-thread.cc libinterp/interpfcn/input.cc
diffstat 2 files changed, 7 insertions(+), 440 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/octave-main-thread.cc	Wed Apr 03 18:11:55 2013 -0400
+++ b/libgui/src/octave-main-thread.cc	Wed Apr 03 18:30:23 2013 -0400
@@ -36,46 +36,6 @@
 #include "octave-link.h"
 
 static octave_value_list
-pre_input_event_hook_fcn (const octave_value_list&, int)
-{
-  octave_value_list retval;
-
-  octave_link::pre_input_event ();
-
-  return retval;
-}
-
-static octave_value_list
-post_input_event_hook_fcn (const octave_value_list&, int)
-{
-  octave_value_list retval;
-
-  octave_link::post_input_event ();
-
-  return retval;
-}
-
-static octave_value_list
-enter_debugger_event_hook_fcn (const octave_value_list& args, int)
-{
-  octave_value_list retval;
-
-  octave_link::enter_debugger_event (args);
-
-  return retval;
-}
-
-static octave_value_list
-exit_debugger_event_hook_fcn (const octave_value_list& args, int)
-{
-  octave_value_list retval;
-
-  octave_link::exit_debugger_event (args);
-
-  return retval;
-}
-
-static octave_value_list
 dbstop_hook_fcn (const octave_value_list& args, int)
 {
   octave_value_list retval;
@@ -120,22 +80,6 @@
   octave_initialize_interpreter (octave_cmdline_argc, octave_cmdline_argv,
                                  octave_embedded);
 
-  octave_value pre_fcn (new octave_builtin (pre_input_event_hook_fcn));
-  octave_value pre_fcn_handle (new octave_fcn_handle (pre_fcn));
-  Fadd_pre_input_event_hook (pre_fcn_handle);
-
-  octave_value post_fcn (new octave_builtin (post_input_event_hook_fcn));
-  octave_value post_fcn_handle (new octave_fcn_handle (post_fcn));
-  Fadd_post_input_event_hook (post_fcn_handle);
-
-  octave_value enter_debugger_fcn (new octave_builtin (enter_debugger_event_hook_fcn));
-  octave_value enter_debugger_fcn_handle (new octave_fcn_handle (enter_debugger_fcn));
-  Fadd_enter_debugger_event_hook (enter_debugger_fcn_handle);
-
-  octave_value exit_debugger_fcn (new octave_builtin (exit_debugger_event_hook_fcn));
-  octave_value exit_debugger_fcn_handle (new octave_fcn_handle (exit_debugger_fcn));
-  Fadd_exit_debugger_event_hook (exit_debugger_fcn_handle);
-
   octave_value dbstop_fcn (new octave_builtin (dbstop_hook_fcn));
   octave_value dbstop_fcn_handle (new octave_fcn_handle (dbstop_fcn));
   Fadd_dbstop_hook (dbstop_fcn_handle);
--- a/libinterp/interpfcn/input.cc	Wed Apr 03 18:11:55 2013 -0400
+++ b/libinterp/interpfcn/input.cc	Wed Apr 03 18:30:23 2013 -0400
@@ -53,6 +53,7 @@
 #include "input.h"
 #include "lex.h"
 #include "load-path.h"
+#include "octave-link.h"
 #include "oct-map.h"
 #include "oct-hist.h"
 #include "toplev.h"
@@ -122,11 +123,7 @@
 // The filemarker used to separate filenames from subfunction names
 char Vfilemarker = '>';
 
-static hook_function_list pre_input_event_hook_functions;
 static hook_function_list input_event_hook_functions;
-static hook_function_list post_input_event_hook_functions;
-static hook_function_list enter_debugger_event_hook_functions;
-static hook_function_list exit_debugger_event_hook_functions;
 
 // For octave_quit.
 void
@@ -215,7 +212,7 @@
   // printing the prompt.
 
   if (interactive || forced_interactive)
-    pre_input_event_hook_functions.run ();
+    octave_link::pre_input_event ();
 
   bool history_skip_auto_repeated_debugging_command = false;
 
@@ -271,7 +268,7 @@
   // list has been updated.
 
   if (interactive || forced_interactive)
-    post_input_event_hook_functions.run ();
+    octave_link::pre_input_event ();
 
   return retval;
 }
@@ -458,12 +455,6 @@
 }
 
 static void
-exit_debugger_cleanup (const octave_value& loc_info)
-{
-  exit_debugger_event_hook_functions.run (loc_info);
-}
-
-static void
 get_debug_input (const std::string& prompt)
 {
   unwind_protect frame;
@@ -512,9 +503,11 @@
             {
               octave_value loc_info = location_info (nm, curr_debug_line);
 
-              enter_debugger_event_hook_functions.run (loc_info);
+              octave_value_list args (loc_info);
 
-              frame.add_fcn (exit_debugger_cleanup, loc_info);
+              octave_link::enter_debugger_event (args);
+
+              frame.add_fcn (octave_link::exit_debugger_event, args);
 
               std::string line_buf
                 = get_file_line (nm, curr_debug_line);
@@ -1091,94 +1084,6 @@
   return retval;
 }
 
-DEFUN (add_pre_input_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {@var{id} =} add_pre_input_event_hook (@var{fcn})\n\
-@deftypefnx {Built-in Function} {@var{id} =} add_pre_input_event_hook (@var{fcn}, @var{data})\n\
-Add the named function or function handle @var{fcn} to the list of functions to call\n\
-immediately prior to prompting for interactive user input.  The\n\
-function should have the form\n\
-\n\
-@example\n\
-@var{fcn} (@var{data})\n\
-@end example\n\
-\n\
-If @var{data} is omitted, Octave calls the function without any\n\
-arguments.\n\
-\n\
-The returned identifier may be used to remove the function handle from\n\
-the list of input hook functions.\n\
-@seealso{remove_pre_input_event_hook}\n\
-@end deftypefn")
-{
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (! error_state)
-        {
-          pre_input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-          retval = hook_fcn.id ();
-        }
-      else
-        error ("add_pre_input_event_hook: expecting string as first arg");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (remove_pre_input_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} remove_pre_input_event_hook (@var{name})\n\
-@deftypefnx {Built-in Function} {} remove_input_event_hook (@var{fcn_id})\n\
-Remove the named function or function handle with the given identifier\n\
-from the list of functions to call immediately prior to prompting for\n\
-interactive user input.\n\
-@seealso{add_pre_input_event_hook}\n\
-@end deftypefn")
-{
-  octave_value_list retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ();
-
-      bool warn = (nargin < 2);
-
-      if (! error_state)
-        {
-          hook_function_list::iterator p
-            = pre_input_event_hook_functions.find (hook_fcn_id);
-
-          if (p != pre_input_event_hook_functions.end ())
-            pre_input_event_hook_functions.erase (p);
-          else if (warn)
-            warning ("remove_pre_input_event_hook: %s not found in list",
-                     hook_fcn_id.c_str ());
-        }
-      else
-        error ("remove_pre_input_event_hook: argument not valid as a hook function name or id");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
- 
 static int
 internal_input_event_hook_fcn (void)
 {
@@ -1284,288 +1189,6 @@
   return retval;
 }
 
-DEFUN (add_post_input_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {@var{id} =} add_post_input_event_hook (@var{fcn})\n\
-@deftypefnx {Built-in Function} {@var{id} =} add_post_input_event_hook (@var{fcn}, @var{data})\n\
-Add the named function or function handle @var{fcn} to the list of functions to call\n\
-immediately after accepting interactive user input.  The function\n\
-should have the form\n\
-\n\
-@example\n\
-@var{fcn} (@var{data})\n\
-@end example\n\
-\n\
-If @var{data} is omitted, Octave calls the function without any\n\
-arguments.\n\
-\n\
-The returned identifier may be used to remove the function handle from\n\
-the list of input hook functions.\n\
-@seealso{remove_post_input_event_hook}\n\
-@end deftypefn")
-{
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (! error_state)
-        {
-          post_input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-          retval = hook_fcn.id ();
-        }
-      else
-        error ("add_post_input_event_hook: expecting string as first arg");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (remove_post_input_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} remove_post_input_event_hook (@var{name})\n\
-@deftypefnx {Built-in Function} {} remove_post_input_event_hook (@var{fcn_id})\n\
-Remove the named function or function handle with the given identifier\n\
-from the list of functions to call immediately after accepting\n\
-interactive user input.\n\
-@seealso{add_post_input_event_hook}\n\
-@end deftypefn")
-{
-  octave_value_list retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ();
-
-      bool warn = (nargin < 2);
-
-      if (! error_state)
-        {
-          hook_function_list::iterator p
-            = post_input_event_hook_functions.find (hook_fcn_id);
-
-          if (p != post_input_event_hook_functions.end ())
-            post_input_event_hook_functions.erase (p);
-          else if (warn)
-            warning ("remove_post_input_event_hook: %s not found in list",
-                     hook_fcn_id.c_str ());
-        }
-      else
-        error ("remove_post_input_event_hook: argument not valid as a hook function name or id");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (add_enter_debugger_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {@var{id} =} add_enter_debugger_event_hook (@var{fcn})\n\
-@deftypefnx {Built-in Function} {@var{id} =} add_enter_debugger_event_hook (@var{fcn}, @var{data})\n\
-Add the named function or function handle @var{fcn} to the list of\n\
-functions to call when a debugger breakpoint is reached.  The function\n\
-should have the form\n\
-\n\
-@example\n\
-@var{fcn} (@var{location}, @var{data})\n\
-@end example\n\
-\n\
-in which @var{location} is a structure containing the following elements:\n\
-\n\
-@table @code\n\
-@item file\n\
-The name of the file where the breakpoint is located.\n\
-@item line\n\
-The line number corresponding to the breakpoint.\n\
-@end table\n\
-\n\
-If @var{data} is omitted when the hook function is added, the hook\n\
-function is called with a single argument.\n\
-\n\
-The returned identifier may be used to remove the function handle from\n\
-the list of input hook functions.\n\
-@seealso{remove_enter_debugger_event_hook}\n\
-@end deftypefn")
-{
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (! error_state)
-        {
-          enter_debugger_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-          retval = hook_fcn.id ();
-        }
-      else
-        error ("add_enter_debugger_event_hook: expecting string as first arg");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (remove_enter_debugger_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} remove_enter_debugger_event_hook (@var{name})\n\
-@deftypefnx {Built-in Function} {} remove_enter_debugger_event_hook (@var{fcn_id})\n\
-Remove the named function or function handle with the given identifier\n\
-from the list of functions to call immediately after accepting\n\
-interactive user input.\n\
-@seealso{add_enter_debugger_event_hook}\n\
-@end deftypefn")
-{
-  octave_value_list retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ();
-
-      bool warn = (nargin < 2);
-
-      if (! error_state)
-        {
-          hook_function_list::iterator p
-            = enter_debugger_event_hook_functions.find (hook_fcn_id);
-
-          if (p != enter_debugger_event_hook_functions.end ())
-            enter_debugger_event_hook_functions.erase (p);
-          else if (warn)
-            warning ("remove_enter_debugger_event_hook: %s not found in list",
-                     hook_fcn_id.c_str ());
-        }
-      else
-        error ("remove_enter_debugger_event_hook: argument not valid as a hook function name or id");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (add_exit_debugger_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {@var{id} =} add_exit_debugger_event_hook (@var{fcn})\n\
-@deftypefnx {Built-in Function} {@var{id} =} add_exit_debugger_event_hook (@var{fcn}, @var{data})\n\
-Add the named function or function handle @var{fcn} to the list of\n\
-functions to call when continuing execution after a debugger breakpoint.\n\
-The function should have the form\n\
-\n\
-@example\n\
-@var{fcn} (@var{location}, @var{data})\n\
-@end example\n\
-\n\
-in which @var{location} is a structure containing the following elements:\n\
-\n\
-@table @code\n\
-@item file\n\
-The name of the file where the breakpoint is located.\n\
-@item line\n\
-The line number corresponding to the breakpoint.\n\
-@end table\n\
-\n\
-If @var{data} is omitted when the hook function is added, the hook\n\
-function is called with a single argument.\n\
-\n\
-The returned identifier may be used to remove the function handle from\n\
-the list of input hook functions.\n\
-@seealso{remove_exit_debugger_event_hook}\n\
-@end deftypefn")
-{
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (! error_state)
-        {
-          exit_debugger_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-          retval = hook_fcn.id ();
-        }
-      else
-        error ("add_exit_debugger_event_hook: expecting string as first arg");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
-DEFUN (remove_exit_debugger_event_hook, args, ,
-  "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} remove_exit_debugger_event_hook (@var{name})\n\
-@deftypefnx {Built-in Function} {} remove_exit_debugger_event_hook (@var{fcn_id})\n\
-Remove the named function or function handle with the given identifier\n\
-from the list of functions to call immediately after accepting\n\
-interactive user input.\n\
-@seealso{add_exit_debugger_event_hook}\n\
-@end deftypefn")
-{
-  octave_value_list retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ();
-
-      bool warn = (nargin < 2);
-
-      if (! error_state)
-        {
-          hook_function_list::iterator p
-            = exit_debugger_event_hook_functions.find (hook_fcn_id);
-
-          if (p != exit_debugger_event_hook_functions.end ())
-            exit_debugger_event_hook_functions.erase (p);
-          else if (warn)
-            warning ("remove_exit_debugger_event_hook: %s not found in list",
-                     hook_fcn_id.c_str ());
-        }
-      else
-        error ("remove_exit_debugger_event_hook: argument not valid as a hook function name or id");
-    }
-  else
-    print_usage ();
-
-  return retval;
-}
-
 DEFUN (PS1, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{val} =} PS1 ()\n\