Mercurial > octave
annotate libinterp/octave.cc @ 31231:a026fb2be108
sparse-xpow.cc: Return empty matrix for empty input (bug #63080)
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Mon, 19 Sep 2022 07:05:31 -0400 |
parents | 1a0756f7c90a |
children | 4b80982e0af8 |
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 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30160
diff
changeset
|
3 // Copyright (C) 1993-2022 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 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
57 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
58 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
59 cmdline_options::cmdline_options (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
60 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
61 m_all_args.resize (1); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
62 m_all_args[0] = ""; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
63 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
64 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
65 cmdline_options::cmdline_options (int argc, char **argv) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
66 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
67 // Save raw program arguments. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
68 m_all_args = string_vector (argv, argc); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
69 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
70 while (true) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
71 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
72 int long_idx; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
73 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
74 int optc = octave_getopt_long_wrapper (argc, argv, short_opts, |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
75 long_opts, &long_idx); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
76 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
77 if (optc < 0) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
78 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
79 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
80 switch (optc) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
81 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
82 case '?': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
83 // Unrecognized option. getopt_long already printed a message about |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
84 // it, so we will just print the usage string and exit. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
85 octave_print_terse_usage_and_exit (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
86 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
87 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
88 case 'H': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
89 m_read_history_file = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
90 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
91 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
92 case 'W': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
93 m_no_window_system = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
94 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
95 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
96 case 'V': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
97 m_verbose_flag = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
98 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
99 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
100 case 'd': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
101 // This is the same as yydebug in parse.y. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
102 octave_debug++; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
103 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
104 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
105 case 'f': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
106 m_read_init_files = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
107 m_read_site_files = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
108 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
109 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
110 case 'h': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
111 octave_print_verbose_usage_and_exit (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
112 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
113 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
114 case 'i': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
115 m_forced_interactive = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
116 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
117 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
118 case 'p': |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
119 if (octave_optarg_wrapper ()) |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
120 m_command_line_path.push_back (octave_optarg_wrapper ()); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
121 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
122 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
123 case 'q': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
124 m_inhibit_startup_message = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
125 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
126 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
127 case 'x': |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
128 m_echo_commands = true; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
129 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
130 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
131 case 'v': |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
132 octave_print_version_and_exit (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
133 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
134 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
135 case BUILT_IN_DOCSTRINGS_FILE_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
136 if (octave_optarg_wrapper ()) |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
137 m_docstrings_file = octave_optarg_wrapper ();; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
138 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
139 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
140 case DOC_CACHE_FILE_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
141 if (octave_optarg_wrapper ()) |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
142 m_doc_cache_file = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
143 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
144 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
145 case EVAL_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
146 if (octave_optarg_wrapper ()) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
147 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
148 if (m_code_to_eval.empty ()) |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
149 m_code_to_eval = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
150 else |
23857
4d4ba038d103
Restore processing multiple '--eval' lines when launching Octave (bug #51708).
Rik <rik@octave.org>
parents:
23819
diff
changeset
|
151 m_code_to_eval += (std::string (" ") |
4d4ba038d103
Restore processing multiple '--eval' lines when launching Octave (bug #51708).
Rik <rik@octave.org>
parents:
23819
diff
changeset
|
152 + octave_optarg_wrapper ()); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
153 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
154 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
155 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
156 case EXEC_PATH_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
157 if (octave_optarg_wrapper ()) |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
158 m_exec_path = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
159 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
160 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
161 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION: |
31222
1a0756f7c90a
disable experimental terminal widget when building without qscintilla
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30888
diff
changeset
|
162 #if defined (HAVE_QSCINTILLA) |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
163 m_experimental_terminal_widget = true; |
31222
1a0756f7c90a
disable experimental terminal widget when building without qscintilla
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30888
diff
changeset
|
164 #endif |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
165 break; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
166 |
27823
83dd2bc500f0
Remove deprecated FORCE_GUI_OPTION from getopts parsing.
Rik <rik@octave.org>
parents:
27301
diff
changeset
|
167 case GUI_OPTION: |
24874
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
168 m_gui = true; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
169 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
170 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
171 case IMAGE_PATH_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
172 if (octave_optarg_wrapper ()) |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
173 m_image_path = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
174 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
175 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
176 case INFO_FILE_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
177 if (octave_optarg_wrapper ()) |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
178 m_info_file = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
179 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
180 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
181 case INFO_PROG_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
182 if (octave_optarg_wrapper ()) |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
183 m_info_program = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
184 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
185 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
186 case LINE_EDITING_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
187 m_forced_line_editing = m_line_editing = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
188 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
189 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
190 case NO_GUI_OPTION: |
24878
4fdb160b47fb
Keep the '--no-gui' option as the inverse of '--gui'
Mike Miller <mtmiller@octave.org>
parents:
24874
diff
changeset
|
191 m_gui = false; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
192 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
193 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
194 case NO_INIT_FILE_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
195 m_read_init_files = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
196 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
197 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
198 case NO_INIT_PATH_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
199 m_set_initial_path = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
200 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
201 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
202 case NO_LINE_EDITING_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
203 m_line_editing = false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
204 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
205 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
206 case NO_SITE_FILE_OPTION: |
26701
e000879eabef
maint: Use bool values true/false rather than 0/1 in C++.
Rik <rik@octave.org>
parents:
26377
diff
changeset
|
207 m_read_site_files = false; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
208 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
209 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
210 case PERSIST_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
211 m_persist = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
212 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
213 |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
214 case SERVER_OPTION: |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
215 m_server = true; |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
216 break; |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
217 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
218 case TEXI_MACROS_FILE_OPTION: |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
219 if (octave_optarg_wrapper ()) |
23711
5a97aafb12a9
don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
220 m_texi_macros_file = octave_optarg_wrapper (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
221 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
222 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
223 case TRADITIONAL_OPTION: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
224 m_traditional = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
225 m_persist = true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
226 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
227 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
228 default: |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
229 // getopt_long should print a message about unrecognized options and |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
230 // return '?', which is handled above. If we end up here, it is |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
231 // because there was an option but we forgot to handle it. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
232 // That should be fatal. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
233 panic_impossible (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
234 break; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
235 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
236 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
237 |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
238 m_remaining_args = string_vector (argv+octave_optind_wrapper (), |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22089
diff
changeset
|
239 argc-octave_optind_wrapper ()); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
240 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
241 |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
242 octave_value cmdline_options::as_octave_value (void) const |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
243 { |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
244 octave_scalar_map m; |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
245 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
246 m.assign ("sys_argc", sys_argc ()); |
30409
6b17822663f8
Return cell array of strings rather than char arrays in cmdline_options().
Rik <rik@octave.org>
parents:
30160
diff
changeset
|
247 m.assign ("sys_argv", Cell (string_vector (sys_argv ()))); |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
248 m.assign ("echo_commands", echo_commands ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
249 m.assign ("forced_interactive", forced_interactive ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
250 m.assign ("forced_line_editing", forced_line_editing ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
251 m.assign ("gui", gui ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
252 m.assign ("inhibit_startup_message", inhibit_startup_message ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
253 m.assign ("line_editing", line_editing ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
254 m.assign ("no_window_system", no_window_system ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
255 m.assign ("persist", persist ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
256 m.assign ("read_history_file", read_history_file ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
257 m.assign ("read_init_files", read_init_files ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
258 m.assign ("read_site_files", read_site_files ()); |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
259 m.assign ("server", server ()); |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
260 m.assign ("set_initial_path", set_initial_path ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
261 m.assign ("traditional", traditional ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
262 m.assign ("verbose_flag", verbose_flag ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
263 m.assign ("code_to_eval", code_to_eval ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
264 m.assign ("command_line_path", string_vector (command_line_path ())); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
265 m.assign ("docstrings_file", docstrings_file ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
266 m.assign ("doc_cache_file", doc_cache_file ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
267 m.assign ("exec_path", exec_path ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
268 m.assign ("image_path", image_path ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
269 m.assign ("info_file", info_file ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
270 m.assign ("info_program", info_program ()); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
271 m.assign ("texi_macros_file", texi_macros_file ()); |
30409
6b17822663f8
Return cell array of strings rather than char arrays in cmdline_options().
Rik <rik@octave.org>
parents:
30160
diff
changeset
|
272 m.assign ("all_args", Cell (all_args ())); |
6b17822663f8
Return cell array of strings rather than char arrays in cmdline_options().
Rik <rik@octave.org>
parents:
30160
diff
changeset
|
273 m.assign ("remaining_args", Cell (remaining_args ())); |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
274 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
275 return m; |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
276 } |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
277 |
30160
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
278 application *application::s_instance = nullptr; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
279 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
280 application::application (int argc, char **argv) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
281 : m_options (argc, argv) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
282 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
283 init (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
284 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
285 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
286 application::application (const cmdline_options& opts) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
287 : m_options (opts) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
288 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
289 init (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
290 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
291 |
29547
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
292 // Note: Although the application destructor doesn't explicitly |
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
293 // perform any actions, it can't be declared "default" in the header |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
294 // file if the interpreter is an incomplete type. Providing |
29547
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
295 // an explicit definition of the destructor here is much simpler than |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
296 // including the full declaration of interpreter in the |
29547
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
297 // octave.h header file. |
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
298 application::~application (void) { } |
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
299 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
300 void |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
301 application::set_program_names (const std::string& pname) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
302 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
303 m_program_invocation_name = pname; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
304 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29545
diff
changeset
|
305 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
|
306 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
307 m_program_name = (pos != std::string::npos) ? pname.substr (pos+1) : pname; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
308 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
309 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
310 void |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
311 application::intern_argv (const string_vector& args) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
312 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
313 octave_idx_type nargs = args.numel (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
314 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
315 if (nargs > 0) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
316 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
317 // Skip first argument (program name). |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
318 nargs--; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
319 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
320 m_argv.resize (nargs); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
321 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
322 for (octave_idx_type i = 0; i < nargs; i++) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
323 m_argv[i] = args[i+1]; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
324 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
325 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
326 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
327 bool application::forced_interactive (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
328 { |
30160
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
329 return s_instance ? s_instance->m_options.forced_interactive () : false; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
330 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
331 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
332 // Provided for convenience. Will be removed once we eliminate the |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
333 // old terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
334 bool application::experimental_terminal_widget (void) const |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
335 { |
30160
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
336 return (s_instance |
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
337 ? s_instance->m_options.experimental_terminal_widget () : false); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
338 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
339 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
340 bool application::interpreter_initialized (void) |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
341 { |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
342 return m_interpreter ? m_interpreter->initialized () : false; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
343 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
344 |
23773
5ff24576b783
defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
345 interpreter& application::create_interpreter (void) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
346 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
347 if (! m_interpreter) |
29547
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
348 m_interpreter = std::unique_ptr<interpreter> (new interpreter (this)); |
23773
5ff24576b783
defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
349 |
5ff24576b783
defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
350 return *m_interpreter; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
351 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
352 |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
353 void application::initialize_interpreter (void) |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
354 { |
23819
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
355 if (m_interpreter) |
5d8ef9b859f8
defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
356 m_interpreter->initialize (); |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
357 } |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
358 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
359 int application::execute_interpreter (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
360 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
361 return m_interpreter ? m_interpreter->execute () : -1; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
362 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
363 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
364 void application::delete_interpreter (void) |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
365 { |
29547
60af3f38f4b1
use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents:
29546
diff
changeset
|
366 m_interpreter.reset (); |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
367 } |
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
368 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
369 void application::init (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
370 { |
30160
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
371 if (s_instance) |
23511
232c8d69d934
manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents:
23460
diff
changeset
|
372 throw std::runtime_error |
232c8d69d934
manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents:
23460
diff
changeset
|
373 ("only one Octave application object may be active"); |
232c8d69d934
manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents:
23460
diff
changeset
|
374 |
30160
9c4e8c3bf41d
maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
375 s_instance = this; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
376 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
377 string_vector all_args = m_options.all_args (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
378 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
379 set_program_names (all_args[0]); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
380 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
381 string_vector remaining_args = m_options.remaining_args (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
382 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
383 std::string code_to_eval = m_options.code_to_eval (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
384 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
385 m_have_script_file = ! remaining_args.empty (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
386 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
387 m_have_eval_option_code = ! code_to_eval.empty (); |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
388 |
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
389 if (m_have_eval_option_code && m_have_script_file) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
390 { |
24344
cac0f8a1c696
Stop segfault when starting Octave with conflicting options (bug #52567).
Rik <rik@octave.org>
parents:
23857
diff
changeset
|
391 std::cerr << R"(error: --eval "CODE" and script file are mutually exclusive options)" << std::endl; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
392 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
393 octave_print_terse_usage_and_exit (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
394 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
395 |
24874
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
396 if (m_options.gui ()) |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
397 { |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
398 if (m_options.no_window_system ()) |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
399 { |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
400 std::cerr << "error: --gui and --no-window-system are mutually exclusive options" << std::endl; |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
401 octave_print_terse_usage_and_exit (); |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
402 } |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
403 if (! m_options.line_editing ()) |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
404 { |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
405 std::cerr << "error: --gui and --no-line-editing are mutually exclusive options" << std::endl; |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
406 octave_print_terse_usage_and_exit (); |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
407 } |
29254
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
408 if (m_options.server ()) |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
409 { |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
410 std::cerr << "error: --gui and --server are mutually exclusive options" << std::endl; |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
411 octave_print_terse_usage_and_exit (); |
11343ca3c125
allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents:
29152
diff
changeset
|
412 } |
24874
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
413 } |
a4dc2ef8741c
Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents:
24534
diff
changeset
|
414 |
23102
373771419d51
refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents:
23087
diff
changeset
|
415 m_is_octave_program = ((m_have_script_file || m_have_eval_option_code) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
416 && ! m_options.persist () |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
417 && ! m_options.traditional ()); |
23460
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
418 |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
419 // This should probably happen early. |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
420 sysdep_init (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
421 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
422 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
423 int cli_application::execute (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
424 { |
23773
5ff24576b783
defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
425 interpreter& interp = create_interpreter (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
426 |
23773
5ff24576b783
defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents:
23721
diff
changeset
|
427 int status = interp.execute (); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
428 |
23117
17a3567a7b01
separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents:
23111
diff
changeset
|
429 return status; |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
430 } |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
431 |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
432 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
|
433 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
|
434 @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
|
435 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
|
436 @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
|
437 @end deftypefn */) |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
438 { |
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
|
439 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
|
440 print_usage (); |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
441 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22081
diff
changeset
|
442 // 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
|
443 // 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
|
444 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
445 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
|
446 } |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
447 |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
448 /* |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
449 %!assert (islogical (isguirunning ())) |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
450 %!error isguirunning (1) |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
451 */ |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
452 |
5780 | 453 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
|
454 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
|
455 @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
|
456 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
|
457 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
458 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
|
459 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
460 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
461 octave --no-line-editing --silent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
462 @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
|
463 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
464 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
465 @code{argv} would return a cell array of strings with the elements |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
466 @option{--no-line-editing} and @option{--silent}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
467 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
468 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
|
469 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
|
470 an example of how to create an executable Octave script. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
471 @end deftypefn */) |
5780 | 472 { |
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
|
473 if (args.length () != 0) |
5823 | 474 print_usage (); |
5780 | 475 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
476 return ovl (Cell (application::argv ())); |
5780 | 477 } |
478 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
479 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
480 %!assert (iscellstr (argv ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
481 %!error argv (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
482 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
483 |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
484 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
|
485 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
|
486 @deftypefn {} {@var{opt_struct} =} cmdline_options () |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
487 Return a structure containing info about the command line arguments passed to |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
488 Octave. |
29152
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
489 @end deftypefn */) |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
490 { |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
491 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
|
492 print_usage (); |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
493 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
494 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
|
495 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
496 if (! app) |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
497 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
|
498 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
499 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
|
500 |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
501 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
|
502 } |
556f20454064
make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents:
28349
diff
changeset
|
503 |
5780 | 504 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
|
505 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
|
506 @deftypefn {} {@var{name} =} program_invocation_name () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
507 Return the name that was typed at the shell prompt to run Octave. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
508 |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
509 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
|
510 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
|
511 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
|
512 executable Octave script. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
513 @seealso{program_name} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
514 @end deftypefn */) |
5780 | 515 { |
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
|
516 if (args.length () != 0) |
5823 | 517 print_usage (); |
5780 | 518 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
519 return ovl (application::program_invocation_name ()); |
5780 | 520 } |
521 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
522 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
523 %!assert (ischar (program_invocation_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
524 %!error program_invocation_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
525 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
526 |
5780 | 527 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
|
528 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
|
529 @deftypefn {} {@var{name} =} program_name () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
530 Return the last component of the value returned by |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
531 @code{program_invocation_name}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
532 @seealso{program_invocation_name} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21938
diff
changeset
|
533 @end deftypefn */) |
5780 | 534 { |
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
|
535 if (args.length () != 0) |
5823 | 536 print_usage (); |
5780 | 537 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
538 return ovl (application::program_name ()); |
5780 | 539 } |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
540 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
541 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
542 %!assert (ischar (program_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
543 %!error program_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
544 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
545 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
546 OCTAVE_NAMESPACE_END |