26 #if defined (HAVE_CONFIG_H)
95 invalid_fcn_handle (
const invalid_fcn_handle&) =
default;
97 ~invalid_fcn_handle () =
default;
99 invalid_fcn_handle *
clone ()
const
101 return new invalid_fcn_handle (*
this);
104 std::string
type ()
const {
return "<invalid>"; }
121 internal_fcn_handle (
const internal_fcn_handle&) =
default;
123 ~internal_fcn_handle () =
default;
125 internal_fcn_handle *
clone ()
const
127 return new internal_fcn_handle (*
this);
130 std::string
type ()
const {
return "<internal>"; }
153 friend bool is_equal_to (
const internal_fcn_handle& fh1,
154 const internal_fcn_handle& fh2);
168 simple_fcn_handle (
const std::string& name =
"",
169 const std::string& file =
"",
170 const std::string& =
"")
174 simple_fcn_handle (
const octave_value& fcn,
const std::string& name)
177 if (m_fcn.is_defined ())
186 simple_fcn_handle (
const simple_fcn_handle&) =
default;
188 ~simple_fcn_handle () =
default;
190 simple_fcn_handle *
clone ()
const
192 return new simple_fcn_handle (*
this);
195 std::string
type ()
const {
return "simple"; }
216 bool save_binary (std::ostream& os,
bool save_as_floats);
221 bool save_as_floats);
226 void print_raw (std::ostream& os,
bool pr_as_read_syntax,
227 int current_print_indent_level)
const;
229 friend bool is_equal_to (
const simple_fcn_handle& fh1,
230 const simple_fcn_handle& fh2);
244 scoped_fcn_handle (
const std::string& name =
"",
245 const std::string& file =
"",
246 const std::string& =
"")
250 scoped_fcn_handle (
const octave_value& fcn,
const std::string& name,
251 const std::list<std::string>& parentage);
253 scoped_fcn_handle (
const scoped_fcn_handle&) =
default;
255 ~scoped_fcn_handle () =
default;
257 scoped_fcn_handle *
clone ()
const
259 return new scoped_fcn_handle (*
this);
262 std::string
type ()
const {
return "scopedfunction"; }
289 bool save_binary (std::ostream& os,
bool save_as_floats);
294 bool save_as_floats);
299 void print_raw (std::ostream&,
bool pr_as_read_syntax,
300 int current_print_indent_level)
const;
302 friend bool is_equal_to (
const scoped_fcn_handle& fh1,
303 const scoped_fcn_handle& fh2);
307 void find_function ();
314 std::list<std::string> m_parentage;
324 base_nested_fcn_handle (
const std::string& name =
"",
325 const std::string& file =
"",
326 const std::string& =
"")
330 base_nested_fcn_handle (
const octave_value& fcn,
const std::string& name)
334 std::string
type ()
const {
return "nested"; }
363 bool save_binary (std::ostream& os,
bool save_as_floats);
368 bool save_as_floats);
373 void print_raw (std::ostream&,
bool pr_as_read_syntax,
374 int current_print_indent_level)
const;
382 class nested_fcn_handle :
public base_nested_fcn_handle
389 nested_fcn_handle (
const std::string& name =
"",
390 const std::string& file =
"",
391 const std::string& octaveroot =
"")
392 : base_nested_fcn_handle (name, file, octaveroot)
395 nested_fcn_handle (
const octave_value& fcn,
const std::string& name,
396 const std::shared_ptr<stack_frame>& stack_context)
397 : base_nested_fcn_handle (fcn, name), m_stack_context (stack_context)
400 m_stack_context->mark_closure_context ();
403 nested_fcn_handle (
const nested_fcn_handle&) =
default;
405 ~nested_fcn_handle () =
default;
407 using base_nested_fcn_handle::is_nested;
409 bool is_nested (
const std::shared_ptr<stack_frame>& frame)
const
411 if (frame == m_stack_context)
415 auto nxt = m_stack_context->access_link ();
420 nxt = nxt->access_link ();
426 nested_fcn_handle * clone ()
const
428 return new nested_fcn_handle (*
this);
437 friend bool is_equal_to (
const nested_fcn_handle& fh1,
438 const nested_fcn_handle& fh2);
440 std::shared_ptr<stack_frame> stack_context ()
const
442 return m_stack_context;
448 std::shared_ptr<stack_frame> m_stack_context;
451 class weak_nested_fcn_handle :
public base_nested_fcn_handle
455 weak_nested_fcn_handle (
const nested_fcn_handle& nfh)
456 : base_nested_fcn_handle (nfh), m_stack_context (nfh.stack_context ())
459 weak_nested_fcn_handle (
const weak_nested_fcn_handle&) =
default;
461 ~weak_nested_fcn_handle () =
default;
463 weak_nested_fcn_handle * clone ()
const
465 return new weak_nested_fcn_handle (*
this);
468 bool is_weak_nested ()
const {
return true; }
474 friend bool is_equal_to (
const weak_nested_fcn_handle& fh1,
475 const weak_nested_fcn_handle& fh2);
480 std::weak_ptr<stack_frame> m_stack_context;
490 class_simple_fcn_handle (
const std::string& name,
491 const std::string& file,
499 class_simple_fcn_handle (
const std::string& class_nm,
500 const std::string& meth_nm);
503 const std::string& class_nm,
504 const std::string& meth_nm);
507 const std::string& class_nm,
508 const std::string& meth_nm);
510 class_simple_fcn_handle (
const class_simple_fcn_handle&) =
default;
512 ~class_simple_fcn_handle () =
default;
514 class_simple_fcn_handle *
clone ()
const
516 return new class_simple_fcn_handle (*
this);
519 std::string
type ()
const {
return "classsimple"; }
532 if (m_fcn.is_defined ())
547 return m_fcn.
is_defined () ? m_fcn.function_value () :
nullptr;
560 std::string dispatch_class ()
const {
return m_dispatch_class; }
566 bool save_binary (std::ostream& os,
bool save_as_floats);
571 bool save_as_floats);
576 void print_raw (std::ostream&,
bool pr_as_read_syntax,
577 int current_print_indent_level)
const;
579 friend bool is_equal_to (
const class_simple_fcn_handle& fh1,
580 const class_simple_fcn_handle& fh2);
591 std::string m_dispatch_class;
624 static const std::string anonymous;
631 base_anonymous_fcn_handle (
const std::string& name =
"")
640 base_anonymous_fcn_handle (
const base_anonymous_fcn_handle&) =
default;
642 ~base_anonymous_fcn_handle () =
default;
644 std::string
type ()
const {
return "anonymous"; }
671 bool save_binary (std::ostream& os,
bool save_as_floats);
676 bool save_as_floats);
681 void print_raw (std::ostream&,
bool pr_as_read_syntax,
682 int current_print_indent_level)
const;
687 bool parse (
const std::string& fcn_text);
698 class anonymous_fcn_handle :
public base_anonymous_fcn_handle
702 using base_anonymous_fcn_handle::anonymous;
709 anonymous_fcn_handle (
const std::string& name =
"")
710 : base_anonymous_fcn_handle (name), m_stack_context ()
715 const std::shared_ptr<stack_frame>& stack_context = std::shared_ptr<stack_frame> ());
717 anonymous_fcn_handle (
const anonymous_fcn_handle&) =
default;
719 ~anonymous_fcn_handle () =
default;
721 anonymous_fcn_handle * clone ()
const
723 return new anonymous_fcn_handle (*
this);
732 friend bool is_equal_to (
const anonymous_fcn_handle& fh1,
733 const anonymous_fcn_handle& fh2);
735 std::shared_ptr<stack_frame> stack_context ()
const
737 return m_stack_context;
743 std::shared_ptr<stack_frame> m_stack_context;
746 class weak_anonymous_fcn_handle :
public base_anonymous_fcn_handle
750 using base_anonymous_fcn_handle::anonymous;
752 weak_anonymous_fcn_handle (
const anonymous_fcn_handle& afh)
753 : base_anonymous_fcn_handle (afh), m_stack_context (afh.stack_context ())
756 weak_anonymous_fcn_handle (
const weak_anonymous_fcn_handle&) =
default;
758 ~weak_anonymous_fcn_handle () =
default;
760 weak_anonymous_fcn_handle * clone ()
const
762 return new weak_anonymous_fcn_handle (*
this);
765 bool is_weak_anonymous ()
const {
return true; }
771 friend bool is_equal_to (
const weak_anonymous_fcn_handle& fh1,
772 const weak_anonymous_fcn_handle& fh2);
777 std::weak_ptr<stack_frame> m_stack_context;
780 extern bool is_equal_to (
const anonymous_fcn_handle& fh1,
781 const anonymous_fcn_handle& fh2);
784 err_invalid_fcn_handle (
const std::string& name)
786 error (
"invalid function handle, unable to find function for @%s",
793 std::string type_str =
type ();
794 error (
"invalid conversion from %s handle to weak nestead handle",
801 std::string type_str =
type ();
802 error (
"invalid conversion from %s handle to weak anonymous handle",
808 const std::list<octave_value_list>& idx,
817 int tmp_nargout = (
type.length () > 1 && nargout == 0) ? 1 : nargout;
819 retval =
call (tmp_nargout, idx.front ());
825 error (
"function handle cannot be indexed with %c",
type[0]);
836 retval = retval(0).next_subsref (nargout,
type, idx);
844 std::ostringstream buf;
900 std::string obj_type =
type ();
903 (
"Octave:load-save-unavailable",
904 "%s: loading %s files not available in this version of Octave",
905 obj_type.c_str (), file_type);
911 std::string obj_type =
type ();
914 (
"Octave:load-save-unavailable",
915 "%s: saving %s files not available in this version of Octave",
916 obj_type.c_str (), file_type);
922 std::string htype =
type ();
924 warning (
"%s for %s handles with %s format is not implemented",
925 op, htype.c_str (), fmt);
931 error (
"invalid call to invalid function handle");
939 return interp.
feval (m_fcn, args, nargout);
943 internal_fcn_handle::info ()
947 m.setfield (
"function", fcn_name ());
948 m.setfield (
"type", type ());
949 m.setfield (
"file",
"");
956 const internal_fcn_handle& fh2)
958 if (fh1.m_name == fh2.m_name
959 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
960 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
982 std::size_t pos = m_name.find (
'.');
984 if (pos != std::string::npos)
1004 std::size_t beg = 0;
1005 std::size_t end = pos;
1007 std::vector<std::string> idx_elts;
1011 end = m_name.find (
'.', beg);
1013 idx_elts.push_back (m_name.substr (beg, end-beg));
1015 if (end == std::string::npos)
1021 std::size_t n_elts = idx_elts.size ();
1023 bool have_object =
false;
1030 partial_expr_val = interp.
varval (idx_elts[0]);
1035 err_invalid_fcn_handle (m_name);
1043 std::list<octave_value_list> arg_list;
1045 for (std::size_t i = 1; i < n_elts; i++)
1050 err_invalid_fcn_handle (m_name);
1053 arg_list.push_back (
ovl (idx_elts[i]));
1060 = partial_expr_val.
subsref (type, arg_list, 0);
1066 err_invalid_fcn_handle (m_name);
1072 err_invalid_fcn_handle (m_name);
1084 err_invalid_fcn_handle (m_name);
1087 arg_list.push_back (
ovl (idx_elts[i]));
1088 arg_list.push_back (args);
1090 return partial_expr_val.
subsref (type, arg_list, nargout);
1093 err_invalid_fcn_handle (m_name);
1099 err_invalid_fcn_handle (m_name);
1101 fcn_to_call = partial_expr_val;
1113 if (m_fcn.is_defined ())
1118 fcn_to_call = m_fcn;
1132 fcn_to_call = ov_fcn;
1141 fcn_to_call = ov_fcn;
1146 err_invalid_fcn_handle (m_name);
1148 return interp.
feval (fcn_to_call, args, nargout);
1152 simple_fcn_handle::function_value (
bool)
1157 if (m_fcn.is_defined ())
1168 return m_fcn.
is_defined () ? m_fcn.function_value () :
nullptr;
1172 simple_fcn_handle::user_function_value (
bool)
1177 if (m_fcn.is_defined ())
1188 return m_fcn.
is_defined () ? m_fcn.user_function_value () :
nullptr;
1192 simple_fcn_handle::fcn_val ()
1194 if (m_fcn.is_defined ())
1209 simple_fcn_handle::info ()
1213 m.setfield (
"function", fcn_name ());
1214 m.setfield (
"type", type ());
1216 m.setfield (
"file", file ());
1222 simple_fcn_handle::save_ascii (std::ostream& os)
1226 std::string fnm = file ();
1228 os <<
"# path: " << fnm <<
"\n";
1230 os <<
"# subtype: " << type () <<
"\n";
1232 os << m_name <<
"\n";
1238 simple_fcn_handle::load_ascii (std::istream& is)
1248 simple_fcn_handle::save_binary (std::ostream& os,
bool)
1250 std::ostringstream nmbuf;
1258 std::string buf_str = nmbuf.str ();
1259 int32_t tmp = buf_str.length ();
1260 os.write (
reinterpret_cast<char *
> (&tmp), 4);
1261 os.write (buf_str.c_str (), buf_str.length ());
1267 simple_fcn_handle::load_binary (std::istream& is,
bool,
1274 simple_fcn_handle::save_hdf5 (
octave_hdf5_id loc_id,
const char *name,
1277 #if defined (HAVE_HDF5)
1282 #if defined (HAVE_HDF5_18)
1286 group_hid = H5Gcreate (loc_id, name, 0);
1292 space_hid = data_hid = type_hid = -1;
1295 type_hid = H5Tcopy (H5T_C_S1);
1296 H5Tset_size (type_hid, m_name.length () + 1);
1299 H5Gclose (group_hid);
1306 space_hid = H5Screate_simple (0, hdims,
nullptr);
1309 H5Tclose (type_hid);
1310 H5Gclose (group_hid);
1313 #if defined (HAVE_HDF5_18)
1314 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
1318 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
1325 H5Sclose (space_hid);
1326 H5Tclose (type_hid);
1327 H5Gclose (group_hid);
1330 H5Dclose (data_hid);
1337 H5Sclose (space_hid);
1339 hdims[1] = octaveroot.length ();
1340 space_hid = H5Screate_simple (0, hdims,
nullptr);
1343 H5Tclose (type_hid);
1344 H5Gclose (group_hid);
1348 H5Tclose (type_hid);
1349 type_hid = H5Tcopy (H5T_C_S1);
1350 H5Tset_size (type_hid, octaveroot.length () + 1);
1352 #if defined (HAVE_HDF5_18)
1353 a_id = H5Acreate (group_hid,
"OCTAVEROOT", type_hid, space_hid,
1356 a_id = H5Acreate (group_hid,
"OCTAVEROOT", type_hid, space_hid,
1362 retval = (H5Awrite (a_id, type_hid, octaveroot.c_str ()) >= 0);
1368 H5Sclose (space_hid);
1369 H5Tclose (type_hid);
1370 H5Gclose (group_hid);
1374 H5Sclose (space_hid);
1376 hdims[1] = fpath.length ();
1377 space_hid = H5Screate_simple (0, hdims,
nullptr);
1380 H5Tclose (type_hid);
1381 H5Gclose (group_hid);
1385 H5Tclose (type_hid);
1386 type_hid = H5Tcopy (H5T_C_S1);
1387 H5Tset_size (type_hid, fpath.length () + 1);
1389 #if defined (HAVE_HDF5_18)
1390 a_id = H5Acreate (group_hid,
"FILE", type_hid, space_hid,
1393 a_id = H5Acreate (group_hid,
"FILE", type_hid, space_hid,
1399 retval = (H5Awrite (a_id, type_hid, fpath.c_str ()) >= 0);
1406 H5Sclose (space_hid);
1407 H5Tclose (type_hid);
1408 H5Gclose (group_hid);
1414 octave_unused_parameter (loc_id);
1415 octave_unused_parameter (name);
1429 #if defined (HAVE_HDF5)
1431 unimplemented (
"load",
"hdf5");
1433 octave_unused_parameter (group_hid);
1434 octave_unused_parameter (space_hid);
1435 octave_unused_parameter (type_hid);
1441 octave_unused_parameter (group_hid);
1442 octave_unused_parameter (space_hid);
1443 octave_unused_parameter (type_hid);
1451 simple_fcn_handle::print_raw (std::ostream& os,
bool pr_as_read_syntax,
1452 int current_print_indent_level)
const
1455 current_print_indent_level);
1459 is_equal_to (
const simple_fcn_handle& fh1,
const simple_fcn_handle& fh2)
1461 if (fh1.m_name == fh2.m_name)
1463 if (fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
1464 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
1466 if (fh1.m_fcn.is_undefined () && fh2.m_fcn.is_undefined ())
1473 scoped_fcn_handle::scoped_fcn_handle (
const octave_value& fcn,
1474 const std::string& name,
1475 const std::list<std::string>& parentage)
1480 if (m_fcn.is_defined ())
1488 m_parentage.push_front (name);
1498 if (! m_fcn.is_defined ())
1505 if (! m_fcn.is_defined ())
1506 err_invalid_fcn_handle (m_name);
1508 return interp.
feval (m_fcn, args, nargout);
1512 scoped_fcn_handle::info ()
1516 m.setfield (
"function", fcn_name ());
1517 m.setfield (
"type", type ());
1518 m.setfield (
"file", file ());
1520 m.setfield (
"parentage",
Cell (m_parentage));
1526 scoped_fcn_handle::save_ascii (std::ostream& os)
1530 std::string fnm = file ();
1532 os <<
"# path: " << fnm <<
"\n";
1534 os <<
"# subtype: " << type () <<
"\n";
1536 os << m_name <<
"\n";
1545 scoped_fcn_handle::load_ascii (std::istream& is)
1555 m_parentage.push_back (cellstr_val(i));
1562 scoped_fcn_handle::save_binary (std::ostream& os,
bool save_as_floats)
1564 std::ostringstream nmbuf;
1566 std::string fnm = file ();
1571 std::string buf_str = nmbuf.str ();
1572 int32_t
len = buf_str.length ();
1573 os.write (
reinterpret_cast<char *
> (&
len), 4);
1574 os.write (buf_str.c_str (), buf_str.length ());
1583 scoped_fcn_handle::load_binary (std::istream& is,
bool swap,
1594 m_parentage.push_back (cellstr_val(i));
1601 scoped_fcn_handle::save_hdf5 (
octave_hdf5_id loc_id,
const char *name,
1604 #if defined (HAVE_HDF5)
1606 unimplemented (
"save",
"hdf5");
1610 octave_unused_parameter (loc_id);
1611 octave_unused_parameter (name);
1617 octave_unused_parameter (loc_id);
1618 octave_unused_parameter (name);
1632 #if defined (HAVE_HDF5)
1634 unimplemented (
"load",
"hdf5");
1638 octave_unused_parameter (group_hid);
1639 octave_unused_parameter (space_hid);
1640 octave_unused_parameter (type_hid);
1646 octave_unused_parameter (group_hid);
1647 octave_unused_parameter (space_hid);
1648 octave_unused_parameter (type_hid);
1656 scoped_fcn_handle::print_raw (std::ostream& os,
1657 bool pr_as_read_syntax,
1658 int current_print_indent_level)
const
1661 current_print_indent_level);
1665 is_equal_to (
const scoped_fcn_handle& fh1,
const scoped_fcn_handle& fh2)
1667 if (fh1.m_name == fh2.m_name
1668 && fh2.m_parentage == fh2.m_parentage
1669 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
1670 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
1676 scoped_fcn_handle::find_function ()
1685 if (m_parentage.size () == 1)
1691 if (pos != std::string::npos)
1692 dir_name = dir_name.substr (0, pos);
1693 else if (dir_name ==
"private")
1696 std::string fcn_name = m_parentage.front ();
1706 std::string primary_parent_name = m_parentage.back ();
1721 if (file_name.substr (0, oct_home.size ()) == oct_home)
1722 file_name = file_name.substr (oct_home.size ());
1734 base_nested_fcn_handle::info ()
1738 m.setfield (
"function", fcn_name ());
1739 m.setfield (
"type", type ());
1740 m.setfield (
"file",
"");
1741 m.setfield (
"workspace", workspace ());
1756 base_nested_fcn_handle::save_ascii (std::ostream& os)
1758 unimplemented (
"save",
"text");
1760 octave_unused_parameter (os);
1766 base_nested_fcn_handle::load_ascii (std::istream& is)
1768 unimplemented (
"load",
"text");
1770 octave_unused_parameter (is);
1776 base_nested_fcn_handle::save_binary (std::ostream& os,
1777 bool save_as_floats)
1779 unimplemented (
"save",
"binary");
1781 octave_unused_parameter (os);
1782 octave_unused_parameter (save_as_floats);
1788 base_nested_fcn_handle::load_binary (std::istream& is,
bool swap,
1791 unimplemented (
"load",
"binary");
1793 octave_unused_parameter (is);
1794 octave_unused_parameter (swap);
1795 octave_unused_parameter (fmt);
1802 const char *name,
bool)
1804 #if defined (HAVE_HDF5)
1806 unimplemented (
"save",
"hdf5");
1808 octave_unused_parameter (loc_id);
1809 octave_unused_parameter (name);
1815 octave_unused_parameter (loc_id);
1816 octave_unused_parameter (name);
1830 #if defined (HAVE_HDF5)
1832 unimplemented (
"load",
"hdf5");
1834 octave_unused_parameter (group_hid);
1835 octave_unused_parameter (space_hid);
1836 octave_unused_parameter (type_hid);
1842 octave_unused_parameter (group_hid);
1843 octave_unused_parameter (space_hid);
1844 octave_unused_parameter (type_hid);
1852 base_nested_fcn_handle::print_raw (std::ostream& os,
1853 bool pr_as_read_syntax,
1854 int current_print_indent_level)
const
1857 current_print_indent_level);
1861 nested_fcn_handle::make_weak_nested_handle ()
const
1864 (
new weak_nested_fcn_handle (*
this)));
1878 return oct_usr_fcn->
execute (tw, nargout, args);
1882 nested_fcn_handle::workspace ()
const
1884 return m_stack_context->workspace ();
1888 is_equal_to (
const nested_fcn_handle& fh1,
const nested_fcn_handle& fh2)
1890 if (fh1.m_name == fh2.m_name
1891 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
1892 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
1904 std::shared_ptr<stack_frame> frames = m_stack_context.
lock ();
1910 return oct_usr_fcn->
execute (tw, nargout, args);
1914 weak_nested_fcn_handle::workspace ()
const
1916 std::shared_ptr<stack_frame> frames = m_stack_context.
lock ();
1918 return frames ? frames->workspace () :
octave_value ();
1923 const weak_nested_fcn_handle& fh2)
1925 if (fh1.m_name == fh2.m_name
1926 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
1927 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
1932 class_simple_fcn_handle::class_simple_fcn_handle (
const std::string& class_nm,
1933 const std::string& meth_nm)
1935 m_dispatch_class (class_nm)
1938 class_simple_fcn_handle::class_simple_fcn_handle (
const octave_value& fcn,
1939 const std::string& class_nm,
1940 const std::string& meth_nm)
1942 m_dispatch_class (class_nm)
1945 class_simple_fcn_handle::class_simple_fcn_handle (
const octave_value& obj,
1947 const std::string& class_nm,
1948 const std::string& meth_nm)
1950 m_dispatch_class (class_nm)
1958 if (m_obj.is_defined ())
1963 return interp.
feval (m_fcn, tmp_args, nargout);
1977 if (m_fcn.is_defined ())
1978 return interp.
feval (m_fcn, args, nargout);
1980 return interp.
feval (fcn_name (), args, nargout);
1984 class_simple_fcn_handle::info ()
1988 m.setfield (
"function", fcn_name ());
1989 m.setfield (
"type", type ());
1990 m.setfield (
"file",
"");
1991 m.setfield (
"class", dispatch_class ());
2002 class_simple_fcn_handle::save_ascii (std::ostream& os)
2004 unimplemented (
"save",
"text");
2006 octave_unused_parameter (os);
2012 class_simple_fcn_handle::load_ascii (std::istream& is)
2014 unimplemented (
"load",
"text");
2016 octave_unused_parameter (is);
2022 class_simple_fcn_handle::save_binary (std::ostream& os,
2023 bool save_as_floats)
2025 unimplemented (
"save",
"binary");
2027 octave_unused_parameter (os);
2028 octave_unused_parameter (save_as_floats);
2034 class_simple_fcn_handle::load_binary (std::istream& is,
bool swap,
2037 unimplemented (
"load",
"binary");
2039 octave_unused_parameter (is);
2040 octave_unused_parameter (swap);
2041 octave_unused_parameter (fmt);
2048 const char *name,
bool)
2050 #if defined (HAVE_HDF5)
2052 unimplemented (
"save",
"hdf5");
2054 octave_unused_parameter (loc_id);
2055 octave_unused_parameter (name);
2061 octave_unused_parameter (loc_id);
2062 octave_unused_parameter (name);
2076 #if defined (HAVE_HDF5)
2078 unimplemented (
"load",
"hdf5");
2080 octave_unused_parameter (group_hid);
2081 octave_unused_parameter (space_hid);
2082 octave_unused_parameter (type_hid);
2088 octave_unused_parameter (group_hid);
2089 octave_unused_parameter (space_hid);
2090 octave_unused_parameter (type_hid);
2098 class_simple_fcn_handle::print_raw (std::ostream& os,
2099 bool pr_as_read_syntax,
2100 int current_print_indent_level)
const
2103 current_print_indent_level);
2108 const class_simple_fcn_handle& fh2)
2112 if (fh1.m_name == fh2.m_name
2113 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
2114 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
2119 const std::string base_anonymous_fcn_handle::anonymous (
"@<anonymous>");
2122 base_anonymous_fcn_handle::info ()
2126 std::ostringstream buf;
2127 print_raw (buf,
true, 0);
2128 m.setfield (
"function", buf.str ());
2130 m.setfield (
"type", type ());
2131 m.setfield (
"file",
"");
2132 m.setfield (
"workspace", workspace ());
2133 m.setfield (
"within_file_path",
"");
2139 base_anonymous_fcn_handle::save_ascii (std::ostream& os)
2143 if (m_fcn.is_undefined ())
2146 os << m_name <<
"\n";
2148 print_raw (os,
true, 0);
2151 std::size_t varlen = m_local_vars.size ();
2155 os <<
"# length: " << varlen <<
"\n";
2157 for (
const auto& nm_val : m_local_vars)
2159 if (!
save_text_data (os, nm_val.second, nm_val.first,
false, 0))
2160 return ! os.fail ();
2168 base_anonymous_fcn_handle::load_ascii (std::istream& is)
2182 std::streampos pos = is.tellg ();
2208 error (
"load: failed to load anonymous function handle");
2210 m_local_vars[name] = t2;
2227 base_anonymous_fcn_handle::save_binary (std::ostream& os,
2228 bool save_as_floats)
2232 if (m_fcn.is_undefined ())
2235 std::ostringstream nmbuf;
2237 std::size_t varlen = m_local_vars.size ();
2241 nmbuf <<
' ' << varlen;
2243 std::string buf_str = nmbuf.str ();
2244 int32_t tmp = buf_str.
length ();
2245 os.write (
reinterpret_cast<char *
> (&tmp), 4);
2246 os.write (buf_str.c_str (), buf_str.length ());
2248 std::ostringstream buf;
2249 print_raw (buf,
true, 0);
2250 std::string stmp = buf.str ();
2251 tmp = stmp.length ();
2252 os.write (
reinterpret_cast<char *
> (&tmp), 4);
2253 os.write (stmp.c_str (), stmp.length ());
2257 for (
const auto& nm_val : m_local_vars)
2260 "", 0, save_as_floats))
2261 return ! os.fail ();
2269 base_anonymous_fcn_handle::load_binary (std::istream& is,
bool swap,
2276 std::size_t anl = anonymous.length ();
2277 if (m_name.length () > anl)
2279 std::istringstream nm_is (m_name.substr (anl));
2291 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
2299 is.read (ctmp2, tmp);
2324 error (
"load: failed to load anonymous function handle");
2326 m_local_vars[name] = t2;
2331 return parse (ctmp2);
2339 bool save_as_floats)
2341 #if defined (HAVE_HDF5)
2346 #if defined (HAVE_HDF5_18)
2350 group_hid = H5Gcreate (loc_id, name, 0);
2356 space_hid = data_hid = type_hid = -1;
2359 type_hid = H5Tcopy (H5T_C_S1);
2360 H5Tset_size (type_hid, m_name.length () + 1);
2363 H5Gclose (group_hid);
2370 space_hid = H5Screate_simple (0, hdims,
nullptr);
2373 H5Tclose (type_hid);
2374 H5Gclose (group_hid);
2377 #if defined (HAVE_HDF5_18)
2378 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
2382 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
2389 H5Sclose (space_hid);
2390 H5Tclose (type_hid);
2391 H5Gclose (group_hid);
2394 H5Dclose (data_hid);
2396 std::ostringstream buf;
2397 print_raw (buf,
true, 0);
2398 std::string stmp = buf.str ();
2401 H5Tset_size (type_hid, stmp.length () + 1);
2404 H5Sclose (space_hid);
2405 H5Gclose (group_hid);
2409 #if defined (HAVE_HDF5_18)
2410 data_hid = H5Dcreate (group_hid,
"fcn", type_hid, space_hid,
2414 data_hid = H5Dcreate (group_hid,
"fcn", type_hid, space_hid,
2421 H5Sclose (space_hid);
2422 H5Tclose (type_hid);
2423 H5Gclose (group_hid);
2427 H5Dclose (data_hid);
2429 std::size_t varlen = m_local_vars.size ();
2438 #if defined (HAVE_HDF5_18)
2439 a_id = H5Acreate (group_hid,
"SYMBOL_TABLE",
H5T_NATIVE_IDX, as_id,
2443 a_id = H5Acreate (group_hid,
"SYMBOL_TABLE",
H5T_NATIVE_IDX, as_id,
2460 #if defined (HAVE_HDF5_18)
2461 data_hid = H5Gcreate (group_hid,
"symbol table",
2465 data_hid = H5Gcreate (group_hid,
"symbol table", 0);
2469 H5Sclose (space_hid);
2470 H5Tclose (type_hid);
2471 H5Gclose (group_hid);
2475 for (
const auto& nm_val : m_local_vars)
2478 "",
false, save_as_floats))
2482 H5Gclose (data_hid);
2485 H5Sclose (space_hid);
2486 H5Tclose (type_hid);
2487 H5Gclose (group_hid);
2493 octave_unused_parameter (loc_id);
2494 octave_unused_parameter (name);
2495 octave_unused_parameter (save_as_floats);
2509 #if defined (HAVE_HDF5)
2511 bool success =
true;
2513 #if defined (HAVE_HDF5_18)
2521 H5Sclose (space_hid);
2522 H5Tclose (type_hid);
2523 H5Gclose (group_hid);
2527 H5Tclose (type_hid);
2528 type_hid = H5Dget_type (data_hid);
2531 if (type_class_hid != H5T_STRING)
2533 H5Sclose (space_hid);
2534 H5Tclose (type_hid);
2535 H5Dclose (data_hid);
2536 H5Gclose (group_hid);
2540 H5Sclose (space_hid);
2541 space_hid = H5Dget_space (data_hid);
2542 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
2546 H5Sclose (space_hid);
2547 H5Tclose (type_hid);
2548 H5Dclose (data_hid);
2549 H5Gclose (group_hid);
2553 int slen = H5Tget_size (type_hid);
2556 H5Sclose (space_hid);
2557 H5Tclose (type_hid);
2558 H5Dclose (data_hid);
2559 H5Gclose (group_hid);
2567 H5Tset_size (st_id, slen);
2574 H5Sclose (space_hid);
2575 H5Tclose (type_hid);
2576 H5Dclose (data_hid);
2577 H5Gclose (group_hid);
2581 H5Dclose (data_hid);
2594 #if defined (HAVE_HDF5_18)
2598 H5Eget_auto (&err_fcn, &err_fcn_data);
2599 H5Eset_auto (
nullptr,
nullptr);
2602 octave_hdf5_id attr_id = H5Aopen_name (group_hid,
"SYMBOL_TABLE");
2613 #if defined (HAVE_HDF5_18)
2616 H5Eset_auto (err_fcn, err_fcn_data);
2629 if (
len > 0 && success)
2631 hsize_t num_obj = 0;
2632 #if defined (HAVE_HDF5_18)
2635 data_hid = H5Gopen (group_hid,
"symbol table");
2637 H5Gget_num_objs (data_hid, &num_obj);
2638 H5Gclose (data_hid);
2640 if (num_obj !=
static_cast<hsize_t
> (
len))
2641 error (
"load: failed to load anonymous function handle");
2644 int current_item = 0;
2649 error (
"load: failed to load anonymous function handle");
2651 m_local_vars[dsub.
name] = dsub.
tc;
2656 return parse (fcn_tmp);
2662 octave_unused_parameter (group_hid);
2663 octave_unused_parameter (space_hid);
2664 octave_unused_parameter (type_hid);
2672 base_anonymous_fcn_handle::print_raw (std::ostream& os,
bool,
int)
const
2679 error (
"invalid anonymous function handle");
2701 error (
"invalid anonymous function handle");
2708 error (
"invalid anonymous function handle");
2710 tpc.print_fcn_handle_body (e);
2714 base_anonymous_fcn_handle::parse (
const std::string& fcn_text)
2735 = interp.
eval_string (fcn_text,
true, parse_status);
2737 if (parse_status != 0)
2760 anonymous_fcn_handle::anonymous_fcn_handle (
const octave_value& fcn,
2762 const std::shared_ptr<stack_frame>& stack_context)
2763 : base_anonymous_fcn_handle (fcn, local_vars),
2764 m_stack_context (stack_context)
2766 if (m_stack_context)
2767 m_stack_context->mark_closure_context ();
2771 anonymous_fcn_handle::make_weak_anonymous_handle ()
const
2774 (
new weak_anonymous_fcn_handle (*
this)));
2788 return oct_usr_fcn->
execute (tw, nargout, args);
2792 anonymous_fcn_handle::workspace ()
const
2796 for (
const auto& nm_val : m_local_vars)
2797 local_vars_map.
assign (nm_val.first, nm_val.second);
2805 if (m_stack_context)
2807 octave_value ov_frames = m_stack_context->workspace ();
2813 Cell retval =
Cell (num_frames+1, 1);
2814 retval(0) = m_local_vars;
2816 retval(i+1) = cell_frames(i);
2823 const anonymous_fcn_handle& fh2)
2825 if (fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
2826 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
2838 std::shared_ptr<stack_frame> frames = m_stack_context.
lock ();
2844 return oct_usr_fcn->
execute (tw, nargout, args);
2848 weak_anonymous_fcn_handle::workspace ()
const
2852 for (
const auto& nm_val : m_local_vars)
2853 local_vars_map.
assign (nm_val.first, nm_val.second);
2859 std::shared_ptr<stack_frame> frames = m_stack_context.lock ();
2873 Cell retval =
Cell (num_frames+1, 1);
2874 retval(0) = m_local_vars;
2876 retval(i+1) = cell_frames(i);
2883 const weak_anonymous_fcn_handle& fh2)
2885 if (fh1.m_name == fh2.m_name
2886 && fh1.m_fcn.is_defined () && fh2.m_fcn.is_defined ())
2887 return fh1.m_fcn.is_copy_of (fh2.m_fcn);
2892 OCTAVE_END_NAMESPACE(
octave)
2907 const std::string& name)
2912 const std::string& meth_nm)
2914 m_rep (new
octave::class_simple_fcn_handle (class_nm, meth_nm))
2918 const std::string& class_nm,
2919 const std::string& meth_nm)
2921 m_rep (new
octave::class_simple_fcn_handle (fcn, class_nm, meth_nm))
2926 const std::string& class_nm,
2927 const std::string& meth_nm)
2929 m_rep (new
octave::class_simple_fcn_handle (obj, fcn, class_nm, meth_nm))
2933 const std::string& name,
2934 const std::list<std::string>& parentage)
2936 m_rep (new
octave::scoped_fcn_handle (fcn, name, parentage))
2940 const std::string& name,
2941 const std::shared_ptr<octave::stack_frame>& stack_context)
2943 m_rep (new
octave::nested_fcn_handle (fcn, name, stack_context))
2947 const octave::stack_frame::local_vars_map& local_vars,
2948 const std::shared_ptr<octave::stack_frame>& stack_context)
2950 m_rep (new
octave::anonymous_fcn_handle (fcn, local_vars, stack_context))
2960 m_rep.reset (fh.m_rep->clone ());
2973 return m_rep->save_ascii (os);
2979 std::shared_ptr<octave::base_fcn_handle> new_rep;
2984 std::streampos pos = is.tellg ();
2987 if (octaveroot.empty ())
3002 if (! (octaveroot.empty () || fpath.empty ()))
3004 std::size_t
len = octaveroot.size ();
3005 if (octaveroot == fpath.substr (0,
len))
3012 if (subtype.empty ())
3024 new_rep.reset (
new octave::anonymous_fcn_handle ());
3026 new_rep.reset (
new octave::simple_fcn_handle (name, fpath, octaveroot));
3032 if (subtype ==
"simple")
3037 new_rep.reset (
new octave::simple_fcn_handle (name, fpath,
3040 else if (subtype ==
"scopedfunction")
3045 new_rep.reset (
new octave::scoped_fcn_handle (name, fpath,
3048 else if (subtype ==
"anonymous")
3049 new_rep.reset (
new octave::anonymous_fcn_handle ());
3050 else if (subtype ==
"nested")
3055 new_rep.reset (
new octave::nested_fcn_handle (name, fpath,
3058 else if (subtype ==
"classsimple")
3063 new_rep.reset (
new octave::class_simple_fcn_handle (name, fpath,
3071 if (! new_rep->load_ascii (is))
3082 return m_rep->save_binary (os, save_as_floats);
3093 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
3101 is.read (ctmp1, tmp);
3103 std::string name (ctmp1);
3108 std::shared_ptr<octave::base_fcn_handle> new_rep;
3112 if (name.length () >= anl && name.substr (0, anl) ==
anonymous)
3119 new_rep.reset (
new octave::anonymous_fcn_handle (name));
3127 std::string octaveroot;
3129 std::string subtype =
"simple";
3131 if (name.find_first_of (
'\n') != std::string::npos)
3133 std::size_t pos1 = name.find_first_of (
'\n');
3134 std::size_t pos2 = name.find_first_of (
'\n', pos1 + 1);
3135 octaveroot = name.substr (pos1 + 1, pos2 - pos1 - 1);
3136 fpath = name.substr (pos2 + 1);
3137 name = name.substr (0, pos1);
3140 std::size_t pos1 = name.find (
'@');
3141 if (pos1 != std::string::npos)
3143 if (name[pos1+1] ==
'<')
3145 std::size_t pos2 = name.find (
'>', pos1 + 2);
3147 if (pos2 != std::string::npos)
3148 subtype = name.substr (pos1 + 2, pos2 - pos1 - 2);
3151 name = name.substr (0, pos1);
3157 if (subtype ==
"simple")
3158 new_rep.reset (
new octave::simple_fcn_handle (name, fpath, octaveroot));
3159 else if (subtype ==
"scopedfunction")
3160 new_rep.reset (
new octave::scoped_fcn_handle (name, fpath, octaveroot));
3161 else if (subtype ==
"nested")
3162 new_rep.reset (
new octave::nested_fcn_handle (name, fpath, octaveroot));
3163 else if (subtype ==
"classsimple")
3164 new_rep.reset (
new octave::class_simple_fcn_handle (name, fpath,
3171 if (! new_rep->load_binary (is, swap, fmt))
3181 bool save_as_floats)
3183 return m_rep->save_hdf5 (loc_id, name, save_as_floats);
3189 #if defined (HAVE_HDF5)
3191 #if defined (HAVE_HDF5_18)
3199 #if defined (HAVE_HDF5_18)
3207 H5Gclose (group_hid);
3214 if (type_class_hid != H5T_STRING)
3216 H5Tclose (type_hid);
3217 H5Dclose (data_hid);
3218 H5Gclose (group_hid);
3223 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
3227 H5Sclose (space_hid);
3228 H5Tclose (type_hid);
3229 H5Dclose (data_hid);
3230 H5Gclose (group_hid);
3234 int slen = H5Tget_size (type_hid);
3237 H5Sclose (space_hid);
3238 H5Tclose (type_hid);
3239 H5Dclose (data_hid);
3240 H5Gclose (group_hid);
3248 H5Tset_size (st_id, slen);
3255 H5Sclose (space_hid);
3256 H5Tclose (type_hid);
3257 H5Dclose (data_hid);
3258 H5Gclose (group_hid);
3262 H5Dclose (data_hid);
3264 std::string name (nm_tmp);
3266 std::shared_ptr<octave::base_fcn_handle> new_rep;
3273 new_rep.reset (
new octave::anonymous_fcn_handle ());
3281 std::string octaveroot;
3283 std::string subtype =
"simple";
3285 if (name.find_first_of (
'\n') != std::string::npos)
3287 std::size_t pos1 = name.find_first_of (
'\n');
3288 std::size_t pos2 = name.find_first_of (
'\n', pos1 + 1);
3289 octaveroot = name.substr (pos1 + 1, pos2 - pos1 - 1);
3290 fpath = name.substr (pos2 + 1);
3291 name = name.substr (0, pos1);
3294 std::size_t pos1 = name.find (
'@');
3295 if (pos1 != std::string::npos)
3297 if (name[pos1+1] ==
'<')
3299 std::size_t pos2 = name.find (
'>', pos1 + 2);
3301 if (pos2 != std::string::npos)
3302 subtype = name.substr (pos1 + 2, pos2 - pos1 - 2);
3305 name = name.substr (0, pos1);
3311 if (subtype ==
"simple")
3312 new_rep.reset (
new octave::simple_fcn_handle (name, fpath, octaveroot));
3313 else if (subtype ==
"scopedfunction")
3314 new_rep.reset (
new octave::scoped_fcn_handle (name, fpath, octaveroot));
3315 else if (subtype ==
"nested")
3316 new_rep.reset (
new octave::nested_fcn_handle (name, fpath, octaveroot));
3317 else if (subtype ==
"classsimple")
3318 new_rep.reset (
new octave::class_simple_fcn_handle (name, fpath,
3322 bool status =
false;
3324 if (new_rep && new_rep->load_hdf5 (group_hid, space_hid, type_hid))
3332 H5Tclose (type_hid);
3333 H5Sclose (space_hid);
3334 H5Gclose (group_hid);
3340 octave_unused_parameter (loc_id);
3341 octave_unused_parameter (name_arg);
3463 return is_equal_to (*
dynamic_cast<octave::internal_fcn_handle *
> (fh1.get_rep ()),
3464 *
dynamic_cast<octave::internal_fcn_handle *
> (fh2.get_rep ()));
3466 return is_equal_to (*
dynamic_cast<octave::simple_fcn_handle *
> (fh1.get_rep ()),
3467 *
dynamic_cast<octave::simple_fcn_handle *
> (fh2.get_rep ()));
3469 return is_equal_to (*
dynamic_cast<octave::scoped_fcn_handle *
> (fh1.get_rep ()),
3470 *
dynamic_cast<octave::scoped_fcn_handle *
> (fh2.get_rep ()));
3472 return is_equal_to (*
dynamic_cast<octave::nested_fcn_handle *
> (fh1.get_rep ()),
3473 *
dynamic_cast<octave::nested_fcn_handle *
> (fh2.get_rep ()));
3475 return is_equal_to (*
dynamic_cast<octave::class_simple_fcn_handle *
> (fh1.get_rep ()),
3476 *
dynamic_cast<octave::class_simple_fcn_handle *
> (fh2.get_rep ()));
3478 return is_equal_to (*
dynamic_cast<octave::anonymous_fcn_handle *
> (fh1.get_rep ()),
3479 *
dynamic_cast<octave::anonymous_fcn_handle *
> (fh2.get_rep ()));
3486 DEFUN (functions, args, ,
3540 octave_fcn_handle *fh = args(0).xfcn_handle_value (
"functions: FCN_HANDLE argument must be a function handle object");
3545 DEFUN (func2str, args, ,
3556 octave_fcn_handle *fh = args(0).xfcn_handle_value (
"func2str: FCN_HANDLE argument must be a function handle object");
3559 error (
"func2str: FCN_HANDLE must be a valid function handle");
3563 std::string fh_nm = fh->
fcn_name ();
3567 std::ostringstream buf;
3571 retval = buf.str ();
3601 int nargin = args.
length ();
3603 if (nargin < 1 || nargin > 2)
3606 std::string nm = args(0).xstring_value (
"str2func: FCN_NAME must be a string");
3609 error (
"str2func: invalid function name");
3628 if (parse_status == 0)
3635 "str2func: second argument ignored");
3677 DEFUN (is_function_handle, args, ,
3687 return ovl (args(0).is_function_handle ());
3727 OCTAVE_END_NAMESPACE(
octave)
void swap_bytes< 4 >(void *ptr)
octave_idx_type numel() const
Number of elements in the array.
virtual bool save_binary(std::ostream &os, bool save_as_floats)
virtual bool is_scoped() const
virtual bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
virtual bool is_class_simple() const
void unimplemented(const char *op, const char *fmt) const
virtual bool print_as_scalar() const
virtual bool save_ascii(std::ostream &os)
void warn_save(const char *file_type) const
virtual bool load_binary(std::istream &is, bool swap, mach_info::float_format fmt)
virtual bool is_simple() const
virtual bool load_hdf5(octave_hdf5_id &group_hid, octave_hdf5_id &space_hid, octave_hdf5_id &type_hid)
virtual octave_scalar_map info()
virtual octave_value_list call(int nargout, const octave_value_list &args)=0
void warn_load(const char *file_type) const
virtual octave_function * function_value(bool=false)
virtual octave_value make_weak_anonymous_handle() const
virtual octave_value workspace() const
virtual bool is_nested() const
virtual bool load_ascii(std::istream &is)
virtual base_fcn_handle * clone() const =0
virtual octave_value fcn_val()
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
virtual octave_user_function * user_function_value(bool=false)
virtual octave_value make_weak_nested_handle() const
virtual bool is_anonymous() const
virtual std::string type() const =0
virtual void print_raw(std::ostream &, bool, int) const
virtual bool is_internal() const
std::size_t length() const
Vector representing the dimensions (size) of an Array.
octave_value varval(const std::string &name) const
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
symbol_table & get_symbol_table()
tree_evaluator & get_evaluator()
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
int current_print_indent_level() const
void newline(std::ostream &os) const
void warn_load(const char *type) const
virtual octave_function * function_value(bool silent=false)
Array< std::string > cellstr_value() const
bool load_ascii(std::istream &is)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
static const std::string anonymous
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
bool load_ascii(std::istream &is)
bool is_class_simple() const
std::string fcn_name() const
bool save_binary(std::ostream &os, bool save_as_floats)
bool is_anonymous() const
bool save_ascii(std::ostream &os)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
void print(std::ostream &os, bool pr_as_read_syntax=false)
std::string dispatch_class() const
bool is_class_method(const std::string &cname="") const
virtual std::string fcn_file_name() const
void assign(const std::string &k, const octave_value &val)
octave::symbol_scope scope()
std::string fcn_file_name() const
octave_value_list execute(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
octave_user_function * user_function_value(bool=false)
octave_value find_subfunction(const std::string &subfuns) const
octave_idx_type length() const
octave_value_list & prepend(const octave_value &val)
bool is_classdef_object() const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
octave_user_function * user_function_value(bool silent=false) const
bool is_classdef_meta() const
bool save_binary(std::ostream &os, bool save_as_floats)
bool save_ascii(std::ostream &os)
octave_function * function_value(bool silent=false) const
octave_fcn_handle * fcn_handle_value(bool silent=false) const
octave_idx_type length() const
std::map< std::string, octave_value > local_vars_map
void cache_name(const std::string &name)
octave_value find_private_function(const std::string &dir_name, const std::string &name)
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
octave_value find_user_function(const std::string &name)
void set_dispatch_class(const std::string &class_name)
void push_dummy_scope(const std::string &name)
octave_value make_fcn_handle(const std::string &nm)
void push_stack_frame(const symbol_scope &scope)
void accept(tree_walker &tw)
bool is_expression() const
tree_expression * expression()
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5E_DEFAULT
const octave_hdf5_id octave_H5S_ALL
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string octave_exec_home()
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void() error(const char *fmt,...)
#define panic_impossible()
#define panic_unless(cond)
std::string dir_sep_chars()
std::string dirname(const std::string &path)
interpreter & __get_interpreter__()
tree_evaluator & __get_evaluator__()
symbol_table & __get_symbol_table__()
F77_RET_T const F77_DBLE const F77_DBLE * f
std::string read_until_newline(std::istream &is, bool keep_newline)
void skip_preceeding_newline(std::istream &is)
octave_hdf5_err hdf5_h5g_iterate(octave_hdf5_id loc_id, const char *name, int *idx, void *operator_data)
bool add_hdf5_data(octave_hdf5_id loc_id, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_global, bool save_as_floats)
std::string read_binary_data(std::istream &is, bool swap, octave::mach_info::float_format fmt, const std::string &filename, bool &global, octave_value &tc, std::string &doc)
bool save_binary_data(std::ostream &os, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_global, bool save_as_floats)
std::string read_text_data(std::istream &is, const std::string &filename, bool &global, octave_value &tc, octave_idx_type count, const bool do_name_validation)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
bool save_text_data(std::ostream &os, const octave_value &val_arg, const std::string &name, bool mark_global, int precision)
std::string octave_exec_home()
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
bool is_equal_to(const octave_fcn_handle &fh1, const octave_fcn_handle &fh2)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)