Mercurial > hg > octave-nkf
comparison libinterp/octave-value/ov-struct.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 | bd9d34f28b0f |
comparison
equal
deleted
inserted
replaced
17786:34d9812a943b | 17787:175b392e91fe |
---|---|
83 if (p != map.end ()) | 83 if (p != map.end ()) |
84 retval = map.contents (p); | 84 retval = map.contents (p); |
85 else if (auto_add) | 85 else if (auto_add) |
86 retval = (numel () == 0) ? Cell (dim_vector (1, 1)) : Cell (dims ()); | 86 retval = (numel () == 0) ? Cell (dim_vector (1, 1)) : Cell (dims ()); |
87 else | 87 else |
88 error_with_id ("Octave:invalid-indexing", | 88 error_with_id ("Octave:invalid-indexing", |
89 "structure has no member '%s'", nm.c_str ()); | 89 "structure has no member '%s'", nm.c_str ()); |
90 | 90 |
91 return retval; | 91 return retval; |
92 } | 92 } |
93 | 93 |
187 | 187 |
188 default: | 188 default: |
189 panic_impossible (); | 189 panic_impossible (); |
190 } | 190 } |
191 | 191 |
192 // FIXME -- perhaps there should be an | 192 // FIXME: perhaps there should be an |
193 // octave_value_list::next_subsref member function? See also | 193 // octave_value_list::next_subsref member function? See also |
194 // octave_user_function::subsref. | 194 // octave_user_function::subsref. |
195 | 195 |
196 if (idx.size () > 1) | 196 if (idx.size () > 1) |
197 retval = retval(0).next_subsref (nargout, type, idx, skip); | 197 retval = retval(0).next_subsref (nargout, type, idx, skip); |
253 | 253 |
254 default: | 254 default: |
255 panic_impossible (); | 255 panic_impossible (); |
256 } | 256 } |
257 | 257 |
258 // FIXME -- perhaps there should be an | 258 // FIXME: perhaps there should be an |
259 // octave_value_list::next_subsref member function? See also | 259 // octave_value_list::next_subsref member function? See also |
260 // octave_user_function::subsref. | 260 // octave_user_function::subsref. |
261 | 261 |
262 if (idx.size () > 1) | 262 if (idx.size () > 1) |
263 retval = retval.next_subsref (auto_add, type, idx, skip); | 263 retval = retval.next_subsref (auto_add, type, idx, skip); |
343 { | 343 { |
344 map.contents (pkey).make_unique (); | 344 map.contents (pkey).make_unique (); |
345 tmpc = map.contents (pkey).index (idx.front (), true); | 345 tmpc = map.contents (pkey).index (idx.front (), true); |
346 } | 346 } |
347 | 347 |
348 // FIXME: better code reuse? cf. octave_cell::subsasgn and the case below. | 348 // FIXME: better code reuse? |
349 // cf. octave_cell::subsasgn and the case below. | |
349 if (! error_state) | 350 if (! error_state) |
350 { | 351 { |
351 if (tmpc.numel () == 1) | 352 if (tmpc.numel () == 1) |
352 { | 353 { |
353 octave_value& tmp = tmpc(0); | 354 octave_value& tmp = tmpc(0); |
358 { | 359 { |
359 tmp = octave_value::empty_conv (next_type, rhs); | 360 tmp = octave_value::empty_conv (next_type, rhs); |
360 tmp.make_unique (); // probably a no-op. | 361 tmp.make_unique (); // probably a no-op. |
361 } | 362 } |
362 else | 363 else |
363 // optimization: ignore the copy still stored inside our map. | 364 // optimization: ignore the copy |
365 // still stored inside our map. | |
364 tmp.make_unique (1); | 366 tmp.make_unique (1); |
365 | 367 |
366 if (! error_state) | 368 if (! error_state) |
367 t_rhs = (orig_undefined | 369 t_rhs = |
368 ? tmp.undef_subsasgn (next_type, next_idx, rhs) | 370 (orig_undefined |
369 : tmp.subsasgn (next_type, next_idx, rhs)); | 371 ? tmp.undef_subsasgn (next_type, next_idx, rhs) |
372 : tmp.subsasgn (next_type, next_idx, rhs)); | |
370 } | 373 } |
371 else | 374 else |
372 gripe_indexed_cs_list (); | 375 gripe_indexed_cs_list (); |
373 } | 376 } |
374 } | 377 } |
417 { | 420 { |
418 tmp = octave_value::empty_conv (next_type, rhs); | 421 tmp = octave_value::empty_conv (next_type, rhs); |
419 tmp.make_unique (); // probably a no-op. | 422 tmp.make_unique (); // probably a no-op. |
420 } | 423 } |
421 else | 424 else |
422 // optimization: ignore the copy still stored inside our map. | 425 // optimization: ignore the copy |
426 // still stored inside our map. | |
423 tmp.make_unique (1); | 427 tmp.make_unique (1); |
424 | 428 |
425 if (! error_state) | 429 if (! error_state) |
426 t_rhs = (orig_undefined | 430 t_rhs = (orig_undefined |
427 ? tmp.undef_subsasgn (next_type, next_idx, rhs) | 431 ? tmp.undef_subsasgn (next_type, next_idx, rhs) |
471 | 475 |
472 // Inquire the proper shape of the RHS. | 476 // Inquire the proper shape of the RHS. |
473 | 477 |
474 dim_vector didx = dims ().redim (idxf.length ()); | 478 dim_vector didx = dims ().redim (idxf.length ()); |
475 for (octave_idx_type k = 0; k < idxf.length (); k++) | 479 for (octave_idx_type k = 0; k < idxf.length (); k++) |
476 if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel (); | 480 if (! idxf(k).is_magic_colon ()) |
481 didx(k) = idxf(k).numel (); | |
477 | 482 |
478 if (didx.numel () == tmp_cell.numel ()) | 483 if (didx.numel () == tmp_cell.numel ()) |
479 tmp_cell = tmp_cell.reshape (didx); | 484 tmp_cell = tmp_cell.reshape (didx); |
480 | 485 |
481 | 486 |
489 else | 494 else |
490 gripe_failed_assignment (); | 495 gripe_failed_assignment (); |
491 } | 496 } |
492 else | 497 else |
493 { | 498 { |
494 const octave_map& cmap = const_cast<const octave_map &> (map); | 499 const octave_map& cmap = |
495 // cast map to const reference to avoid forced key insertion. | 500 const_cast<const octave_map &> (map); |
501 // cast to const reference, avoid forced key insertion. | |
496 if (idxf.all_scalars () | 502 if (idxf.all_scalars () |
497 || cmap.contents (key).index (idxf, true).numel () == 1) | 503 || cmap.contents (key).index (idxf, true).numel () |
504 == 1) | |
498 { | 505 { |
499 map.assign (idxf, key, Cell (t_rhs.storable_value ())); | 506 map.assign (idxf, |
507 key, Cell (t_rhs.storable_value ())); | |
500 if (! error_state) | 508 if (! error_state) |
501 { | 509 { |
502 count++; | 510 count++; |
503 retval = octave_value (this); | 511 retval = octave_value (this); |
504 } | 512 } |
839 else if (len == 0 ) | 847 else if (len == 0 ) |
840 map = octave_map (dv); | 848 map = octave_map (dv); |
841 else | 849 else |
842 panic_impossible (); | 850 panic_impossible (); |
843 } | 851 } |
844 else { | 852 else |
845 error ("load: failed to extract number of elements in structure"); | 853 { |
846 success = false; | 854 error ("load: failed to extract number of elements in structure"); |
847 } | 855 success = false; |
856 } | |
848 | 857 |
849 return success; | 858 return success; |
850 } | 859 } |
851 | 860 |
852 bool | 861 bool |
1029 hid_t group_id = H5Gopen (loc_id, name); | 1038 hid_t group_id = H5Gopen (loc_id, name); |
1030 #endif | 1039 #endif |
1031 H5Gget_num_objs (group_id, &num_obj); | 1040 H5Gget_num_objs (group_id, &num_obj); |
1032 H5Gclose (group_id); | 1041 H5Gclose (group_id); |
1033 | 1042 |
1034 // FIXME -- fields appear to be sorted alphabetically on loading. | 1043 // FIXME: fields appear to be sorted alphabetically on loading. |
1035 // Why is that happening? | 1044 // Why is that happening? |
1036 | 1045 |
1037 while (current_item < static_cast<int> (num_obj) | 1046 while (current_item < static_cast<int> (num_obj) |
1038 && (retval2 = H5Giterate (loc_id, name, ¤t_item, | 1047 && (retval2 = H5Giterate (loc_id, name, ¤t_item, |
1039 hdf5_read_next_data, &dsub)) > 0) | 1048 hdf5_read_next_data, &dsub)) > 0) |
1123 | 1132 |
1124 return retval; | 1133 return retval; |
1125 } | 1134 } |
1126 DEFINE_OCTAVE_ALLOCATOR(octave_scalar_struct); | 1135 DEFINE_OCTAVE_ALLOCATOR(octave_scalar_struct); |
1127 | 1136 |
1128 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_scalar_struct, "scalar struct", "struct"); | 1137 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_scalar_struct, "scalar struct", |
1138 "struct"); | |
1129 | 1139 |
1130 octave_value | 1140 octave_value |
1131 octave_scalar_struct::dotref (const octave_value_list& idx, bool auto_add) | 1141 octave_scalar_struct::dotref (const octave_value_list& idx, bool auto_add) |
1132 { | 1142 { |
1133 octave_value retval; | 1143 octave_value retval; |
1410 newline (os); | 1420 newline (os); |
1411 } | 1421 } |
1412 } | 1422 } |
1413 | 1423 |
1414 bool | 1424 bool |
1415 octave_scalar_struct::print_name_tag (std::ostream& os, const std::string& name) const | 1425 octave_scalar_struct::print_name_tag (std::ostream& os, |
1426 const std::string& name) const | |
1416 { | 1427 { |
1417 bool retval = false; | 1428 bool retval = false; |
1418 | 1429 |
1419 indent (os); | 1430 indent (os); |
1420 | 1431 |
1510 else if (len == 0) | 1521 else if (len == 0) |
1511 map = octave_scalar_map (); | 1522 map = octave_scalar_map (); |
1512 else | 1523 else |
1513 panic_impossible (); | 1524 panic_impossible (); |
1514 } | 1525 } |
1515 else { | 1526 else |
1516 error ("load: failed to extract number of elements in structure"); | 1527 { |
1517 success = false; | 1528 error ("load: failed to extract number of elements in structure"); |
1518 } | 1529 success = false; |
1530 } | |
1519 | 1531 |
1520 return success; | 1532 return success; |
1521 } | 1533 } |
1522 | 1534 |
1523 bool | 1535 bool |
1605 } | 1617 } |
1606 | 1618 |
1607 #if defined (HAVE_HDF5) | 1619 #if defined (HAVE_HDF5) |
1608 | 1620 |
1609 bool | 1621 bool |
1610 octave_scalar_struct::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) | 1622 octave_scalar_struct::save_hdf5 (hid_t loc_id, const char *name, |
1623 bool save_as_floats) | |
1611 { | 1624 { |
1612 hid_t data_hid = -1; | 1625 hid_t data_hid = -1; |
1613 | 1626 |
1614 #if HAVE_HDF5_18 | 1627 #if HAVE_HDF5_18 |
1615 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); | 1628 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); |
1662 hid_t group_id = H5Gopen (loc_id, name); | 1675 hid_t group_id = H5Gopen (loc_id, name); |
1663 #endif | 1676 #endif |
1664 H5Gget_num_objs (group_id, &num_obj); | 1677 H5Gget_num_objs (group_id, &num_obj); |
1665 H5Gclose (group_id); | 1678 H5Gclose (group_id); |
1666 | 1679 |
1667 // FIXME -- fields appear to be sorted alphabetically on loading. | 1680 // FIXME: fields appear to be sorted alphabetically on loading. |
1668 // Why is that happening? | 1681 // Why is that happening? |
1669 | 1682 |
1670 while (current_item < static_cast<int> (num_obj) | 1683 while (current_item < static_cast<int> (num_obj) |
1671 && (retval2 = H5Giterate (loc_id, name, ¤t_item, | 1684 && (retval2 = H5Giterate (loc_id, name, ¤t_item, |
1672 hdf5_read_next_data, &dsub)) > 0) | 1685 hdf5_read_next_data, &dsub)) > 0) |
1733 { | 1746 { |
1734 return new octave_struct (octave_map (map)); | 1747 return new octave_struct (octave_map (map)); |
1735 } | 1748 } |
1736 | 1749 |
1737 bool | 1750 bool |
1738 octave_scalar_struct::fast_elem_insert_self (void *where, builtin_type_t btyp) const | 1751 octave_scalar_struct::fast_elem_insert_self (void *where, |
1752 builtin_type_t btyp) const | |
1739 { | 1753 { |
1740 | 1754 |
1741 if (btyp == btyp_struct) | 1755 if (btyp == btyp_struct) |
1742 { | 1756 { |
1743 *(reinterpret_cast<const octave_scalar_map **>(where)) = ↦ | 1757 *(reinterpret_cast<const octave_scalar_map **>(where)) = ↦ |
1746 else | 1760 else |
1747 return false; | 1761 return false; |
1748 } | 1762 } |
1749 | 1763 |
1750 DEFUN (struct, args, , | 1764 DEFUN (struct, args, , |
1751 "-*- texinfo -*-\n\ | 1765 "-*- texinfo -*-\n\ |
1752 @deftypefn {Built-in Function} {} struct (@var{field1}, @var{value1}, @var{field2}, @var{value2}, @dots{})\n\ | 1766 @deftypefn {Built-in Function} {} struct (@var{field1}, @var{value1}, @var{field2}, @var{value2}, @dots{})\n\ |
1753 \n\ | 1767 \n\ |
1754 Create a scalar or array structure and initialize its values. The\n\ | 1768 Create a scalar or array structure and initialize its values. The\n\ |
1755 @var{field1}, @var{field2}, @dots{} variables are strings giving the\n\ | 1769 @var{field1}, @var{field2}, @dots{} variables are strings giving the\n\ |
1756 names of the fields and the @var{value1}, @var{value2}, @dots{}\n\ | 1770 names of the fields and the @var{value1}, @var{value2}, @dots{}\n\ |
1945 %!fail ('struct (1,2,3,4)', 'struct: expecting alternating "field", VALUE pairs') | 1959 %!fail ('struct (1,2,3,4)', 'struct: expecting alternating "field", VALUE pairs') |
1946 %!fail ('struct ("1",2,"3")', 'struct: expecting alternating "field", VALUE pairs') | 1960 %!fail ('struct ("1",2,"3")', 'struct: expecting alternating "field", VALUE pairs') |
1947 */ | 1961 */ |
1948 | 1962 |
1949 DEFUN (isstruct, args, , | 1963 DEFUN (isstruct, args, , |
1950 "-*- texinfo -*-\n\ | 1964 "-*- texinfo -*-\n\ |
1951 @deftypefn {Built-in Function} {} isstruct (@var{x})\n\ | 1965 @deftypefn {Built-in Function} {} isstruct (@var{x})\n\ |
1952 Return true if @var{x} is a structure or a structure array.\n\ | 1966 Return true if @var{x} is a structure or a structure array.\n\ |
1953 @seealso{ismatrix, iscell, isa}\n\ | 1967 @seealso{ismatrix, iscell, isa}\n\ |
1954 @end deftypefn") | 1968 @end deftypefn") |
1955 { | 1969 { |
1962 | 1976 |
1963 return retval; | 1977 return retval; |
1964 } | 1978 } |
1965 | 1979 |
1966 DEFUN (__fieldnames__, args, , | 1980 DEFUN (__fieldnames__, args, , |
1967 "-*- texinfo -*-\n\ | 1981 "-*- texinfo -*-\n\ |
1968 @deftypefn {Built-in Function} {} __fieldnames__ (@var{struct})\n\ | 1982 @deftypefn {Built-in Function} {} __fieldnames__ (@var{struct})\n\ |
1969 @deftypefnx {Built-in Function} {} __fieldnames__ (@var{obj})\n\ | 1983 @deftypefnx {Built-in Function} {} __fieldnames__ (@var{obj})\n\ |
1970 Internal function.\n\ | 1984 Internal function.\n\ |
1971 \n\ | 1985 \n\ |
1972 Implements @code{fieldnames()} for structures and Octave objects.\n\ | 1986 Implements @code{fieldnames()} for structures and Octave objects.\n\ |
1989 | 2003 |
1990 return retval; | 2004 return retval; |
1991 } | 2005 } |
1992 | 2006 |
1993 DEFUN (isfield, args, , | 2007 DEFUN (isfield, args, , |
1994 "-*- texinfo -*-\n\ | 2008 "-*- texinfo -*-\n\ |
1995 @deftypefn {Built-in Function} {} isfield (@var{x}, @var{name})\n\ | 2009 @deftypefn {Built-in Function} {} isfield (@var{x}, @var{name})\n\ |
1996 Return true if the @var{x} is a structure and it\n\ | 2010 Return true if the @var{x} is a structure and it\n\ |
1997 includes an element named @var{name}. If @var{name} is a cell\n\ | 2011 includes an element named @var{name}. If @var{name} is a cell\n\ |
1998 array of strings then a logical array of equal dimension is returned.\n\ | 2012 array of strings then a logical array of equal dimension is returned.\n\ |
1999 @end deftypefn") | 2013 @end deftypefn") |
2008 | 2022 |
2009 if (args(0).is_map ()) | 2023 if (args(0).is_map ()) |
2010 { | 2024 { |
2011 octave_map m = args(0).map_value (); | 2025 octave_map m = args(0).map_value (); |
2012 | 2026 |
2013 // FIXME -- should this work for all types that can do | 2027 // FIXME: should this work for all types that can do |
2014 // structure reference operations? | 2028 // structure reference operations? |
2015 | 2029 |
2016 if (args(1).is_string ()) | 2030 if (args(1).is_string ()) |
2017 { | 2031 { |
2018 std::string key = args(1).string_value (); | 2032 std::string key = args(1).string_value (); |
2046 | 2060 |
2047 return retval; | 2061 return retval; |
2048 } | 2062 } |
2049 | 2063 |
2050 DEFUN (nfields, args, , | 2064 DEFUN (nfields, args, , |
2051 "-*- texinfo -*-\n\ | 2065 "-*- texinfo -*-\n\ |
2052 @deftypefn {Built-in Function} {} nfields (@var{s})\n\ | 2066 @deftypefn {Built-in Function} {} nfields (@var{s})\n\ |
2053 Return the number of fields of the structure @var{s}.\n\ | 2067 Return the number of fields of the structure @var{s}.\n\ |
2054 @end deftypefn") | 2068 @end deftypefn") |
2055 { | 2069 { |
2056 octave_value retval; | 2070 octave_value retval; |
2276 %! assert (fieldnames (y), {"d"; "b"; "c"}); | 2290 %! assert (fieldnames (y), {"d"; "b"; "c"}); |
2277 %! assert (size (y), [1, 6]); | 2291 %! assert (size (y), [1, 6]); |
2278 */ | 2292 */ |
2279 | 2293 |
2280 DEFUN (struct_levels_to_print, args, nargout, | 2294 DEFUN (struct_levels_to_print, args, nargout, |
2281 "-*- texinfo -*-\n\ | 2295 "-*- texinfo -*-\n\ |
2282 @deftypefn {Built-in Function} {@var{val} =} struct_levels_to_print ()\n\ | 2296 @deftypefn {Built-in Function} {@var{val} =} struct_levels_to_print ()\n\ |
2283 @deftypefnx {Built-in Function} {@var{old_val} =} struct_levels_to_print (@var{new_val})\n\ | 2297 @deftypefnx {Built-in Function} {@var{old_val} =} struct_levels_to_print (@var{new_val})\n\ |
2284 @deftypefnx {Built-in Function} {} struct_levels_to_print (@var{new_val}, \"local\")\n\ | 2298 @deftypefnx {Built-in Function} {} struct_levels_to_print (@var{new_val}, \"local\")\n\ |
2285 Query or set the internal variable that specifies the number of\n\ | 2299 Query or set the internal variable that specifies the number of\n\ |
2286 structure levels to display.\n\ | 2300 structure levels to display.\n\ |
2293 return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print, -1, | 2307 return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print, -1, |
2294 std::numeric_limits<int>::max ()); | 2308 std::numeric_limits<int>::max ()); |
2295 } | 2309 } |
2296 | 2310 |
2297 DEFUN (print_struct_array_contents, args, nargout, | 2311 DEFUN (print_struct_array_contents, args, nargout, |
2298 "-*- texinfo -*-\n\ | 2312 "-*- texinfo -*-\n\ |
2299 @deftypefn {Built-in Function} {@var{val} =} print_struct_array_contents ()\n\ | 2313 @deftypefn {Built-in Function} {@var{val} =} print_struct_array_contents ()\n\ |
2300 @deftypefnx {Built-in Function} {@var{old_val} =} print_struct_array_contents (@var{new_val})\n\ | 2314 @deftypefnx {Built-in Function} {@var{old_val} =} print_struct_array_contents (@var{new_val})\n\ |
2301 @deftypefnx {Built-in Function} {} print_struct_array_contents (@var{new_val}, \"local\")\n\ | 2315 @deftypefnx {Built-in Function} {} print_struct_array_contents (@var{new_val}, \"local\")\n\ |
2302 Query or set the internal variable that specifies whether to print struct\n\ | 2316 Query or set the internal variable that specifies whether to print struct\n\ |
2303 array contents. If true, values of struct array elements are printed.\n\ | 2317 array contents. If true, values of struct array elements are printed.\n\ |