comparison libinterp/corefcn/pr-output.cc @ 18484:bcd71a2531d3

Support disp/display overloading in classdef * ov-classdef.h (octave_classdef::print, octave_classdef::print_raw): Move definition to C++ file. (octave_classdef::print_as_scalar): Removed method. (octave_classdef::print_name_tag, octave_classdef::print_with_name): New methods. * ov-classdef.cc (octave_classdef::print): Moved from header. (octave_classdef::print_raw): Likewise. Call overloaded disp, if defined and not called from builtin. (octave_classdef::print_name_tag): New method. (octave_classdef::print_with_name): New method, calls overloaded "display" if defined. * pr-output.cc (octave_print_internal(std::ostream, bool): Avoid compilation warning. (Frats, Fdisp, Ffdisp): Allow to call non-const octave_value::print. * ov.h (octave_value::print): Make non-const. * ov-base.h (octave_base_value::print): Likewise. * ov-base.cc (octave_base_value::print): Likewise. * ov-base-diag.h (octave_base_diag::print): Likewise. * ov-base-diag.cc (octave_base_diag::print): Likewise. * ov-base-mat.h (octave_base_matrix::print): Likewise. * ov-base-mat.cc (octave_base_matrix::print): Likewise. * ov-base-scalar.h (octave_base_scalar::print): Likewise. * ov-base-scalar.cc (octave_base_scalar::print): Likewise. * ov-base-sparse.h (octave_base_sparse::print): Likewise. * ov-base-sparse.cc (octave_base_sparse::print): Likewise. * ov-cell.h (octave_cell::print): Likewise. * ov-cell.cc (octave_cell::print): Likewise. * ov-class.h (octave_class::print): Likewise. * ov-class.cc (octave_class::print): Likewise. * ov-colon.h (octave_magic_colon::print): Likewise. * ov-colon.cc (octave_magic_colon::print): Likewise. * ov-fcn-handle.h (octave_fcn_handle::print): Likewise. * ov-fcn-handle.cc (octave_fcn_handle::print): Likewise. * ov-fcn-inline.h (octave_fcn_inline::print): Likewise. * ov-fcn-inline.cc (octave_fcn_inline::print): Likewise. * ov-java.h (octave_java::print): Likewise. * ov-java.cc (octave_java::print): Likewise. * ov-lazy-idx.h (octave_lazy_index::print): Likewise. * ov-oncleanup.h (octave_oncleanup::print): Likewise. * ov-oncleanup.cc (octave_oncleanup::print): Likewise. * ov-perm.h (octave_perm_matrix::print): Likewise. * ov-perm.cc (octave_perm_matrix::print): Likewise. * ov-range.h (octave_range::print): Likewise. * ov-range.cc (octave_range::print): Likewise. * ov-struct.h (octave_struct::print, octave_scalar_struct): Likewise. * ov-struct.cc (octave_struct::print, octave_scalar_struct): Likewise.
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 31 Jan 2014 11:41:19 -0500
parents b560bac0fca2
children e76d50d65278
comparison
equal deleted inserted replaced
18482:68fc31c69fcb 18484:bcd71a2531d3
3385 { 3385 {
3386 panic_impossible (); 3386 panic_impossible ();
3387 } 3387 }
3388 3388
3389 void 3389 void
3390 octave_print_internal (std::ostream&, const octave_value&, 3390 octave_print_internal (std::ostream&, const octave_value&, bool)
3391 bool pr_as_read_syntax)
3392 { 3391 {
3393 panic_impossible (); 3392 panic_impossible ();
3394 } 3393 }
3395 3394
3396 DEFUN (rats, args, nargout, 3395 DEFUN (rats, args, nargout,
3437 frame.protect_var (rat_format); 3436 frame.protect_var (rat_format);
3438 3437
3439 rat_format = true; 3438 rat_format = true;
3440 3439
3441 std::ostringstream buf; 3440 std::ostringstream buf;
3442 args(0).print (buf); 3441 arg.print (buf);
3443 std::string s = buf.str (); 3442 std::string s = buf.str ();
3444 3443
3445 std::list<std::string> lst; 3444 std::list<std::string> lst;
3446 3445
3447 size_t n = 0; 3446 size_t n = 0;
3499 3498
3500 int nargin = args.length (); 3499 int nargin = args.length ();
3501 3500
3502 if (nargin == 1 && nargout < 2) 3501 if (nargin == 1 && nargout < 2)
3503 { 3502 {
3503 octave_value arg = args(0);
3504
3504 if (nargout == 0) 3505 if (nargout == 0)
3505 args(0).print (octave_stdout); 3506 arg.print (octave_stdout);
3506 else 3507 else
3507 { 3508 {
3508 octave_value arg = args(0);
3509 std::ostringstream buf; 3509 std::ostringstream buf;
3510 arg.print (buf); 3510 arg.print (buf);
3511 retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\''); 3511 retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\'');
3512 } 3512 }
3513 } 3513 }
3548 3548
3549 if (! error_state) 3549 if (! error_state)
3550 { 3550 {
3551 std::ostream *osp = os.output_stream (); 3551 std::ostream *osp = os.output_stream ();
3552 3552
3553 octave_value arg = args(1);
3554
3553 if (osp) 3555 if (osp)
3554 args(1).print (*osp); 3556 arg.print (*osp);
3555 else 3557 else
3556 error ("fdisp: stream FID not open for writing"); 3558 error ("fdisp: stream FID not open for writing");
3557 } 3559 }
3558 } 3560 }
3559 else 3561 else