Skip to content

Commit

Permalink
removes weakref interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Nov 18, 2023
1 parent 848fd95 commit 9baf211
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 152 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ export(unsubscribe)
export(until)
export(wait)
export(wait_aio)
export(weakref)
export(weakref_key)
export(weakref_value)
export(write_cert)
importFrom(stats,start)
importFrom(utils,.DollarNames)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
+ registered 'refhook' functions apply to external pointer type objects only.
* `until()` updated to be identical to `.until()`, returning FALSE instead of TRUE if the timeout has been reached.
* `pipe_notify()` arguments 'add', 'remove' and 'flag' now default to FALSE instead of TRUE for easier selective specification of the events to signal.
* The weak references interface is removed as 'non-core'.
* Upgrades bundled 'libmbedtls' to v 3.5.1.

# nanonext 0.10.4
Expand Down
60 changes: 0 additions & 60 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,66 +275,6 @@ status_code <- function(x) .Call(rnng_status_code, x)
#'
strcat <- function(a, b) .Call(rnng_strcat, a, b)

# nanonext - Weak References ---------------------------------------------------

#' Weak References
#'
#' \code{weakref} creates a new weak reference, a special type of R object that
#' associates a value with a key. The value is kept alive for as long as the
#' key remains reachable (i.e. has yet to be garbage collected), even if the
#' value itself is no longer referenced.
#'
#' @param key a reference object (such as an environment or external pointer).
#' @param value an object.
#'
#' @return For \code{weakref}: a weak reference.
#'
#' For \code{weakref_key} and \code{weakref_value}: the key or value
#' associated with the weak reference, or NULL if no longer reachable.
#'
#' @examples
#' k <- new.env()
#' v <- "value"
#'
#' w <- weakref(k, v)
#' w
#' typeof(w)
#'
#' @export
#'
weakref <- function(key, value) .Call(rnng_weakref_make, key, value)

#' Weakref Key
#'
#' \code{weakref_key} retrieves the key associated with a weak reference.
#'
#' @param w a weak reference.
#'
#' @examples
#' key <- weakref_key(w)
#' identical(key, k)
#'
#' @rdname weakref
#' @export
#'
weakref_key <- function(w) .Call(rnng_weakref_key, w)

#' Weakref Value
#'
#' \code{weakref_value} retrieves the value associated with a weak reference.
#'
#' @examples
#' value <- weakref_value(w)
#' identical(value, v)
#'
#' rm(v)
#' weakref_value(w)
#'
#' @rdname weakref
#' @export
#'
weakref_value <- function(w) .Call(rnng_weakref_value, w)

#' Next Mode Settings
#'
#' Configures send mode 'next' by registering functions for custom serialization
Expand Down
55 changes: 0 additions & 55 deletions man/weakref.Rd

This file was deleted.

20 changes: 0 additions & 20 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,26 +1395,6 @@ SEXP rnng_strcat(SEXP a, SEXP b) {

}

// weakref ---------------------------------------------------------------------

SEXP rnng_weakref_make(SEXP key, SEXP value) {

return R_MakeWeakRef(key, value, R_NilValue, FALSE);

}

SEXP rnng_weakref_key(SEXP w) {

return R_WeakRefKey(w);

}

SEXP rnng_weakref_value(SEXP w) {

return R_WeakRefValue(w);

}

// next mode selector ----------------------------------------------------------

SEXP rnng_next_mode(SEXP refhook, SEXP mark) {
Expand Down
3 changes: 0 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ static const R_CallMethodDef callMethods[] = {
{"rnng_url_parse", (DL_FUNC) &rnng_url_parse, 1},
{"rnng_version", (DL_FUNC) &rnng_version, 0},
{"rnng_wait_thread_create", (DL_FUNC) &rnng_wait_thread_create, 1},
{"rnng_weakref_make", (DL_FUNC) &rnng_weakref_make, 2},
{"rnng_weakref_key", (DL_FUNC) &rnng_weakref_key, 1},
{"rnng_weakref_value", (DL_FUNC) &rnng_weakref_value, 1},
{"rnng_write_cert", (DL_FUNC) &rnng_write_cert, 3},
{NULL, NULL, 0}
};
Expand Down
3 changes: 0 additions & 3 deletions src/nanonext.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ extern SEXP rnng_unresolved2(SEXP);
extern SEXP rnng_url_parse(SEXP);
extern SEXP rnng_version(void);
extern SEXP rnng_wait_thread_create(SEXP);
extern SEXP rnng_weakref_make(SEXP, SEXP);
extern SEXP rnng_weakref_key(SEXP);
extern SEXP rnng_weakref_value(SEXP);
extern SEXP rnng_write_cert(SEXP, SEXP, SEXP);

#endif
8 changes: 0 additions & 8 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,6 @@ nanotest(is.integer(base64dec(base64enc(c(1L, 2L)), convert = NA)))
nanotesterr(base64dec("__"), "not valid base64")
nanotesterr(base64dec(404), "not valid base64")

k <- new.env()
v <- "value"
nanotest(typeof(w <- weakref(k, v)) == "weakref")
nanotest(identical(weakref_key(w), k))
nanotest(identical(weakref_value(w), v))
rm(v)
nanotest(weakref_value(w) == "value")

file <- tempfile()
pem <- "-----BEGIN CERTIFICATE----- -----END CERTIFICATE-----"
cat(pem, file = file)
Expand Down

0 comments on commit 9baf211

Please sign in to comment.