Mercurial > hg > octave-terminal
changeset 15420:1249a615c91b
call built-in functions directly in GUI callbacks
* main-window.cc: Include builtins.h instead of debug.h and
variables.h.
(main_window::save_workspace_callback): Call Fsave directly.
(main_window::load_workspace_callback): Call Fload directly.
(main_window::clear_workspace_callback):Call Fclear directly.
(main_window::change_directory_callback): Call Fcd, not
octave_env::chdir.
(main_window::debug_continue_callback): Call Fdbcont directly.
(main_window::debug_step_into_callback): Call Fdbstep directly.
(main_window::debug_step_over_callback): Call Fdbstep directly.
(main_window::debug_step_out_callback): Call Fdbstep directly.
(main_window::debug_quit_callback): Call Fdbquit directly.
(main_window::exit_callback): Call Fquit directly.
* oct-obj.h (ovl): New functions.
* debug.cc, debug.h (debug_step, debug_quit, debug_continue): Delete.
* load-save.cc, load-save.h (load_workspace, save_workspace): Delete.
* variables.cc, varaibles.h (clear_current_scope): Delete.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 19 Sep 2012 14:38:47 -0400 |
parents | 2afbe4295682 |
children | cd6ce11b9c57 |
files | libgui/src/main-window.cc libinterp/interp-core/oct-obj.h libinterp/interpfcn/debug.cc libinterp/interpfcn/debug.h libinterp/interpfcn/load-save.cc libinterp/interpfcn/load-save.h libinterp/interpfcn/variables.cc libinterp/interpfcn/variables.h |
diffstat | 8 files changed, 159 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -42,11 +42,10 @@ #include "octave-link.h" #include "settings-dialog.h" -#include "debug.h" +#include "builtins.h" #include "defaults.h" #include "load-save.h" #include "toplev.h" -#include "variables.h" #include "version.h" #include "cmd-hist.h" @@ -871,19 +870,19 @@ void main_window::save_workspace_callback (const std::string& file) { - save_workspace (file); + Fsave (ovl (file)); } void main_window::load_workspace_callback (const std::string& file) { - load_workspace (file); + Fload (ovl (file)); } void main_window::clear_workspace_callback (void) { - clear_current_scope (); + Fclear (); } void @@ -897,41 +896,41 @@ void main_window::change_directory_callback (const std::string& directory) { - octave_env::chdir (directory); + Fcd (ovl (directory)); } void main_window::debug_continue_callback (void) { - debug_continue (); + Fdbcont (); } void main_window::debug_step_into_callback (void) { - debug_step ("in"); + Fdbstep (ovl ("in")); } void main_window::debug_step_over_callback (void) { - debug_step (); + Fdbstep (); } void main_window::debug_step_out_callback (void) { - debug_step ("out"); + Fdbstep (ovl ("out")); } void main_window::debug_quit_callback (void) { - debug_quit (); + Fdbquit (); } void main_window::exit_callback (void) { - clean_up_and_exit (0); + Fquit (); }
--- a/libinterp/interp-core/oct-obj.h +++ b/libinterp/interp-core/oct-obj.h @@ -166,4 +166,152 @@ DECLARE_OCTAVE_ALLOCATOR }; +// Make it easy to build argument lists for built-in functions or for +// returning values. + +inline octave_value_list +ovl (const octave_value& a0) +{ + octave_value_list retval; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1) +{ + octave_value_list retval; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2) +{ + octave_value_list retval; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3) +{ + octave_value_list retval; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4) +{ + octave_value_list retval; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4, const octave_value& a5) +{ + octave_value_list retval; + retval(5) = a5; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4, const octave_value& a5, + const octave_value& a6) +{ + octave_value_list retval; + retval(6) = a6; + retval(5) = a5; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4, const octave_value& a5, + const octave_value& a6, const octave_value& a7) +{ + octave_value_list retval; + retval(7) = a7; + retval(6) = a6; + retval(5) = a5; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4, const octave_value& a5, + const octave_value& a6, const octave_value& a7, + const octave_value& a8) +{ + octave_value_list retval; + retval(8) = a8; + retval(7) = a7; + retval(6) = a6; + retval(5) = a5; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + +inline octave_value_list +ovl (const octave_value& a0, const octave_value& a1, + const octave_value& a2, const octave_value& a3, + const octave_value& a4, const octave_value& a5, + const octave_value& a6, const octave_value& a7, + const octave_value& a8, const octave_value& a9) +{ + octave_value_list retval; + retval(9) = a9; + retval(8) = a8; + retval(7) = a7; + retval(6) = a6; + retval(5) = a5; + retval(4) = a4; + retval(3) = a3; + retval(2) = a2; + retval(1) = a1; + retval(0) = a0; + return retval; +} + #endif
--- a/libinterp/interpfcn/debug.cc +++ b/libinterp/interpfcn/debug.cc @@ -1201,17 +1201,6 @@ DEFALIAS (dbnext, dbstep); -void -debug_step (const std::string& what) -{ - octave_value_list args; - - if (! what.empty ()) - args(0) = what; - - Fdbstep (args); -} - DEFUN (dbcont, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} dbcont\n\ @@ -1236,12 +1225,6 @@ return octave_value_list (); } -void -debug_continue (void) -{ - Fdbcont (); -} - DEFUN (dbquit, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} dbquit\n\ @@ -1269,12 +1252,6 @@ return octave_value_list (); } -void -debug_quit (void) -{ - Fdbquit (); -} - DEFUN (isdebugmode, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isdebugmode ()\n\
--- a/libinterp/interpfcn/debug.h +++ b/libinterp/interpfcn/debug.h @@ -131,10 +131,4 @@ extern std::string get_file_line (const std::string& fname, size_t line); -extern void OCTINTERP_API debug_continue (void); - -extern void OCTINTERP_API debug_step (const std::string& what = std::string ()); - -extern void OCTINTERP_API debug_quit (void); - #endif
--- a/libinterp/interpfcn/load-save.cc +++ b/libinterp/interpfcn/load-save.cc @@ -1443,17 +1443,6 @@ } } -void -load_workspace (const std::string& file) -{ - octave_value_list args; - - if (! file.empty ()) - args(0) = file; - - Fload (args); -} - DEFUN (save, args, , "-*- texinfo -*-\n\ @deftypefn {Command} {} save file\n\ @@ -1755,17 +1744,6 @@ return retval; } -void -save_workspace (const std::string& file) -{ - octave_value_list args; - - if (! file.empty ()) - args(0) = file; - - Fsave (args); -} - DEFUN (crash_dumps_octave_core, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} crash_dumps_octave_core ()\n\
--- a/libinterp/interpfcn/load-save.h +++ b/libinterp/interpfcn/load-save.h @@ -87,7 +87,4 @@ extern void write_header (std::ostream& os, load_save_format format); -extern OCTINTERP_API void load_workspace (const std::string& file); -extern OCTINTERP_API void save_workspace (const std::string& file); - #endif
--- a/libinterp/interpfcn/variables.cc +++ b/libinterp/interpfcn/variables.cc @@ -2460,12 +2460,6 @@ return retval; } -void -clear_current_scope (void) -{ - Fclear (); -} - DEFUN (whos_line_format, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} whos_line_format ()\n\