[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Changeset]: Documentation for the OOP code of Octave
From: |
David Bateman |
Subject: |
[Changeset]: Documentation for the OOP code of Octave |
Date: |
Wed, 15 Oct 2008 15:14:07 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.16 (X11/20080724) |
Here is my first attempt at documentation for the OOP code of Octave. It
is still a bit incomplete and it relies on a nasty hack to avoid the
issue of "@" in the directory name for the example files. Basically I
named the directory "examples/polynomial" and not "examples/polynomial"
as it really should be named. If you want to really use the example
files you'll need to run
cd example
ln -s polynomial @polynomial
prior to actually use them. Once I have a solution (or if I have a
solution) to the "@" in the filename issue with pdfetex I'll update this
and all of the locations like examples/Makefile.in, configure.in and
doc/interpreter/Makefile.in, etc where an incorrect reference to this
directory is made.
In any case before committing this changeset, it would be good if I
could have some comments, or improvements.
Cheers
David
3)
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
# HG changeset patch
# User David Bateman <address@hidden>
# Date 1224079351 -3600
# Node ID b4db39541d69a29a4f03a2caf9952cd269d9111e
# Parent 5bd29ca61596aec13b0019b2cc944c4d9c055302
Add some documentation for the OOP code of Octave
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-10-15 David Bateman <address@hidden>
+
+ * examples/polynomial/display.m, examples/polynomial/double.m,
+ examples/polynomial/end.m, examples/polynomial/get.m,
+ examples/polynomial/mtimes.m, examples/polynomial/plot.m,
+ examples/polynomial/polynomial.m,
+ examples/polynomial/polynomial_superiorto.m,
+ examples/polynomial/polyval.m, examples/polynomial/set.m,
+ examples/polynomial/subsasgn.m, examples/polynomial/subsref.m:
+ New example files for a sample OOP class.
+ * examples/polynomial/Makefile.in: Add a makefile for this new
+ directory
+ * examples/Makefile.in: Reference the new subdirectory here.
+ * configure.in: Add the new makefile to AC_CONFIG_FILES.
+
2008-10-01 Jaroslav Hajek <address@hidden>
* configure.in: Check for sizeof (long double) and randl.
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -1989,9 +1989,9 @@
AC_CONFIG_FILES([Makefile octMakefile Makeconf test/Makefile
doc/Makefile doc/faq/Makefile doc/interpreter/Makefile
doc/liboctave/Makefile doc/refcard/Makefile emacs/Makefile
- examples/Makefile liboctave/Makefile liboctave/oct-types.h
- src/Makefile src/mxarray.h libcruft/Makefile libcruft/Makerules
- libcruft/amos/Makefile libcruft/blas/Makefile
+ examples/Makefile examples/polynomial/Makefile liboctave/Makefile
+ liboctave/oct-types.h src/Makefile src/mxarray.h libcruft/Makefile
+ libcruft/Makerules libcruft/amos/Makefile libcruft/blas/Makefile
libcruft/daspk/Makefile libcruft/dasrt/Makefile
libcruft/dassl/Makefile libcruft/fftpack/Makefile
libcruft/lapack/Makefile libcruft/minpack/Makefile
diff --git a/doc/ChangeLog b/doc/ChangeLog
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,4 +1,16 @@
+2008-10-15 David Bateman <address@hidden>
+
+ * interpreter/oop.txi: New file.
+ * interpreter/Makefile.in (SUB_SOURCES): Add it here.
+ (POLYNOMIAL_FILES_NODIR): New varaible for polynomial example class
+ methods.
+ (EXAMPLE_FILES_NODIR): Add POLYNOMIAL_FILES_NODIR here.
+ * interpreter/octave.texi: Reference new OOP chapter here.
+ * interpreter/func.txi: Document private directories and function
+ precedence here.
+
2008-10-03 Thorsten Meyer <address@hidden>
+
* interpreter/contrib.txi: added example for mercurial queues
08-10-03 Thorsten Meyer <address@hidden>
diff --git a/doc/interpreter/Makefile.in b/doc/interpreter/Makefile.in
--- a/doc/interpreter/Makefile.in
+++ b/doc/interpreter/Makefile.in
@@ -33,6 +33,20 @@
SCRIPT_SOURCES = sparseimages.m interpimages.m geometryimages.m plotimages.m
+POLYNOMIAL_FILES_NODIR = \
+ display.m \
+ double.m \
+ end.m \
+ get.m \
+ mtimes.m \
+ plot.m \
+ polynomial.m \
+ polynomial_superiorto.m \
+ polyval.m \
+ set.m \
+ subsasgn.m \
+ subsref.m
+
EXAMPLE_FILES_NODIR = \
addtwomatrices.cc \
celldemo.cc \
@@ -52,7 +66,8 @@
paramdemo.cc \
stringdemo.cc \
structdemo.cc \
- unwinddemo.cc
+ unwinddemo.cc \
+ $(addprefix polynomial/, $(POLYNOMIAL_FILES_NODIR))
EXAMPLE_FILES = $(addprefix $(top_srcdir)/examples/, $(EXAMPLE_FILES_NODIR))
@@ -99,7 +114,7 @@
expr.txi fn-idx.txi func.txi geometry.txi gpl.txi \
grammar.txi image.txi install.txi interp.txi \
intro.txi io.txi linalg.txi matrix.txi nonlin.txi numbers.txi \
- op-idx.txi optim.txi package.txi plot.txi poly.txi preface.txi \
+ oop.txi op-idx.txi optim.txi package.txi plot.txi poly.txi preface.txi \
quad.txi set.txi signal.txi sparse.txi stats.txi \
stmt.txi strings.txi system.txi testfun.txi tips.txi var.txi \
vr-idx.txi
diff --git a/doc/interpreter/func.txi b/doc/interpreter/func.txi
--- a/doc/interpreter/func.txi
+++ b/doc/interpreter/func.txi
@@ -625,8 +625,10 @@
@menu
* Manipulating the load path::
* Subfunctions::
+* Private Functions::
* Overloading and Autoloading::
* Function Locking::
+* Function Precedence::
@end menu
@node Manipulating the load path
@@ -699,6 +701,34 @@
subfunctions @code{g} and @code{h} may only be called from the main
function @code{f} or from the other subfunctions, but not from outside
the file @file{f.m}.
+
address@hidden Private Functions
address@hidden Private Functions
+
+In many cases one function needs to access one or more helper
+functions. If the helper function is limited to the scope of a single
+function, then subfunctions as discussed above might be used. However,
+if a single helper function is used by more than one function, then
+this is no longer possible. In this case the helper functions might
+be placed in a subdirectory, called "private", of the directory in which
+the functions needing access to this helper function are found.
+
+As a simple example, consider a function @code{func1}, that calls a helper
+function @code{func2} to do much of the work. For example
+
address@hidden
address@hidden
+function y = func1 (x)
+ y = func2 (x);
+endfunction
address@hidden group
address@hidden example
+
address@hidden
+Then if the path to @code{func1} is @code{<directory>/func1.m}, and if
address@hidden is found in the directory @code{<directory>/private/func2.m},
+then @code{func2} is only available for use of the functions, like
address@hidden, that are found in @code{<directory>}.
@node Overloading and Autoloading
@subsection Overloading and Autoloading
@@ -825,6 +855,49 @@
@DOCSTRING(munlock)
@DOCSTRING(mislocked)
+
address@hidden Function Precedence
address@hidden Function Precedence
+
+Given the numereous different ways that Octave can define a function, it
+is possible and even likely that multiple versions of a function, might be
+defined within a particular scope. The precedence of which function will be
+used within a particular scope is given by
+
address@hidden 1
address@hidden Subfunction
+A subfunction with the required function name in the given scope.
+
address@hidden Private function
+A function defined within a private directory of the directory
+which contains the current function.
+
address@hidden Class constructor
+A function that constuctors a user class as defined in chapter
address@hidden Oriented Programming}.
+
address@hidden Class method
+An overloaded function of a class as in chapter
address@hidden Oriented Programming}.
+
address@hidden Legacy Dispatch
+An overloaded function as defined by @xref{dispatch}.
+
address@hidden Command-line Function
+A function that has been defined on the command-line.
+
address@hidden Autoload function
+A function that is marked as autoloaded with @xref{autoload}.
+
address@hidden A Function on the Path
+A function that can be found on the users load-path. There can also be
+Oct-file, mex-file or m-file versions of this function and the precedence
+between these versions are in that order.
+
address@hidden Built-in function
+A function that is builtin to Octave itself such as @code{numel},
address@hidden, etc.
address@hidden enumerate
@node Script Files
@section Script Files
diff --git a/doc/interpreter/octave.texi b/doc/interpreter/octave.texi
--- a/doc/interpreter/octave.texi
+++ b/doc/interpreter/octave.texi
@@ -177,6 +177,7 @@
* Signal Processing::
* Image Processing::
* Audio Processing::
+* Object Oriented Programming::
* System Utilities::
* Packages::
* Dynamically Linked Functions::
@@ -487,6 +488,13 @@
* Plotting on top of Images::
* Color Conversion::
+Object Oriented Programming
+
+* Creating a Class:
+* Manipulating Classes::
+* Indexing Objects::
+* Overloading Objects::
+
System Utilities
* Timing Utilities::
@@ -600,6 +608,7 @@
@include signal.texi
@include image.texi
@include audio.texi
address@hidden oop.texi
@include system.texi
@include package.texi
diff --git a/examples/Makefile.in b/examples/Makefile.in
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -33,6 +33,10 @@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_DATA = @INSTALL_DATA@
+
+SUBDIRS = polynomial
+
+DISTSUBDIRS = $(SUBDIRS)
SCRIPTS = info-emacs-info info-emacs-octave-help
@@ -78,8 +82,12 @@
DISTSUBDIRS =
-all: octave.desktop
+all: $(SUBDIRS) octave.desktop
.PHONY: all
+
+$(SUBDIRS):
+ $(MAKE) -C $@ all
+.PHONY: $(SUBDIRS)
octave.desktop: octave.desktop.in Makefile ../Makeconf
echo "making $@ from $<"
@@ -134,4 +142,5 @@
dist:
ln $(DISTFILES) ../`cat ../.fname`/examples
+ for dir in $(DISTSUBDIRS); do mkdir ../`cat ../.fname`/scripts/$$dir;
$(MAKE) -C $$dir $@; done
.PHONY: dist
diff --git a/examples/polynomial/Makefile.in b/examples/polynomial/Makefile.in
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/Makefile.in
@@ -0,0 +1,93 @@
+# Makefile for octave's scripts/geometry directory
+#
+# Copyright (C) 2007 John W. Eaton
+#
+# This file is part of Octave.
+#
+# Octave is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# Octave is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Octave; see the file COPYING. If not, see
+# <http://www.gnu.org/licenses/>.
+
+TOPDIR = ../..
+
+script_sub_dir = polynomial
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+
+include $(TOPDIR)/Makeconf
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+SOURCES = \
+ display.m \
+ double.m \
+ end.m \
+ get.m \
+ mtimes.m \
+ plot.m \
+ polynomial.m \
+ polynomial_superiorto.m \
+ polyval.m \
+ set.m \
+ subsasgn.m \
+ subsref.m
+
+DISTFILES = $(addprefix $(srcdir)/,Makefile.in $(SOURCES))
+
+FCN_FILES = $(addprefix $(srcdir)/, $(SOURCES))
+FCN_FILES_NO_DIR = $(notdir $(FCN_FILES))
+
+all: PKG_ADD
+.PHONY: all
+
+install install-strip:
+.PHONY: install install-strip
+
+uninstall:
+.PHONY: uninstall
+
+clean:
+.PHONY: clean
+
+PKG_ADD: $(FCN_FILES)
+ @echo "making PKG_ADD"
+ @$(do-mkpkgadd)
+
+tags: $(SOURCES)
+ ctags $(SOURCES)
+
+TAGS: $(SOURCES)
+ etags $(SOURCES)
+
+mostlyclean: clean
+.PHONY: mostlyclean
+
+distclean: clean
+ rm -f Makefile PKG_ADD
+.PHONY: distclean
+
+maintainer-clean: distclean
+ rm -f tags TAGS
+.PHONY: maintainer-clean
+
+dist:
+ ln $(DISTFILES) ../../`cat ../../.fname`/examples/$(script_sub_dir)
+.PHONY: dist
+
+check-m-sources:
+ @$(do-check-m-sources)
+.PHONY: check-m-sources
diff --git a/examples/polynomial/display.m b/examples/polynomial/display.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/display.m
@@ -0,0 +1,33 @@
+function display (p)
+ a = p.poly;
+ first = true;
+ fprintf("%s =", inputname(1));
+ for i = 1 : length (a);
+ if (a(i) != 0)
+ if (first)
+ first = false;
+ elseif (a(i) > 0)
+ fprintf (" +");
+ endif
+ if (a(i) < 0)
+ fprintf (" -");
+ endif
+ if (i == 1)
+ fprintf (" %g", abs (a(i)));
+ elseif (abs(a(i)) != 1)
+ fprintf (" %g *", abs (a(i)));
+ endif
+ if (i > 1)
+ fprintf (" X");
+ endif
+ if (i > 2)
+ fprintf (" ^ %d", i - 1);
+ endif
+ endif
+ endfor
+ if (first)
+ fprintf(" 0");
+ endif
+ fprintf("\n");
+endfunction
+
diff --git a/examples/polynomial/double.m b/examples/polynomial/double.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/double.m
@@ -0,0 +1,3 @@
+function b = double (a)
+ b = a.poly;
+endfunction
diff --git a/examples/polynomial/end.m b/examples/polynomial/end.m
new file mode 100755
--- /dev/null
+++ b/examples/polynomial/end.m
@@ -0,0 +1,11 @@
+function r = end (obj, index_pos, num_indices)
+ dv = size (obj.x);
+ for i = (num_indices + 1) : length (dv)
+ dv(num_indices) *= dv(i);
+ endfor
+ if (index_pos <= length (dv))
+ r = dv (index_pos);
+ elseif
+ r = 1;
+ endif
+endfunction
diff --git a/examples/polynomial/get.m b/examples/polynomial/get.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/get.m
@@ -0,0 +1,18 @@
+function s = get (p, f)
+ if (nargin == 1)
+ s.poly = p.poly;
+ elseif (nargin == 2)
+ if (ischar (f))
+ switch (f)
+ case "poly"
+ s = p.poly;
+ otherwise
+ error ("get: invalid property %s", f);
+ endswitch
+ else
+ error ("get: expecting the property to be a string");
+ endif
+ else
+ print_usage ();
+ endif
+endfunction
diff --git a/examples/polynomial/mtimes.m b/examples/polynomial/mtimes.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/mtimes.m
@@ -0,0 +1,5 @@
+function y = mtimes (a, b)
+ ap = double (a);
+ bp = double (b);
+ y = polynomial (filter (ap, 1, [bp(:).', zeros(1, length(bp) - 1)]));
+endfunction
\ No newline at end of file
diff --git a/examples/polynomial/plot.m b/examples/polynomial/plot.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/plot.m
@@ -0,0 +1,10 @@
+function h = plot(p, varargin)
+ n = 128;
+ rmax = max (abs (roots (p.poly)));
+ x = [0 : (n - 1)] / (n - 1) * 2.2 * rmax - 1.1 * rmax;
+ if (nargout > 0)
+ h = plot(x, p(x), varargin{:});
+ else
+ plot(x, p(x), varargin{:});
+ endif
+endfunction
\ No newline at end of file
diff --git a/examples/polynomial/polynomial.m b/examples/polynomial/polynomial.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/polynomial.m
@@ -0,0 +1,28 @@
+## -*- texinfo -*-
+## @deftypefn {Function File} {} polynomial ()
+## @deftypefnx {Function File} {} polynomial (@var{a})
+## Creates a polynomial object representing the polynomial
+##
+## @example
+## a0 + a1 * x + a2 * x^2 + @dots{} + an * x^n
+## @end example
+## @end deftypefn
+
+function p = polynomial (a)
+ if (nargin == 0)
+ p.poly = [];
+ p = class (p, "polynomial");
+ elseif (nargin == 1)
+ if (strcmp (class (a), "polynomial"))
+ p = a;
+ elseif (isvector (a) && isreal (a))
+ p.poly = a(:)';
+ p = class (p, "polynomial");
+ else
+ error ("polynomial: expecting real or complex vector")
+ endif
+ else
+ print_usage ();
+ endif
+ superiorto ("double");
+endfunction
diff --git a/examples/polynomial/polynomial_superiorto.m
b/examples/polynomial/polynomial_superiorto.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/polynomial_superiorto.m
@@ -0,0 +1,18 @@
+function p = polynomial (a)
+ if (nargin == 0)
+ p.poly = [];
+ p = class (p, "polynomial");
+ elseif (nargin == 1)
+ if (strcmp (class (a), "polynomial"))
+ p = a;
+ elseif (isvector (a) && isreal (a))
+ p.poly = a(:)';
+ p = class (p, "polynomial");
+ else
+ error ("polynomial: expecting real or complex vector")
+ endif
+ else
+ print_usage ();
+ endif
+ superiorto ("double");
+endfunction
diff --git a/examples/polynomial/polyval.m b/examples/polynomial/polyval.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/polyval.m
@@ -0,0 +1,7 @@
+function [y, dy] = polyval (p, varargin)
+ if (nargout == 2)
+ [y, dy] = polyval (p.poly, varargin{:});
+ else
+ y = polyval (p.poly, varargin{:});
+ endif
+endfunction
diff --git a/examples/polynomial/set.m b/examples/polynomial/set.m
new file mode 100644
--- /dev/null
+++ b/examples/polynomial/set.m
@@ -0,0 +1,20 @@
+function s = set (p, varargin)
+ s = p;
+ if (length (varargin) < 2 || rem (length (varargin), 2) != 0)
+ error ("set: expecting property/value pairs");
+ endif
+ while (length (varargin) > 1)
+ prop = varargin{1};
+ val = varargin{2};
+ varargin(1:2) = [];
+ if (ischar (prop) && strcmp (prop, "poly"))
+ if (isvector (val) && isreal (val))
+ s.poly = val(:)';
+ else
+ error ("set: expecting the value to be a real vector");
+ endif
+ else
+ error ("set: invalid property of polynomial class");
+ endif
+ endwhile
+endfunction
\ No newline at end of file
diff --git a/examples/polynomial/subsasgn.m b/examples/polynomial/subsasgn.m
new file mode 100755
--- /dev/null
+++ b/examples/polynomial/subsasgn.m
@@ -0,0 +1,12 @@
+function s = subsasgn (s, index, val)
+ switch (index.type)
+ case "()"
+ if (! isnumeric (val) || iscomplex(val) ||any (val(:)) >= 2.^ s.m ||
+ any (val(:)) < 0 || any (val(:) != fix(val(:))))
+ error ("subsasgn: value must be an array of real integers between 0 and
2.^m - 1");
+ endif
+ s.x = subsasgn (s.x, index, double (val));
+ case "."
+ error ("subsagn: can not set properties of a galois field directly");
+ endswitch
+endfunction
diff --git a/examples/polynomial/subsref.m b/examples/polynomial/subsref.m
new file mode 100755
--- /dev/null
+++ b/examples/polynomial/subsref.m
@@ -0,0 +1,17 @@
+function b = subsref (a, s)
+ switch s.type
+ case "()"
+ ind = s.subs;
+ b = polyval (fliplr(a.poly), ind{:});
+ case "{}"
+ ind = s.subs;
+ b = polynomial (a.poly(ind{:}));
+ case "."
+ fld = s.subs;
+ if (strcmp (fld, "poly"))
+ b = a.poly;
+ else
+ error ("subsref: unrecognized property \"%s\" of a polynomial", fld);
+ endif
+ endswitch
+endfunction
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-15 David Bateman <address@hidden>
+
+ * general/colon.m: Small typo.
+ * general/loadobj.m: Ditto.
+
2008-10-14 Daniel J. Sebald <address@hidden>
* plot/__go_draw_axes__.m: Send binary data to gnuplot.
diff --git a/scripts/general/colon.m b/scripts/general/colon.m
--- a/scripts/general/colon.m
+++ b/scripts/general/colon.m
@@ -27,6 +27,7 @@
## a = myclass (@dots{})
## b = myclass (@dots{})
## c = a : b
+## @end group
## @end example
##
## @seealso{class, subsref, subsasgn}
diff --git a/scripts/general/loadobj.m b/scripts/general/loadobj.m
--- a/scripts/general/loadobj.m
+++ b/scripts/general/loadobj.m
@@ -18,7 +18,7 @@
## -*- texinfo -*-
## @deftypefn {Function File} address@hidden =} loadobj (@var{a})
-## Methof of a class to manipulate an object after loading it tfrom a file.
+## Method of a class to manipulate an object after loading it tfrom a file.
## The function @code{loadobj} is called when the object @var{a} is loaded
## using the @code{load} function. An example of the use of @code{saveobj}
## might be to add fields to an object that don't make sense to be saved.
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-15 David Bateman <address@hidden>
+
+ * ov-class.c (Fsuperiorto, Finferiorto): Allow more than one class
+ to be defined at a time.
+
2008-10-12 David Bateman <address@hidden>
* pt-colon.cc (octave_value tree_colon_expression::make_range
diff --git a/src/ov-class.cc b/src/ov-class.cc
--- a/src/ov-class.cc
+++ b/src/ov-class.cc
@@ -1342,9 +1342,10 @@
DEFUN (superiorto, args, ,
"-*- texinfo -*-\n\
address@hidden {Built-in Function} {} superiorto (@var{class_name})\n\
address@hidden {Built-in Function} {} superiorto (@var{class_name}, @dots{})\n\
When called from a class constructor, mark the object currently\n\
constructed as having a higher precedence than @var{class_name}.\n\
+More that one such class can be specified in a single call.\n\
This function may only be called from a class constructor.\n\
@end deftypefn")
{
@@ -1354,9 +1355,9 @@
if (fcn && fcn->is_class_constructor ())
{
- if (args.length () == 1)
+ for (int i = 0; i < args.length(); i++)
{
- std::string class_name = args(0).string_value ();
+ std::string class_name = args(i).string_value ();
if (! error_state)
{
@@ -1366,8 +1367,11 @@
if (! symbol_table::set_class_relationship (this_class_name,
class_name))
- error ("superiorto: precedence already set for %s and %s",
- this_class_name.c_str (), class_name.c_str ());
+ {
+ error ("superiorto: precedence already set for %s and %s",
+ this_class_name.c_str (), class_name.c_str ());
+ break;
+ }
}
else
{
@@ -1376,10 +1380,11 @@
}
}
else
- error ("superiorto: expecting argument to be class name");
+ {
+ error ("superiorto: expecting argument to be class name");
+ break;
+ }
}
- else
- print_usage ();
}
else
error ("superiorto: invalid call from outside class constructor");
@@ -1389,9 +1394,10 @@
DEFUN (inferiorto, args, ,
"-*- texinfo -*-\n\
address@hidden {Built-in Function} {} inferiorto (@var{class_name})\n\
address@hidden {Built-in Function} {} inferiorto (@var{class_name}, @dots{})\n\
When called from a class constructor, mark the object currently\n\
constructed as having a lower precedence than @var{class_name}.\n\
+More that one such class can be specified in a single call.\n\
This function may only be called from a class constructor.\n\
@end deftypefn")
{
@@ -1401,9 +1407,9 @@
if (fcn && fcn->is_class_constructor ())
{
- if (args.length () == 1)
+ for (int i = 0; i < args.length(); i++)
{
- std::string class_name = args(0).string_value ();
+ std::string class_name = args(i).string_value ();
if (! error_state)
{
@@ -1416,17 +1422,24 @@
if (! symbol_table::set_class_relationship (this_class_name,
class_name))
- error ("inferiorto: precedence already set for %s and %s",
- this_class_name.c_str (), class_name.c_str ());
+ {
+ error ("inferiorto: precedence already set for %s and %s",
+ this_class_name.c_str (), class_name.c_str ());
+ break;
+ }
}
else
- error ("inferiorto: cannot give user-defined class lower
precedence than built-in class");
+ {
+ error ("inferiorto: cannot give user-defined class lower
precedence than built-in class");
+ break;
+ }
}
else
- error ("inferiorto: expecting argument to be class name");
+ {
+ error ("inferiorto: expecting argument to be class name");
+ break;
+ }
}
- else
- print_usage ();
}
else
error ("inferiorto: invalid call from outside class constructor");
- [Changeset]: Documentation for the OOP code of Octave,
David Bateman <=