diff --git a/DESCRIPTION b/DESCRIPTION index 63fce385..a0104060 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,6 +42,8 @@ VignetteBuilder: knitr Config/Needs/website: sloop Config/testthat/edition: 3 +Config/testthat/parallel: TRUE +Config/testthat/start-first: external-generic Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index 888a5342..a1e3c7e5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -90,6 +90,7 @@ if (getRversion() >= "4.3.0") S3method(matrixOps, S7_object) if (getRversion() >= "4.3.0") S3method(nameOfClass, S7_class, S7_class_name) importFrom(stats,setNames) importFrom(utils,getFromNamespace) +importFrom(utils,globalVariables) importFrom(utils,hasName) importFrom(utils,head) importFrom(utils,packageName) diff --git a/R/S7-package.R b/R/S7-package.R index be37ed55..767a83e9 100644 --- a/R/S7-package.R +++ b/R/S7-package.R @@ -1,5 +1,6 @@ ## usethis namespace: start -#' @useDynLib S7, .registration = TRUE +#' @importFrom utils globalVariables #' @importFrom utils head str hasName +#' @useDynLib S7, .registration = TRUE ## usethis namespace: end NULL diff --git a/R/method-ops.R b/R/method-ops.R index 48aae74e..b496d4ee 100644 --- a/R/method-ops.R +++ b/R/method-ops.R @@ -34,16 +34,16 @@ Ops.S7_object <- function(e1, e2) { chooseOpsMethod.S7_object <- function(x, y, mx, my, cl, reverse) TRUE #' @rawNamespace if (getRversion() >= "4.3.0") S3method(matrixOps, S7_object) -matrixOps.S7_object <- NULL +matrixOps.S7_object <- function(x, y) { + base_matrix_ops[[.Generic]](x, y) +} + on_load_define_matrixOps <- function() { - if (getRversion() >= "4.4.0") { - matrixOps.S7_object <<- function(x, y) { - base_matrix_ops[[.Generic]](x, y) - } - } else { - matrixOps.S7_object <<- function(e1, e2) { - base_matrix_ops[[.Generic]](e1, e2) - } - } + # if (getRversion() >= "4.3.0") { + # } else { + # matrixOps.S7_object <<- function(e1, e2) { + # base_matrix_ops[[.Generic]](e1, e2) + # } + # } } diff --git a/tests/testthat/test-base-r.R b/tests/testthat/test-base-r.R index cd37e595..390ea177 100644 --- a/tests/testthat/test-base-r.R +++ b/tests/testthat/test-base-r.R @@ -56,8 +56,7 @@ test_that("base::`@` accesses S7 properties", { }) test_that("dput() works", { - skip_if(getRversion() < "4.3") - skip("dput() not fixed yet; https://github.com/RConsortium/S7/issues/272") + skip_if(getRversion() < "4.4") expect_no_error(dput(new_class("Foo")())) expect_no_error(dput(new_class("Foo"))) diff --git a/vignettes/classes-objects.Rmd b/vignettes/classes-objects.Rmd index 8e6e219f..861e80e8 100644 --- a/vignettes/classes-objects.Rmd +++ b/vignettes/classes-objects.Rmd @@ -283,4 +283,3 @@ The first argument to `new_object()` should be an object of the `parent` class ( That argument should be followed by one named argument for each property. There's one drawback of custom constructors that you should be aware of: any subclass will also require a custom constructor. - diff --git a/vignettes/generics-methods.Rmd b/vignettes/generics-methods.Rmd index ff4c7501..bac11933 100644 --- a/vignettes/generics-methods.Rmd +++ b/vignettes/generics-methods.Rmd @@ -2,7 +2,7 @@ title: "Generics and methods" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{S7 generics and method dispatch} + %\VignetteIndexEntry{Generics and methods} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- diff --git a/vignettes/motivation.Rmd b/vignettes/motivation.Rmd index aed85bd0..cb73e973 100644 --- a/vignettes/motivation.Rmd +++ b/vignettes/motivation.Rmd @@ -63,12 +63,6 @@ library(S7) This made it possible to make radical changes but it made it harder to switch from S3 to S4, leading to a general lack of adoption in the R community. S7 is designed to be drop-in compatible with S3, making it possible to convert existing packages to use S7 instead of S3 with only an hour or two of work. -```{=html} -``` -- At least within Bioconductor, slots are generally thought of as implementation detail that should not be directly accessed by the end-user. - This leads to two problems. - Firstly, implementing an S4 Bioconductor class often also requires a plethora of accessor functions that are a thin wrapper around `@` or `@<-`. - Secondly, users know about `@` and use it to access object internals even though they're not supposed to. - S7 avoids these problems by accepting the fact that R is a data language, and that there's no way to stop users from pulling the data they need out of an object. - To make it possible to change the internal implementation details of an object while preserving existing `@` usage, S7 provides dynamic properties. + +- At least within Bioconductor, slots are generally thought of as implementation detail that should not be directly accessed by the end-user. This leads to two problems. Firstly, implementing an S4 Bioconductor class often also requires a plethora of accessor functions that are a thin wrapper around `@` or `@<-`. Secondly, users know about `@` and use it to access object internals even though they're not supposed to. S7 avoids these problems by accepting the fact that R is a data language, and that there's no way to stop users from pulling the data they need out of an object. To make it possible to change the internal implementation details of an object while preserving existing `@` usage, S7 provides dynamic properties. diff --git a/vignettes/packages.Rmd b/vignettes/packages.Rmd index 92779c19..cf0add41 100644 --- a/vignettes/packages.Rmd +++ b/vignettes/packages.Rmd @@ -2,7 +2,7 @@ title: "Using S7 in a package" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{packages} + %\VignetteIndexEntry{Using S7 in a package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} ---