annotate libinterp/octave-value/ov-java.cc @ 24534:194eb4bd202b

maint: Update punctuation for GPL v3 license text. * COPYING, Makefile.am, README, bootstrap, bootstrap.conf, OctJavaQry.java, changelog.tmpl, check-subst-vars.in.sh, find-defun-files.sh, find-files-with-tests.sh, get-source-mtime.sh, mk-hg-id.sh, mk-octave-config-h.sh, mk-opts.pl, stl_algo.h-fixed, subst-config-vals.in.sh, subst-cross-config-vals.in.sh, subst-default-vals.in.sh, subst-script-vals.in.sh, configure.ac, Doxyfile.in, arith.txi, audio.txi, basics.txi, bugs.txi, config-images.sh, container.txi, cp-idx.txi, data.txi, debug.txi, diagperm.txi, diffeq.txi, add_to_aspell_dict, mk_undocumented_list, spellcheck, errors.txi, eval.txi, expr.txi, external.txi, fn-idx.txi, func.txi, genpropdoc.m, geometry.txi, geometryimages.m, grammar.txi, gui.txi, image.txi, images.awk, install.txi, interp.txi, interpimages.m, intro.txi, io.txi, linalg.txi, macros.texi, matrix.txi, mk-doc-cache.pl, mkcontrib.awk, mkoctfile.1, munge-texi.pl, nonlin.txi, numbers.txi, obsolete.txi, octave-cli.1, octave-config.1, octave.1, octave.css, octave.texi, oop.txi, op-idx.txi, optim.txi, package.txi, plot.txi, plotimages.m, poly.txi, preface.txi, quad.txi, set.txi, signal.txi, sparse.txi, sparseimages.m, splineimages.m, stats.txi, stmt.txi, strings.txi, system.txi, testfun.txi, var.txi, vectorize.txi, array.texi, bugs.texi, cp-idx.texi, dae.texi, diffeq.texi, error.texi, factor.texi, fn-idx.texi, gpl.texi, install.texi, intro.texi, liboctave.texi, matvec.texi, nleqn.texi, nlfunc.texi, ode.texi, optim.texi, preface.texi, quad.texi, range.texi, refcard-a4.tex, refcard-legal.tex, refcard-letter.tex, refcard.tex, HACKING.md, octave.appdata.xml.in, Backend.cc, Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, MouseModeActionGroup.cc, MouseModeActionGroup.h, Object.cc, Object.h, ObjectFactory.cc, ObjectFactory.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, liboctgui-build-info.h, liboctgui-build-info.in.cc, mk-default-qt-settings.in.sh, QTerminal.cc, QTerminal.h, BlockArray.cpp, BlockArray.h, Character.h, CharacterColor.h, Emulation.cpp, Emulation.h, Filter.cpp, Filter.h, History.cpp, History.h, KeyboardTranslator.cpp, KeyboardTranslator.h, QUnixTerminalImpl.cpp, QUnixTerminalImpl.h, Screen.cpp, Screen.h, ScreenWindow.cpp, ScreenWindow.h, SelfListener.cpp, SelfListener.h, TerminalCharacterDecoder.cpp, TerminalCharacterDecoder.h, TerminalModel.cpp, TerminalModel.h, TerminalView.cpp, TerminalView.h, Vt102Emulation.cpp, Vt102Emulation.h, kpty.cpp, kpty.h, kpty_p.h, QTerminalColors.cpp, QTerminalColors.h, QWinTerminalImpl.cpp, QWinTerminalImpl.h, main.cpp, color-picker.cc, color-picker.h, dialog.cc, dialog.h, documentation-dock-widget.cc, documentation-dock-widget.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc, octave-dock-widget.h, octave-gui.cc, octave-gui.h, octave-qt-link.cc, octave-qt-link.h, octave-settings.h, texinfo-parser.cc, texinfo-parser.h, webinfo.cc, webinfo.h, resource-manager.cc, resource-manager.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h, thread-manager.cc, thread-manager.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h, build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, base-text-renderer.h, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, default-defs.in.h, defaults.cc, defaults.h, defun-dld.h, defun-int.h, defun.cc, defun.h, det.cc, dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc, genprops.awk, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-handle.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gripes.cc, gripes.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, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.cc, ls-mat5.h, ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, mk-errno-list.sh, mk-mxarray-h.in.sh, mxarray.in.h, nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, oct.h, octave-default-image.h, octave-link.cc, octave-link.h, ordschur.cc, pager.cc, pager.h, pinv.cc, pr-output.cc, pr-output.h, procstream.cc, procstream.h, psi.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc, txt-eng.h, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h, deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, config-module.awk, config-module.sh, convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, mk-doc.pl, mk-pkg-add.sh, mk-version-h.in.sh, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc, ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h, ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-kw-docs, 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-cdm-cm.cc, op-cdm-cs.cc, op-cdm-dm.cc, op-cdm-m.cc, op-cdm-s.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.cc, op-cm-m.cc, op-cm-pm.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-cdm.cc, op-dm-cm.cc, op-dm-cs.cc, op-dm-dm.cc, op-dm-m.cc, op-dm-s.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fcs.cc, op-fcdm-fdm.cc, op-fcdm-fm.cc, op-fcdm-fs.cc, op-fcm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fdm.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fcdm.cc, op-fdm-fcm.cc, op-fdm-fcs.cc, op-fdm-fdm.cc, op-fdm-fm.cc, op-fdm-fs.cc, op-fm-fcdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.cc, op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.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-int.h, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.cc, op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc, op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.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, options-usage.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.in.yy, octave.gperf, parse.h, profiler.cc, profiler.h, pt-all.h, pt-arg-list.cc, pt-arg-list.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-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jit.cc, pt-jit.h, pt-jump.cc, 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-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc, version.in.h, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc, CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc, DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse-C.cc, MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.cc, chMatrix.h, chNDArray.cc, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc, idx-vector.h, int16NDArray.cc, int16NDArray.h, int32NDArray.cc, int32NDArray.h, int64NDArray.cc, int64NDArray.h, int8NDArray.cc, int8NDArray.h, intNDArray.cc, intNDArray.h, uint16NDArray.cc, uint16NDArray.h, uint32NDArray.cc, uint32NDArray.h, uint64NDArray.cc, uint64NDArray.h, uint8NDArray.cc, uint8NDArray.h, cconv2.f, cdotc3.f, cmatm3.f, csconv2.f, dconv2.f, ddot3.f, dmatm3.f, sconv2.f, sdot3.f, smatm3.f, zconv2.f, zdconv2.f, zdotc3.f, zmatm3.f, crsf2csf.f, zrsf2csf.f, mk-f77-def.in.sh, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK-opts.in, DASPK.cc, DASPK.h, DASRT-opts.in, DASRT.cc, DASRT.h, DASSL-opts.in, DASSL.cc, DASSL.h, DET.h, EIG.cc, EIG.h, LSODE-opts.in, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.cc, ODES.h, ODESFunc.h, Quad-opts.in, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h, chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h, lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h, lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h, lo-slatec-proto.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-dmsolve.cc, sparse-dmsolve.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, config-ops.sh, mk-ops.awk, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h, mx-ops, smx-ops, vx-ops, child-list.cc, child-list.h, cmach-info.c, cmach-info.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, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-passwd.cc, oct-passwd.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.h, base-list.h, blaswrap.c, byte-swap.h, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, cquit.c, data-conv.cc, data-conv.h, f2c-main.c, f77-fcn.c, f77-fcn.h, file-info.cc, file-info.h, functor.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, lo-cutils.c, lo-cutils.h, lo-error.c, lo-error.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-traits.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-glob.cc, oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c, oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, oct-sparse.h, oct-string.cc, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, singleton-cleanup.cc, singleton-cleanup.h, sparse-sort.cc, sparse-sort.h, sparse-util.cc, sparse-util.h, str-vec.cc, str-vec.h, sun-utils.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, areadlink-wrapper.c, areadlink-wrapper.h, async-system-wrapper.c, async-system-wrapper.h, base64-wrappers.c, base64-wrappers.h, canonicalize-file-name-wrapper.c, canonicalize-file-name-wrapper.h, dirent-wrappers.c, dirent-wrappers.h, fcntl-wrappers.c, fcntl-wrappers.h, filepos-wrappers.c, filepos-wrappers.h, fpucw-wrappers.c, fpucw-wrappers.h, gen-tempname-wrapper.c, gen-tempname-wrapper.h, getopt-wrapper.c, getopt-wrapper.h, glob-wrappers.c, glob-wrappers.h, hash-wrappers.c, hash-wrappers.h, localcharset-wrapper.c, localcharset-wrapper.h, math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c, mkostemp-wrapper.h, nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c, nproc-wrapper.h, octave-popen2.c, octave-popen2.h, putenv-wrapper.c, putenv-wrapper.h, set-program-name-wrapper.c, set-program-name-wrapper.h, signal-wrappers.c, signal-wrappers.h, stat-wrappers.c, stat-wrappers.h, strdup-wrapper.c, strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h, strmode-wrapper.c, strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h, time-wrappers.c, time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h, uname-wrapper.c, uname-wrapper.h, uniconv-wrappers.c, uniconv-wrappers.h, unistd-wrappers.c, unistd-wrappers.h, unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c, vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c, wait-wrappers.h, acinclude.m4, ax_blas.m4, ax_lapack.m4, ax_openmp.m4, ax_pthread.m4, octave_blas_f77_func.m4, pkg.m4, oct-conf-post.in.h, run-octave.in, Map.m, ascii.m, binary.m, cd.m, close.m, delete.m, dir.m, disp.m, ftp.m, loadobj.m, mget.m, mkdir.m, mput.m, rename.m, rmdir.m, saveobj.m, __get_properties__.m, audioplayer.m, disp.m, get.m, isplaying.m, pause.m, play.m, playblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, __get_properties__.m, audiorecorder.m, disp.m, get.m, getaudiodata.m, getplayer.m, isrecording.m, pause.m, play.m, record.m, recordblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, lin2mu.m, mu2lin.m, record.m, sound.m, soundsc.m, bitmax.m, chop.m, comma.m, isstr.m, mahalanobis.m, md5sum.m, octave_config_info.m, onenormest.m, paren.m, semicolon.m, sleep.m, usleep.m, wavread.m, wavwrite.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m, atan2d.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m, cell2mat.m, celldisp.m, circshift.m, common_size.m, cplxpair.m, cumtrapz.m, curl.m, dblquad.m, deal.m, deg2rad.m, del2.m, divergence.m, flip.m, flipdim.m, fliplr.m, flipud.m, gradient.m, idivide.m, int2str.m, integral.m, integral2.m, integral3.m, interp1.m, interp2.m, interp3.m, interpft.m, interpn.m, isequal.m, isequaln.m, logspace.m, nextpow2.m, num2str.m, pol2cart.m, polyarea.m, postpad.m, prepad.m, __splinen__.m, quad2d.m, quadgk.m, quadl.m, quadv.m, rad2deg.m, randi.m, rat.m, repelem.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sortrows.m, sph2cart.m, structfun.m, subsindex.m, trapz.m, triplequad.m, xor.m, convhull.m, delaunay.m, delaunayn.m, dsearch.m, dsearchn.m, griddata.m, griddata3.m, griddatan.m, inpolygon.m, rectint.m, tsearchn.m, voronoi.m, voronoin.m, dialog.m, errordlg.m, getappdata.m, guidata.m, guihandles.m, helpdlg.m, inputdlg.m, isappdata.m, listdlg.m, msgbox.m, __file_filter__.m, __fltk_file_filter__.m, __get_funcname__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, questdlg.m, rmappdata.m, setappdata.m, uibuttongroup.m, uicontextmenu.m, uicontrol.m, uigetdir.m, uigetfile.m, uimenu.m, uipanel.m, uipushtool.m, uiputfile.m, uiresume.m, uitoggletool.m, uitoolbar.m, uiwait.m, waitbar.m, waitforbuttonpress.m, warndlg.m, __gripe_missing_component__.m, __makeinfo__.m, __unimplemented__.m, ans.m, debug.m, doc.m, doc_cache_create.m, error_ids.m, get_first_help_sentence.m, help.m, lookfor.m, print_usage.m, __additional_help_message__.m, __strip_html_tags__.m, slash.m, type.m, warning_ids.m, which.m, autumn.m, bone.m, brighten.m, cmpermute.m, cmunique.m, colorcube.m, colormap.m, contrast.m, cool.m, copper.m, cubehelix.m, flag.m, frame2im.m, getframe.m, gray.m, gray2ind.m, hot.m, hsv.m, hsv2rgb.m, im2double.m, im2frame.m, image.m, imagesc.m, imfinfo.m, imformats.m, imread.m, imshow.m, imwrite.m, ind2gray.m, ind2rgb.m, iscolormap.m, jet.m, lines.m, ntsc2rgb.m, ocean.m, pink.m, prism.m, __imfinfo__.m, __imread__.m, __imwrite__.m, colorspace_conversion_input_check.m, colorspace_conversion_revert.m, imageIO.m, imwrite_filename.m, ind2x.m, rainbow.m, rgb2hsv.m, rgb2ind.m, rgb2ntsc.m, rgbplot.m, spinmap.m, spring.m, summer.m, viridis.m, white.m, winter.m, beep.m, csvread.m, csvwrite.m, dlmwrite.m, fileread.m, importdata.m, is_valid_file_id.m, strread.m, textread.m, javaArray.m, java_get.m, java_set.m, javaaddpath.m, javachk.m, javaclasspath.m, javamem.m, javarmpath.m, ClassHelper.java, Matrix.java, OctClassLoader.java, Octave.java, OctaveReference.java, usejava.m, bandwidth.m, commutation_matrix.m, cond.m, condeig.m, condest.m, cross.m, duplication_matrix.m, expm.m, gls.m, housh.m, isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m, istril.m, istriu.m, krylov.m, linsolve.m, logm.m, lscov.m, normest.m, normest1.m, null.m, ols.m, orth.m, planerot.m, qzhess.m, rank.m, rref.m, subspace.m, trace.m, vech.m, vecnorm.m, bug_report.m, bunzip2.m, cast.m, citation.m, compare_versions.m, computer.m, copyfile.m, delete.m, desktop.m, dir.m, dos.m, edit.m, fact.m, fieldnames.m, fileattrib.m, fileparts.m, fullfile.m, genvarname.m, getfield.m, grabcode.m, gunzip.m, info.m, inputParser.m, inputname.m, isdeployed.m, isdir.m, ismac.m, ispc.m, isunix.m, license.m, list_primes.m, loadobj.m, ls.m, ls_command.m, menu.m, methods.m, mex.m, mexext.m, mkdir.m, mkoctfile.m, movefile.m, namelengthmax.m, nargchk.m, narginchk.m, nargoutchk.m, news.m, nthargout.m, open.m, orderfields.m, pack.m, parseparams.m, perl.m, __publish_html_output__.m, __publish_latex_output__.m, __w2mpth__.m, display_info_file.m, publish.m, python.m, recycle.m, run.m, saveobj.m, setfield.m, substruct.m, swapbytes.m, symvar.m, tar.m, tempdir.m, tmpnam.m, unix.m, unpack.m, untar.m, unzip.m, validateattributes.m, ver.m, version.m, what.m, zip.m, mk-doc.pl, mk-pkg-add.sh, decic.m, ode15i.m, ode15s.m, ode23.m, ode45.m, odeget.m, odeplot.m, odeset.m, AbsRel_norm.m, check_default_input.m, integrate_adaptive.m, kahan.m, ode_event_handler.m, odedefaults.m, odemergeopts.m, runge_kutta_23.m, runge_kutta_45_dorpri.m, runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m, fminsearch.m, fminunc.m, fsolve.m, fzero.m, glpk.m, humps.m, lsqnonneg.m, optimget.m, optimset.m, pqpnonneg.m, __fdjac__.m, qp.m, sqp.m, import.m, matlabroot.m, pathdef.m, getsavepath.m, savepath.m, pkg.m, build.m, configure_make.m, default_prefix.m, describe.m, dirempty.m, get_description.m, get_forge_download.m, get_forge_pkg.m, get_unsatisfied_deps.m, getarch.m, getarchdir.m, install.m, installed_packages.m, list_forge_packages.m, load_packages.m, load_packages_and_dependencies.m, rebuild.m, save_order.m, uninstall.m, unload_packages.m, __clabel__.m, __getlegenddata__.m, __rotate_around_axis__.m, annotation.m, axis.m, box.m, camlookat.m, camorbit.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m, camzoom.m, caxis.m, clabel.m, daspect.m, datetick.m, diffuse.m, grid.m, gtext.m, hidden.m, legend.m, lighting.m, material.m, orient.m, pbaspect.m, __axis_label__.m, __axis_limits__.m, rticks.m, shading.m, specular.m, text.m, thetaticks.m, title.m, view.m, whitebg.m, xlabel.m, xlim.m, xticklabels.m, xticks.m, ylabel.m, ylim.m, yticklabels.m, yticks.m, zlabel.m, zlim.m, zticklabels.m, zticks.m, area.m, bar.m, barh.m, camlight.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourc.m, contourf.m, cylinder.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, hist.m, isocaps.m, isocolors.m, isonormals.m, isosurface.m, light.m, line.m, loglog.m, loglogerr.m, mesh.m, meshc.m, meshz.m, pareto.m, patch.m, pcolor.m, peaks.m, pie.m, pie3.m, plot.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, __add_datasource__.m, __bar__.m, __calc_isovalue_from_data__.m, __contour__.m, __errplot__.m, __ezplot__.m, __interp_cube__.m, __line__.m, __marching_cube__.m, __patch__.m, __pie__.m, __plt__.m, __quiver__.m, __scatter__.m, __stem__.m, __unite_shared_vertices__.m, quiver.m, quiver3.m, rectangle.m, reducepatch.m, reducevolume.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shrinkfaces.m, slice.m, smooth3.m, sombrero.m, sphere.m, stairs.m, stem.m, stem3.m, stemleaf.m, surf.m, surface.m, surfc.m, surfl.m, surfnorm.m, tetramesh.m, trimesh.m, triplot.m, trisurf.m, waterfall.m, __actual_axis_position__.m, __default_plot_options__.m, __gnuplot_drawnow__.m, __next_line_color__.m, __next_line_style__.m, __opengl_info__.m, __plt_get_axis_arg__.m, __pltopt__.m, allchild.m, ancestor.m, axes.m, cla.m, clf.m, close.m, closereq.m, colstyle.m, copyobj.m, figure.m, findall.m, findfigs.m, findobj.m, gca.m, gcbf.m, gcbo.m, gcf.m, gco.m, ginput.m, gnuplot_binary.in.m, graphics_toolkit.m, groot.m, hdl2struct.m, hggroup.m, hgload.m, hgsave.m, hgtransform.m, hold.m, isaxes.m, isfigure.m, isgraphics.m, ishandle.m, ishold.m, isprop.m, linkaxes.m, linkprop.m, meshgrid.m, ndgrid.m, newplot.m, pan.m, print.m, printd.m, __add_default_menu__.m, __ghostscript__.m, __gnuplot_draw_axes__.m, __gnuplot_draw_figure__.m, __gnuplot_get_var__.m, __gnuplot_ginput__.m, __gnuplot_has_feature__.m, __gnuplot_has_terminal__.m, __gnuplot_open_stream__.m, __gnuplot_print__.m, __gnuplot_version__.m, __opengl_print__.m, __print_parse_opts__.m, __set_default_mouse_modes__.m, refresh.m, refreshdata.m, rotate.m, rotate3d.m, saveas.m, shg.m, struct2hdl.m, subplot.m, zoom.m, compan.m, conv.m, deconv.m, mkpp.m, mpoles.m, padecoef.m, pchip.m, poly.m, polyaffine.m, polyder.m, polyeig.m, polyfit.m, polygcd.m, polyint.m, polyout.m, polyreduce.m, polyval.m, polyvalm.m, ppder.m, ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, splinefit.m, unmkpp.m, addpref.m, getpref.m, ispref.m, prefdir.m, preferences.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m, setpref.m, style.css, profexplore.m, profexport.m, profile.m, profshow.m, intersect.m, ismember.m, powerset.m, validsetargs.m, setdiff.m, setxor.m, union.m, unique.m, arch_fit.m, arch_rnd.m, arch_test.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, diffpara.m, durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, filter2.m, fractdiff.m, freqz.m, freqz_plot.m, hamming.m, hanning.m, hurst.m, ifftshift.m, periodogram.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m, triangle_sw.m, sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m, stft.m, synthesis.m, unwrap.m, yulewalker.m, bicg.m, bicgstab.m, cgs.m, colperm.m, eigs.m, etreeplot.m, gmres.m, gplot.m, ichol.m, ilu.m, nonzeros.m, pcg.m, pcr.m, __sprand__.m, qmr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m, sprand.m, sprandn.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, treeplot.m, bessel.m, beta.m, betaln.m, ellipke.m, expint.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m, nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m, gallery.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m, toeplitz.m, vander.m, wilkinson.m, __finish__.m, center.m, cloglog.m, corr.m, corrcoef.m, cov.m, crosstab.m, histc.m, iqr.m, kendall.m, kurtosis.m, logit.m, mean.m, meansq.m, median.m, mode.m, moment.m, ppplot.m, prctile.m, probit.m, qqplot.m, quantile.m, range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m, statistics.m, std.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m, betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m, cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m, chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m, expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m, gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m, hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m, laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m, logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m, lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m, norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m, poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m, tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m, unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m, wblrnd.m, wienrnd.m, logistic_regression.m, logistic_regression_derivatives.m, logistic_regression_likelihood.m, anova.m, bartlett_test.m, chisquare_test_homogeneity.m, chisquare_test_independence.m, cor_test.m, f_test_regression.m, hotelling_test.m, hotelling_test_2.m, kolmogorov_smirnov_test.m, kolmogorov_smirnov_test_2.m, kruskal_wallis_test.m, manova.m, mcnemar_test.m, prop_test_2.m, run_test.m, sign_test.m, t_test.m, t_test_2.m, t_test_regression.m, u_test.m, var_test.m, welch_test.m, wilcoxon_test.m, z_test.m, z_test_2.m, base2dec.m, bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, erase.m, findstr.m, hex2dec.m, index.m, isletter.m, isstring.m, isstrprop.m, mat2str.m, native2unicode.m, ostrsplit.m, regexptranslate.m, rindex.m, str2num.m, strcat.m, strchr.m, strjoin.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m, substr.m, unicode2native.m, untabify.m, validatestring.m, __have_feature__.m, __printf_assert__.m, __prog_output_assert__.m, __run_test_suite__.m, assert.m, demo.m, example.m, fail.m, compare_plot_demos.m, dump_demos.m, html_compare_plot_demos.m, rundemos.m, runtests.m, speed.m, test.m, addtodate.m, asctime.m, calendar.m, clock.m, ctime.m, date.m, datenum.m, datestr.m, datevec.m, eomday.m, etime.m, is_leap_year.m, now.m, weekday.m, display-available.c, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h, octave-build-info.in.cc, octave-config.in.cc, shared-fcns.h, args.tst, bug-31371.tst, bug-35448.tst, bug-35881.tst, bug-36025.tst, bug-38236.tst, bug-38565.tst, bug-38576.tst, bug-38691.tst, bug-41723.tst, bug-44940.tst, bug-46330.tst, bug-46660.tst, bug-50014.tst, bug-50035.tst, bug-50716.tst, bug-51192.tst, bug-51532.tst, bug-51534.tst, bug-51599.tst, bug-52075.tst, class-concat.tst, classdef-multiple-inheritance.tst, classdef.tst, classes.tst, colormaps.tst, command.tst, complex.tst, ctor-vs-method.tst, deprecate-props.tst, diag-perm.tst, error.tst, eval-catch.tst, fcn-handle-derived-resolution.tst, fntests.m, for.tst, func.tst, global.tst, if.tst, index.tst, io.tst, jit.tst, leftdiv.tst, line-continue.tst, logical-index.tst, mk-bc-overloads-tst.sh, mk-conv-tst.sh, mk-sparse-tst.sh, nest.tst, null-assign.tst, parser.tst, prefer.tst, publish.tst, range.tst, recursion.tst, return.tst, show-failures.awk, single-index.tst, slice.tst, struct.tst, switch.tst, system.tst, transpose.tst, try.tst, unwind.tst, while.tst: Changed punctuation of GPL license text to match that suggested by FSF.
author Rik <rik@octave.org>
date Sat, 06 Jan 2018 07:57:19 -0800
parents 2ac103974d00
children 46440078d73b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
1 /*
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2007-2017 Michael Goffioul
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
4
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
5 This file is part of Octave.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24199
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24199
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
10 (at your option) any later version.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
11
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22497
diff changeset
15 GNU General Public License for more details.
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
16
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
17 You should have received a copy of the GNU General Public License
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24199
diff changeset
19 <https://www.gnu.org/licenses/>.
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15745
diff changeset
20
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
23
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
24 //! @file ov-java.cc
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
25 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
26 //! Provides Octave's Java interface.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
27
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
28 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21211
diff changeset
29 # include "config.h"
15736
6faa01ff2967 build: Add --disable-java option to configure (bug #37838).
Rik <rik@octave.org>
parents: 15625
diff changeset
30 #endif
6faa01ff2967 build: Add --disable-java option to configure (bug #37838).
Rik <rik@octave.org>
parents: 15625
diff changeset
31
15755
3216dafbbd48 ov-java.cc: Correcty typo HAVE_WINDWOS_H to HAVE_WINDOWS_H
Rik <rik@octave.org>
parents: 15754
diff changeset
32 #if defined (HAVE_WINDOWS_H)
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
33 # include <windows.h>
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include <algorithm>
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <map>
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <iostream>
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include <fstream>
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
40 #include <string>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
41 #include <vector>
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include <clocale>
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
45 #include "Cell.h"
23129
35e3d199527c Replace feval calls with direct call to C++ function (bug #50116).
Rik <rik@octave.org>
parents: 23084
diff changeset
46 #include "builtin-defun-decls.h"
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
47 #include "cmd-edit.h"
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
48 #include "defaults.h"
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
49 #include "defun.h"
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
50 #include "error.h"
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
51 #include "errwarn.h"
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
52 #include "file-ops.h"
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
53 #include "file-stat.h"
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
54 #include "fpucw-wrappers.h"
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
55 #include "load-path.h"
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
56 #include "oct-env.h"
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
57 #include "oct-shlib.h"
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
58 #include "ov-java.h"
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
59 #include "parse.h"
15747
4be890c5527c * __java__.cc, __java__.h: Clean up lists of include files.
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
60 #include "variables.h"
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
61
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
62 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
63 #include <jni.h>
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
64 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
65
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
66 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
67
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
68 #define TO_JOBJECT(obj) reinterpret_cast<jobject> (obj)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
69 #define TO_JCLASS(obj) reinterpret_cast<jclass> (obj)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
70
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
71 #define TO_JNIENV(env) reinterpret_cast<JNIEnv *> (env)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
72
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
73 typedef jint (JNICALL *JNI_CreateJavaVM_t) (JavaVM **pvm, JNIEnv **penv,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
74 void *args);
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
75
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
76 typedef jint (JNICALL *JNI_GetCreatedJavaVMs_t) (JavaVM **pvm, jsize bufLen,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
77 jsize *nVMs);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
79 template <typename T>
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
80 class java_local_ref
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
81 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
82 public:
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
83
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
84 java_local_ref (JNIEnv *_env)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
85 : jobj (nullptr), detached (false), env (_env) { }
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
86
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
87 java_local_ref (JNIEnv *_env, T obj)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
88 : jobj (obj), detached (false), env (_env) { }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
89
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
90 ~java_local_ref (void) { release (); }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
91
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
92 T& operator = (T obj)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
93 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
94 release ();
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
95
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
96 jobj = obj;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
97 detached = false;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
98
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
99 return jobj;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
100 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
101
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
102 operator bool () const { return (jobj != 0); }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
103 operator T () { return jobj; }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
104
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
105 void detach (void) { detached = true; }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
106
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
107 private:
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
108
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
109 void release (void)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
110 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
111 if (env && jobj && ! detached)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
112 env->DeleteLocalRef (jobj);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
113
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
114 jobj = nullptr;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
115 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
116
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
117 java_local_ref (void)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
118 : jobj (0), detached (false), env (0)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
119 { }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
120
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
121 protected:
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
122
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
123 T jobj;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
124 bool detached;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
125 JNIEnv *env;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
126 };
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
127
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
128 typedef java_local_ref<jobject> jobject_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
129 typedef java_local_ref<jclass> jclass_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
130 typedef java_local_ref<jstring> jstring_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
131 typedef java_local_ref<jobjectArray> jobjectArray_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
132 typedef java_local_ref<jintArray> jintArray_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
133 typedef java_local_ref<jbyteArray> jbyteArray_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
134 typedef java_local_ref<jdoubleArray> jdoubleArray_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
135 typedef java_local_ref<jthrowable> jthrowable_ref;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
136
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
137 static std::string
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
138 jstring_to_string (JNIEnv *jni_env, jstring s);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
139
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
140 static std::string
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
141 jstring_to_string (JNIEnv *jni_env, jobject obj);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
142
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
143 static octave_value
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
144 box (JNIEnv *jni_env, void *jobj, void *jcls_arg = nullptr);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
145
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
146 static octave_value
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
147 box_more (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg = nullptr);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
148
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
149 static bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
150 unbox (JNIEnv *jni_env, const octave_value& val, jobject_ref& jobj,
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
151 jclass_ref& jcls);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
152
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
153 static bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
154 unbox (JNIEnv *jni_env, const octave_value_list& args,
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
155 jobjectArray_ref& jobjs, jobjectArray_ref& jclss);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
156
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
157 extern "C"
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
158 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
159 JNIEXPORT jboolean JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
160 Java_org_octave_Octave_call (JNIEnv *, jclass, jstring, jobjectArray,
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
161 jobjectArray);
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
162
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
163 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
164 Java_org_octave_OctaveReference_doFinalize (JNIEnv *, jclass, jint);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
165
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
166 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
167 Java_org_octave_Octave_doInvoke (JNIEnv *, jclass, jint, jobjectArray);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
169 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
170 Java_org_octave_Octave_doEvalString (JNIEnv *, jclass, jstring);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
171
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
172 JNIEXPORT jboolean JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
173 Java_org_octave_Octave_needThreadedInvokation (JNIEnv *, jclass);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
174 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
175
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
176 //! The pointer to a java virtual machine either created in the current thread
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
177 //! or attached this thread to it.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
178
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
179 static JavaVM *jvm = nullptr;
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
180
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
181 //! Whether the current thread is attached to the jvm given by #jvm.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
182 //! This is @c false also if no jvm exists, i.e. if #jvm is @c nullptr.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
183 //! @see #initialize_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
184 //! @see #terminate_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
185
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 static bool jvm_attached = false;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
188 //! Need to keep hold of the shared library handle until exit.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
189 //! @see #initialize_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
190 //! @see #terminate_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
191
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
192 static octave::dynamic_library jvm_lib;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194 static std::map<int,octave_value> listener_map;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195 static std::map<int,octave_value> octave_ref_map;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196 static int octave_java_refcount = 0;
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
197
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
198 //! The thread id of the currently executing thread or @c -1 if this is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
199 //! unknown.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
200 //! @see #initialize_java()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
201
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 static long octave_thread_ID = -1;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
204 bool Vjava_matrix_autoconversion = false;
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
205 bool Vjava_unsigned_autoconversion = true;
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
206 bool Vdebug_java = false;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
208 namespace octave
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
209 {
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
210 class JVMArgs
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
211 {
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
212 public:
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
213
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
214 JVMArgs (void)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
215 {
23929
20c83f619102 bump Java compatibility level to 1.6, minimum supported by Java 9 (bug #51803)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
216 vm_args.version = JNI_VERSION_1_6;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
217 vm_args.nOptions = 0;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
218 vm_args.options = nullptr;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
219 vm_args.ignoreUnrecognized = false;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
220 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
221
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
222 ~JVMArgs (void)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
223 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
224 clean ();
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
225 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
226
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23405
diff changeset
227 JavaVMInitArgs * to_args ()
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
228 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
229 update ();
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
230 return &vm_args;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
231 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
232
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
233 void add (const std::string& opt)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
234 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
235 java_opts.push_back (opt);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
236 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
237
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
238 void read_java_opts (const std::string& filename)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
239 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
240 std::ifstream js (filename.c_str ());
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
241
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
242 if (! js.bad () && ! js.fail ())
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
243 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
244 std::string line;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
245
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
246 while (! js.eof () && ! js.fail ())
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
247 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
248 std::getline (js, line);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
249
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23804
diff changeset
250 if (line.find ('-') == 0)
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
251 java_opts.push_back (line);
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
252 else if (line.length () > 0 && Vdebug_java)
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
253 std::cerr << "invalid JVM option, skipping: " << line
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
254 << std::endl;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
255 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
256 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
257 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
258
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
259 private:
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
260
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
261 void clean (void)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
262 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
263 if (vm_args.options != nullptr)
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
264 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
265 for (int i = 0; i < vm_args.nOptions; i++)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
266 delete [] vm_args.options[i].optionString;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
267
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
268 delete [] vm_args.options;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
269
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
270 vm_args.options = nullptr;
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
271 vm_args.nOptions = 0;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
272 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
273 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
274
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
275 void update (void)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
276 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
277 clean ();
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
278
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
279 if (java_opts.size () > 0)
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
280 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
281 int index = 0;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
282
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
283 vm_args.nOptions = java_opts.size ();
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
284 vm_args.options = new JavaVMOption [vm_args.nOptions];
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
285
22871
50495eeb5df1 maint: Use C++ range feature to simplify some for loops in libinterp/octave-value.
Rik <rik@octave.org>
parents: 22755
diff changeset
286 for (const auto& opt : java_opts)
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
287 {
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
288 if (Vdebug_java)
22871
50495eeb5df1 maint: Use C++ range feature to simplify some for loops in libinterp/octave-value.
Rik <rik@octave.org>
parents: 22755
diff changeset
289 std::cout << opt << std::endl;
50495eeb5df1 maint: Use C++ range feature to simplify some for loops in libinterp/octave-value.
Rik <rik@octave.org>
parents: 22755
diff changeset
290 vm_args.options[index++].optionString = strsave (opt.c_str ());
22331
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
291 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
292
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
293 java_opts.clear ();
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
294 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
295 }
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
296
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
297 private:
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
298
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
299 JavaVMInitArgs vm_args;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
300
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
301 std::list<std::string> java_opts;
b81b08cc4c83 maint: Indent namespaces in more files.
John W. Eaton <jwe@octave.org>
parents: 22327
diff changeset
302 };
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
303 }
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
304
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
305 #if defined (OCTAVE_USE_WINDOWS_API)
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
306
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
307 static std::string
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
308 read_registry_string (const std::string& key, const std::string& value)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
309 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
310 HKEY hkey;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311 DWORD len;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
312
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
313 std::string retval;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
315 if (! RegOpenKeyEx (HKEY_LOCAL_MACHINE, key.c_str (), 0, KEY_READ, &hkey))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
317 if (! RegQueryValueEx (hkey, value.c_str (), 0, 0, 0, &len))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319 retval.resize (len);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
320 if (RegQueryValueEx (hkey, value.c_str (), 0, 0,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
321 (LPBYTE)&retval[0], &len))
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
322 retval = "";
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
323 else if (retval[len-1] == '\0')
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
324 retval.resize (--len);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 RegCloseKey (hkey);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
328
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
332 static std::string
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
333 get_module_filename (HMODULE hMod)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335 int n = 1024;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
336 std::string retval (n, '\0');
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337 bool found = false;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339 while (n < 65536)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
340 {
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
341 int status = GetModuleFileName (hMod, &retval[0], n);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343 if (status < n)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344 {
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
345 retval.resize (n);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346 found = true;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347 break;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
350 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
351 n *= 2;
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
352 retval.resize (n);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
354 }
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
355
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356 return (found ? retval : "");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
357 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
359 #endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
361 //! The java initialization directory is given by the environment variable
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
362 //! @c OCTAVE_JAVA_DIR if defined; otherwise it is the directory of Octave's
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
363 //! m-files defining Java functions.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
364 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
365 //! The Java initialization directory is the directory where resides:
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
366 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
367 //! - @c octave.jar, defining the java classes implementing octave's java
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
368 //! interface,
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
369 //! - @c javaclasspath.txt, defining the installation defined portion of the
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
370 //! (static) classpath,
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
371 //! - @c java.opts, defining the configurable options of the java virtual
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
372 //! machine.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
373 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
374 //! Note that the (static) java classpath of the java virtual machine starts
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
375 //! with @c octave.jar, and that the static java classpath ends with what
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
376 //! is read from @c javaclasspath.txt located in the initial java directory.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
377 //! Moreover, the java virtual machine is created essentially with
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
378 //! the options given by @c java.opts.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
379
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
380 static std::string
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
381 initial_java_dir (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
382 {
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
383 static std::string java_dir;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
385 if (java_dir.empty ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386 {
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
387 java_dir = octave::sys::env::getenv ("OCTAVE_JAVA_DIR");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
388
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
389 if (java_dir.empty ())
23717
06579337237b move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents: 23681
diff changeset
390 java_dir = (octave::config::fcn_file_dir ()
06579337237b move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents: 23681
diff changeset
391 + octave::sys::file_ops::dir_sep_str () + "java");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
392 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
393
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
394 return java_dir;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
395 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
396
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
397 //! Return the classpath in the given file @c filepath as a string.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
398 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
399 //! In the classpath file, each line which is neither empty nor a comment, is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
400 //! interpreted as a segment of a path. Comment lines are those starting with
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
401 //! a @c # or with a @c % in the very first column.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
402 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
403 //! @param filepath The path to the file (usually @c classpath.txt) containing
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
404 //! a portion of the classpath.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
405 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
406 //! @returns A string consisting of the lines of @c filepath which are neither
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
407 //! comments nor empty without trailing whitespace separated by
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
408 //! `octave::directory_path::path_sep_str()`. The returned string also
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
409 //! starts with that path separator.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
410
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
411 static std::string
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
412 read_classpath_txt (const std::string& filepath)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 {
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
414 std::string classpath;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
415
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
416 std::ifstream fs (filepath.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
418 if (! fs.bad () && ! fs.fail ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419 {
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
420 std::string line;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
422 while (! fs.eof () && ! fs.fail ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
423 {
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
424 std::getline (fs, line);
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
425 if (line.length () > 0 && line[0] != '#' && line[0] != '%')
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
427 // prepend separator character
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
428 classpath.append (octave::directory_path::path_sep_str ());
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
429
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
430 // append content of line without whitespace
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
431 int last = line.find_last_not_of (" \t\f\v\r\n");
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
432
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
433 classpath.append (octave::sys::file_ops::tilde_expand (line.substr (0, last+1)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
434 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
436 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
437
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
438 return (classpath);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
439 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
441
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
442 //! Return the initial classpath.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
443 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
444 //! The initial classpath starts with a pointer to @c octave.jar which is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
445 //! located in the initial java directory given by #java_init_dir().
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
446 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
447 //! @attention This is nowhere documented and also the script
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
448 //! @c javaclasspath.m drops this. On the other hand, this is vital because
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
449 //! @c octave.jar contains the java core classes of octave's java interface.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
450 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
451 //! The rest of the classpath is read sequentially from files
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
452 //! @c javaclasspath.txt located in either:
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
453 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
454 //! - the current directory,
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
455 //! - the user's home directory,
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
456 //! - the initial java directory returned by #initial_java_dir()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
457 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
458 //! @returns The initial classpath.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
459
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
460 static std::string
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
461 initial_class_path (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462 {
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
463 std::string java_dir = initial_java_dir ();
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
464
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
465 std::string retval = java_dir;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
466
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
467 // Find octave.jar file.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
468 if (! retval.empty ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
469 {
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
470 std::string sep = octave::sys::file_ops::dir_sep_str ();
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
471
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
472 std::string jar_file = java_dir + sep + "octave.jar";
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
473
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
474 octave::sys::file_stat jar_exists (jar_file);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476 if (jar_exists)
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
477 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
478 // Initialize static classpath to octave.jar.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
479 retval = jar_file;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
480
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
481 // The base classpath has been set.
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
482 // Try to find an optional file specifying classpaths in 3 places.
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
483 // 1) Current directory
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
484 // 2) User's home directory
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
485 // 3) Octave installation directory where octave.jar resides
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
486
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
487 std::string cwd = octave::sys::env::get_current_directory ();
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
488 std::string home_dir = octave::sys::env::get_home_directory ();
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
489
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
490 // The filename is "javaclasspath.txt", but historically has been
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
491 // "classpath.txt" so both are supported.
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
492 std::vector<std::string> cp_list = {"javaclasspath.txt",
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
493 "classpath.txt"};
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
494
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
495 for (std::string filename : cp_list)
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
496 {
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
497 std::string cp_file = filename;
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23804
diff changeset
498 octave::sys::file_stat cp_exists;
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
499
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
500 // Try to find classpath file in the current directory.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
501
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
502 cp_exists = octave::sys::file_stat (cp_file);
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
503 if (cp_exists)
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
504 {
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
505 // File found. Add its contents to the static classpath.
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
506 std::string classpath = read_classpath_txt (cp_file);
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
507 retval.append (classpath);
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
508 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
509
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
510 // Try to find classpath file in the user's home directory.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
511
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
512 if (cwd != home_dir)
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
513 {
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23804
diff changeset
514 cp_file = '~' + sep + filename;
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
515 cp_file = octave::sys::file_ops::tilde_expand (cp_file);
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
516 cp_exists = octave::sys::file_stat (cp_file);
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
517 if (cp_exists)
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
518 {
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
519 // File found. Add its contents to the static classpath.
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
520 std::string classpath = read_classpath_txt (cp_file);
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
521 retval.append (classpath);
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
522 }
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
523 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
524
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
525 // Try to find classpath file in the Octave install directory.
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
526
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
527 if (cwd != java_dir)
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
528 {
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
529 cp_file = java_dir + sep + filename;
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
530 cp_exists = octave::sys::file_stat (cp_file);
20422
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
531 if (cp_exists)
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
532 {
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
533 // File found. Add its contents to the static classpath.
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
534 std::string classpath = read_classpath_txt (cp_file);
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
535 retval.append (classpath);
4262598620ae Don't add duplicates to javaclasspath when run in home directory (bug #45683).
Rik <rik@octave.org>
parents: 20274
diff changeset
536 }
15797
492893b98eef Search for "javaclasspath.txt" as well as "classpath.txt" to set static class path.
Rik <rik@octave.org>
parents: 15792
diff changeset
537 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
538 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
539 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 else
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
541 error ("octave.jar does not exist: %s", jar_file.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 else
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
544 error ("initial java dir is empty");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
549 //! Initialize the java virtual machine (jvm) and field #jvm if necessary.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
550 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
551 //! If the jvm exists and is initialized, #jvm points to it, i.e. is not 0
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
552 //! and there is nothing to do.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
553 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
554 //! If #jvm is 0 and if at least one jvm exists, attach the current thread to
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
555 //! it by setting #jvm_attached. Otherwise, create a #jvm with some hard-
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
556 //! coded options:
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
557 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
558 //! - `-Djava.class.path=classpath`, where @c classpath is given by
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
559 //! #initial_class_path().
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
560 //! - `-Djava.system.class.loader=org.octave.OctClassLoader`.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
561 //! - `-Xrs`
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
562 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
563 //! Further options are read from the file @c java.opts in the directory given
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
564 //! by #java_init_dir().
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
565 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
566 //! Note that #initial_class_path() determines the initial classpath. This
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
567 //! is the static classpath which cannot be changed. Elements of the dynamic
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
568 //! classpath can be added and removed using the m-file scripts
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
569 //! @c javaaddpath.m and @c javarmpath.m.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
570 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
571 //! @see #terminate_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
572
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
573 static void
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
574 initialize_jvm (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 {
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
576 // Most of the time JVM already exists and has been initialized.
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
577 // Also it seems, as if jvm is set, the jvm is already attached.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
578 // This does not fit terminate_jvm.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
579 if (jvm)
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
580 return;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
581
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
582 JNIEnv *current_env;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
583 const char *static_locale = setlocale (LC_ALL, nullptr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
584 const std::string locale (static_locale);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
585
21979
d04da18a407a use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
586 #if defined (OCTAVE_USE_WINDOWS_API)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
587
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
588 HMODULE hMod = GetModuleHandle ("jvm.dll");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 std::string jvm_lib_path;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
591 if (hMod)
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
592 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
593 // JVM seems to be already loaded, better to use that DLL instead of
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
594 // looking in the registry, to avoid opening a different JVM.
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
595 jvm_lib_path = get_module_filename (hMod);
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
596
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
597 if (jvm_lib_path.empty ())
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
598 error ("unable to find Java Runtime Environment");
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
599 }
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
600 else
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
601 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
602 // In windows, find the location of the JRE from the registry
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
603 // and load the symbol from the dll.
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
604 std::string key, value;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605
23804
8057d3f0673d Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents: 23795
diff changeset
606 key = R"(software\javasoft\java runtime environment)";
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
608 value = octave::sys::env::getenv ("JAVA_VERSION");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
609 if (value.empty ())
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
610 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
611 value = "Currentversion";
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
612 std::string regval = read_registry_string (key,value);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
614 if (regval.empty ())
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
615 error ("unable to find Java Runtime Environment: %s::%s",
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
616 key.c_str (), value.c_str ());
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
617
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
618 value = regval;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
619 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
620
23804
8057d3f0673d Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents: 23795
diff changeset
621 key = key + '\\' + value;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
622 value = "RuntimeLib";
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
623 jvm_lib_path = read_registry_string (key, value);
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
624
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
625 if (jvm_lib_path.empty ())
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
626 error ("unable to find Java Runtime Environment: %s::%s",
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
627 key.c_str (), value.c_str ());
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
628 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629
20945
9d9270e2f98f eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents: 20939
diff changeset
630 #else
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
631
15763
56239ff815a3 build: Overhaul auto-detection of Java when JAVA_HOME is not set.
Rik <rik@octave.org>
parents: 15755
diff changeset
632 // JAVA_LDPATH determined by configure and set in config.h
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
633 # if defined (__APPLE__)
15763
56239ff815a3 build: Overhaul auto-detection of Java when JAVA_HOME is not set.
Rik <rik@octave.org>
parents: 15755
diff changeset
634 std::string jvm_lib_path = JAVA_LDPATH + std::string ("/libjvm.dylib");
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
635 # else
15763
56239ff815a3 build: Overhaul auto-detection of Java when JAVA_HOME is not set.
Rik <rik@octave.org>
parents: 15755
diff changeset
636 std::string jvm_lib_path = JAVA_LDPATH + std::string ("/libjvm.so");
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
637 # endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 #endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
641 //! The number of created jvm's.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 jsize nVMs = 0;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
644 #if ! defined (__APPLE__) && ! defined (__MACH__)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
646 octave::dynamic_library lib (jvm_lib_path);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
647
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
648 if (! lib)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
649 error ("unable to load Java Runtime Environment from %s",
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
650 jvm_lib_path.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
651
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
652 JNI_CreateJavaVM_t create_vm =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
653 reinterpret_cast<JNI_CreateJavaVM_t> (lib.search ("JNI_CreateJavaVM"));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
654 JNI_GetCreatedJavaVMs_t get_vm =
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
655 reinterpret_cast<JNI_GetCreatedJavaVMs_t>
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
656 (lib.search ("JNI_GetCreatedJavaVMs"));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
657
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
658 if (! create_vm)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
659 error ("unable to find JNI_CreateJavaVM in %s", jvm_lib_path.c_str ());
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
660
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
661 if (! get_vm)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
662 error ("unable to find JNI_GetCreatedJavaVMs in %s", jvm_lib_path.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
664 if (get_vm (&jvm, 1, &nVMs) == 0 && nVMs > 0)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
666 #else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668 // FIXME: There exists a problem on the Mac platform that
21750
6720e5a220ba use namespace for octave_shlib class
John W. Eaton <jwe@octave.org>
parents: 21748
diff changeset
669 // octave::dynamic_library lib (jvm_lib_path)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
670 // doesn't work with 'not-bundled' *.oct files.
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
672 if (JNI_GetCreatedJavaVMs (&jvm, 1, &nVMs) == 0 && nVMs > 0)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
674 #endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
675
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
676 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
677 // At least one JVM exists, try to attach the current thread to it.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
678
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
679 switch (jvm->GetEnv (reinterpret_cast<void **> (&current_env),
23929
20c83f619102 bump Java compatibility level to 1.6, minimum supported by Java 9 (bug #51803)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
680 JNI_VERSION_1_6))
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
681 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
682 case JNI_EDETACHED:
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
683 // Attach the current thread
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
684 JavaVMAttachArgs vm_args;
23929
20c83f619102 bump Java compatibility level to 1.6, minimum supported by Java 9 (bug #51803)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
685 vm_args.version = JNI_VERSION_1_6;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
686 vm_args.name = const_cast<char *> ("octave");
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
687 vm_args.group = nullptr;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
688 if (jvm->AttachCurrentThread (reinterpret_cast<void **> (&current_env),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
689 &vm_args) < 0)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
690 error ("JVM internal error, unable to attach octave to existing JVM");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
691 break;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
692
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
693 case JNI_EVERSION:
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
694 error ("JVM internal error, the required JNI version is not supported");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
695 break;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
696
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
697 case JNI_OK:
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
698 // Don't do anything, the current thread is already attached to JVM
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
699 break;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
700 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
701
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
702 jvm_attached = true;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
703 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
704 else
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
705 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
706 // No JVM exists, create one
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
708 octave::JVMArgs vm_args;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
709
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
710 // Hard-coded options for the jvm.
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
711 vm_args.add ("-Djava.class.path=" + initial_class_path ());
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
712 vm_args.add ("-Djava.system.class.loader=org.octave.OctClassLoader");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
713 vm_args.add ("-Xrs");
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
714
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
715 // Additional options given by file java.opts.
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
716 vm_args.read_java_opts (initial_java_dir () +
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
717 octave::sys::file_ops::dir_sep_str () +
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
718 "java.opts");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
719
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21042
diff changeset
720 #if ! defined (__APPLE__) && ! defined (__MACH__)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
721
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
722 if (create_vm (&jvm, &current_env, vm_args.to_args ()) != JNI_OK)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
723 error ("unable to start Java VM in %s", jvm_lib_path.c_str ());
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
724 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
725
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
726 jvm_lib = lib;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
727
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
728 #else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
729
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
730 if (JNI_CreateJavaVM (&jvm, reinterpret_cast<void **> (&current_env),
15752
f96faf028d90 make java functions part of core octave_value classes
John W. Eaton <jwe@octave.org>
parents: 15747
diff changeset
731 vm_args.to_args ()) != JNI_OK)
21380
460943554233 * ov-java.cc: Call error instead of throwing std::string objects.
John W. Eaton <jwe@octave.org>
parents: 21379
diff changeset
732 error ("unable to start Java VM in %s", jvm_lib_path.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
733
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
734 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
735
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
736 #endif
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
737
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
738 setlocale (LC_ALL, locale.c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
739 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
740
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
741 //! Terminate the current jvm, if there is any.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
742 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
743 //! Otherwise, detach the jvm if this thread is attached to it and unload it
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
744 //! if this thread created it itself.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
745 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
746 //! @see #initialize_jvm()
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
747
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
748 static void
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
749 terminate_jvm (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
750 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
751 // There is nothing to do if jvm is not set (= nullptr).
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
752 if (jvm)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
753 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
754 // FIXME: Seems that if jvm_attached is always true if jvm is not null.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
755 if (jvm_attached)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
756 jvm->DetachCurrentThread ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
758 jvm->DestroyJavaVM ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
759
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
760 jvm = nullptr;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
761 jvm_attached = false;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
762
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
763 if (jvm_lib)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
764 jvm_lib.close ();
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
765
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
766 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
767 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
768 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
769
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
770 //! Converts a Java string object to std::string.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
771 //!{
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
772 static std::string
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
773 jstring_to_string (JNIEnv *jni_env, jstring s)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
774 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775 std::string retval;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
776
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
779 const char *cstr = jni_env->GetStringUTFChars (s, nullptr);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780 retval = cstr;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781 jni_env->ReleaseStringUTFChars (s, cstr);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
782 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
783
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
784 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
786
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
787 static std::string
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
788 jstring_to_string (JNIEnv *jni_env, jobject obj)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
789 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
790 std::string retval;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
791
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792 if (jni_env && obj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
793 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
794 jclass_ref cls (jni_env, jni_env->FindClass ("java/lang/String"));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
795 if (cls)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
796 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
797 if (jni_env->IsInstanceOf (obj, cls))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
798 retval = jstring_to_string (jni_env,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
799 reinterpret_cast<jstring> (obj));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
800 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
801 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
802
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
803 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
804 }
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
805 //!}
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
806
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
807 //! Returns a reference to the jni (java native interface) environment of the
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
808 //! Java virtual machine #jvm.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
809 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
810 //! @returns A reference to jni, if #jvm is present, otherwise @c nullptr.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
811
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
812 static inline JNIEnv *
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
813 thread_jni_env (void)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
814 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
815 JNIEnv *env = nullptr;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
816
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
817 if (jvm)
23929
20c83f619102 bump Java compatibility level to 1.6, minimum supported by Java 9 (bug #51803)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
818 jvm->GetEnv (reinterpret_cast<void **> (&env), JNI_VERSION_1_6);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
819
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
820 return env;
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
821 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
822
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
823 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
824
15824
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
825 bool
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
826 octave_java::is_java_string (void) const
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
827 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
828 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
829
15824
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
830 JNIEnv *current_env = thread_jni_env ();
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
831
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
832 if (current_env && java_object)
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
833 {
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
834 jclass_ref cls (current_env, current_env->FindClass ("java/lang/String"));
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
835 return current_env->IsInstanceOf (TO_JOBJECT (java_object), cls);
15824
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
836 }
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
837
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
838 return false;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
839
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
840 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
841
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
842 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
843 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
844
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
845 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
846
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
847 #endif
15824
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
848 }
abc9e5f3c661 Return correct value for ischar() predicate test on octave_java objects.
Rik <rik@octave.org>
parents: 15822
diff changeset
849
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
850 bool
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
851 octave_java::is_instance_of (const std::string& cls_name) const
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
852 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
853 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
854
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
855 JNIEnv *current_env = thread_jni_env ();
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
856
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
857 std::string cls_cpp = cls_name;
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
858 std::replace (cls_cpp.begin (), cls_cpp.end (), '.', '/');
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
859
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
860 if (current_env && java_object)
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
861 {
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
862 jclass_ref cls (current_env, current_env->FindClass (cls_cpp.c_str ()));
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
863 if (current_env->ExceptionCheck ())
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
864 current_env->ExceptionClear ();
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
865 else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
866 return current_env->IsInstanceOf (TO_JOBJECT (java_object), cls);
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
867 }
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
868 return false;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
869
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
870 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
871
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
872 octave_unused_parameter (cls_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
873
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
874 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
875 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
876
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
877 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
878
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
879 #endif
20028
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
880 }
107130a0490c isa: check parent class of java objects (bug #42702)
Carnë Draug <carandraug@octave.org>
parents: 19861
diff changeset
881
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
882 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
883
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
884 static octave_value
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
885 check_exception (JNIEnv *jni_env)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
886 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
887 octave_value retval;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
888
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
889 jthrowable_ref ex (jni_env, jni_env->ExceptionOccurred ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
890
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
891 if (ex)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
892 {
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
893 if (Vdebug_java)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894 jni_env->ExceptionDescribe ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
895
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
896 jni_env->ExceptionClear ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
897
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
898 jclass_ref jcls (jni_env, jni_env->GetObjectClass (ex));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
899 jmethodID mID = jni_env->GetMethodID (jcls, "toString",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
900 "()Ljava/lang/String;");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
901 jstring_ref js (jni_env,
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
902 reinterpret_cast<jstring> (jni_env->CallObjectMethod (ex,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
903 mID)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
904 std::string msg = jstring_to_string (jni_env, js);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
906 error ("[java] %s", msg.c_str ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
907 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
908 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909 retval = Matrix ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
910
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
911 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
912 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
913
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
914 static jclass
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
915 find_octave_class (JNIEnv *jni_env, const char *name)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
916 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
917 static std::string class_loader;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
918 static jclass uiClass = nullptr;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
919
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
920 jclass jcls = jni_env->FindClass (name);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
922 if (jcls == nullptr)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
924 jni_env->ExceptionClear ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926 if (! uiClass)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
927 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928 if (class_loader.empty ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
929 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
930 jclass_ref syscls (jni_env,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
931 jni_env->FindClass ("java/lang/System"));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
932 jmethodID mID = jni_env->GetStaticMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
933 (syscls,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
934 "getProperty",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
935 "(Ljava/lang/String;)Ljava/lang/String;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
936 jstring_ref js (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
937 jni_env->NewStringUTF ("octave.class.loader"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
938 js = reinterpret_cast<jstring> (jni_env->CallStaticObjectMethod
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
939 (syscls, mID, jstring (js)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
940 class_loader = jstring_to_string (jni_env, jstring (js));
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
941 std::replace (class_loader.begin (), class_loader.end (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
942 '.', '/');
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
943 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
944
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
945 jclass_ref uicls (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
946 jni_env->FindClass (class_loader.c_str ()));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
947
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
948 if (! uicls)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
949 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
950 jni_env->ExceptionClear ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
951
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20945
diff changeset
952 // Try the netbeans way
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
953 std::replace (class_loader.begin (), class_loader.end (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
954 '/', '.');
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
955 jclass_ref jcls2 (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
956 jni_env->FindClass ("org/openide/util/Lookup"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
957 jmethodID mID = jni_env->GetStaticMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
958 (jcls2, "getDefault", "()Lorg/openide/util/Lookup;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
959 jobject_ref lObj (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
960 jni_env->CallStaticObjectMethod (jcls2, mID));
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
961 mID = jni_env->GetMethodID (jcls2, "lookup",
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19598
diff changeset
962 "(Ljava/lang/Class;)Ljava/lang/Object;");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
963 jclass_ref cLoaderCls (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
964 jni_env->FindClass ("java/lang/ClassLoader"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
965 jobject_ref cLoader (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
966 jni_env->CallObjectMethod
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
967 (lObj, mID, jclass (cLoaderCls)));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
968 mID = jni_env->GetMethodID (cLoaderCls, "loadClass",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
969 "(Ljava/lang/String;)Ljava/lang/Class;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
970 jstring_ref js (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
971 jni_env->NewStringUTF (class_loader.c_str ()));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
972 uicls = reinterpret_cast<jclass>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
973 (jni_env->CallObjectMethod (cLoader, mID, jstring (js)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
974 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
975
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
976 if (uicls)
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
977 uiClass = reinterpret_cast<jclass>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
978 (jni_env->NewGlobalRef (jclass (uicls)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
979 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
980
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
981 if (uiClass)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
982 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
983 jmethodID mID = jni_env->GetStaticMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
984 (uiClass, "findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
985 jstring_ref js (jni_env, jni_env->NewStringUTF (name));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
986 jcls = reinterpret_cast<jclass>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
987 (jni_env->CallStaticObjectMethod (uiClass, mID, jstring (js)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
988 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
989 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
990
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
991 return jcls;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
992 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
993
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
994 static dim_vector
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
995 compute_array_dimensions (JNIEnv *jni_env, jobject obj)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
996 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
997 jobjectArray_ref jobj (jni_env, reinterpret_cast<jobjectArray> (obj));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
998 jclass_ref jcls (jni_env, jni_env->GetObjectClass (obj));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
999 jclass_ref ccls (jni_env, jni_env->GetObjectClass (jcls));
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
1000 jmethodID isArray_ID = jni_env->GetMethodID (ccls, "isArray", "()Z");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1001 jmethodID getComponentType_ID = jni_env->GetMethodID (ccls,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1002 "getComponentType",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1003 "()Ljava/lang/Class;");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1004
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1005 dim_vector dv (1, 1);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1006 int idx = 0;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1007
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1008 jobj.detach ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1009 while (jcls && jni_env->CallBooleanMethod (jcls, isArray_ID))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1010 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1011 int len = (jobj ? jni_env->GetArrayLength (jobj) : 0);
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21580
diff changeset
1012 if (idx >= dv.ndims ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 dv.resize (idx+1);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1014 dv(idx) = len;
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1015 jcls = reinterpret_cast<jclass>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1016 (jni_env->CallObjectMethod (jcls, getComponentType_ID));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1017 jobj = len > 0
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1018 ? reinterpret_cast<jobjectArray> (jni_env->GetObjectArrayElement (jobj,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1019 0))
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1020 : nullptr;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1021 idx++;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1022 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1023
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1024 octave_set_default_fpucw ();
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1025
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1026 return dv;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1027 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1028
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1029 static jobject
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1030 make_java_index (JNIEnv *jni_env, const octave_value_list& idx)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1031 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1032 jclass_ref ocls (jni_env, jni_env->FindClass ("[I"));
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1033 jobjectArray retval = jni_env->NewObjectArray (idx.length (), ocls, nullptr);
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1034 // Here retval has the same length as idx
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1035
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1036 // Fill in entries of idx into retval
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1037 for (int i = 0; i < idx.length (); i++)
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1038 try
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1039 {
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1040 idx_vector v = idx(i).index_vector ();
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1041
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1042 jintArray_ref i_array (jni_env, jni_env->NewIntArray (v.length ()));
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1043 jint *buf = jni_env->GetIntArrayElements (i_array, nullptr);
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1044 // Here, buf points to the beginning of i_array
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1045
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1046 // Copy v to buf.
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1047 for (int k = 0; k < v.length (); k++)
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1048 buf[k] = v(k);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1049
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1050 // Set retval[i] = i_array
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1051 jni_env->ReleaseIntArrayElements (i_array, buf, 0);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1052 jni_env->SetObjectArrayElement (retval, i, i_array);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1053
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1054 check_exception (jni_env);
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1055 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22326
diff changeset
1056 catch (octave::index_exception& e)
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1057 {
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1058 // Rethrow to allow more info to be reported later.
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1059 e.set_pos_if_unset (idx.length (), i + 1);
20542
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1060 throw;
dd6345fd8a97 use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents: 20531
diff changeset
1061 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1062
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1063 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1064 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1065
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1066 static octave_value
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1067 get_array_elements (JNIEnv *jni_env, jobject jobj,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1068 const octave_value_list& idx)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1069 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1070 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1071 jobject_ref resObj (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1072 jobject_ref java_idx (jni_env, make_java_index (jni_env, idx));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1073
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1074 jclass_ref helperClass (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1075 find_octave_class (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1076 "org/octave/ClassHelper"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1077 jmethodID mID = jni_env
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1078 ->GetStaticMethodID (helperClass, "arraySubsref",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1079 "(Ljava/lang/Object;[[I)Ljava/lang/Object;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1080 resObj = jni_env->CallStaticObjectMethod
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1081 (helperClass, mID, jobj, jobject (java_idx));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1082
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1083 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1084 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1085 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1086 retval = check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1087
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1088 octave_set_default_fpucw ();
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1089
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1090 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1091 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1093 static octave_value
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1094 set_array_elements (JNIEnv *jni_env, jobject jobj,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1095 const octave_value_list& idx, const octave_value& rhs)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1096 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1097 octave_value retval;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1098
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1099 jclass_ref rhsCls (jni_env);
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
1100 jobject_ref resObj (jni_env);
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
1101 jobject_ref rhsObj (jni_env);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1102 jobject_ref java_idx (jni_env, make_java_index (jni_env, idx));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1103
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1104 if (unbox (jni_env, rhs, rhsObj, rhsCls))
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1105 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1106 jclass_ref helperClass (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1107 find_octave_class (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1108 "org/octave/ClassHelper"));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1109 jmethodID mID = jni_env->GetStaticMethodID (helperClass, "arraySubsasgn",
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1110 "(Ljava/lang/Object;[[ILjava/lang/Object;)" "Ljava/lang/Object;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1111 resObj = jni_env->CallStaticObjectMethod
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1112 (helperClass, mID, jobj, jobject (java_idx), jobject (rhsObj));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1113 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1114
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1115 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1116 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1117 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1118 retval = check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1119
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1120 octave_set_default_fpucw ();
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1121
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1122 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1123 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1124
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1125 static string_vector
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1126 get_invoke_list (JNIEnv *jni_env, void *jobj_arg)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1127 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1128 jobject jobj = TO_JOBJECT (jobj_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1129
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1130 std::list<std::string> name_list;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1131
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1132 if (jni_env)
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1133 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1134 jclass_ref cls (jni_env, jni_env->GetObjectClass (jobj));
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1135 jclass_ref ccls (jni_env, jni_env->GetObjectClass (cls));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1136 jmethodID getMethods_ID = jni_env->GetMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1137 (ccls, "getMethods", "()[Ljava/lang/reflect/Method;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1138 jmethodID getFields_ID = jni_env->GetMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1139 (ccls, "getFields", "()[Ljava/lang/reflect/Field;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1140 jobjectArray_ref mList (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1141 reinterpret_cast<jobjectArray>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1142 (jni_env->CallObjectMethod (cls, getMethods_ID)));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1143 jobjectArray_ref fList (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1144 reinterpret_cast<jobjectArray>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1145 (jni_env->CallObjectMethod (cls, getFields_ID)));
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
1146 int mLen = jni_env->GetArrayLength (mList);
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
1147 int fLen = jni_env->GetArrayLength (fList);
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1148 jclass_ref mCls (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1149 jni_env->FindClass ("java/lang/reflect/Method"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1150 jclass_ref fCls (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1151 jni_env->FindClass ("java/lang/reflect/Field"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1152 jmethodID m_getName_ID = jni_env->GetMethodID (mCls, "getName",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1153 "()Ljava/lang/String;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1154 jmethodID f_getName_ID = jni_env->GetMethodID (fCls, "getName",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1155 "()Ljava/lang/String;");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1156
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1157 for (int i = 0; i < mLen; i++)
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1158 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1159 jobject_ref meth (jni_env, jni_env->GetObjectArrayElement (mList, i));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1160 jstring_ref methName (jni_env, reinterpret_cast<jstring>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1161 (jni_env->CallObjectMethod (meth,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1162 m_getName_ID)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1163 name_list.push_back (jstring_to_string (jni_env, methName));
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1164 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1165
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1166 for (int i = 0; i < fLen; i++)
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1167 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1168 jobject_ref field (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1169 jni_env->GetObjectArrayElement (fList, i));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1170 jstring_ref fieldName (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1171 reinterpret_cast<jstring>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1172 (jni_env->CallObjectMethod
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1173 (field, f_getName_ID)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1174 name_list.push_back (jstring_to_string (jni_env, fieldName));
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1175 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1176
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1177 octave_set_default_fpucw ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1178 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1179
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1180 string_vector v (name_list);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1181
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1182 return v.sort (true);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1183 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1184
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1185 static octave_value
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1186 convert_to_string (JNIEnv *jni_env, jobject java_object, bool force, char type)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1187 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1188 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1189
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1190 if (jni_env && java_object)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1191 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1192 jclass_ref cls (jni_env, jni_env->FindClass ("java/lang/String"));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1193
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1194 if (jni_env->IsInstanceOf (java_object, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1195 retval = octave_value (jstring_to_string (jni_env, java_object), type);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1196 else if (force)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1197 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1198 cls = jni_env->FindClass ("[Ljava/lang/String;");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1199
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1200 if (jni_env->IsInstanceOf (java_object, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1201 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1202 jobjectArray array = reinterpret_cast<jobjectArray> (java_object);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1203 int len = jni_env->GetArrayLength (array);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1204 Cell c (len, 1);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1205
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1206 for (int i = 0; i < len; i++)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1207 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1208 jstring_ref js (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1209 reinterpret_cast<jstring>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1210 (jni_env->GetObjectArrayElement (array, i)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1211
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1212 if (js)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1213 c(i) = octave_value (jstring_to_string (jni_env, js), type);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1214 else
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1215 c(i) = check_exception (jni_env);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1216 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1217
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1218 retval = octave_value (c);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1219 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1220 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1221 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1222 cls = jni_env->FindClass ("java/lang/Object");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1223 jmethodID mID = jni_env->GetMethodID (cls, "toString",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1224 "()Ljava/lang/String;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1225 jstring_ref js (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1226 reinterpret_cast<jstring>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1227 (jni_env->CallObjectMethod (java_object,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1228 mID)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1229
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1230 if (js)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1231 retval = octave_value (jstring_to_string (jni_env, js), type);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1232 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1233 retval = check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1234 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1235 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1236 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1237 error ("unable to convert Java object to string");
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1238
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1239 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1240 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1241
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1242 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1243 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1244
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23446
diff changeset
1245 #define TO_JAVA(obj) dynamic_cast<octave_java *> ((obj).internal_rep ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1246
22202
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1247 //! Return whether @c jobj shall be automatically converted to an Octave
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1248 //! numeric value.
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1249 //!
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1250 //! If @c jobj is an instance of any of the numeric wrapper classes @c Byte,
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1251 //! @c Integer, @c Long, @c Short, @c Float, or @c Double, then it will be
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1252 //! converted using the @c java.lang.Number.doubleValue() method.
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1253 //!
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1254 //! @param jobj Java object being returned to Octave
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1255 //! @return @c true if @c jobj shall be converted into a numeric value
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1256 //! automatically, @c false otherwise
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1257 static bool
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1258 is_auto_convertible_number (JNIEnv *jni_env, jobject jobj)
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1259 {
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1260 jclass_ref cls (jni_env);
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1261 cls = jni_env->FindClass ("java/lang/Double");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1262 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1263 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1264 cls = jni_env->FindClass ("java/lang/Float");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1265 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1266 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1267 cls = jni_env->FindClass ("java/lang/Byte");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1268 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1269 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1270 cls = jni_env->FindClass ("java/lang/Short");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1271 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1272 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1273 cls = jni_env->FindClass ("java/lang/Integer");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1274 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1275 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1276 cls = jni_env->FindClass ("java/lang/Long");
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1277 if (jni_env->IsInstanceOf (jobj, cls))
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1278 return true;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1279
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1280 return false;
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1281 }
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1282
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1283 //! Convert the Java object pointed to by @c jobj_arg with class @c jcls_arg
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1284 //! to an Octave value.
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1285 //!
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1286 //! @param jni_env JNI environment pointer.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1287 //! @param jobj_arg Pointer to a Java object.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1288 //! @param jcls_arg Optional pointer to the Java class of @c jobj_arg.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1289 //!
22202
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1290 //! @return
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1291 //! @arg numeric value as a @c double if @c jobj_arg is of type @c Byte,
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1292 //! @c Short, @c Integer, @c Long, @c Float or @c Double
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1293 //! @arg logical value if @c jobj_arg is of type @c Boolean
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1294 //! @arg string value if @c jobj_arg is of type @c Character or @c String
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1295 //! @arg Octave array of numeric, logical, or char type if @c jobj_arg is
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1296 //! a Java array of primitive types
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1297 //! @arg Octave matrix if @c jobj_arg is of type @c org.octave.Matrix and
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1298 //! #Vjava_matrix_autoconversion is enabled
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1299 //! @arg Octave object if @c jobj_arg is of type
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1300 //! @c org.octave.OctaveReference
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1301 //! @arg @c octave_java object wrapping the Java object otherwise.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1302
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1303 static octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1304 box (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1305 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1306 octave_value retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1307
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1308 jobject jobj = TO_JOBJECT (jobj_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1309 jclass jcls = TO_JCLASS (jcls_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1310
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1311 jclass_ref cls (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1312
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1313 if (! jobj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1314 retval = Matrix ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1315
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1316 while (retval.is_undefined ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1317 {
22202
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1318 // Convert a scalar of any numeric class wrapping a primitive class
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1319 // (byte, short, integer, long, float, double) to a double value.
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1320 // Test whether java.lang.Number before testing for each type.
15820
00172e5c2302 Add autoconversion of Java numeric types (byte, short, integer, long, float) to Octave double.
Rik <rik@octave.org>
parents: 15816
diff changeset
1321 cls = jni_env->FindClass ("java/lang/Number");
22202
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1322 if (jni_env->IsInstanceOf (jobj, cls)
f094186125d3 Only convert specific Java numeric objects to double for Matlab compatibility (bug #48013)
Ernst Reissner <rei3ner@arcor.de>
parents: 22146
diff changeset
1323 && is_auto_convertible_number (jni_env, jobj))
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1324 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1325 jmethodID m = jni_env->GetMethodID (cls, "doubleValue", "()D");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1326 retval = jni_env->CallDoubleMethod (jobj, m);
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1327 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1328 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1329
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1330 cls = jni_env->FindClass ("java/lang/Boolean");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1331 if (jni_env->IsInstanceOf (jobj, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1332 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1333 jmethodID m = jni_env->GetMethodID (cls, "booleanValue", "()Z");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1334 retval = (jni_env->CallBooleanMethod (jobj, m) ? true : false);
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1335 break;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1336 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1337
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1338 cls = jni_env->FindClass ("java/lang/String");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1339 if (jni_env->IsInstanceOf (jobj, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1340 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1341 retval = jstring_to_string (jni_env, jobj);
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1342 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1343 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1344
15815
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1345 cls = jni_env->FindClass ("java/lang/Character");
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1346 if (jni_env->IsInstanceOf (jobj, cls))
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1347 {
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1348 jmethodID m = jni_env->GetMethodID (cls, "charValue", "()C");
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1349 retval = jni_env->CallCharMethod (jobj, m);
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17898
diff changeset
1350 retval = retval.convert_to_str (false, true);
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1351 break;
15815
f28b3dcbaa9a Add autoconversion between java.lang.Character class and Octave string class.
Rik <rik@octave.org>
parents: 15813
diff changeset
1352 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1353
20120
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1354 #define BOX_PRIMITIVE_ARRAY(JAVA_TYPE, JAVA_ID, JAVA_TYPE_CAP, OCTAVE_ID) \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1355 cls = jni_env->FindClass (JAVA_ID); \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1356 if (jni_env->IsInstanceOf (jobj, cls)) \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1357 { \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1358 const JAVA_TYPE ## Array jarr = reinterpret_cast<JAVA_TYPE ## Array> (jobj); \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1359 const jsize len = jni_env->GetArrayLength (jarr); \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1360 OCTAVE_ID ## NDArray d (dim_vector (len, 1)); \
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1361 JAVA_TYPE *buffer = reinterpret_cast<JAVA_TYPE *> (d.fortran_vec ()); \
20120
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1362 jni_env->Get ## JAVA_TYPE_CAP ## ArrayRegion (jarr, 0, len, buffer); \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1363 retval = d; \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1364 break; \
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1365 }
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1366
20254
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1367 BOX_PRIMITIVE_ARRAY (jdouble, "[D", Double, )
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1368 BOX_PRIMITIVE_ARRAY (jboolean, "[Z", Boolean, bool)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1369 BOX_PRIMITIVE_ARRAY (jfloat, "[F", Float, Float)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1370 BOX_PRIMITIVE_ARRAY (jchar, "[C", Char, char)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1371 BOX_PRIMITIVE_ARRAY (jbyte, "[B", Byte, int8)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1372 BOX_PRIMITIVE_ARRAY (jshort, "[S", Short, int16)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1373 BOX_PRIMITIVE_ARRAY (jint, "[I", Int, int32)
a51fe1b60e3f Put most used conversions first in Java box/unbox routines.
Rik <rik@octave.org>
parents: 20253
diff changeset
1374 BOX_PRIMITIVE_ARRAY (jlong, "[J", Long, int64)
20120
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1375
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1376 #undef BOX_PRIMITIVE_ARRAY
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
1377
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1378 if (Vjava_matrix_autoconversion)
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1379 {
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1380 cls = find_octave_class (jni_env, "org/octave/Matrix");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1381
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1382 if (jni_env->IsInstanceOf (jobj, cls))
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1383 {
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1384 jmethodID mID = jni_env->GetMethodID (cls, "getDims", "()[I");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1385 jintArray_ref iv (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1386 reinterpret_cast<jintArray>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1387 (jni_env->CallObjectMethod (jobj, mID)));
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1388 jint *iv_data = jni_env->GetIntArrayElements (jintArray (iv),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1389 nullptr);
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1390 dim_vector dims;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1391 dims.resize (jni_env->GetArrayLength (jintArray (iv)));
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1392
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21580
diff changeset
1393 for (int i = 0; i < dims.ndims (); i++)
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1394 dims(i) = iv_data[i];
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1395
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1396 jni_env->ReleaseIntArrayElements (jintArray (iv), iv_data, 0);
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1397 mID = jni_env->GetMethodID (cls, "getClassName",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1398 "()Ljava/lang/String;");
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1399 jstring_ref js (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1400 reinterpret_cast<jstring>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1401 (jni_env->CallObjectMethod (jobj, mID)));
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1402
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1403 std::string s = jstring_to_string (jni_env, js);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1404
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1405 if (s == "double")
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1406 {
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1407 NDArray m (dims);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1408 mID = jni_env->GetMethodID (cls, "toDouble", "()[D");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1409 jdoubleArray_ref dv (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1410 reinterpret_cast<jdoubleArray>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1411 (jni_env->CallObjectMethod (jobj,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1412 mID)));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1413 jni_env->GetDoubleArrayRegion (dv, 0, m.numel (),
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1414 m.fortran_vec ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1415 retval = m;
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1416 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1417 }
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1418 else if (s == "byte")
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1419 {
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1420 if (Vjava_unsigned_autoconversion)
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1421 {
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1422 uint8NDArray m (dims);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1423 mID = jni_env->GetMethodID (cls, "toByte", "()[B");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1424 jbyteArray_ref dv (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1425 reinterpret_cast<jbyteArray>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1426 (jni_env->CallObjectMethod (jobj,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1427 mID)));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1428 jni_env->GetByteArrayRegion (dv, 0, m.numel (),
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1429 reinterpret_cast<jbyte *>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1430 (m.fortran_vec ()));
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1431 retval = m;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1432 break;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1433 }
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1434 else
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1435 {
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1436 int8NDArray m (dims);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1437 mID = jni_env->GetMethodID (cls, "toByte", "()[B");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1438 jbyteArray_ref dv (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1439 reinterpret_cast<jbyteArray>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1440 (jni_env->CallObjectMethod (jobj,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1441 mID)));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1442 jni_env->GetByteArrayRegion (dv, 0, m.numel (),
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1443 reinterpret_cast<jbyte *>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1444 (m.fortran_vec ()));
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1445 retval = m;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1446 break;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1447 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1448 }
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1449 else if (s == "integer")
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1450 {
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1451 if (Vjava_unsigned_autoconversion)
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1452 {
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1453 uint32NDArray m (dims);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1454 mID = jni_env->GetMethodID (cls, "toInt", "()[I");
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1455 jintArray_ref dv (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1456 reinterpret_cast<jintArray>
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1457 (jni_env->CallObjectMethod (jobj,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1458 mID)));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1459 jni_env->GetIntArrayRegion (dv, 0, m.numel (),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1460 reinterpret_cast<jint *>
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1461 (m.fortran_vec ()));
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1462 retval = m;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1463 break;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1464 }
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1465 else
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1466 {
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1467 int32NDArray m (dims);
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1468 mID = jni_env->GetMethodID (cls, "toInt", "()[I");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1469 jintArray_ref dv (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1470 reinterpret_cast<jintArray>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1471 (jni_env->CallObjectMethod (jobj,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1472 mID)));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1473 jni_env->GetIntArrayRegion (dv, 0, m.numel (),
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1474 reinterpret_cast<jint *>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1475 (m.fortran_vec ()));
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1476 retval = m;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1477 break;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1478 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1479 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1480 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1481 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1482
15744
686580b1a934 eliminate most compilation warnings for __java__.cc
John W. Eaton <jwe@octave.org>
parents: 15743
diff changeset
1483 cls = find_octave_class (jni_env, "org/octave/OctaveReference");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1484 if (jni_env->IsInstanceOf (jobj, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1485 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1486 jmethodID mID = jni_env->GetMethodID (cls, "getID", "()I");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1487 int ID = jni_env->CallIntMethod (jobj, mID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1488 std::map<int,octave_value>::iterator it = octave_ref_map.find (ID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1489
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1490 if (it != octave_ref_map.end ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1491 retval = it->second;
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1492 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1493 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1494
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1495 // No suitable class found. Return a generic octave_java object.
15821
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1496 retval = octave_value (new octave_java (jobj, jcls));
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1497 break;
72661fe4b9e5 Short-circuit out of Java box code as soon as valid class has been found.
Rik <rik@octave.org>
parents: 15820
diff changeset
1498 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1499
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1500 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1501 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1502
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1503 static octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1504 box_more (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1505 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1506 jobject jobj = TO_JOBJECT (jobj_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1507 jclass jcls = TO_JCLASS (jcls_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1508
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1509 octave_value retval = box (jni_env, jobj, jcls);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1510
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
1511 if (retval.isjava ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1512 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1513 retval = octave_value ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1514
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1515 jclass_ref cls (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1516
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1517 if (retval.is_undefined ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1518 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1519 cls = jni_env->FindClass ("[D");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1520
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1521 if (jni_env->IsInstanceOf (jobj, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1522 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1523 jdoubleArray jarr = reinterpret_cast<jdoubleArray> (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1524 int len = jni_env->GetArrayLength (jarr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1525
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1526 if (len > 0)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1527 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1528 Matrix m (1, len);
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1529 jni_env->GetDoubleArrayRegion (jarr, 0, len,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1530 m.fortran_vec ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1531 retval = m;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1532 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1533 else
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1534 retval = Matrix ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1535 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1536 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1537
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1538 if (retval.is_undefined ())
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1539 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1540 cls = jni_env->FindClass ("[[D");
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1541
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1542 if (jni_env->IsInstanceOf (jobj, cls))
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1543 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1544 jobjectArray jarr = reinterpret_cast<jobjectArray> (jobj);
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17898
diff changeset
1545 int rows = jni_env->GetArrayLength (jarr);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17898
diff changeset
1546 int cols = 0;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1547
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1548 if (rows > 0)
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1549 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1550 Matrix m;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1551
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1552 for (int r = 0; r < rows; r++)
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1553 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1554 jdoubleArray_ref row (jni_env,
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1555 reinterpret_cast<jdoubleArray>
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1556 (jni_env->GetObjectArrayElement
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
1557 (jarr, r)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1558
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
1559 if (m.isempty ())
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1560 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1561 cols = jni_env->GetArrayLength (row);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1562 m.resize (cols, rows);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1563 }
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1564 jni_env->GetDoubleArrayRegion
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1565 (row, 0, cols, m.fortran_vec () + r * cols);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1566 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1567 retval = m.transpose ();
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1568 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1569 else
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1570 retval = Matrix ();
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1571 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1572 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1573
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1574 if (retval.is_undefined ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1575 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1576 cls = jni_env->FindClass ("[Ljava/lang/String;");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1577
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1578 if (jni_env->IsInstanceOf (jobj, cls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1579 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1580 jobjectArray jarr = reinterpret_cast<jobjectArray> (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1581 int len = jni_env->GetArrayLength (jarr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1582 Cell m (len, 1);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1583
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1584 for (int i = 0; i < len; i++)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1585 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1586 jstring_ref js (jni_env,
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1587 reinterpret_cast<jstring>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1588 (jni_env->GetObjectArrayElement (jarr, i)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1589 m(i) = jstring_to_string (jni_env, js);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1590 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1591
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1592 retval = m;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1593 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1594 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1595 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1596
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1597 if (retval.is_undefined ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1598 retval = octave_value (new octave_java (jobj, jcls));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1599
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1600 octave_set_default_fpucw ();
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1601
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1602 return retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1603 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1604
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1605 static bool
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1606 unbox (JNIEnv *jni_env, const octave_value& val, jobject_ref& jobj,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1607 jclass_ref& jcls)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1608 {
20121
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1609 bool found = true;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1610
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
1611 if (val.isjava ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1612 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1613 octave_java *ovj = TO_JAVA (val);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1614 jobj = TO_JOBJECT (ovj->to_java ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1615 jobj.detach ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1616 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1617 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1618 else if (val.is_string ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1619 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1620 std::string s = val.string_value ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1621
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1622 jobj = jni_env->NewStringUTF (s.c_str ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1623 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1624 }
23575
e95738a119da maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents: 23573
diff changeset
1625 else if (val.iscellstr ())
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1626 {
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1627 const Array<std::string> str_arr = val.cellstr_value ();
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1628 const octave_idx_type n = str_arr.numel ();
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1629
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1630 jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String"));
23459
ddcbf10c8c39 maint: Use C++11 nullptr rather than 0 or NULL for remaining instances in code.
Rik <rik@octave.org>
parents: 23457
diff changeset
1631 jobjectArray array = jni_env->NewObjectArray (n, scls, nullptr);
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1632
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1633 for (octave_idx_type i = 0; i < n; i++)
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1634 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1635 jstring_ref jstr (jni_env, jni_env->NewStringUTF
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1636 (str_arr(i).c_str ()));
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1637 jni_env->SetObjectArrayElement (array, i, jstr);
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1638 }
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1639
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1640 jobj = array;
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1641 jcls = jni_env->GetObjectClass (jobj);
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
1642 }
23592
80e3bfb7bd5a maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents: 23585
diff changeset
1643 else if (val.numel () > 1 && val.dims ().isvector ())
20122
81fcf4aa9e03 Automatically convert octave vectors into java primitive arrays (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20121
diff changeset
1644 {
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1645 // FIXME: Is there any way to avoid code duplication here without
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1646 // using a macro?
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1647
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1648 #define UNBOX_PRIMITIVE_ARRAY(METHOD_T, OCTAVE_T, JAVA_T, JAVA_T_CAP) \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1649 do \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1650 { \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1651 const OCTAVE_T ## NDArray v = val.METHOD_T ## array_value (); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1652 JAVA_T ## Array jarr = jni_env->New ## JAVA_T_CAP ## Array (v.numel ()); \
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23446
diff changeset
1653 const JAVA_T *jv = reinterpret_cast<const JAVA_T *> (v.data ()); \
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1654 jni_env->Set ## JAVA_T_CAP ## ArrayRegion (jarr, 0, v.numel (), jv); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1655 jobj = reinterpret_cast<jobject> (jarr); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1656 jcls = jni_env->GetObjectClass (jobj); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1657 } \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1658 while (0)
20122
81fcf4aa9e03 Automatically convert octave vectors into java primitive arrays (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20121
diff changeset
1659
81fcf4aa9e03 Automatically convert octave vectors into java primitive arrays (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20121
diff changeset
1660 // Note that we do NOT handle char here because they are unboxed
81fcf4aa9e03 Automatically convert octave vectors into java primitive arrays (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20121
diff changeset
1661 // into a String[], not into a char array
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1662
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1663 if (val.is_double_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1664 UNBOX_PRIMITIVE_ARRAY ( , , jdouble, Double);
23579
c20a0fa91c0c maint: Deprecate is_bool_type and replace with islogical.
Rik <rik@octave.org>
parents: 23578
diff changeset
1665 else if (val.islogical ())
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1666 UNBOX_PRIMITIVE_ARRAY (bool_, bool, jboolean, Boolean);
23585
570170b6eb09 maint: Deprecate is_float_type and replace with isfloat.
Rik <rik@octave.org>
parents: 23582
diff changeset
1667 else if (val.isfloat ())
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1668 UNBOX_PRIMITIVE_ARRAY (float_, Float, jfloat, Float);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1669 else if (val.is_int8_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1670 UNBOX_PRIMITIVE_ARRAY (int8_, int8, jbyte, Byte);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1671 else if (val.is_uint8_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1672 UNBOX_PRIMITIVE_ARRAY (uint8_, uint8, jbyte, Byte);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1673 else if (val.is_int16_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1674 UNBOX_PRIMITIVE_ARRAY (int16_, int16, jshort, Short);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1675 else if (val.is_uint16_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1676 UNBOX_PRIMITIVE_ARRAY (uint16_, uint16, jshort, Short);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1677 else if (val.is_int32_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1678 UNBOX_PRIMITIVE_ARRAY (int32_, int32, jint, Int);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1679 else if (val.is_uint32_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1680 UNBOX_PRIMITIVE_ARRAY (uint32_, uint32, jint, Int);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1681 else if (val.is_int64_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1682 UNBOX_PRIMITIVE_ARRAY (int64_, int64, jlong, Long);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1683 else if (val.is_uint64_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1684 UNBOX_PRIMITIVE_ARRAY (uint64_, uint64, jlong, Long);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1685
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1686 #undef UNBOX_PRIMITIVE_ARRAY
20122
81fcf4aa9e03 Automatically convert octave vectors into java primitive arrays (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20121
diff changeset
1687 }
20123
8261c4a11250 Convert octave integer scalars into closest java type (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20122
diff changeset
1688 else if (val.is_real_scalar () || val.is_bool_scalar ())
15822
e7d9db9531d1 Add conversion for Octave integer and single classes to Java int and float classes.
Rik <rik@octave.org>
parents: 15821
diff changeset
1689 {
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1690 // FIXME: Is there any way to avoid code duplication here without
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1691 // using a macro?
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1692
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1693 #define UNBOX_PRIMITIVE_SCALAR(OCTAVE_T, METHOD_T, JAVA_T, JAVA_CON) \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1694 do \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1695 { \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1696 const OCTAVE_T ov = val.METHOD_T ## _value (); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1697 jclass_ref dcls (jni_env, jni_env->FindClass (JAVA_T)); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1698 const jfieldID fid = jni_env->GetStaticFieldID (dcls, "TYPE", "Ljava/lang/Class;"); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1699 const jmethodID mid = jni_env->GetMethodID (dcls, "<init>", JAVA_CON); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1700 jcls = reinterpret_cast<jclass> (jni_env->GetStaticObjectField (dcls, fid)); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1701 jobj = jni_env->NewObject (dcls, mid, ov); \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1702 } \
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1703 while (0)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1704
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1705 if (val.is_double_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1706 UNBOX_PRIMITIVE_SCALAR (double, double, "java/lang/Double", "(D)V");
23579
c20a0fa91c0c maint: Deprecate is_bool_type and replace with islogical.
Rik <rik@octave.org>
parents: 23578
diff changeset
1707 else if (val.islogical ())
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1708 UNBOX_PRIMITIVE_SCALAR (bool, bool, "java/lang/Boolean", "(Z)V");
23585
570170b6eb09 maint: Deprecate is_float_type and replace with isfloat.
Rik <rik@octave.org>
parents: 23582
diff changeset
1709 else if (val.isfloat ())
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1710 UNBOX_PRIMITIVE_SCALAR (float, float, "java/lang/Float", "(F)V");
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1711 else if (val.is_int8_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1712 UNBOX_PRIMITIVE_SCALAR (int8_t, int8_scalar, "java/lang/Byte", "(B)V");
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1713 else if (val.is_uint8_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1714 UNBOX_PRIMITIVE_SCALAR (uint8_t, uint8_scalar, "java/lang/Byte", "(B)V");
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1715 else if (val.is_int16_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1716 UNBOX_PRIMITIVE_SCALAR (int16_t, int16_scalar, "java/lang/Short", "(S)V");
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1717 else if (val.is_uint16_type ())
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1718 UNBOX_PRIMITIVE_SCALAR (uint16_t, uint16_scalar, "java/lang/Short", "(S)V");
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1719 else if (val.is_int32_type ())
21823
49d999dc443f maint: Periodic merge of stable to default.
Mike Miller <mtmiller@octave.org>
parents: 21781 21822
diff changeset
1720 UNBOX_PRIMITIVE_SCALAR (int32_t, int32_scalar, "java/lang/Integer", "(I)V");
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1721 else if (val.is_uint32_type ())
21823
49d999dc443f maint: Periodic merge of stable to default.
Mike Miller <mtmiller@octave.org>
parents: 21781 21822
diff changeset
1722 UNBOX_PRIMITIVE_SCALAR (uint32_t, uint32_scalar, "java/lang/Integer", "(I)V");
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1723 else if (val.is_int64_type ())
21823
49d999dc443f maint: Periodic merge of stable to default.
Mike Miller <mtmiller@octave.org>
parents: 21781 21822
diff changeset
1724 UNBOX_PRIMITIVE_SCALAR (int64_t, int64_scalar, "java/lang/Long", "(J)V");
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1725 else if (val.is_uint64_type ())
21823
49d999dc443f maint: Periodic merge of stable to default.
Mike Miller <mtmiller@octave.org>
parents: 21781 21822
diff changeset
1726 UNBOX_PRIMITIVE_SCALAR (uint64_t, uint64_scalar, "java/lang/Long", "(J)V");
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1727
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1728 #undef UNBOX_PRIMITIVE_SCALAR
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
1729 }
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23576
diff changeset
1730 else if (val.isempty ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1731 {
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1732 jobj = nullptr;
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1733 jcls = nullptr;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1734 //jcls = jni_env->FindClass ("java/lang/Object");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1735 }
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20946
diff changeset
1736 else if (! Vjava_matrix_autoconversion
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1737 && ((val.is_real_matrix ()
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1738 && (val.rows () == 1 || val.columns () == 1))
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1739 || val.is_range ()))
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1740 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1741 Matrix m = val.matrix_value ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1742 jdoubleArray dv = jni_env->NewDoubleArray (m.numel ());
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1743 jni_env->SetDoubleArrayRegion (dv, 0, m.numel (), m.fortran_vec ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1744 jobj = dv;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1745 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1746 }
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
1747 else if (Vjava_matrix_autoconversion
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1748 && (val.is_matrix_type () || val.is_range ())
23582
0cc2011d800e maint: Deprecate is_real_type and replace with isreal.
Rik <rik@octave.org>
parents: 23579
diff changeset
1749 && val.isreal ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1750 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1751 jclass_ref mcls (jni_env, find_octave_class (jni_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1752 "org/octave/Matrix"));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1753 dim_vector dims = val.dims ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21580
diff changeset
1754 jintArray_ref iv (jni_env, jni_env->NewIntArray (dims.ndims ()));
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1755 jint *iv_data = jni_env->GetIntArrayElements (jintArray (iv), nullptr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1756
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21580
diff changeset
1757 for (int i = 0; i < dims.ndims (); i++)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1758 iv_data[i] = dims(i);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1759
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1760 jni_env->ReleaseIntArrayElements (jintArray (iv), iv_data, 0);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1761
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1762 if (val.is_double_type ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1763 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1764 NDArray m = val.array_value ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1765 jdoubleArray_ref dv (jni_env, jni_env->NewDoubleArray (m.numel ()));
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1766 jni_env->SetDoubleArrayRegion (jdoubleArray (dv), 0, m.numel (),
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1767 m.fortran_vec ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1768 jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([D[I)V");
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1769 jobj = jni_env->NewObject (jclass (mcls), mID, jdoubleArray (dv),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1770 jintArray (iv));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1771 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1772 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1773 else if (val.is_int8_type ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1774 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1775 int8NDArray m = val.int8_array_value ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1776 jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ()));
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1777 jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (),
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1778 reinterpret_cast<jbyte *>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1779 (m.fortran_vec ()));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1780 jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([B[I)V");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1781 jobj = jni_env->NewObject
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1782 (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1783 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1784 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1785 else if (val.is_uint8_type ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1786 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1787 uint8NDArray m = val.uint8_array_value ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1788 jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ()));
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1789 jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (),
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1790 reinterpret_cast<jbyte *>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1791 (m.fortran_vec ()));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1792 jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([B[I)V");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1793 jobj = jni_env->NewObject
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1794 (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1795 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1796 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1797 else if (val.is_int32_type ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1798 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1799 int32NDArray m = val.int32_array_value ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1800 jintArray_ref v (jni_env, jni_env->NewIntArray (m.numel ()));
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20163
diff changeset
1801 jni_env->SetIntArrayRegion (jintArray (v), 0, m.numel (),
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1802 reinterpret_cast<jint *>
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1803 (m.fortran_vec ()));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1804 jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([I[I)V");
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1805 jobj = jni_env->NewObject
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1806 (jclass (mcls), mID, jintArray (v), jintArray (iv));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1807 jcls = jni_env->GetObjectClass (jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1808 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1809 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1810 {
20121
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1811 found = false;
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1812 error ("cannot convert matrix of type '%s'",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1813 val.class_name ().c_str ());
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1814 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1815 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1816 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1817 {
15744
686580b1a934 eliminate most compilation warnings for __java__.cc
John W. Eaton <jwe@octave.org>
parents: 15743
diff changeset
1818 jclass rcls = find_octave_class (jni_env, "org/octave/OctaveReference");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1819 jmethodID mID = jni_env->GetMethodID (rcls, "<init>", "(I)V");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1820 int ID = octave_java_refcount++;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1821
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1822 jobj = jni_env->NewObject (rcls, mID, ID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1823 jcls = rcls;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1824 octave_ref_map[ID] = val;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1825 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1826
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1827 return found;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1828 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1829
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1830 static bool
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
1831 unbox (JNIEnv *jni_env, const octave_value_list& args,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1832 jobjectArray_ref& jobjs, jobjectArray_ref& jclss)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1833 {
20121
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1834 bool found = true;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1835
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1836 jclass_ref ocls (jni_env, jni_env->FindClass ("java/lang/Object"));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1837 jclass_ref ccls (jni_env, jni_env->FindClass ("java/lang/Class"));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1838
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1839 if (! jobjs)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1840 jobjs = jni_env->NewObjectArray (args.length (), ocls, nullptr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1841
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1842 if (! jclss)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1843 jclss = jni_env->NewObjectArray (args.length (), ccls, nullptr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1844
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1845 for (int i = 0; i < args.length (); i++)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1846 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1847 jobject_ref jobj (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1848 jclass_ref jcls (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1849
20121
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1850 found = unbox (jni_env, args(i), jobj, jcls);
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1851 if (! found)
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1852 break;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1853
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1854 jni_env->SetObjectArrayElement (jobjs, i, jobj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1855 jni_env->SetObjectArrayElement (jclss, i, jcls);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1856 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1857
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1858 return found;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1859 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1860
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1861 //! Returns the id of the current thread.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1862 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1863 //! @param jni_env The current environment or @c nullptr.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1864 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1865 //! @returns The id of the current thread or -1 otherwise. The latter happens
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1866 //! if @c jni_env is @c nullptr, for example.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1867
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1868 static long
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1869 get_current_thread_ID (JNIEnv *jni_env)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1870 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1871 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1872 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1873 // Call Java method static Thread java.lang.Thread.currentThread().
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1874 jclass_ref cls (jni_env, jni_env->FindClass ("java/lang/Thread"));
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1875 jmethodID mID = jni_env->GetStaticMethodID (cls, "currentThread",
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1876 "()Ljava/lang/Thread;");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1877 jobject_ref jthread (jni_env, jni_env->CallStaticObjectMethod (cls, mID));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1878
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1879 if (jthread)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1880 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1881 // Call Java method long java.lang.Thread.getId().
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1882 jclass_ref jth_cls (jni_env, jni_env->GetObjectClass (jthread));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1883 mID = jni_env->GetMethodID (jth_cls, "getId", "()J");
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1884 long result = jni_env->CallLongMethod (jthread, mID);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1885 return result;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1886 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1887 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1888
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1889 return -1;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1890 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1891
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1892 //! Run the java method @c org.octave.Octave.checkPendingAction().
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1893 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1894 //! @returns 0 in any case for good reason.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1895
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1896 static int
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1897 java_event_hook (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1898 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1899 JNIEnv *current_env = thread_jni_env ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1900
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1901 if (current_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1902 {
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1903 // Invoke static void org.octave.Octave.checkPendingAction().
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1904 jclass_ref cls (current_env, find_octave_class (current_env,
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1905 "org/octave/Octave"));
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1906 jmethodID mID = current_env->GetStaticMethodID
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
1907 (cls, "checkPendingAction", "()V");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1908 current_env->CallStaticVoidMethod (cls, mID);
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1909
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1910 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1911 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1912
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1913 return 0;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1914 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1915
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1916 //! Initialize java including the virtual machine (jvm) if necessary.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1917 //!
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1918 //! Initializes the fields #jvm, #jvm_attached, #jvm_lib, and
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1919 //! #octave_thread_ID. To ensure that java is initialized, this method is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1920 //! used as part of octave functions @c javaObject, @c javaMethod,
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1921 //! @c __java_get__, @c __java_set__, and @c java2mat.
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
1922
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1923 static void
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1924 initialize_java (void)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1925 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1926 if (! jvm)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1927 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1928 try
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1929 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1930 initialize_jvm ();
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1931
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1932 JNIEnv *current_env = thread_jni_env ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1933
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21745
diff changeset
1934 octave::command_editor::add_event_hook (java_event_hook);
15754
bf77f7f66bdf register octave_java type at Octave startup
John W. Eaton <jwe@octave.org>
parents: 15752
diff changeset
1935
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1936 octave_thread_ID = get_current_thread_ID (current_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1937 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1938 catch (std::string msg)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1939 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1940 error (msg.c_str ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1941 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
1942
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
1943 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1944 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1945 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1946
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1947 JNIEXPORT jboolean JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1948 Java_org_octave_Octave_call (JNIEnv *env, jclass, jstring funcName,
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1949 jobjectArray argin, jobjectArray argout)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1950 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1951 std::string fname = jstring_to_string (env, funcName);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1952
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1953 int nargout = env->GetArrayLength (argout);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1954 int nargin = env->GetArrayLength (argin);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1955
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1956 octave_value_list varargin, varargout;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1957
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1958 for (int i = 0; i < nargin; i++)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1959 varargin(i) = box (env, env->GetObjectArrayElement (argin, i), nullptr);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1960
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22871
diff changeset
1961 varargout = octave::feval (fname, varargin, nargout);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1962
20121
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1963 jobjectArray_ref out_objs (env, argout), out_clss (env);
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1964 out_objs.detach ();
41064c150724 Return bools instead of ints in oc-java box and unbox internal functions.
Carnë Draug <carandraug@octave.org>
parents: 20120
diff changeset
1965 return unbox (env, varargout, out_objs, out_clss);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1966 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1967
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1968 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1969 Java_org_octave_OctaveReference_doFinalize (JNIEnv *, jclass, jint ID)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1970 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1971 octave_ref_map.erase (ID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1972 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1973
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1974 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1975 Java_org_octave_Octave_doInvoke (JNIEnv *env, jclass, jint ID,
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1976 jobjectArray args)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1977 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1978 std::map<int,octave_value>::iterator it = octave_ref_map.find (ID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1979
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1980 if (it != octave_ref_map.end ())
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1981 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1982 octave_value val = it->second;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1983 int len = env->GetArrayLength (args);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1984 octave_value_list oct_args;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1985
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
1986 for (int i = 0; i < len; i++)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1987 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1988 jobject_ref jobj (env, env->GetObjectArrayElement (args, i));
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
1989 oct_args(i) = box (env, jobj, nullptr);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1990 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1991
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1992 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1993
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1994 if (val.is_function_handle ())
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1995 {
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1996 octave_function *fcn = val.function_value ();
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22871
diff changeset
1997 octave::feval (fcn, oct_args);
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
1998 }
23576
00e518162fda maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents: 23575
diff changeset
1999 else if (val.iscell () && val.length () > 0
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2000 && (val.rows () == 1 || val.columns () == 1)
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2001 && val.cell_value()(0).is_function_handle ())
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2002 {
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2003 Cell c = val.cell_value ();
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2004 octave_function *fcn = c(0).function_value ();
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2005
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2006 for (int i=1; i<c.numel (); i++)
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2007 oct_args(len+i-1) = c(i);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2008
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22871
diff changeset
2009 octave::feval (fcn, oct_args);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2010 }
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2011 else
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2012 error ("trying to invoke non-invocable object");
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2013
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2014 END_INTERRUPT_WITH_EXCEPTIONS;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2015 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2016 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2017
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2018 JNIEXPORT void JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2019 Java_org_octave_Octave_doEvalString (JNIEnv *env, jclass, jstring cmd)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2020 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2021 std::string s = jstring_to_string (env, cmd);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2022 int pstatus;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22871
diff changeset
2023 octave::eval_string (s, false, pstatus, 0);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2024 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2025
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2026 JNIEXPORT jboolean JNICALL
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2027 Java_org_octave_Octave_needThreadedInvokation (JNIEnv *env, jclass)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2028 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2029 return (get_current_thread_ID (env) != octave_thread_ID);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2030 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2031
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2032 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2033
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2034 //! Ctor.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2035
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2036 octave_java::octave_java (void)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
2037 : octave_base_value (), java_object (nullptr), java_class (nullptr)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2038 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2039 #if ! defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2040
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2041 err_disabled_feature ("Java Objects", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2042
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2043 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2044 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2045
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2046 octave_java::octave_java (const voidptr& jobj, void *jcls)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
2047 : octave_base_value (), java_object (nullptr), java_class (nullptr)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2048 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2049 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2050
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2051 init (jobj, jcls);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2052
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2053 #else
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2054
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2055 octave_unused_parameter (jobj);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2056 octave_unused_parameter (jcls);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2057
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2058 err_disabled_feature ("Java Objects", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2059
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2060 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2061 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2062
15813
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2063 int octave_java::t_id (-1);
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2064
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2065 const std::string octave_java::t_name ("octave_java");
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2066
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2067 void
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2068 octave_java::register_type (void)
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2069 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2070 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2071
15813
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2072 t_id = octave_value_typeinfo::register_type
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2073 (octave_java::t_name, "<unknown>", octave_value (new octave_java ()));
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2074
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2075 #endif
15813
10d6ab9b1b4f Implement octave_value function class_name() for class "octave_java"
Rik <rik@octave.org>
parents: 15806
diff changeset
2076 }
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2077
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2078 dim_vector
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2079 octave_java::dims (void) const
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2080 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2081 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2082
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2083 JNIEnv *current_env = thread_jni_env ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2084
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2085 if (current_env && java_object)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2086 return compute_array_dimensions (current_env, TO_JOBJECT (java_object));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2087 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2088 return dim_vector (1, 1);
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2089
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2090 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2091
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2092 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2093 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2094
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2095 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2096
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2097 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2098 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2099
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2100 octave_value_list
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2101 octave_java::subsref (const std::string& type,
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2102 const std::list<octave_value_list>& idx, int nargout)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2103 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2104 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2105
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2106 octave_value_list retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2107 int skip = 1;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2108
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2109 JNIEnv *current_env = thread_jni_env ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2110
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2111 switch (type[0])
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2112 {
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2113 case '.':
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2114 if (type.length () > 1 && type[1] == '(')
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2115 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2116 octave_value_list ovl;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2117 count++;
15790
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15771
diff changeset
2118 ovl(1) = octave_value (this);
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15771
diff changeset
2119 ovl(0) = (idx.front ())(0);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2120 std::list<octave_value_list>::const_iterator it = idx.begin ();
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2121 ovl.append (*++it);
23129
35e3d199527c Replace feval calls with direct call to C++ function (bug #50116).
Rik <rik@octave.org>
parents: 23084
diff changeset
2122 retval = FjavaMethod (ovl, 1);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2123 skip++;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2124 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2125 else
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2126 {
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2127 octave_value_list ovl;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2128 count++;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2129 ovl(0) = octave_value (this);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2130 ovl(1) = (idx.front ())(0);
23129
35e3d199527c Replace feval calls with direct call to C++ function (bug #50116).
Rik <rik@octave.org>
parents: 23084
diff changeset
2131 retval = F__java_get__ (ovl, 1);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2132 }
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2133 break;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2134
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2135 case '(':
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2136 if (current_env)
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
2137 retval = get_array_elements
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
2138 (current_env, TO_JOBJECT (to_java ()), idx.front ());
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2139 break;
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2140
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2141 default:
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2142 error ("subsref: Java object cannot be indexed with %c", type[0]);
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2143 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2144 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2145
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2146 if (idx.size () > 1 && type.length () > 1)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2147 retval = retval(0).next_subsref (nargout, type, idx, skip);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2148
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2149 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2150
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2151 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2152
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2153 octave_unused_parameter (type);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2154 octave_unused_parameter (idx);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2155 octave_unused_parameter (nargout);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2156
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2157 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2158 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2159
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2160 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2161
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2162 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2163 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2164
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2165 octave_value
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2166 octave_java::subsasgn (const std::string& type,
21661
1b9a36a66b01 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21660
diff changeset
2167 const std::list<octave_value_list>& idx,
1b9a36a66b01 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21660
diff changeset
2168 const octave_value& rhs)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2169 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2170 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2171
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2172 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2173
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2174 JNIEnv *current_env = thread_jni_env ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2175
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2176 switch (type[0])
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2177 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2178 case '.':
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2179 if (type.length () == 1)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2180 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2181 // field assignment
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2182 octave_value_list ovl;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2183 count++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2184 ovl(0) = octave_value (this);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2185 ovl(1) = (idx.front ())(0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2186 ovl(2) = rhs;
23129
35e3d199527c Replace feval calls with direct call to C++ function (bug #50116).
Rik <rik@octave.org>
parents: 23084
diff changeset
2187 F__java_set__ (ovl);
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2188
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2189 count++;
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2190 retval = octave_value (this);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2191 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2192 else if (type.length () > 2 && type[1] == '(')
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2193 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2194 std::list<octave_value_list> new_idx;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2195 std::list<octave_value_list>::const_iterator it = idx.begin ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2196 new_idx.push_back (*it++);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2197 new_idx.push_back (*it++);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2198 octave_value_list u = subsref (type.substr (0, 2), new_idx, 1);
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2199
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2200 std::list<octave_value_list> next_idx (idx);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2201 next_idx.erase (next_idx.begin ());
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2202 next_idx.erase (next_idx.begin ());
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2203 u(0).subsasgn (type.substr (2), next_idx, rhs);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2204
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2205 count++;
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2206 retval = octave_value (this);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2207 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2208 else if (type[1] == '.')
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2209 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2210 octave_value_list u = subsref (type.substr (0, 1), idx, 1);
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2211
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2212 std::list<octave_value_list> next_idx (idx);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2213 next_idx.erase (next_idx.begin ());
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2214 u(0).subsasgn (type.substr (1), next_idx, rhs);
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2215
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2216 count++;
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2217 retval = octave_value (this);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2218 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2219 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2220 error ("invalid indexing/assignment on Java object");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2221 break;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2222
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2223 case '(':
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2224 if (current_env)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2225 {
22303
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
2226 set_array_elements (current_env, TO_JOBJECT (to_java ()),
0448bf26fe98 style fixes (patch #9059)
Ernst Reissner <rei3ner@arcor.de>
parents: 22203
diff changeset
2227 idx.front (), rhs);
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2228
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2229 count++;
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2230 retval = octave_value (this);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2231 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2232 break;
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2233
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2234 default:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2235 error ("Java object cannot be indexed with %c", type[0]);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2236 break;
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2237 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2238
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2239 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2240
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2241 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2242
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2243 octave_unused_parameter (type);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2244 octave_unused_parameter (idx);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2245 octave_unused_parameter (rhs);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2246
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2247 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2248 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2249
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2250 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2251
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2252 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2253 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2254
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2255 string_vector
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2256 octave_java::map_keys (void) const
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2257 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2258 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2259
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2260 JNIEnv *current_env = thread_jni_env ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2261
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2262 if (current_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2263 return get_invoke_list (current_env, to_java ());
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2264 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2265 return string_vector ();
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2266
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2267 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2268
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2269 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2270 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2271
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2272 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2273
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2274 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2275 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2276
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2277 octave_value
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2278 octave_java::convert_to_str_internal (bool, bool force, char type) const
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2279 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2280 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2281
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2282 JNIEnv *current_env = thread_jni_env ();
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2283
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2284 if (current_env)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2285 return convert_to_string (current_env, TO_JOBJECT (to_java ()), force, type);
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2286 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2287 return octave_value ("");
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2288
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2289 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2290
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2291 octave_unused_parameter (force);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2292 octave_unused_parameter (type);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2293
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2294 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2295 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2296
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2297 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2298
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2299 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2300 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2301
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2302 void
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18100
diff changeset
2303 octave_java::print (std::ostream& os, bool)
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2304 {
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2305 print_raw (os);
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2306 newline (os);
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2307 }
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2308
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2309 void
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2310 octave_java::print_raw (std::ostream& os, bool) const
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2311 {
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23804
diff changeset
2312 os << "<Java object: " << java_classname << '>';
15859
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2313 }
0e393e744e5e ov-java.cc: Replace instances of comma operator for code clarity.
Rik <rik@octave.org>
parents: 15858
diff changeset
2314
20441
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2315 // FIXME: Need routines to actually save/load java objects through Serialize.
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20468
diff changeset
2316 // See bug #42112.
20441
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2317
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2318 bool
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2319 octave_java::save_ascii (std::ostream& /* os */)
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2320 {
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20468
diff changeset
2321 warning ("save: unable to save java objects, skipping");
20441
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2322
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2323 return true;
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2324 }
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2325
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2326 bool
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2327 octave_java::load_ascii (std::istream& /* is */)
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2328 {
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2329 // Silently skip over java object that was not saved
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2330 return true;
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2331 }
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2332
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2333 bool
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2334 octave_java::save_binary (std::ostream& /* os */, bool& /* save_as_floats */)
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2335 {
20531
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20468
diff changeset
2336 warning ("save: unable to save java objects, skipping");
20441
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2337
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2338 return true;
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2339 }
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2340
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2341 bool
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2342 octave_java::load_binary (std::istream& /* is */, bool /* swap*/,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
2343 octave::mach_info::float_format /* fmt */)
20441
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2344 {
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2345 // Silently skip over java object that was not saved
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2346 return true;
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2347 }
b22528fd3deb Add placeholder functions for save_ascii, save_binary for octave_java (bug #45694).
Rik <rik@octave.org>
parents: 20422
diff changeset
2348
20468
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2349 bool
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2350 octave_java::save_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */,
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2351 bool /* save_as_floats */)
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2352 {
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2353 warning ("save: unable to save java objects, skipping");
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2354
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2355 return true;
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2356 }
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2357
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2358 bool
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2359 octave_java::load_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */)
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2360 {
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2361 // Silently skip object that was not saved
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2362 return true;
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2363 }
2f94652de9ff Add placeholder functions for save_hdf5, load_hdf5 for octave_java functions.
Rik <rik@octave.org>
parents: 20441
diff changeset
2364
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2365 octave_value
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2366 octave_java::do_javaMethod (void *jni_env_arg, const std::string& name,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2367 const octave_value_list& args)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2368 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2369 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2370
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2371 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2372
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2373 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2374
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2375 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2376 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2377 jobjectArray_ref arg_objs (jni_env), arg_types (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2378 if (unbox (jni_env, args, arg_objs, arg_types))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2379 {
15744
686580b1a934 eliminate most compilation warnings for __java__.cc
John W. Eaton <jwe@octave.org>
parents: 15743
diff changeset
2380 jclass_ref helperClass (jni_env, find_octave_class (jni_env, "org/octave/ClassHelper"));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2381 jmethodID mID = jni_env->GetStaticMethodID (helperClass, "invokeMethod",
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2382 "(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2383 jstring_ref methName (jni_env, jni_env->NewStringUTF (name.c_str ()));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2384 jobjectArray_ref resObj (jni_env, reinterpret_cast<jobjectArray> (jni_env->CallStaticObjectMethod (helperClass, mID,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2385 to_java (), jstring (methName), jobjectArray (arg_objs), jobjectArray (arg_types))));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2386 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2387 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2388 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2389 retval = check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2390 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2391
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2392 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2393 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2394
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2395 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2396
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2397 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2398
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2399 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2400 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2401 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2402
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2403 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2404 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2405
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2406 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2407
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2408 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2409 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2410
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2411 octave_value
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2412 octave_java::do_javaMethod (const std::string& name,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2413 const octave_value_list& args)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2414 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2415 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2416
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2417 return do_javaMethod (thread_jni_env (), name, args);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2418
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2419 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2420
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2421 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2422 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2423
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2424 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2425 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2426
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2427 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2428
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2429 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2430 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2431
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2432 octave_value
24199
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 24141
diff changeset
2433 octave_java::do_javaMethod (void *jni_env_arg,
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 24141
diff changeset
2434 const std::string& class_name,
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 24141
diff changeset
2435 const std::string& name,
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 24141
diff changeset
2436 const octave_value_list& args)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2437 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2438 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2439
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2440 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2441
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2442 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2443
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2444 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2445 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2446 jobjectArray_ref arg_objs (jni_env), arg_types (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2447 if (unbox (jni_env, args, arg_objs, arg_types))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2448 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2449 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2450 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2451 "org/octave/ClassHelper"));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2452 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2453 "invokeStaticMethod",
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2454 "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;");
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2455 jstring_ref methName (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2456 jni_env->NewStringUTF (name.c_str ()));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2457 jstring_ref clsName (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2458 jni_env->NewStringUTF (class_name.c_str ()));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2459 jobject_ref resObj (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2460 jni_env->CallStaticObjectMethod (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2461 mID,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2462 jstring (clsName),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2463 jstring (methName),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2464 jobjectArray (arg_objs),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2465 jobjectArray (arg_types)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2466 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2467 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2468 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2469 retval = check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2470 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2471
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2472 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2473 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2474
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2475 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2476
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2477 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2478
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2479 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2480 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2481 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2482 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2483
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2484 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2485 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2486
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2487 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2488
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2489 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2490 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2491
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2492 octave_value
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2493 octave_java::do_javaMethod (const std::string& class_name,
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2494 const std::string& name,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2495 const octave_value_list& args)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2496 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2497 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2498
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2499 return do_javaMethod (thread_jni_env (), class_name, name, args);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2500
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2501 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2502
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2503 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2504 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2505 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2506
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2507 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2508 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2509
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2510 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2511
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2512 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2513 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2514
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2515 octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2516 octave_java::do_javaObject (void *jni_env_arg, const std::string& name,
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2517 const octave_value_list& args)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2518 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2519 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2520
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2521 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2522
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2523 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2524
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2525 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2526 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2527 jobjectArray_ref arg_objs (jni_env), arg_types (jni_env);
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2528
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2529 if (unbox (jni_env, args, arg_objs, arg_types))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2530 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2531 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2532 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2533 "org/octave/ClassHelper"));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2534 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2535 "invokeConstructor",
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2536 "(Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;");
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2537 jstring_ref clsName (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2538 jni_env->NewStringUTF (name.c_str ()));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2539 jobject_ref resObj (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2540 jni_env->CallStaticObjectMethod (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2541 mID,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2542 jstring (clsName),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2543 jobjectArray (arg_objs),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2544 jobjectArray (arg_types)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2545
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2546 if (resObj)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
2547 retval = octave_value (new octave_java (resObj, nullptr));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2548 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2549 check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2550 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2551
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2552 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2553 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2554
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2555 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2556
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2557 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2558
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2559 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2560 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2561 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2562
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2563 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2564 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2565
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2566 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2567
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2568 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2569 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2570
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2571 octave_value
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2572 octave_java::do_javaObject (const std::string& name,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2573 const octave_value_list& args)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2574 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2575 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2576
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2577 return do_javaObject (thread_jni_env (), name, args);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2578
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2579 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2580
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2581 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2582 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2583
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2584 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2585 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2586
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2587 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2588
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2589 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2590 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2591
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2592 octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2593 octave_java::do_java_get (void *jni_env_arg, const std::string& name)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2594 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2595 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2596
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2597 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2598
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2599 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2600
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2601 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2602 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2603 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2604 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2605 "org/octave/ClassHelper"));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2606 jmethodID mID = jni_env->GetStaticMethodID (helperClass, "getField",
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2607 "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;");
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2608 jstring_ref fName (jni_env, jni_env->NewStringUTF (name.c_str ()));
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2609 jobject_ref resObj (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2610 jni_env->CallStaticObjectMethod (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2611 mID,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2612 to_java (),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2613 jstring (fName)));
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2614
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2615 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2616 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2617 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2618 retval = check_exception (jni_env);
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2619
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2620 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2621 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2622
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2623 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2624
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2625 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2626
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2627 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2628 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2629
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2630 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2631 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2632
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2633 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2634
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2635 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2636 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2637
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2638 octave_value
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2639 octave_java::do_java_get (const std::string& name)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2640 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2641 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2642
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2643 return do_java_get (thread_jni_env (), name);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2644
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2645 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2646
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2647 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2648
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2649 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2650 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2651
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2652 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2653
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2654 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2655 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2656
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2657 octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2658 octave_java::do_java_get (void *jni_env_arg, const std::string& class_name,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2659 const std::string& name)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2660 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2661 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2662
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2663 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2664
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2665 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2666
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2667 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2668 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2669 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2670 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2671 "org/octave/ClassHelper"));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2672 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2673 "getStaticField",
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2674 "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2675 jstring_ref cName (jni_env, jni_env->NewStringUTF (class_name.c_str ()));
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2676 jstring_ref fName (jni_env, jni_env->NewStringUTF (name.c_str ()));
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2677 jobject_ref resObj (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2678 jni_env->CallStaticObjectMethod (helperClass, mID,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2679 jstring (cName),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2680 jstring (fName)));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2681 if (resObj)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2682 retval = box (jni_env, resObj);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2683 else
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2684 retval = check_exception (jni_env);
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2685
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2686 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2687 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2688
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2689 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2690
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2691 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2692
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2693 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2694 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2695 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2696
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2697 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2698 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2699
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2700 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2701
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2702 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2703 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2704
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2705 octave_value
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2706 octave_java::do_java_get (const std::string& class_name,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2707 const std::string& name)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2708 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2709 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2710
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2711 return do_java_get (thread_jni_env (), class_name, name);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2712
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2713 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2714
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2715 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2716 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2717
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2718 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2719 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2720
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2721 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2722
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2723 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2724 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2725
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2726 octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2727 octave_java::do_java_set (void *jni_env_arg, const std::string& name,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2728 const octave_value& val)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2729 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2730 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2731
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2732 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2733
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2734 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2735
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2736 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2737 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2738 jobject_ref jobj (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2739 jclass_ref jcls (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2740
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2741 if (unbox (jni_env, val, jobj, jcls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2742 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2743 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2744 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2745 "org/octave/ClassHelper"));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2746 jmethodID mID = jni_env->GetStaticMethodID (helperClass, "setField",
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2747 "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V");
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2748 jstring_ref fName (jni_env, jni_env->NewStringUTF (name.c_str ()));
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2749 jni_env->CallStaticObjectMethod (helperClass, mID, to_java (),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2750 jstring (fName), jobject (jobj));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2751 check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2752 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2753
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2754 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2755 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2756
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2757 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2758
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2759 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2760
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2761 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2762 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2763 octave_unused_parameter (val);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2764
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2765 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2766 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2767
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2768 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2769
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2770 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2771 }
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2772
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2773 octave_value
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2774 octave_java::do_java_set (const std::string& name, const octave_value& val)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2775 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2776 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2777
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2778 return do_java_set (thread_jni_env (), name, val);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2779
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2780 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2781
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2782 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2783 octave_unused_parameter (val);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2784
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2785 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2786 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2787
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2788 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2789
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2790 #endif
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2791 }
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2792
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2793 octave_value
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2794 octave_java::do_java_set (void *jni_env_arg, const std::string& class_name,
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2795 const std::string& name, const octave_value& val)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2796 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2797 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2798
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2799 octave_value retval;
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2800
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2801 JNIEnv *jni_env = TO_JNIENV (jni_env_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2802
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2803 if (jni_env)
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2804 {
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2805 jobject_ref jobj (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2806 jclass_ref jcls (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2807
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2808 if (unbox (jni_env, val, jobj, jcls))
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2809 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2810 jclass_ref helperClass (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2811 find_octave_class (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2812 "org/octave/ClassHelper"));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2813 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2814 "setStaticField",
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2815 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V");
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2816 jstring_ref cName (jni_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2817 jni_env->NewStringUTF (class_name.c_str ()));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2818 jstring_ref fName (jni_env, jni_env->NewStringUTF (name.c_str ()));
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2819 jni_env->CallStaticObjectMethod (helperClass, mID, jstring (cName),
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2820 jstring (fName), jobject (jobj));
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2821 check_exception (jni_env);
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2822 }
16078
9439f3b5c5fa Restore default floating point state after calling Java
Mike Miller <mtmiller@ieee.org>
parents: 15879
diff changeset
2823
21894
67a5cb9cd941 hide gnulib fpucw header
John W. Eaton <jwe@octave.org>
parents: 21823
diff changeset
2824 octave_set_default_fpucw ();
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2825 }
15745
19850dfc2f88 * __java__.h, __java__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 15744
diff changeset
2826
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2827 return retval;
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2828
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2829 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2830
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2831 octave_unused_parameter (jni_env_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2832 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2833 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2834 octave_unused_parameter (val);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2835
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2836 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2837 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2838
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2839 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2840
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2841 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2842 }
15736
6faa01ff2967 build: Add --disable-java option to configure (bug #37838).
Rik <rik@octave.org>
parents: 15625
diff changeset
2843
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2844 octave_value
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2845 octave_java::do_java_set (const std::string& class_name,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22331
diff changeset
2846 const std::string& name,
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2847 const octave_value& val)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2848 {
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2849 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2850
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2851 return do_java_set (thread_jni_env (), class_name, name, val);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2852
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2853 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2854
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2855 octave_unused_parameter (class_name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2856 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2857 octave_unused_parameter (val);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2858
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2859 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2860 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2861
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2862 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2863
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2864 #endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2865 }
15736
6faa01ff2967 build: Add --disable-java option to configure (bug #37838).
Rik <rik@octave.org>
parents: 15625
diff changeset
2866
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2867 void
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2868 octave_java::init (void *jobj_arg, void *jcls_arg)
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2869 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2870 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2871
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2872 jobject jobj = TO_JOBJECT (jobj_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2873 jclass jcls = TO_JCLASS (jcls_arg);
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2874
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2875 JNIEnv *current_env = thread_jni_env ();
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2876
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2877 if (current_env)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2878 {
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2879 if (jobj)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2880 java_object = current_env->NewGlobalRef (jobj);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2881
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2882 if (jcls)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2883 java_class = current_env->NewGlobalRef (jcls);
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2884 else if (java_object)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2885 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2886 jclass_ref ocls (current_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2887 current_env->GetObjectClass(TO_JOBJECT (java_object)));
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2888 java_class = current_env->NewGlobalRef (jclass (ocls));
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2889 }
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2890
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2891 if (java_class)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2892 {
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2893 jclass_ref clsCls (current_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2894 current_env->GetObjectClass (TO_JCLASS (java_class)));
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2895 jmethodID mID = current_env->GetMethodID (clsCls,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2896 "getCanonicalName",
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2897 "()Ljava/lang/String;");
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2898 jobject_ref resObj (current_env,
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2899 current_env->CallObjectMethod (TO_JCLASS (java_class), mID));
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2900 java_classname = jstring_to_string (current_env, resObj);
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2901 }
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2902 }
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2903
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2904 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2905
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2906 octave_unused_parameter (jobj_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2907 octave_unused_parameter (jcls_arg);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2908
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2909 // This shouldn't happen because construction of octave_java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2910 // objects is supposed to be impossible if Java is not available.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2911
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2912 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2913
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2914 #endif
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2915 }
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2916
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2917 void
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2918 octave_java::release (void)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2919 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2920 #if defined (HAVE_JAVA)
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2921
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2922 JNIEnv *current_env = thread_jni_env ();
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2923
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2924 if (current_env)
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2925 {
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2926 if (java_object)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2927 current_env->DeleteGlobalRef (TO_JOBJECT (java_object));
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2928
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2929 if (java_class)
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2930 current_env->DeleteGlobalRef (TO_JCLASS (java_class));
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2931
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
2932 java_object = nullptr;
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
2933 java_class = nullptr;
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2934 }
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2935
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2936 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2937
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2938 // This shouldn't happen because construction of octave_java objects is
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2939 // supposed to be impossible if Java is not available.
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2940
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2941 panic_impossible ();
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2942
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2943 #endif
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
2944 }
15806
01d4f742d75d doc: Re-organize and improve Java Interface documentation.
Rik <rik@octave.org>
parents: 15800
diff changeset
2945
24140
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2946 // DEFUN blocks below must be outside of HAVE_JAVA block so that documentation
0b7662d8bd02 doc: libinterp/octave-value/ov-java.cc: Improve (Doxygen) comments.
Ernst Reissner <rei3ner@arcor.de>
parents: 23929
diff changeset
2947 // strings are always available, even when functions are not.
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
2948
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2949 DEFUN (__java_init__, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2950 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2951 @deftypefn {} {} __java_init__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2952 Internal function used @strong{only} when debugging Java interface.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2953
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2954 Function will directly call initialize_java to create an instance of a JVM.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2955 @end deftypefn */)
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2956 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2957 #if defined (HAVE_JAVA)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2958
24141
af577de75e68 maint: libinterp/octave-value/ov-java.cc: Clean up code. No function changes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 24140
diff changeset
2959 octave_value retval = 0;
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2960
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2961 initialize_java ();
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2962
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
2963 retval = 1;
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2964
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2965 return retval;
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2966
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2967 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2968
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2969 err_disabled_feature ("__java_init__", "Java");
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2970
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2971 #endif
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2972 }
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2973
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2974 DEFUN (__java_exit__, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2975 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2976 @deftypefn {} {} __java_exit__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2977 Internal function used @strong{only} when debugging Java interface.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2978
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2979 Function will directly call terminate_jvm to destroy the current JVM
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2980 instance.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2981 @end deftypefn */)
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2982 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
2983 #if defined (HAVE_JAVA)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2984
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2985 terminate_jvm ();
20957
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2986
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2987 return ovl ();
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2988
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2989 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2990
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2991 err_disabled_feature ("__java_exit__", "Java");
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
2992
15879
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2993 #endif
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2994 }
f69530e3600d make docstrings for __java_init__ and __java_exit__ available unconditionally
John W. Eaton <jwe@octave.org>
parents: 15859
diff changeset
2995
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
2996 DEFUN (javaObject, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2997 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2998 @deftypefn {} {@var{jobj} =} javaObject (@var{classname})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
2999 @deftypefnx {} {@var{jobj} =} javaObject (@var{classname}, @var{arg1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3000 Create a Java object of class @var{classsname}, by calling the class
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3001 constructor with the arguments @var{arg1}, @dots{}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3002
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3003 The first example below creates an uninitialized object, while the second
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3004 example supplies an initial argument to the constructor.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3005
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3006 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3007 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3008 x = javaObject ("java.lang.StringBuffer")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3009 x = javaObject ("java.lang.StringBuffer", "Initial string")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3010 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3011 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3012
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3013 @seealso{javaMethod, javaArray}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3014 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3015 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3016 #if defined (HAVE_JAVA)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3017
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3018 if (args.length () == 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3019 print_usage ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3020
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3021 std::string classname = args(0).xstring_value ("javaObject: CLASSNAME must be a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3022
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3023 initialize_java ();
15790
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15771
diff changeset
3024
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3025 JNIEnv *current_env = thread_jni_env ();
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3026
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3027 octave_value_list tmp;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3028 for (int i=1; i<args.length (); i++)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3029 tmp(i-1) = args(i);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3030
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3031 return ovl (octave_java::do_javaObject (current_env, classname, tmp));
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3032
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3033 #else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3034
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3035 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3036
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3037 err_disabled_feature ("javaObject", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3038
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3039 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3040 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3041
15825
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3042 /*
21042
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
3043 ## The tests below merely check if javaObject works at all. Whether
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
3044 ## it works properly, i.e., creates the right values, is a matter of
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
3045 ## Java itself. Create a Short and check if it really is a short, i.e.,
0967e2393386 * ov-java.h, ov-java.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 20974
diff changeset
3046 ## whether it overflows.
23405
32ec90068be5 use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
3047 %!testif HAVE_JAVA; usejava ("jvm")
15825
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3048 %! assert (javaObject ("java.lang.Short", 40000).doubleValue < 0);
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3049 */
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3050
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3051 DEFUN (javaMethod, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3052 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3053 @deftypefn {} {@var{ret} =} javaMethod (@var{methodname}, @var{obj})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3054 @deftypefnx {} {@var{ret} =} javaMethod (@var{methodname}, @var{obj}, @var{arg1}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3055 Invoke the method @var{methodname} on the Java object @var{obj} with the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3056 arguments @var{arg1}, @dots{}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3057
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3058 For static methods, @var{obj} can be a string representing the fully
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3059 qualified name of the corresponding class.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3060
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3061 When @var{obj} is a regular Java object, structure-like indexing can be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3062 used as a shortcut syntax. For instance, the two following statements are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3063 equivalent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3064
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3065 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3066 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3067 ret = javaMethod ("method1", x, 1.0, "a string")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3068 ret = x.method1 (1.0, "a string")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3069 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3070 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3071
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3072 @code{javaMethod} returns the result of the method invocation.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3073
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3074 @seealso{methods, javaObject}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3075 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3076 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3077 #if defined (HAVE_JAVA)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3078
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3079 if (args.length () < 2)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3080 print_usage ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3081
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3082 std::string methodname = args(0).xstring_value ("javaMethod: METHODNAME must be a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3083
15790
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15771
diff changeset
3084 initialize_java ();
921912c92102 Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents: 15771
diff changeset
3085
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3086 JNIEnv *current_env = thread_jni_env ();
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3087
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3088 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3089
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3090 octave_value_list tmp;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3091 for (int i=2; i<args.length (); i++)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3092 tmp(i-2) = args(i);
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3093
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
3094 if (args(1).isjava ())
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3095 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3096 octave_java *jobj = TO_JAVA (args(1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3097 retval = jobj->do_javaMethod (current_env, methodname, tmp);
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3098 }
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3099 else if (args(1).is_string ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3100 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3101 std::string cls = args(1).string_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3102 retval = octave_java::do_javaMethod (current_env, cls, methodname, tmp);
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3103 }
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3104 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3105 error ("javaMethod: OBJ must be a Java object or a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3106
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3107 return retval;
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3108
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3109 #else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3110
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3111 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3112
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3113 err_disabled_feature ("javaMethod", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3114
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3115 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3116 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3117
15825
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3118 /*
23405
32ec90068be5 use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
3119 %!testif HAVE_JAVA; usejava ("jvm")
20152
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3120 %! ## Check for valid first two Java version numbers
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3121 %! jver = strsplit (javaMethod ("getProperty", "java.lang.System", "java.version"), ".");
15825
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3122 %! assert (isfinite (str2double (jver{1})) && isfinite (str2double (jver{2})));
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3123 */
9854666df787 ov-java.cc: tests added for javaObject and javaMethod
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15824
diff changeset
3124
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3125 DEFUN (__java_get__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3126 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3127 @deftypefn {} {@var{val} =} __java_get__ (@var{obj}, @var{name})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3128 Get the value of the field @var{name} of the Java object @var{obj}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3129
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3130 For static fields, @var{obj} can be a string representing the fully
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3131 qualified name of the corresponding class.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3132
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3133 When @var{obj} is a regular Java object, structure-like indexing can be used
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3134 as a shortcut syntax. For instance, the two following statements are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3135 equivalent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3136
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3137 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3138 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3139 __java_get__ (x, "field1")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3140 x.field1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3141 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3142 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3143
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3144 @seealso{__java_set__, javaMethod, javaObject}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3145 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3146 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3147 #if defined (HAVE_JAVA)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3148
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3149 if (args.length () != 2)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3150 print_usage ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3151
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3152 std::string name = args(1).string_value ("__java_get__: NAME must be a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3153
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3154 initialize_java ();
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3155
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3156 JNIEnv *current_env = thread_jni_env ();
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3157
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3158 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3159
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
3160 if (args(0).isjava ())
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3161 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3162 octave_java *jobj = TO_JAVA (args(0));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3163 retval = jobj->do_java_get (current_env, name);
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3164 }
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3165 else if (args(0).is_string ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3166 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3167 std::string cls = args(0).string_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3168 retval = octave_java::do_java_get (current_env, cls, name);
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3169 }
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3170 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3171 error ("__java_get__: OBJ must be a Java object or a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3172
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3173 return retval;
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3174
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3175 #else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3176
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3177 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3178
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3179 err_disabled_feature ("__java_get__", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3180
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3181 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3182 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3183
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3184 DEFUN (__java_set__, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3185 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3186 @deftypefn {} {@var{obj} =} __java_set__ (@var{obj}, @var{name}, @var{val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3187 Set the value of the field @var{name} of the Java object @var{obj} to
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3188 @var{val}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3189
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3190 For static fields, @var{obj} can be a string representing the fully
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3191 qualified named of the corresponding Java class.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3192
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3193 When @var{obj} is a regular Java object, structure-like indexing can be
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3194 used as a shortcut syntax. For instance, the two following statements are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3195 equivalent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3196
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3197 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3198 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3199 __java_set__ (x, "field1", val)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3200 x.field1 = val
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3201 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3202 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3203
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3204 @seealso{__java_get__, javaMethod, javaObject}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3205 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3206 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3207 #if defined (HAVE_JAVA)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3208
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3209 if (args.length () != 3)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3210 print_usage ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3211
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3212 std::string name = args(1).xstring_value ("__java_set__: NAME must be a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3213
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3214 initialize_java ();
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3215
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3216 JNIEnv *current_env = thread_jni_env ();
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3217
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3218 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3219
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
3220 if (args(0).isjava ())
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3221 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3222 octave_java *jobj = TO_JAVA (args(0));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3223 retval = jobj->do_java_set (current_env, name, args(2));
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3224 }
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3225 else if (args(0).is_string ())
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3226 {
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3227 std::string cls = args(0).string_value ();
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3228 retval = octave_java::do_java_set (current_env, cls, name, args(2));
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3229 }
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3230 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3231 error ("__java_set__: OBJ must be a Java object or a string");
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3232
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3233 return retval;
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3234
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3235 #else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3236
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3237 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3238
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3239 err_disabled_feature ("__java_set__", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3240
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3241 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3242 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3243
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3244 DEFUN (java2mat, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3245 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3246 @deftypefn {} {} java2mat (@var{javaobj})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3247 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3248 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3249 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3250 #if defined (HAVE_JAVA)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3251
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3252 if (args.length () != 1)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3253 print_usage ();
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3254
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3255 initialize_java ();
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3256
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3257 JNIEnv *current_env = thread_jni_env ();
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3258
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3259 octave_value_list retval;
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3260
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
3261 if (args(0).isjava ())
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3262 {
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3263 octave_java *jobj = TO_JAVA (args(0));
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23717
diff changeset
3264 retval = ovl (box_more (current_env, jobj->to_java (), nullptr));
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3265 }
20559
0650b8431037 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20542
diff changeset
3266 else
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20893
diff changeset
3267 retval = ovl (args(0));
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3268
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3269 return retval;
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3270
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3271 #else
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3272
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3273 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3274
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3275 err_disabled_feature ("java2mat", "Java");
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3276
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3277 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3278 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3279
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3280 DEFUN (java_matrix_autoconversion, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3281 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3282 @deftypefn {} {@var{val} =} java_matrix_autoconversion ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3283 @deftypefnx {} {@var{old_val} =} java_matrix_autoconversion (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3284 @deftypefnx {} {} java_matrix_autoconversion (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3285 Query or set the internal variable that controls whether Java arrays are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3286 automatically converted to Octave matrices.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3287
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3288 The default value is false.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3289
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3290 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3291 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3292 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3293 @seealso{java_unsigned_autoconversion, debug_java}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3294 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3295 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3296 #if defined (HAVE_JAVA)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3297
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3298 return SET_INTERNAL_VARIABLE (java_matrix_autoconversion);
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3299
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3300 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3301
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3302 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3303 octave_unused_parameter (nargout);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3304
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3305 err_disabled_feature ("java_matrix_autoconversion", "Java");
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3306
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3307 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3308 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3309
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3310 DEFUN (java_unsigned_autoconversion, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3311 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3312 @deftypefn {} {@var{val} =} java_unsigned_autoconversion ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3313 @deftypefnx {} {@var{old_val} =} java_unsigned_autoconversion (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3314 @deftypefnx {} {} java_unsigned_autoconversion (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3315 Query or set the internal variable that controls how integer classes are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3316 converted when @code{java_matrix_autoconversion} is enabled.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3317
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3318 When enabled, Java arrays of class Byte or Integer are converted to matrices
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3319 of class uint8 or uint32 respectively. The default value is true.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3320
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3321 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3322 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3323 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3324 @seealso{java_matrix_autoconversion, debug_java}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3325 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3326 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3327 #if defined (HAVE_JAVA)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3328
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3329 return SET_INTERNAL_VARIABLE (java_unsigned_autoconversion);
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3330
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3331 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3332
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3333 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3334 octave_unused_parameter (nargout);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3335
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3336 err_disabled_feature ("java_unsigned_autoconversion", "Java");
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3337
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3338 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3339 }
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3340
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3341 DEFUN (debug_java, args, nargout,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3342 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3343 @deftypefn {} {@var{val} =} debug_java ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3344 @deftypefnx {} {@var{old_val} =} debug_java (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3345 @deftypefnx {} {} debug_java (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3346 Query or set the internal variable that determines whether extra debugging
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3347 information regarding the initialization of the JVM and any Java exceptions
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3348 is printed.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3349
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3350 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3351 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3352 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3353 @seealso{java_matrix_autoconversion, java_unsigned_autoconversion}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3354 @end deftypefn */)
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3355 {
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3356 #if defined (HAVE_JAVA)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3357
15800
d9b8333df5e4 Deprecate java_debug, java_convert_matrix, java_unsigned_conversion.
Rik <rik@octave.org>
parents: 15798
diff changeset
3358 return SET_INTERNAL_VARIABLE (debug_java);
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3359
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3360 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3361
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3362 octave_unused_parameter (args);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3363 octave_unused_parameter (nargout);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3364
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3365 err_disabled_feature ("debug_java", "Java");
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21661
diff changeset
3366
15771
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3367 #endif
4698ea77aa75 Hide java_init, java_exit functions. Deprecate java_new, java_set, java_get.
Rik <rik@octave.org>
parents: 15770
diff changeset
3368 }
15736
6faa01ff2967 build: Add --disable-java option to configure (bug #37838).
Rik <rik@octave.org>
parents: 15625
diff changeset
3369
21379
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3370 // Outside of #if defined (HAVE_JAVA) because it is desirable to be able
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3371 // to test for the presence of a Java object without having Java
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3372 // installed.
93c489ca8a6b elimnate HAVE_JAVA from ov-java.h
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3373
15770
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3374 DEFUN (isjava, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3375 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3376 @deftypefn {} {} isjava (@var{x})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3377 Return true if @var{x} is a Java object.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3378 @seealso{class, typeinfo, isa, javaObject}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21894
diff changeset
3379 @end deftypefn */)
15770
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3380 {
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3381 if (args.length () != 1)
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3382 print_usage ();
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20765
diff changeset
3383
23578
7b47b7c2d6c7 maint: Deprecate is_java and replace with isjava.
Rik <rik@octave.org>
parents: 23577
diff changeset
3384 return ovl (args(0).isjava ());
15770
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3385 }
e61405133a76 Add new isjava function.
Rik <rik@octave.org>
parents: 15763
diff changeset
3386
20120
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
3387 /*
20152
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3388 ## Check automatic conversion of java primitive arrays into octave types.
23405
32ec90068be5 use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
3389 %!testif HAVE_JAVA; usejava ("jvm")
20152
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3390 %! assert (javaObject ("java.lang.String", "hello").getBytes (),
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3391 %! int8 ([104 101 108 108 111]'));
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3392
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3393 ## Check automatic conversion of octave types into java primitive arrays.
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3394 ## Note that uint8 is casted to int8.
23405
32ec90068be5 use %!testif runtime tests to properly skip java tests
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
3395 %!testif HAVE_JAVA; usejava ("jvm")
20152
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3396 %! assert (javaMethod ("binarySearch", "java.util.Arrays", [90 100 255], 255), 2);
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3397 %! assert (javaMethod ("binarySearch", "java.util.Arrays", uint8 ([90 100 255]), uint8 (255)) < 0);
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3398 %! assert (javaMethod ("binarySearch", "java.util.Arrays", uint8 ([90 100 128]), uint8 (128)) < 0);
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3399 %! assert (javaMethod ("binarySearch", "java.util.Arrays", uint8 ([90 100 127]), uint8 (127)), 2);
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3400 %! assert (javaMethod ("binarySearch", "java.util.Arrays", uint16 ([90 100 128]), uint16 (128)), 2);
8187a66039e4 Don't run Java BIST tests if HAVA_JAVA is false.
Rik <rik@octave.org>
parents: 20124
diff changeset
3401
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
3402 ## Check we can create objects that wrap java literals
23573
1b4f4ec53b4a use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents: 23572
diff changeset
3403 %!testif HAVE_JAVA; usejava ("jvm") <*38821>
21822
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3404 %! assert (class (javaObject ("java.lang.Byte", uint8 (1))), "java.lang.Byte");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3405 %! assert (class (javaObject ("java.lang.Byte", int8 (1))), "java.lang.Byte");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3406 %! assert (class (javaObject ("java.lang.Short", uint16 (1))), "java.lang.Short");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3407 %! assert (class (javaObject ("java.lang.Short", int16 (1))), "java.lang.Short");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3408 %! assert (class (javaObject ("java.lang.Integer", uint32 (1))), "java.lang.Integer");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3409 %! assert (class (javaObject ("java.lang.Integer", int32 (1))), "java.lang.Integer");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3410 %! assert (class (javaObject ("java.lang.Long", uint64 (1))), "java.lang.Long");
e56ba70108d3 Fix typos in Java conversion of 32 and 64 bit integers (bug #48107)
Mike Miller <mtmiller@octave.org>
parents: 21780
diff changeset
3411 %! assert (class (javaObject ("java.lang.Long", int64 (1))), "java.lang.Long");
20260
137f183b7dee Fix conversion from string cell array into java's String[] (bug #45290)
Carnë Draug <carandraug@octave.org>
parents: 20250
diff changeset
3412
23681
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3413 ## More checks of java numeric and boolean class instances
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3414 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3415 %! n = javaObject ("java.lang.Double", 1.35);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3416 %! assert (n.compareTo (1.0), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3417 %! assert (n.compareTo (1.35), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3418 %! assert (n.compareTo (10), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3419 %! assert (n.isInfinite (), false);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3420
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3421 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3422 %! n = javaObject ("java.lang.Float", 1.35);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3423 %! assert (n.compareTo (1.0), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3424 %! assert (n.compareTo (1.35), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3425 %! assert (n.compareTo (10), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3426 %! assert (n.doubleValue (), 1.35, 1e7);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3427
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3428 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3429 %! n = javaObject ("java.lang.Long", (int64 (1)));
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3430 %! assert (n.compareTo (int64 (0)), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3431 %! assert (n.compareTo (int64 (1)), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3432 %! assert (n.compareTo (int64 (2)), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3433 %! assert (n.toString (), "1");
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3434
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3435 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3436 %! n = javaObject ("java.lang.Integer", 1.35);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3437 %! assert (n.compareTo (0), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3438 %! assert (n.compareTo (1), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3439 %! assert (n.compareTo (2), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3440
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3441 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3442 %! n = javaObject ("java.lang.Short", 1.35);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3443 %! assert (n.compareTo (0), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3444 %! assert (n.compareTo (1), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3445 %! assert (n.compareTo (2), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3446
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3447 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3448 %! n = javaObject ("java.lang.Byte", int8 (17));
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3449 %! assert (n.compareTo (int8 (20)), -3);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3450 %! assert (n.compareTo (int8 (10)), 7);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3451 %! assert (n.compareTo (int8 (17)), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3452
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3453 %!testif HAVE_JAVA; usejava ("jvm")
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3454 %! b = javaObject ("java.lang.Boolean", true);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3455 %! assert (b.compareTo (true), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3456 %! assert (b.compareTo (false), 1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3457 %! b = javaObject ("java.lang.Boolean", false);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3458 %! assert (b.compareTo (true), -1);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3459 %! assert (b.compareTo (false), 0);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3460
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
3461 ## Test for automatic conversion of specific numeric classes
23573
1b4f4ec53b4a use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents: 23572
diff changeset
3462 %!testif HAVE_JAVA; usejava ("jvm") <*48013>
22203
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3463 %! assert (javaMethod ("valueOf", "java.lang.Byte", int8 (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3464 %! assert (javaMethod ("valueOf", "java.lang.Short", int16 (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3465 %! assert (javaMethod ("valueOf", "java.lang.Integer", int32 (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3466 %! assert (javaMethod ("valueOf", "java.lang.Long", int64 (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3467 %! assert (javaMethod ("valueOf", "java.lang.Float", single (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3468 %! assert (javaMethod ("valueOf", "java.lang.Double", double (1)), 1)
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3469 %! assert (class (javaMethod ("valueOf", "java.math.BigDecimal", double (1))), "java.math.BigDecimal")
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3470 %! assert (class (javaMethod ("valueOf", "java.math.BigInteger", int64 (1))), "java.math.BigInteger")
2f301a30aeed Add tests for Java numeric type conversion (bug #48013)
Mike Miller <mtmiller@octave.org>
parents: 22202
diff changeset
3471
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
3472 ## Automatic conversion from string cell array into String[]
23573
1b4f4ec53b4a use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents: 23572
diff changeset
3473 %!testif HAVE_JAVA; usejava ("jvm") <*45290>
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
3474 %! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "aaa"), 0);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
3475 %! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "zzz"), 3);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21547
diff changeset
3476 %! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "hhh") < 0);
23671
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3477
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3478 ## Test that Octave index syntax allows Java object method calls with args
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3479 %!testif HAVE_JAVA; usejava ("jvm") <*51152>
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3480 %! s = javaObject ("java.lang.String", "Octave");
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3481 %! assert (s.length (), 6)
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3482 %! assert (s.charAt (0), "O")
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3483 %! assert (s.charAt (5), "e")
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3484 %! assert (s.matches ("^Octave$"))
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3485 %! assert (s.startsWith ("Oct"))
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3486 %! ## same tests with Java object as part of another indexing expression
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3487 %! a(1).s = s;
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3488 %! assert (! a(1).s.isEmpty ())
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3489 %! assert (a(1).s.length (), 6)
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3490 %! assert (a(1).s.charAt (0), "O")
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3491 %! assert (a(1).s.charAt (5), "e")
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3492 %! assert (a(1).s.matches ("^Octave$"))
d197f62cde8a restore Java method calls by delegating indexing properly (bug #51152)
Mike Miller <mtmiller@octave.org>
parents: 23592
diff changeset
3493 %! assert (a(1).s.startsWith ("Oct"))
23681
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3494
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3495 ## Check for basic usability of the java awt library
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3496 %!testif HAVE_JAVA; usejava ("jvm") && usejava ("awt") && have_window_system ()
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3497 %! frame = javaObject ("java.awt.Frame");
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3498 %! frame.setResizable (true);
8b5bc5e5f74b add unit tests creating and calling methods on some basic Java types
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 23671
diff changeset
3499 %! assert (frame.isResizable ());
20120
2db2db2df55b Automatically convert arrays of java primitives into Octave types (bug #44882)
Carnë Draug <carandraug@octave.org>
parents: 20028
diff changeset
3500 */