Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/cellfun.cc @ 10066:2cd940306a06
make unwind_protect frames local
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 13:18:41 +0100 |
parents | 2d7a8c227713 |
children | 84b0725f4b09 |
comparison
equal
deleted
inserted
replaced
10065:64a06079cae4 | 10066:2cd940306a06 |
---|---|
475 return retval; | 475 return retval; |
476 | 476 |
477 if (func.is_function_handle () || func.is_inline_function () | 477 if (func.is_function_handle () || func.is_inline_function () |
478 || func.is_function ()) | 478 || func.is_function ()) |
479 { | 479 { |
480 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame (); | 480 unwind_protect frame; |
481 unwind_protect::protect_var (buffer_error_messages); | 481 frame.protect_var (buffer_error_messages); |
482 | 482 |
483 bool uniform_output = true; | 483 bool uniform_output = true; |
484 octave_value error_handler; | 484 octave_value error_handler; |
485 | 485 |
486 while (nargin > 3 && args(nargin-2).is_string()) | 486 while (nargin > 3 && args(nargin-2).is_string()) |
538 octave_idx_type k = 1; | 538 octave_idx_type k = 1; |
539 | 539 |
540 dim_vector fdims (1, 1); | 540 dim_vector fdims (1, 1); |
541 | 541 |
542 if (error_state) | 542 if (error_state) |
543 goto cellfun_err; | 543 return octave_value_list (); |
544 | 544 |
545 for (int j = 0; j < nargin; j++) | 545 for (int j = 0; j < nargin; j++) |
546 { | 546 { |
547 if (! args(j+1).is_cell ()) | 547 if (! args(j+1).is_cell ()) |
548 { | 548 { |
549 error ("cellfun: arguments must be cells"); | 549 error ("cellfun: arguments must be cells"); |
550 goto cellfun_err; | 550 return octave_value_list (); |
551 } | 551 } |
552 | 552 |
553 inputs[j] = args(j+1).cell_value (); | 553 inputs[j] = args(j+1).cell_value (); |
554 mask[j] = inputs[j].numel () != 1; | 554 mask[j] = inputs[j].numel () != 1; |
555 if (! mask[j]) | 555 if (! mask[j]) |
565 for (int i = j+1; i < nargin; i++) | 565 for (int i = j+1; i < nargin; i++) |
566 { | 566 { |
567 if (mask[i] && inputs[i].dims () != fdims) | 567 if (mask[i] && inputs[i].dims () != fdims) |
568 { | 568 { |
569 error ("cellfun: Dimensions mismatch."); | 569 error ("cellfun: Dimensions mismatch."); |
570 goto cellfun_err; | 570 return octave_value_list (); |
571 } | 571 } |
572 } | 572 } |
573 break; | 573 break; |
574 } | 574 } |
575 } | 575 } |
603 error_state = 0; | 603 error_state = 0; |
604 tmp = error_handler.do_multi_index_op (nargout, errlist); | 604 tmp = error_handler.do_multi_index_op (nargout, errlist); |
605 buffer_error_messages++; | 605 buffer_error_messages++; |
606 | 606 |
607 if (error_state) | 607 if (error_state) |
608 goto cellfun_err; | 608 return octave_value_list (); |
609 } | 609 } |
610 | 610 |
611 if (error_state) | 611 if (error_state) |
612 goto cellfun_err; | 612 return octave_value_list (); |
613 | 613 |
614 if (tmp.length () < nargout1) | 614 if (tmp.length () < nargout1) |
615 { | 615 { |
616 if (tmp.length () < nargout) | 616 if (tmp.length () < nargout) |
617 { | 617 { |
618 error ("cellfun: too many output arguments"); | 618 error ("cellfun: too many output arguments"); |
619 goto cellfun_err; | 619 return octave_value_list (); |
620 } | 620 } |
621 else | 621 else |
622 nargout1 = 0; | 622 nargout1 = 0; |
623 } | 623 } |
624 | 624 |
695 error_state = 0; | 695 error_state = 0; |
696 tmp = error_handler.do_multi_index_op (nargout, errlist); | 696 tmp = error_handler.do_multi_index_op (nargout, errlist); |
697 buffer_error_messages++; | 697 buffer_error_messages++; |
698 | 698 |
699 if (error_state) | 699 if (error_state) |
700 goto cellfun_err; | 700 return octave_value_list (); |
701 } | 701 } |
702 | 702 |
703 if (error_state) | 703 if (error_state) |
704 goto cellfun_err; | 704 return octave_value_list (); |
705 | 705 |
706 if (tmp.length () < nargout1) | 706 if (tmp.length () < nargout1) |
707 { | 707 { |
708 if (tmp.length () < nargout) | 708 if (tmp.length () < nargout) |
709 { | 709 { |
710 error ("cellfun: too many output arguments"); | 710 error ("cellfun: too many output arguments"); |
711 goto cellfun_err; | 711 return octave_value_list (); |
712 } | 712 } |
713 else | 713 else |
714 nargout1 = 0; | 714 nargout1 = 0; |
715 } | 715 } |
716 | 716 |
721 | 721 |
722 retval.resize(nargout1); | 722 retval.resize(nargout1); |
723 for (int j = 0; j < nargout1; j++) | 723 for (int j = 0; j < nargout1; j++) |
724 retval(j) = results[j]; | 724 retval(j) = results[j]; |
725 } | 725 } |
726 | |
727 cellfun_err: | |
728 if (error_state) | |
729 retval = octave_value_list(); | |
730 | |
731 unwind_protect::run_frame (uwp_frame); | |
732 } | 726 } |
733 else | 727 else |
734 error ("cellfun: first argument must be a string or function handle"); | 728 error ("cellfun: first argument must be a string or function handle"); |
735 | 729 |
736 return retval; | 730 return retval; |