Mercurial > octave
annotate libinterp/octave.cc @ 33608:5fba13104493 bytecode-interpreter tip
maint: merge default to bytecode-interpreter.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Sat, 18 May 2024 22:40:00 -0400 |
parents | 79cfa1b7a813 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
32589
diff
changeset
|
3 // Copyright (C) 1993-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
26 // Born February 20, 1992. | |
27 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
28 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21220
diff
changeset
|
29 # include "config.h" |
1 | 30 #endif |
31 | |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
32 #include <iostream> |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22090
diff
changeset
|
33 #include <string> |
1355 | 34 |
4097 | 35 #include "file-ops.h" |
22064
bd4f3d2ce52f
provide wrapper for getopt
John W. Eaton <jwe@octave.org>
parents:
22051
diff
changeset
|
36 #include "getopt-wrapper.h" |
240 | 37 #include "lo-error.h" |
2926 | 38 #include "oct-env.h" |
1907 | 39 #include "str-vec.h" |
223 | 40 |
3933 | 41 #include "Cell.h" |
1355 | 42 #include "defun.h" |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
43 #include "display.h" |
1355 | 44 #include "error.h" |
1 | 45 #include "input.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22090
diff
changeset
|
46 #include "interpreter.h" |
4113 | 47 #include "octave.h" |
1742 | 48 #include "oct-hist.h" |
5654 | 49 #include "oct-map.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
50 #include "ovl.h" |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
51 #include "options.h" |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
52 #include "ov.h" |
1 | 53 #include "parse.h" |
22186
9aff1ce307b1
do system dependent and default variable inits early (bug #)
John W. Eaton <jwe@octave.org>
parents:
22101
diff
changeset
|
54 #include "sysdep.h" |
29898
dffd1c943f1a
main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29654
diff
changeset
|
55 #include "usage.h" |
1410 | 56 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31535
diff
changeset
|
57 OCTAVE_BEGIN_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
58 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
59 cmdline_options::cmdline_options () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
60 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
61 m_all_args.resize (1); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
62 m_all_args[0] = ""; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
63 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
64 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
65 cmdline_options::cmdline_options (int argc, char **argv) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
66 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
67 // Save raw program arguments. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
68 m_all_args = string_vector (argv, argc); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
69 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
70 while (true) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
71 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
72 int long_idx; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
73 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
74 int optc = octave_getopt_long_wrapper (argc, argv, short_opts, |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
75 long_opts, &long_idx); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
76 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
77 if (optc < 0) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
78 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
79 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
80 switch (optc) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
81 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
82 case '?': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
83 // Unrecognized option. getopt_long already printed a message about |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
84 // it, so we will just print the usage string and exit. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
85 octave_print_terse_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
86 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
87 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
88 case 'G': |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
89 m_gui = false; |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
90 break; |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
91 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
92 case 'H': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
93 m_read_history_file = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
94 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
95 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
96 case 'W': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
97 m_no_window_system = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
98 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
99 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
100 case 'V': |
32677
03dcf031fbf3
Deprecate '--verbose' option in favor of '--init-trace'.
Rik <rik@octave.org>
parents:
32671
diff
changeset
|
101 m_init_trace = true; |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
102 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
103 |
32671
fe4976232a24
Remove '--debug' option to octave executable.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
104 // FIXME: Disabled debug option for parser 2023-12-29. |
fe4976232a24
Remove '--debug' option to octave executable.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
105 // However, uncomment and restore option if Octave adds a debug option |
fe4976232a24
Remove '--debug' option to octave executable.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
106 // to immediately enter debug mode for a script. |
fe4976232a24
Remove '--debug' option to octave executable.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
107 // case 'd': |
fe4976232a24
Remove '--debug' option to octave executable.
Rik <rik@octave.org>
parents:
32669
diff
changeset
|
108 // break; |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
109 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
110 case 'e': |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
111 if (octave_optarg_wrapper ()) |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
112 { |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
113 if (m_code_to_eval.empty ()) |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
114 m_code_to_eval = octave_optarg_wrapper (); |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
115 else |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
116 m_code_to_eval += (std::string (" ") |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
117 + octave_optarg_wrapper ()); |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
118 } |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
119 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
120 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
121 case 'f': |
32678
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
122 m_read_user_files = false; |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
123 m_read_site_files = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
124 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
125 |
32669
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
126 case 'g': |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
127 m_gui = true; |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
128 break; |
b18af44b044b
Add new short form aliases of runtime long form options to octave.
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
129 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
130 case 'h': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
131 octave_print_verbose_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
132 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
133 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
134 case 'i': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
135 m_forced_interactive = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
136 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
137 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
138 case 'p': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
139 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
140 m_command_line_path.push_back (octave_optarg_wrapper ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
141 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
142 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
143 case 'q': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
144 m_inhibit_startup_message = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
145 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
146 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
147 case 'x': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
148 m_echo_commands = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
149 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
150 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
151 case 'v': |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
152 octave_print_version_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
153 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
154 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
155 case BUILT_IN_DOCSTRINGS_FILE_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
156 if (octave_optarg_wrapper ()) |
31932
2e135e3cb1aa
maint: replace double semicolon ';;' line ending with just ';'.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
157 m_docstrings_file = octave_optarg_wrapper (); |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
158 break; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
159 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
160 case DOC_CACHE_FILE_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
161 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
162 m_doc_cache_file = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
163 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
164 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
165 case EXEC_PATH_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
166 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
167 m_exec_path = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
168 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
169 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
170 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
171 #if defined (HAVE_QSCINTILLA) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
172 m_experimental_terminal_widget = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
173 #endif |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
174 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
175 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
176 case IMAGE_PATH_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
177 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
178 m_image_path = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
179 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
180 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
181 case INFO_FILE_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
182 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
183 m_info_file = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
184 break; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
185 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
186 case INFO_PROG_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
187 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
188 m_info_program = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
189 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
190 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
191 case LINE_EDITING_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
192 m_forced_line_editing = m_line_editing = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
193 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
194 |
32678
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
195 case NO_INIT_USER_OPTION: |
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
196 m_read_user_files = false; |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
197 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
198 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
199 case NO_INIT_PATH_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
200 m_set_initial_path = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
201 break; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
202 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
203 case NO_LINE_EDITING_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
204 m_line_editing = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
205 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
206 |
32678
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
207 case NO_INIT_SITE_OPTION: |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
208 m_read_site_files = false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
209 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
210 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
211 case PERSIST_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
212 m_persist = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
213 break; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
214 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
215 case SERVER_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
216 m_server = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
217 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
218 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
219 case TEXI_MACROS_FILE_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
220 if (octave_optarg_wrapper ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
221 m_texi_macros_file = octave_optarg_wrapper (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
222 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
223 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
224 case TRADITIONAL_OPTION: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
225 m_traditional = true; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
226 m_persist = true; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
227 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
228 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
229 default: |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
230 // getopt_long should print a message about unrecognized options and |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
231 // return '?', which is handled above. If we end up here, it is |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
232 // because there was an option but we forgot to handle it. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
233 // That should be fatal. |
33382
79cfa1b7a813
replace nearly all remaining uses of panic_impossible with error
John W. Eaton <jwe@octave.org>
parents:
32943
diff
changeset
|
234 |
79cfa1b7a813
replace nearly all remaining uses of panic_impossible with error
John W. Eaton <jwe@octave.org>
parents:
32943
diff
changeset
|
235 error ("unexpected option (= %d) - please reportt this bug", optc); |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
236 break; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
237 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
238 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
239 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
240 m_remaining_args = string_vector (argv+octave_optind_wrapper (), |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
241 argc-octave_optind_wrapper ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
242 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
243 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
244 octave_value |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
245 cmdline_options::as_octave_value () const |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
246 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
247 octave_scalar_map m; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
248 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
249 m.assign ("sys_argc", sys_argc ()); |
32710
c3a339799a27
Fix memory leak in cmdline_options().
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
250 m.assign ("sys_argv", Cell (all_args ())); |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
251 m.assign ("echo_commands", echo_commands ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
252 m.assign ("forced_interactive", forced_interactive ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
253 m.assign ("forced_line_editing", forced_line_editing ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
254 m.assign ("gui", gui ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
255 m.assign ("inhibit_startup_message", inhibit_startup_message ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
256 m.assign ("line_editing", line_editing ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
257 m.assign ("no_window_system", no_window_system ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
258 m.assign ("persist", persist ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
259 m.assign ("read_history_file", read_history_file ()); |
32678
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
260 // FIXME: read_init_files deprecated in Octave 10 in favor of read_user_files |
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
261 m.assign ("read_init_files", read_user_files ()); |
49d6ecd07a76
Rename command-line options for handling configuration files.
Rik <rik@octave.org>
parents:
32677
diff
changeset
|
262 m.assign ("read_user_files", read_user_files ()); |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
263 m.assign ("read_site_files", read_site_files ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
264 m.assign ("server", server ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
265 m.assign ("set_initial_path", set_initial_path ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
266 m.assign ("traditional", traditional ()); |
32677
03dcf031fbf3
Deprecate '--verbose' option in favor of '--init-trace'.
Rik <rik@octave.org>
parents:
32671
diff
changeset
|
267 m.assign ("init_trace", init_trace ()); |
03dcf031fbf3
Deprecate '--verbose' option in favor of '--init-trace'.
Rik <rik@octave.org>
parents:
32671
diff
changeset
|
268 // FIXME: --verbose deprecated in Octave 10. Remove in Octave 12. |
03dcf031fbf3
Deprecate '--verbose' option in favor of '--init-trace'.
Rik <rik@octave.org>
parents:
32671
diff
changeset
|
269 m.assign ("verbose", init_trace ()); |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
270 m.assign ("code_to_eval", code_to_eval ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
271 m.assign ("command_line_path", string_vector (command_line_path ())); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
272 m.assign ("docstrings_file", docstrings_file ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
273 m.assign ("doc_cache_file", doc_cache_file ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
274 m.assign ("exec_path", exec_path ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
275 m.assign ("image_path", image_path ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
276 m.assign ("info_file", info_file ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
277 m.assign ("info_program", info_program ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
278 m.assign ("texi_macros_file", texi_macros_file ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
279 m.assign ("all_args", Cell (all_args ())); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
280 m.assign ("remaining_args", Cell (remaining_args ())); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
281 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
282 return m; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
283 } |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
284 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
285 application *application::s_instance = nullptr; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
286 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
287 application::application (int argc, char **argv) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
288 : m_options (argc, argv) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
289 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
290 init (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
291 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
292 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
293 application::application (const cmdline_options& opts) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
294 : m_options (opts) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
295 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
296 init (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
297 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
298 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
299 // Note: Although the application destructor doesn't explicitly |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
300 // perform any actions, it can't be declared "default" in the header |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
301 // file if the interpreter is an incomplete type. Providing |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
302 // an explicit definition of the destructor here is much simpler than |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
303 // including the full declaration of interpreter in the |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
304 // octave.h header file. |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
305 application::~application () { } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
306 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
307 void |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
308 application::set_program_names (const std::string& pname) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
309 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
310 m_program_invocation_name = pname; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
311 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
312 std::size_t pos = pname.find_last_of (sys::file_ops::dir_sep_chars ()); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
313 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
314 m_program_name = (pos != std::string::npos) ? pname.substr (pos+1) : pname; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
315 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
316 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
317 void |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
318 application::intern_argv (const string_vector& args) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
319 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
320 octave_idx_type nargs = args.numel (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
321 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
322 if (nargs > 0) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
323 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
324 // Skip first argument (program name). |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
325 nargs--; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
326 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
327 m_argv.resize (nargs); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
328 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
329 for (octave_idx_type i = 0; i < nargs; i++) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
330 m_argv[i] = args[i+1]; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
331 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
332 } |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
333 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
334 bool |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
335 application::forced_interactive () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
336 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
337 return s_instance ? s_instance->m_options.forced_interactive () : false; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
338 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
339 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
340 // Provided for convenience. Will be removed once we eliminate the |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
341 // old terminal widget. |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
342 bool |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
343 application::experimental_terminal_widget () const |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
344 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
345 return (s_instance |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
346 ? s_instance->m_options.experimental_terminal_widget () : false); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
347 } |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
348 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
349 bool |
32942
c854ec36dcbe
rename and deprecate application::interpreter_initialized
John W. Eaton <jwe@octave.org>
parents:
32941
diff
changeset
|
350 application::interpreter_is_initialized () const |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
351 { |
32941
3085687255dc
rename and deprecate interpreter::initialized
John W. Eaton <jwe@octave.org>
parents:
32710
diff
changeset
|
352 return m_interpreter ? m_interpreter->is_initialized () : false; |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
353 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
354 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
355 interpreter& |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
356 application::create_interpreter () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
357 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
358 if (! m_interpreter) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
359 m_interpreter = std::unique_ptr<interpreter> (new interpreter (this)); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
360 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
361 return *m_interpreter; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
362 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
363 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
364 void |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
365 application::initialize_interpreter () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
366 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
367 if (m_interpreter) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
368 m_interpreter->initialize (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
369 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
370 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
371 int |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
372 application::execute_interpreter () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
373 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
374 return m_interpreter ? m_interpreter->execute () : -1; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
375 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
376 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
377 void |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
378 application::delete_interpreter () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
379 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
380 m_interpreter.reset (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
381 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
382 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
383 void |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
384 application::init () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
385 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
386 if (s_instance) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
387 throw std::runtime_error |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
388 ("only one Octave application object may be active"); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
389 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
390 s_instance = this; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
391 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
392 string_vector all_args = m_options.all_args (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
393 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
394 set_program_names (all_args[0]); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
395 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
396 string_vector remaining_args = m_options.remaining_args (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
397 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
398 std::string code_to_eval = m_options.code_to_eval (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
399 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
400 m_have_script_file = ! remaining_args.empty (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
401 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
402 m_have_eval_option_code = ! code_to_eval.empty (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
403 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
404 if (m_have_eval_option_code && m_have_script_file) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
405 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
406 std::cerr << R"(error: --eval "CODE" and script file are mutually exclusive options)" << std::endl; |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
407 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
408 octave_print_terse_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
409 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
410 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
411 if (m_options.gui ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
412 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
413 if (m_options.no_window_system ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
414 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
415 std::cerr << "error: --gui and --no-window-system are mutually exclusive options" << std::endl; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
416 octave_print_terse_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
417 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
418 if (! m_options.line_editing ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
419 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
420 std::cerr << "error: --gui and --no-line-editing are mutually exclusive options" << std::endl; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
421 octave_print_terse_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
422 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
423 if (m_options.server ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
424 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
425 std::cerr << "error: --gui and --server are mutually exclusive options" << std::endl; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
426 octave_print_terse_usage_and_exit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
427 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
428 } |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
429 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
430 m_is_octave_program = ((m_have_script_file || m_have_eval_option_code) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
431 && ! m_options.persist () |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
432 && ! m_options.traditional ()); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
433 |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
434 // This should probably happen early. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
435 sysdep_init (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
436 } |
24874
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
437 |
32589
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
438 int |
05b4479c29d8
maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents:
31934
diff
changeset
|
439 cli_application::execute () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
440 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
441 interpreter& interp = create_interpreter (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
442 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
443 int status = interp.execute (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
444 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
445 return status; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
446 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
447 |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
448 DEFUN (isguirunning, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
449 doc: /* -*- texinfo -*- |
30559
841a10208c38
doc: Use TF for output variable in documentation for isXXX functions in libinterp/ directory.
Rik <rik@octave.org>
parents:
30409
diff
changeset
|
450 @deftypefn {} {@var{tf} =} isguirunning () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
451 Return true if Octave is running in GUI mode and false otherwise. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
452 @seealso{have_window_system} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
453 @end deftypefn */) |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
454 { |
20849
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20756
diff
changeset
|
455 if (args.length () != 0) |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
456 print_usage (); |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
457 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
458 // FIXME: This isn't quite right, it just says that we intended to |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
459 // start the GUI, not that it is actually running. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
460 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
461 return ovl (application::is_gui_running ()); |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
462 } |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
463 |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
464 /* |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
465 %!assert (islogical (isguirunning ())) |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
466 %!error <Invalid call> isguirunning (1) |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
467 */ |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
468 |
5780 | 469 DEFUN (argv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
470 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
471 @deftypefn {} {@var{args} =} argv () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
472 Return the command line arguments passed to Octave. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
473 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
474 For example, if you invoked Octave using the command |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
475 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
476 @example |
32680
25e8f63da459
Prefer --quiet to --silent in Octave.
Rik <rik@octave.org>
parents:
32678
diff
changeset
|
477 octave --no-line-editing --quiet |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
478 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
479 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
480 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
481 @code{argv} would return a cell array of strings with the elements |
32680
25e8f63da459
Prefer --quiet to --silent in Octave.
Rik <rik@octave.org>
parents:
32678
diff
changeset
|
482 @option{--no-line-editing} and @option{--quiet}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
483 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
484 If you write an executable Octave script, @code{argv} will return the list |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
485 of arguments passed to the script. @xref{Executable Octave Programs}, for |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
486 an example of how to create an executable Octave script. |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
487 @seealso{program_name, cmdline_options} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
488 @end deftypefn */) |
5780 | 489 { |
20849
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20756
diff
changeset
|
490 if (args.length () != 0) |
5823 | 491 print_usage (); |
5780 | 492 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
493 return ovl (Cell (application::argv ())); |
5780 | 494 } |
495 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
496 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
497 %!assert (iscellstr (argv ())) |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
498 %!error <Invalid call> argv (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
499 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
500 |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
501 DEFUN (cmdline_options, args, , |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
502 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
503 @deftypefn {} {@var{opt_struct} =} cmdline_options () |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
504 Return a structure containing detailed information about the command line |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
505 arguments passed to Octave. |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
506 |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
507 Programming Note: This function provides copious amounts of information about |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
508 Octave's parsing of command line options and may be more useful for debugging |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
509 Octave rather than for general use. |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
510 @seealso{argv, program_name} |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
511 @end deftypefn */) |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
512 { |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
513 if (args.length () != 0) |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
514 print_usage (); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
515 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
516 application *app = application::app (); |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
517 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
518 if (! app) |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
519 error ("invalid application context!"); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
520 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
521 cmdline_options opts = app->options (); |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
522 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
523 return ovl (opts.as_octave_value ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
524 } |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
525 |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
526 /* |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
527 %!assert (isstruct (cmdline_options ())) |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
528 %!error <Invalid call> cmdline_options (1) |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
529 */ |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
530 |
5780 | 531 DEFUN (program_invocation_name, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
532 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
533 @deftypefn {} {@var{name} =} program_invocation_name () |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
534 Return the string that was typed at the shell prompt to run Octave. |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
535 |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
536 The string may include path components as well as the program filename. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
537 |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
538 If executing a script from the command line (e.g., @code{octave foo.m}) or |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
539 using an executable Octave script, the program name is set to the name of the |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
540 script. @xref{Executable Octave Programs}, for an example of how to create an |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
541 executable Octave script. |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
542 @seealso{program_name, argv} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
543 @end deftypefn */) |
5780 | 544 { |
20849
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20756
diff
changeset
|
545 if (args.length () != 0) |
5823 | 546 print_usage (); |
5780 | 547 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
548 return ovl (application::program_invocation_name ()); |
5780 | 549 } |
550 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
551 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
552 %!assert (ischar (program_invocation_name ())) |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
553 %!error <Invalid call> program_invocation_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
554 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
555 |
5780 | 556 DEFUN (program_name, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
557 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
558 @deftypefn {} {@var{name} =} program_name () |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
559 Return the filename component of the value returned by |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
560 @code{program_invocation_name}. |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
561 |
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
562 @seealso{program_invocation_name, argv} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
563 @end deftypefn */) |
5780 | 564 { |
20849
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20756
diff
changeset
|
565 if (args.length () != 0) |
5823 | 566 print_usage (); |
5780 | 567 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
568 return ovl (application::program_name ()); |
5780 | 569 } |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
570 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
571 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
572 %!assert (ischar (program_name ())) |
31535
4b80982e0af8
doc: Add undocumented functions to Octave manual for 8.1 release.
Rik <rik@octave.org>
parents:
31222
diff
changeset
|
573 %!error <Invalid call> program_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
574 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
575 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31535
diff
changeset
|
576 OCTAVE_END_NAMESPACE(octave) |