comparison libinterp/octave-value/ov-classdef.cc @ 15955:837a4a9b5049 classdef

Support constructor call with no indexing syntax. * libinterp/octave-value/ov-classdef.cc (octave_classdef_proxy::do_multi_index_op): Emulate constructor. (octave_classdef_proxy::is_postfix_index_handled): New method, support '(' and '.' index. (octave_classdef_proxy::function_value): New method, return itself.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 15 Jan 2013 17:01:13 -0500
parents 8521321604df
children d8553705f8f0
comparison
equal deleted inserted replaced
15954:46ca8488de92 15955:837a4a9b5049
851 { 851 {
852 // This means the class has been cleared from the symbol table. 852 // This means the class has been cleared from the symbol table.
853 all_classes.erase (klass.get_name ()); 853 all_classes.erase (klass.get_name ());
854 } 854 }
855 855
856 octave_function* function_value (bool = false) { return this; }
857
856 octave_value_list 858 octave_value_list
857 subsref (const std::string& type, 859 subsref (const std::string& type,
858 const std::list<octave_value_list>& idx, 860 const std::list<octave_value_list>& idx,
859 int nargout) 861 int nargout)
860 { return klass.subsref_meta (type, idx, nargout); } 862 { return klass.subsref_meta (type, idx, nargout); }
869 871
870 return (retval.length () > 0 ? retval(0) : octave_value ()); 872 return (retval.length () > 0 ? retval(0) : octave_value ());
871 } 873 }
872 874
873 octave_value_list 875 octave_value_list
874 do_multi_index_op (int /* nargout */, const octave_value_list& /* idx */) 876 do_multi_index_op (int nargout, const octave_value_list& idx)
875 { return to_ov (klass); } 877 {
878 // Emulate constructor
879
880 std::list<octave_value_list> l (1, idx);
881 std::string type ("(");
882
883 return subsref (type, l, nargout);
884 }
885
886 bool is_postfix_index_handled (char type) const
887 { return (type == '(' || type == '.'); }
876 888
877 private: 889 private:
878 cdef_class klass; 890 cdef_class klass;
879 }; 891 };
880 892