Skip to content

Commit ef2bc3c

Browse files
committed
0.27.1
1 parent 4798f3c commit ef2bc3c

11 files changed

Lines changed: 123 additions & 11 deletions

‎ChangeLog‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 0.27.1 (2024-06-04)
2+
* Add function `set_trust_promises` to allow for serialization and deserialization of PROMSXP
3+
14
Version 0.26.3 (2024-05-15)
25
* When serializing, eval promises immediately (https://github.com/traversc/qs/issues/94)
36
* Return NULL and issue a warning when unserializing a PROMSXP (see https://github.com/traversc/qs/issues/93)

‎NAMESPACE‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export(qsave_handle)
3131
export(qsavem)
3232
export(qserialize)
3333
export(register_altrep_class)
34+
export(set_trust_promises)
3435
export(unregister_altrep_class)
3536
export(zstd_compress_bound)
3637
export(zstd_compress_raw)

‎R/RcppExports.R‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ get_altrep_class_info <- function(obj) {
173173
.Call(`_qs_get_altrep_class_info`, obj)
174174
}
175175

176+
set_trust_promises <- function(value) {
177+
.Call(`_qs_set_trust_promises`, value)
178+
}
179+
176180
# Register entry points for exported C++ functions
177181
methods::setLoadAction(function(ns) {
178182
.Call(`_qs_RcppExport_registerCCallable`)

‎R/zz_help_files.R‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,20 @@ NULL
590590
#' @examples
591591
#' get_altrep_class_info(1:5)
592592
NULL
593+
594+
#' Allow for serialization/deserialization of promises
595+
#'
596+
#' Allow for serialization/deserialization of promises
597+
#'
598+
#' @usage set_trust_promises(value)
599+
#'
600+
#' @param value a boolean `TRUE` or `FALSE`
601+
#' @return The previous value of the global variable `trust_promises`
602+
#'
603+
#' @export
604+
#' @name set_trust_promises
605+
#'
606+
#' @examples
607+
#' set_trust_promises(TRUE)
608+
NULL
609+

‎inst/include/qs_RcppExports.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,26 @@ namespace qs {
882882
return Rcpp::as<SEXP >(rcpp_result_gen);
883883
}
884884

885+
inline bool set_trust_promises(bool value) {
886+
typedef SEXP(*Ptr_set_trust_promises)(SEXP);
887+
static Ptr_set_trust_promises p_set_trust_promises = NULL;
888+
if (p_set_trust_promises == NULL) {
889+
validateSignature("bool(*set_trust_promises)(bool)");
890+
p_set_trust_promises = (Ptr_set_trust_promises)R_GetCCallable("qs", "_qs_set_trust_promises");
891+
}
892+
RObject rcpp_result_gen;
893+
{
894+
rcpp_result_gen = p_set_trust_promises(Shield<SEXP>(Rcpp::wrap(value)));
895+
}
896+
if (rcpp_result_gen.inherits("interrupted-error"))
897+
throw Rcpp::internal::InterruptedException();
898+
if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen))
899+
throw Rcpp::LongjumpException(rcpp_result_gen);
900+
if (rcpp_result_gen.inherits("try-error"))
901+
throw Rcpp::exception(Rcpp::as<std::string>(rcpp_result_gen).c_str());
902+
return Rcpp::as<bool >(rcpp_result_gen);
903+
}
904+
885905
}
886906

887907
#endif // RCPP_qs_RCPPEXPORTS_H_GEN_

‎man/set_trust_promises.Rd‎

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/RcppExports.cpp‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,39 @@ RcppExport SEXP _qs_get_altrep_class_info(SEXP objSEXP) {
14971497
UNPROTECT(1);
14981498
return rcpp_result_gen;
14991499
}
1500+
// set_trust_promises
1501+
bool set_trust_promises(bool value);
1502+
static SEXP _qs_set_trust_promises_try(SEXP valueSEXP) {
1503+
BEGIN_RCPP
1504+
Rcpp::RObject rcpp_result_gen;
1505+
Rcpp::traits::input_parameter< bool >::type value(valueSEXP);
1506+
rcpp_result_gen = Rcpp::wrap(set_trust_promises(value));
1507+
return rcpp_result_gen;
1508+
END_RCPP_RETURN_ERROR
1509+
}
1510+
RcppExport SEXP _qs_set_trust_promises(SEXP valueSEXP) {
1511+
SEXP rcpp_result_gen;
1512+
{
1513+
rcpp_result_gen = PROTECT(_qs_set_trust_promises_try(valueSEXP));
1514+
}
1515+
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
1516+
if (rcpp_isInterrupt_gen) {
1517+
UNPROTECT(1);
1518+
Rf_onintr();
1519+
}
1520+
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
1521+
if (rcpp_isLongjump_gen) {
1522+
Rcpp::internal::resumeJump(rcpp_result_gen);
1523+
}
1524+
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
1525+
if (rcpp_isError_gen) {
1526+
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
1527+
UNPROTECT(1);
1528+
Rf_error("%s", CHAR(rcpp_msgSEXP_gen));
1529+
}
1530+
UNPROTECT(1);
1531+
return rcpp_result_gen;
1532+
}
15001533

15011534
// validate (ensure exported C++ functions exist before calling them)
15021535
static int _qs_RcppExport_validate(const char* sig) {
@@ -1545,6 +1578,7 @@ static int _qs_RcppExport_validate(const char* sig) {
15451578
signatures.insert("void(*register_altrep_class)(const std::string&,const std::string&)");
15461579
signatures.insert("void(*unregister_altrep_class)(const std::string&,const std::string&)");
15471580
signatures.insert("SEXP(*get_altrep_class_info)(SEXP)");
1581+
signatures.insert("bool(*set_trust_promises)(bool)");
15481582
}
15491583
return signatures.find(sig) != signatures.end();
15501584
}
@@ -1594,6 +1628,7 @@ RcppExport SEXP _qs_RcppExport_registerCCallable() {
15941628
R_RegisterCCallable("qs", "_qs_register_altrep_class", (DL_FUNC)_qs_register_altrep_class_try);
15951629
R_RegisterCCallable("qs", "_qs_unregister_altrep_class", (DL_FUNC)_qs_unregister_altrep_class_try);
15961630
R_RegisterCCallable("qs", "_qs_get_altrep_class_info", (DL_FUNC)_qs_get_altrep_class_info_try);
1631+
R_RegisterCCallable("qs", "_qs_set_trust_promises", (DL_FUNC)_qs_set_trust_promises_try);
15971632
R_RegisterCCallable("qs", "_qs_RcppExport_validate", (DL_FUNC)_qs_RcppExport_validate);
15981633
return R_NilValue;
15991634
}
@@ -1642,6 +1677,7 @@ static const R_CallMethodDef CallEntries[] = {
16421677
{"_qs_register_altrep_class", (DL_FUNC) &_qs_register_altrep_class, 2},
16431678
{"_qs_unregister_altrep_class", (DL_FUNC) &_qs_unregister_altrep_class, 2},
16441679
{"_qs_get_altrep_class_info", (DL_FUNC) &_qs_get_altrep_class_info, 1},
1680+
{"_qs_set_trust_promises", (DL_FUNC) &_qs_set_trust_promises, 1},
16451681
{"_qs_RcppExport_registerCCallable", (DL_FUNC) &_qs_RcppExport_registerCCallable, 0},
16461682
{NULL, NULL, 0}
16471683
};

‎src/qs_common.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ enum class qstype {NUMERIC, INTEGER, LOGICAL, CHARACTER, NIL, LIST, COMPLEX, RAW
225225
S4, S4FLAG, LOCKED_ENV, UNLOCKED_ENV, REFERENCE,
226226
ATTRIBUTE, RSERIALIZED};
227227

228+
// global variable to trust promises for both serialization and de-serialization
229+
static bool trust_promises_global = false;
228230

229231
///////////////////////////////////////////////////////
230232
// There are three types of output input streams -- std::ifstream/ofstream, file descriptor, windows handle

‎src/qs_deserialize_common.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ SEXP processBlock(T * const sobj) {
646646
SET_S4_OBJECT(obj);
647647
// SET_OBJECT(obj, 1); // this flag seems kind of pointless
648648
}
649-
if(TYPEOF(obj) == PROMSXP) {
649+
if( !trust_promises_global && (TYPEOF(obj) == PROMSXP)) {
650650
Rcpp::warning("PROMSXP detected, replacing with NULL (see https://github.com/traversc/qs/issues/93)");
651651
return R_NilValue;
652652
} else {

‎src/qs_functions.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,13 @@ SEXP get_altrep_class_info(SEXP obj) {
844844
#endif
845845
}
846846

847+
// [[Rcpp::export(rng = false)]]
848+
bool set_trust_promises(bool value) {
849+
bool previous_value = trust_promises_global;
850+
trust_promises_global = value;
851+
return previous_value;
852+
}
853+
847854

848855
// std::vector<unsigned char> brotli_compress_raw(RawVector x, int compress_level) {
849856
// uint64_t zsize = BrotliEncoderMaxCompressedSize(x.size());

0 commit comments

Comments
 (0)