Mercurial > octave
annotate libinterp/octave-value/cdef-object.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 670a0d878af1 |
children | aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3 // Copyright (C) 2012-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
26771
diff
changeset
|
30 #include "cdef-class.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "cdef-object.h" |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
26771
diff
changeset
|
32 #include "cdef-property.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "cdef-utils.h" |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "interpreter.h" |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27056
diff
changeset
|
35 #include "interpreter-private.h" |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "ov-classdef.h" |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 // Define to 1 to enable debugging statements. |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #define DEBUG_TRACE 0 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
41 OCTAVE_BEGIN_NAMESPACE(octave) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
42 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
43 void |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
44 cdef_object_rep::release (const cdef_object& obj) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
45 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
46 // We need to be careful to keep a reference to the object if we are |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
47 // calling the delete method. The object is passed to the delete |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
48 // method as an argument and if the count is already zero when we |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
49 // do that, then we will increment the count while creating the |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
50 // argument list for the delete method and then it will be decremented |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
51 // back to zero and we'll find ourselves in an infinite loop. |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
53 if (m_count - 1 > static_count ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
54 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
55 --m_count; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
56 return; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
57 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
59 if (is_handle_object () && ! is_meta_object ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
60 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
61 unwind_protect frame; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
63 // Clear interrupts. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
64 frame.protect_var (octave_interrupt_state); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
65 octave_interrupt_state = 0; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
67 // Disallow quit(). |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
68 frame.protect_var (quit_allowed); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
69 quit_allowed = false; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30565
diff
changeset
|
71 interpreter& interp = __get_interpreter__ (); |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
72 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
73 interpreter_try (frame); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
75 try |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
76 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
77 // Call classdef "delete()" method on object |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
78 get_class ().delete_object (obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
79 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
80 catch (const interrupt_exception&) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
81 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
82 interp.recover_from_exception (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
84 warning ("interrupt occurred in handle class delete method"); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 } |
27471 | 86 catch (const execution_exception& ee) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 { |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
88 interp.recover_from_exception (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27056
diff
changeset
|
89 |
27471 | 90 std::string msg = ee.message (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27056
diff
changeset
|
91 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
92 warning ("error caught while executing handle class delete method:\n%s\n", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
93 msg.c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
94 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
95 catch (const exit_exception&) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
97 // This shouldn't happen since we disabled quit above. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
98 warning ("exit disabled while executing handle class delete method"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
99 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
100 catch (...) // Yes, the black hole. We're in a d-tor. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
101 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
102 // This shouldn't happen, in theory. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
103 warning ("internal error: unhandled exception in handle class delete method"); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 } |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
106 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
107 // Now it is safe to set the count to zero. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
108 m_count--; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
109 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
110 destroy (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
111 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
112 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
113 cdef_class |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
114 cdef_object_rep::get_class (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
115 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
116 err_invalid_object ("get_class"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
117 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
118 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
119 std::string |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
120 cdef_object_rep::class_name (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
121 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
122 return get_class ().get_name (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
123 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
124 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
125 string_vector |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
126 cdef_object_rep::map_keys (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
127 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
128 cdef_class cls = get_class (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
129 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
130 if (cls.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
131 return cls.get_names (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
132 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
133 return string_vector (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
134 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
135 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
136 octave_map |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
137 cdef_object::map_value (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
138 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
139 octave_map retval; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
141 warning_with_id ("Octave:classdef-to-struct", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
142 "struct: converting a classdef object into a struct " |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
143 "overrides the access restrictions defined for properties. " |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
144 "All properties are returned, including private and " |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
145 "protected ones."); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
146 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
147 cdef_class cls = get_class (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
148 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
149 if (cls.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
150 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
151 std::map<std::string, cdef_property> props; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
152 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
153 props = cls.get_property_map (cdef_class::property_all); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
155 // FIXME: Why not const here? |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
156 for (auto& prop_val : props) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
157 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
158 if (is_array ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
159 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
160 Array<cdef_object> a_obj = array_value (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
161 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
162 Cell cvalue (a_obj.dims ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
163 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
164 for (octave_idx_type i = 0; i < a_obj.numel (); i++) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
165 cvalue (i) = prop_val.second.get_value (a_obj(i), false); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
166 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
167 retval.setfield (prop_val.first, cvalue); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
168 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
169 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
170 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
171 Cell cvalue (dim_vector (1, 1), |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
172 prop_val.second.get_value (*this, false)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
173 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
174 retval.setfield (prop_val.first, cvalue); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
175 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
176 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
177 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
178 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
179 return retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
180 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
182 cdef_class |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
183 cdef_object::get_class (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
184 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
185 return m_rep->get_class (); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
186 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
187 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
188 cdef_class |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
189 cdef_object_base::get_class (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
190 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
191 return cdef_class (m_klass); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
192 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
193 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
194 void |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
195 cdef_object_base::set_class (const cdef_class& cls) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
196 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
197 if ((m_klass.ok () && cls.ok () && cls != get_class ()) |
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
198 || (m_klass.ok () && ! cls.ok ()) |
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
199 || (! m_klass.ok () && cls.ok ())) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
200 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
201 m_klass = cls; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
202 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
203 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
204 |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30075
diff
changeset
|
205 cdef_object_rep * |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
206 cdef_object_base::make_array (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
207 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
208 cdef_object_rep *r = new cdef_object_array (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
209 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
210 r->set_class (get_class ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
211 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
212 return r; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
213 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
214 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
215 octave_value_list |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
216 cdef_object_array::subsref (const std::string& type, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
217 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
218 int /* nargout */, std::size_t& skip, |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
219 const cdef_class& /* context */, bool auto_add) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
220 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
221 octave_value_list retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
222 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
223 skip = 1; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
224 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
225 switch (type[0]) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
226 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
227 case '(': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
228 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
229 const octave_value_list& ival = idx.front (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
230 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
231 if (ival.empty ()) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
233 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
234 retval(0) = to_ov (cdef_object (this)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
235 break; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 bool is_scalar = true; |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 Array<idx_vector> iv (dim_vector (1, ival.length ())); |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 for (int i = 0; i < ival.length (); i++) |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 { |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 try |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 { |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 iv(i) = ival(i).index_vector (); |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
247 catch (index_exception& ie) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 { |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 // Rethrow to allow more info to be reported later. |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
250 ie.set_pos_if_unset (ival.length (), i+1); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 throw; |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 is_scalar = is_scalar && iv(i).is_scalar (); |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
257 Array<cdef_object> ires = m_array.index (iv, auto_add); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
259 // If resizing is enabled (auto_add = true), it's possible |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
260 // indexing was out-of-bound and the result array contains |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
261 // invalid cdef_objects. |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
263 if (auto_add) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
264 fill_empty_values (ires); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
266 if (is_scalar) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
267 retval(0) = to_ov (ires(0)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
268 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
269 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
270 cdef_object array_obj (new cdef_object_array (ires)); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
272 array_obj.set_class (get_class ()); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
274 retval(0) = to_ov (array_obj); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 } |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
277 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
278 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
279 case '.': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
280 if (type.size () == 1 && idx.size () == 1) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
281 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
282 Cell c (dims ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
283 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
284 octave_idx_type n = m_array.numel (); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
285 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
286 // dummy variables |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
287 std::size_t dummy_skip; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
288 cdef_class dummy_cls; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
289 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
290 for (octave_idx_type i = 0; i < n; i++) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
291 { |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30075
diff
changeset
|
292 octave_value_list r = m_array(i).subsref (type, idx, 1, |
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30075
diff
changeset
|
293 dummy_skip, |
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30075
diff
changeset
|
294 dummy_cls); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
296 if (r.length () > 0) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
297 c(i) = r(0); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
298 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
299 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
300 retval(0) = octave_value (c, true); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
302 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
303 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
304 OCTAVE_FALLTHROUGH; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
306 default: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
307 error ("can't perform indexing operation on array of %s objects", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
308 class_name ().c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
309 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
310 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 return retval; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
313 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
315 octave_value |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
316 cdef_object_array::subsasgn (const std::string& type, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
317 const std::list<octave_value_list>& idx, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
318 const octave_value& rhs) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
319 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
320 octave_value retval; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
322 switch (type[0]) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
323 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
324 case '(': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
325 if (type.length () == 1) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
327 cdef_object rhs_obj = to_cdef (rhs); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
329 if (rhs_obj.get_class () != get_class ()) |
28905
89a425f2c202
maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents:
27932
diff
changeset
|
330 error ("can't assign %s object into array of %s objects", |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
331 rhs_obj.class_name ().c_str (), |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
332 class_name ().c_str ()); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
334 const octave_value_list& ival = idx.front (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
335 bool is_scalar = true; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
336 Array<idx_vector> iv (dim_vector (1, ival.length ())); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
338 for (int i = 0; i < ival.length (); i++) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
340 try |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
341 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
342 iv(i) = ival(i).index_vector (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
343 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
344 catch (index_exception& ie) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
345 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
346 ie.set_pos_if_unset (ival.length (), i+1); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
347 throw; // var name set in pt-idx.cc / pt-assign.cc |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
348 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
350 is_scalar = is_scalar && iv(i).is_scalar (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
353 Array<cdef_object> rhs_mat; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
354 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
355 if (! rhs_obj.is_array ()) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
357 rhs_mat = Array<cdef_object> (dim_vector (1, 1)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
358 rhs_mat(0) = rhs_obj; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 } |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
360 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
361 rhs_mat = rhs_obj.array_value (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
362 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
363 octave_idx_type n = m_array.numel (); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
364 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
365 m_array.assign (iv, rhs_mat, cdef_object ()); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
367 if (m_array.numel () > n) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
368 fill_empty_values (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
369 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
370 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
371 retval = to_ov (cdef_object (this)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
372 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
373 else |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
375 const octave_value_list& ivl = idx.front (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
377 // Fill in trailing singleton dimensions so that |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
378 // array.index doesn't create a new blank entry (bug #46660). |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
379 const octave_idx_type one = static_cast<octave_idx_type> (1); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
380 const octave_value_list& ival = ivl.length () >= 2 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
381 ? ivl : ((m_array.dims ()(0) == 1) |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
382 ? ovl (one, ivl(0)) |
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
383 : ovl (ivl(0), one)); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
384 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
385 bool is_scalar = true; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
386 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
387 Array<idx_vector> iv (dim_vector (1, ival.length ())); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
389 for (int i = 0; i < ival.length (); i++) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
391 try |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
392 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
393 iv(i) = ival(i).index_vector (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
394 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
395 catch (index_exception& ie) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
396 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
397 // Rethrow to allow more info to be reported later. |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28905
diff
changeset
|
398 ie.set_pos_if_unset (ival.length (), i+1); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
399 throw; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
400 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
401 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
402 is_scalar = is_scalar && iv(i).is_scalar (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
403 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
404 if (! is_scalar) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
405 error ("subsasgn: invalid indexing for object array assignment" |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
406 ", the index must reference a single object in the " |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
407 "array."); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
410 Array<cdef_object> a = m_array.index (iv, true); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
411 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
412 if (a.numel () != 1) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
413 error ("subsasgn: invalid indexing for object array assignment"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
414 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
415 cdef_object obj = a(0); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
416 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
417 int ignore_copies = 0; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
418 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
419 // If the object in 'a' is not valid, this means the index |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
420 // was out-of-bound and we need to create a new object. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
421 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
422 if (! obj.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
423 obj = get_class ().construct_object (octave_value_list ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
424 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
425 // Optimize the subsasgn call to come. There are 2 copies |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
426 // that we can safely ignore: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
427 // - 1 in "array" |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
428 // - 1 in "a" |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
429 ignore_copies = 2; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
430 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
431 std::list<octave_value_list> next_idx (idx); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
432 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
433 next_idx.erase (next_idx.begin ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
434 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
435 octave_value tmp = obj.subsasgn (type.substr (1), next_idx, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
436 rhs, ignore_copies); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
437 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
438 cdef_object robj = to_cdef (tmp); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
439 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
440 if (! robj.ok () |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
441 || robj.is_array () |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
442 || robj.get_class () != get_class ()) |
26968
342fc514de46
Fix typo in subsasgn error message (bug #55994).
A.R. Burgers <arburgers@gmail.com>
parents:
26774
diff
changeset
|
443 error ("subsasgn: invalid assignment into array of %s objects", |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
444 class_name ().c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
445 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
446 // Small optimization, when dealing with handle |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
447 // objects, we don't need to re-assign the result |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
448 // of subsasgn back into the array. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
449 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
450 if (! robj.is (a(0))) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
451 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
452 Array<cdef_object> rhs_a (dim_vector (1, 1), |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
453 robj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
454 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
455 octave_idx_type n = m_array.numel (); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
456 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
457 m_array.assign (iv, rhs_a); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
458 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
459 if (m_array.numel () > n) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
460 fill_empty_values (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
461 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
462 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
463 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
464 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
465 retval = to_ov (cdef_object (this)); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 break; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
468 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
469 default: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
470 error ("can't perform indexing operation on array of %s objects", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
471 class_name ().c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
472 break; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
475 return retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
476 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
478 void |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
479 cdef_object_array::fill_empty_values (Array<cdef_object>& arr) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
480 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
481 cdef_class cls = get_class (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
483 cdef_object obj; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
485 int n = arr.numel (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
487 for (int i = 0; i < n; i++) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
489 if (! arr.xelem (i).ok ()) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
491 if (! obj.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
492 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
493 obj = cls.construct_object (octave_value_list ()); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
495 arr.xelem (i) = obj; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
496 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
497 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
498 arr.xelem (i) = obj.copy (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 } |
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 } |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
501 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
503 void |
29950
6549fa7558ba
eliminate some unnecessary octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
504 cdef_object_scalar::break_closure_cycles (const std::shared_ptr<stack_frame>& frame) |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
505 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
506 for (octave_idx_type i = 0; i < m_map.nfields (); i++) |
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
507 m_map.contents(i).break_closure_cycles (frame); |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
508 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
509 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
510 octave_value_list |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
511 cdef_object_scalar::subsref (const std::string& type, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
512 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
513 int nargout, std::size_t& skip, |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
514 const cdef_class& context, bool auto_add) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
515 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
516 skip = 0; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
517 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
518 cdef_class cls = (context.ok () ? context : get_class ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
519 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
520 octave_value_list retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
521 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
522 if (! cls.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
523 return retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
524 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
525 switch (type[0]) |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
527 case '.': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
528 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
529 std::string name = (idx.front ())(0).string_value (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
531 cdef_method meth = cls.find_method (name); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
533 if (meth.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
534 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
535 int _nargout = (type.length () > 2 ? 1 : nargout); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
537 octave_value_list args; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
538 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
539 skip = 1; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
541 if (type.length () > 1 && type[1] == '(') |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
542 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
543 auto it = idx.begin (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
544 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
545 args = *++it; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
546 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
547 skip++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
548 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
550 if (meth.is_static ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
551 retval = meth.execute (args, _nargout, true, "subsref"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
552 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
553 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
554 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
555 retval = meth.execute (cdef_object (this), args, _nargout, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
556 true, "subsref"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
557 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
558 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
560 if (skip == 0) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
561 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
562 cdef_property prop = cls.find_property (name); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
563 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
564 if (! prop.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
565 error ("subsref: unknown method or property: %s", name.c_str ()); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
567 if (prop.is_constant ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
568 retval(0) = prop.get_value (true, "subsref"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
569 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
570 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
571 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
572 retval(0) = prop.get_value (cdef_object (this), |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
573 true, "subsref"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
574 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
575 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
576 skip = 1; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
577 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
578 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
579 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
580 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
581 case '(': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
582 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
583 const octave_value_list& ival = idx.front (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
584 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
585 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
586 cdef_object this_obj (this); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
587 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
588 if (ival.empty ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
589 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
590 skip++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
591 retval(0) = to_ov (this_obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
592 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
593 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
594 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
595 Array<cdef_object> arr (dim_vector (1, 1), this_obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
596 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
597 cdef_object new_obj = cdef_object (new cdef_object_array (arr)); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
599 new_obj.set_class (get_class ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
600 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
601 retval = new_obj.subsref (type, idx, nargout, skip, cls, auto_add); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
602 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
603 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
604 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
605 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
606 default: |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
607 error ("object cannot be indexed with '%c'", type[0]); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
608 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
609 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
610 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
611 return retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
612 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
614 octave_value |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
615 cdef_object_scalar::subsasgn (const std::string& type, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
616 const std::list<octave_value_list>& idx, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
617 const octave_value& rhs) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
618 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
619 octave_value retval; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
621 cdef_class cls = get_class (); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
623 switch (type[0]) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
624 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
625 case '.': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
626 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
627 std::string name = (idx.front ())(0).string_value (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
628 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
629 cdef_property prop = cls.find_property (name); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
631 if (! prop.ok ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
632 error ("subsasgn: unknown property: %s", name.c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
633 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
634 if (prop.is_constant ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
635 error ("subsasgn: cannot assign constant property: %s", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
636 name.c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
637 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
638 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
639 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
640 cdef_object obj (this); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
641 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
642 if (type.length () == 1) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
643 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
644 prop.set_value (obj, rhs, true, "subsasgn"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
645 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
646 retval = to_ov (obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
647 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
648 else |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
649 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
650 octave_value val = prop.get_value (obj, true, "subsasgn"); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
651 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
652 std::list<octave_value_list> args (idx); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
653 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
654 args.erase (args.begin ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
655 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
656 val = val.assign (octave_value::op_asn_eq, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
657 type.substr (1), args, rhs); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
659 if (val.class_name () != "object" |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
660 || ! to_cdef (val).is_handle_object ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
661 prop.set_value (obj, val, true, "subsasgn"); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
662 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
663 retval = to_ov (obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
664 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
665 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
666 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
667 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
668 case '(': |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
669 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
670 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
671 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
672 cdef_object this_obj (this); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
674 Array<cdef_object> arr (dim_vector (1, 1), this_obj); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
675 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
676 cdef_object new_obj = cdef_object (new cdef_object_array (arr)); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
677 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
678 new_obj.set_class (get_class ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
679 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
680 octave_value tmp = new_obj.subsasgn (type, idx, rhs); |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
682 retval = tmp; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
683 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
684 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
685 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
686 default: |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
687 error ("subsasgn: object cannot be index with '%c'", type[0]); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
688 break; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
689 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
691 return retval; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
692 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
693 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
694 void |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
695 cdef_object_scalar::mark_for_construction (const cdef_class& cls) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
696 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
697 std::string cls_name = cls.get_name (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
698 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
699 Cell supcls = cls.get ("SuperClasses").cell_value (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
700 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
701 std::list<cdef_class> supcls_list = lookup_classes (supcls); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
702 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
703 m_ctor_list[cls] = supcls_list; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
704 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
705 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
706 bool |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
707 cdef_object_scalar::is_constructed_for (const cdef_class& cls) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
708 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
709 return (is_constructed () |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
710 || m_ctor_list.find (cls) == m_ctor_list.end ()); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
711 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
713 bool |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
714 cdef_object_scalar::is_partially_constructed_for (const cdef_class& cls) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
715 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
716 if (is_constructed ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
717 return true; |
27056
64461ccf3039
allow inherited method calls during classdef construction (bug #52614)
John W. Eaton <jwe@octave.org>
parents:
26968
diff
changeset
|
718 |
64461ccf3039
allow inherited method calls during classdef construction (bug #52614)
John W. Eaton <jwe@octave.org>
parents:
26968
diff
changeset
|
719 std::map<cdef_class, std::list<cdef_class>>::const_iterator it |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
720 = m_ctor_list.find (cls); |
27056
64461ccf3039
allow inherited method calls during classdef construction (bug #52614)
John W. Eaton <jwe@octave.org>
parents:
26968
diff
changeset
|
721 |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
722 if (it == m_ctor_list.end () || it->second.empty ()) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
723 return true; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
725 for (const auto& cdef_cls : it->second) |
27056
64461ccf3039
allow inherited method calls during classdef construction (bug #52614)
John W. Eaton <jwe@octave.org>
parents:
26968
diff
changeset
|
726 if (! is_partially_constructed_for (cdef_cls)) |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
727 return false; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
728 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
729 return true; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
730 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
731 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
732 void |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
733 cdef_object_scalar::mark_as_constructed (const cdef_class& cls) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
734 { |
30075
0e0cc2760540
maint: use "m_" prefix for member variables in some classdef classes.
John W. Eaton <jwe@octave.org>
parents:
29950
diff
changeset
|
735 m_ctor_list.erase (cls); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
736 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
737 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
738 handle_cdef_object::~handle_cdef_object (void) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
739 { |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 #if DEBUG_TRACE |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
741 std::cerr << "deleting " << get_class ().get_name () |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
742 << " object (handle)" << std::endl; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 #endif |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
744 } |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
746 value_cdef_object::~value_cdef_object (void) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
747 { |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 #if DEBUG_TRACE |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
749 std::cerr << "deleting " << get_class ().get_name () |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
750 << " object (value)" << std::endl; |
26769
2f847e3e8d6b
split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 #endif |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
752 } |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
753 |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31105
diff
changeset
|
754 OCTAVE_END_NAMESPACE(octave) |