From 580ca806818518e108ab63c0510e631eb67e9d53 Mon Sep 17 00:00:00 2001 From: mike Date: Sat, 20 Jan 2024 07:01:15 +1000 Subject: [PATCH] Fixed warnings when compiling with PKGFLAGS=-Wconversion --- DESCRIPTION | 2 +- NEWS.md | 11 ++- src/R-yyjson-parse.c | 142 +++++++++++++++++++-------------------- src/R-yyjson-serialize.c | 74 ++++++++++---------- 4 files changed, 117 insertions(+), 112 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6514da1..d8f9ae9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: yyjsonr Type: Package Title: Fast JSON Parser and Generator -Version: 0.1.16 +Version: 0.1.16.9000 Authors@R: c( person("Mike", "Cheng", role = c("aut", "cre", 'cph'), email = "mikefc@coolbutuseless.com"), diff --git a/NEWS.md b/NEWS.md index 7b8f453..9041e17 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,18 +1,23 @@ -# yyjson4 0.1.16 2024-01-17 +# yyjsonr 0.1.17 2024-01-20 + +* Fixes for CRAN + * Fixed warnings when building with `MAKEVARS` `PKG_CFLAGS = -Wconversion` + +# yyjsonr 0.1.16 2024-01-17 * Fixes for CRAN * DESCRIPTION fix: Write `C` as `'C'` * Add link to original `yyjson` library * Fix name in LICENSE -# yyjson4 0.1.15 2024-01-15 +# yyjsonr 0.1.15 2024-01-15 * Fixes for CRAN * Simplify example to remove `checkRd` NOTE * Platform specific handling of error location format string to fix WARNING -# yyjson4 0.1.14 2024-01-13 +# yyjsonr 0.1.14 2024-01-13 * Add `int64 = "double"` option to `opts_read_json()` * Preparations for CRAN diff --git a/src/R-yyjson-parse.c b/src/R-yyjson-parse.c index ce8cea0..891816b 100644 --- a/src/R-yyjson-parse.c +++ b/src/R-yyjson-parse.c @@ -75,7 +75,7 @@ parse_options create_parse_options(SEXP parse_opts_) { opt.df_missing_list_elem = val_; } else if (strcmp(opt_name, "yyjson_read_flag") == 0) { for (unsigned int idx = 0; idx < length(val_); idx++) { - opt.yyjson_read_flag |= INTEGER(val_)[idx]; + opt.yyjson_read_flag |= (unsigned int)INTEGER(val_)[idx]; } } else if (strcmp(opt_name, "obj_of_arrs_to_df") == 0) { opt.obj_of_arrs_to_df = asLogical(val_); @@ -164,10 +164,10 @@ int32_t json_val_to_integer(yyjson_val *val, parse_options *opt) { case YYJSON_TYPE_NUM: switch (yyjson_get_subtype(val)) { case YYJSON_SUBTYPE_UINT: - return yyjson_get_uint(val); + return (int32_t)yyjson_get_uint(val); break; case YYJSON_SUBTYPE_SINT: - return yyjson_get_sint(val); + return (int32_t)yyjson_get_sint(val); break; default: warning("json_val_to_integer(). Unhandled numeric type: %i\n", yyjson_get_subtype(val)); @@ -256,14 +256,14 @@ double json_val_to_double(yyjson_val *val, parse_options *opt) { long long json_val_to_integer64(yyjson_val *val, parse_options *opt) { if (val == NULL) { - return NA_REAL; + return INT64_MIN; } switch (yyjson_get_type(val)) { case YYJSON_TYPE_NUM: switch (yyjson_get_subtype(val)) { case YYJSON_SUBTYPE_UINT: - return yyjson_get_uint(val); + return (long long)yyjson_get_uint(val); break; case YYJSON_SUBTYPE_SINT: return yyjson_get_sint(val); @@ -655,7 +655,7 @@ unsigned int get_best_sexp_type_for_matrix(yyjson_val *arr, parse_options *opt) // if all lengths match, then POSSIBLY an array. // if any lengths different then DEFINITELY NOT an array - unsigned int first_len = yyjson_get_len( yyjson_arr_get_first(arr) ); + size_t first_len = yyjson_get_len( yyjson_arr_get_first(arr) ); yyjson_val *val; @@ -665,7 +665,7 @@ unsigned int get_best_sexp_type_for_matrix(yyjson_val *arr, parse_options *opt) // Check lengths //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while ((val = yyjson_arr_iter_next(&iter))) { - unsigned int len = yyjson_get_len( val ); + size_t len = yyjson_get_len( val ); if (len != first_len) { return 0; } @@ -734,8 +734,8 @@ SEXP json_array_as_lglsxp(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R LGLSXP vector //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - int N = yyjson_arr_size(arr); - SEXP res_ = PROTECT(allocVector(LGLSXP, N)); + size_t N = yyjson_arr_size(arr); + SEXP res_ = PROTECT(allocVector(LGLSXP, (R_xlen_t)N)); int32_t *res = INTEGER(res_); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -768,8 +768,8 @@ SEXP json_array_as_intsxp(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R INTSXP vector //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - int N = yyjson_arr_size(arr); - SEXP res_ = PROTECT(allocVector(INTSXP, N)); + size_t N = yyjson_arr_size(arr); + SEXP res_ = PROTECT(allocVector(INTSXP, (R_xlen_t)N)); int32_t *res = INTEGER(res_); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -802,8 +802,8 @@ SEXP json_array_as_realsxp(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R REALSXP vector //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - int N = yyjson_arr_size(arr); - SEXP res_ = PROTECT(allocVector(REALSXP, N)); + size_t N = yyjson_arr_size(arr); + SEXP res_ = PROTECT(allocVector(REALSXP, (R_xlen_t)N)); double *res = REAL(res_); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -837,8 +837,8 @@ SEXP json_array_as_integer64(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R REALSXP vector //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - int N = yyjson_arr_size(arr); - SEXP res_ = PROTECT(allocVector(REALSXP, N)); + size_t N = yyjson_arr_size(arr); + SEXP res_ = PROTECT(allocVector(REALSXP, (R_xlen_t)N)); long long *res = (long long *)REAL(res_); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -873,8 +873,8 @@ SEXP json_array_as_strsxp(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R STRSXP vector //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - int N = yyjson_arr_size(arr); - SEXP res_ = PROTECT(allocVector(STRSXP, N)); + size_t N = yyjson_arr_size(arr); + SEXP res_ = PROTECT(allocVector(STRSXP, (R_xlen_t)N)); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Iterate over array @@ -908,7 +908,7 @@ SEXP json_array_as_vecsxp(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create R VECSXP vector (i.e. a list) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - SEXP res_ = PROTECT(allocVector(VECSXP, yyjson_arr_size(arr))); + SEXP res_ = PROTECT(allocVector(VECSXP, (R_xlen_t)yyjson_arr_size(arr))); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Iterate over array and insert items into list @@ -931,10 +931,10 @@ SEXP json_array_as_vecsxp(yyjson_val *arr, parse_options *opt) { //=========================================================================== SEXP json_array_as_lglsxp_matrix(yyjson_val *arr, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - unsigned int ncol = yyjson_get_len(yyjson_arr_get_first(arr)); + size_t nrow = yyjson_get_len(arr); + size_t ncol = yyjson_get_len(yyjson_arr_get_first(arr)); - SEXP mat_ = PROTECT(allocVector(LGLSXP, nrow * ncol)); + SEXP mat_ = PROTECT(allocVector(LGLSXP, (R_xlen_t)(nrow * ncol))); int32_t *matp = INTEGER(mat_); yyjson_arr_iter iter1 = yyjson_arr_iter_with( arr ); @@ -966,10 +966,10 @@ SEXP json_array_as_lglsxp_matrix(yyjson_val *arr, parse_options *opt) { //=========================================================================== SEXP json_array_as_intsxp_matrix(yyjson_val *arr, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - unsigned int ncol = yyjson_get_len(yyjson_arr_get_first(arr)); + size_t nrow = yyjson_get_len(arr); + size_t ncol = yyjson_get_len(yyjson_arr_get_first(arr)); - SEXP mat_ = PROTECT(allocVector(INTSXP, nrow * ncol)); + SEXP mat_ = PROTECT(allocVector(INTSXP, (R_xlen_t)(nrow * ncol))); int32_t *matp = INTEGER(mat_); yyjson_arr_iter iter1 = yyjson_arr_iter_with( arr ); @@ -1001,10 +1001,10 @@ SEXP json_array_as_intsxp_matrix(yyjson_val *arr, parse_options *opt) { //=========================================================================== SEXP json_array_as_realsxp_matrix(yyjson_val *arr, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - unsigned int ncol = yyjson_get_len(yyjson_arr_get_first(arr)); + size_t nrow = yyjson_get_len(arr); + size_t ncol = yyjson_get_len(yyjson_arr_get_first(arr)); - SEXP mat_ = PROTECT(allocVector(REALSXP, nrow * ncol)); + SEXP mat_ = PROTECT(allocVector(REALSXP, (R_xlen_t)(nrow * ncol))); double *matp = REAL(mat_); yyjson_arr_iter iter1 = yyjson_arr_iter_with( arr ); @@ -1036,10 +1036,10 @@ SEXP json_array_as_realsxp_matrix(yyjson_val *arr, parse_options *opt) { //=========================================================================== SEXP json_array_as_strsxp_matrix(yyjson_val *arr, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - unsigned int ncol = yyjson_get_len(yyjson_arr_get_first(arr)); + size_t nrow = yyjson_get_len(arr); + size_t ncol = yyjson_get_len(yyjson_arr_get_first(arr)); - SEXP mat_ = PROTECT(allocVector(STRSXP, nrow * ncol)); + SEXP mat_ = PROTECT(allocVector(STRSXP, (R_xlen_t)(nrow * ncol))); yyjson_arr_iter iter1 = yyjson_arr_iter_with( arr ); yyjson_val *inner_arr; @@ -1052,7 +1052,7 @@ SEXP json_array_as_strsxp_matrix(yyjson_val *arr, parse_options *opt) { unsigned int col = 0; while ((val = yyjson_arr_iter_next(&iter2))) { - SET_STRING_ELT(mat_, col * nrow + row, json_val_to_charsxp(val, opt)); + SET_STRING_ELT(mat_, (R_xlen_t)(col * nrow + row), json_val_to_charsxp(val, opt)); col++; } @@ -1069,7 +1069,7 @@ SEXP json_array_as_strsxp_matrix(yyjson_val *arr, parse_options *opt) { //=========================================================================== SEXP json_array_as_matrix(yyjson_val *arr, unsigned int sexp_type, parse_options *opt) { - unsigned int nprotect = 0; + int nprotect = 0; SEXP mat_ = R_NilValue; switch(sexp_type) { @@ -1090,12 +1090,12 @@ SEXP json_array_as_matrix(yyjson_val *arr, unsigned int sexp_type, parse_options } if (!isNull(mat_)) { - unsigned int ncol = yyjson_get_len(arr); - unsigned int nrow = yyjson_get_len(yyjson_arr_get_first(arr)); + size_t ncol = yyjson_get_len(arr); + size_t nrow = yyjson_get_len(yyjson_arr_get_first(arr)); SEXP dims_ = PROTECT(allocVector(INTSXP, 2)); nprotect++; - INTEGER(dims_)[0] = ncol; // JSON arrays are column-major - INTEGER(dims_)[1] = nrow; + INTEGER(dims_)[0] = (int32_t)ncol; // JSON arrays are column-major + INTEGER(dims_)[1] = (int32_t)nrow; setAttrib(mat_, R_DimSymbol, dims_); } @@ -1120,7 +1120,7 @@ SEXP json_array_as_matrix(yyjson_val *arr, unsigned int sexp_type, parse_options //=========================================================================== SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { - unsigned int nprotect = 0; + int nprotect = 0; SEXP res_ = R_NilValue; if (!yyjson_is_arr(arr)) { @@ -1197,9 +1197,9 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { // and promote all types to that for the final 3d matrix. // For now, just keeping it basic. Mike 2023-08-12 bool is_3d_matrix = true; - unsigned int dim0 = 0; - unsigned int dim1 = 0; - unsigned int nlayer = length(res_); + int dim0 = 0; + int dim1 = 0; + int nlayer = length(res_); unsigned int sexp_type = 0; if (nlayer > 1) { @@ -1226,7 +1226,7 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { // check type if (layer == 0) { - sexp_type = TYPEOF(elem_); + sexp_type = (unsigned int)TYPEOF(elem_); } else { if (TYPEOF(elem_) != sexp_type) { is_3d_matrix = false; @@ -1244,7 +1244,7 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { arr_ = PROTECT(allocVector(LGLSXP, N)); nprotect++; int *ptr = INTEGER(arr_); for (unsigned int layer = 0; layer < nlayer; layer++) { - memcpy(ptr, INTEGER(VECTOR_ELT(res_, layer)), dim0 * dim1 * sizeof(int)); + memcpy(ptr, INTEGER(VECTOR_ELT(res_, layer)), (size_t)dim0 * (size_t)dim1 * sizeof(int)); ptr += dim0 * dim1; } } @@ -1253,7 +1253,7 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { arr_ = PROTECT(allocVector(INTSXP, N)); nprotect++; int *ptr = INTEGER(arr_); for (unsigned int layer = 0; layer < nlayer; layer++) { - memcpy(ptr, INTEGER(VECTOR_ELT(res_, layer)), dim0 * dim1 * sizeof(int)); + memcpy(ptr, INTEGER(VECTOR_ELT(res_, layer)), (size_t)dim0 * (size_t)dim1 * sizeof(int)); ptr += dim0 * dim1; } } @@ -1262,7 +1262,7 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { arr_ = PROTECT(allocVector(REALSXP, N)); nprotect++; double *ptr = REAL(arr_); for (unsigned int layer = 0; layer < nlayer; layer++) { - memcpy(ptr, REAL(VECTOR_ELT(res_, layer)), dim0 * dim1 * sizeof(double)); + memcpy(ptr, REAL(VECTOR_ELT(res_, layer)), (size_t)dim0 * (size_t)dim1 * sizeof(double)); ptr += dim0 * dim1; } } @@ -1345,8 +1345,8 @@ SEXP json_array_as_robj(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP json_array_of_objects_to_lglsxp(yyjson_val *arr, const char *key_name, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - SEXP vec_ = PROTECT(allocVector(LGLSXP, nrow)); + size_t nrow = yyjson_get_len(arr); + SEXP vec_ = PROTECT(allocVector(LGLSXP, (R_xlen_t)nrow)); int *vecp = INTEGER(vec_); yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1369,8 +1369,8 @@ SEXP json_array_of_objects_to_lglsxp(yyjson_val *arr, const char *key_name, pars //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP json_array_of_objects_to_intsxp(yyjson_val *arr, const char *key_name, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - SEXP vec_ = PROTECT(allocVector(INTSXP, nrow)); + size_t nrow = yyjson_get_len(arr); + SEXP vec_ = PROTECT(allocVector(INTSXP, (R_xlen_t)nrow)); int *vecp = INTEGER(vec_); yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1393,8 +1393,8 @@ SEXP json_array_of_objects_to_intsxp(yyjson_val *arr, const char *key_name, pars //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP json_array_of_objects_to_realsxp(yyjson_val *arr, const char *key_name, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - SEXP vec_ = PROTECT(allocVector(REALSXP, nrow)); + size_t nrow = yyjson_get_len(arr); + SEXP vec_ = PROTECT(allocVector(REALSXP, (R_xlen_t)nrow)); double *vecp = REAL(vec_); yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1417,8 +1417,8 @@ SEXP json_array_of_objects_to_realsxp(yyjson_val *arr, const char *key_name, par //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP json_array_of_objects_to_strsxp(yyjson_val *arr, const char *key_name, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - SEXP vec_ = PROTECT(allocVector(STRSXP, nrow)); + size_t nrow = yyjson_get_len(arr); + SEXP vec_ = PROTECT(allocVector(STRSXP, (R_xlen_t)nrow)); unsigned int idx = 0; yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1441,8 +1441,8 @@ SEXP json_array_of_objects_to_strsxp(yyjson_val *arr, const char *key_name, pars //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP json_array_of_objects_to_vecsxp(yyjson_val *arr, const char *key_name, parse_options *opt) { - unsigned int nrow = yyjson_get_len(arr); - SEXP vec_ = PROTECT(allocVector(VECSXP, nrow)); + size_t nrow = yyjson_get_len(arr); + SEXP vec_ = PROTECT(allocVector(VECSXP, (R_xlen_t)nrow)); unsigned int idx = 0; yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1477,7 +1477,7 @@ SEXP json_array_of_objects_to_vecsxp(yyjson_val *arr, const char *key_name, pars //=========================================================================== SEXP json_array_of_objects_to_data_frame(yyjson_val *arr, parse_options *opt) { - unsigned nprotect = 0; + int nprotect = 0; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Accumulation of unique key-names in the objects @@ -1492,7 +1492,7 @@ SEXP json_array_of_objects_to_data_frame(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Prepare to iterate over all {}-objects within the []-array //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - unsigned int nrows = yyjson_get_len(arr); + unsigned int nrows = (unsigned int)yyjson_get_len(arr); yyjson_arr_iter iter = yyjson_arr_iter_with(arr); yyjson_val *obj; @@ -1519,7 +1519,7 @@ SEXP json_array_of_objects_to_data_frame(yyjson_val *arr, parse_options *opt) { } if (name_idx < 0) { // Name has not been seen yet. so add it. - name_idx = ncols; + name_idx = (int)ncols; colname[ncols] = (char *)yyjson_get_str(key); ncols++; if (ncols == MAX_DF_COLS) { @@ -1595,7 +1595,7 @@ SEXP json_array_of_objects_to_data_frame(yyjson_val *arr, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP rownames = PROTECT(allocVector(INTSXP, 2)); nprotect++; SET_INTEGER_ELT(rownames, 0, NA_INTEGER); - SET_INTEGER_ELT(rownames, 1, -nrows); + SET_INTEGER_ELT(rownames, 1, -(int)nrows); setAttrib(df_, R_RowNamesSymbol, rownames); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1623,13 +1623,13 @@ SEXP json_array_of_objects_to_data_frame(yyjson_val *arr, parse_options *opt) { // JSON {}-object to R List //=========================================================================== SEXP json_object_as_list(yyjson_val *obj, parse_options *opt) { - unsigned int nprotect = 0; + int nprotect = 0; if (!yyjson_is_obj(obj)) { error("json_object(): Must be object. Not %i -> %s\n", yyjson_get_type(obj), yyjson_get_type_desc(obj)); } - unsigned int n = yyjson_get_len(obj); + R_xlen_t n = (R_xlen_t)yyjson_get_len(obj); SEXP res_ = PROTECT(allocVector(VECSXP, n)); nprotect++; SEXP nms_ = PROTECT(allocVector(STRSXP, n)); nprotect++; @@ -1678,7 +1678,7 @@ SEXP json_object_as_list(yyjson_val *obj, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEXP rownames = PROTECT(allocVector(INTSXP, 2)); nprotect++; SET_INTEGER_ELT(rownames, 0, NA_INTEGER); - SET_INTEGER_ELT(rownames, 1, -nrow); + SET_INTEGER_ELT(rownames, 1, -(int)nrow); setAttrib(res_, R_RowNamesSymbol, rownames); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1706,7 +1706,7 @@ SEXP json_object_as_list(yyjson_val *obj, parse_options *opt) { //=========================================================================== SEXP json_as_robj(yyjson_val *val, parse_options *opt) { - unsigned int nprotect = 0; + int nprotect = 0; static char buf[128]; SEXP res_ = R_NilValue; @@ -1748,7 +1748,7 @@ SEXP json_as_robj(yyjson_val *val, parse_options *opt) { error("Unhandled opt.bit64 option for YYJSON_SUBTYPE_UINT"); } } else { - res_ = PROTECT(ScalarInteger(tmp)); nprotect++; + res_ = PROTECT(ScalarInteger((int32_t)tmp)); nprotect++; } } break; @@ -1778,7 +1778,7 @@ SEXP json_as_robj(yyjson_val *val, parse_options *opt) { error("Unhandled opt.bit64 option for YYJSON_SUBTYPE_SINT"); } } else { - res_ = PROTECT(ScalarInteger(tmp)); nprotect++; + res_ = PROTECT(ScalarInteger((int32_t)tmp)); nprotect++; } } break; @@ -1807,9 +1807,9 @@ SEXP json_as_robj(yyjson_val *val, parse_options *opt) { #define ERR_CONTEXT 20 void output_verbose_error(const char *str, yyjson_read_err err) { // Slice off a bit of the string within +/- ERR_CONTEXT of the error pos - int min_idx = err.pos - ERR_CONTEXT; + size_t min_idx = err.pos - ERR_CONTEXT; min_idx = min_idx < 0 ? 0 : min_idx; - int max_idx = err.pos + ERR_CONTEXT; + size_t max_idx = err.pos + ERR_CONTEXT; max_idx = max_idx > strlen(str) ? strlen(str) : max_idx; // copy this context into a temp string. ensure it ends in '\0' @@ -1819,7 +1819,7 @@ void output_verbose_error(const char *str, yyjson_read_err err) { Rprintf("%s\n", err_string); // Print a "^" to point to the error - unsigned int pos = ERR_CONTEXT; + size_t pos = ERR_CONTEXT; pos = err.pos < ERR_CONTEXT ? err.pos - 1 : ERR_CONTEXT; for (unsigned int i = 0; i < pos; i++) { Rprintf(" "); @@ -1846,7 +1846,7 @@ SEXP parse_json_from_str(const char *str, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { output_verbose_error(str, err); -#if defined(__APPLE__) || defined(_WIN32) +#if defined(_WIN32) error("Error parsing JSON: %s code: %u at position: %llu\n", err.msg, err.code, err.pos); #else error("Error parsing JSON: %s code: %u at position: %lu\n", err.msg, err.code, err.pos); @@ -1883,7 +1883,7 @@ SEXP parse_json_from_file(const char *filename, parse_options *opt) { // If doc is NULL, then an error occurred during parsing. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { -#if defined(__APPLE__) || defined(_WIN32) +#if defined(_WIN32) error("Error parsing JSON file '%s': %s code: %u at position: %llu\n", filename, err.msg, err.code, err.pos); #else error("Error parsing JSON file '%s': %s code: %u at position: %lu\n", filename, err.msg, err.code, err.pos); @@ -1968,7 +1968,7 @@ SEXP validate_json_file_(SEXP filename_, SEXP verbose_, SEXP parse_opts_) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { if (asLogical(verbose_)) { -#if defined(__APPLE__) || defined(_WIN32) +#if defined(_WIN32) warning("Error parsing JSON file '%s': %s code: %u at position: %llu\n", filename, err.msg, err.code, err.pos); #else warning("Error parsing JSON file '%s': %s code: %u at position: %lu\n", filename, err.msg, err.code, err.pos); @@ -2000,7 +2000,7 @@ SEXP validate_json_str_(SEXP str_, SEXP verbose_, SEXP parse_opts_) { if (doc == NULL) { if (asLogical(verbose_)) { output_verbose_error(str, err); -#if defined(__APPLE__) || defined(_WIN32) +#if defined(_WIN32) warning("Error parsing JSON: %s code: %u at position: %llu\n", err.msg, err.code, err.pos); #else warning("Error parsing JSON: %s code: %u at position: %lu\n", err.msg, err.code, err.pos); diff --git a/src/R-yyjson-serialize.c b/src/R-yyjson-serialize.c index 35518cc..c4c6acd 100644 --- a/src/R-yyjson-serialize.c +++ b/src/R-yyjson-serialize.c @@ -77,7 +77,7 @@ serialize_options parse_serialize_options(SEXP serialize_opts_) { opt.name_repair = strcmp(tmp, "none") == 0 ? NAME_REPAIR_NONE : NAME_REPAIR_MINIMAL; } else if (strcmp(opt_name, "yyjson_write_flag") == 0) { for (unsigned int idx = 0; idx < length(val_); idx++) { - opt.yyjson_write_flag |= INTEGER(val_)[idx]; + opt.yyjson_write_flag |= (unsigned int)INTEGER(val_)[idx]; } } else if (strcmp(opt_name, "str_specials") == 0) { const char *val = CHAR(STRING_ELT(val_, 0)); @@ -183,7 +183,7 @@ yyjson_mut_val *scalar_date_to_json_val(SEXP vec_, unsigned int idx, yyjson_mut_ return yyjson_mut_null(doc); } } else if (isInteger(vec_)) { - uint32_t ndays_int = INTEGER(vec_)[idx]; + uint32_t ndays_int = (uint32_t)INTEGER(vec_)[idx]; if (ndays_int == INT32_MIN) { // NA return yyjson_mut_null(doc); } @@ -193,7 +193,7 @@ yyjson_mut_val *scalar_date_to_json_val(SEXP vec_, unsigned int idx, yyjson_mut_ } // Convert days-since-epoch to seconds-since-epoch, then handle like posixct - time_t tt = ndays * 24 * 60 * 60; + time_t tt = (time_t)(ndays * 24.0 * 60.0 * 60.0); struct tm *st = gmtime(&tt); strftime(buf, 50, "%Y-%m-%d", st); yyjson_mut_val *val = yyjson_mut_strcpy(doc, buf); @@ -216,7 +216,7 @@ yyjson_mut_val *scalar_posixct_to_json_val(SEXP vec_, unsigned int idx, yyjson_m return yyjson_mut_null(doc); } } else if (isInteger(vec_)) { - uint32_t seconds_int = INTEGER(vec_)[idx]; + uint32_t seconds_int = (uint32_t)INTEGER(vec_)[idx]; if (seconds_int == INT32_MIN) { // NA return yyjson_mut_null(doc); } @@ -225,7 +225,7 @@ yyjson_mut_val *scalar_posixct_to_json_val(SEXP vec_, unsigned int idx, yyjson_m error("scalar_posixct_to_json_val(): Nope"); } - time_t tt = seconds; + time_t tt = (time_t)seconds; struct tm *st = gmtime(&tt); strftime(buf, 50, "%Y-%m-%d %H:%M:%S", st); yyjson_mut_val *val = yyjson_mut_strcpy(doc, buf); @@ -254,7 +254,7 @@ yyjson_mut_val *scalar_rawsxp_to_json_val(SEXP vec_, unsigned int idx, yyjson_mu yyjson_mut_val *scalar_factor_to_json_val(SEXP factor_, unsigned int idx, yyjson_mut_doc *doc, serialize_options *opt) { yyjson_mut_val *val ; - unsigned int factor = INTEGER(factor_)[idx]; + int32_t factor = INTEGER(factor_)[idx]; if (opt->factor == FACTOR_AS_INT) { val = scalar_integer_to_json_val(factor, doc, opt); @@ -299,7 +299,7 @@ yyjson_mut_val *scalar_double_to_json_val(double rdbl, yyjson_mut_doc *doc, seri val = yyjson_mut_real(doc, rdbl); } else if (opt->digits == 0) { // round to integer - val = yyjson_mut_int(doc, round(rdbl)); + val = yyjson_mut_int(doc, (int64_t)round(rdbl)); } else { // round to decimal places val = yyjson_mut_real(doc, round(rdbl * fac[opt->digits])/fac[opt->digits]); @@ -377,7 +377,7 @@ yyjson_mut_val *vector_factor_to_json_array(SEXP vec_, yyjson_mut_doc *doc, seri yyjson_mut_val *arr = yyjson_mut_arr(doc); - for (int i = 0; i < length(vec_); i++) { + for (unsigned int i = 0; i < length(vec_); i++) { yyjson_mut_arr_append(arr, scalar_factor_to_json_val(vec_, i, doc, opt)); } @@ -408,7 +408,7 @@ yyjson_mut_val *vector_posixct_to_json_array(SEXP vec_, yyjson_mut_doc *doc, ser yyjson_mut_val *arr = yyjson_mut_arr(doc); - for (int i = 0; i < length(vec_); i++) { + for (unsigned int i = 0; i < length(vec_); i++) { yyjson_mut_arr_append(arr, scalar_posixct_to_json_val(vec_, i, doc, opt)); } @@ -423,7 +423,7 @@ yyjson_mut_val *vector_date_to_json_array(SEXP vec_, yyjson_mut_doc *doc, serial yyjson_mut_val *arr = yyjson_mut_arr(doc); - for (int i = 0; i < length(vec_); i++) { + for (unsigned int i = 0; i < length(vec_); i++) { yyjson_mut_arr_append(arr, scalar_date_to_json_val(vec_, i, doc, opt)); } @@ -438,7 +438,7 @@ yyjson_mut_val *vector_integer64_to_json_array(SEXP vec_, yyjson_mut_doc *doc, s yyjson_mut_val *arr = yyjson_mut_arr(doc); - for (int i = 0; i < length(vec_); i++) { + for (unsigned int i = 0; i < length(vec_); i++) { yyjson_mut_arr_append(arr, scalar_integer64_to_json_val(vec_, i, doc, opt)); } @@ -500,7 +500,7 @@ yyjson_mut_val *vector_realsxp_to_json_array(SEXP vec_, yyjson_mut_doc *doc, ser yyjson_mut_val *vector_strsxp_to_json_array(SEXP vec_, yyjson_mut_doc *doc, serialize_options *opt) { yyjson_mut_val *arr = yyjson_mut_arr(doc); - for (int i = 0; i < length(vec_); i++) { + for (unsigned int i = 0; i < length(vec_); i++) { yyjson_mut_arr_append(arr, scalar_strsxp_to_json_val(vec_, i, doc, opt)); } @@ -540,7 +540,7 @@ yyjson_mut_val *vector_to_json_array(SEXP vec_, yyjson_mut_doc *doc, serialize_o arr = vector_rawsxp_to_json_array(vec_, doc, opt); break; default: - error("serialize_array(): Unknown array type: %s", type2char(TYPEOF(vec_))); + error("serialize_array(): Unknown array type: %s", type2char((SEXPTYPE)TYPEOF(vec_))); } return arr; @@ -562,8 +562,8 @@ yyjson_mut_val *vector_to_json_array(SEXP vec_, yyjson_mut_doc *doc, serialize_o yyjson_mut_val *matrix_to_col_major_array(SEXP mat_, unsigned int offset, yyjson_mut_doc *doc, serialize_options *opt) { SEXP dims_ = getAttrib(mat_, R_DimSymbol); - unsigned int nrow = INTEGER(dims_)[0]; - unsigned int ncol = INTEGER(dims_)[1]; + unsigned int nrow = (unsigned int)INTEGER(dims_)[0]; + unsigned int ncol = (unsigned int)INTEGER(dims_)[1]; // 'Offset' is used for array processing where we want to start processing // elements at an index other than 0. i.e. the n-th layer of the 3-d array @@ -618,7 +618,7 @@ yyjson_mut_val *matrix_to_col_major_array(SEXP mat_, unsigned int offset, yyjson } break; default: - error("matrix_to_col_major_array(). Unhandled type: %s", type2char(TYPEOF(mat_))); + error("matrix_to_col_major_array(). Unhandled type: %s", type2char((SEXPTYPE)TYPEOF(mat_))); } @@ -633,9 +633,9 @@ yyjson_mut_val *matrix_to_col_major_array(SEXP mat_, unsigned int offset, yyjson yyjson_mut_val *dim3_matrix_to_col_major_array(SEXP mat_, yyjson_mut_doc *doc, serialize_options *opt) { SEXP dims_ = getAttrib(mat_, R_DimSymbol); - unsigned int nrow = INTEGER(dims_)[0]; - unsigned int ncol = INTEGER(dims_)[1]; - unsigned int nlayer = INTEGER(dims_)[2]; + unsigned int nrow = (unsigned int)INTEGER(dims_)[0]; + unsigned int ncol = (unsigned int)INTEGER(dims_)[1]; + unsigned int nlayer = (unsigned int)INTEGER(dims_)[2]; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Allocate an array within the document @@ -669,10 +669,10 @@ yyjson_mut_val *dim3_matrix_to_col_major_array(SEXP mat_, yyjson_mut_doc *doc, s //=========================================================================== yyjson_mut_val *env_to_json_object(SEXP env_, yyjson_mut_doc *doc, serialize_options *opt) { if (!isEnvironment(env_)) { - error("env_to_json_object(): Expected environment. got %s", type2char(TYPEOF(env_))); + error("env_to_json_object(): Expected environment. got %s", type2char((SEXPTYPE)TYPEOF(env_))); } - unsigned int nprotect = 0; + int nprotect = 0; yyjson_mut_val *obj = yyjson_mut_obj(doc); @@ -708,7 +708,7 @@ yyjson_mut_val *env_to_json_object(SEXP env_, yyjson_mut_doc *doc, serialize_opt //=========================================================================== yyjson_mut_val *unnamed_list_to_json_array(SEXP list_, yyjson_mut_doc *doc, serialize_options *opt) { if (!isNewList(list_)) { - error("unnamed_list_to_json_array(): Expected list. got %s", type2char(TYPEOF(list_))); + error("unnamed_list_to_json_array(): Expected list. got %s", type2char((SEXPTYPE)TYPEOF(list_))); } yyjson_mut_val *arr = yyjson_mut_arr(doc); @@ -736,7 +736,7 @@ yyjson_mut_val *unnamed_list_to_json_array(SEXP list_, yyjson_mut_doc *doc, seri //=========================================================================== yyjson_mut_val *named_list_to_json_object(SEXP list_, yyjson_mut_doc *doc, serialize_options *opt) { if (!isNewList(list_)) { - error("named_list_to_json_object(): Expected list. got %s", type2char(TYPEOF(list_))); + error("named_list_to_json_object(): Expected list. got %s", type2char((SEXPTYPE)TYPEOF(list_))); } yyjson_mut_val *obj = yyjson_mut_obj(doc); @@ -794,7 +794,7 @@ int is_named_list(SEXP list_) { //=========================================================================== unsigned int *detect_data_frame_types(SEXP df_, serialize_options *opt) { - unsigned int ncols = length(df_); + unsigned int ncols = (unsigned int)length(df_); unsigned int *col_type; col_type = (unsigned int *)malloc(ncols * sizeof(unsigned int)); @@ -848,7 +848,7 @@ unsigned int *detect_data_frame_types(SEXP df_, serialize_options *opt) { col_type[col] = RAWSXP; break; default: - error("detect_data_frame_types(): Unhandled scalar SEXP: %s\n", type2char(TYPEOF(col_))); + error("detect_data_frame_types(): Unhandled scalar SEXP: %s\n", type2char((SEXPTYPE)TYPEOF(col_))); } } @@ -861,7 +861,7 @@ yyjson_mut_val *data_frame_row_to_json_object(SEXP df_, unsigned int *col_type, // get data.frame names SEXP nms_ = getAttrib(df_, R_NamesSymbol); - unsigned int ncols = length(df_); + unsigned int ncols = (unsigned int)length(df_); yyjson_mut_val *obj = yyjson_mut_obj(doc); @@ -913,7 +913,7 @@ yyjson_mut_val *data_frame_row_to_json_object(SEXP df_, unsigned int *col_type, val = scalar_rawsxp_to_json_val(col_, row, doc, opt); break; default: - error("data_frame_row_to_json_object(): Unhandled scalar SEXP/col_type: %s [%i]\n", type2char(TYPEOF(col_)), col_type[col]); + error("data_frame_row_to_json_object(): Unhandled scalar SEXP/col_type: %s [%i]\n", type2char((SEXPTYPE)TYPEOF(col_)), col_type[col]); } // Add value to row obj if (val != NULL) { @@ -929,7 +929,7 @@ yyjson_mut_val *data_frame_row_to_json_object(SEXP df_, unsigned int *col_type, yyjson_mut_val *data_frame_row_to_json_array(SEXP df_, unsigned int *col_type, unsigned int row, int skip_col, yyjson_mut_doc *doc, serialize_options *opt) { // get data.frame names - unsigned int ncols = length(df_); + unsigned int ncols = (unsigned int)length(df_); yyjson_mut_val *arr = yyjson_mut_arr(doc); @@ -979,7 +979,7 @@ yyjson_mut_val *data_frame_row_to_json_array(SEXP df_, unsigned int *col_type, u val = scalar_rawsxp_to_json_val(col_, row, doc, opt); break; default: - error("data_frame_row_to_json_object(): Unhandled scalar SEXP/col_type: %s [%i]\n", type2char(TYPEOF(col_)), col_type[col]); + error("data_frame_row_to_json_object(): Unhandled scalar SEXP/col_type: %s [%i]\n", type2char((SEXPTYPE)TYPEOF(col_)), col_type[col]); } // Add value to row obj if (val != NULL) { @@ -1001,7 +1001,7 @@ yyjson_mut_val *data_frame_to_json_array_of_arrays(SEXP df_, yyjson_mut_doc *doc // Sanity check //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!Rf_inherits(df_, "data.frame")) { - error("data_frame_to_json_array_of_arrays(). Not a data.frame!! %s", type2char(TYPEOF(df_))); + error("data_frame_to_json_array_of_arrays(). Not a data.frame!! %s", type2char((SEXPTYPE)TYPEOF(df_))); } @@ -1009,7 +1009,7 @@ yyjson_mut_val *data_frame_to_json_array_of_arrays(SEXP df_, yyjson_mut_doc *doc yyjson_mut_val *arr = yyjson_mut_arr(doc); // get size of data.frame - unsigned int nrows = length(VECTOR_ELT(df_, 0)); // length of first column + unsigned int nrows = (unsigned int)length(VECTOR_ELT(df_, 0)); // length of first column //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // For each row @@ -1019,7 +1019,7 @@ yyjson_mut_val *data_frame_to_json_array_of_arrays(SEXP df_, yyjson_mut_doc *doc // add the array to the overall array //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ unsigned int *col_type = detect_data_frame_types(df_, opt); - for (int row = 0; row < nrows; row++) { + for (unsigned int row = 0; row < nrows; row++) { yyjson_mut_val *obj = data_frame_row_to_json_array(df_, col_type, row, -1, doc, opt); @@ -1043,7 +1043,7 @@ yyjson_mut_val *data_frame_to_json_array_of_objects(SEXP df_, yyjson_mut_doc *do // Sanity check //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (!Rf_inherits(df_, "data.frame")) { - error("data_frame_to_json_array_of_objects(). Not a data.frame!! %s", type2char(TYPEOF(df_))); + error("data_frame_to_json_array_of_objects(). Not a data.frame!! %s", type2char((SEXPTYPE)TYPEOF(df_))); } @@ -1055,7 +1055,7 @@ yyjson_mut_val *data_frame_to_json_array_of_objects(SEXP df_, yyjson_mut_doc *do yyjson_mut_val *arr = yyjson_mut_arr(doc); // get size of data.frame - unsigned int nrows = length(VECTOR_ELT(df_, 0)); // length of first column + unsigned int nrows = (unsigned int)length(VECTOR_ELT(df_, 0)); // length of first column //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // For each row @@ -1078,7 +1078,7 @@ yyjson_mut_val *data_frame_to_json_array_of_objects(SEXP df_, yyjson_mut_doc *do // Rprintf("Col %i: %i\n", i, col_type[i]); // } - for (int row = 0; row < nrows; row++) { + for (unsigned int row = 0; row < nrows; row++) { yyjson_mut_val *obj = data_frame_row_to_json_object(df_, col_type, row, -1, doc, opt); @@ -1167,7 +1167,7 @@ yyjson_mut_val *serialize_core(SEXP robj_, yyjson_mut_doc *doc, serialize_option val = scalar_rawsxp_to_json_val(robj_, 0, doc, opt); break; default: - error("Unhandled scalar SEXP: %s\n", type2char(TYPEOF(robj_))); + error("Unhandled scalar SEXP: %s\n", type2char((SEXPTYPE)TYPEOF(robj_))); } } } else if (isVectorAtomic(robj_)) { @@ -1175,7 +1175,7 @@ yyjson_mut_val *serialize_core(SEXP robj_, yyjson_mut_doc *doc, serialize_option } else if (isNull(robj_)) { val = yyjson_mut_null(doc); } else { - warning("serialize_core(): Unhandled SEXP: %s\n", type2char(TYPEOF(robj_))); + warning("serialize_core(): Unhandled SEXP: %s\n", type2char((SEXPTYPE)TYPEOF(robj_))); val = yyjson_mut_null(doc); }