Mercurial > octave-nkf
comparison libinterp/corefcn/symtab.cc @ 20617:ba2b07c13913
use new string_value method to handle value extraction errors
* __dispatch__.cc, balance.cc, colloc.cc, conv2.cc, data.cc, debug.cc,
graphics.cc, input.cc, matrix_type.cc, oct-hist.cc, schur.cc,
spparms.cc, symtab.cc, sysdep.cc, toplev.cc, utils.cc:
Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Oct 2015 10:06:39 -0400 |
parents | 33b03b06442b |
children |
comparison
equal
deleted
inserted
replaced
20616:fd0efcdb3718 | 20617:ba2b07c13913 |
---|---|
1686 } | 1686 } |
1687 } | 1687 } |
1688 | 1688 |
1689 if (nargin == 1) | 1689 if (nargin == 1) |
1690 { | 1690 { |
1691 if (args(0).is_string ()) | 1691 std::string sval = args(0).string_value ("ignore_function_time_stamp: expecting argument to be a string"); |
1692 { | 1692 |
1693 std::string sval = args(0).string_value (); | 1693 if (sval == "all") |
1694 if (sval == "all") | 1694 Vignore_function_time_stamp = 2; |
1695 Vignore_function_time_stamp = 2; | 1695 else if (sval == "system") |
1696 else if (sval == "system") | 1696 Vignore_function_time_stamp = 1; |
1697 Vignore_function_time_stamp = 1; | 1697 else if (sval == "none") |
1698 else if (sval == "none") | 1698 Vignore_function_time_stamp = 0; |
1699 Vignore_function_time_stamp = 0; | |
1700 else | |
1701 error ("ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\""); | |
1702 } | |
1703 else | 1699 else |
1704 error ("ignore_function_time_stamp: expecting argument to be character string"); | 1700 error ("ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\""); |
1705 } | 1701 } |
1706 else if (nargin > 1) | 1702 else if (nargin > 1) |
1707 print_usage (); | 1703 print_usage (); |
1708 | 1704 |
1709 return retval; | 1705 return retval; |
1821 { | 1817 { |
1822 octave_value retval; | 1818 octave_value retval; |
1823 | 1819 |
1824 if (args.length () == 1) | 1820 if (args.length () == 1) |
1825 { | 1821 { |
1826 std::string name = args(0).string_value (); | 1822 std::string name = args(0).string_value ("__get_cmd_line_function_text__: expecting function name"); |
1827 | 1823 |
1828 if (! error_state) | 1824 octave_value ov = symbol_table::find_cmdline_function (name); |
1829 { | 1825 |
1830 octave_value ov = symbol_table::find_cmdline_function (name); | 1826 octave_user_function *f = ov.user_function_value (); |
1831 | 1827 |
1832 octave_user_function *f = ov.user_function_value (); | 1828 if (f) |
1833 | 1829 { |
1834 if (f) | 1830 std::ostringstream buf; |
1835 { | 1831 |
1836 std::ostringstream buf; | 1832 tree_print_code tpc (buf); |
1837 | 1833 |
1838 tree_print_code tpc (buf); | 1834 f->accept (tpc); |
1839 | 1835 |
1840 f->accept (tpc); | 1836 retval = buf.str (); |
1841 | 1837 } |
1842 retval = buf.str (); | |
1843 } | |
1844 } | |
1845 else | |
1846 error ("__get_cmd_line_function_text__: expecting function name"); | |
1847 } | 1838 } |
1848 else | 1839 else |
1849 print_usage (); | 1840 print_usage (); |
1850 | 1841 |
1851 return retval; | 1842 return retval; |
1859 { | 1850 { |
1860 octave_value retval; | 1851 octave_value retval; |
1861 | 1852 |
1862 if (args.length () == 2) | 1853 if (args.length () == 2) |
1863 { | 1854 { |
1864 std::string name = args(0).string_value (); | 1855 std::string name = args(0).string_value ("set_variable: expecting variable name as first argument"); |
1865 | 1856 |
1866 if (! error_state) | 1857 symbol_table::assign (name, args(1)); |
1867 symbol_table::assign (name, args(1)); | |
1868 else | |
1869 error ("set_variable: expecting variable name as first argument"); | |
1870 } | 1858 } |
1871 else | 1859 else |
1872 print_usage (); | 1860 print_usage (); |
1873 | 1861 |
1874 return retval; | 1862 return retval; |
1878 { | 1866 { |
1879 octave_value retval; | 1867 octave_value retval; |
1880 | 1868 |
1881 if (args.length () == 1) | 1869 if (args.length () == 1) |
1882 { | 1870 { |
1883 std::string name = args(0).string_value (); | 1871 std::string name = args(0).string_value ("variable_value: expecting variable name as first argument"); |
1884 | 1872 |
1885 if (! error_state) | 1873 retval = symbol_table::varval (name); |
1886 { | 1874 |
1887 retval = symbol_table::varval (name); | 1875 if (retval.is_undefined ()) |
1888 | 1876 error ("variable_value: '%s' is not a variable in the current scope", |
1889 if (retval.is_undefined ()) | 1877 name.c_str ()); |
1890 error ("variable_value: '%s' is not a variable in the current scope", | |
1891 name.c_str ()); | |
1892 } | |
1893 else | |
1894 error ("variable_value: expecting variable name as first argument"); | |
1895 } | 1878 } |
1896 else | 1879 else |
1897 print_usage (); | 1880 print_usage (); |
1898 | 1881 |
1899 return retval; | 1882 return retval; |