Skip to content

Commit

Permalink
Try new @ syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed May 28, 2024
1 parent 8adfc4c commit 6ee9aa5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- {os: macOS-13, r: 'release'}
- {os: macOS-14, r: 'release'}
- {os: macOS-latest, r: 'release', disable-static: 'disable-static'}
- {os: windows-latest, r: '3.6'}
- {os: windows-latest, r: '4.1'}
- {os: windows-latest, r: '4.2'}
- {os: windows-latest, r: '4.3'}
- {os: windows-latest, r: 'release'}
- {os: windows-2022, r: 'devel'}
- {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method("$",V8)
S3method("@",V8)
S3method("[",V8)
S3method("[[",V8)
S3method(names,V8)
Expand All @@ -11,6 +12,8 @@ export(new_context)
export(v8)
export(wasm)
export(wasm_features)
if (getRversion() >= "4.3.0" && !is.null(asNamespace("utils")$.AtNames)) S3method(utils::.AtNames,V8)
if (getRversion() >= "4.3.0") S3method(base::`@`, V8) else export("@")
import(Rcpp)
importFrom(curl,curl)
importFrom(jsonlite,fromJSON)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
5.0.0
- Enable @ instead of $ syntax for accessing v8 fields

4.4.2
- Prevent Fedora from accidentally building against the legacy v8-314 library
instead of the current v8-devel on that system.
Expand Down
12 changes: 12 additions & 0 deletions R/V8.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,18 @@ print.V8 <- function(x, ...){
}
}

#' @export
#' @rawNamespace if (getRversion() >= "4.3.0") S3method(base::`@`, V8) else export("@")
`@.V8` <- function(object, name, ...){
object[[name]]
}

### enable tab completion
#' @rawNamespace if (getRversion() >= "4.3.0" && !is.null(asNamespace("utils")$.AtNames)) S3method(utils::.AtNames,V8)
.AtNames.V8 <- function(x, pattern) {
utils::findMatches(pattern, ls(x))
}

# Pretty format function headers
format_function <- function(fun, name = deparse(substitute(fun))){
#header <- sub("\\{$", "", capture.output(fun)[1])
Expand Down

0 comments on commit 6ee9aa5

Please sign in to comment.