Mercurial > hg > octave-nkf
annotate scripts/deprecated/java_invoke.m @ 16048:10142aad4b9f classdef
Implement indirect method call: fun(obj, ...).
* libinterp/octave-value/ov-classdef.h (class cdef_manager): New class.
(cdef_method::cdef_method_rep::meta_subsref,
cdef_method::cdef_method_rep::meta_is_postfix_index_handled): New
methods.
* libinterp/octave-value/ov-classdef.cc (all_packages, all_classes):
Move static variables to class cdef_manager.
(lookup_class (std::string, bool, bool)): Move implementation to
method cdef_manager::do_find_class().
(lookup_package): Move implementation to method
cdef_manager::do_find_package().
(make_class): Use cdef_manager::register_class.
(make_package): Use cdef_manager::register_package and
cdef_manager::find_package.
(cdef_class::cdef_class_rep::meta_release): Use
cdef_manager::unregister_class.
(cdef_method::cdef_method_rep::meta_subsref): New method.
(class cdef_manager): New class.
* libinterp/interpfcn/symtab.cc
(symbol_table::fcn_info::fcn_info_rep::load_class_constructor):
Look for classdef constructor in normal m-files. Call
find_user_function() and check whether the result is a classdef
constructor. If it is, stash it as a constructor and restore the
previous value of function_on_path.
(symbol_table::fcn_info::fcn_info_rep::load_class_method): Look for
method in classdef system, using cdef_manager::find_method_symbol().
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Mon, 11 Feb 2013 15:20:00 -0500 |
parents | cf3bb2f353a5 |
children | fe112e09d799 |
rev | line source |
---|---|
15790
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
1 ## Copyright (C) 2007 Michael Goffioul |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
2 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
4 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
9 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
14 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
18 |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
20 ## @deftypefn {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}) |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
21 ## @deftypefnx {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}, @var{arg1}, @dots{}) |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
22 ## Invoke the method @var{methodname} on the Java object @var{obj} with the |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
23 ## arguments @var{arg1}, @dots{} For static methods, @var{obj} can be a |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
24 ## string representing the fully qualified name of the corresponding class. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
25 ## The function returns the result of the method invocation. |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
26 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
27 ## When @var{obj} is a regular Java object, structure-like indexing can be |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
28 ## used as a shortcut syntax. For instance, the two following statements are |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
29 ## equivalent |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
30 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
31 ## @example |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
32 ## @group |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
33 ## ret = java_invoke (x, \"method1\", 1.0, \"a string\") |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
34 ## ret = x.method1 (1.0, \"a string\") |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
35 ## @end group |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
36 ## @end example |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
37 ## |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
38 ## @seealso{javaMethod, javaObject} |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
39 ## @end deftypefn |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
40 |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
41 function retval = java_invoke (obj, methodname, varargin) |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
42 |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
43 persistent warned = false; |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
44 if (! warned) |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
45 warned = true; |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
46 warning ("Octave:deprecated-function", |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
47 "java_invoke is obsolete and will be removed from a future version of Octave, please use javaMethod instead"); |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
48 endif |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
49 |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
50 if (nargin < 2) |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
51 print_usage (); |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
52 endif |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
53 |
15794
cf3bb2f353a5
java_new, java_invoke: convey cs-list rather than cell array
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15790
diff
changeset
|
54 retval = javaMethod (methodname, obj, varargin{:}); |
15790
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
55 |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
56 endfunction |
921912c92102
Deprecate java_invoke, replace with javaMethod.
Rik <rik@octave.org>
parents:
diff
changeset
|
57 |