comparison libinterp/corefcn/mex.cc @ 17787:175b392e91fe

Use GNU style coding conventions for code in libinterp/ * libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc, libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc, libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc, libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h, libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h, libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc, libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc, libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc, libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc, libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h, libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc, libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc, libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h, libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/input.h, libinterp/corefcn/inv.cc, libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h, libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc, libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc, libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc, libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc, libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h, libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h, libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h, libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h, libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h, libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h, libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc, libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h, libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc, libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h, libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc, libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc, libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc, libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc, libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc, libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc, libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h, libinterp/octave-value/ov-base-scalar.cc, libinterp/octave-value/ov-base-scalar.h, libinterp/octave-value/ov-base-sparse.cc, libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc, libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc, libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc, libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc, libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h, libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h, libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-handle.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h, libinterp/octave-value/ov-flt-complex.cc, libinterp/octave-value/ov-flt-complex.h, libinterp/octave-value/ov-flt-cx-diag.cc, libinterp/octave-value/ov-flt-cx-diag.h, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.h, libinterp/octave-value/ov-flt-re-diag.cc, libinterp/octave-value/ov-flt-re-diag.h, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc, libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc, libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h, libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h, libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc, libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc, libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc, libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc, libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc, libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc, libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h, libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc, libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc, libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc, libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc, libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc, libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc, libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc, libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc, libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc, libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc, libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc, libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc, libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc, libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc, libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc, libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc, libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc, libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc, libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc, libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc, libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc, libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc, libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc, libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc, libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc, libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc, libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc, libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc, libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc, libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc, libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc, libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc, libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc, libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc, libinterp/operators/ops.h, libinterp/parse-tree/lex.h, libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc, libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc, libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc, libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h, libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc, libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc, libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc, libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h, libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc, libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc, libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/token.h, libinterp/version.cc: Use GNU style coding conventions for code in libinterp/
author Rik <rik@octave.org>
date Mon, 28 Oct 2013 19:51:46 -0700
parents d63878346099
children 6da521da1c70
comparison
equal deleted inserted replaced
17786:34d9812a943b 17787:175b392e91fe
95 95
96 retval = 1; 96 retval = 1;
97 } 97 }
98 } 98 }
99 99
100 done: 100 done:
101 101
102 return retval; 102 return retval;
103 } 103 }
104 104
105 // ------------------------------------------------------------------ 105 // ------------------------------------------------------------------
243 { 243 {
244 if (! dims) 244 if (! dims)
245 { 245 {
246 ndims = val.ndims (); 246 ndims = val.ndims ();
247 247
248 dims = static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))); 248 dims = static_cast<mwSize *> (mxArray::malloc (ndims
249 * sizeof (mwSize)));
249 250
250 dim_vector dv = val.dims (); 251 dim_vector dv = val.dims ();
251 252
252 for (mwIndex i = 0; i < ndims; i++) 253 for (mwIndex i = 0; i < ndims; i++)
253 dims[i] = dv(i); 254 dims[i] = dv(i);
408 request_mutation (); 409 request_mutation ();
409 return 0; 410 return 0;
410 } 411 }
411 412
412 // Not allowed. 413 // Not allowed.
413 void set_field_by_number (mwIndex /*index*/, int /*key_num*/, mxArray */*val*/) 414 void set_field_by_number (mwIndex /*index*/, int /*key_num*/,
415 mxArray */*val*/)
414 { 416 {
415 request_mutation (); 417 request_mutation ();
416 } 418 }
417 419
418 int get_number_of_fields (void) const { return val.nfields (); } 420 int get_number_of_fields (void) const { return val.nfields (); }
452 return retval; 454 return retval;
453 } 455 }
454 456
455 char *array_to_string (void) const 457 char *array_to_string (void) const
456 { 458 {
457 // FIXME -- this is suposed to handle multi-byte character 459 // FIXME: this is suposed to handle multi-byte character strings.
458 // strings.
459 460
460 char *buf = 0; 461 char *buf = 0;
461 462
462 if (val.is_string ()) 463 if (val.is_string ())
463 { 464 {
533 534
534 mxArray_octave_value (const mxArray_octave_value& arg) 535 mxArray_octave_value (const mxArray_octave_value& arg)
535 : mxArray_base (arg), val (arg.val), mutate_flag (arg.mutate_flag), 536 : mxArray_base (arg), val (arg.val), mutate_flag (arg.mutate_flag),
536 id (arg.id), class_name (mxArray::strsave (arg.class_name)), 537 id (arg.id), class_name (mxArray::strsave (arg.class_name)),
537 ndims (arg.ndims), 538 ndims (arg.ndims),
538 dims (ndims > 0 ? static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))) : 0) 539 dims (ndims > 0 ? static_cast<mwSize *>
540 (mxArray::malloc (ndims * sizeof (mwSize)))
541 : 0)
539 { 542 {
540 if (dims) 543 if (dims)
541 { 544 {
542 for (mwIndex i = 0; i < ndims; i++) 545 for (mwIndex i = 0; i < ndims; i++)
543 dims[i] = arg.dims[i]; 546 dims[i] = arg.dims[i];
557 mutable mxClassID id; 560 mutable mxClassID id;
558 mutable char *class_name; 561 mutable char *class_name;
559 mutable mwSize ndims; 562 mutable mwSize ndims;
560 mutable mwSize *dims; 563 mutable mwSize *dims;
561 564
562 // No assignment! FIXME -- should this be implemented? Note that we 565 // No assignment! FIXME: should this be implemented? Note that we
563 // do have a copy constructor. 566 // do have a copy constructor.
564 567
565 mxArray_octave_value& operator = (const mxArray_octave_value&); 568 mxArray_octave_value& operator = (const mxArray_octave_value&);
566 }; 569 };
567 570
837 { 840 {
838 invalid_type_error (); 841 invalid_type_error ();
839 return 0; 842 return 0;
840 } 843 }
841 844
842 void set_field_by_number (mwIndex /*index*/, int /*key_num*/, mxArray */*val*/) 845 void set_field_by_number (mwIndex /*index*/, int /*key_num*/,
846 mxArray */*val*/)
843 { 847 {
844 invalid_type_error (); 848 invalid_type_error ();
845 } 849 }
846 850
847 int get_number_of_fields (void) const 851 int get_number_of_fields (void) const
940 void invalid_type_error (void) const 944 void invalid_type_error (void) const
941 { 945 {
942 error ("invalid type for operation"); 946 error ("invalid type for operation");
943 } 947 }
944 948
945 // No assignment! FIXME -- should this be implemented? Note that we 949 // No assignment! FIXME: should this be implemented? Note that we
946 // do have a copy constructor. 950 // do have a copy constructor.
947 951
948 mxArray_matlab& operator = (const mxArray_matlab&); 952 mxArray_matlab& operator = (const mxArray_matlab&);
949 }; 953 };
950 954
956 960
957 mxArray_number (mxClassID id_arg, mwSize ndims_arg, const mwSize *dims_arg, 961 mxArray_number (mxClassID id_arg, mwSize ndims_arg, const mwSize *dims_arg,
958 mxComplexity flag = mxREAL) 962 mxComplexity flag = mxREAL)
959 : mxArray_matlab (id_arg, ndims_arg, dims_arg), 963 : mxArray_matlab (id_arg, ndims_arg, dims_arg),
960 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())), 964 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
961 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (), get_element_size ()) : 0) { } 965 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (),
966 get_element_size ())
967 : 0) { }
962 968
963 mxArray_number (mxClassID id_arg, const dim_vector& dv, 969 mxArray_number (mxClassID id_arg, const dim_vector& dv,
964 mxComplexity flag = mxREAL) 970 mxComplexity flag = mxREAL)
965 : mxArray_matlab (id_arg, dv), 971 : mxArray_matlab (id_arg, dv),
966 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())), 972 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
967 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (), get_element_size ()) : 0) { } 973 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (),
968 974 get_element_size ())
969 mxArray_number (mxClassID id_arg, mwSize m, mwSize n, mxComplexity flag = mxREAL) 975 : 0) { }
976
977 mxArray_number (mxClassID id_arg, mwSize m, mwSize n,
978 mxComplexity flag = mxREAL)
970 : mxArray_matlab (id_arg, m, n), 979 : mxArray_matlab (id_arg, m, n),
971 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())), 980 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
972 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (), get_element_size ()) : 0) { } 981 pi (flag == mxCOMPLEX ? mxArray::calloc (get_number_of_elements (),
982 get_element_size ())
983 : 0) { }
973 984
974 mxArray_number (mxClassID id_arg, double val) 985 mxArray_number (mxClassID id_arg, double val)
975 : mxArray_matlab (id_arg, 1, 1), 986 : mxArray_matlab (id_arg, 1, 1),
976 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())), 987 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
977 pi (0) 988 pi (0)
991 1002
992 mxArray_number (const char *str) 1003 mxArray_number (const char *str)
993 : mxArray_matlab (mxCHAR_CLASS, 1004 : mxArray_matlab (mxCHAR_CLASS,
994 str ? (strlen (str) ? 1 : 0) : 0, 1005 str ? (strlen (str) ? 1 : 0) : 0,
995 str ? strlen (str) : 0), 1006 str ? strlen (str) : 0),
996 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())), 1007 pr (mxArray::calloc (get_number_of_elements (), get_element_size ())),
997 pi (0) 1008 pi (0)
998 { 1009 {
999 mxChar *cpr = static_cast<mxChar *> (pr); 1010 mxChar *cpr = static_cast<mxChar *> (pr);
1000 mwSize nel = get_number_of_elements (); 1011 mwSize nel = get_number_of_elements ();
1001 for (mwIndex i = 0; i < nel; i++) 1012 for (mwIndex i = 0; i < nel; i++)
1002 cpr[i] = str[i]; 1013 cpr[i] = str[i];
1133 return retval; 1144 return retval;
1134 } 1145 }
1135 1146
1136 char *array_to_string (void) const 1147 char *array_to_string (void) const
1137 { 1148 {
1138 // FIXME -- this is suposed to handle multi-byte character 1149 // FIXME: this is suposed to handle multi-byte character strings.
1139 // strings.
1140 1150
1141 mwSize nel = get_number_of_elements (); 1151 mwSize nel = get_number_of_elements ();
1142 1152
1143 char *buf = static_cast<char *> (mxArray::malloc (nel + 1)); 1153 char *buf = static_cast<char *> (mxArray::malloc (nel + 1));
1144 1154
1319 } 1329 }
1320 1330
1321 mxArray_number (const mxArray_number& val) 1331 mxArray_number (const mxArray_number& val)
1322 : mxArray_matlab (val), 1332 : mxArray_matlab (val),
1323 pr (mxArray::malloc (get_number_of_elements () * get_element_size ())), 1333 pr (mxArray::malloc (get_number_of_elements () * get_element_size ())),
1324 pi (val.pi ? mxArray::malloc (get_number_of_elements () * get_element_size ()) : 0) 1334 pi (val.pi ? mxArray::malloc (get_number_of_elements ()
1335 * get_element_size ())
1336 : 0)
1325 { 1337 {
1326 size_t nbytes = get_number_of_elements () * get_element_size (); 1338 size_t nbytes = get_number_of_elements () * get_element_size ();
1327 1339
1328 if (pr) 1340 if (pr)
1329 memcpy (pr, val.pr, nbytes); 1341 memcpy (pr, val.pr, nbytes);
1335 private: 1347 private:
1336 1348
1337 void *pr; 1349 void *pr;
1338 void *pi; 1350 void *pi;
1339 1351
1340 // No assignment! FIXME -- should this be implemented? Note that we 1352 // No assignment! FIXME: should this be implemented? Note that we
1341 // do have a copy constructor. 1353 // do have a copy constructor.
1342 1354
1343 mxArray_number& operator = (const mxArray_number&); 1355 mxArray_number& operator = (const mxArray_number&);
1344 }; 1356 };
1345 1357
1354 : mxArray_matlab (id_arg, m, n), nzmax (nzmax_arg), 1366 : mxArray_matlab (id_arg, m, n), nzmax (nzmax_arg),
1355 pr (mxArray::calloc (nzmax, get_element_size ())), 1367 pr (mxArray::calloc (nzmax, get_element_size ())),
1356 pi (flag == mxCOMPLEX ? mxArray::calloc (nzmax, get_element_size ()) : 0), 1368 pi (flag == mxCOMPLEX ? mxArray::calloc (nzmax, get_element_size ()) : 0),
1357 ir (static_cast<mwIndex *> (mxArray::calloc (nzmax, sizeof (mwIndex)))), 1369 ir (static_cast<mwIndex *> (mxArray::calloc (nzmax, sizeof (mwIndex)))),
1358 jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex)))) 1370 jc (static_cast<mwIndex *> (mxArray::calloc (n + 1, sizeof (mwIndex))))
1359 { } 1371 { }
1360 1372
1361 mxArray_base *dup (void) const { return new mxArray_sparse (*this); } 1373 mxArray_base *dup (void) const { return new mxArray_sparse (*this); }
1362 1374
1363 ~mxArray_sparse (void) 1375 ~mxArray_sparse (void)
1364 { 1376 {
1502 1514
1503 if (jc) 1515 if (jc)
1504 memcpy (jc, val.jc, (val.get_n () + 1) * sizeof (mwIndex)); 1516 memcpy (jc, val.jc, (val.get_n () + 1) * sizeof (mwIndex));
1505 } 1517 }
1506 1518
1507 // No assignment! FIXME -- should this be implemented? Note that we 1519 // No assignment! FIXME: should this be implemented? Note that we
1508 // do have a copy constructor. 1520 // do have a copy constructor.
1509 1521
1510 mxArray_sparse& operator = (const mxArray_sparse&); 1522 mxArray_sparse& operator = (const mxArray_sparse&);
1511 }; 1523 };
1512 1524
1516 { 1528 {
1517 public: 1529 public:
1518 1530
1519 mxArray_struct (mwSize ndims_arg, const mwSize *dims_arg, int num_keys_arg, 1531 mxArray_struct (mwSize ndims_arg, const mwSize *dims_arg, int num_keys_arg,
1520 const char **keys) 1532 const char **keys)
1521 : mxArray_matlab (mxSTRUCT_CLASS, ndims_arg, dims_arg), nfields (num_keys_arg), 1533 : mxArray_matlab (mxSTRUCT_CLASS, ndims_arg, dims_arg),
1522 fields (static_cast<char **> (mxArray::calloc (nfields, sizeof (char *)))), 1534 nfields (num_keys_arg),
1523 data (static_cast<mxArray **> (mxArray::calloc (nfields * get_number_of_elements (), sizeof (mxArray *)))) 1535 fields (static_cast<char **> (mxArray::calloc (nfields,
1536 sizeof (char *)))),
1537 data (static_cast<mxArray **> (mxArray::calloc (nfields *
1538 get_number_of_elements (),
1539 sizeof (mxArray *))))
1524 { 1540 {
1525 init (keys); 1541 init (keys);
1526 } 1542 }
1527 1543
1528 mxArray_struct (const dim_vector& dv, int num_keys_arg, const char **keys) 1544 mxArray_struct (const dim_vector& dv, int num_keys_arg, const char **keys)
1529 : mxArray_matlab (mxSTRUCT_CLASS, dv), nfields (num_keys_arg), 1545 : mxArray_matlab (mxSTRUCT_CLASS, dv), nfields (num_keys_arg),
1530 fields (static_cast<char **> (mxArray::calloc (nfields, sizeof (char *)))), 1546 fields (static_cast<char **> (mxArray::calloc (nfields,
1531 data (static_cast<mxArray **> (mxArray::calloc (nfields * get_number_of_elements (), sizeof (mxArray *)))) 1547 sizeof (char *)))),
1548 data (static_cast<mxArray **> (mxArray::calloc (nfields *
1549 get_number_of_elements (),
1550 sizeof (mxArray *))))
1532 { 1551 {
1533 init (keys); 1552 init (keys);
1534 } 1553 }
1535 1554
1536 mxArray_struct (mwSize m, mwSize n, int num_keys_arg, const char **keys) 1555 mxArray_struct (mwSize m, mwSize n, int num_keys_arg, const char **keys)
1537 : mxArray_matlab (mxSTRUCT_CLASS, m, n), nfields (num_keys_arg), 1556 : mxArray_matlab (mxSTRUCT_CLASS, m, n), nfields (num_keys_arg),
1538 fields (static_cast<char **> (mxArray::calloc (nfields, sizeof (char *)))), 1557 fields (static_cast<char **> (mxArray::calloc (nfields,
1539 data (static_cast<mxArray **> (mxArray::calloc (nfields * get_number_of_elements (), sizeof (mxArray *)))) 1558 sizeof (char *)))),
1559 data (static_cast<mxArray **> (mxArray::calloc (nfields *
1560 get_number_of_elements (),
1561 sizeof (mxArray *))))
1540 { 1562 {
1541 init (keys); 1563 init (keys);
1542 } 1564 }
1543 1565
1544 void init (const char **keys) 1566 void init (const char **keys)
1570 1592
1571 if (valid_key (key)) 1593 if (valid_key (key))
1572 { 1594 {
1573 nfields++; 1595 nfields++;
1574 1596
1575 fields = static_cast<char **> (mxRealloc (fields, nfields * sizeof (char *))); 1597 fields = static_cast<char **>
1598 (mxRealloc (fields, nfields * sizeof (char *)));
1576 1599
1577 if (fields) 1600 if (fields)
1578 { 1601 {
1579 fields[nfields-1] = mxArray::strsave (key); 1602 fields[nfields-1] = mxArray::strsave (key);
1580 1603
1581 mwSize nel = get_number_of_elements (); 1604 mwSize nel = get_number_of_elements ();
1582 1605
1583 mwSize ntot = nfields * nel; 1606 mwSize ntot = nfields * nel;
1584 1607
1585 mxArray **new_data = static_cast<mxArray **> (mxArray::malloc (ntot * sizeof (mxArray *))); 1608 mxArray **new_data;
1609 new_data = static_cast<mxArray **>
1610 (mxArray::malloc (ntot * sizeof (mxArray *)));
1586 1611
1587 if (new_data) 1612 if (new_data)
1588 { 1613 {
1589 mwIndex j = 0; 1614 mwIndex j = 0;
1590 mwIndex k = 0; 1615 mwIndex k = 0;
1621 1646
1622 mwSize ntot = nfields * nel; 1647 mwSize ntot = nfields * nel;
1623 1648
1624 int new_nfields = nfields - 1; 1649 int new_nfields = nfields - 1;
1625 1650
1626 char **new_fields = static_cast<char **> (mxArray::malloc (new_nfields * sizeof (char *))); 1651 char **new_fields = static_cast<char **>
1627 1652 (mxArray::malloc (new_nfields * sizeof (char *)));
1628 mxArray **new_data = static_cast<mxArray **> (mxArray::malloc (new_nfields * nel * sizeof (mxArray *))); 1653
1654 mxArray **new_data = static_cast<mxArray **>
1655 (mxArray::malloc (new_nfields * nel
1656 * sizeof (mxArray *)));
1629 1657
1630 for (int i = 0; i < key_num; i++) 1658 for (int i = 0; i < key_num; i++)
1631 new_fields[i] = fields[i]; 1659 new_fields[i] = fields[i];
1632 1660
1633 for (int i = key_num + 1; i < nfields; i++) 1661 for (int i = key_num + 1; i < nfields; i++)
1662 } 1690 }
1663 1691
1664 mxArray *get_field_by_number (mwIndex index, int key_num) const 1692 mxArray *get_field_by_number (mwIndex index, int key_num) const
1665 { 1693 {
1666 return key_num >= 0 && key_num < nfields 1694 return key_num >= 0 && key_num < nfields
1667 ? data[nfields * index + key_num] : 0; 1695 ? data[nfields * index + key_num] : 0;
1668 } 1696 }
1669 1697
1670 void set_field_by_number (mwIndex index, int key_num, mxArray *val); 1698 void set_field_by_number (mwIndex index, int key_num, mxArray *val);
1671 1699
1672 int get_number_of_fields (void) const { return nfields; } 1700 int get_number_of_fields (void) const { return nfields; }
1730 1758
1731 mxArray **data; 1759 mxArray **data;
1732 1760
1733 mxArray_struct (const mxArray_struct& val) 1761 mxArray_struct (const mxArray_struct& val)
1734 : mxArray_matlab (val), nfields (val.nfields), 1762 : mxArray_matlab (val), nfields (val.nfields),
1735 fields (static_cast<char **> (mxArray::malloc (nfields * sizeof (char *)))), 1763 fields (static_cast<char **> (mxArray::malloc (nfields
1736 data (static_cast<mxArray **> (mxArray::malloc (nfields * get_number_of_elements () * sizeof (mxArray *)))) 1764 * sizeof (char *)))),
1765 data (static_cast<mxArray **> (mxArray::malloc (nfields *
1766 get_number_of_elements ()
1767 * sizeof (mxArray *))))
1737 { 1768 {
1738 for (int i = 0; i < nfields; i++) 1769 for (int i = 0; i < nfields; i++)
1739 fields[i] = mxArray::strsave (val.fields[i]); 1770 fields[i] = mxArray::strsave (val.fields[i]);
1740 1771
1741 mwSize nel = get_number_of_elements (); 1772 mwSize nel = get_number_of_elements ();
1745 mxArray *ptr = val.data[i]; 1776 mxArray *ptr = val.data[i];
1746 data[i] = ptr ? ptr->dup () : 0; 1777 data[i] = ptr ? ptr->dup () : 0;
1747 } 1778 }
1748 } 1779 }
1749 1780
1750 // No assignment! FIXME -- should this be implemented? Note that we 1781 // No assignment! FIXME: should this be implemented? Note that we
1751 // do have a copy constructor. 1782 // do have a copy constructor.
1752 1783
1753 mxArray_struct& operator = (const mxArray_struct& val); 1784 mxArray_struct& operator = (const mxArray_struct& val);
1754 }; 1785 };
1755 1786
1759 { 1790 {
1760 public: 1791 public:
1761 1792
1762 mxArray_cell (mwSize ndims_arg, const mwSize *dims_arg) 1793 mxArray_cell (mwSize ndims_arg, const mwSize *dims_arg)
1763 : mxArray_matlab (mxCELL_CLASS, ndims_arg, dims_arg), 1794 : mxArray_matlab (mxCELL_CLASS, ndims_arg, dims_arg),
1764 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) { } 1795 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
1796 sizeof (mxArray *)))) { }
1765 1797
1766 mxArray_cell (const dim_vector& dv) 1798 mxArray_cell (const dim_vector& dv)
1767 : mxArray_matlab (mxCELL_CLASS, dv), 1799 : mxArray_matlab (mxCELL_CLASS, dv),
1768 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) { } 1800 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
1801 sizeof (mxArray *)))) { }
1769 1802
1770 mxArray_cell (mwSize m, mwSize n) 1803 mxArray_cell (mwSize m, mwSize n)
1771 : mxArray_matlab (mxCELL_CLASS, m, n), 1804 : mxArray_matlab (mxCELL_CLASS, m, n),
1772 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (), sizeof (mxArray *)))) { } 1805 data (static_cast<mxArray **> (mxArray::calloc (get_number_of_elements (),
1806 sizeof (mxArray *)))) { }
1773 1807
1774 mxArray_base *dup (void) const { return new mxArray_cell (*this); } 1808 mxArray_base *dup (void) const { return new mxArray_cell (*this); }
1775 1809
1776 ~mxArray_cell (void) 1810 ~mxArray_cell (void)
1777 { 1811 {
1814 1848
1815 mxArray **data; 1849 mxArray **data;
1816 1850
1817 mxArray_cell (const mxArray_cell& val) 1851 mxArray_cell (const mxArray_cell& val)
1818 : mxArray_matlab (val), 1852 : mxArray_matlab (val),
1819 data (static_cast<mxArray **> (mxArray::malloc (get_number_of_elements () * sizeof (mxArray *)))) 1853 data (static_cast<mxArray **> (mxArray::malloc (get_number_of_elements ()
1854 * sizeof (mxArray *))))
1820 { 1855 {
1821 mwSize nel = get_number_of_elements (); 1856 mwSize nel = get_number_of_elements ();
1822 1857
1823 for (mwIndex i = 0; i < nel; i++) 1858 for (mwIndex i = 0; i < nel; i++)
1824 { 1859 {
1825 mxArray *ptr = val.data[i]; 1860 mxArray *ptr = val.data[i];
1826 data[i] = ptr ? ptr->dup () : 0; 1861 data[i] = ptr ? ptr->dup () : 0;
1827 } 1862 }
1828 } 1863 }
1829 1864
1830 // No assignment! FIXME -- should this be implemented? Note that we 1865 // No assignment! FIXME: should this be implemented? Note that we
1831 // do have a copy constructor. 1866 // do have a copy constructor.
1832 1867
1833 mxArray_cell& operator = (const mxArray_cell&); 1868 mxArray_cell& operator = (const mxArray_cell&);
1834 }; 1869 };
1835 1870
1836 // ------------------------------------------------------------------ 1871 // ------------------------------------------------------------------
1837 1872
1838 mxArray::mxArray (const octave_value& ov) 1873 mxArray::mxArray (const octave_value& ov)
1839 : rep (new mxArray_octave_value (ov)), name (0) { } 1874 : rep (new mxArray_octave_value (ov)), name (0) { }
1840 1875
1841 mxArray::mxArray (mxClassID id, mwSize ndims, const mwSize *dims, mxComplexity flag) 1876 mxArray::mxArray (mxClassID id, mwSize ndims, const mwSize *dims,
1877 mxComplexity flag)
1842 : rep (new mxArray_number (id, ndims, dims, flag)), name (0) { } 1878 : rep (new mxArray_number (id, ndims, dims, flag)), name (0) { }
1843 1879
1844 mxArray::mxArray (mxClassID id, const dim_vector& dv, mxComplexity flag) 1880 mxArray::mxArray (mxClassID id, const dim_vector& dv, mxComplexity flag)
1845 : rep (new mxArray_number (id, dv, flag)), name (0) { } 1881 : rep (new mxArray_number (id, dv, flag)), name (0) { }
1846 1882
1857 : rep (new mxArray_number (str)), name (0) { } 1893 : rep (new mxArray_number (str)), name (0) { }
1858 1894
1859 mxArray::mxArray (mwSize m, const char **str) 1895 mxArray::mxArray (mwSize m, const char **str)
1860 : rep (new mxArray_number (m, str)), name (0) { } 1896 : rep (new mxArray_number (m, str)), name (0) { }
1861 1897
1862 mxArray::mxArray (mxClassID id, mwSize m, mwSize n, mwSize nzmax, mxComplexity flag) 1898 mxArray::mxArray (mxClassID id, mwSize m, mwSize n, mwSize nzmax,
1899 mxComplexity flag)
1863 : rep (new mxArray_sparse (id, m, n, nzmax, flag)), name (0) { } 1900 : rep (new mxArray_sparse (id, m, n, nzmax, flag)), name (0) { }
1864 1901
1865 mxArray::mxArray (mwSize ndims, const mwSize *dims, int num_keys, const char **keys) 1902 mxArray::mxArray (mwSize ndims, const mwSize *dims, int num_keys,
1903 const char **keys)
1866 : rep (new mxArray_struct (ndims, dims, num_keys, keys)), name (0) { } 1904 : rep (new mxArray_struct (ndims, dims, num_keys, keys)), name (0) { }
1867 1905
1868 mxArray::mxArray (const dim_vector& dv, int num_keys, const char **keys) 1906 mxArray::mxArray (const dim_vector& dv, int num_keys, const char **keys)
1869 : rep (new mxArray_struct (dv, num_keys, keys)), name (0) { } 1907 : rep (new mxArray_struct (dv, num_keys, keys)), name (0) { }
1870 1908
1990 { 2028 {
1991 void *ptr = gnulib::malloc (n); 2029 void *ptr = gnulib::malloc (n);
1992 2030
1993 if (! ptr) 2031 if (! ptr)
1994 { 2032 {
1995 // FIXME -- could use "octave_new_handler();" instead 2033 // FIXME: could use "octave_new_handler();" instead
1996 2034
1997 error ("%s: failed to allocate %d bytes of memory", 2035 error ("%s: failed to allocate %d bytes of memory",
1998 function_name (), n); 2036 function_name (), n);
1999 2037
2000 abort (); 2038 abort ();
2371 } 2409 }
2372 2410
2373 void * 2411 void *
2374 mxRealloc (void *ptr, size_t size) 2412 mxRealloc (void *ptr, size_t size)
2375 { 2413 {
2376 return mex_context ? mex_context->realloc (ptr, size) : gnulib::realloc (ptr, size); 2414 return mex_context ? mex_context->realloc (ptr, size)
2415 : gnulib::realloc (ptr, size);
2377 } 2416 }
2378 2417
2379 void 2418 void
2380 mxFree (void *ptr) 2419 mxFree (void *ptr)
2381 { 2420 {
2452 { 2491 {
2453 return maybe_mark_array (new mxArray (class_id, ndims, dims, flag)); 2492 return maybe_mark_array (new mxArray (class_id, ndims, dims, flag));
2454 } 2493 }
2455 2494
2456 mxArray * 2495 mxArray *
2457 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id, mxComplexity flag) 2496 mxCreateNumericMatrix (mwSize m, mwSize n, mxClassID class_id,
2497 mxComplexity flag)
2458 { 2498 {
2459 return maybe_mark_array (new mxArray (class_id, m, n, flag)); 2499 return maybe_mark_array (new mxArray (class_id, m, n, flag));
2460 } 2500 }
2461 2501
2462 mxArray * 2502 mxArray *
2476 { 2516 {
2477 return maybe_mark_array (new mxArray (str)); 2517 return maybe_mark_array (new mxArray (str));
2478 } 2518 }
2479 2519
2480 mxArray * 2520 mxArray *
2481 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys, const char **keys) 2521 mxCreateStructArray (mwSize ndims, const mwSize *dims, int num_keys,
2522 const char **keys)
2482 { 2523 {
2483 return maybe_mark_array (new mxArray (ndims, dims, num_keys, keys)); 2524 return maybe_mark_array (new mxArray (ndims, dims, num_keys, keys));
2484 } 2525 }
2485 2526
2486 mxArray * 2527 mxArray *
2920 } 2961 }
2921 2962
2922 // ------------------------------------------------------------------ 2963 // ------------------------------------------------------------------
2923 2964
2924 typedef void (*cmex_fptr) (int nlhs, mxArray **plhs, int nrhs, mxArray **prhs); 2965 typedef void (*cmex_fptr) (int nlhs, mxArray **plhs, int nrhs, mxArray **prhs);
2925 typedef F77_RET_T (*fmex_fptr) (int& nlhs, mxArray **plhs, int& nrhs, mxArray **prhs); 2966 typedef F77_RET_T (*fmex_fptr) (int& nlhs, mxArray **plhs,
2967 int& nrhs, mxArray **prhs);
2926 2968
2927 octave_value_list 2969 octave_value_list
2928 call_mex (bool have_fmex, void *f, const octave_value_list& args, 2970 call_mex (bool have_fmex, void *f, const octave_value_list& args,
2929 int nargout_arg, octave_mex_function *curr_mex_fcn) 2971 int nargout_arg, octave_mex_function *curr_mex_fcn)
2930 { 2972 {
3012 mexCallMATLAB (int nargout, mxArray *argout[], int nargin, 3054 mexCallMATLAB (int nargout, mxArray *argout[], int nargin,
3013 mxArray *argin[], const char *fname) 3055 mxArray *argin[], const char *fname)
3014 { 3056 {
3015 octave_value_list args; 3057 octave_value_list args;
3016 3058
3017 // FIXME -- do we need unwind protect to clean up args? Off hand, I 3059 // FIXME: do we need unwind protect to clean up args? Off hand, I
3018 // would say that this problem is endemic to Octave and we will 3060 // would say that this problem is endemic to Octave and we will
3019 // continue to have memory leaks after Ctrl-C until proper exception 3061 // continue to have memory leaks after Ctrl-C until proper exception
3020 // handling is implemented. longjmp() only clears the stack, so any 3062 // handling is implemented. longjmp() only clears the stack, so any
3021 // class which allocates data on the heap is going to leak. 3063 // class which allocates data on the heap is going to leak.
3022 3064
3027 3069
3028 octave_value_list retval = feval (fname, args, nargout); 3070 octave_value_list retval = feval (fname, args, nargout);
3029 3071
3030 if (error_state && mex_context->trap_feval_error == 0) 3072 if (error_state && mex_context->trap_feval_error == 0)
3031 { 3073 {
3032 // FIXME -- is this the correct way to clean up? abort() is 3074 // FIXME: is this the correct way to clean up? abort() is
3033 // going to trigger a long jump, so the normal class destructors 3075 // going to trigger a long jump, so the normal class destructors
3034 // will not be called. Hopefully this will reduce things to a 3076 // will not be called. Hopefully this will reduce things to a
3035 // tiny leak. Maybe create a new octave memory tracer type 3077 // tiny leak. Maybe create a new octave memory tracer type
3036 // which prints a friendly message every time it is 3078 // which prints a friendly message every time it is
3037 // created/copied/deleted to check this. 3079 // created/copied/deleted to check this.
3046 if (nargout < retval.length ()) 3088 if (nargout < retval.length ())
3047 num_to_copy = nargout; 3089 num_to_copy = nargout;
3048 3090
3049 for (int i = 0; i < num_to_copy; i++) 3091 for (int i = 0; i < num_to_copy; i++)
3050 { 3092 {
3051 // FIXME -- it would be nice to avoid copying the value here, 3093 // FIXME: it would be nice to avoid copying the value here,
3052 // but there is no way to steal memory from a matrix, never mind 3094 // but there is no way to steal memory from a matrix, never mind
3053 // that matrix memory is allocated by new[] and mxArray memory 3095 // that matrix memory is allocated by new[] and mxArray memory
3054 // is allocated by malloc(). 3096 // is allocated by malloc().
3055 argout[i] = mex_context->make_value (retval (i)); 3097 argout[i] = mex_context->make_value (retval (i));
3056 } 3098 }
3141 } 3183 }
3142 3184
3143 void 3185 void
3144 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...) 3186 mexWarnMsgIdAndTxt (const char *id, const char *fmt, ...)
3145 { 3187 {
3146 // FIXME -- is this right? What does Matlab do if fmt is NULL or 3188 // FIXME: is this right? What does Matlab do if fmt is NULL or
3147 // an empty string? 3189 // an empty string?
3148 3190
3149 if (fmt && strlen (fmt) > 0) 3191 if (fmt && strlen (fmt) > 0)
3150 { 3192 {
3151 const char *fname = mexFunctionName (); 3193 const char *fname = mexFunctionName ();
3152 size_t len = strlen (fname) + 2 + strlen (fmt) + 1; 3194 size_t len = strlen (fname) + 2 + strlen (fmt) + 1;
3179 3221
3180 if (! strcmp (space, "global")) 3222 if (! strcmp (space, "global"))
3181 val = get_global_value (name); 3223 val = get_global_value (name);
3182 else 3224 else
3183 { 3225 {
3184 // FIXME -- should this be in variables.cc? 3226 // FIXME: should this be in variables.cc?
3185 3227
3186 unwind_protect frame; 3228 unwind_protect frame;
3187 3229
3188 bool caller = ! strcmp (space, "caller"); 3230 bool caller = ! strcmp (space, "caller");
3189 bool base = ! strcmp (space, "base"); 3231 bool base = ! strcmp (space, "base");
3242 3284
3243 if (! strcmp (space, "global")) 3285 if (! strcmp (space, "global"))
3244 set_global_value (name, mxArray::as_octave_value (ptr)); 3286 set_global_value (name, mxArray::as_octave_value (ptr));
3245 else 3287 else
3246 { 3288 {
3247 // FIXME -- should this be in variables.cc? 3289 // FIXME: should this be in variables.cc?
3248 3290
3249 unwind_protect frame; 3291 unwind_protect frame;
3250 3292
3251 bool caller = ! strcmp (space, "caller"); 3293 bool caller = ! strcmp (space, "caller");
3252 bool base = ! strcmp (space, "base"); 3294 bool base = ! strcmp (space, "base");