diff --git a/DESCRIPTION b/DESCRIPTION index e221f0223..1fb422452 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nanonext Type: Package Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library -Version: 1.1.0.9002 +Version: 1.1.0.9003 Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library implementing 'Scalability Protocols', a reliable, high-performance standard for common communications patterns including diff --git a/NEWS.md b/NEWS.md index acbcf4e65..99740166e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# nanonext 1.1.0.9002 (development) +# nanonext 1.1.0.9003 (development) #### New Features @@ -9,6 +9,7 @@ * `request()` specifying argument 'cv' other than NULL or a 'conditionVariable' will cause the pipe connection to be dropped when the reply is (asynchronously) completed. * Removes deprecated functions `strcat()`, `recv_aio_signal()` and `request_signal()`. * Removes `base64enc()` and `base64dec()` in favour of those in the {secretbase} package. +* `later` is now a 'suggests' dependency (only required if using promises). # nanonext 1.1.0 diff --git a/src/aio.c b/src/aio.c index 49cc07ca6..3f659a2f3 100644 --- a/src/aio.c +++ b/src/aio.c @@ -558,7 +558,7 @@ SEXP rnng_aio_call(SEXP x) { case VECSXP: ; const R_xlen_t xlen = Rf_xlength(x); for (R_xlen_t i = 0; i < xlen; i++) { - rnng_aio_call(VECTOR_ELT(x, i)); + rnng_aio_call(R_VECTOR(x)[i]); } break; } @@ -581,7 +581,7 @@ static SEXP rnng_aio_collect_impl(SEXP x, SEXP (*const func)(SEXP)) { const R_xlen_t xlen = Rf_xlength(x); PROTECT(out = Rf_allocVector(VECSXP, xlen)); for (R_xlen_t i = 0; i < xlen; i++) { - env = func(VECTOR_ELT(x, i)); + env = func(R_VECTOR(x)[i]); if (TYPEOF(env) != ENVSXP) goto exit; env = Rf_findVarInFrame(env, nano_ValueSymbol); if (env == R_UnboundValue) goto exit; @@ -624,7 +624,7 @@ SEXP rnng_aio_stop(SEXP x) { case VECSXP: ; const R_xlen_t xlen = Rf_xlength(x); for (R_xlen_t i = 0; i < xlen; i++) { - rnng_aio_stop(VECTOR_ELT(x, i)); + rnng_aio_stop(R_VECTOR(x)[i]); } break; } @@ -678,7 +678,7 @@ SEXP rnng_unresolved(SEXP x) { case VECSXP: ; const R_xlen_t xlen = Rf_xlength(x); for (R_xlen_t i = 0; i < xlen; i++) { - if (rnng_unresolved_impl(VECTOR_ELT(x, i))) + if (rnng_unresolved_impl(R_VECTOR(x)[i])) return Rf_ScalarLogical(1); } } @@ -710,7 +710,7 @@ SEXP rnng_unresolved2(SEXP x) { int xc = 0; const R_xlen_t xlen = Rf_xlength(x); for (R_xlen_t i = 0; i < xlen; i++) { - xc += rnng_unresolved2_impl(VECTOR_ELT(x, i)); + xc += rnng_unresolved2_impl(R_VECTOR(x)[i]); } return Rf_ScalarInteger(xc); } diff --git a/src/core.c b/src/core.c index b4b7737cf..cac0762f1 100644 --- a/src/core.c +++ b/src/core.c @@ -161,7 +161,7 @@ static SEXP nano_inHook(SEXP x, SEXP fun) { PROTECT(newlist = Rf_allocVector(VECSXP, xlen + 1)); PROTECT(newnames = Rf_allocVector(STRSXP, xlen + 1)); for (R_xlen_t i = 0; i < xlen; i++) { - SET_VECTOR_ELT(newlist, i, VECTOR_ELT(list, i)); + SET_VECTOR_ELT(newlist, i, R_VECTOR(list)[i]); SET_STRING_ELT(newnames, i, STRING_ELT(names, i)); } SET_VECTOR_ELT(newlist, xlen, x); @@ -178,7 +178,7 @@ static SEXP nano_inHook(SEXP x, SEXP fun) { static SEXP nano_outHook(SEXP x, SEXP fun) { const long i = atol(CHAR(*(SEXP *) DATAPTR_RO(x))) - 1; - return VECTOR_ELT(fun, i); + return R_VECTOR(fun)[i]; } @@ -269,7 +269,7 @@ void nano_serialize_next(nano_buf *buf, const SEXP object) { buf->cur += sizeof(R_xlen_t); for (R_xlen_t i = 0; i < llen; i++) { - PROTECT(call = Rf_lcons(func, Rf_cons(VECTOR_ELT(refList, i), R_NilValue))); + PROTECT(call = Rf_lcons(func, Rf_cons(R_VECTOR(refList)[i], R_NilValue))); PROTECT(out = R_UnwindProtect(eval_safe, call, rl_reset, NULL, NULL)); if (TYPEOF(out) == RAWSXP) { R_xlen_t xlen = XLENGTH(out); @@ -1571,8 +1571,8 @@ SEXP rnng_next_config(SEXP refhook, SEXP klass, SEXP list, SEXP mark) { case VECSXP: if (Rf_xlength(refhook) != 2) return nano_refHook; - typ1 = TYPEOF(VECTOR_ELT(refhook, 0)); - typ2 = TYPEOF(VECTOR_ELT(refhook, 1)); + typ1 = TYPEOF(R_VECTOR(refhook)[0]); + typ2 = TYPEOF(R_VECTOR(refhook)[1]); plist = 0; break; case NILSXP: @@ -1586,8 +1586,8 @@ SEXP rnng_next_config(SEXP refhook, SEXP klass, SEXP list, SEXP mark) { if ((typ1 == CLOSXP || typ1 == SPECIALSXP || typ1 == BUILTINSXP) && (typ2 == CLOSXP || typ2 == SPECIALSXP || typ2 == BUILTINSXP)) { - SETCAR(nano_refHook, plist ? CAR(refhook) : VECTOR_ELT(refhook, 0)); - SETCADR(nano_refHook, plist ? CADR(refhook) : VECTOR_ELT(refhook, 1)); + SETCAR(nano_refHook, plist ? CAR(refhook) : R_VECTOR(refhook)[0]); + SETCADR(nano_refHook, plist ? CADR(refhook) : R_VECTOR(refhook)[1]); SETCAR(nano_klassString, STRING_ELT(klass, 0)); registered = *NANO_INTEGER(list) ? 1 : 2; diff --git a/src/nanonext.h b/src/nanonext.h index 1ef89b089..4a012495d 100644 --- a/src/nanonext.h +++ b/src/nanonext.h @@ -154,6 +154,8 @@ typedef struct nano_cv_s { #include #include +#define R_VECTOR(x) ((const SEXP *) DATAPTR_RO(x)) + #define ERROR_OUT(xc) Rf_error("%d | %s", xc, nng_strerror(xc)) #define ERROR_RET(xc) { Rf_warning("%d | %s", xc, nng_strerror(xc)); return mk_error(xc); } #define NANONEXT_INIT_BUFSIZE 8192 diff --git a/src/thread.c b/src/thread.c index 51a6dfb46..51bbda59e 100644 --- a/src/thread.c +++ b/src/thread.c @@ -328,7 +328,7 @@ SEXP rnng_wait_thread_create(SEXP x) { const R_xlen_t xlen = Rf_xlength(x); for (R_xlen_t i = 0; i < xlen; i++) { - rnng_wait_thread_create(VECTOR_ELT(x, i)); + rnng_wait_thread_create(R_VECTOR(x)[i]); } }