Mercurial > hg > octave-lojdl
changeset 8221:06094fa570a3
Add some documentation for the OOP code of Octave
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 15 Oct 2008 20:35:22 +0100 |
parents | 4e05ba66ead2 |
children | 11badf6c9e9f |
files | ChangeLog configure.in doc/ChangeLog doc/interpreter/Makefile.in doc/interpreter/func.txi doc/interpreter/octave.texi examples/Makefile.in scripts/ChangeLog scripts/general/colon.m scripts/general/loadobj.m |
diffstat | 10 files changed, 146 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-10-15 David Bateman <dbateman@free.fr> + + * 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 <highegg@gmail.com> * configure.in: Check for sizeof (long double) and randl.
--- 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
--- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,16 @@ +2008-10-15 David Bateman <dbateman@free.fr> + + * 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 <thorsten.meyier@gmx.de> + * interpreter/contrib.txi: added example for mercurial queues 08-10-03 Thorsten Meyer <thorsten.meyier@gmx.de>
--- 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
--- 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 @@ -700,6 +702,34 @@ function @code{f} or from the other subfunctions, but not from outside the file @file{f.m}. +@node Private Functions +@subsection 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 + +@example +@group +function y = func1 (x) + y = func2 (x); +endfunction +@end group +@end example + +@noindent +Then if the path to @code{func1} is @code{<directory>/func1.m}, and if +@code{func2} is found in the directory @code{<directory>/private/func2.m}, +then @code{func2} is only available for use of the functions, like +@code{func1}, that are found in @code{<directory>}. + @node Overloading and Autoloading @subsection Overloading and Autoloading @@ -826,6 +856,49 @@ @DOCSTRING(mislocked) +@node Function Precedence +@subsection 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 + +@enumerate 1 +@item Subfunction +A subfunction with the required function name in the given scope. + +@item Private function +A function defined within a private directory of the directory +which contains the current function. + +@item Class constructor +A function that constuctors a user class as defined in chapter +@ref{Object Oriented Programming}. + +@item Class method +An overloaded function of a class as in chapter +@ref{Object Oriented Programming}. + +@item Legacy Dispatch +An overloaded function as defined by @xref{dispatch}. + +@item Command-line Function +A function that has been defined on the command-line. + +@item Autoload function +A function that is marked as autoloaded with @xref{autoload}. + +@item 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. + +@item Built-in function +A function that is builtin to Octave itself such as @code{numel}, +@code{size}, etc. +@end enumerate + @node Script Files @section Script Files
--- 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 +@include oop.texi @include system.texi @include package.texi
--- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -34,6 +34,10 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_DATA = @INSTALL_DATA@ +SUBDIRS = polynomial + +DISTSUBDIRS = $(SUBDIRS) + SCRIPTS = info-emacs-info info-emacs-octave-help SOURCES = \ @@ -78,9 +82,13 @@ 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 $<" $(SED) < $< > $@-t \ @@ -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
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2008-10-15 David Bateman <dbateman@free.fr> + + * general/colon.m: Small typo. + * general/loadobj.m: Ditto. + 2008-10-14 Ben Abbott <bpabbott@mac.com> * plot/__go_draw_axes__.m (do_tics_1): New args, fontname and fontsize.
--- 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}
--- a/scripts/general/loadobj.m +++ b/scripts/general/loadobj.m @@ -18,7 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{b} =} 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.