diff -Nru r-cran-r.methodss3-1.7.1/debian/changelog r-cran-r.methodss3-1.8.0/debian/changelog --- r-cran-r.methodss3-1.7.1/debian/changelog 2018-05-31 19:57:02.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/debian/changelog 2020-02-22 17:58:25.000000000 +0000 @@ -1,3 +1,13 @@ +r-cran-r.methodss3 (1.8.0-1) unstable; urgency=medium + + * Team upload. + * New upstream version + * debhelper-compat 12 + * Standards-Version: 4.5.0 + * autopkgtest: s/ADTTMP/AUTOPKGTEST_TMP/g + + -- Dylan Aïssi Sat, 22 Feb 2020 18:58:25 +0100 + r-cran-r.methodss3 (1.7.1-3) unstable; urgency=medium * Rebuild for R 3.5 transition diff -Nru r-cran-r.methodss3-1.7.1/debian/compat r-cran-r.methodss3-1.8.0/debian/compat --- r-cran-r.methodss3-1.7.1/debian/compat 2018-05-31 19:57:02.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru r-cran-r.methodss3-1.7.1/debian/control r-cran-r.methodss3-1.8.0/debian/control --- r-cran-r.methodss3-1.7.1/debian/control 2018-05-31 19:57:02.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/debian/control 2020-02-22 17:58:25.000000000 +0000 @@ -3,10 +3,10 @@ Uploaders: Andreas Tille Section: gnu-r Priority: optional -Build-Depends: debhelper (>= 11~), +Build-Depends: debhelper-compat (= 12), dh-r, r-base-dev -Standards-Version: 4.1.4 +Standards-Version: 4.5.0 Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-r.methodss3 Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-r.methodss3.git Homepage: https://cran.r-project.org/package=R.methodsS3 diff -Nru r-cran-r.methodss3-1.7.1/debian/tests/run-unit-test r-cran-r.methodss3-1.8.0/debian/tests/run-unit-test --- r-cran-r.methodss3-1.7.1/debian/tests/run-unit-test 2018-05-31 19:57:02.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/debian/tests/run-unit-test 2020-02-22 17:58:25.000000000 +0000 @@ -3,13 +3,13 @@ oname=R.methodsS3 pkg=r-cran-`echo $oname | tr '[A-Z]' '[a-z]'` -if [ "$ADTTMP" = "" ] ; then - ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX` +if [ "$AUTOPKGTEST_TMP" = "" ] ; then + AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX` fi -cd $ADTTMP -cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP +cd $AUTOPKGTEST_TMP +cp -a /usr/share/doc/${pkg}/tests/* $AUTOPKGTEST_TMP find . -name "*.gz" -exec gunzip \{\} \; for rfile in *.[rR] ; do R CMD BATCH $rfile done -rm -fr $ADTTMP/* +rm -fr $AUTOPKGTEST_TMP/* diff -Nru r-cran-r.methodss3-1.7.1/DESCRIPTION r-cran-r.methodss3-1.8.0/DESCRIPTION --- r-cran-r.methodss3-1.7.1/DESCRIPTION 2016-02-16 12:48:09.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/DESCRIPTION 2020-02-14 07:10:20.000000000 +0000 @@ -1,8 +1,8 @@ Package: R.methodsS3 -Version: 1.7.1 +Version: 1.8.0 Depends: R (>= 2.13.0) Imports: utils -Date: 2016-02-15 +Suggests: codetools Title: S3 Methods Simplified Authors@R: c(person("Henrik", "Bengtsson", role=c("aut", "cre", "cph"), email = "henrikb@braju.com")) @@ -11,7 +11,9 @@ Description: Methods that simplify the setup of S3 generic functions and S3 methods. Major effort has been made in making definition of methods as simple as possible with a minimum of maintenance for package developers. For example, generic functions are created automatically, if missing, and naming conflict are automatically solved, if possible. The method setMethodS3() is a good start for those who in the future may want to migrate to S4. This is a cross-platform package implemented in pure R that generates standard S3 methods. License: LGPL (>= 2.1) LazyLoad: TRUE +URL: https://github.com/HenrikBengtsson/R.methodsS3 +BugReports: https://github.com/HenrikBengtsson/R.methodsS3/issues NeedsCompilation: no -Packaged: 2016-02-16 03:21:35 UTC; hb +Packaged: 2020-02-14 03:35:57 UTC; hb Repository: CRAN -Date/Publication: 2016-02-16 13:48:09 +Date/Publication: 2020-02-14 07:10:20 UTC diff -Nru r-cran-r.methodss3-1.7.1/inst/CITATION r-cran-r.methodss3-1.8.0/inst/CITATION --- r-cran-r.methodss3-1.7.1/inst/CITATION 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/inst/CITATION 2020-02-14 03:21:07.000000000 +0000 @@ -1,4 +1,4 @@ -citHeader("Please cite R.oo/R.methodsS3 as"); +citHeader("Please cite R.oo/R.methodsS3 as") citEntry( # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -13,8 +13,8 @@ address = "Vienna, Austria", month = "March", issn = "1609-395X", - url = "http://www.r-project.org/conferences/DSC-2003/Proceedings/Bengtsson.pdf", - howpublished = "http://www.r-project.org/conferences/DSC-2003/Proceedings/", + url = "https://www.r-project.org/conferences/DSC-2003/Proceedings/Bengtsson.pdf", + howpublished = "https://www.r-project.org/conferences/DSC-2003/Proceedings/", # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Plain-text citation: @@ -27,4 +27,4 @@ "Hornik, K.; Leisch, F. & Zeileis, A. (ed.), ", "2003" ) -); +) diff -Nru r-cran-r.methodss3-1.7.1/inst/WORDLIST r-cran-r.methodss3-1.8.0/inst/WORDLIST --- r-cran-r.methodss3-1.7.1/inst/WORDLIST 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/inst/WORDLIST 2019-05-24 03:04:45.000000000 +0000 @@ -0,0 +1,16 @@ +Achim +AppVeyor +CMD +conveniency +DSC +Friedrich +Hornik +Leisch +macOS +methodsS +oo +pre +Pre +setMethodS +UseMethod +Zeileis diff -Nru r-cran-r.methodss3-1.7.1/man/pkgStartupMessage.Rd r-cran-r.methodss3-1.8.0/man/pkgStartupMessage.Rd --- r-cran-r.methodss3-1.7.1/man/pkgStartupMessage.Rd 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/man/pkgStartupMessage.Rd 2020-02-14 03:32:22.000000000 +0000 @@ -25,7 +25,7 @@ \arguments{ \item{...}{Arguments passed to \code{\link[base]{packageStartupMessage}}().} - \item{quietly}{If \code{\link[base:logical]{FALSE}}, the message is outputed, otherwise not. + \item{quietly}{If \code{\link[base:logical]{FALSE}}, the message is outputted, otherwise not. If \code{\link[base]{NA}}, the message is \emph{not} outputted if \code{\link[base]{library}}() (or \code{require()}) was called with argument \code{quietly=TRUE}.} } diff -Nru r-cran-r.methodss3-1.7.1/man/R.methodsS3-package.Rd r-cran-r.methodss3-1.8.0/man/R.methodsS3-package.Rd --- r-cran-r.methodss3-1.7.1/man/R.methodsS3-package.Rd 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/man/R.methodsS3-package.Rd 2020-02-14 03:32:22.000000000 +0000 @@ -25,10 +25,11 @@ \code{install.packages("R.methodsS3")} - To get the "devel" version, see \url{http://www.braju.com/R/}. + To get the "devel" version, see + \url{https://github.com/HenrikBengtsson/R.methodsS3/}. } -\section{Dependancies and other requirements}{ +\section{Dependencies and other requirements}{ This package only requires a standard \R installation. } @@ -65,7 +66,7 @@ } \references{ - [1] H. Bengtsson, \emph{The R.oo package - Object-Oriented Programming with References Using Standard R Code}, In Kurt Hornik, Friedrich Leisch and Achim Zeileis, editors, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), March 20-22, Vienna, Austria. \url{http://www.r-project.org/conferences/DSC-2003/Proceedings/} + [1] H. Bengtsson, \emph{The R.oo package - Object-Oriented Programming with References Using Standard R Code}, In Kurt Hornik, Friedrich Leisch and Achim Zeileis, editors, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), March 20-22, Vienna, Austria. \url{https://www.r-project.org/conferences/DSC-2003/Proceedings/} \cr } \keyword{package} diff -Nru r-cran-r.methodss3-1.7.1/man/setMethodS3.Rd r-cran-r.methodss3-1.8.0/man/setMethodS3.Rd --- r-cran-r.methodss3-1.7.1/man/setMethodS3.Rd 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/man/setMethodS3.Rd 2020-02-14 03:32:22.000000000 +0000 @@ -32,7 +32,7 @@ \item{class}{The class for which the method should be defined. If \code{class == "default"} a function with name \code{.default} will be created.} - \item{definition}{The method defintion.} + \item{definition}{The method definition.} \item{private, protected}{If \code{private=TRUE}, the method is declared private. If \code{protected=TRUE}, the method is declared protected. In all other cases the method is declared public.} @@ -55,7 +55,7 @@ the same class), different actions can be taken. If \code{"error"}, an exception will be thrown and the method will not be created. If \code{"warning"}, a \code{\link[base]{warning}} will be given and the method \emph{will} - be created, otherwise the conflict will be passed unnotice.} + be created, otherwise the conflict will be passed unnoticed.} \item{createGeneric, exportGeneric}{If \code{createGeneric=TRUE}, a generic S3/UseMethod function is defined for this method, iff missing, and \code{exportGeneric} species attribute @@ -106,7 +106,7 @@ } -# Your defintion; will redefine bar() above to bar.default(). +# Your definition; will redefine bar() above to bar.default(). setMethodS3("bar", "character", function(object, ...) { cat("In bar() for class 'character':\n"); print(object, ...); diff -Nru r-cran-r.methodss3-1.7.1/MD5 r-cran-r.methodss3-1.8.0/MD5 --- r-cran-r.methodss3-1.7.1/MD5 2016-02-16 12:48:09.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/MD5 2020-02-14 07:10:20.000000000 +0000 @@ -1,36 +1,38 @@ -ce1f0ae4eb9b0ad13759842bfe8b4379 *DESCRIPTION -bff607e7e05a4b10762bc1a225e11ed8 *NAMESPACE -fe2405991cbfd120c528b79de79778c3 *NEWS -2e86e8b470b9e59384be62210c3da00b *R/000.R -576ff223c1df906b32590e3e78d06d57 *R/001.R.KEYWORDS.R -1b1f9bd06d558a455d3f9374d2a378a3 *R/005.varArgs.R -f1d34d487e5092e88713531cf6f10a6c *R/006.fixVarArgs.R -085e40e0b603eb14de11e0fb86e6187b *R/010.setGenericS3.R -c2ca3d6adab3aefe4ff7ed3729583f70 *R/030.setMethodS3.R -a4ab3969cbc2da96a8a2c1c2ed77b206 *R/999.NonDocumentedObjects.R -18dce216cff64556a53b1cd3916184f8 *R/999.package.R -6a7f4e7757621f569c529f11eb8a1c1a *R/findDispatchMethodsS3.R -919beccc0425b2a5bd93bfe4fbf78264 *R/getDispatchMethodS3.R -0628c16ffde62e06702c6a4570bb9123 *R/getGenericS3.R -856008a212f94e54384665dae7c49e4e *R/getMethodS3.R -44f342186a376d7e38555b28de85936e *R/isGenericS3.R -91b40723acbdd29d4143330b862d61b3 *R/pkgStartupMessage.R -a1103ffdfd1c7ed50b0366f939d8549f *R/rccValidators.R -0e0caf77368e0fbee1650a5161a72a42 *R/throw.default.R +b605941ab867e80a6ae720140559b5dc *DESCRIPTION +5ba0f371553d70d18151e9da2bd50edc *NAMESPACE +72083915299446b326fc503cf5a2d9cd *NEWS +544d6e098c1f8f20a9c75e7063eecf4f *R/000.R +b6fedf6eec903c85f59d383d15983fc0 *R/001.R.KEYWORDS.R +51ecd8323217b75599a40978646b2407 *R/005.varArgs.R +1df04dc13e5ad8dbc137a07bad5a1af1 *R/006.fixVarArgs.R +2ec154beac75177376dd9c2778458acd *R/010.setGenericS3.R +a60f9ab55d6f4a518ee449db9184db20 *R/030.setMethodS3.R +8a1ef83fe9e11779f11a04d068e7918d *R/999.NonDocumentedObjects.R +760bda3a9fc83be2df7be8e06231e10c *R/999.package.R +76d19ef014a0702fe70d226f98d5fdf1 *R/findDispatchMethodsS3.R +40363fdcbf82aab8d2c5108792bd1735 *R/getDispatchMethodS3.R +6c847d1b632efb00d941a1eb23cbf6d7 *R/getGenericS3.R +8c0c4ab88c058f9f15d17b290bc2642a *R/getMethodS3.R +ce96a82dbbf247c8338a8124f2f0dc1b *R/isGenericS3.R +1b00320bdebb59cb0d86228cc839d89d *R/makeNamespace.R +2dea65413ed2dc7c64c651d060b8420a *R/pkgStartupMessage.R +e57c9ff235c9417f3e46431368ee4625 *R/rccValidators.R +670bbff94e5704528abd38280b983b18 *R/throw.default.R 87a07bdb31889de9bbb85b28e96db183 *R/zzz.R -d8150d1411942582b7175c2bd26bf5eb *inst/CITATION +221a5cb641badf6e5da59455778861ca *inst/CITATION +5ca40d7ba68d1842ff37a487642361e5 *inst/WORDLIST e62840f5029923bb7fde68ff03c85ba7 *man/Non-documented_objects.Rd 1b3a605645f2bf15b72946858f67a3bb *man/R.KEYWORDS.Rd -af63cbe05b850b79cfa16ebb9b0acd42 *man/R.methodsS3-package.Rd +4e0e780fddcd5a999d4ac9be4e415c27 *man/R.methodsS3-package.Rd 3b5bcb3544cfbf6faadca52e1ccc8c9d *man/findDispatchMethodsS3.Rd 48ee8839fd89e9512fdec95178ebf9bd *man/getDispatchMethodS3.Rd 47ca671f187d64cd06c73abfef5e20fe *man/getGenericS3.Rd 9594dc57bec938a16807c4b746ad3e78 *man/getMethodS3.Rd 0c3197129ab90808ee71e8de415dff11 *man/isGenericS3.Rd 4390144243165827fa06fd5e9077109b *man/isGenericS4.Rd -1e7a7b30b80214fe3325a50d61a998b5 *man/pkgStartupMessage.Rd +1ec8c68e31afd08566ef46903a60e5d2 *man/pkgStartupMessage.Rd d0ad086d52e72c12787dc638dd019a5a *man/setGenericS3.Rd -519552cddec0a9e862f9401ad0eb1206 *man/setMethodS3.Rd +830bb1b41ffb0d2fe6f208157381fa61 *man/setMethodS3.Rd 08f7aee8b35261e03de5cf4e245a405a *man/throw.Rd b24a7cd174fded033c7469ca5fe4f8b9 *tests/appendVarArgs.R 2afbc200a256afc37d33c7a6b0d75f74 *tests/attributes.R @@ -38,6 +40,6 @@ 533869ce20ae7fb3e73bd7f4a60c0dc6 *tests/getDispatchMethodS3.R f2a3e7bf4f61342c91f284944d7888a2 *tests/isGenericS3S4.R 1c3c57bf749393c8dff21b2a3089688b *tests/pkgStartupMessage.R -292f96279990101660ccb20487c0f851 *tests/setGenericS3.R -c200d5724ee5e90a244a72643f106394 *tests/setMethodS3.R +870ea909d3e0a14c511264b8c3dc724b *tests/setGenericS3.R +7b97e880f5819a2d04e4a715aa6e8f55 *tests/setMethodS3.R b452094c7796d50a9aa77eac96407479 *tests/throw.R diff -Nru r-cran-r.methodss3-1.7.1/NAMESPACE r-cran-r.methodss3-1.8.0/NAMESPACE --- r-cran-r.methodss3-1.7.1/NAMESPACE 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/NAMESPACE 2018-09-12 04:46:12.000000000 +0000 @@ -5,9 +5,7 @@ importFrom("utils", "getAnywhere") importFrom("utils", "getS3method") importFrom("utils", "head") - -## When package depends on R (>= 2.6.0) -## importFrom("codetools", "findGlobals") +importFrom("utils", "file_test") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru r-cran-r.methodss3-1.7.1/NEWS r-cran-r.methodss3-1.8.0/NEWS --- r-cran-r.methodss3-1.7.1/NEWS 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/NEWS 2020-02-14 03:14:11.000000000 +0000 @@ -1,91 +1,180 @@ Package: R.methodsS3 ==================== +Version: 1.8.0 [2020-02-13] + +SIGNIFICANT CHANGES: + + * Now setGenericS3() produce an error if it can not turn an existing function + into a "default" function and create a new generic function. Previously, + it produced a warning. + +NEW FEATURES: + + * Now setGenericS3() sets the 'S3class' attribute on any "default" methods + it creates, if any. + + * Add internal function R.methodsS3:::makeNamespace(pkg) for producing + S3method() statements to be put in a package's NAMESPACE file. + +CODE QUALITY: + + * Now formally suggesting 'codetools'. + +BUG FIXES: + + * R.methodsS3::setMethodS3() could produce 'Error in appendVarArgs( + ...R.oo.definition) : could not find function "appendVarArgs"' if the + R.methodsS3 package is not attached. + + * setMethodS3() and setGenericS3() failed to detect names 'NA_real_' etc. + as R keywords due to an 11 year old bug. + +DEPRECATED & DEFUNCT: + + * R.methodsS3::throw() is deprecated. Use base::stop(), or R.oo::throw(), + instead. + + Version: 1.7.1 [2016-02-15] -o Explicit namespace imports also from 'utils' package. -o CLEANUP: Package now requires R (>= 2.13.0) (April 2011). If really - needed on earlier version of R, it only takes a minor tweak, but - I won't do that unless really really needed. + +SIGNIFICANT CHANGES: + + * CLEANUP: Package now requires R (>= 2.13.0) (April 2011). If really needed + on earlier version of R, it only takes a minor tweak, but I won't do that + unless really really needed. + +CODE QUALITY: + + * Explicit namespace imports also from 'utils' package. Version: 1.7.0 [2015-02-19] -o ROBUSTNESS: Added several package tests. -o CONSISTENCY: Now isGenericS4() returns FALSE for non-existing - functions, just as isGenericS3() does. -o BUG FIX: isGenericS3() on a function gave error "object 'Math' of - mode 'function' was not found" when the 'methods' package was not - loaded, e.g. Rscript -e "R.methodsS3::isGenericS3(function(...) NULL)". -o BUG FIX/WORKAROUND: findDispatchMethodsS3() could in rare cases return - an extra set of false functions in R (< 3.1.2). This was due to a - bug in R (< 3.1.2) where the output of getAnywhere() contained - garbage results, e.g. getAnywhere(".Options")$objs. For backward - compatibility, findDispatchMethodsS3() now detects this case and works - around it. This bug was only detected after adding an explicit package - test for findDispatchMethodsS3(). + +NEW FEATURES: + + * CONSISTENCY: Now isGenericS4() returns FALSE for non-existing functions, + just as isGenericS3() does. + +CODE QUALITY: + + * ROBUSTNESS: Added several package tests. + +BUG FIXES: + + * isGenericS3() on a function gave error "object 'Math' of mode 'function' + was not found" when the 'methods' package was not loaded, e.g. + Rscript -e "R.methodsS3::isGenericS3(function(...) NULL)". + + * findDispatchMethodsS3() could in rare cases return an extra set of false + functions in R (< 3.1.2). This was due to a bug in R (< 3.1.2) where the + output of getAnywhere() contained garbage results, e.g. + getAnywhere(".Options")$objs. For backward compatibility, + findDispatchMethodsS3() now detects this case and works around it. This + bug was only detected after adding an explicit package test for + findDispatchMethodsS3(). Version: 1.6.2 [2014-05-04] -o CLEANUP: Internal directory restructuring. + +CODE QUALITY: + + * CLEANUP: Internal directory restructuring. Version: 1.6.1 [2014-01-04] -o CLEANUP: Dropped obsolete argument 'ellipsesOnly' from setGenericS3(). - It was not used. Thanks Antonio Piccolboni for reporting on this. + +CODE QUALITY: + + * CLEANUP: Dropped obsolete argument 'ellipsesOnly' from setGenericS3(). + It was not used. Thanks Antonio Piccolboni for reporting on this. Version: 1.6.0 [2013-11-12] -o BUG FIX: Generic function created by setGenericS3("foo<-") would not - have a last argument name 'value', which 'R CMD check' complains about. + +BUG FIXES: + + * Generic function created by setGenericS3("foo<-") would not have a last + argument name 'value', which 'R CMD check' complains about. Version: 1.5.3 [2013-11-05] -o ROBUSTNESS: Now setMethodS3(name, class, ...) and - setGenericS3(name, ...) assert that arguments 'name' and 'class' - are non-empty. + +NEW FEATURES: + + * ROBUSTNESS: Now setMethodS3(name, class, ...) and setGenericS3(name, ...) + assert that arguments 'name' and 'class' are non-empty. Version: 1.5.2 [2013-10-06] -o BETA: Added an in-official option to make setGenericS3() and - setMethodsS3() look for existing (generic) functions also in - imported namespaces. This will eventually become the default. -o ROBUSTNESS: Now isGenericS3() also compares to known generic - functions in the 'base' package. It also does a better job on - checking whether the function calls UseMethod() or not. -o Added argument 'inherits' to getGenericS3(). -o The above improvement of isGenericS3() means that setGenericS3() - does a better job to decided whether a generic function should be - created or not, which in turn means 'createGeneric=FALSE' is needed - much less in setMethodS3(). + +NEW FEATURES: + + * BETA: Added an in-official option to make setGenericS3() and setMethodsS3() + look for existing (generic) functions also in imported namespaces. This + will eventually become the default. + + * ROBUSTNESS: Now isGenericS3() also compares to known generic functions in + the 'base' package. It also does a better job on checking whether the + function calls UseMethod() or not. + + * Added argument 'inherits' to getGenericS3(). + + * The above improvement of isGenericS3() means that setGenericS3() does a + better job to decided whether a generic function should be created or not, + which in turn means 'createGeneric = FALSE' is needed much less in + setMethodS3(). Version: 1.5.1 [2013-09-15] -o BUG FIX: Forgot to explicitly import capture.output() from 'utils' - which could give an error on function "capture.output" not available - when setMethodS3() was used to define a "replacement" function. - This was only observed on the R v3.0.1 release version but not with - the more recent patched or devel versions. - In addition, two other 'utils' functions are now explicitly imported. + +BUG FIXES: + + * Forgot to explicitly import capture.output() from 'utils' which could give + an error on function "capture.output" not available when setMethodS3() was + used to define a "replacement" function. This was only observed on the + R v3.0.1 release version but not with the more recent patched or devel + versions. In addition, two other 'utils' functions are now explicitly + imported. Version: 1.5.0 [2013-08-29] -o Added pkgStartupMessage() which acknowledges library(..., quietly=TRUE). + +NEW FEATURES: + + * Added pkgStartupMessage() which acknowledges library(..., quietly = TRUE). Version: 1.4.5 [2013-08-23] -o CLEANUP: Dropped deprecated inst/HOWTOSITE replaced by inst/CITATION. -o CLEANUP: No longer utilizing ':::' for "self" (i.e. R.methodsS3) methods. + +CODE QUALITY: + + * CLEANUP: No longer utilizing ':::' for "self" (i.e. R.methodsS3) methods. + +DEPRECATED & DEFUNCT: + + * CLEANUP: Dropped deprecated inst/HOWTOSITE replaced by inst/CITATION. Version: 1.4.4 [2013-05-19] -o CRAN POLICY: Now all Rd \usage{} lines are at most 90 characters long. + +CODE QUALITY: + + * CRAN POLICY: Now all Rd \usage{} lines are at most 90 characters long. Version: 1.4.3 [2013-03-08] -o Added an Authors@R field to the DESCRIPTION. + +CODE QUALITY: + + * Added an Authors@R field to the DESCRIPTION. Version: 1.4.2 [2012-06-22] -o Now setMethodS3(..., appendVarArgs=TRUE) ignores 'appendVarArgs' if + +NEW FEATURES: + + * Now setMethodS3(..., appendVarArgs = TRUE) ignores 'appendVarArgs' if the method name is "==", "+", "-", "*", "/", "^", "%%", or "%/%", (in addition to "$", "$<-", "[[", "[[<-", "[", "[<-"). It will also ignore it if the name matches regular expressions "<-$" or "^%[^%]*%$". @@ -93,71 +182,113 @@ Version: 1.4.1 [2012-06-20] -o Added argument 'overwrite' to setGenericS3(). + +NEW FEATURES: + + * Added argument 'overwrite' to setGenericS3(). Version: 1.4.0 [2012-04-20] -o Now setMethodS3() sets attribute "S3class" to the class. -o Added argument 'export' to setMethodS3() and setGenericS3(), which - sets attribute "export" to the same value. + +NEW FEATURES: + + * Now setMethodS3() sets attribute "S3class" to the class. + + * Added argument 'export' to setMethodS3() and setGenericS3(), which sets + attribute "export" to the same value. Version: 1.3.0 [2012-04-16] -o Now only generic funcions are exported, and not all of them. -o Now all S3 methods are properly declared in NAMESPACE. + +SIGNIFICANT CHANGES: + + * Now only generic funcions are exported, and not all of them. + + * Now all S3 methods are properly declared in NAMESPACE. Version: 1.2.3 [2012-03-08] -o Now arguments '...' of setMethodS3() are passed to setGenericS3(). + +NEW FEATURES: + + * Now arguments '...' of setMethodS3() are passed to setGenericS3(). Version: 1.2.2 [2011-11-17] -o CLEANUP: Dropped example(getMethodS3), which was for setMethodS3(). + +DOCUMENTATION: + + * CLEANUP: Dropped example(getMethodS3), which was for setMethodS3(). Version: 1.2.1 [2010-09-18] -o BUG FIX: isGenericS3(), isGenericS4(), getGenericS3() and getMethodS3() - failed to locate functions created in the global environment while - there exist a function with the same name in the 'base' package. - The problem only affects the above functions and nothing else and it - did not exist prior to R.methodsS3 v1.2.0 when the package did not yet - have a namespace. Thanks John Oleynick for reporting on this problem. -o BUG FIX: isGenericS3() and isGenericS4() did not support specifying - the function by name as a character string, despite it was documented - to do so. Thanks John Oleynick for reporting on this. + +BUG FIXES: + + * isGenericS3(), isGenericS4(), getGenericS3() and getMethodS3() failed to + locate functions created in the global environment while there exist a + function with the same name in the 'base' package. The problem only affected + the above functions and nothing else and it did not exist prior to + R.methodsS3 v1.2.0 when the package did not yet have a namespace. Thanks + John Oleynick for reporting on this problem. + + * isGenericS3() and isGenericS4() did not support specifying the function by + name as a character string, despite it was documented to do so. Thanks + John Oleynick for reporting on this. Version: 1.2.0 [2010-03-13] -o Added a NAMESPACE. + +CODE QUALITY: + + * Added a NAMESPACE. Version: 1.1.0 [2010-01-02] -o Added getDispatchMethodS3() and findDispatchMethodsS3(). + +NEW FEATURES: + + * Added getDispatchMethodS3() and findDispatchMethodsS3(). Version: 1.0.3 [2008-07-02] -o Renamed HISTORY file to NEWS. + +CODE QUALITY: + + * Renamed HISTORY file to NEWS. Version: 1.0.2 [2008-05-08] -o Added getMethodS3() and getGenericS3(). -o BUG FIX: isGenericS3() and isGenericS4() gave an error if - a function was passed. + +NEW FEATURES: + + * Added getMethodS3() and getGenericS3(). + +BUG FIXES: + + * isGenericS3() and isGenericS4() gave an error if a function was passed. Version: 1.0.1 [2008-03-06] -o Added paper to citation("R.methodsS3"). -o BUG FIX: Regular expression pattern 'a-Z' is illegal on (at least) - some locale, e.g. 'C' (where 'A-z' works). The only way to specify - the ASCII alphabet is to list all characters explicitly, which we now - do in all methods of the package. See the r-devel thread - "invalid regular expression '[a-Z]'" on 2008-03-05 for details. + +DOCUMENTATION: + + * Added paper to citation("R.methodsS3"). + +BUG FIXES: + + * Regular expression pattern 'a-Z' is illegal on (at least) some locale, e.g. + 'C' (where 'A-z' works). The only way to specify the ASCII alphabet is to + list all characters explicitly, which we now do in all methods of the + package. See the r-devel thread "invalid regular expression '[a-Z]'" on + 2008-03-05 for details. Version: 1.0.0 [2007-09-17] -o Created by extracting setMethodS3() and related methods from the - R.oo package. The purpose is to provide setMethodS3() without - having to load (the already lightweight) R.oo package. For - previous history related to the methods in this package, please - see the history of the R.oo package. +SIGNIFICANTLY CHANGES: + + * Created by extracting setMethodS3() and related methods from the R.oo + package. The purpose is to provide setMethodS3() without having to load + (the already lightweight) R.oo package. For previous history related to + the methods in this package, please see the history of the R.oo package. diff -Nru r-cran-r.methodss3-1.7.1/R/000.R r-cran-r.methodss3-1.8.0/R/000.R --- r-cran-r.methodss3-1.7.1/R/000.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/000.R 2018-09-12 04:46:12.000000000 +0000 @@ -8,20 +8,20 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Sets attribute export to TRUE export <- function(x) { - attr(x, "export") <- TRUE; - x; + attr(x, "export") <- TRUE + x } export <- export(export) # Sets attribute export to 'value'. "export<-" <- export(function(x, value) { - attr(x, "export") <- value; - x; + attr(x, "export") <- value + x }) noexport <- export(function(x) { - attr(x, "export") <- FALSE; - x; + attr(x, "export") <- FALSE + x }) @@ -30,8 +30,8 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Sets attribute 'S3class' to 'value'. "S3class<-" <- export(function(x, value) { - attr(x, "S3class") <- value; - x; + attr(x, "S3class") <- value + x }) @@ -40,21 +40,21 @@ .findFunction <- function(name, envir, inherits=rep(FALSE, times=length(envir))) { # Argument 'envir': if (!is.list(envir)) { - envir <- list(envir); + envir <- list(envir) } - n <- length(envir); + n <- length(envir) # Argument 'inherits': - inherits <- as.logical(inherits); - stopifnot(length(inherits) == n); + inherits <- as.logical(inherits) + stopifnot(length(inherits) == n) - fcn <- pkg <- NULL; + fcn <- pkg <- NULL for (kk in seq_along(envir)) { - env <- envir[[kk]]; - inh <- inherits[kk]; + env <- envir[[kk]] + inh <- inherits[kk] if (exists(name, mode="function", envir=env, inherits=inh)) { - fcn <- get(name, mode="function", envir=env, inherits=inh); - pkg <- attr(env, "name"); + fcn <- get(name, mode="function", envir=env, inherits=inh) + pkg <- attr(env, "name") if (is.null(pkg)) { pkg <- "base" if (identical(env, baseenv())) { @@ -62,53 +62,11 @@ pkg <- "" } } else { - pkg <- gsub("^package:", "", pkg); + pkg <- gsub("^package:", "", pkg) } - break; + break } } # for (kk ...) - list(fcn=fcn, pkg=pkg); + list(fcn=fcn, pkg=pkg) } # .findFunction() - - -############################################################################ -# HISTORY: -# 2013-10-06 -# o Added .findFunction(). -# 2012-04-17 -# o Added S3class() function. -# o Added export() and noexport() functions. -# 2007-09-17 -# o Removed support for R v2.2.0 and before by removing patch for missing -# baseenv(). -# 2007-04-07 -# o Removed support for R v2.0.0 and before. -# 2006-02-09 -# o Added baseenv() for R versions (< v2.2.0) where it does not exist. -# This is used in setGenericS3() and setMethodS3() from R v2.3.0. -# 2005-02-15 -# o Now require() is only called for R v1.9.1 or eariler. -# 2005-02-10 -# o Moved R.KEYWORDS into its own source file. -# 2003-05-06 -# o Added require(methods) to make sure getMethods() etc works. -# 2002-11-21 -# o Added "..." to R.KEYWORDS. -# 2002-10-17 -# o Removed obsolete "modifiers<-"(). -# o Added also "Object" to the class attribute to make static methods to -# work. -# 2002-10-16 -# o There are times when -# generic <- function(...) UseMethod() -# is not working, for example -# fcn <- get("generic"); fcn(myObj, ...); -# For this reason, always do method dispatching using the name explicitly; -# generic <- function(...) UseMethod("generic") -# -# 2002-10-15 -# o Created from R.oo Object.R and ideas as described on -# http://www.maths.lth.se/help/R/ -############################################################################ - diff -Nru r-cran-r.methodss3-1.7.1/R/001.R.KEYWORDS.R r-cran-r.methodss3-1.8.0/R/001.R.KEYWORDS.R --- r-cran-r.methodss3-1.7.1/R/001.R.KEYWORDS.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/001.R.KEYWORDS.R 2019-12-09 00:49:23.000000000 +0000 @@ -22,19 +22,7 @@ R.KEYWORDS <- c( "break", "else", "for", "function", "if", "in", "next", "repeat", "while", "TRUE", "FALSE", "Inf", "NULL", "NA", "NaN", - paste("NA_", c("integer", "real", "complex", "character", "_", sep="")), + paste("NA_", c("integer", "real", "complex", "character"), "_", sep=""), "...", paste("..", 1:99, sep="") -); -export(R.KEYWORDS) <- FALSE; - - -############################################################################ -# HISTORY: -# 2007-09-17 -# o Updated. Added 'NA__' keywords. -# 2005-02-10 -# o Moved into its own source code file. Extracted from 000.GLOBALS.R. -# 2002-11-21 -# o Added "..." to R.KEYWORDS. -############################################################################ - +) +export(R.KEYWORDS) <- FALSE diff -Nru r-cran-r.methodss3-1.7.1/R/005.varArgs.R r-cran-r.methodss3-1.8.0/R/005.varArgs.R --- r-cran-r.methodss3-1.7.1/R/005.varArgs.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/005.varArgs.R 2018-09-12 04:46:12.000000000 +0000 @@ -1,41 +1,34 @@ -hasVarArgs <- function(...) UseMethod("hasVarArgs"); -export(hasVarArgs) <- TRUE; +hasVarArgs <- function(...) UseMethod("hasVarArgs") +export(hasVarArgs) <- TRUE hasVarArgs.function <- function(fcn, ...) { if (!is.function(fcn)) - stop("Argument 'fcn' must be a function: ", mode(fcn)); + stop("Argument 'fcn' must be a function: ", mode(fcn)) # Get the current formals - args <- formals(fcn); + args <- formals(fcn) - is.element("...", names(args)); + is.element("...", names(args)) } # hasVarArgs() -S3class(hasVarArgs.function) <- "function"; -export(hasVarArgs.function) <- FALSE; +S3class(hasVarArgs.function) <- "function" +export(hasVarArgs.function) <- FALSE -appendVarArgs <- function(...) UseMethod("appendVarArgs"); -export(appendVarArgs) <- TRUE; +appendVarArgs <- function(...) UseMethod("appendVarArgs") +export(appendVarArgs) <- TRUE appendVarArgs.function <- function(fcn, ...) { if (hasVarArgs(fcn)) - return(fcn); + return(fcn) # Get the current formals - args <- formals(fcn); + args <- formals(fcn) # Add '...' - args <- c(args, formals(function(...) {})); + args <- c(args, formals(function(...) {})) # Set new formals - formals(fcn) <- args; + formals(fcn) <- args - fcn; + fcn } # appendVarArgs() -S3class(appendVarArgs.function) <- "function"; -export(appendVarArgs.function) <- FALSE; - - -############################################################################ -# HISTORY: -# 2005-02-15 -# o Created. -############################################################################ +S3class(appendVarArgs.function) <- "function" +export(appendVarArgs.function) <- FALSE diff -Nru r-cran-r.methodss3-1.7.1/R/006.fixVarArgs.R r-cran-r.methodss3-1.8.0/R/006.fixVarArgs.R --- r-cran-r.methodss3-1.7.1/R/006.fixVarArgs.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/006.fixVarArgs.R 2018-09-12 04:46:12.000000000 +0000 @@ -1,9 +1,2 @@ # Added '...' to some base functions. These will later be # turned into default functions by setMethodS3(). - - -############################################################################ -# HISTORY: -# 2005-02-15 -# o Created to please R CMD check. -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/010.setGenericS3.R r-cran-r.methodss3-1.8.0/R/010.setGenericS3.R --- r-cran-r.methodss3-1.7.1/R/010.setGenericS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/010.setGenericS3.R 2020-02-14 01:55:14.000000000 +0000 @@ -49,17 +49,17 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'name': if (nchar(name) == 0L) { - stop("Cannot set S3 generic method. Argument 'name' is empty."); + stop("Cannot set S3 generic method. Argument 'name' is empty.") } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Backward compatibility tests # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - args <- list(...); + args <- list(...) if (is.element("enforceRCC", names(args))) { - warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'."); + warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'.") # Turn off validators? - if (args$enforceRCC == FALSE) validators <- NULL; + if (args$enforceRCC == FALSE) validators <- NULL } @@ -70,14 +70,14 @@ # maybe load and set the new get, which is then a generic function, and the # next thing it will try to get() (it uses get internally) will not be # retrieved, since get.default() might not be loaded at this time, but later. - PROTECTED.NAMES <- c("get"); + PROTECTED.NAMES <- c("get") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 1. Test the definition using validators # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (!is.null(validators)) { for (validator in validators) { - validator(name=name, envir=envir, dontWarn=dontWarn, type="setGenericS3"); + validator(name=name, envir=envir, dontWarn=dontWarn, type="setGenericS3") } } @@ -85,10 +85,10 @@ # 2. Check for forbidden names # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (is.element(name, R.KEYWORDS)) - stop("Method names must not be same as a reserved keyword in R: ", name); + stop("Method names must not be same as a reserved keyword in R: ", name) if (is.element(name, PROTECTED.NAMES)) - stop("Trying to use an unsafe generic method name (trust us, it is for a *good* reason): ", name); + stop("Trying to use an unsafe generic method name (trust us, it is for a *good* reason): ", name) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 2. Find the environment where sys.source() loads the package, which is @@ -102,12 +102,12 @@ # find it. *Not* checking the currently loading environment would *not* # be harmful, but it would produce too many warnings. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sys.source.def <- get("sys.source", mode="function", envir=baseenv()); - loadenv <- NULL; + sys.source.def <- get("sys.source", mode="function", envir=baseenv()) + loadenv <- NULL for (framePos in sys.parents()[-1L]) { if (identical(sys.source.def, sys.function(framePos))) { - loadenv <- parent.frame(framePos); - break; + loadenv <- parent.frame(framePos) + break } } @@ -117,146 +117,80 @@ # ii) in the currently loading environment ('loadenv'), or # iii) in the environments in the search path (search()). # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - envirs <- c(envir, loadenv, lapply(search(), FUN=as.environment)); - inherits <- rep(FALSE, times=length(envirs)); - checkImports <- getOption("R.methodsS3:checkImports:setGenericS3", FALSE); - if (checkImports) inherits[1:2] <- TRUE; - - fcn <- .findFunction(name, envir=envirs, inherits=inherits); - fcnDef <- fcn$fcn; - fcnPkg <- fcn$pkg; + envirs <- c(envir, loadenv, lapply(search(), FUN=as.environment)) + inherits <- rep(FALSE, times=length(envirs)) + checkImports <- getOption("R.methodsS3:checkImports:setGenericS3", FALSE) + if (checkImports) inherits[1:2] <- TRUE + + fcn <- .findFunction(name, envir=envirs, inherits=inherits) + fcnDef <- fcn$fcn + fcnPkg <- fcn$pkg if (!overwrite && !is.null(fcnDef)) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 4a. Is it already a generic function? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - isGeneric <- isGenericS3(fcnDef) || isGenericS4(fcnDef); + isGeneric <- isGenericS3(fcnDef) || isGenericS4(fcnDef) # If it is a generic function, we are done! if (isGeneric) { # TO DO: Update generic functions with '...', if missing. - return(); + return() } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 4b. ... or, is there already a default function with the same name? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Search for preexisting default function in the same environments as above. - nameDefault <- paste(name, ".default", sep=""); - fcn <- .findFunction(nameDefault, envir=envirs, inherits=inherits); - defaultExists <- !is.null(fcn$fcn); - defaultPkg <- fcn$pkg; + nameDefault <- paste(name, ".default", sep="") + fcn <- .findFunction(nameDefault, envir=envirs, inherits=inherits) + defaultExists <- !is.null(fcn$fcn) + defaultPkg <- fcn$pkg if (defaultExists) { - warning("Could not create generic function. There is already a", - " non-generic function named ", name, "() in package ", fcnPkg, - " with the same name as an existing default function ", - nameDefault, "() in ", defaultPkg, "."); - return(); + msg <- paste("Could not create generic function. There is already a non-generic function named ", name, "() in package ", fcnPkg, " with the same name as an existing default function ", nameDefault, "() in ", defaultPkg, ".", sep = "") + action <- Sys.getenv("R_R_METHODSS3_SETGENERICS3_ONDEFAULTEXISTS", "error") + action <- getOption("R.methodsS3.setGenericS3.onDefaultExists", action) + if (identical(action, "error")) { + stop(msg) + } else { + warning(msg) + return() + } } + ## Assign 'S3class' attribute (an R.methodsS3 thing) + attr(fcnDef, "S3class") <- "default" + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 4c. "Rename" the function to a default function # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - assign(nameDefault, substitute(fcn, list(fcn=fcnDef)), envir=envir); + assign(nameDefault, substitute(fcn, list(fcn=fcnDef)), envir=envir) if (!is.element(fcnPkg, dontWarn)) { warning("Renamed the preexisting function ", name, " to ", - nameDefault, ", which was defined in environment ", fcnPkg, "."); + nameDefault, ", which was defined in environment ", fcnPkg, ".") } } # if (...) # By default all generic functions have '...' arguments - argsStr <- "..."; + argsStr <- "..." # Should argument 'value' be added? - isReplacementFunction <- (regexpr("<-$", name) != -1L); + isReplacementFunction <- (regexpr("<-$", name) != -1L) if (isReplacementFunction) { - argsStr <- paste(c(argsStr, "value"), collapse=", "); + argsStr <- paste(c(argsStr, "value"), collapse=", ") } # Create a generic function - src <- sprintf("...tmpfcn <- function(%s) UseMethod(\"%s\")", argsStr, name); - src <- c(src, sprintf("R.methodsS3:::export(...tmpfcn) <- %s", export)); - src <- c(src, sprintf("\"%s\" <- ...tmpfcn", name)); - src <- c(src, "rm(list=\"...tmpfcn\")"); - src <- paste(src, collapse=";\n"); - expr <- parse(text=src); - eval(expr, envir=envir); + src <- sprintf("...tmpfcn <- function(%s) UseMethod(\"%s\")", argsStr, name) + src <- c(src, sprintf("R.methodsS3:::export(...tmpfcn) <- %s", export)) + src <- c(src, sprintf("\"%s\" <- ...tmpfcn", name)) + src <- c(src, "rm(list=\"...tmpfcn\")") + src <- paste(src, collapse=";\n") + expr <- parse(text=src) + eval(expr, envir=envir) } # setGenericS3.default() -S3class(setGenericS3.default) <- "default"; -export(setGenericS3.default) <- FALSE; +S3class(setGenericS3.default) <- "default" +export(setGenericS3.default) <- FALSE -setGenericS3.default("setGenericS3"); # Creates itself ;) - - - - -############################################################################ -# HISTORY: -# 2014-01-04 -# o CLEANUP: Dropped obsolete argument 'ellipsesOnly' from setGenericS3(). -# It was not used internally anyway. Thanks Antonio Piccolboni for -# reporting on this. -# 2013-11-12 -# o BUG FIX: Generic function created by setGenericS3("foo<-") would not -# have a last argument name 'value', which 'R CMD check' complains about. -# 2013-11-05 -# o ROBUSTNESS: Now setGenericS3(name, ...) asserts that argument -# 'name' is non-empty. -# 2013-10-06 -# o CLEANUP: setGenericS3() utilizes new .findFunction(). -# 2013-10-05 -# o Now setGenericS3() fully utilizes isGenericS3(). -# o Now setGenericS3() looks for existing generic functions also in -# imported namespaces. -# 2012-06-17 -# o Added argument 'overwrite' to setGenericS3(). -# 2012-04-17 -# o Added argument 'export' to setMethodS3() and setGenericS3(). -# 2007-09-17 -# o Replaced 'enforceRCC' argument with more generic 'validators'. -# 2007-06-09 -# o Removed (incorrect) argument name 'list' from all substitute() calls. -# 2006-02-09 -# o Removed all usage of NULL environments. get(envir=NULL) is replaced -# with get(envir=baseenv()). -# 2005-06-14 -# o Now setGenericS3() allows a few methods that starts with a non-letter -# as the first character. See code for details. -# 2005-02-15 -# o Added arguments '...' in order to match any generic functions. -# 2004-06-27 -# o Added known generic function 'as.vector()'. -# 2003-07-07 -# o Removed obsolete argument 'force' in Rdoc. -# 2002-11-29 -# o Updated some error messages. -# o Now it is possible to create generic methods with one (or several) -# . (period) as a prefix of the name. Such a method should be considered -# private in the same manner as fields with a period are private. -# 2002-11-28 -# o SPELL CHECK: "...name name..." in one of setGenericS3()'s error messages. -# 2002-11-10 -# o Updated setGenericS3() to assert that the environment variable 'envir' -# is actually the one in the frame of the sys.source() function call. This -# is done by comparing function defintions. -# o Changed setGenericS3() to *always* create generic functions with no -# arguments except "...". -# 2002-10-21 -# o Made ellipsesOnly=TRUE by default. -# 2002-10-17 -# o Removed obsolete "modifiers<-"(). -# o Added also "Object" to the class attribute to make static methods to -# work. -# 2002-10-16 -# o There are times when -# generic <- function(...) UseMethod() -# is not working, for example -# fcn <- get("generic"); fcn(myObj, ...); -# For this reason, always do method dispatching using the name explicitly; -# generic <- function(...) UseMethod("generic") -# -# 2002-10-15 -# o Created from R.oo Object.R and ideas as described on -# http://www.maths.lth.se/help/R/ -############################################################################ +setGenericS3.default("setGenericS3") # Creates itself ;) diff -Nru r-cran-r.methodss3-1.7.1/R/030.setMethodS3.R r-cran-r.methodss3-1.8.0/R/030.setMethodS3.R --- r-cran-r.methodss3-1.7.1/R/030.setMethodS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/030.setMethodS3.R 2018-09-12 04:47:13.000000000 +0000 @@ -17,7 +17,7 @@ # \item{class}{The class for which the method should be defined. If # \code{class == "default"} a function with name \code{.default} # will be created.} -# \item{definition}{The method defintion.} +# \item{definition}{The method definition.} # \item{private, protected}{If \code{private=TRUE}, the method is declared # private. If \code{protected=TRUE}, the method is declared protected. # In all other cases the method is declared public.} @@ -40,7 +40,7 @@ # the same class), different actions can be taken. If \code{"error"}, # an exception will be thrown and the method will not be created. # If \code{"warning"}, a @warning will be given and the method \emph{will} -# be created, otherwise the conflict will be passed unnotice.} +# be created, otherwise the conflict will be passed unnoticed.} # \item{createGeneric, exportGeneric}{If \code{createGeneric=TRUE}, # a generic S3/UseMethod function is defined for this method, # iff missing, and \code{exportGeneric} species attribute @@ -72,26 +72,26 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'name': if (nchar(name) == 0L) { - stop("Cannot set S3 method. Argument 'name' is empty."); + stop("Cannot set S3 method. Argument 'name' is empty.") } # Argument 'class': if (nchar(class) == 0L) { - stop("Cannot set S3 method. Argument 'class' is empty."); + stop("Cannot set S3 method. Argument 'class' is empty.") } # Argument 'conflict': - conflict <- match.arg(conflict); + conflict <- match.arg(conflict) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Backward compatibility tests # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - args <- list(...); + args <- list(...) if (is.element("enforceRCC", names(args))) { - warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'."); + warning("Argument 'enforceRCC' of setGenericS3() has been replaced by argument 'validators'.") # Turn off validators? - if (!args$enforceRCC) validators <- NULL; + if (!args$enforceRCC) validators <- NULL } @@ -100,7 +100,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (!is.null(validators)) { for (validator in validators) { - validator(name=name, class=class, definition=definition, private=private, protected=protected, static=static, abstract=abstract, trial=trial, deprecated=deprecated, envir=envir, overwrite=overwrite, conflict=conflict, createGeneric=createGeneric, appendVarArgs=appendVarArgs, type="setMethodS3"); + validator(name=name, class=class, definition=definition, private=private, protected=protected, static=static, abstract=abstract, trial=trial, deprecated=deprecated, envir=envir, overwrite=overwrite, conflict=conflict, createGeneric=createGeneric, appendVarArgs=appendVarArgs, type="setMethodS3") } } @@ -108,24 +108,24 @@ # or a replacement method. if (appendVarArgs) { # (a) Do not append '...' for the following methods - ignores <- c("$", "$<-", "[[", "[[<-", "[", "[<-"); - ignores <- c(ignores, "=="); - ignores <- c(ignores, "+", "-", "*", "/", "^", "%%", "%/%"); - appendVarArgs <- !is.element(name, ignores); + ignores <- c("$", "$<-", "[[", "[[<-", "[", "[<-") + ignores <- c(ignores, "==") + ignores <- c(ignores, "+", "-", "*", "/", "^", "%%", "%/%") + appendVarArgs <- !is.element(name, ignores) if (appendVarArgs) { # (b) Neither functions with any of these name patterns - ignorePatterns <- c("<-$", "^%[^%]*%$"); - ignores <- (sapply(ignorePatterns, FUN=regexpr, name) != -1L); - appendVarArgs <- appendVarArgs && !any(ignores); + ignorePatterns <- c("<-$", "^%[^%]*%$") + ignores <- (sapply(ignorePatterns, FUN=regexpr, name) != -1L) + appendVarArgs <- appendVarArgs && !any(ignores) } } # Check for forbidden names. if (is.element(name, R.KEYWORDS)) - stop("Method names must not be same as a reserved keyword in R: ", name); + stop("Method names must not be same as a reserved keyword in R: ", name) - if (class == "ANY") class <- "default"; + if (class == "ANY") class <- "default" # Create the modifiers if (private) @@ -133,18 +133,18 @@ else if (protected) protection <- "protected" else - protection <- "public"; + protection <- "public" - modifiers <- protection; - if (static == TRUE) modifiers <- c(modifiers, "static"); - if (abstract == TRUE) modifiers <- c(modifiers, "abstract"); - if (deprecated == TRUE) modifiers <- c(modifiers, "deprecated"); - if (trial == TRUE) modifiers <- c(modifiers, "trial"); + modifiers <- protection + if (static == TRUE) modifiers <- c(modifiers, "static") + if (abstract == TRUE) modifiers <- c(modifiers, "abstract") + if (deprecated == TRUE) modifiers <- c(modifiers, "deprecated") + if (trial == TRUE) modifiers <- c(modifiers, "trial") if (missing(definition) && abstract == TRUE) { # Set default 'definition'. - src <- paste("...R.oo.definition <- function(...) stop(\"Method \\\"", name, "\\\" is defined abstract in class \\\"", class, "\\\" and has not been overridden by any of the subclasses: \", class(list(...)[[1]])[1])", sep=""); - expr <- parse(text=src); + src <- paste("...R.oo.definition <- function(...) stop(\"Method \\\"", name, "\\\" is defined abstract in class \\\"", class, "\\\" and has not been overridden by any of the subclasses: \", class(list(...)[[1]])[1])", sep="") + expr <- parse(text=src) # If just defining a local 'definition' function, to be used below, # one will get warnings "using .GlobalEnv instead of package:" @@ -152,14 +152,14 @@ # the reasons for it, but here follows a trick in order to not get # such warnings. It kinda borrows the 'envir' frame to define a local # function. It works, but don't ask me why. /HB 2005-02-25 - eval(expr, envir=envir); - definition <- get("...R.oo.definition", envir=envir); - rm(list="...R.oo.definition", envir=envir); + eval(expr, envir=envir) + definition <- get("...R.oo.definition", envir=envir) + rm(list="...R.oo.definition", envir=envir) } # Create the class method 'name': - methodName <- paste(name, class, sep="."); + methodName <- paste(name, class, sep=".") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 2. Find the environment where sys.source() loads the package, which is @@ -173,12 +173,12 @@ # find it. *Not* checking the currently loading environment would *not* # be harmful, but it would produce too many warnings. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sys.source.def <- get("sys.source", mode="function", envir=baseenv()); - loadenv <- NULL; + sys.source.def <- get("sys.source", mode="function", envir=baseenv()) + loadenv <- NULL for (framePos in sys.parents()[-1L]) { if (identical(sys.source.def, sys.function(framePos))) { - loadenv <- parent.frame(framePos); - break; + loadenv <- parent.frame(framePos) + break } } @@ -189,13 +189,13 @@ # ii) in the currently loading environment ('loadenv'), or # iii) in the environments in the search path (search()). # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - envirs <- c(envir, loadenv, lapply(search(), FUN=as.environment)); - inherits <- rep(FALSE, times=length(envirs)); - checkImports <- getOption("R.methodsS3:checkImports:setGenericS3", FALSE); - if (checkImports) inherits[1:2] <- TRUE; + envirs <- c(envir, loadenv, lapply(search(), FUN=as.environment)) + inherits <- rep(FALSE, times=length(envirs)) + checkImports <- getOption("R.methodsS3:checkImports:setGenericS3", FALSE) + if (checkImports) inherits[1:2] <- TRUE - fcn <- .findFunction(methodName, envir=envirs, inherits=inherits); - fcnDef <- fcn$fcn; fcnPkg <- fcn$pkg; + fcn <- .findFunction(methodName, envir=envirs, inherits=inherits) + fcnDef <- fcn$fcn; fcnPkg <- fcn$pkg # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -203,15 +203,15 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (appendVarArgs) { if (!hasVarArgs(definition)) { - warning("Added missing argument '...' to make it more compatible with a generic function: ", methodName); -# definition <- appendVarArgs(definition); + warning("Added missing argument '...' to make it more compatible with a generic function: ", methodName) +# definition <- appendVarArgs(definition) # As above, to avoid "using .GlobalEnv instead of package:" # warnings, we do the below trick. /HB 2005-02-25 - assign("...R.oo.definition", definition, envir=envir); - eval(substitute(fcn <- appendVarArgs(fcn), list(fcn=as.name("...R.oo.definition"))), envir=envir); - definition <- get("...R.oo.definition", envir=envir); - rm(list="...R.oo.definition", envir=envir); + assign("...R.oo.definition", definition, envir=envir) + eval(substitute(fcn <- R.methodsS3::appendVarArgs(fcn), list(fcn=as.name("...R.oo.definition"))), envir=envir) + definition <- get("...R.oo.definition", envir=envir) + rm(list="...R.oo.definition", envir=envir) } } @@ -219,16 +219,16 @@ # 5. Validate replacement functions (since R CMD check will complain) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (regexpr("<-$", name) != -1L) { - f <- formals(definition); + f <- formals(definition) - fStr <- capture.output(args(definition))[[1]]; - fStr <- sub("^[\t\n\f\r ]*", "", fStr); # trim() is not available - fStr <- sub("[\t\n\f\r ]*$", "", fStr); # when package loads! + fStr <- capture.output(args(definition))[[1]] + fStr <- sub("^[\t\n\f\r ]*", "", fStr) # trim() is not available + fStr <- sub("[\t\n\f\r ]*$", "", fStr) # when package loads! if (names(f)[length(f)] != "value") { ## covr: skip=2 stop("Last argument of a ", name, - "() method should be named 'value': ", fStr); + "() method should be named 'value': ", fStr) } } @@ -237,32 +237,32 @@ # 5b. Validate arguments for 'picky' methods. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pickyMethods <- list( - "$" = c(NA, "name"), - "$<-" = c(NA, "name", "value") + "$" = c(NA_character_, "name"), + "$<-" = c(NA_character_, "name", "value") ) if (is.element(name, names(pickyMethods))) { - f <- formals(definition); + f <- formals(definition) - fStr <- capture.output(args(definition))[[1L]]; - fStr <- sub("^[\t\n\f\r ]*", "", fStr); # trim() is not available - fStr <- sub("[\t\n\f\r ]*$", "", fStr); # when package loads! + fStr <- capture.output(args(definition))[[1L]] + fStr <- sub("^[\t\n\f\r ]*", "", fStr) # trim() is not available + fStr <- sub("[\t\n\f\r ]*$", "", fStr) # when package loads! - reqArgs <- pickyMethods[[name]]; - nbrOfReqArgs <- length(reqArgs); + reqArgs <- pickyMethods[[name]] + nbrOfReqArgs <- length(reqArgs) # Check for correct number of arguments if (length(f) != nbrOfReqArgs) { ## covr: skip=2 stop("There should be exactly ", nbrOfReqArgs, " arguments of a ", - name, "() method: ", fStr); + name, "() method: ", fStr) } for (kk in 1:nbrOfReqArgs) { if (!is.na(reqArgs[kk]) && (names(f)[kk] != reqArgs[kk])) { ## covr: skip=2 stop("Argument #", kk, " in a ", name, - "() method, should be named '", reqArgs[kk], "': ", fStr); + "() method, should be named '", reqArgs[kk], "': ", fStr) } } } @@ -274,18 +274,18 @@ if (is.null(fcnDef) || overwrite) { # Create expr <- substitute({ - fcn <- definition; + fcn <- definition `R.methodsS3_export<-` <- get("export<-", mode="function", - envir=asNamespace("R.methodsS3"), inherits=FALSE); - R.methodsS3_export(fcn) <- doExport; - rm(list="R.methodsS3_export<-"); - attr(fcn, "S3class") <- class; - attr(fcn, "modifiers") <- modifiers; + envir=asNamespace("R.methodsS3"), inherits=FALSE) + R.methodsS3_export(fcn) <- doExport + rm(list="R.methodsS3_export<-") + attr(fcn, "S3class") <- class + attr(fcn, "modifiers") <- modifiers }, list(fcn=as.name(methodName), class=class, definition=definition, doExport=export, modifiers=modifiers) - ); + ) # Assign - eval(expr, envir=envir); + eval(expr, envir=envir) } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -293,9 +293,9 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (!is.null(fcnDef)) { msg <- paste("Method already existed and was", - if (overwrite != TRUE) " not", " overwritten: ", sep=""); + if (overwrite != TRUE) " not", " overwritten: ", sep="") if (is.null(conflict)) - conflict <- "quiet"; + conflict <- "quiet" if (conflict == "quiet") { } else if (conflict == "warning") { warning(msg, methodName) @@ -307,95 +307,10 @@ # 8. Create a generic function? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (createGeneric) { - setGenericS3(name, export=exportGeneric, envir=envir, validators=validators, ...); + setGenericS3(name, export=exportGeneric, envir=envir, validators=validators, ...) } } # setMethodS3.default() -S3class(setMethodS3.default) <- "default"; -export(setMethodS3.default) <- FALSE; +S3class(setMethodS3.default) <- "default" +export(setMethodS3.default) <- FALSE -setGenericS3("setMethodS3"); - - -############################################################################ -# HISTORY: -# 2013-11-05 -# o ROBUSTNESS: Now setMethodS3(name, class, ...) asserts that arguments -# 'name' and 'class' are non-empty. -# 2013-10-06 -# o CLEANUP: setGenericS3() utilizes new .findFunction(). -# 2012-08-23 -# o No longer utilizing ':::' for "self" (i.e. R.methods3) methods. -# 2012-06-22 -# o Now setMethodS3(..., appendVarArgs=TRUE) ignores 'appendVarArgs' if -# the method name is "==", "+", "-", "*", "/", "^", "%%", or "%/%", -# (in addition to "$", "$<-", "[[", "[[<-", "[", "[<-"). It will also -# ignore it if the name matches regular expressions "<-$" or "^%[^%]*%$". -# 2012-04-17 -# o Added argument 'exportGeneric' to setMethodS3(). -# o Added argument 'export' to setMethodS3() and setGenericS3(). -# o Now setMethodS3() sets attribute "S3class" to the class. This will -# make S3 methods such as a.b.c() non abigous, because it will be possible -# to infer whether the generic function is a() or a.b(). The reason for -# not using an attribute "S3method" = c("a.b", "c") is that the generic -# function should automaticly change if someone does d.e.c <- a.b.c. -# 2012-03-08 -# o Now arguments '...' of setMethodS3() are passed to setGenericS3(). -# 2007-09-17 -# o Replaced 'enforceRCC' argument with more generic 'validators'. -# 2007-06-09 -# o Removed (incorrect) argument name 'list' from all substitute() calls. -# 2006-02-09 -# o Removed all usage of NULL environments. get(envir=NULL) is replaced -# with get(envir=baseenv()). -# 2005-11-23 -# o Added validation of arguments in replacement functions. -# o Added RCC validation of arguments in 'picky' methods, e.g. $()". -# 2005-06-14 -# o BUG FIX: Argument 'enforceRCC' was not passed to setGenericS3(). -# 2005-02-28 -# o Now appendVarArgs is ignore if replacement function, i.e. named "nnn<-". -# 2005-02-25 -# o Tracked down the source of "using .GlobalEnv instead of package:" -# warnings. They occured when defining abstract methods. They also occured -# when automatically adding missing '...' arguments. Made an ad hoc fix -# for this, which I do not really understand why it works, or rather why -# it did not work before. -# 2005-02-20 -# o Abstract methods are now defined with '...' as the only argument(s). -# This will please R CMD check for some methods, e.g. open(). -# 2005-02-15 -# o Added argument 'addVarArgs' if missing. -# o Added arguments '...' in order to match any generic functions. -# 2003-04-24 -# o From R v1.7.0, 'if (vector == scalar)' gives a warning. Had to do -# conflict <- match.arg(conflict), which is more correct. -# 2003-01-18 -# o Replaced all occurences of getClass() with data.class(). Will change -# the use of getClass() in the future to return a Class object. -# 2002-12-05 -# o Spell correction in error message. -# 2002-12-02 -# o Change to argument 'overwrite=TRUE'. -# 2002-12-01 -# o Added argument 'overwrite=FALSE' and 'conflict=c("error", "warning", -# "quiet")' to setMethodS3(). -# 2002-11-29 -# o Updated some error messages. -# o Now it is possible to create methods (also generic) with one (or several) -# . (period) as a prefix of the name. Such a method should be considered -# private in the same manner as fields with a period are private. -# 2002-10-17 -# o Removed obsolete "modifiers<-"(). -# o Added also "Object" to the class attribute to make static methods to -# work. -# 2002-10-16 -# o There are times when -# generic <- function(...) UseMethod() -# is not working, for example -# fcn <- get("generic"); fcn(myObj, ...); -# For this reason, always do method dispatching using the name explicitly; -# generic <- function(...) UseMethod("generic") -# 2002-10-15 -# o Created from R.oo Object.R and ideas as described on -# http://www.maths.lth.se/help/R/ -############################################################################ +setGenericS3("setMethodS3") diff -Nru r-cran-r.methodss3-1.7.1/R/999.NonDocumentedObjects.R r-cran-r.methodss3-1.8.0/R/999.NonDocumentedObjects.R --- r-cran-r.methodss3-1.7.1/R/999.NonDocumentedObjects.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/999.NonDocumentedObjects.R 2018-09-12 04:46:12.000000000 +0000 @@ -28,10 +28,3 @@ # # @keyword internal #*/########################################################################### - -############################################################################ -# HISTORY: -# 2005-02-10 -# o Created to please R CMD check. -############################################################################ - diff -Nru r-cran-r.methodss3-1.7.1/R/999.package.R r-cran-r.methodss3-1.8.0/R/999.package.R --- r-cran-r.methodss3-1.7.1/R/999.package.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/999.package.R 2020-02-14 03:20:20.000000000 +0000 @@ -12,10 +12,11 @@ # # \code{install.packages("R.methodsS3")} # -# To get the "devel" version, see \url{http://www.braju.com/R/}. +# To get the "devel" version, see +# \url{https://github.com/HenrikBengtsson/R.methodsS3/}. # } # -# \section{Dependancies and other requirements}{ +# \section{Dependencies and other requirements}{ # This package only requires a standard \R installation. # } # diff -Nru r-cran-r.methodss3-1.7.1/R/findDispatchMethodsS3.R r-cran-r.methodss3-1.8.0/R/findDispatchMethodsS3.R --- r-cran-r.methodss3-1.7.1/R/findDispatchMethodsS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/findDispatchMethodsS3.R 2019-05-24 02:52:49.000000000 +0000 @@ -33,32 +33,32 @@ #*/########################################################################### setMethodS3("findDispatchMethodsS3", "default", function(methodName, classNames, firstOnly=FALSE, ...) { # Argument 'methodName': - methodName <- as.character(methodName); + methodName <- as.character(methodName) if (length(methodName) == 0) { - throw("Argument 'methodName' is empty."); + stop("Argument 'methodName' is empty.") } if (length(methodName) > 1) { - throw("Argument 'methodName' must only contain one element: ", paste(head(methodName), collapse=", ")); + stop("Argument 'methodName' must only contain one element: ", paste(head(methodName), collapse=", ")) } # Argument 'classNames': - classNames <- as.character(classNames); + classNames <- as.character(classNames) if (length(classNames) == 0) { - throw("Argument 'classNames' is empty."); + stop("Argument 'classNames' is empty.") } # Argument 'firstOnly': - firstOnly <- as.logical(firstOnly); + firstOnly <- as.logical(firstOnly) - res <- list(); + res <- list() for (kk in seq_along(classNames)) { - className <- classNames[kk]; - fcnName <- paste(methodName, className, sep="."); - obj <- do.call(getAnywhere, list(fcnName)); + className <- classNames[kk] + fcnName <- paste(methodName, className, sep=".") + obj <- do.call(getAnywhere, list(fcnName)) if (length(obj$objs) == 0) { # No matching objects - next; + next } # WORKAROUND: In R (< 3.1.?) there is a bug in getAnywhere() @@ -84,46 +84,31 @@ } # Keep only functions - keep <- which(sapply(obj$objs, FUN=is.function)); + keep <- which(sapply(obj$objs, FUN=is.function)) if (length(keep) == 0) { # No functions - next; + next } # Keep the first function - first <- keep[1]; - fcn <- obj$objs[[first]]; - where <- obj$where[first]; - - resKK <- list(); - resKK$class <- className; - resKK$name <- methodName; - resKK$fullname <- fcnName; - resKK$fcn <- fcn; - resKK$where <- obj$where; + first <- keep[1] + fcn <- obj$objs[[first]] + where <- obj$where[first] + + resKK <- list() + resKK$class <- className + resKK$name <- methodName + resKK$fullname <- fcnName + resKK$fcn <- fcn + resKK$where <- obj$where - res[[className]] <- resKK; + res[[className]] <- resKK # Return only the first match? if (firstOnly) { - break; + break } } # for (kk ...) - res; + res }, private=TRUE) # findDispatchMethodsS3() - - -############################################################################ -# HISTORY: -# 2015-02-02 -# o WORKAROUND: In R (< 3.1.?) there is a bug in getAnywhere() causing it -# to return garbage in parts of the 'objs' list. This bug has been -# there all the time, but was only detected now when a package test -# for findDispatchMethodsS3() was added. -# 2010-12-02 -# o Added Rdoc comments. -# o Made findDispatchMethodsS3() a default method. -# 2009-11-20 -# o Added findDispatchMethodsS3(). -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/getDispatchMethodS3.R r-cran-r.methodss3-1.8.0/R/getDispatchMethodS3.R --- r-cran-r.methodss3-1.7.1/R/getDispatchMethodS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/getDispatchMethodS3.R 2019-05-24 02:53:00.000000000 +0000 @@ -31,20 +31,10 @@ # @keyword internal #*/########################################################################### setMethodS3("getDispatchMethodS3", "default", function(methodName, classNames, ...) { - res <- findDispatchMethodsS3(methodName, classNames, firstOnly=TRUE, ...); + res <- findDispatchMethodsS3(methodName, classNames, firstOnly=TRUE, ...) if (length(res) == 0) { - throw(sprintf("No method %s() for this class structure: %s", methodName, paste(classNames, collapse=", "))); + stop(sprintf("No method %s() for this class structure: %s", methodName, paste(classNames, collapse=", "))) } - res[[1]]$fcn; + res[[1]]$fcn }, private=TRUE) - - -############################################################################ -# HISTORY: -# 2010-12-02 -# o Added Rdoc comments. -# o Made getDispatchMethodS3() a default method. -# 2009-11-20 -# o Added getDispatchMethodS3(). -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/getGenericS3.R r-cran-r.methodss3-1.8.0/R/getGenericS3.R --- r-cran-r.methodss3-1.7.1/R/getGenericS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/getGenericS3.R 2019-05-24 02:53:10.000000000 +0000 @@ -30,26 +30,11 @@ # @keyword methods #*/########################################################################### setMethodS3("getGenericS3", "default", function(name, envir=parent.frame(), inherits=TRUE, ...) { - fcn <- .findFunction(name, envir=envir, inherits=inherits)$fcn; + fcn <- .findFunction(name, envir=envir, inherits=inherits)$fcn if (is.null(fcn)) { - throw("No such function found: ", name); + stop("No such function found: ", name) } else if (!isGenericS3(fcn)) { - throw("The function found is not an S3 generic function: ", name); + stop("The function found is not an S3 generic function: ", name) } - fcn; + fcn }) - - - -############################################################################ -# HISTORY: -# 2013-10-06 -# o Now getGenericS3() uses .findFunction(). -# 2013-10-05 -# o Added argument 'inherits' to getGenericS3(). -# 2010-09-18 -# o BUG FIX: getGenericS3() failed to locate generic functions created -# in the global enviroment. -# 2008-05-08 -# o Added getGenericS3(). -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/getMethodS3.R r-cran-r.methodss3-1.8.0/R/getMethodS3.R --- r-cran-r.methodss3-1.7.1/R/getMethodS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/getMethodS3.R 2018-09-12 04:46:12.000000000 +0000 @@ -29,19 +29,6 @@ # @keyword methods #*/########################################################################### setMethodS3("getMethodS3", "default", function(name, class="default", envir=parent.frame(), ...) { - args <- list(name, class=class, optional=FALSE); - do.call(getS3method, args, envir=envir); + args <- list(name, class=class, optional=FALSE) + do.call(getS3method, args, envir=envir) }) - - - -############################################################################ -# HISTORY: -# 2011-11-17 -# o CLEANUP: Dropped example(getMethodS3), which was for setMethodS3(). -# 2010-09-18 -# o BUG FIX: getMethodS3() failed to locate S3 methods created in the -# global enviroment. -# 2008-05-08 -# o Added getMethodS3(). -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/isGenericS3.R r-cran-r.methodss3-1.8.0/R/isGenericS3.R --- r-cran-r.methodss3-1.7.1/R/isGenericS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/isGenericS3.R 2018-09-12 04:46:12.000000000 +0000 @@ -36,40 +36,40 @@ # Local functions # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - knownInternalGenericS3 <- function(fcn, which=1:4, ...) { - knownGenerics <- NULL; + knownGenerics <- NULL # Get the name of all known S3 generic functions if (any(which == 1L)) { - knownGenerics <- c(knownGenerics, names(.knownS3Generics)); + knownGenerics <- c(knownGenerics, names(.knownS3Generics)) } if (any(which == 2L)) { - knownGenerics <- c(knownGenerics, .S3PrimitiveGenerics); + knownGenerics <- c(knownGenerics, .S3PrimitiveGenerics) } # tools:::.get_internal_S3_generics() if available if (any(which == 3L)) { ns <- getNamespace("tools") if (exists(".get_internal_S3_generics", envir=ns, inherits=FALSE)) { - names <- get(".get_internal_S3_generics", envir=ns, inherits=FALSE)(); - knownGenerics <- c(knownGenerics, names); + names <- get(".get_internal_S3_generics", envir=ns, inherits=FALSE)() + knownGenerics <- c(knownGenerics, names) } } # Manually added, cf. ?cbind if (any(which == 4L)) { - names <- c("cbind", "rbind"); - knownGenerics <- c(knownGenerics, names); + names <- c("cbind", "rbind") + knownGenerics <- c(knownGenerics, names) } # Is it one of the known S3 generic functions? - knownGenerics <- unique(knownGenerics); + knownGenerics <- unique(knownGenerics) - knownGenerics; + knownGenerics } # knownInternalGenericS3() isNameInternalGenericS3 <- function(fcn, ...) { - is.element(fcn, knownInternalGenericS3()); + is.element(fcn, knownInternalGenericS3()) } # isNameInternalGenericS3() isPrimitive <- function(fcn, ...) { @@ -78,58 +78,55 @@ if (is.character(fcn)) { - if (isNameInternalGenericS3(fcn)) return(TRUE); + if (isNameInternalGenericS3(fcn)) return(TRUE) # Get the function - fcn <- .findFunction(fcn, envir=envir, inherits=TRUE)$fcn; + fcn <- .findFunction(fcn, envir=envir, inherits=TRUE)$fcn # Does it even exist? if (is.null(fcn)) { - return(FALSE); + return(FALSE) } } - # Check with codetools::findGlobals(), if available, - # otherwise scan the body + # Check with codetools::findGlobals(), otherwise scan the body res <- tryCatch({ - ns <- getNamespace("codetools"); - findGlobals <- get("findGlobals", mode="function", envir=ns); - fcns <- findGlobals(fcn, merge=FALSE)$functions; - is.element("UseMethod", fcns); + fcns <- codetools::findGlobals(fcn, merge=FALSE)$functions + is.element("UseMethod", fcns) }, error = function(ex) { # Scan the body of the function - body <- body(fcn); + body <- body(fcn) if (is.call(body)) - body <- deparse(body); - body <- as.character(body); - (length(grep("UseMethod[(]", body)) > 0L); - }); - if (isTRUE(res)) return(TRUE); + body <- deparse(body) + body <- as.character(body) + (length(grep("UseMethod[(]", body)) > 0L) + }) + if (isTRUE(res)) return(TRUE) # Check primitive functions if (isPrimitive(fcn)) { # Scan the body of the function - body <- deparse(fcn); - call <- grep(".Primitive[(]", body, value=TRUE); - call <- gsub(".Primitive[(]\"", "", call); - call <- gsub("\"[)].*", "", call); - if (is.element(call, knownInternalGenericS3(2L))) return(TRUE); + body <- deparse(fcn) + call <- grep(".Primitive[(]", body, value=TRUE) + call <- gsub(".Primitive[(]\"", "", call) + call <- gsub("\"[)].*", "", call) + if (is.element(call, knownInternalGenericS3(2L))) return(TRUE) } # Finally, compare to all known internal generics for (name in knownInternalGenericS3()) { if (exists(name, mode="function", inherits=TRUE)) { - generic <- get(name, mode="function", inherits=TRUE); - if (identical(fcn, generic)) return(TRUE); + generic <- get(name, mode="function", inherits=TRUE) + if (identical(fcn, generic)) return(TRUE) } } - FALSE; + FALSE } -S3class(isGenericS3.default) <- "default"; -export(isGenericS3.default) <- FALSE; +S3class(isGenericS3.default) <- "default" +export(isGenericS3.default) <- FALSE -setGenericS3("isGenericS3"); +setGenericS3("isGenericS3") @@ -168,42 +165,17 @@ isGenericS4.default <- function(fcn, envir=parent.frame(), ...) { if (is.character(fcn)) { if (!exists(fcn, mode="function", envir=envir, inherits=TRUE)) { - return(FALSE); + return(FALSE) } - fcn <- get(fcn, mode="function", envir=envir, inherits=TRUE); + fcn <- get(fcn, mode="function", envir=envir, inherits=TRUE) } - body <- body(fcn); + body <- body(fcn) if (is.call(body)) - body <- deparse(body); - body <- as.character(body); + body <- deparse(body) + body <- as.character(body) return(length(grep("standardGeneric", body)) > 0) } -S3class(isGenericS4.default) <- "default"; -export(isGenericS4.default) <- FALSE; +S3class(isGenericS4.default) <- "default" +export(isGenericS4.default) <- FALSE -setGenericS3("isGenericS4"); - - - -############################################################################ -# HISTORY: -# 2015-01-13 -# o CONSISTENCY: Now isGenericS4() returns FALSE for non-existing -# functions, just as isGenericS3() does. -# o BUG FIX: isGenericS3() on a function gave error "object 'Math' of -# mode 'function' was not found" when the 'methods' package was not -# loaded, e.g. Rscript -e "R.methodsS3::isGenericS3(function(...) NULL)". -# 2013-10-05 -# o ROBUSTNESS: Now isGenericS3() also compares to known generic functions -# in the 'base' package. It also does a better job on checking whether -# the function calls UseMethod() or not. -# 2010-09-18 -# o BUG FIX: isGenericS3() and isGenericS4() did not support specifying -# the function by name as a character string, despite it was documented -# to do so. Thanks John Oleynick for reporting on this. -# 2004-10-18 -# o Added Rdoc comments for isGenericS3() and isGenericS4(). -# 2002-10-15 -# o Created from R.oo Object.R and ideas as described on -# http://www.maths.lth.se/help/R/ -############################################################################ +setGenericS3("isGenericS4") diff -Nru r-cran-r.methodss3-1.7.1/R/makeNamespace.R r-cran-r.methodss3-1.8.0/R/makeNamespace.R --- r-cran-r.methodss3-1.7.1/R/makeNamespace.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/makeNamespace.R 2018-09-12 04:46:12.000000000 +0000 @@ -0,0 +1,23 @@ +makeNamespace <- function(pkg = ".", style = c("minimal", "quoted")) { + if (pkg == ".") { + pathname <- file.path(pkg, "DESCRIPTION") + if (!file_test("-f", pathname)) stop("No such file: ", sQuote(pathname)) + desc <- read.dcf(pathname) + pkg <- desc[, "Package"] + stopifnot(length(pkg) == 1L, !is.na(pkg)) + } + style <- match.arg(style) + ns <- getNamespace(pkg) + for (name in ls(envir = ns, all.names = TRUE)) { + fcn <- get(name, envir = ns) + if (!is.function(fcn)) next + s3class <- attr(fcn, "S3class") + if (is.null(s3class)) next + name <- gsub(sprintf("[.]%s$", s3class), "", name) + if (style == "minimal") { + cat(sprintf('S3method(%s,%s)\n', name, s3class)) + } else { + cat(sprintf('S3method("%s", "%s")\n', name, s3class)) + } + } +} diff -Nru r-cran-r.methodss3-1.7.1/R/pkgStartupMessage.R r-cran-r.methodss3-1.8.0/R/pkgStartupMessage.R --- r-cran-r.methodss3-1.7.1/R/pkgStartupMessage.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/pkgStartupMessage.R 2018-09-12 04:46:12.000000000 +0000 @@ -14,7 +14,7 @@ # # \arguments{ # \item{...}{Arguments passed to @see "base::packageStartupMessage".} -# \item{quietly}{If @FALSE, the message is outputed, otherwise not. +# \item{quietly}{If @FALSE, the message is outputted, otherwise not. # If @NA, the message is \emph{not} outputted if @see "base::library" # (or \code{require()}) was called with argument \code{quietly=TRUE}.} # } @@ -36,53 +36,47 @@ # Infer 'quietly' from argument 'argument' in library() call? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (is.na(quietly)) { - quietly <- FALSE; + quietly <- FALSE # Just in case the below won't work one day due to R updates... tryCatch({ # The default, if not found - quietly <- formals(base::library)$quietly; + quietly <- formals(base::library)$quietly # Identify the environment/frame of interest by making sure # it at least contains all the arguments of source(). - argsToFind <- names(formals(base::library)); + argsToFind <- names(formals(base::library)) # Scan the call frames/environments backwards... - srcfileList <- list(); + srcfileList <- list() for (ff in sys.nframe():0) { - env <- sys.frame(ff); + env <- sys.frame(ff) # Does the environment look like a library() environment? - exist <- sapply(argsToFind, FUN=exists, envir=env, inherits=FALSE); + exist <- sapply(argsToFind, FUN=exists, envir=env, inherits=FALSE) if (!all(exist)) { # Nope, then skip to the next one - next; + next } # Was argument 'quietly' specified? - missing <- eval(expression(missing(quietly)), envir=env); + missing <- eval(expression(missing(quietly)), envir=env) if (!missing) { - quietly <- get("quietly", envir=env, inherits=FALSE); - break; + quietly <- get("quietly", envir=env, inherits=FALSE) + break } # ...otherwise keep searching due to nested library() calls. } # for (ff ...) - }, error = function() {}); + }, error = function() {}) } # if (is.na(quietly) # Output message? if (!quietly) { - packageStartupMessage(...); + packageStartupMessage(...) } }, protected=TRUE) ## startupMessage <- pkgStartupMessage ## startupMessage.default <- pkgStartupMessage.default - -############################################################################ -# HISTORY: -# 2013-08-29 -# o Added pkgStartupMessage(). -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/R/rccValidators.R r-cran-r.methodss3-1.8.0/R/rccValidators.R --- r-cran-r.methodss3-1.7.1/R/rccValidators.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/rccValidators.R 2019-05-24 02:53:17.000000000 +0000 @@ -3,37 +3,27 @@ # Validate 'name' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Assert that the generic function name is a valid function name. - firstLetter <- substring(gsub("^[.]*", "", name), 1,1); + firstLetter <- substring(gsub("^[.]*", "", name), 1,1) - allowedFirst <- c("?", "$", "$<-", "[", "[<-", "[[", "[[<-"); - allowedFirst <- c(allowedFirst, "+", "-", "*", "^", "%"); + allowedFirst <- c("?", "$", "$<-", "[", "[<-", "[[", "[[<-") + allowedFirst <- c(allowedFirst, "+", "-", "*", "^", "%") if (!is.element(firstLetter, allowedFirst)) { if (!is.element(tolower(firstLetter), letters)) - throw("Except for a few operators, method/function names must begin with a letter: ", name); + stop("Except for a few operators, method/function names must begin with a letter: ", name) # Check first letter if (firstLetter == toupper(firstLetter)) - throw("Method/function names should start with a lower case letter: ", name); + stop("Method/function names should start with a lower case letter: ", name) } } -export(rccValidateFunctionName) <- FALSE; +export(rccValidateFunctionName) <- FALSE rccValidateSetMethodS3 <- function(name, ...) { rccValidateFunctionName(name=name) } -export(rccValidateSetMethodS3) <- FALSE; +export(rccValidateSetMethodS3) <- FALSE rccValidateSetGenericS3 <- function(name, ...) { rccValidateFunctionName(name=name) } -export(rccValidateSetGenericS3) <- FALSE; - - -############################################################################ -# HISTORY: -# 2012-06-22 -# o Now rccValidateFunctionName() also accepts names starting with -# symbols "+", "-", "*", "^", and "%". -# 200x-xx-xx -# o Created. -############################################################################ +export(rccValidateSetGenericS3) <- FALSE diff -Nru r-cran-r.methodss3-1.7.1/R/throw.default.R r-cran-r.methodss3-1.8.0/R/throw.default.R --- r-cran-r.methodss3-1.7.1/R/throw.default.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/R/throw.default.R 2019-05-24 02:58:23.000000000 +0000 @@ -33,31 +33,6 @@ # \keyword{error} #*/########################################################################### setMethodS3("throw", "default", function(...) { - stop(...); + .Deprecated(msg = "R.methodsS3::throw() is deprecated. Use base::stop() instead, or R.oo::throw().") + stop(...) }) - - - -############################################################################ -# HISTORY: -# 2005-09-17 -# o Added to R.methodsS3 since it is so commonly used by my packages. -# 2005-02-20 -# o Updated broken link to tryCatch(). -# 2005-02-10 -# o Making use of tryCatch() only. -# 2002-10-17 -# o Now throw() always throws an Exception. -# 2002-05-25 -# * Bug fix in Rd \examples{}. Forgot a comment. -# 2002-04-21 -# * Redefined throw.default() so it takes several arguments, which are then -# pasted together with sep="". In other words, instead of doing -# stop(paste("bla bla", "value:", x, ".\n", sep="")) -# one can just do -# throw("bla bla", "value:", x, ".\n") -# This is also a step towards the new exception model that supports -# classes. -# * Extract the throw() functions from trycatch.R, which relies on them, but -# the throw()'s are stand-alone. -############################################################################ diff -Nru r-cran-r.methodss3-1.7.1/tests/setGenericS3.R r-cran-r.methodss3-1.8.0/tests/setGenericS3.R --- r-cran-r.methodss3-1.7.1/tests/setGenericS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/tests/setGenericS3.R 2020-02-14 01:56:13.000000000 +0000 @@ -24,12 +24,13 @@ bar.default <- function(...) cat("bar.default\n") bar <- function(...) cat("bar\n") -setGenericS3("bar") +res <- tryCatch(setGenericS3("bar"), error = identity) +stopifnot(inherits(res, "error")) print(getGenericS3("print")) -# Your defintion will redefine bar() above to bar.default(). +# Your definition will redefine bar() above to bar.default(). foobar <- function() print("foobar()") setGenericS3("foobar") diff -Nru r-cran-r.methodss3-1.7.1/tests/setMethodS3.R r-cran-r.methodss3-1.8.0/tests/setMethodS3.R --- r-cran-r.methodss3-1.7.1/tests/setMethodS3.R 2016-02-16 03:21:34.000000000 +0000 +++ r-cran-r.methodss3-1.8.0/tests/setMethodS3.R 2018-09-12 04:46:12.000000000 +0000 @@ -37,7 +37,7 @@ } -# Your defintion will redefine bar() above to bar.default(). +# Your definition will redefine bar() above to bar.default(). setMethodS3("bar", "character", function(object, ...) { cat("In bar() for class 'character':\n") print(object, ...)