diff --git a/.codecov.yml b/.codecov.yml index 9ec352888..e10eb4a78 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,4 +1,5 @@ comment: false + coverage: status: project: @@ -9,6 +10,9 @@ coverage: default: target: 0% # the (on purpose low) required coverage value +ignore: + - 'R/inline.R' # function factory setup confuses codecov + # layout: "header, diff, tree, changes" # behavior: default # require_changes: false # if true: only post the comment if coverage changes diff --git a/.github/workflows/autoapprove.yaml b/.github/workflows/autoapprove.yaml new file mode 100644 index 000000000..a9a9dc76e --- /dev/null +++ b/.github/workflows/autoapprove.yaml @@ -0,0 +1,29 @@ +# Once a PR has been approved by one member of the organization, a second +# approving review will automatically be added 24 hours later. This allows time +# for other maintainers to take a look. +# +# Borrowed with love from 'auto-approve.yml' in the mlpack repo. + +name: approval_timer +on: + workflow_dispatch: + schedule: + # Run every six hours. + - cron: "15 */6 * * *" + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + auto-approve: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Auto-approve PRs + uses: rcurtin/actions/auto-approve@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + approval-message: + 'Additional approval provided automatically after 24 hours.' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 406d28fc5..e8ad0ffa7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,12 @@ jobs: - name: release cntr: rcpp/ci r: R + - name: r-4.5 + cntr: rcpp/ci-4.5 + r: R + - name: r-4.4 + cntr: rcpp/ci-4.4 + r: R - name: r-4.3 cntr: rcpp/ci-4.3 r: R @@ -48,13 +54,7 @@ jobs: r: RD steps: - - uses: actions/checkout@v4 - - #- name: Bootstrap - # run: | - # curl -OLs https://eddelbuettel.github.io/r-ci/run.sh - # chmod 0755 run.sh - # ./run.sh bootstrap + - uses: actions/checkout@v6 - name: SessionInfo run: ${{ matrix.r }} -q -e 'sessionInfo()' @@ -65,14 +65,19 @@ jobs: - name: Check run: CI=true ${{ matrix.r }} CMD check --no-vignettes --no-manual Rcpp_*.tar.gz - #covr: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout Project - # uses: actions/checkout@v3 - # - # - name: Container - # run: docker pull rcpp/ci - # - # - name: Coverage - # run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CODECOV_TOKEN=${{secrets.CODECOV_TOKEN }} rcpp/ci r -l covr -e 'codecov()' + covr: + runs-on: ubuntu-latest + steps: + - name: Checkout Project + uses: actions/checkout@v6 + + - name: Setup + uses: eddelbuettel/github-actions/r-ci@master + + - name: Dependencies + run: ./run.sh install_deps + + - name: Coverage + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: ./run.sh coverage diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index dd6fc6541..8d3b8b199 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -4,6 +4,7 @@ on: push: branches: - master + workflow_dispatch: schedule: - cron: "32 1 * * 6" @@ -19,19 +20,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v7 with: push: true context: docker/${{ matrix.tag }} @@ -45,19 +46,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v7 with: push: true context: docker/run @@ -71,19 +72,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v7 with: push: true context: docker/plus diff --git a/.github/workflows/linuxarm.yaml b/.github/workflows/linuxarm.yaml new file mode 100644 index 000000000..1e4653015 --- /dev/null +++ b/.github/workflows/linuxarm.yaml @@ -0,0 +1,38 @@ +# Run CI for R using https://eddelbuettel.github.io/r-ci/ + +name: linuxarm + +on: + #push: + #pull_request: + workflow_dispatch: + +env: + _R_CHECK_FORCE_SUGGESTS_: "false" + +jobs: + ci: + strategy: + matrix: + include: + #- {os: ubuntu-latest} + - {os: ubuntu-24.04-arm} + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup + uses: eddelbuettel/github-actions/r-ci@master + + - name: Dependencies + run: ./run.sh install_deps + + - name: Test + run: ./run.sh run_tests + + #- name: Coverage + # if: ${{ matrix.os == 'ubuntu-latest' }} + # run: ./run.sh coverage diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index c86c6350e..486e28e1a 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -14,20 +14,18 @@ jobs: strategy: matrix: include: - - {os: macOS-latest} + - {os: macos-latest} #- {os: ubuntu-latest} + #- {os: ubuntu-24.04-arm} runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup - uses: eddelbuettel/github-actions/r-ci-setup@master - - - name: Bootstrap - run: ./run.sh bootstrap + uses: eddelbuettel/github-actions/r-ci@master - name: Dependencies run: ./run.sh install_deps diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 1f73e3641..84c20a193 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -11,7 +11,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v8 + - uses: actions/stale@v10 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-label: 'no-issue-activity' diff --git a/.github/workflows/werror.yml b/.github/workflows/werror.yml new file mode 100644 index 000000000..751a9847e --- /dev/null +++ b/.github/workflows/werror.yml @@ -0,0 +1,36 @@ +# Run CI for R using https://eddelbuettel.github.io/r-ci/ + +name: werror + +on: + push: + pull_request: + +env: + _R_CHECK_FORCE_SUGGESTS_: "false" + RCPP_CXXFLAGS: "-Werror -Wall -Wextra -Wconversion" + +jobs: + ci: + runs-on: ubuntu-latest + container: eddelbuettel/drd:26.04 + + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Setup + uses: eddelbuettel/github-actions/r-ci@master + + - name: Dependencies + run: ./run.sh install_deps + + - name: Set flags + run: mkdir -p ~/.R && echo "CXXFLAGS += $RCPP_CXXFLAGS" >> ~/.R/Makevars + + - name: Test + run: ./run.sh run_tests + + - name: Logs + run: ./run.sh dump_logs + if: failure() diff --git a/ChangeLog b/ChangeLog index c2c0278f4..17e01906c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,1235 @@ +2026-11-30 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * .github/workflows/autoapprove.yaml: Add 24 hour approval timer + action, borrowed from similar mlpack/mlpack action + +2026-11-29 Simon Urbanek + + * inst/include/Rcpp/vector/const_string_proxy.h: Declare operator== + and operator!= as const to fix ambiguities failing to compile with + Apple clang (#1537) + +2026-11-27 David Seifert + + * inst/include/Rcpp/internal/wrap.h: Comment out parameter to avoid + -Wunused-parameter warnings + +2026-11-23 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp.bib: Correct misspelling of gitlab + * inst/bib/Rcpp.bib: Idem + +2026-11-06 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-10-31 Dirk Eddelbuettel + + * .github/workflows/macos.yaml (jobs): Retire macos-14 (but retain + macos-latest) + +2026-10-29 Kevin Ushey + + * inst/include/Rcpp/module/Module_Add_Property.h: Return *this from + the property() overload taking a free-function getter and a member + function setter, which fell off the end and trapped at module load + (#1519) + * inst/tinytest/cpp/Module.cpp: Expose one property per property() + overload + * inst/tinytest/test_module.R: Test them + + * src/module.cpp (InternalFunction_invoke): Raise an error when fewer + arguments are supplied than the arity stored in the function pointer's + tag, instead of reading the missing ones from uninitialized memory + (#1521) + * inst/include/Rcpp/module/Module.h (Module::get_function): Store the + arity of module functions in the pointer tag + * inst/include/Rcpp/InternalFunction.h: Idem for InternalFunction + * inst/tinytest/cpp/Module.cpp: Add module functions with formals + * inst/tinytest/test_module.R: Test calls with too few arguments + * inst/tinytest/test_internal_function.R: Idem + * inst/tinytest/test_internal_function_cpp11.R: Idem + + * R/00_classes.R (.cppfunction_formals_gets): Find the .External() call + in the body of the function instead of assuming it is the second + element, which it is not once coverage tools have instrumented the body + * R/00_classes.R (.cppfunction_set_external_args): New helper + * inst/tinytest/test_module.R: Test it with an instrumented body + * inst/include/Rcpp/api/meat/as.h (as_module_object_internal): Check + that the argument is a live module object, raising an error for + deserialized, uninitialized and non-module objects instead of handing + out a NULL or garbage address; a new overload taking the expected C++ + type also requires the object's class to be that type or one that + derives() from it (#1523) + * inst/include/Rcpp/as.h: Use the new overload when converting to + module classes + * inst/tinytest/cpp/Module.cpp: Add a class deriving from another + * inst/tinytest/test_module.R: Test the new checks + + * inst/include/Rcpp/Module.h (RCPP_MODULE): Run the module body only the + first time the boot function is called, since it adds to the static + module and every Module() call boots the module again, which duplicated + constructors and methods (#1527) + * inst/include/Rcpp/module/Module.h (Module::clear): New, removes the + registered classes and functions + * inst/include/Rcpp/Module.h (RCPP_MODULE): Clear the module when the + body throws, so that a later load runs the body against an empty module + instead of appending to what the failed run registered + * inst/tinytest/cpp/ModuleInitRetry.cpp: New module whose first load + fails after registering a class and a function + * inst/tinytest/test_module.R: Test loading a module repeatedly, and + loading one again after its body threw + + * inst/include/Rcpp/Module.h (RCPP_MODULE): Wrap the module boot + function in BEGIN_RCPP / END_RCPP so that an exception thrown while the + module initializes raises an R error instead of terminating the session + (#1525) + * inst/include/Rcpp/Module.h (internal::ModuleScope): New RAII guard + restoring the previous module scope however the module body exits + * inst/tinytest/cpp/ModuleInitError.cpp: New module whose initialization + throws + * inst/tinytest/cpp/Module.cpp (Module_scope_is_cleared): New + * inst/tinytest/test_module.R: Test loading the failing module + + * inst/include/Rcpp/module/class.h (class_::AddMethod): Count special + '[' methods once per name rather than once per overload, as complete() + expects; overloading '[[' dropped methods from completion or ran past + the end of the method map (#1529) + * inst/tinytest/cpp/Module.cpp: Add classes overloading '[[' + * inst/tinytest/test_module.R: Test their completions + + * vignettes/rmd/Rcpp-modules.Rmd: Document that objects of exposed + classes returned by value or reference are copied, while a returned + pointer is owned and eventually deleted by R, so that returning this or + another pointer the C++ side still owns deletes the object twice (#1533) + * inst/tinytest/cpp/Module.cpp: Add a class counting its destructions + * inst/tinytest/test_module.R: Test that R deletes a returned pointer + + * inst/include/Rcpp/Module.h (internal::module_class_pointer): New + per-library record of the class_ registered for a C++ type + * inst/include/Rcpp/Module.h (internal::make_new_object): Pass it to + the new cpp_object_maker_by_class(), so that objects returned from C++ + are wrapped as the module class of the library that returned them + rather than as another library's class of the same name (#1531) + * inst/include/Rcpp/module/class.h (class_::get_instance): Record the + class + * R/Module.R (cpp_object_maker_by_class): New, looking the class up by + its pointer and creating the object through the class's generator + * R/Module.R (Module): Register classes by pointer as well + * R/zzz.R: Add .classes_by_pointer + * inst/tinytest/testRcppCollisionA: New test package + * inst/tinytest/testRcppCollisionB: Idem + * inst/tinytest/test_module_class_collision.R: Test objects returned + by both + +2026-10-23 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-10-22 Kevin Ushey + + * src/module.cpp (CppObject__finalize): Make finalize() a no-op for a + module object that was never constructed (created without arguments for a + class without a default constructor); it used to fail on the dummy + pointer, and the failure surfaced as an error message at garbage + collection + * inst/tinytest/test_module.R: Add test + +2026-10-22 Michael Sumner + + * R/00_classes.R: Define C++Field, C++OverloadedMethods and + C++Constructor as S4 classes as creating one reference class + object per exposed method dominated the time spent loading a + module; add '$' and '$<-' methods for backwards compatibility + * R/00_classes.R (.cpp_methods_info): Former 'info' reference method + * R/01_show.R: Use slot access and .cpp_methods_info() + * R/Module.R (method_wrapper, binding_maker): Idem + * inst/include/Rcpp/Module.h: Derive from S4 instead of Reference + * man/CppConstructor-class.Rd: Document slots and '$' methods + * man/CppField-class.Rd: Idem + * man/CppOverloadedMethods-class.Rd: Idem + +2026-10-21 Michael Sumner + + * R/Module.R: Supply 'initialize' method to setRefClass() with + other methods instead of adding second generator$methods() call, + which repeated reference class analysis of every exposed method, + * R/Module.R (Module): Take class representation from generator + rather than looking up by name with methods::getClass() + * R/Module.R (Module): Register as(FROM, TO) converters after loop + that populates 'storage' rather than once per function inside it + * R/Module.R (Module): Match 'show' method name exactly rather + than as a substring, so a class exposing C++Object show method + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-10-13 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-10-12 Kevin Ushey + + * inst/include/Rcpp/vector/traits.h: Update copyright + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/vector/Matrix.h: Idem + +2026-10-09 Kevin Ushey + + * inst/include/Rcpp/config.h: Define RCPP_SUGAR_LENGTH_CHECKS, on for + development versions and off for releases unless overridden + * inst/include/Rcpp/sugar/tools/check_sizes.h: Compile the length checks + out when RCPP_SUGAR_LENGTH_CHECKS is 0 + * inst/tinytest/cpp/sugar_expressions.cpp: Report whether the checks are + enabled + * inst/tinytest/test_sugar.R: Test the length errors only when enabled, + and the truncation otherwise + * vignettes/rmd/Rcpp-sugar.Rmd: Document when the lengths are checked + * inst/NEWS.Rd: Idem + + * inst/include/Rcpp/sugar/functions/lapply.h: Index the operand through + VectorBase so vectors yield their stored type rather than a proxy + * inst/tinytest/cpp/sugar.cpp: Add a test + * inst/tinytest/test_sugar.R: Idem + +2026-09-30 Kevin Ushey + + * inst/include/Rcpp/traits/sugar_operand.h: New trait for how sugar + expressions hold their operands: vectors by reference, and nested + expressions and views by value, so stored expressions don't dangle + * inst/include/Rcpp/traits/is_elementwise.h: New trait for whether a + sugar expression can be written in place into storage it may read from + * inst/include/Rcpp/sugar/tools/check_sizes.h: New helpers checking that + sugar operands, and vectors assigned into views, have matching lengths + * inst/include/RcppCommon.h: Include the above + * inst/include/Rcpp/sugar/sugar_forward.h: Idem + * inst/include/Rcpp/sugar/: Hold operands via sugar_operand, declare + elementwise operands, and check operand lengths + * inst/include/Rcpp/stats/dpq/dpq.h: Idem + * inst/include/Rcpp/sugar/block/SugarBlock_3.h: Also fix the type of the + third operand + * inst/include/Rcpp/sugar/logical/and.h: Fix operator&& on two single + logical results, hold their operands by value, and make NA && FALSE + return FALSE + * inst/include/Rcpp/sugar/logical/or.h: Idem for operator||, making + NA || TRUE return TRUE, and fix the base class of Or_SingleLogicalResult_bool + * inst/include/Rcpp/sugar/logical/not.h: Hold the operand of operator! + by value + * inst/include/Rcpp/sugar/logical/SingleLogicalResult.h: Add get_ref() + * inst/include/Rcpp/vector/Vector.h: Evaluate sugar expressions that + aren't elementwise before assigning them in place + * inst/include/Rcpp/vector/RangeIndexer.h: Idem, and check lengths + * inst/include/Rcpp/vector/MatrixColumn.h: Idem + * inst/include/Rcpp/vector/MatrixRow.h: Idem + * inst/include/Rcpp/vector/MatrixBase.h: Add a const get_ref() + * inst/tinytest/cpp/sugar_expressions.cpp: New tests + * inst/tinytest/test_sugar.R: Idem + * vignettes/rmd/Rcpp-sugar.Rmd: Document operand lengths, storing + expressions, and assignment + +2026-09-30 Kevin Ushey + + * inst/include/Rcpp/vector/traits.h: Move the out-of-bounds warning into + a cold, out-of-line helper; add get_size() to the vector caches + * inst/include/Rcpp/vector/Vector.h: Return the length cached by + r_vector_cache from size() and length() rather than calling + Rf_xlength() each time + * inst/include/Rcpp/vector/Matrix.h: Derive ncol() from the cached + length and nrow() instead of reading the dim attribute; document that + no data members may be added, as the layout is shared across packages + +2026-09-22 Iñaki Ucar + + * inst/include/Rcpp/sugar/matrix/col.h: Fix Col constructor using ncol() + instead of nrow() to set the number of rows + * inst/tinytest/test_sugar.R: Add a non-square matrix test case for the + row()/col() sugar functions + +2026-09-05 Iñaki Ucar + + * .github/workflows/werror.yaml: Add -Wconversion + + * inst/include/Rcpp/macros/interface.h: Mark GenericProxy constructor as + explicit to resolve ambiguities with validated SEXP constructors + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/DataFrame.h: Idem with ad hoc constructor + * inst/include/Rcpp/vector/ListOf.h: In this case, the implicit conversion + of ListOf e.g. from List is intentional, so the previously generic + constructor now gets restricted to cases that are convertible to SEXP + + * inst/include/Rcpp/stats/dpq/dpq.h: Expand and homogenize R_xlen_t use + * inst/include/Rcpp/sugar/functions/head.h: Idem + * inst/include/Rcpp/vector/MatrixColumn.h: Idem + * inst/include/Rcpp/vector/MatrixRow.h: Idem + * inst/include/Rcpp/vector/RangeIndexer.h: Idem + * inst/include/Rcpp/internal/wrap.h: Idem and fix potential integer overflow + * inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: Idem and + fix a bug where rhs_is_na may return NaN instead of NA_INTEGER + * inst/include/Rcpp/Language.h: Revert incorrect use of R_xlen_t + * inst/include/Rcpp/vector/SubMatrix.h: Idem, because Matrix rows and cols + are restricted to int anyway + + * src/date.cpp: Add missing explicit integer narrowing + * inst/tinytest/cpp/dates.cpp: Add static_cast to time_t + * inst/tinytest/cpp/language.cpp: Fix implicit cast to int + * inst/tinytest/cpp/Matrix.cpp: Idem + * inst/tinytest/cpp/Module.cpp: Idem + * inst/tinytest/cpp/String.cpp: Idem + * inst/tinytest/cpp/Vector.cpp: Idem + * inst/include/Rcpp/vector/Matrix.h: Idem + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/sugar/Range.h: Idem + * inst/include/Rcpp/sugar/functions/seq_along.h: Idem + * inst/include/Rcpp/sugar/functions/rowSums.h: Idem + * inst/include/Rcpp/sugar/functions/sample.h: Idem + * inst/include/Rcpp/sugar/matrix/col.h: Idem + * inst/include/Rcpp/sugar/matrix/diag.h: Idem + * inst/include/Rcpp/sugar/matrix/lower_tri.h: Idem + * inst/include/Rcpp/sugar/matrix/outer.h: Idem + * inst/include/Rcpp/sugar/matrix/row.h: Idem + * inst/include/Rcpp/sugar/matrix/upper_tri.h: Idem + * inst/include/Rcpp/sugar/functions/var.h: Add static_cast to double + * inst/include/Rcpp/vector/Subsetter.h: Add several necessary static_cast + * inst/include/Rcpp/vector/MatrixBase.h: Idem + +2026-09-04 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-09-04 Iñaki Ucar + + * inst/include/Rcpp/Module.h: Update copyright + * inst/include/Rcpp/StretchyList.h: Idem + * inst/include/Rcpp/algo.h: Idem + * inst/include/Rcpp/config.h: Idem + * inst/include/Rcpp/date_datetime/newDateVector.h: Idem + * inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem + * inst/include/Rcpp/internal/wrap.h: Idem + * inst/include/Rcpp/macros/unroll.h: Idem + * inst/include/Rcpp/module/Module_Field.h: Idem + * inst/include/Rcpp/sugar/functions/cbind.h: Idem + * inst/include/Rcpp/sugar/functions/is_na.h: Idem + * inst/include/Rcpp/sugar/matrix/col.h: Idem + * inst/include/Rcpp/sugar/matrix/row.h: Idem + * inst/include/Rcpp/vector/RangeIndexer.h: Idem + * inst/include/Rcpp/vector/Subsetter.h: Idem + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/tinytest/cpp/InternalFunction.cpp: Idem + +2026-09-03 Iñaki Ucar + + * .github/workflows/werror.yaml: Add -Wcast-function-type + + * inst/include/Rcpp/routines.h: New function pointer RCPP_FUNC typedef used + as an intermediate cast target to avoid gcc's -Wcast-function-type warnings + * inst/include/Rcpp/Module.h: Idem + * src/rcpp_init.cpp: Idem + + * src/attributes.cpp: Generate RCPP_FUNC-routed casts in interface code + * inst/examples/ConvolveBenchmarks/overhead_1.cpp: Update generated code + * inst/tinytest/testRcppInterfaceExporter/src/RcppExports.cpp: Idem + * inst/tinytest/testRcppInterfaceExporter/inst/include/testRcppInterfaceExporter_RcppExports.h: Idem + + * .github/workflows/werror.yaml: Add -Wdeprecated-copy + + * inst/include/Rcpp/date_datetime/newDateVector.h: Remove redundant custom + copy operator to avoid -Wdeprecated-copy warnings + * inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem + + * .github/workflows/werror.yaml: Add -Wimplicit-fallthrough + + * inst/include/Rcpp/algo.h: Add explicit fallthrough comments to avoid + -Wimplicit-fallthrough warnings + * inst/include/Rcpp/vector/RangeIndexer.h: Idem + * inst/include/Rcpp/macros/unroll.h: Idem + + * .github/workflows/werror.yaml: Add -Wall -Wextra, substituting the + previous ones, which enables them but also -Wunused-parameter and more, + and switch to a container with gcc16 + + * src/api.cpp: Comment out parameters to avoid -Wunused-parameter warnings + * inst/include/Rcpp/Module.h: Idem + * inst/include/Rcpp/Promise.h: Idem + * inst/include/Rcpp/StretchyList.h: Idem + * inst/include/Rcpp/internal/wrap.h: Idem + * inst/include/Rcpp/module/Module_Field.h: Idem + * inst/include/Rcpp/sugar/functions/cbind.h: Idem + * inst/include/Rcpp/sugar/functions/is_na.h: Idem + * inst/include/Rcpp/sugar/matrix/col.h: Idem + * inst/include/Rcpp/sugar/matrix/row.h: Idem + * inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: Idem + * inst/include/Rcpp/sugar/tools/safe_math.h: Idem + * inst/include/Rcpp/vector/Subsetter.h: Idem + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/tinytest/cpp/InternalFunction.cpp: Idem + * inst/tinytest/cpp/attributes.cpp: Reference parameters in the body instead + * inst/tinytest/cpp/ListOf.cpp: Idem + * inst/tinytest/cpp/Vector.cpp: Idem + +2026-09-01 Iñaki Ucar + + * .github/workflows/werror.yaml: Add new CI file with -Werror enabled + +2026-08-08 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * README.md: Update package usage and download figures + +2026-08-03 Kevin Ushey + + * src/module.cpp (class__newInstance, CppMethod__invoke, + CppMethod__invoke_void, CppMethod__invoke_notvoid): Convert C++ + exceptions to R errors at these .External entry points, so that + e.g. calling a method on an uninitialized module object raises + the intended R error rather than terminating the R session + (#1495) + * inst/tinytest/test_module.R: Add regression test + + * inst/include/Rcpp/module/class.h (invoke): Protect freshly + computed method results while wrapping them in the result list + (#1493) + * inst/include/Rcpp/module/Module.h (invoke): Idem for module + function results + * inst/tinytest/cpp/Module.cpp: Add regression test + * inst/tinytest/test_module.R: Idem + + * inst/include/Rcpp/api/meat/proxy.h: Protect fresh SEXPs returned + from proxy get() in conversion and assignment operators (#1491) + * inst/include/Rcpp/proxy/Binding.h: Idem + * inst/include/Rcpp/proxy/NamesProxy.h: Idem + * inst/include/Rcpp/proxy/SlotProxy.h: Idem + * inst/tinytest/cpp/misc.cpp: Add regression tests + +2026-08-02 Kevin Ushey + + * inst/include/Rcpp/api/meat/StretchyList.h: Protect the new cell + from collection during Rf_install() in named push_back() (#1489) + * inst/tinytest/cpp/misc.cpp: Add regression test + * inst/tinytest/test_misc.R: Idem + +2026-07-24 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * man/dependsAttribute.Rd: Add \usage{} section to appease R-devel + * man/exportAttribute.Rd: Idem + * man/interfacesAttribute.Rd: Idem + * man/pluginsAttribute.Rd: Idem + +2026-07-13 Dirk Eddelbuettel + + * README.md: Revert back to mentioning rcpp-devel as R-forge is back, + mention updated doxygen documentation + +2026-07-01 Dirk Eddelbuettel + + * DESCRIPTION (Date, Version): Release 1.1.2 + + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Idem + + * inst/bib/Rcpp.bib: Small correction and reference update + * vignettes/rmd/Rcpp.bib: Idem + * vignettes/rmd/Rcpp-FAQ.Rmd: Quote rbenchmark package once + +2026-06-29 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-06-26 Kevin Ushey + + * inst/include/Rcpp/proxy/AttributeProxy.h: Do not rely on get__() + in attribute accessors so that classes such as ListOf compile + * inst/tinytest/cpp/ListOf.cpp: Added tests + * inst/tinytest/test_listof.R: Idem + +2026-06-23 Jeroen Ooms + + * Add templated integer-index overload on platforms without + LONG_VECTOR_SUPPORT such as wasm32 (PR #1482) + +2026-06-18 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp.bib: Updated references + * inst/bib/Rcpp.bib: Idem + +2026-06-09 Dirk Eddelbuettel + + * .github/workflows/ci.yaml: Update actions to current versions + * .github/workflows/docker.yaml: Idem + * .github/workflows/macos.yaml: Idem + * .github/workflows/stale.yaml: Idem + * .github/workflows/linuxarm.yaml: Idem + +2026-06-08 Dirk Eddelbuettel + + * R/RcppLdpath.R: Prefix three messages with 'Rcpp:::' to make it + more obvious where they originate from + +2026-05-05 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/Nullable.h (Nullable): Switch operatorT() from + opt-in to opt-out as six downstream packages have updated at CRAN + + * docker/ci-4.5/Dockerfile: Added based on r-base:4.5.3 + * .github/workflows/ci.yaml (jobs): Add rcpp/ci-4.5 to matrix + +2026-05-01 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-04-29 Kevin Ushey + + * inst/include/Rcpp/exceptions.h: Use stack buffer for warning + message to avoid string memory leakage in case of longjump + * inst/tinytest/test_dataframe.R: New test + +2026-04-23 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp.bib: Update one arXiv URL + * inst/bib/Rcpp.bib: Idem + * vignettes/Rcpp-libraries.pdf: Regenerated + +2026-04-13 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-04-12 Dirk Eddelbuettel + + * inst/include/Rcpp/Nullable.h (Nullable): 'operator T()' is now + behind an opt-in #define + +2026-04-09 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/Nullable.h (T): Also add 'operator T()' + (conditional on R (>= 4.3.0) as older versions croak) + +2026-04-08 Dirk Eddelbuettel + + * inst/include/Rcpp/Nullable.h (as): Enhance by adding an explicit + Rcpp::as() aiding cases where implicit as<> does not suffice + +2026-04-07 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date (twice) + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Stress interim status + +2026-04-06 Iñaki Ucar + + * inst/tinytest/test_vector.R: Complete test cases for setting NamesProxy + * inst/tinytest/cpp/Vector.cpp: Idem + +2026-04-02 Dirk Eddelbuettel + + * inst/include/Rcpp/Function.h: Further refinement for 4.6.0 to not + require R_NamespaceRegistry, using R_getRegisteredNamespace() instead + +2026-04-03 Dirk Eddelbuettel + + * inst/include/Rcpp/proxy/NamesProxy.h (set): Only set non-null values + +2026-04-01 Mattias Ellert + + * inst/discovery/cxx0x.R: Set execute permissions for script + with shebang + * inst/examples/ConvolveBenchmarks/overhead.r: Idem + * inst/examples/ConvolveBenchmarks/overhead.sh: Idem + * inst/examples/Misc/ifelseLooped.r: Idem + * inst/examples/Misc/newFib.r: Idem + * inst/examples/OpenMP/OpenMPandInline.r: Idem + * inst/tinytest/test_dispatch.R: Idem + +2026-03-29 Iñaki Ucar + + * inst/include/Rcpp/api/meat/Rcpp_eval.h: Remove check for non-API + R_UnboundValue, which is never returned anyway from Rf_findFun + * inst/include/Rcpp/Function.h: Use alternative to R_UnboundValue + * inst/include/Rcpp/Promise.h: Idem + * inst/include/Rcpp/Environment.h: Idem + some refactoring + +2026-03-26 Iñaki Ucar + + * inst/include/Rcpp/internal/r_vector.h: Use dataptr() again to avoid an + invalid pointer for empty vectors, which causes UB in e.g. std::copy + * inst/tinytest/test_vector.R: Add tests for std::copy + * inst/tinytest/cpp/Vector.cpp: Idem +2026-03-27 Iñaki Ucar + + * inst/include/Rcpp/vector/ListOf.h: Fix inheritance + * inst/include/Rcpp/proxy/NamesProxy.h: Fix compatibility + +2026-03-26 Dirk Eddelbuettel + + * inst/bib/Rcpp.bib: Refreshed a few more references + +2026-03-06 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date (twice) + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Updated + + * inst/include/Rcpp/Environment.h: For R 4.5.0 or later, use + R_ParentEnv instead of ENCLOS to reach parent environment + +2026-02-27 Iñaki Ucar + + * inst/include/Rcpp/sugar/functions/max.h: Fix UB for empty integer + * inst/include/Rcpp/sugar/functions/min.h: Idem + * inst/tinytest/test_sugar.R: Adapt tests + +2026-02-26 Iñaki Ucar + + * inst/include/Rcpp/sugar/tools/safe_math.h: New header implementing safe + versions of add/sub/mul operations for integral types + * inst/include/Rcpp/sugar/sugar.h: Includes the previous header + + * inst/include/Rcpp/sugar/functions/cumprod.h: Use the previous operations + * inst/include/Rcpp/sugar/functions/cumsum.h: Idem + * inst/include/Rcpp/sugar/functions/diff.h: Idem, also fixed a bug where + the diff was recomputed instead of returning the calculated value + * inst/include/Rcpp/sugar/functions/rowSums.h: Idem + * inst/include/Rcpp/sugar/functions/sum.h: Idem + * inst/include/Rcpp/sugar/operators/minus.h: Idem, also fixed a bug for + an incorrect Extractor specialization in Minus_Primitive_Vector + * inst/include/Rcpp/sugar/operators/plus.h: Idem + * inst/include/Rcpp/sugar/operators/times.h: Idem + + * inst/tinytest/test_sugar.R: New tests covering the new operations + * inst/tinytest/cpp/sugar.cpp: Idem + * inst/tinytest/cpp/sugar_safe_math.cpp: Idem + * inst/tinytest/cpp/sugar_safe_math_fallback.cpp: Idem + +2026-02-17 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Updated + +2026-02-17 Iñaki Ucar + + * inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: Fix UB + for non-integer RTYPEs in comparator + +2026-01-23 Dirk Eddelbuettel + + * inst/include/Rcpp/DataFrame.h (nrow): Use R_nrow() with R >= 4.6.0 + * inst/include/Rcpp/proxy/AttributeProxy.h (attributeNames): Use + R_getAttribNames() with R >= 4.6.0; + * inst/include/Rcpp/proxy/AttributeProxy.h (hasAttribute): Use + R_hasAttrib with R >= 4.6.0 + +2026-01-22 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2026-01-21 Dirk Eddelbuettel + + * inst/include/Rcpp/date_datetime/Datetime.h: Fractional seconds type + switched to 'int' for consistency, print format string re-adjusted + +2026-01-20 Dirk Eddelbuettel + + * inst/include/Rcpp/date_datetime/Datetime.h (format): Correct a + format string reflecting 'unsigned int' rather than 'int' + +2026-01-13 Dirk Eddelbuettel + + * inst/tinytest/cpp/attributes_extended.cpp: New unit tests + * inst/tinytest/test_attributes_extended.R: Idem + * inst/tinytest/test_compile_attributes_errors.R: Idem + * inst/tinytest/test_cppfunction_errors.R: Idem + * inst/tinytest/test_sourcecpp_errors.R: Idem + * R/Attributes.R: Remove #nocov tags + * src/attributes.cpp: Idem + +2026-01-12 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/exceptions_impl.h: Combine previous and current + methods enabling when 'execinfo.h' is found on selected platforms + +2026-01-08 Dirk Eddelbuettel + + * DESCRIPTION (Date, Version): Release 1.1.1 + + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Idem + +2026-01-07 Dirk Eddelbuettel + + * vignettes/pdf/*: Rebuilt + + * vignettes/rmd/Rcpp.bib: Updates to several URLs + * inst/bib/Rcpp.bib: Idem + * vignettes/rmd/*: Idem + * README.md: Idem + +2026-01-06 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * vignettes/rmd/Rcpp.bib: Update package versions dates + * inst/bib/Rcpp.bib: Idem + +2026-01-04 Dirk Eddelbuettel + + * inst/include/RcppCommon.h: No longer require RCPP_USING_UNWIND_PROTECT + * inst/include/Rcpp/r/headers.h: Idem + * inst/include/Rcpp/api/meat/Rcpp_eval.h: Idem + * inst/tinytest/cpp/stack.cpp: No longer test with RCPP_USING_UNWIND_PROTECT + * inst/tinytest/test_interface.R: Idem + +2026-01-01 Dirk Eddelbuettel + + * R/Attributes.R: Additional or adjusted #nocov tags + * R/Rcpp.package.skeleton.R: Idem + * R/RcppLdpath.R: Idem + * R/asis.R: Idem + * R/inline.R: Idem + * inst/include/Rcpp/api/meat/Rcpp_eval.h: Idem + * inst/include/Rcpp/internal/caster.h: Idem + * inst/include/Rcpp/internal/export.h: Idem + * inst/include/Rcpp/proxy/NamesProxy.h: Idem + * inst/include/Rcpp/proxy/SlotProxy.h: Idem + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/vector/proxy.h: Idem + * inst/include/Rcpp/vector/traits.h: Idem + * inst/include/Rcpp/Environment.h: Idem + * inst/include/Rcpp/Function.h: Idem + * inst/include/Rcpp/Module.h: Idem + * inst/include/Rcpp/S4.h: Idem + * inst/include/Rcpp/as.h: Idem + * inst/include/Rcpp/exceptions.h: Idem + * inst/include/Rcpp/r_cast.h: Idem + * src/attributes.cpp: Idem + * src/barrier.cpp: Idem + +2025-12-30 Dirk Eddelbuettel + + * tests/tinytest.R: Refine decision of when not to run all tests even + when development version number is seen + +2025-12-28 Dirk Eddelbuettel + + * README.md: Replace installation from drat section with r-universe + +2025-12-22 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/DataFrame.h (nrow): Simplified per #1430 discussion + relying on compact sequence representation removing use of ATTRIB + * inst/include/Rcpp/proxy/AttributeProxy.h (hasAttribute): For R + 4.6.0, rewritten using R_mapAttrib() avoiding to-be-removed ATTRIB() + +2025-12-21 Dirk Eddelbuettel + + * .github/workflows/docker.yaml: Add workflow_dispatch, update + checkout action + +2025-12-19 Dirk Eddelbuettel + + * man/RcppUnitTests.Rd: Removed outdated help page + +2025-12-17 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * DESCRIPTION (Depends): Add 'R (>= 3.5.0)' + +2025-12-16 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * src/barrier.cpp (dataptr): Remove check for 'R (>= 3.5.0)' + * inst/include/Rcpp/Rmath.h: Remove check for 'R (>= 3.1.2)' + * inst/include/Rcpp/Symbol.h: Remove check for 'R (>= 3.2.0)' + * inst/include/Rcpp/exceptions.h: Remove check for 'R (>= 3.5.0)' + * inst/include/Rcpp/r/headers.h: Idem + + * R/Attributes.R: Remove multiple checks for R version < 3.5.0 + * R/Rcpp.package.skeleton.R: Idem + * inst/tinytest/testRcppInterfaceUser/tests/tests.R: Remove one check + +2025-12-12 Dirk Eddelbuettel + + * inst/tinytest/test_system.R: Wrap suppressMessages() around three + tests for long-obsolete linker and compiler flags + + * inst/include/Rcpp/Environment.h: Replace use of Rf_findVarInFrame + with R_getVarEx (or R_getVar) if R 4.5.0 or later is used + * inst/include/Rcpp/Function.h: Idem + * src/barrier.cpp: Idem + +2025-12-10 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/Rmath.h: Do not access Rf_rnbeta + * inst/include/Rcpp/sugar/undoRmath.h: Remove #undef + +2025-12-06 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Updated + +2025-12-04 Iñaki Ucar + + * inst/include/Rcpp/r/headers.h: Include + * inst/include/RcppCommon.h: Drop , not used anymore + and dropped from the API; drop , included above + * src/api.cpp: Drop , dropped from the API + +2025-12-03 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-12-02 Dirk Eddelbuettel + + * R/loadRcppModules.R: Remove file with function deprecated years ago + * man/loadRcppModules-deprecated.Rd: Idem + * NAMESPACE: Remove reference to loadRcppModules() + * man/loadModule.Rd: Idem + * man/Rcpp-deprecated.Rd: Idem + * vignettes/rmd/Rcpp-modules.Rmd: Idem + +2025-12-01 Kevin Ushey + + * R/Attributes.R: Update OpenMP plugin for macOS + +2025-11-29 Dirk Eddelbuettel + + * R/RcppLdpath.R: Revisit deprecation warnings via 'message()' to be + turned into warning or deprecation in 12 or more months 'when suitable' + +2025-11-24 Dirk Eddelbuettel + + * inst/include/Rcpp/r/check_r_headers.h: Add RCPP_NO_R_HEADERS_CHECK + override to skip new check + +2025-11-23 Dirk Eddelbuettel + + * inst/include/Rcpp/r/check_r_headers.h: New header to check if R.h + or related R headers were installed first + * inst/include/RcppCommon.h: Call new header as first thing + +2025-11-12 Iñaki Ucar + + * inst/include/Rcpp/macros/mask.h: Lay the ground for Rf_error masking + with a warning at compilation time unless RCPP_NO_MASK_RF_ERROR is defined + * inst/include/RcppCommon.h: Include the previous file in the last place + * src/attributes.cpp: Use parentheses to protect call to Rf_error + * inst/tinytest/cpp/stack.cpp: Idem + * inst/tinytest/testRcppInterfaceExporter/src/RcppExports.cpp: Idem + +2025-11-04 Dirk Eddelbuettel + + * .github/workflows/macos.yaml (jobs): Roll macos-13 to macos-14 + +2025-11-01 Iñaki Ucar + + * inst/include/Rcpp/hash/IndexHash.h: Normalize values for all comparisons + * inst/include/Rcpp/hash/SelfHash.h: Idem + * inst/tinytest/test_sugar.R: Add test for signed zeroes + +2025-10-21 Iñaki Ucar + + * inst/include/Rcpp/exceptions_impl.h: Use __has_include to simplify checks + to enable demangling, making them robust for more platforms + +2025-10-13 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/tinytest/test_sugar.R: Simplify and generalize the August fix + as we no longer need to control for R-devel which has been corrected + +2025-09-04 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/internal/wrap.h (make_charsexp__impl__cstring): + Avoid a narrowing warning by casting explicitly + +2025-08-26 Dirk Eddelbuettel + + * inst/tinytest/test_sugar.R: For r-devel, use apply(x, DIM, mean, + na.rm=TRUE) instead of (row|col)Means for complex NA valued matrices + +2025-08-24 Dirk Eddelbuettel + + * .github/workflows/ci.yaml (jobs): Re-enable coverage, roll checkout + action to v5 + + * inst/tinytest/test_sugar.R: For now, park two tests of complex + matrix row and col means under R-devel, this could be a R-devel issue + +2025-07-20 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * R/compilerCheck.R: Remove unused function + * man/compilerCheck.Rd: Remove its documentation + +2025-07-19 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp.bib: Use DOI for R citation + * inst/bib/Rcpp.bib: Idem + +2025-07-18 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * R/asis.R (asisWeave, asisTangle): Borrowed with thanks from R.rsp + and shortened / simplified to provide 'asis' vignette processor + * R/zzz.R (.onLoad): Register new vignette processor + * vignettes/*.asis: New files with vignette info from .Rnw files + * vignettes/pdf/*.pdf: Moved to directory vignettes/ + * vignettes/*.Rnw: Removed + * man/asisWeave.Rd: Documentation + +2025-07-01 Dirk Eddelbuettel + + * DESCRIPTION (Date, Version): Release 1.1.0 + + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Idem + * vignettes/rmd/Rcpp.bib: Idem + * inst/bib/Rcpp.bib: Idem + * vignettes/pdf/*: Rebuilt + +2025-06-25 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-06-18 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp.bib: Use doi references for CRAN packages, + update versions, update some package titles + * inst/bib/Rcpp.bib: Idem + * vignettes/pdf/*: Re-rendered + +2025-06-05 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-06-02 Kevin Ushey + + * inst/include/Rcpp.h: Avoid copy when creating Language objects + * inst/include/Rcpp/Language.h: Idem + * inst/include/Rcpp/lgrow.h: Idem + * inst/tinytest/cpp/language.cpp: Idem + * inst/tinytest/test_language.R: Idem + +2025-05-27 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-05-23 Dirk Eddelbuettel + + * inst/include/Rcpp/date_datetime/newDateVector.h: Add default + constructor + * inst/include/Rcpp/date_datetime/newDatetimeVector.h: Idem + + * inst/tinytest/test_date.R: Add tests + * inst/tinytest/cpp/dates.cpp: Idem + +2025-05-06 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * R/Attributes.R: Support C++26 via plugin + +2025-05-05 Dirk Eddelbuettel + + * inst/tinytest/test_sugar.R: Condition four NA-related tests away on + arm64 on Linux too + + * .github/workflows/linuxarm.yaml (jobs): Add ubuntu-24.04-arm as + optional workflow_dispatch run + +2025-04-15 Dirk Eddelbuettel + + * docker/ci-4.4/Dockerfile: Added based on r-base:4.4.3 + * .github/workflows/ci.yaml (jobs): Add rcpp/ci-4.4 to matrix + +2025-03-31 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-03-29 Iñaki Ucar + + * inst/include/Rcpp/traits/result_of.h: Reimplement traits::result_of using + std::result_of (up to C++14) or std::invoke_result (C++17 or later), which + supports previous use cases and enables lambdas + * inst/include/Rcpp/sugar/functions/sapply.h: Use new result_of interface + * inst/include/Rcpp/sugar/functions/lapply.h: Idem + * inst/include/Rcpp/sugar/functions/mapply/mapply_2.h: Idem + * inst/include/Rcpp/sugar/functions/mapply/mapply_3.h: Idem + * inst/include/Rcpp/sugar/matrix/outer.h: Idem + * inst/tinytest/cpp/sugar.cpp: New tests for previous sugar functions + * inst/tinytest/test_sugar.R: Idem + +2025-03-26 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-03-26 Iñaki Ucar + + * inst/include/Rcpp/platform/compiler.h: Remove definitions of + RCPP_USING_UNORDERED_MAP and RCPP_USING_UNORDERED_SET + * inst/include/Rcpp/sugar/sets.h: Remove redefinition of macros + * inst/include/Rcpp/sugar/functions/self_match.h: Replace macros with + std::unordered_map and std::unordered_set respectively + * inst/include/Rcpp/sugar/functions/setdiff.h: Idem + * inst/include/Rcpp/sugar/functions/table.h: Idem + * inst/tinytest/cpp/wrap.cpp: Idem + +2025-03-24 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-03-24 Iñaki Ucar + + * inst/include/Rcpp/exceptions.h: Include C+11 variadic template definitions + unconditionally + * inst/include/Rcpp/exceptions/cpp11/exceptions.h: Removed + * inst/include/Rcpp/exceptions/cpp98/exceptions.h: Idem + + * src/attributes.cpp: Remove obsolete pre-C+11 paths based on __cplusplus + define checks + * inst/tinytest/cpp/sugar.cpp: Idem + * inst/include/Rcpp/Language.h: Idem + * inst/include/Rcpp/StringTransformer.h: Idem + * inst/include/Rcpp/algorithm.h: Idem + * inst/include/Rcpp/utils/tinyformat.h: Idem + * inst/include/Rcpp/longlong.h: Idem, unconditional RCPP_HAS_LONG_LONG_TYPES + + * src/api.cpp: Remove explicit RCPP_HAS_LONG_LONG_TYPES as availability is + both implicit and ensured + * inst/include/Rcpp/algorithm.h: Idem + * inst/include/Rcpp/traits/is_arithmetic.h: Idem + * inst/include/Rcpp/traits/longlong.h: Idem + +2025-03-21 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/String.h: Remove explicit RCPP_USING_CXX11 as + use of C++11 (or newer) is both implicit and ensured + * inst/include/Rcpp/macros/dispatch.h: Idem + * inst/include/Rcpp/platform/compiler.h: Idem + * inst/include/Rcpp/unwindProtect.h: Idem + * inst/tinytest/cpp/wrap.cpp: Idem + * src/api.cpp: Idem + +2025-03-18 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/module/class.h: Use variadic templates unconditionally + * inst/include/Rcpp/grow.h: Idem + * inst/include/Rcpp/DottedPair.h: Idem + * inst/include/Rcpp/Vector.h: Idem + * inst/include/Rcpp/Function.h: Idem + * inst/include/Rcpp/internal/call.h: Idem + * inst/include/Rcpp/InternalFunctionWithStdFunction.h: Idem + * inst/include/Rcpp/Module.h: Idem + * inst/include/Rcpp/traits/index_sequence.h: Idem + * inst/include/Rcpp/traits/named_object.h: Idem + * inst/include/Rcpp/Language.h: Idem + * inst/include/Rcpp/DataFrame.h: Idem + * inst/include/Rcpp/PairList.h: Idem + * inst/include/Rcpp/InternalFunction.h: Idem + + * inst/include/Rcpp/module/Module_generated_class_constructor.h: Removed + * inst/include/Rcpp/module/Module_generated_class_factory.h: Idem + * inst/include/Rcpp/module/Module_generated_method.h: Idem + * inst/include/Rcpp/module/Module_generated_Pointer_method.h: Idem + * inst/include/Rcpp/generated/grow__pairlist.h: Idem + * inst/include/Rcpp/generated/DottedPair__ctors.h: Idem + * inst/include/Rcpp/generated/Vector__create.h: Idem + * inst/include/Rcpp/generated/Function__operator.h: Idem + * inst/include/Rcpp/generated/InternalFunctionWithStdFunction_call.h: Idem + * inst/include/Rcpp/module/Module_generated_Constructor.h: Idem + * inst/include/Rcpp/module/Module_generated_CppFunction.h: Idem + * inst/include/Rcpp/module/Module_generated_CppMethod.h: Idem + * inst/include/Rcpp/module/Module_generated_Factory.h: Idem + * inst/include/Rcpp/module/Module_generated_Pointer_CppMethod.h: Idem + * inst/include/Rcpp/module/Module_generated_class_signature.h: Idem + * inst/include/Rcpp/module/Module_generated_ctor_signature.h: Idem + * inst/include/Rcpp/module/Module_generated_function.h: Idem + * inst/include/Rcpp/module/Module_generated_get_signature.h: Idem + * inst/include/Rcpp/generated/Language__ctors.h: Idem + * inst/include/Rcpp/generated/DataFrame_generated.h: Idem + * inst/include/Rcpp/generated/Pairlist__ctors.h: Idem + * inst/include/Rcpp/generated/InternalFunction__ctors.h: Idem + + * inst/include/Rcpp/platform/compiler.h: No longer define HAS_VARIADIC_TEMPLATES + * src/api.cpp (rcpp_can_use_cxx0x): Return true unconditionally + +2025-03-15 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/platform/compiler.h: Simplified and shortened + establishing C++11 as baseline; further PRs to complete this + * inst/include/Rcpp/String.h: Unconditionally use std::hash with C++11 + * inst/include/Rcpp/wrap.h: Unconditionally use static_assert + * inst/include/Rcpp/sugar/functions/sapply.h: Use std::result_of + (with C++11 or C++14) or std::invoke_result (C++17 or later) + * inst/include/Rcpp/sugar/functions/table.h: Use std::map + * inst/include/Rcpp/sugar/sets.h: Use std::unordered_{set,map} + * man/evalCpp.Rd: Update example + * src/api.cpp: Simplify rcpp_capabilities assignment + +2025-03-13 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * inst/include/Rcpp/Environment.h: Switch from R_lsInternal to + R_lsInternal3 as the former is now outlawed + +2025-03-10 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-03-08 Dirk Eddelbuettel + + * inst/include/Rcpp/Function.h: Use R_ClosureEnv instead of + deprecated CLOENV if under R >= 4.5.0 + +2025-03-07 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + + * src/barrier.cpp (dataptr): Replace remaining DATAPTR with + DATAPTR_RO for suitable R greater than 3.5.0 + +2025-02-11 Dirk Eddelbuettel + + * R/Rcpp.package.skeleton.R (Rcpp.package.skeleton): Support optional + argument 'github_user' to populate URL and BugReports if given + * man/Rcpp.package.skeleton.Rd: Document new optional argument + + * R/Rcpp.package.skeleton.R (Rcpp.package.skeleton): Default version + is now '0.0.1' and not '1.0' + * inst/tinytest/test_rcpp_package_skeleton.R: Adjust test accordingly + * inst/tinytest/test_expose_class.R: Idem + +2025-02-05 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-01-31 Lev Kandel + + * inst/include/Rcpp/internal/wrap.h: Add support for std::string_view + * inst/include/Rcpp/traits/r_type_traits.h: Idem + * inst/include/Rcpp/traits/wrap_type_traits.h: Idem + * inst/include/RcppCommon.h: Include + * inst/tinytest/cpp/wrap.cpp: Add unit test for wrap(std::string_view) + * inst/tinytest/test_wrap.R: Idem + +2025-01-26 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version and date + * inst/include/Rcpp/config.h: Idem + +2025-01-25 Dirk Eddelbuettel + + * vignettes/rmd/Rcpp-libraries.Rdm: Add mention of PACKAGE_types.h + * vignettes/rmd/Rcpp.bib: Add AsioHeaders + * inst/bib/Rcpp.bib: Idem + +2025-01-18 Ben Bolker + + * inst/NEWS.Rd: fix trivial typos in NEWS file + +2025-01-11 Dirk Eddelbuettel + + * DESCRIPTION (Date, Version): Release 1.0.14 + + * inst/include/Rcpp/config.h: Idem + * inst/NEWS.Rd: Idem + * vignettes/rmd/Rcpp.bib: Idem + * inst/bib/Rcpp.bib: Idem + * vignettes/pdf/*: Rebuilt + +2025-01-01 Dirk Eddelbuettel + + * inst/include/Rcpp/Benchmark/Timer.h (R_NO_REMAP): Protect include + with preceding #ifndef now that R 4.5.0 will set this too + +2024-11-25 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): Roll micro version to 1.0.13.6 + * inst/include/Rcpp/config.h (RCPP_DEV_VERSION): Idem + + * inst/tinytest/test_date.R: Minor adjustment to datetime format test + following R Dev Day change for R bug 17350 (and issue #1347 here) + +2024-11-25 Simon Guest + + * src/attributes.cpp: fix CPP source having to be writable + +2024-11-03 Marco Colombo + + * vignettes/rmd/Rcpp-FAQ.Rmd: Fixed typos + * vignettes/rmd/Rcpp-attributes.Rmd: Idem + * vignettes/rmd/Rcpp-extending.Rmd: Idem + * vignettes/rmd/Rcpp-introduction.Rmd: Idem + * vignettes/rmd/Rcpp-libraries.Rmd: Idem + * vignettes/rmd/Rcpp-modules.Rmd: Idem + * vignettes/rmd/Rcpp-package.Rmd: Idem + * vignettes/rmd/Rcpp-quickref.Rmd: Idem + * vignettes/rmd/Rcpp-sugar.Rmd: Idem + 2024-11-02 Dirk Eddelbuettel * tests/tinytest.R: Minor code edit, removal of two no longer diff --git a/Contributing.md b/Contributing.md index e57f25b99..8c975175d 100644 --- a/Contributing.md +++ b/Contributing.md @@ -54,10 +54,9 @@ reasonable defaults. ### Asking Questions -Please direct general questions to the -[Rcpp-devel](http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel) -mailing list (preferred, note that only subscribers can post), or post an -issue at GitHub. +Please direct general questions to the [discussion section of the GitHub +repo](https://github.com/RcppCore/Rcpp/discussions), or post an issue at +GitHub. Are you a new user of Rcpp? You might find the [vignettes](https://cran.r-project.org/package=Rcpp) helpful in getting diff --git a/DESCRIPTION b/DESCRIPTION index 1a4933735..04a98defc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 1.0.13.5 -Date: 2024-11-01 +Version: 1.1.2.9 +Date: 2026-11-30 Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org", comment = c(ORCID = "0000-0001-6419-907X")), person("Romain", "Francois", role = "aut", @@ -27,11 +27,12 @@ Description: The 'Rcpp' package provides R functions as well as C++ classes whic Francois (2011, ), the book by Eddelbuettel (2013, ) and the paper by Eddelbuettel and Balamuta (2018, ); see 'citation("Rcpp")' for details. +Depends: R (>= 3.5.0) Imports: methods, utils Suggests: tinytest, inline, rbenchmark, pkgKitten (>= 0.1.2) URL: https://www.rcpp.org, https://dirk.eddelbuettel.com/code/rcpp.html, https://github.com/RcppCore/Rcpp License: GPL (>= 2) BugReports: https://github.com/RcppCore/Rcpp/issues -MailingList: rcpp-devel@lists.r-forge.r-project.org RoxygenNote: 6.1.1 Encoding: UTF-8 +VignetteBuilder: Rcpp diff --git a/NAMESPACE b/NAMESPACE index 45a07c50f..9f6fdf377 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,6 @@ exportMethods(prompt, show, .DollarNames, initialize, "formals<-") export(Module, Rcpp.package.skeleton, populate, - loadRcppModules, # deprecated since Rcpp 0.12.5 released May 2016 setRcppClass, loadRcppClass, loadModule, @@ -33,8 +32,7 @@ export(Module, cpp_object_initializer, cpp_object_dummy, Rcpp.plugin.maker, - getRcppVersion - ) + getRcppVersion) S3method(print, bytes) S3method(format, Rcpp_stack_trace) S3method(str, Rcpp_stack_trace) diff --git a/R/00_classes.R b/R/00_classes.R index 589d3a836..7099367e4 100644 --- a/R/00_classes.R +++ b/R/00_classes.R @@ -24,47 +24,72 @@ setClassUnion("refGenerator", c("refObjectGenerator", "refClassGeneratorFunction ## Stands in for a reference class with those fields. setClass( "Module", contains = "environment" ) -setRefClass( "C++Field", - fields = list( - pointer = "externalptr", - cpp_class = "character", - read_only = "logical", - class_pointer = "externalptr", +## Plain S4 classes describing the fields, methods and constructors that a +## C++ class exposes. These used to be reference classes; creating one +## reference-class object per exposed method (via new()) dominated the +## time spent loading a module. A "$" method is provided below so that +## existing code using field-style access (x$pointer, x$info()) keeps working. +setClass( "C++Field", + representation( + pointer = "externalptr", + cpp_class = "character", + read_only = "logical", + class_pointer = "externalptr", docstring = "character" ) ) -setRefClass( "C++OverloadedMethods", - fields = list( - pointer = "externalptr", - class_pointer = "externalptr", - size = "integer", +setClass( "C++OverloadedMethods", + representation( + pointer = "externalptr", + class_pointer = "externalptr", + size = "integer", void = "logical", - const = "logical", - docstrings = "character", - signatures = "character", + const = "logical", + docstrings = "character", + signatures = "character", nargs = "integer" - ), - methods = list( - info = function(prefix = " " ){ - paste( - paste( prefix, signatures, ifelse(const, " const", "" ), "\n", prefix, prefix, - ifelse( nchar(docstrings), paste( "docstring :", docstrings) , "" ) - ) , collapse = "\n" ) - } ) ) -setRefClass( "C++Constructor", - fields = list( - pointer = "externalptr", - class_pointer = "externalptr", - nargs = "integer", - signature = "character", +setClass( "C++Constructor", + representation( + pointer = "externalptr", + class_pointer = "externalptr", + nargs = "integer", + signature = "character", docstring = "character" ) ) +## formerly the 'info' reference method of C++OverloadedMethods +.cpp_methods_info <- function( x, prefix = " " ){ + paste( + paste( prefix, x@signatures, ifelse(x@const, " const", "" ), "\n", prefix, prefix, + ifelse( nchar(x@docstrings), paste( "docstring :", x@docstrings) , "" ) + ) , collapse = "\n" ) +} + +## backwards compatible field-style access +setMethod( "$", "C++OverloadedMethods", function(x, name){ + if( identical( name, "info" ) ) + function( prefix = " " ) .cpp_methods_info( x, prefix ) + else + methods::slot( x, name ) +} ) +setMethod( "$", "C++Field", function(x, name) methods::slot( x, name ) ) +setMethod( "$", "C++Constructor", function(x, name) methods::slot( x, name ) ) + +## packages compiled against earlier versions of the Rcpp headers populate +## these objects with `$<-` (FieldProxy); keep those binaries loadable +.slot_dollar_assign <- function(x, name, value) { + methods::slot( x, name ) <- value + x +} +setReplaceMethod( "$", "C++OverloadedMethods", .slot_dollar_assign ) +setReplaceMethod( "$", "C++Field", .slot_dollar_assign ) +setReplaceMethod( "$", "C++Constructor", .slot_dollar_assign ) + setClass( "C++Class", representation( pointer = "externalptr", @@ -92,13 +117,23 @@ setClass( "C++Function", contains = "function" ) -.cppfunction_formals_gets <- function (fun, envir = environment(fun), value) { - bd <- body(fun) - b2 <- bd[[2L]] - for( i in seq_along(value) ){ - b2[[3L+i]] <- as.name( names(value)[i] ) +## passes the arguments named in 'names' on from the .External(entry, +## pointer, ...) call in expr; the call is searched for rather than assumed +## to be a top-level statement, as coverage tools wrap each statement +.cppfunction_set_external_args <- function( expr, names ){ + if( !is.call( expr ) ) + return( expr ) + if( identical( expr[[1L]], as.name( ".External" ) ) ) + return( as.call( c( as.list( expr )[1:3], lapply( names, as.name ) ) ) ) + for( i in seq_along( expr )[-1L] ){ + if( is.call( expr[[i]] ) ) + expr[[i]] <- .cppfunction_set_external_args( expr[[i]], names ) } - bd[[2]] <- b2 + expr +} + +.cppfunction_formals_gets <- function (fun, envir = environment(fun), value) { + bd <- .cppfunction_set_external_args( body(fun), names(value) ) f <- fun@.Data formals(f) <- value body(f) <- bd diff --git a/R/01_show.R b/R/01_show.R index 7d88ebcc4..4a7410801 100644 --- a/R/01_show.R +++ b/R/01_show.R @@ -41,8 +41,8 @@ setMethod( "show", "C++Class", function(object){ txt <- character( nctors ) for( i in seq_len(nctors) ){ ctor <- ctors[[i]] - doc <- ctor$docstring - txt[i] <- sprintf( " %s%s", ctor$signature, if( nchar(doc) ) sprintf( "\n docstring : %s", doc) else "" ) + doc <- ctor@docstring + txt[i] <- sprintf( " %s%s", ctor@signature, if( nchar(doc) ) sprintf( "\n docstring : %s", doc) else "" ) } writeLines( "Constructors:" ) writeLines( paste( txt, collapse = "\n" ) ) @@ -55,11 +55,11 @@ setMethod( "show", "C++Class", function(object){ writeLines( "\nFields: " ) for( i in seq_len(nfields) ){ f <- fields[[i]] - doc <- f$docstring + doc <- f@docstring txt[i] <- sprintf( " %s %s%s%s", - f$cpp_class, + f@cpp_class, names[i], - if( f$read_only ) " [readonly]" else "", + if( f@read_only ) " [readonly]" else "", if( nchar(doc) ) sprintf( "\n docstring : %s", doc ) else "" ) } @@ -74,7 +74,7 @@ setMethod( "show", "C++Class", function(object){ writeLines( "\nMethods: " ) txt <- character( nmethods ) for( i in seq_len(nmethods) ){ - txt[i] <- mets[[i]]$info(" ") + txt[i] <- .cpp_methods_info( mets[[i]], " " ) } writeLines( paste( txt, collapse = "\n" ) ) } else { diff --git a/R/Attributes.R b/R/Attributes.R index 583fbac6f..9136ec65e 100644 --- a/R/Attributes.R +++ b/R/Attributes.R @@ -1,6 +1,6 @@ # Copyright (C) 2012 - 2022 JJ Allaire, Dirk Eddelbuettel and Romain Francois -# Copyright (C) 2023 - 2024 JJ Allaire, Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +# Copyright (C) 2023 - 2026 JJ Allaire, Dirk Eddelbuettel, Romain Francois and Iñaki Ucar # # This file is part of Rcpp. # @@ -55,16 +55,16 @@ sourceCpp <- function(file = "", file <- normalizePath(file, winslash = "/") # error if the file extension isn't one supported by R CMD SHLIB - if (! tools::file_ext(file) %in% c("cc", "cpp")) { # #nocov start + if (! tools::file_ext(file) %in% c("cc", "cpp")) { stop("The filename '", basename(file), "' does not have an ", "extension of .cc or .cpp so cannot be compiled.") - } # #nocov end + } # validate that there are no spaces in the path on windows - if (.Platform$OS.type == "windows") { # #nocov start - if (grepl(' ', basename(file), fixed=TRUE)) { + if (.Platform$OS.type == "windows") { + if (grepl(' ', basename(file), fixed=TRUE)) { # #nocov start stop("The filename '", basename(file), "' contains spaces. This ", - "is not permitted.") + "is not permitted.") # #nocov end } } else { if (windowsDebugDLL) { @@ -73,7 +73,7 @@ sourceCpp <- function(file = "", "non-Windows platforms.") } windowsDebugDLL <- FALSE # now we do not need to deal with OS choice below - } # #nocov end + } } # get the context (does code generation as necessary) @@ -323,9 +323,9 @@ cppFunction <- function(code, # verify that a single function was exported and return it if (length(exported$functions) == 0) - stop("No function definition found") # #nocov + stop("No function definition found") else if (length(exported$functions) > 1) - stop("More than one function definition") # #nocov + stop("More than one function definition") # #nocov else { functionName <- exported$functions[[1]] invisible(get(functionName, env)) @@ -417,7 +417,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { pkgdir <- normalizePath(pkgdir, winslash = "/") descFile <- file.path(pkgdir,"DESCRIPTION") if (!file.exists(descFile)) - stop("pkgdir must refer to the directory containing an R package") # #nocov + stop("pkgdir must refer to the directory containing an R package") pkgDesc <- read.dcf(descFile)[1,] pkgname = .readPkgDescField(pkgDesc, "Package") depends <- c(.readPkgDescField(pkgDesc, "Depends", character()), @@ -429,7 +429,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { # check the NAMESPACE file to see if dynamic registration is enabled namespaceFile <- file.path(pkgdir, "NAMESPACE") if (!file.exists(namespaceFile)) - stop("pkgdir must refer to the directory containing an R package") # #nocov + stop("pkgdir must refer to the directory containing an R package") pkgNamespace <- readLines(namespaceFile, warn = FALSE) registration <- any(grepl("^\\s*useDynLib.*\\.registration\\s*=\\s*TRUE.*$", pkgNamespace)) @@ -499,21 +499,11 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { # built-in C++98 plugin .plugins[["cpp98"]] <- function() { - if (getRversion() >= "3.4") # with recent R versions, R can decide - list(env = list(USE_CXX98 = "yes")) - else - list(env = list(PKG_CXXFLAGS ="-std=c++98")) + list(env = list(USE_CXX98 = "yes")) } # built-in C++11 plugin .plugins[["cpp11"]] <- function() { - if (getRversion() >= "3.4") # with recent R versions, R can decide - list(env = list(USE_CXX11 = "yes")) - else if (getRversion() >= "3.1") # with recent R versions, R can decide - list(env = list(USE_CXX1X = "yes")) - else if (.Platform$OS.type == "windows") - list(env = list(PKG_CXXFLAGS = "-std=c++0x")) - else # g++-4.8.1 or later - list(env = list(PKG_CXXFLAGS ="-std=c++11")) + list(env = list(USE_CXX11 = "yes")) } # built-in C++11 plugin for older g++ compiler @@ -525,10 +515,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { ## this is the default in g++-6.1 and later ## per https://gcc.gnu.org/projects/cxx-status.html#cxx14 .plugins[["cpp14"]] <- function() { - if (getRversion() >= "3.4") # with recent R versions, R can decide - list(env = list(USE_CXX14 = "yes")) - else - list(env = list(PKG_CXXFLAGS ="-std=c++14")) + list(env = list(USE_CXX14 = "yes")) } # built-in C++1y plugin for C++14 and C++17 standard under development @@ -538,10 +525,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { # built-in C++17 plugin for C++17 standard (g++-6 or later) .plugins[["cpp17"]] <- function() { - if (getRversion() >= "3.4") # with recent R versions, R can decide - list(env = list(USE_CXX17 = "yes")) - else - list(env = list(PKG_CXXFLAGS ="-std=c++17")) + list(env = list(USE_CXX17 = "yes")) } # built-in C++20 plugin for C++20 @@ -560,6 +544,13 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { list(env = list(PKG_CXXFLAGS ="-std=c++23")) } +# built-in C++26 plugin for C++26 +.plugins[["cpp26"]] <- function() { + if (getRversion() >= "4.5") # with recent R versions, R can decide + list(env = list(USE_CXX26 = "yes")) + else + list(env = list(PKG_CXXFLAGS ="-std=c++26")) +} ## built-in C++1z plugin for C++17 standard under development ## note that as of Feb 2017 this is taken to be a moving target @@ -579,10 +570,74 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) { list(env = list(PKG_CXXFLAGS ="-std=c++2b")) } +.openmpPluginDefault <- function() { + list(env = list(PKG_CXXFLAGS = "-fopenmp", PKG_LIBS = "-fopenmp")) # #nocov start +} + +.openmpPluginDarwin <- function() { + + # generate a test script for compilation + script <- tempfile("openmp-detect-", fileext = ".cpp") + writeLines("", con = script) + on.exit(unlink(script, force = TRUE), add = TRUE) + + # get the C++ compiler from R + r <- file.path(R.home("bin"), "R") + output <- tryCatch( + system2(r, c("CMD", "SHLIB", "--dry-run", shQuote(script)), stdout = TRUE), + condition = identity + ) + if (inherits(output, "condition")) + return(.openmpPluginDefault()) + + # extract the compiler invocation from the shlib output + # use some heuristics here... + index <- grep("make would use", output) + compile <- output[[index + 1L]] + + # use everything up to the first include flag, which is normally + # the R headers from CPPFLAGS + idx <- regexpr(" -I", compile, fixed = TRUE) + cxx <- substring(compile, 1L, idx - 1L) + + # check the compiler version + command <- paste(cxx, "--version") + version <- tryCatch( + system(command, intern = TRUE), + condition = identity + ) + if (inherits(version, "condition")) + return(.openmpPluginDefault()) + + # if we're using Apple clang, use alternate flags + # assume libomp was installed following https://mac.r-project.org/openmp/ + if (any(grepl("Apple clang", version))) { + cxxflags <- "-Xclang -fopenmp" + libs <- "-lomp" + } + + # if we're using Homebrew clang, add in libomp include paths + else if (any(grepl("Homebrew clang", version))) { + machine <- Sys.info()[["machine"]] + prefix <- if (machine == "arm64") "/opt/homebrew" else "/usr/local" + cxxflags <- sprintf("-I%s/opt/libomp/include -fopenmp", prefix) + libs <- sprintf("-L%s/opt/libomp/lib -fopenmp", prefix) + + # otherwise, use default -fopenmp flags for other compilers (LLVM clang; gcc) + } else { + cxxflags <- "-fopenmp" + libs <- "-fopenmp" + } + + list(env = list(PKG_CXXFLAGS = cxxflags, PKG_LIBS = libs)) # #nocov end + +} + ## built-in OpenMP plugin -.plugins[["openmp"]] <- function() { - list(env = list(PKG_CXXFLAGS="-fopenmp", - PKG_LIBS="-fopenmp")) +.plugins[["openmp"]] <- if (Sys.info()[["sysname"]] == "Darwin") { + .openmpPluginDarwin +} else { + .openmpPluginDefault } .plugins[["unwindProtect"]] <- function() { # nocov start @@ -1232,41 +1287,39 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) { declarations = character() call_entries = character() - # if we are running R 3.4 or higher we can use an internal utility function + # we are running R 3.4 or higher so we can use an internal utility function # to automatically discover additional native routines that require registration - if (getRversion() >= "3.4") { - - # determine the package directory - pkgdir <- dirname(dirname(targetFile)) - - # get the generated code from R - con <- textConnection(object = NULL, open = "w") - on.exit(close(con), add = TRUE) - tools::package_native_routine_registration_skeleton( - dir = pkgdir, - con = con, - character_only = FALSE - ) - code <- textConnectionValue(con) - # look for lines containing call entries - matches <- regexec('^\\s+\\{"([^"]+)",.*$', code) - matches <- regmatches(code, matches) - matches <- Filter(x = matches, function(x) { - length(x) > 0 # #nocov start - }) - for (match in matches) { - routine <- match[[2]] - if (!routine %in% routines) { - declaration <- grep(sprintf("^extern .* %s\\(.*$", routine), code, - value = TRUE) - # FIXME: maybe we should extend this to *any* routine? - # or is there any case in which `void *` is not SEXP for a .Call? - if (routine == "run_testthat_tests") - declaration <- gsub("void *", "SEXP", declaration, fixed=TRUE) - declarations <- c(declarations, sub("^extern", "RcppExport", declaration)) - call_entries <- c(call_entries, match[[1]]) # #nocov end - } + # determine the package directory + pkgdir <- dirname(dirname(targetFile)) + + # get the generated code from R + con <- textConnection(object = NULL, open = "w") + on.exit(close(con), add = TRUE) + tools::package_native_routine_registration_skeleton( + dir = pkgdir, + con = con, + character_only = FALSE + ) + code <- textConnectionValue(con) + + # look for lines containing call entries + matches <- regexec('^\\s+\\{"([^"]+)",.*$', code) + matches <- regmatches(code, matches) + matches <- Filter(x = matches, function(x) { + length(x) > 0 # #nocov start + }) + for (match in matches) { + routine <- match[[2]] + if (!routine %in% routines) { + declaration <- grep(sprintf("^extern .* %s\\(.*$", routine), code, + value = TRUE) + # FIXME: maybe we should extend this to *any* routine? + # or is there any case in which `void *` is not SEXP for a .Call? + if (routine == "run_testthat_tests") + declaration <- gsub("void *", "SEXP", declaration, fixed=TRUE) + declarations <- c(declarations, sub("^extern", "RcppExport", declaration)) + call_entries <- c(call_entries, match[[1]]) # #nocov end } } diff --git a/R/Module.R b/R/Module.R index e0268012f..31a621e21 100644 --- a/R/Module.R +++ b/R/Module.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010 - 2021 John Chambers, Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2026 John Chambers, Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -161,6 +161,17 @@ cpp_object_maker <- function(typeid, pointer){ new( Class, .object_pointer = pointer ) } +# called by make_new_object() with the module class that the calling library +# registered for this C++ type, since other libraries' unrelated classes of +# the same name share its typeid; the object is created through that class's +# generator, as new() would look the reference class up by name +cpp_object_maker_by_class <- function(typeid, pointer, class_pointer){ + Class <- .classes_by_pointer[[ externalptr_address(class_pointer) ]] + if( is.null( Class ) ) + return( cpp_object_maker( typeid, pointer ) ) + Class@generator$new( .object_pointer = pointer ) +} + Module <- function( module, PACKAGE = methods::getPackageName(where), where = topenv(parent.frame()), mustStart = FALSE ) { if (inherits(module, "DLLInfo") && missing(mustStart)) mustStart <- TRUE # #nocov if (inherits(module, "Module")) { @@ -222,15 +233,12 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to fields <- cpp_fields( CLASS, where ) methods <- cpp_refMethods(CLASS, where) - generator <- methods::setRefClass( clname, - fields = fields, - contains = "C++Object", - methods = methods, - where = where - ) # just to make codetools happy .self <- .refClassDef <- NULL - generator$methods(initialize = + # Supply 'initialize' together with the other methods so that the + # reference class is analysed once, instead of a second full pass + # through refClassInformation() in generator$methods(...) + methods[["initialize"]] <- if (cpp_hasDefaultConstructor(CLASS)) function(...) Rcpp::cpp_object_initializer(.self,.refClassDef, ...) else @@ -238,10 +246,15 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to if (nargs()) Rcpp::cpp_object_initializer(.self,.refClassDef, ...) else Rcpp::cpp_object_dummy(.self, .refClassDef) # #nocov } - ) rm( .self, .refClassDef ) + generator <- methods::setRefClass( clname, + fields = fields, + contains = "C++Object", + methods = methods, + where = where + ) - classDef <- methods::getClass(clname) + classDef <- generator$def ## non-public (static) fields in class representation ## Should these become real fields? fields <- classDef@fieldPrototypes @@ -268,7 +281,7 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to } # #nocov end # promoting show to S4 - if( any( grepl( "show", names(CLASS@methods) ) ) ){ + if( "show" %in% names(CLASS@methods) ){ setMethod( "show", clname, function(object) object$show(), where = where ) # #nocov } @@ -281,7 +294,11 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to CLASS <- classes[[i]] clname <- CLASS@.Data demangled_name <- sub( "^Rcpp_", "", clname ) - .classes_map[[ CLASS@typeid ]] <- storage[[ demangled_name ]] <- .get_Module_Class( module, demangled_name, xp ) + # reuse the C++Class object already built by Module__classes_info + # rather than rebuilding it (and all of its method/field objects) + CLASS@generator <- generators[[ clname ]] + .classes_map[[ CLASS@typeid ]] <- storage[[ demangled_name ]] <- CLASS + .classes_by_pointer[[ externalptr_address( CLASS@pointer ) ]] <- CLASS # exposing enums values as CLASS.VALUE # (should really be CLASS$value but I don't know how to do it) @@ -299,24 +316,21 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to functions <- .Call( Module__functions_names, xp ) for( fun in functions ){ storage[[ fun ]] <- .get_Module_function( module, fun, xp ) - - # register as(FROM, TO) methods - converter_rx <- "^[.]___converter___(.*)___(.*)$" - if( length( matches <- grep( converter_rx, functions ) ) ){ # #nocov start - for( i in matches ){ - fun <- functions[i] - from <- sub( converter_rx, "\\1", fun ) - to <- sub( converter_rx, "\\2", fun ) - converter <- function( from ){} - body( converter ) <- substitute( { CONVERT(from) }, - list( CONVERT = storage[[fun]] ) - ) - setAs( from, to, converter, where = where ) - } - } # #nocov end - } + # register as(FROM, TO) methods once storage holds every function: the + # converter body captures storage[[fun]] by value via substitute() + converter_rx <- "^[.]___converter___(.*)___(.*)$" + for( fun in grep( converter_rx, functions, value = TRUE ) ){ # #nocov start + from <- sub( converter_rx, "\\1", fun ) + to <- sub( converter_rx, "\\2", fun ) + converter <- function( from ){} + body( converter ) <- substitute( { CONVERT(from) }, + list( CONVERT = storage[[fun]] ) + ) + setAs( from, to, converter, where = where ) + } # #nocov end + assign( "storage", storage, envir = as.environment(module) ) module } @@ -324,15 +338,15 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to dealWith <- function( x ) if(isTRUE(x[[1]])) invisible(NULL) else x[[2]] # #nocov method_wrapper <- function( METHOD, where ){ - noargs <- all( METHOD$nargs == 0 ) + noargs <- all( METHOD@nargs == 0 ) stuff <- list( - class_pointer = METHOD$class_pointer, - pointer = METHOD$pointer, + class_pointer = METHOD@class_pointer, + pointer = METHOD@pointer, CppMethod__invoke = CppMethod__invoke, CppMethod__invoke_void = CppMethod__invoke_void, CppMethod__invoke_notvoid = CppMethod__invoke_notvoid, dealWith = dealWith, - docstring = METHOD$info("") + docstring = .cpp_methods_info( METHOD, "" ) ) f <- function(...) NULL if( noargs ){ @@ -340,7 +354,7 @@ method_wrapper <- function( METHOD, where ){ } extCall <- if( noargs ) { - if( all( METHOD$void ) ){ + if( all( METHOD@void ) ){ # all methods are void, so we know we want to return invisible(NULL) substitute( { @@ -348,7 +362,7 @@ method_wrapper <- function( METHOD, where ){ .External(CppMethod__invoke_void, class_pointer, pointer, .pointer ) invisible(NULL) } , stuff ) - } else if( all( ! METHOD$void ) ){ + } else if( all( ! METHOD@void ) ){ # none of the methods are void so we always return the result of # .External substitute( @@ -366,7 +380,7 @@ method_wrapper <- function( METHOD, where ){ } , stuff ) # #nocov end } } else { - if( all( METHOD$void ) ){ + if( all( METHOD@void ) ){ # all methods are void, so we know we want to return invisible(NULL) substitute( { @@ -374,7 +388,7 @@ method_wrapper <- function( METHOD, where ){ .External(CppMethod__invoke_void, class_pointer, pointer, .pointer, ...) invisible(NULL) } , stuff ) - } else if( all( ! METHOD$void ) ){ + } else if( all( ! METHOD@void ) ){ # none of the methods are void so we always return the result of # .External substitute( @@ -426,8 +440,8 @@ binding_maker <- function( FIELD, where ){ .Call( CppField__get, class_pointer, pointer, .pointer) else .Call( CppField__set, class_pointer, pointer, .pointer, x) - }, list(class_pointer = FIELD$class_pointer, - pointer = FIELD$pointer, + }, list(class_pointer = FIELD@class_pointer, + pointer = FIELD@pointer, CppField__get = CppField__get, CppField__set = CppField__set )) environment(f) <- where diff --git a/R/Rcpp.package.skeleton.R b/R/Rcpp.package.skeleton.R index 80be4380a..d8c989b50 100644 --- a/R/Rcpp.package.skeleton.R +++ b/R/Rcpp.package.skeleton.R @@ -1,4 +1,4 @@ -# Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2009 - 2026 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -24,6 +24,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), maintainer = if (missing(author)) "Your Name" else author, email = "your@email.com", + githubuser = NA_character_, license = "GPL (>= 2)") { havePkgKitten <- requireNamespace("pkgKitten", quietly=TRUE) @@ -90,18 +91,26 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), paste(splitname[-length(splitname)], collapse=" "), splitname[length(splitname)], email)) - #x[, "Author"] <- author - #x[, "Maintainer"] <- sprintf("%s <%s>", maintainer, email) + fields_written <- c("Package", "Type", "Title", "Version", "Date", + "Authors@R", "Description", "License", "Imports", "LinkingTo") + if (!is.na(githubuser)) { # #nocov start + x <- cbind(x, matrix("", 1, 1, dimnames=list("", "URL"))) + x[1, "URL"] <- paste0("https://github.com/", githubuser, "/", name) + x <- cbind(x, matrix("", 1, 1, dimnames=list("", "BugReports"))) + x[1, "BugReports"] <- paste0("https://github.com/", githubuser, "/", name, "/issues") + + fields_written <- c("Package", "Type", "Title", "Version", "Date", + "Authors@R", "Description", "URL", "BugReports", + "License", "Imports", "LinkingTo") + } # #nocov end + x[, "License"] <- license x[, "Title"] <- "Concise Summary of What the Package Does" x[, "Description"] <- "More about what it does (maybe more than one line)." + x[, "Version"] <- "0.0.1" message( " >> added Imports: Rcpp" ) message( " >> added LinkingTo: Rcpp" ) - write.dcf(x, file = DESCRIPTION) - write.dcf(x[1, c("Package", "Type", "Title", "Version", "Date", - "Authors@R", "Description", "License", "Imports", "LinkingTo"), - drop = FALSE], - file = DESCRIPTION) + write.dcf(x[1, fields_written, drop = FALSE], file = DESCRIPTION) } ## add useDynLib and importFrom to NAMESPACE @@ -109,11 +118,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), lines <- readLines(NAMESPACE) ns <- file(NAMESPACE, open="w") if (!any(grepl("useDynLib", lines))) { - if (getRversion() >= "3.4.0") { - lines <- c(sprintf( "useDynLib(%s, .registration=TRUE)", name), lines) - } else { - lines <- c(sprintf( "useDynLib(%s)", name), lines) # #nocov - } + lines <- c(sprintf( "useDynLib(%s, .registration=TRUE)", name), lines) writeLines(lines, con = ns) message(" >> added useDynLib directive to NAMESPACE" ) } @@ -131,7 +136,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), ## update the package description help page if (havePkgKitten) { # if pkgKitten is available, use it - pkgKitten::playWithPerPackageHelpPage(name, path, maintainer, email) + pkgKitten::playWithPerPackageHelpPage(name, path, maintainer, email) # #nocov } else { .playWithPerPackageHelpPage(name, path, maintainer, email) # #nocov } @@ -193,14 +198,10 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(), # generate native routines if we aren't using attributes (which already generate # them automatically) and we have at least R 3.4 if (!attributes) { - if (getRversion() >= "3.4.0") { - con <- file(file.path(src, "init.c"), "wt") - tools::package_native_routine_registration_skeleton(root, con=con) - close(con) - message(" >> created init.c for package registration") - } else { - message(" >> R version older than 3.4.0 detected, so NO file init.c created.") # #nocov - } + con <- file(file.path(src, "init.c"), "wt") + tools::package_native_routine_registration_skeleton(root, con=con) + close(con) + message(" >> created init.c for package registration") } lines <- readLines(package.doc <- file.path( root, "man", sprintf("%s-package.Rd", name))) diff --git a/R/RcppLdpath.R b/R/RcppLdpath.R index c0a37b528..112f92515 100644 --- a/R/RcppLdpath.R +++ b/R/RcppLdpath.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010 - 2021 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -25,7 +25,7 @@ Rcpp.quoteNonStandard <- function(path) { ## On unix, check if path has only characters that do not need quoting noquote <- .Platform$OS.type == "unix" && grepl("^[[:alnum:]/._~+@%-]*$", path) ## If no quoting needed return unchanged else quote input - if (noquote) path else shQuote(path) + if (noquote) path else shQuote(path) # #nocov } ## Use R's internal knowledge of path settings to find the lib/ directory @@ -33,6 +33,7 @@ Rcpp.quoteNonStandard <- function(path) { RcppLdPath <- function() { #.Deprecated(msg=paste("This function is now deprecated as it has not", # "been needed since 2013.")) + message("'RcppLdPath' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") "" } @@ -47,6 +48,7 @@ RcppLdPath <- function() { RcppLdFlags <- function() { #.Deprecated(msg=paste("This function is now deprecated as it has not", # "been needed since 2013.")) + message("'RcppLdFlags' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") "" } @@ -64,14 +66,16 @@ RcppCxxFlags <- function(cxx0x=FALSE) { ## Shorter names, and call cat() directly ## CxxFlags defaults to no using c++0x extensions are these are considered non-portable -CxxFlags <- function(cxx0x=FALSE) { +CxxFlags <- function(cxx0x=FALSE) { # #nocov start #.Deprecated(msg=paste("This function is now deprecated as R uses minimally", # "viable compilers om all platforme.")) - cat(RcppCxxFlags(cxx0x=cxx0x)) # #nocov + message("'Rcpp:::CxxFlags' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") + cat(RcppCxxFlags(cxx0x=cxx0x)) # #nocov end } ## LdFlags defaults to static linking on the non-Linux platforms Windows and OS X LdFlags <- function() { + message("'Rcpp:::LdFlags' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") cat(RcppLdFlags()) } @@ -80,14 +84,16 @@ RcppCapabilities <- capabilities <- function() .Call( rcpp_capabilities ) # compile, load and call the cxx0x.c script to identify whether # the compiler is GCC >= 4.3 -RcppCxx0xFlags <- function() { +RcppCxx0xFlags <- function() { # #nocov start #.Deprecated(msg=paste("This function is now deprecated as R uses minimally", # "viable compilers om all platforme.")) - script <- Rcpp.system.file( "discovery", "cxx0x.R" ) # #nocov start + message("'RcppCxx0xFlags' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") + script <- Rcpp.system.file( "discovery", "cxx0x.R" ) flag <- capture.output( source( script ) ) flag } Cxx0xFlags <- function() { + message("'Rcpp:::Cxx0xFlags' has not been needed since 2013 (!!) and may get removed in 2027. Please update your 'Makevars'.") cat(RcppCxx0xFlags()) # #nocov end } diff --git a/R/asis.R b/R/asis.R new file mode 100644 index 000000000..5fede4fc5 --- /dev/null +++ b/R/asis.R @@ -0,0 +1,56 @@ +## These two functions are borrowed with grateful appreciation from the R.rsp package +## by Henrik Bengtsson licensed under LGPL (>= 2.1) and somewhat simplified / shortened +## feature-reduced here. Please see the R.rsp for a full-featured version and documentation + +##' Simple \sQuote{asis} Vignette Processor +##' +##' To pass pre-made pdf vignettes through \dQuote{as is}, a simple vignette +##' process is added. It is derived from the more feature-complete one in the \pkg{R.rsp} +##' package. To use it, add files named like the pdf file plus an appended \code{.asis} +##' with the vignette metainformation and register the vignette processor, see the examples. +##' +##' @title Process pdf vignettes \sQuote{asis} +##' @name asisWeave +##' @param file character Filename to be processed +##' @param ... dots Currently ignored +##' @param pattern character A regular expression describing the filename pattern +##' @return The respective filename is returned, invisibly +##' @author Henrik Bengtsson for the original versions in package \pkg{R.rsp}, +##' Dirk Eddelbuettel for the shortened ones used here +##' @examples +##' # To register this vignette engine in another package, add +##' # \code{VignetteBuilder: Rcpp} as well as \code{Suggests: Rcpp} to \code{DESCRIPTION} +##' # which uses the registration this package provides via +##' \dontrun{tools::vignetteEngine("asis", package = pkgname, pattern = "[.](pdf|html)[.]asis$", +##' weave = asisWeave, tangle = asisTangle)} +##' +##' # Use a .asis file as in the Rcpp package, for example Rcpp-FAQ.pdf.asis has these lines: +##' # %\VignetteIndexEntry{Rcpp-FAQ} +##' # %\VignetteKeywords{Rcpp, FAQ, R, Cpp} +##' # %\VignettePackage{Rcpp} +##' # %\VignetteEncoding{UTF-8} +##' # %\VignetteEngine{Rcpp::asis} +asisWeave <- function (file, ...) { # #nocov start + output <- tools::file_path_sans_ext(basename(file)) + if (!file.exists(output)) { + outputS <- file.path("..", "inst", "doc", output) + if (file.exists(outputS)) { + file.copy(outputS, output, overwrite = TRUE) + output <- outputS + } else { + stop("No file to process", call. = FALSE) + } + } + Sys.setFileTime(output, time = Sys.time()) + invisible(output) +} + +##' @rdname asisWeave +asisTangle <- function (file, ..., pattern = "(|[.][^.]*)[.]asis$") { + workdir <- "." + filename <- basename(file) + fullname <- gsub(pattern, "", filename) + filenameR <- sprintf("%s.R", fullname) + cat(sprintf("### This is an R script tangled from '%s'\n", filename), file = filenameR) + invisible(filenameR) +} # #nocov end diff --git a/R/compilerCheck.R b/R/compilerCheck.R deleted file mode 100644 index 25a67d5cf..000000000 --- a/R/compilerCheck.R +++ /dev/null @@ -1,36 +0,0 @@ -##' Helper function to establish minimal compiler versions, currently limited -##' only to \code{g++} which (particularly for older RHEL/CentOS releases) is -##' too far behind current C++11 standards required for some packages. -##' -##' This function looks up \code{g++} (as well as optional values in the -##' \code{CXX} and \code{CXX1X} environment variables) in the \code{PATH}. For -##' all values found, the output of \code{g++ -v} is analyzed for the version -##' string, which is then compared to the given minimal version. -##' @title Check for Minimal (g++) Compiler Version -##' @param minVersion An object of type \code{package_version}, with a default -##' of version 4.6.0 -##' @return A boolean value is returned, indicating if the minimal version is -##' being met -##' @author Dirk Eddelbuettel -compilerCheck <- function(minVersion=package_version("4.6.0")) { # nocov start - - binaries <- c("g++", Sys.getenv("CXX", unset=""), Sys.getenv("CXX1X", unset="")) - binpaths <- lapply(binaries, function(b) { if (b=="") NULL else Sys.which(b) }) - - allgood <- FALSE - rl <- lapply(binpaths, function(b) { - if (is.null(b)) return(NULL) - con <- pipe(paste(b, "-v 2>&1"), "r") # NB: not --version, but -v - lines <- readLines(con) - close(con) - lines <- lines[grepl("^g.. version", lines)] - if (length(lines) == 0) return(NULL) - ver <- strsplit(lines, " ")[[1]][3] # format is 'gcc version x.y.z ....' - package_version(ver) >= minVersion - }) - all(do.call(c, rl)) # drops NULLs -} # nocov end - -## TODO: maybe not limit to gcc/g++ -## TODO: maybe be smarter about combination of path, CXX and CXX1X ? -## TODO: maybe make env.var optional arguments too diff --git a/R/inline.R b/R/inline.R index 8243e033f..165c615ed 100644 --- a/R/inline.R +++ b/R/inline.R @@ -1,4 +1,4 @@ -# Copyright (C) 2009 - 2017 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2009 - 2026 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -38,12 +38,11 @@ Rcpp.plugin.maker <- function(include.before = "", #endif using namespace Rcpp;", include.before, include.after) - out <- list(env = list( PKG_LIBS = libs ), includes = includes, LinkingTo = LinkingTo , body = function( x ) { - sprintf( "BEGIN_RCPP\n%s\nEND_RCPP", x ) + sprintf( "BEGIN_RCPP\n%s\nEND_RCPP", x ) # #nocov }, Depends = Depends, Imports = Imports) @@ -54,4 +53,3 @@ using namespace Rcpp;", include.before, include.after) } inlineCxxPlugin <- Rcpp.plugin.maker() - diff --git a/R/loadModule.R b/R/loadModule.R index 77ac55139..82d2dcda1 100644 --- a/R/loadModule.R +++ b/R/loadModule.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010 - 2015 John Chambers, Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2010 - 2026 John Chambers, Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -54,12 +54,12 @@ loadModule <- function( module, what = character(), loadNow, if(exists(metaName, envir = env, inherits = FALSE)) loadM <- get(metaName, envir = env) } - else if(is(module, "Module")) { - loadM <- as.environment(module) # #nocov - module <- get(loadM, "moduleName") # #nocov + else if(is(module, "Module")) { # #nocov start + loadM <- as.environment(module) + module <- get(loadM, "moduleName") } else - stop(gettextf("Argument \"module\" should be a module or the name of a module: got an object of class \"%s\"", class(module))) + stop(gettextf("Argument \"module\" should be a module or the name of a module: got an object of class \"%s\"", class(module))) # #nocov end if(missing(loadNow)) { # test it if(is.null(loadM)) loadM <- tryCatch(Module( module, mustStart = TRUE, where = env ), @@ -104,7 +104,7 @@ loadModule <- function( module, what = character(), loadNow, assignAs <- .moduleNames(what) for( i in seq_along(what) ) { if(.botched) - assign(assignAs[[i]], NULL, envir = storage) + assign(assignAs[[i]], NULL, envir = storage) # #nocov else assign(assignAs[[i]], get(what[[i]], envir = storage), envir = env) } @@ -120,4 +120,3 @@ loadModule <- function( module, what = character(), loadNow, invisible(myCall) # #nocov } } - diff --git a/R/loadRcppModules.R b/R/loadRcppModules.R deleted file mode 100644 index 844da8fc8..000000000 --- a/R/loadRcppModules.R +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2010 - 2016 John Chambers, Dirk Eddelbuettel and Romain Francois -# -# This file is part of Rcpp. -# -# Rcpp is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# Rcpp is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Rcpp. If not, see . - -loadRcppModules <- function(direct=TRUE) { # #nocov start - # deprecation added May 2016, 'loadModule' has been prefered for years - .Deprecated("loadModule") - - ## hunt for the namespace of the package that calls this - calls <- sys.calls() - w <- which( sapply( calls, function(call){ - identical( call[[1L]], as.name( "runHook" ) ) - } ) ) - if( !length(w) ) - stop( "loadRcppModules can only be used within a .onLoad function" ) - w <- w[ length(w) ] - call <- calls[[w]] - if( !identical( call[[2L]], ".onLoad" ) ) - stop( "loadRcppModules can only be used within a .onLoad function" ) - f <- sys.frame( w ) - ns <- get("env", f ) - if( !isNamespace( ns ) ) - stop( "loadRcppModules not called from a namespace" ) - pkg <- get( "pkgname", f ) - lib <- get( "libname", f ) - - ## look for declared modules in the DESCRIPTION fields - description <- packageDescription(pkg, lib.loc=lib) - modules <- description[["RcppModules"]] - if( !is.null( modules ) ){ - modules <- strsplit( modules, "[[:space:]]*,[[:space:]]*")[[1L]] - for( m in modules ){ - tryCatch( { - mod <- Module( m, pkg, mustStart = TRUE) - if(isTRUE(direct)){ - populate( mod, ns ) - } else { - forceAssignInNamespace( m, mod, ns ) - } - assign(.moduleMetaName(m), mod, envir = ns) - }, error = function(e){ - stop( sprintf( "failed to load module %s from package %s\n%s", m, pkg, conditionMessage(e) ) ) - }) - } - } -} # #nocov end diff --git a/R/zzz.R b/R/zzz.R index 2ed6bfd79..ea5207915 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,4 +1,4 @@ -# Copyright (C) 2009 - 2016 Dirk Eddelbuettel and Romain Francois +# Copyright (C) 2009 - 2025 Dirk Eddelbuettel and Romain Francois # # This file is part of Rcpp. # @@ -18,9 +18,11 @@ .dummyInstancePointer <- new.env() # just something permanent .classes_map <- new.env() +.classes_by_pointer <- new.env() .onLoad <- function(libname, pkgname){ - new_dummyObject(.dummyInstancePointer) # nocov -} - + new_dummyObject(.dummyInstancePointer) # nocov start + tools::vignetteEngine("asis", package = pkgname, pattern = "[.](pdf|html)[.]asis$", + weave = asisWeave, tangle = asisTangle) # nocov end +} diff --git a/README.md b/README.md index dfc3be5b3..a92631602 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,10 @@ [![CRAN use](https://jangorecki.gitlab.io/rdeps/Rcpp/CRAN_usage.svg?sanitize=true)](https://cran.r-project.org/package=Rcpp) [![CRAN indirect](https://jangorecki.gitlab.io/rdeps/Rcpp/indirect_usage.svg?sanitize=true)](https://cran.r-project.org/package=Rcpp) [![BioConductor use](https://jangorecki.gitlab.io/rdeps/Rcpp/BioC_usage.svg?sanitize=true)](https://cran.r-project.org/package=Rcpp) -[![JSS](https://img.shields.io/badge/JSS-10.18637%2Fjss.v040.i08-brightgreen)](https://dx.doi.org/10.18637/jss.v040.i08) -[![Springer useR!](https://img.shields.io/badge/Springer%20useR!-10.1007%2F978--1--4614--6868--4-brightgreen)](https://www.amazon.com/gp/product/1461468671/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1461468671&linkCode=as2&tag=rcpp-20&linkId=3P5LNUWOAQ2YMEJ6) -[![TAS](https://img.shields.io/badge/TAS-10.1080%2F00031305.2017.1375990-brightgreen)](https://dx.doi.org/10.1080/00031305.2017.1375990) +[![Doxygen Documentation](https://img.shields.io/badge/document-doxygen-brightgreen)](https://dirk.eddelbuettel.com/code/rcpp/html/) +[![JSS](https://img.shields.io/badge/JSS-10.18637%2Fjss.v040.i08-brightgreen)](https://doi.org/10.18637/jss.v040.i08) +[![Springer useR!](https://img.shields.io/badge/Springer%20useR!-10.1007%2F978--1--4614--6868--4-brightgreen)](https://link.springer.com/book/10.1007/978-1-4614-6868-4) +[![TAS](https://img.shields.io/badge/TAS-10.1080%2F00031305.2017.1375990-brightgreen)](https://doi.org/10.1080/00031305.2017.1375990) ### Synopsis @@ -37,7 +38,7 @@ provides a good entry point to Rcpp as do the [Rcpp website](https://www.rcpp.org), the [Rcpp page](https://dirk.eddelbuettel.com/code/rcpp.html) and the [Rcpp Gallery](https://gallery.rcpp.org). Full documentation is provided by the -[Rcpp book](https://www.amazon.com/gp/product/1461468671/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1461468671&linkCode=as2&tag=rcpp-20&linkId=3P5LNUWOAQ2YMEJ6). +[Rcpp book](https://link.springer.com/book/10.1007/978-1-4614-6868-4). Other highlights: @@ -78,9 +79,11 @@ Among the other vignettes are the [Rcpp FAQ](https://cran.r-project.org/package=Rcpp/vignettes/Rcpp-FAQ.pdf) and the introduction to [Rcpp Attributes](https://cran.r-project.org/package=Rcpp/vignettes/Rcpp-attributes.pdf). -Additional documentation is available via the [Rcpp book](https://www.amazon.com/gp/product/1461468671/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1461468671&linkCode=as2&tag=rcpp-20&linkId=3P5LNUWOAQ2YMEJ6) +Additional documentation is available via the [Rcpp book](https://link.springer.com/book/10.1007/978-1-4614-6868-4) by Eddelbuettel (2013, Springer); see 'citation("Rcpp")' for details. +[C++ class structure documentation][rcpp-doxygen] (generated by `doxygen`) is available as well. + ### Performance Rcpp follows the C++ motto of _"you pay only for what you use"_ and imposes @@ -109,14 +112,14 @@ been factored out of Rcpp into the package RcppClassic, and it is still available for code relying on the older interface. New development should always use this Rcpp package instead. -Other usage examples are provided by packages using Rcpp. As of early January -2024, there are 2791 [CRAN](https://cran.r-project.org) packages using Rcpp -(corresponding to 13.8% of all packages, and 59.9% of packages containing -compiled code), a further 254 [BioConductor](https://www.bioconductor.org) +Other usage examples are provided by packages using Rcpp. As of early August +2026, there are 3293 [CRAN](https://cran.r-project.org) packages using Rcpp +(corresponding to 13.4% of all packages, and 61.3% of packages containing +compiled code), a further 292 [BioConductor](https://www.bioconductor.org) packages in its current release as well as an unknown number of GitHub, Bitbucket, R-Forge, ... repositories using Rcpp. All these packages provide usage examples for Rcpp. The package is in widespread use and has been -downloaded over 78.1 million times (per the partial logs from the cloud mirrors +downloaded over 124.1 million times (per the partial logs from the cloud mirrors of CRAN). ### Installation @@ -134,20 +137,20 @@ install.packages("Rcpp") #### Release Candidates -For the last several releases, we also made interim _candidate_ releases available -on the [Rcpp Drat Repo](https://RcppCore.github.io/drat/). Versions from a -[drat](https://github.com/eddelbuettel/drat) repo can be installed either by -just temporarily setting the [drat](https://github.com/eddelbuettel/drat) repo as in +We generally make interim _candidate_ releases available via the [r-universe +page](https://rcppcore.r-universe.dev/Rcpp). It provides a standard R repository which +corresponds to the current main branch in the source repository. Both binary and source +versions can be installed via ```R -install.packages("Rcpp", repos="https://RcppCore.github.io/drat") +install.packages("Rcpp", repos = c("https://rcppcore.r-universe.dev", + "https://cloud.r-project.org")) ``` -or by setting a [drat](https://github.com/eddelbuettel/drat) repo more permanently -(as described in the documentation of the [drat](https://github.com/eddelbuettel/drat) -package). +where other repos can be set as needed. -Testing the release candidates prior to actual release help. Please run this if you can. +Testing the release candidates prior to the actual release helps. Please run +this if you can. #### Source @@ -166,15 +169,12 @@ we cannot test on outdated versions of R or your OS. ### Support -The best place for questions is the -[Rcpp-devel](https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel) -mailing list hosted at R-forge. Note that in order to keep spam down, you must -be a subscriber in order to post. One can also consult the list archives to see -if your question has been asked before. +The best place for questions may be the [discussion section of the GitHub repo][discussions]] or the +[rcpp-devel mailing list][rcpp-devel] at R-forge with its focus on _development with Rcpp_ (as +opposed to _development of Rcpp_ for which we have another list). -The [issue tickets at the GitHub repo](https://github.com/RcppCore/Rcpp/issues) -are the primary bug reporting interface. As with the other web resources, -previous issues can be searched as well. +The [issue tickets at the GitHub repo][issues] are the primary bug reporting interface. As with the +other web resources, previous issues can be searched as well. ### Authors @@ -185,3 +185,8 @@ Nathan Russell, Iñaki Ucar, Doug Bates, and John Chambers ### License GPL (>= 2) + +[discussions]: https://github.com/RcppCore/Rcpp/discussions +[issues]: https://github.com/RcppCore/Rcpp/issues +[rcpp-devel]: https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel +[rcpp-doxygen]: https://dirk.eddelbuettel.com/code/rcpp/html/ diff --git a/cleanup b/cleanup index 9bbece184..b6d7ae9f7 100755 --- a/cleanup +++ b/cleanup @@ -30,7 +30,10 @@ rm -f confdefs.h config.log config.status \ vignettes/*.toc vignettes/*.tpt vignettes/*.xwm rm -rf autom4te.cache inst/lib/ inst/doc/man/ inst/doc/html/ inst/doc/latex/ \ - inst/doc/auto inst/bib/auto inst/doc/Rcpp-*/auto/ src-* vignettes/auto + inst/doc/auto inst/bib/auto inst/doc/Rcpp-*/auto/ src-* vignettes/auto \ + inst/tinytest/testRcppAttributePackage/inst \ + inst/tinytest/testRcppAttributePackage/R \ + inst/tinytest/testRcppAttributePackage/src/RcppExports.cpp find . -name \*~ -exec rm {} \; find . -name \*.flc -exec rm {} \; diff --git a/docker/ci-4.4/Dockerfile b/docker/ci-4.4/Dockerfile new file mode 100644 index 000000000..dd50e1f7d --- /dev/null +++ b/docker/ci-4.4/Dockerfile @@ -0,0 +1,17 @@ +## Emacs, make this -*- mode: sh; -*- + +FROM r-base:4.4.3 + +LABEL org.label-schema.license="GPL-2.0" \ + org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ + maintainer="Dirk Eddelbuettel " + +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && install.r inline pkgKitten rbenchmark tinytest + +ENV _R_CHECK_FORCE_SUGGESTS_=FALSE +ENV _R_CHECK_TESTS_NLINES_=0 +ENV RunAllRcppTests=yes + +CMD ["bash"] diff --git a/docker/ci-4.5/Dockerfile b/docker/ci-4.5/Dockerfile new file mode 100644 index 000000000..9d6b1ab12 --- /dev/null +++ b/docker/ci-4.5/Dockerfile @@ -0,0 +1,17 @@ +## Emacs, make this -*- mode: sh; -*- + +FROM r-base:4.5.3 + +LABEL org.label-schema.license="GPL-2.0" \ + org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ + maintainer="Dirk Eddelbuettel " + +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && install.r inline pkgKitten rbenchmark tinytest + +ENV _R_CHECK_FORCE_SUGGESTS_=FALSE +ENV _R_CHECK_TESTS_NLINES_=0 +ENV RunAllRcppTests=yes + +CMD ["bash"] diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile index 494c47d67..dbe84d13d 100644 --- a/docker/ci/Dockerfile +++ b/docker/ci/Dockerfile @@ -18,8 +18,8 @@ RUN apt-get update \ git \ && install.r rbenchmark -ENV _R_CHECK_FORCE_SUGGESTS_ FALSE -ENV _R_CHECK_TESTS_NLINES_ 0 -ENV RunAllRcppTests yes +ENV _R_CHECK_FORCE_SUGGESTS_=FALSE +ENV _R_CHECK_TESTS_NLINES_=0 +ENV RunAllRcppTests=yes CMD ["bash"] diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index e5b87eca5..e84f70099 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -3,21 +3,300 @@ \newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}} -\section{Changes in Rcpp release version 1.0.14 (2025-01-xx)}{ +\section{Changes in Rcpp release version 1.1.2.9 [github] (2026-11-30)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item Ensure protection in \code{StretchyList::push_back()} (Kevin in + \ghpr{1490} closing \ghit{1489}) + \item Ensure protection in fresh proxy \code{get()} calls (Kevin in + \ghpr{1492} closing \ghit{1491}) + \item Ensure protection in Module method and function results (Kevin in + \ghpr{1494} closing \ghit{1493}) + \item Convert C++ exception to R errors in Module \code{.External} + entries (Kevin in \ghpr{1496} closing \ghit{1495}) + \item Ensure flag \code{-Wcast-function-type} no longer triggers + warnings (Iñaki in \ghpr{1502} closing \ghit{1500}) + \item Ensure flag \code{-Wdeprecated-copy-with-user-provided-copy} no + longer triggers warnings (Iñaki in \ghpr{1503} closing \ghit{1498}) + \item Ensure flag \code{-Wimplicit-fallthrough} no longer triggers + warnings (Iñaki in \ghpr{1503} closing \ghit{1504}) + \item Ensure flag \code{-Wunused-parameter} no longer triggers + warnings (Iñaki in \ghpr{1506} closing \ghit{1499}) + \item Ensure flag \code{-Wconversion} no longer triggers + warnings (Iñaki in \ghpr{1508} closing \ghit{1497}) + \item The \code{col} constructor now uses \code{nrow} in an + initialization (Iñaki in \ghpr{1509}) + \item Sugar expressions hold nested expressions by value so they can be + stored, and evaluate expressions that may read the target before + assigning them in place (Kevin in \ghpr{1513} closing \ghit{1512}). + Same-length assignment of an expression that is not elementwise, such + as \code{x = rev(x)}, now goes through a temporary vector. + \item Development versions check that sugar operands, and vectors + assigned into a range, row or column, have matching lengths, and signal + an error otherwise; releases do not check, and the define + \code{RCPP_SUGAR_LENGTH_CHECKS} overrides the default (Kevin in + \ghpr{1513}) + \item Assignment between overlapping subsets of the same vector, as in + \code{x[i] = x[j]}, reads the source elements before writing (Kevin in + \ghpr{1513}) + \item The sugar operators \code{!}, \code{&&} and \code{||} on single + logical results such as \code{all()} now compile, and follow R's + handling of \code{NA} (Kevin in \ghpr{1513}) + \item Bounds-checked element access is faster, \code{size()} of + atomic vectors uses the cached length, and \code{ncol()} no longer + reads the \code{dim} attribute; object layouts are unchanged, as + packages such as \pkg{rust} and \pkg{revdbayes} exchange Rcpp + objects across shared libraries (Kevin in \ghpr{1511} closing + \ghit{1510}) + \item Module namespace load time is much improved by relying more on S4 + semantics rather than reference classes (Michael Sumner in \ghpr{1515} + and \ghpr{1516} addressing \ghit{1514}) + \item A large battery of Modules improvement has been applied by Kevin: + \itemize{ + \item \code{finalize()} is a no-op for never constructed objects (\ghpr{1518}) + \item \code{*this} is returned from \code{property} overload + (\ghpr{1520} fixing \ghit{1519}) + \item Module and internal function arity is checked before invocation + (\ghpr{1522} fixing \ghit{1521}) + \item Module objects are validated before conversion to C++ classes + (\ghpr{1524} fixing \ghit{1523}) + \item Exceptions during modules initializations are turned into R errors + (\ghpr{1526} fixing \ghit{1525}) + \item Module bodies are only run once per DLL + (\ghpr{1528} fixing \ghit{1527}) + \item Special module methods are counted once per name for completion + (\ghpr{1530} fixing \ghit{1529}) + \item Returned modules object are wrapped as the class of the + library that returns them (\ghpr{1532} fixing C++ parts of \ghit{1531}) + \item Ownership of objects returned from R modules is documented + (\ghpr{1534} fixing \ghit{1533}) + } + \item A Clang-specific unused parameter warning in uninstantiated + templates is now avoided (David Seifert in \ghpr{1536}) + \item An ambiguous (to Clang on Apple) \code{const_string_proxy} + comparison now works (Simon Urbanek in \ghpr{1538} fixing \ghit{1537}) + } + \item Changes in Rcpp Documentation: + \itemize{ + \item Mention updated doxygen2 documentation and once again working + R-forge list rcpp-devel in README.md + \item Copyright headers have been updated in corresponding source files + (Iñaki in \ghpr{1507}) + } + \item Changes in Rcpp Deployment: + \itemize{ + \item A new CI job checks with flag \code{-Werror} and ensure this not + cause failures (Iñaki in \ghpr{1501}) + \item The macOS 14 CI runner has been retired as GitHub retired those + (Dirk in \ghpr{1535}) + } + } +} + +\section{Changes in Rcpp release version 1.1.2 (2026-07-01)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item Use of \code{execinfo.h} is again conditional to avoid build + complexity (Dirk in \ghpr{1445} addressing \ghit{1442}) + \item An internal state component for \code{Datetime} is now \code{int} + (Dirk in \ghpr{1448} and \ghpr{1449} fixing \ghpr{1447}) + \item Three new (in R 4.6.0) attribute accessors are used conditionally + (Dirk in \ghpr{1450} closing \ghit{1432}) + \item An UBSAN error in the Sugar-based NA comparison has been + corrected (Iñaki in \ghpr{1453} fixing \ghit{1452}) + \item Treatment of Inf outside of integer range in Sugar function has + been corrected (Iñaki in \ghpr{1458} fixing \ghit{1455}) + \item Integer overflow protection has been added for sugar functions + (Iñaki in \ghpr{1457} fixing \ghpr{1454}) + \item The parent environment is now accessed via \code{R_ParentEnv} + (Dirk in \ghpr{1460} fixing \ghit{1459}) + \item Change to returning \code{dataptr} again for better handling of + empty vectors (Iñaki in \ghpr{1462} fixing \ghit{1461}) + \item Undefined behavior errors in use of \code{ListOf} proxies have + been addressed (Iñaki in \ghpr{1464} fixing \ghit{1463}) + \item Under newer R version, \code{R_UnboundValue} is no longer used + (Iñaki in \ghpr{1466} fixing \ghit{1465}) + \item New R API access point \code{R_getRegisteredNamespace()} is used + with current R versions (Dirk in \ghpr{1469} fixing \ghit{1468}) + \item The \code{Nullable::as()} exporter now uses an explicit cast to + the templated type (Dirk in \ghpr{1471} fixing \ghit{1470}) + \item A memory leak in the variadic \code{Rcpp::warning()} template + has been fixed (Kevin in \ghpr{1475} fixing \ghit{1474}) + \item The \code{Nullable::operatorT()} has been added as a 'opt-out' + (Dirk in \ghpr{1477} with coordination in \ghit{1472}) + \item Add templated integer-index overload for \code{operator[]} on + small systems such as WASM (Jeroen Ooms in \ghpr{1482}) + \item The attribute accessors in \code{AttributeProxyPolicy} no longer + rely on \code{get__()} (Kevin in \ghpr{1484} fixing \ghit{1483}) + } + \item Changes in Rcpp Documentation: + \itemize{ + \item Reference in the bibliography used by the package vignettes have + been updated. + } + \item Changes in Rcpp Deployment: + \itemize{ + \item Excute permissions are set consistently on scripts with shebangs + (Mattias Ellert in \ghpr{1467}) + \item R 4.5.* has been added to the CI matrix (Dirk in \ghpr{1476}) + \item Three nag messages issued when obsolete build flag accessors are + used now show \code{Rcpp:::} (Dirk in \ghpr{1480} fixing \ghit{1456}) + \item Reference GitHub Actions have been updated to their current + versions (Dirk in \ghpr{1481}) + } + \item Non-release Changes: + \itemize{ + \item A non-release hotfix 1.1.1-1 used by CRAN accommodates breaking + changes to the API in R 4.6.0. It would be nice to have the same level + of release management in R itself that CRAN expects from us. + } + } +} + +\section{Changes in Rcpp release version 1.1.1 (2026-01-08)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item An unused old R function for a compiler version check has been + removed after checking no known package uses it (Dirk in \ghpr{1395}) + \item A narrowing warning is avoided via a cast (Dirk in \ghpr{1398}) + \item Demangling checks have been simplified (Iñaki in \ghpr{1401} + addressing \ghit{1400}) + \item The treatment of signed zeros is now improved in the Sugar code + (Iñaki in \ghpr{1404}) + \item Preparations for phasing out use of \code{Rf_error} have been + made (Iñaki in \ghpr{1407}) + \item The long-deprecated function \code{loadRcppModules()} has been + removed (Dirk in \ghpr{1416} closing \ghit{1415}) + \item Some non-API includes from R were refactored to accommodate + R-devel changes (Iñaki in \ghpr{1418} addressing \ghit{1417}) + \item An accessor to \code{Rf_rnbeta} has been removed (Dirk in + \ghpr{1419} also addressing \ghit{1420}) + \item Code accessing non-API \code{Rf_findVarInFrame} now uses + \code{R_getVarEx} (Dirk in \ghpr{1423} fixing \ghit{1421}) + \item Code conditional on the R version now expects at least R 3.5.0; + older code has been removed (Dirk in \ghpr{1426} fixing \ghit{1425}) + \item The non-API \code{ATTRIB} entry point to the R API is no longer + used (Dirk in \ghpr{1430} addressing \ghit{1429}) + \item The unwind-protect mechanism is now used unconditionally (Dirk + in \ghpr{1437} closing \ghit{1436}) + } + \item Changes in Rcpp Attributes: + \itemize{ + \item The OpenMP plugin has been generalized for different macOS + compiler installations (Kevin in \ghpr{1414}) + } + \item Changes in Rcpp Documentation: + \itemize{ + \item Vignettes are now processed via a new "asis" processor adopted + from \pkg{R.rsp} (Dirk in \ghpr{1394} fixing \ghit{1393}) + \item R is now cited via its DOI (Dirk) + \item A (very) stale help page has been removed (Dirk in \ghpr{1428} + fixing \ghit{1427}) + \item The main README.md was updated emphasizing r-universe in favor of + the local drat repos (Dirk in \ghpr{1431}) + } + \item Changes in Rcpp Deployment: + \itemize{ + \item A temporary change in R-devel concerning NA part in complex variables + was accommodated, and then reverted (Dirk in \ghpr{1399} fixing \ghit{1397}) + \item The macOS CI runners now use macos-14 (Dirk in \ghpr{1405}) + \item A message is shown if \code{R.h} is included before Rcpp headers + as this can lead to errors (Dirk in \ghpr{1411} closing \ghit{1410}) + \item Old helper functions use \code{message()} to signal they are not used, + deprecation and removal to follow (Dirk in \ghpr{1413} closing + \ghit{1412}) + \item Three tests were being silenced following \ghpr{1413} (Dirk in + \ghpr{1422}) + \item The heuristic whether to run all available tests was refined + (Dirk in \ghpr{1434} addressing \ghit{1433}) + \item Coverage has been tweaked via additional \code{#nocov} tags (Dirk + in \ghpr{1435}) + } + \item Non-release Changes: + \itemize{ + \item Two interim non-releases 1.1.0.8.1 and .2 were made in order to + unblock CRAN due to changes in R-devel rather than Rcpp + } + } +} + +\section{Changes in Rcpp release version 1.1.0 (2025-07-01)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item C++11 is now the required minimal C++ standard + \item The \code{std::string_view} type is now covered by \code{wrap()} + (Lev Kandel in \ghpr{1356} as discussed in \ghit{1357}) + \item A last remaining \code{DATAPTR} use has been converted to + \code{DATAPTR_RO} (Dirk in \ghpr{1359}) + \item Under R 4.5.0 or later, \code{R_ClosureEnv} is used instead of + \code{CLOENV} (Dirk in \ghpr{1361} fixing \ghpr{1360}) + \item Use of \code{lsInternal} switched to \code{lsInternal3} (Dirk in + #1362) + \item Removed compiler detection macro in a header cleanup setting + C++11 as the minunum (Dirk in \ghpr{1364} closing \ghit{1363}) + \item Variadic templates are now used onconditionally given C++11 (Dirk + in \ghpr{1367} closing \ghit{1366}) + \item Remove \code{RCPP_USING_CXX11} as a \code{#define} as C++11 is + now a given (Dirk in \ghpr{1369}) + \item Additional cleanup for \code{__cplusplus} checks (Iñaki in + \ghpr{1371} fixing \ghit{1370}) + \item Unordered set construction no longer needs a macro for the + pre-C++11 case (Iñaki in \ghpr{1372}) + \item Lambdas are supported in a Rcpp Sugar functions (Iñaki in \ghpr{1373}) + \item The Date(time)Vector classes now have default ctor (Dirk in + \ghpr{1385} closing \ghpr{1384}) + \item Fixed an issue where Rcpp::Language would duplicate its arguments + (Kevin in \ghpr{1388}, fixing \ghit{1386}) + } + \item Changes in Rcpp Attributes: + \itemize{ + \item The C++26 standard now has plugin support (Dirk in \ghpr{1381} + closing \ghit{1380}) + } + \item Changes in Rcpp Documentation: + \itemize{ + \item Several typos were correct in the NEWS file (Ben Bolker in + \ghpr{1354}) + \item The Rcpp Libraries vignette mentions \code{PACKAGE_types.h} to + declare types used in \code{RcppExports.cpp} (Dirk in \ghpr{1355}) + \item The vignettes bibliography file was updated to current package + versions, and now uses doi references (Dirk in \ghpr{1389}) + } + \item Changes in Rcpp Deployment: + \itemize{ + \item \code{Rcpp.package.skeleton()} creates \sQuote{URL} and + \sQuote{BugReports} if given a GitHub username (Dirk in \ghpr{1358}) + \item R 4.4.* has been added to the CI matrix (Dirk in \ghpr{1376}) + \item Tests involving NA propagation are skipped under linux-arm64 as + they are under macos-arm (Dirk in \ghpr{1379} closing \ghit{1378}) + } + } +} + +\section{Changes in Rcpp release version 1.0.14 (2025-01-11)}{ \itemize{ \item Changes in Rcpp API: \itemize{ \item Support for user-defined databases has been removed (Kevin in \ghpr{1314} fixing \ghit{1313}) - \item The \code{SET_TYPEOF} function and macro is no longer used (Kevin in - \ghpr{1315} fixing \ghit{1312}) - \item An errorneous cast to \code{int} affecting large return object + \item The \code{SET_TYPEOF} function and macro is no longer used (Kevin + in \ghpr{1315} fixing \ghit{1312}) + \item An erroneous cast to \code{int} affecting large return object has been removed (Dirk in \ghpr{1335} fixing \ghpr{1334}) \item Compilation on DragonFlyBSD is now supported (Gábor Csárdi in \ghpr{1338}) - \item Use read-only \code{VECTOR_PTR} and \code{STRING_PTR} only with + \item Use read-only \code{VECTOR_PTR} and \code{STRING_PTR} only with R 4.5.0 or later (Kevin in \ghpr{1342} fixing \ghit{1341}) } + \item Changes in Rcpp Attributes: + \itemize{ + \item The \code{sourceCpp()} function can now handle input files with + read-only modes (Simon Guest in \ghpr{1346} fixing \ghit{1345}) + } \item Changes in Rcpp Deployment: \itemize{ \item One unit tests for arm64 macOS has been adjusted; a macOS @@ -25,13 +304,18 @@ \item Authors@R is now used in DESCRIPTION as mandated by CRAN, the \code{Rcpp.package.skeleton()} function also creates it (Dirk in \ghpr{1325} and \ghpr{1327}) + \item A single datetime format test has been adjusted to match a change + in R-devel (Dirk in \ghpr{1348} fixing \ghit{1347}) } \item Changes in Rcpp Documentation: \itemize{ \item The Rcpp Modules vignette was extended slightly following \ghit{1322} (Dirk) \item Pdf vignettes have been regenerated under Ghostscript 10.03.1 to - avoid a false positive by a Windows virus scanner (Iñaki in \ghpr{1331}) + avoid a false positive by a Windows virus scanner (Iñaki in + \ghpr{1331}) + \item A (large) number of (old) typos have been corrected in the + vignettes (Marco Colombo in \ghpr{1344}) } } } @@ -82,7 +366,7 @@ added in two places (Michael Chirico in \ghpr{1272} closing \ghit{1271}). \item Casts to avoid integer overflow in matrix row/col selections - have neem added (Aaron Lun \ghpr{1281}). + have been added (Aaron Lun \ghpr{1281}). \item Three print format correction uncovered by R-devel were applied with thanks to Tomas Kalibera (Dirk in \ghpr{1285}). \item Correct a print format correction in the RcppExports glue code diff --git a/inst/bib/Rcpp.bib b/inst/bib/Rcpp.bib index 1aac8921c..37f721fa4 100644 --- a/inst/bib/Rcpp.bib +++ b/inst/bib/Rcpp.bib @@ -3,13 +3,14 @@ @String{manuals @String{RCoreTeam = "{R Core Team}" } @String{RFoundation = "R Foundation for Statistical Computing" } @String{R-Forge = "https://R-Forge.R-Project.org/" } +@String{DOI = "10.32614/CRAN.package." } @manual{Abrahams+Grosse-Kunstleve:2003:Boost.Python, author = { David Abrahams and Ralf W. Grosse-Kunstleve }, organization = "Boost Consulting", title = "Building Hybrid Systems with Boost.Python", year = 2003, - url = "https://www.boostpro.com/writing/bpl.pdf" + url = "https://www.boost.org/doc/libs/latest/libs/python/doc/html/article.html" } @Book{Abrahams+Gurtovoy:2004:TemplateMetaprogramming, @@ -59,7 +60,7 @@ @InProceedings{Bates+DebRoy:2001:C++Classes Universit\"at Wien, Vienna, Austria}, editor = {Kurt Hornik and Friedrich Leisch}, year = {2001}, - url = {https://www.ci.tuwien.ac.at/Conferences/DSC-2001/Proceedings/}, + url = {https://www.r-project.org/conferences/DSC-2001/Proceedings/}, note = {ISSN 1609-395X} } @@ -75,59 +76,75 @@ @Misc{Brokken:2011:Cpp @Manual{CRAN:anytime, title = {anytime: Anything to 'POSIXct' or 'Date' Converter}, author = {Dirk Eddelbuettel}, - year = {2020}, - note = {R package version 0.3.9}, - url = CRAN # "package=anytime" + year = {2026}, + note = {R package version 0.3.13}, + oldurl = CRAN # "package=anytime", + doi = DOI # "anytime" +} + +@Manual{CRAN:AsioHeaders, + title = {'Asio' C++ Header Files}, + author = {Dirk Eddelbuettel}, + year = {2025}, + note = {R package version 1.30.2-1}, + oldurl = CRAN # "package=AsioHeaders", + doi = DOI # "AsioHeaders" } @Manual{CRAN:BH, title = {BH: Boost C++ Header Files}, author = {Dirk Eddelbuettel and John W. Emerson and Michael J. Kane}, - year = {2023}, - note = {R package version 1.81.0-1}, - url = CRAN # "package=BH" + year = {2025}, + note = {R package version 1.90.0-1}, + oldurl = CRAN # "package=BH", + doi = DOI # "BH" } @Manual{CRAN:Matrix, title = {\pkg{Matrix}: Sparse and Dense Matrix Classes and Methods}, author = {Douglas Bates and Martin Maechler}, - year = 2023, - note = {R package version 1.6-4}, - url = CRAN # "package=Matrix" + year = 2026, + note = {R package version 1.7-5}, + oldurl = CRAN # "package=Matrix", + doi = DOI # "Matrix" } @Manual{CRAN:RInside, title = {RInside: C++ classes to embed R in C++ applications}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2020, - note = {R package version 0.2.16}, - url = CRAN # "package=RInside" + year = 2025, + note = {R package version 0.2.19}, + oldurl = CRAN # "package=RInside", + doi = DOI # "RInside" } @Manual{CRAN:RProtoBuf, title = {RProtoBuf: R Interface to the Protocol Buffers API}, author = {Romain Fran\c{c}ois and Dirk Eddelbuettel and Murray Stokely and Jeroen Ooms}, - year = 2023, - note = {R package version 0.4.21}, - url = CRAN # "package=RProtoBuf" + year = 2026, + note = {R package version 0.4.27}, + oldurl = CRAN # "package=RProtoBuf", + doi = DOI # "RProtoBuf" } @Manual{CRAN:RQuantLib, - title = {RQuantLib: {R} interface to the {QuantLib} library}, + title = {RQuantLib: {R} Interface to the {QuantLib} Library}, author = {Dirk Eddelbuettel and Khanh Nguyen and Terry Leitch}, - year = 2023, - note = {R package version 0.4.20}, - url = CRAN # "package=RQuantLib" + year = 2026, + note = {R package version 0.4.27}, + oldurl = CRAN # "package=RQuantLib", + doi = DOI # "RQuantLib" } @Manual{CRAN:RUnit, title = {RUnit: R Unit Test Framework}, author = {Matthias Burger and Klaus Juenemann and Thomas Koenig}, - year = 2018, - note = {R package version 0.4.32}, - url = CRAN # "package=RUnit" + year = 2024, + note = {R package version 0.4.33.1}, + oldurl = CRAN # "package=RUnit", + doi = DOI # "RUnit" } @Manual{CRAN:Rcpp, @@ -135,9 +152,10 @@ @Manual{CRAN:Rcpp author = {Dirk Eddelbuettel and Romain Fran\c{c}ois and JJ Allaire and Kevin Ushey and Qiang Kou and Nathan Russel and John Chambers and Douglas Bates}, - year = 2024, - note = {R package version 1.0.13}, - url = CRAN # "package=Rcpp" + year = 2026, + note = {R package version 1.1.2}, + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:Attributes, @@ -145,72 +163,80 @@ @Manual{CRAN:Rcpp:Attributes author = {J. J. Allaire and Dirk Eddelbuettel and Romain Fran\c{c}ois}, title = {{Rcpp} Attributes}, - year = 2023, + year = 2026, note = {Vignette included in R package Rcpp}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:FAQ, crossref = {CRAN:Rcpp}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, title = {Frequently Asked Questions About {Rcpp}}, - year = 2023, + year = 2026, note = {Vignette included in R package {Rcpp}}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:Libraries, crossref = {CRAN:Rcpp}, author = {Dirk Eddelbuettel}, title = {Thirteen Simple Steps for Creating An R Package with an External C++ Library }, - year = 2023, + year = 2026, note = {Vignette included in R package Rcpp}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:Modules, crossref = {CRAN:Rcpp}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, title = {Exposing {C++} functions and classes with {Rcpp} modules}, - year = 2023, + year = 2026, note = {Vignette included in R package Rcpp}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:Package, crossref = {CRAN:Rcpp}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, title = {Writing a package that uses {Rcpp}}, - year = 2023, + year = 2026, note = {Vignette included in R package {Rcpp}}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:Rcpp:Sugar, crossref = {CRAN:Rcpp}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, title = {Rcpp syntactic sugar}, - year = 2023, + year = 2026, note = {Vignette included in R package {Rcpp}}, - url = CRAN # "package=Rcpp" + oldurl = CRAN # "package=Rcpp", + doi = DOI # "Rcpp" } @Manual{CRAN:RcppArmadillo, - title = {RcppArmadillo: Rcpp integration for Armadillo - templated linear algebra library}, + title = {RcppArmadillo: Rcpp Integration for the Armadillo + Templated Linear Algebra Library}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois and Douglas Bates and Binxiang Ni and Conrad Sanderson}, - year = 2023, - note = {R package version 0.12.6.6.1}, - url = CRAN # "package=RcppArmadillo" + year = 2026, + note = {R package version 15.4.0-1}, + oldurl = CRAN # "package=RcppArmadillo", + doi = DOI # "RcppArmadillo" } @Manual{CRAN:RcppCCTZ, title = {RcppCCTZ: Rcpp Bindings for the CCTZ Library}, author = {Dirk Eddelbuettel}, - year = 2022, - note = {R package version 0.2.12}, - url = CRAN # "package=RcppCCTZ" + year = 2024, + note = {R package version 0.2.13}, + oldurl = CRAN # "package=RcppCCTZ", + doi = DOI # "RcppCCTZ" } @Manual{CRAN:RcppClassic, @@ -218,73 +244,82 @@ @Manual{CRAN:RcppClassic author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, year = 2022, note = {R package version 0.9.13}, - url = CRAN # "package=RcppClassic" + oldurl = CRAN # "package=RcppClassic", + doi = DOI # "RcppClassic" } @Manual{CRAN:RcppDate, title = {RcppDate: 'date' C++ Header Libary for Date and Time Functionality}, author = {Dirk Eddelbuettel}, - year = 2021, - note = {R package version 0.0.3}, - url = CRAN # "package=RcppDate" + year = 2025, + note = {R package version 0.0.6}, + oldurl = CRAN # "package=RcppDate", + doi = DOI # "RcppDate" } @Manual{CRAN:RcppDE, - title = {RcppDE: Global optimization by differential evolution in C++}, + title = {RcppDE: Global Optimization by Differential Evolution in C++}, author = {Dirk Eddelbuettel}, - year = 2022, - note = {R package version 0.1.7}, - url = CRAN # "package=RcppDE" + year = 2026, + note = {R package version 0.1.9}, + oldurl = CRAN # "package=RcppDE", + doi = DOI # "RcppDE" } @Manual{CRAN:RcppEigen, - title = {RcppEigen: Rcpp integration for the Eigen templated linear - algebra library}, + title = {RcppEigen: Rcpp Integration for the Eigen Templated Linear + Algebra Library}, author = {Douglas Bates and Dirk Eddelbuettel and Romain Fran\c{c}ois and Yixuan Qiu}, - year = 2023, - note = {{R} package version 0.3.3.9.4}, - url = CRAN # "package=RcppEigen" + year = 2024, + note = {{R} package version 0.3.4.0.2}, + oldurl = CRAN # "package=RcppEigen", + doi = DOI # "RcppEigen" } @Manual{CRAN:RcppExamples, title = {RcppExamples: Examples using {Rcpp} to interface {R} and {C++}}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2019, - note = {R package version 0.1.9}, - url = CRAN # "package=RcppExamples" + year = 2025, + note = {R package version 0.1.10}, + oldurl = CRAN # "package=RcppExamples", + doi = DOI # "RcppExamples" } @Manual{CRAN:RcppGSL, - title = {RcppGSL: Rcpp integration for GNU GSL vectors and matrices}, + title = {RcppGSL: Rcpp Integration for GNU GSL Vectors and Matrices}, author = {Dirk Eddelbuettel and Romain Fran\c{c}ois}, - year = 2021, - note = {R package version 0.3.10}, - url = CRAN # "package=RcppGSL" + year = 2026, + note = {R package version 0.3.14}, + oldurl = CRAN # "package=RcppGSL", + doi = DOI # "RcppGSL" } @Manual{CRAN:RcppInt64, title = {RppInt64: Rcpp-Based Helper Functions to Pass Int64 and nanotime Values Between R and C++}, author = {Dirk Eddelbuettel}, - year = 2023, - note = {R package version 0.0.4}, - url = CRAN # "package=RcppInt64" + year = 2024, + note = {R package version 0.0.5}, + oldurl = CRAN # "package=RcppInt64", + doi = DOI # "RcppInt64" } @Manual{CRAN:RcppZiggurat, title = {RcppZiggurat: Rcpp Integration of Different Ziggurat Normal RNG Implementations}, author = {Dirk Eddelbuettel}, - year = 2020, - note = {R package version 0.1.6}, - url = CRAN # "package=RcppZiggurat" + year = 2025, + note = {R package version 0.1.8}, + oldurl = CRAN # "package=RcppZiggurat", + doi = DOI # "RcppZiggurat" } @Manual{CRAN:Rserve, - title = {Rserve: Binary R server}, + title = {Rserve: Versatile R Server}, author = {Simon Urbanek}, - year = 2023, - note = {R package version 1.8-13}, - url = CRAN # "package=Rserve" + year = 2026, + note = {R package version 1.8-19}, + oldurl = CRAN # "package=Rserve", + doi = DOI # "Rserve" } @Manual{CRAN:cxxPack, @@ -293,94 +328,105 @@ @Manual{CRAN:cxxPack author = {Dominick Samperi}, year = 2010, note = {R package version 7.0.6}, - url = CRAN # "package=cxxPack" + oldurl = CRAN # "package=cxxPack", + doi = DOI # "cxxPack" } @Manual{CRAN:devtools, title = {devtools: Tools to Make Developing R Packages Easier}, - author = {Hadley Wickham and Jim Hester and Winston Chang}, - year = 2022, - note = {R package version 2.4.5}, - url = CRAN # "package=devtools" + author = {Hadley Wickham and Jim Hester and Winston Chang and Jennifer Bryan}, + year = 2026, + note = {R package version 2.5.2}, + oldurl = CRAN # "package=devtools", + doi = DOI # "devtools" } @Manual{CRAN:highlight, - title = {highlight: Syntax highlighter}, + title = {highlight: Syntax Highlighter}, author = {Hadley Wickham and Romain Fran\c{c}ois and Andre Simon}, - year = 2023, - note = {R package with version 0.5.1}, - url = CRAN # "package=highlight" + year = 2025, + note = {R package with version 0.5.2}, + oldurl = CRAN # "package=highlight", + doi = DOI # "highlight" } @Manual{CRAN:inline, - title = {inline: Inline C, C++, Fortran function calls from + title = {inline: Functions to Inline C, C++, Fortran Function Calls from R}, author = {Oleg Sklyar and Duncan Murdoch and Mike Smith and Dirk Eddelbuettel and Romain Fran\c{c}ois and Karline Soetaert and Johannes Ranke}, - year = 2021, - note = {R package version 0.3.19}, - url = CRAN # "package=inline" + year = 2025, + note = {R package version 0.3.21}, + oldurl = CRAN # "package=inline", + doi = DOI # "inline" } @Manual{CRAN:littler, title = {littler: {R} at the {Command-Line} via r}, author = {Dirk Eddelbuettel and Jeffrey Horner}, - year = 2023, - note = {R package version 0.3.19}, - url = CRAN # "package=littler" + year = 2026, + note = {R package version 0.3.23}, + oldurl = CRAN # "package=littler", + doi = DOI # "littler" } @Manual{CRAN:microbenchmark, title = {microbenchmark: Accurate Timing Functions}, author = {Olaf Mersmann}, year = 2023, - note = {R package version 1.4-10}, - url = CRAN # "package=microbenchmark" + note = {R package version 1.5-0}, + oldurl = CRAN # "package=microbenchmark", + doi = DOI # "microbenchmark" } @Manual{CRAN:minqa, - title = {minqa: Derivative-free optimization algorithms by - quadratic approximation}, + title = {minqa: Derivative-Free Optimization Algorithms by + Quadratic Approximation}, author = {Douglas Bates and Katharine M. Mullen and John C. Nash and Ravi Varadhan}, - year = 2023, - note = {R package version 1.2.6}, - url = CRAN # "package=minqa" + year = 2024, + note = {R package version 1.2.8}, + oldurl = CRAN # "package=minqa", + doi = DOI # "minqa" } @Manual{CRAN:pkgKitten, title = {pkgKitten: Create Simple Packages Which Do not Upset R Package Checks}, author = {Dirk Eddelbuettel}, - year = {2023}, - note = {R package version 0.2.3}, - url = CRAN # "package=pkgKitten" + year = {2024}, + note = {R package version 0.2.4}, + oldurl = CRAN # "package=pkgKitten", + doi = DOI # "pkgKitten" } @Manual{CRAN:profvis, title = {profvis: Interactive Visualizations for Profiling R Code}, author = {Winston Chang and Javier Luraschi and and Timothy Mastny}, - year = 2023, - note = {R package version 0.3.8}, - url = CRAN # "package=profvis" + year = 2024, + note = {R package version 0.4.0}, + oldurl = CRAN # "package=profvis", + doi = DOI # "profvis" } @Manual{CRAN:rbenchmark, title = {\pkg{rbenchmark}: Benchmarking routine for R}, - author = {Wacek Kusnierczyk}, - year = 2012, - note = {R package version 1.0.0}, - url = CRAN # "package=rbenchmark" + author = {Wacek Kusnierczyk and Dirk Eddelbuettel and Berend Hasselman}, + year = 2026, + note = {R package version 1.0.1}, + oldurl = CRAN # "package=rbenchmark", + doi = DOI # "rbenchmark" } @Manual{CRAN:roxygen2, - title = {roxygen2: In-source documentation for R}, + title = {roxygen2: In-Line documentation for R}, author = {Hadley Wickham and Peter Danenberg and G\a'bor Cs\a'rdi and Manuel Eugster}, - year = 2022, - note = {R package version 7.2.3}, - url = CRAN # "package=roxygen2" + year = 2026, + note = {R package version 8.0.0}, + oldurl = CRAN # "package=roxygen2", + doi = DOI # "roxygen2" } @Article{CRAN:testthat, @@ -489,7 +535,8 @@ @Book{Eddelbuettel:2013:Rcpp series = {Use R!}, year = 2013, address = {New York}, - isbn = {978-1-4614-6867-7} + isbn = {978-1-4614-6867-7}, + doi = {10.1007/978-1-4614-6868-4} } @article{Efron:1979:Bootstrap, @@ -508,7 +555,7 @@ @MISC{Eigen:Web author = {Ga\"{e}l Guennebaud and Beno\^{i}t Jacob and others}, title = {Eigen v3}, year = 2012, - url = {https://eigen.tuxfamily.org} + url = {https://libeigen.gitlab.io/} } @Manual{GSL, @@ -727,8 +774,8 @@ @Article{PeerJ:Rcpp issue = {e3188v1}, year = 2017, month = {August}, - url = {https://doi.org/10.7287/peerj.preprints.3188v1/}, - doi = {10.7287/peerj.preprints.3188v1/} + url = {https://peerj.com/preprints/3188v1/}, + doi = {10.7287/peerj.preprints.3188v1} } @Book{Plauger+Et+Al:2000:STL, @@ -744,16 +791,17 @@ @manual{QuantLib author = {{QuantLib Core Team}}, year = 2021, title = {QuantLib: a free/open-source library for quantitative finance}, - url = {https://quantlib.org} + url = {https://www.quantlib.org} } @manual{R:Administration, author = RCoreTeam, organization = RFoundation, address = {Vienna, Austria}, - year = 2023, + year = 2026, title = "R Installation and Administration", annote = {{ISBN} 3-900051-09-7}, + doi = "10.32614/R.manuals", url = manuals # "R-admin.html" } @@ -761,9 +809,10 @@ @manual{R:Extensions author = RCoreTeam, organization = RFoundation, address = {Vienna, Austria}, - year = 2023, + year = 2026, title = "Writing R extensions", annote = {{ISBN} 3-900051-11-9}, + doi = "10.32614/R.manuals", url = manuals # "R-exts.html" } @@ -771,9 +820,10 @@ @manual{R:Internals author = RCoreTeam, organization = RFoundation, address = {Vienna, Austria}, - year = 2023, + year = 2026, title = "R internals", annote = {{ISBN} 3-900051-14-3}, + doi = "10.32614/R.manuals", url = manuals # "R-ints.html" } @@ -781,9 +831,10 @@ @manual{R:Language author = RCoreTeam, organization = RFoundation, address = {Vienna, Austria}, - year = 2023, + year = 2026, title = "R language", annote = {{ISBN} 3-900051-13-5}, + doi = "10.32614/R.manuals", url = manuals # "R-lang.html" } @@ -793,7 +844,8 @@ @Manual{R:Main author = RCoreTeam, organization = RFoundation, address = {Vienna, Austria}, - year = 2023, + year = 2026, + doi = "10.32614/R.manuals", url = {https://www.R-project.org/} } @@ -835,7 +887,7 @@ @TechReport{Sanderson:2010:Armadillo Experiments }, institution = {{NICTA}}, year = 2010, - url = "https://arma.sf.net" + url = "https://arma.sourceforge.net" } @Book{Stroustrup:1997:Cpp, @@ -901,7 +953,7 @@ @InProceedings{Urbanek:2003:Rserve Statistical Computing, Vienna, Austria}, editor = {Kurt Hornik and Friedrich Leisch and Achim Zeileis}, year = {2003}, - url = {https://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/}, + url = {https://www.r-project.org/conferences/DSC-2003/Proceedings/}, note = {{ISSN 1609-395X}} } @@ -945,7 +997,7 @@ @Book{Venables+Ripley:2002:MASS address = {New York}, year = 2002, note = {ISBN 0-387-95457-0}, - url = {https://www.stats.ox.ac.uk/pub/MASS4}, + url = {https://www.stats.ox.ac.uk/pub/MASS4/}, } @misc{arxiv:corels, @@ -954,7 +1006,7 @@ @misc{arxiv:corels author = {Elaine Angelino and Nicholas Larus-Stone and Daniel Alabi and Margo Seltzer and Cynthia Rudin}, year = 2017, - howpublished = {\href{https://www.arxiv.org/1704.01701}{arXiv:1704.01701}}, + howpublished = {\href{https://arxiv.org/abs/1704.01701}{arXiv:1704.01701}}, archivePrefix ={arXiv}, primaryClass = {stat.ML} } @@ -962,7 +1014,7 @@ @misc{arxiv:corels @Misc{github:corels, author = {Nicholas Laurus-Stone}, title = {corels: {Learning Certifiably Optimal Rule Lists}}, - howpublished = {\url{https://github.com/nlarusstone/corels}. Also online at \url{https://corels.eecs.harvard.edu/corels/}}, + howpublished = {\url{https://github.com/corels/corels}. Also online at \url{https://corels.cs.ubc.ca/corels/Larus-Stone_thesis.pdf}}, month = 06, year = 2019 } @@ -970,7 +1022,7 @@ @Misc{github:corels @Misc{github:rcppcorels, author = {Dirk Eddelbuettel}, title = {RcppCorels: R binding for the 'Certifiably Optimal RulE ListS (Corels)' Learner}, - howpublished = {\url{https://github.com/eddelbuettel/rcppcorels}}, + howpublished = {\url{https://github.com/corels/rcppcorels}}, month = 11, year = 2019 } diff --git a/inst/discovery/cxx0x.R b/inst/discovery/cxx0x.R old mode 100644 new mode 100755 diff --git a/inst/examples/ConvolveBenchmarks/overhead.r b/inst/examples/ConvolveBenchmarks/overhead.r old mode 100644 new mode 100755 diff --git a/inst/examples/ConvolveBenchmarks/overhead.sh b/inst/examples/ConvolveBenchmarks/overhead.sh old mode 100644 new mode 100755 diff --git a/inst/examples/ConvolveBenchmarks/overhead_1.cpp b/inst/examples/ConvolveBenchmarks/overhead_1.cpp index cf1e74641..55ebb80ab 100644 --- a/inst/examples/ConvolveBenchmarks/overhead_1.cpp +++ b/inst/examples/ConvolveBenchmarks/overhead_1.cpp @@ -12,7 +12,7 @@ SEXP overhead_cpp(SEXP a, SEXP b) { extern "C" void R_init_overhead_1(DllInfo *info){ R_CallMethodDef callMethods[] = { - {"overhead_cpp", (DL_FUNC) &overhead_cpp, 2}, + {"overhead_cpp", (DL_FUNC) (RCPP_FUNC) &overhead_cpp, 2}, {NULL, NULL, 0} }; diff --git a/inst/examples/Misc/ifelseLooped.r b/inst/examples/Misc/ifelseLooped.r old mode 100644 new mode 100755 diff --git a/inst/examples/Misc/newFib.r b/inst/examples/Misc/newFib.r old mode 100644 new mode 100755 diff --git a/inst/examples/OpenMP/OpenMPandInline.r b/inst/examples/OpenMP/OpenMPandInline.r old mode 100644 new mode 100755 diff --git a/inst/include/Rcpp.h b/inst/include/Rcpp.h index e518a70ac..bec4f9f41 100644 --- a/inst/include/Rcpp.h +++ b/inst/include/Rcpp.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/inst/include/Rcpp/Benchmark/Timer.h b/inst/include/Rcpp/Benchmark/Timer.h index d8e3ea735..5dab598ac 100644 --- a/inst/include/Rcpp/Benchmark/Timer.h +++ b/inst/include/Rcpp/Benchmark/Timer.h @@ -1,8 +1,6 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// // Timer.h: Rcpp R/C++ interface class library -- Rcpp benchmark utility // -// Copyright (C) 2012 - 2014 JJ Allaire, Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012 - 2025 JJ Allaire, Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -26,7 +24,9 @@ #include #include -#define R_NO_REMAP +#ifndef R_NO_REMAP + #define R_NO_REMAP +#endif #include #if defined(_WIN32) diff --git a/inst/include/Rcpp/DataFrame.h b/inst/include/Rcpp/DataFrame.h index 84d69fc8f..806cb98f0 100644 --- a/inst/include/Rcpp/DataFrame.h +++ b/inst/include/Rcpp/DataFrame.h @@ -1,8 +1,8 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // DataFrame.h: Rcpp R/C++ interface class library -- data frames // -// Copyright (C) 2010 - 2021 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -47,7 +47,12 @@ namespace Rcpp{ set__(other) ; } - template + // enabled for everything except the InputParameter family (which + // each offer their own operator T() conversion), so this doesn't + // compete with that conversion, while still accepting anything + // wrap()-able, including third-party types (e.g. arma::mat) + template ::value, int>::type = 0> DataFrame_Impl( const T& obj ) ; DataFrame_Impl& operator=( DataFrame_Impl& other){ @@ -61,29 +66,21 @@ namespace Rcpp{ } // By definition, the number of rows in a data.frame is contained - // in its row.names attribute. If it has row names of the form 1:n, - // they will be stored as {NA_INTEGER, -}. Unfortunately, - // getAttrib(df, R_RowNamesSymbol) will force an expansion of that - // compact form thereby allocating a huge vector when we just want - // the row.names. Hence this workaround. - inline int nrow() const { - SEXP rn = R_NilValue ; - SEXP att = ATTRIB( Parent::get__() ) ; - while( att != R_NilValue ){ - if( TAG(att) == R_RowNamesSymbol ) { - rn = CAR(att) ; - break ; - } - att = CDR(att) ; - } - if (Rf_isNull(rn)) - return 0; - if (TYPEOF(rn) == INTSXP && LENGTH(rn) == 2 && INTEGER(rn)[0] == NA_INTEGER) - return std::abs(INTEGER(rn)[1]); - return LENGTH(rn); + // in its row.names attribute. Since R 3.5.0 this is returned as a + // compact sequence from which we can just take the (x)length + // But as this makes an allocation an even simpler check on length as + // discussed in #1430 is also possible and preferable. We also switch + // to returning R_xlen_t which as upcast from int is safe + inline R_xlen_t nrow() const { +#if R_VERSION < R_Version(4,6,0) + Shield rn{Rf_getAttrib(Parent::get__(), R_RowNamesSymbol)}; + return Rf_xlength(rn); +#else + return R_nrow(Parent::get__()); +#endif } - template + template void push_back( const T& object){ Parent::push_back(object); set_type_after_push(); @@ -108,8 +105,8 @@ namespace Rcpp{ } // Offer multiple variants to accomodate both old interface here and signatures in other classes - inline int nrows() const { return DataFrame_Impl::nrow(); } - inline int rows() const { return DataFrame_Impl::nrow(); } + inline R_xlen_t nrows() const { return DataFrame_Impl::nrow(); } + inline R_xlen_t rows() const { return DataFrame_Impl::nrow(); } inline R_xlen_t ncol() const { return DataFrame_Impl::length(); } inline R_xlen_t cols() const { return DataFrame_Impl::length(); } @@ -117,14 +114,10 @@ namespace Rcpp{ static DataFrame_Impl create(){ return DataFrame_Impl() ; } - #if defined(HAS_VARIADIC_TEMPLATES) - template - static DataFrame_Impl create(const T&... args) { - return DataFrame_Impl::from_list(Parent::create(args...)); - } - #else - #include - #endif + template + static DataFrame_Impl create(const T&... args) { + return DataFrame_Impl::from_list(Parent::create(args...)); + } private: void set__(SEXP x){ diff --git a/inst/include/Rcpp/DottedPair.h b/inst/include/Rcpp/DottedPair.h index f74e01fa0..ba08c10b0 100644 --- a/inst/include/Rcpp/DottedPair.h +++ b/inst/include/Rcpp/DottedPair.h @@ -2,7 +2,7 @@ // // DottedPair.h: Rcpp R/C++ interface class library -- dotted pair list template // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -35,14 +35,10 @@ RCPP_API_CLASS(DottedPair_Impl), DottedPair_Impl(SEXP x) { Storage::set__(x) ; } - #if defined(HAS_VARIADIC_TEMPLATES) - template - DottedPair_Impl(const T&... args) { - Storage::set__(pairlist(args...)); - } - #else - #include - #endif + template + DottedPair_Impl(const T&... args) { + Storage::set__(pairlist(args...)); + } void update(SEXP){} diff --git a/inst/include/Rcpp/Environment.h b/inst/include/Rcpp/Environment.h index 76779f2fb..7a77eb020 100644 --- a/inst/include/Rcpp/Environment.h +++ b/inst/include/Rcpp/Environment.h @@ -1,9 +1,9 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Environment.h: Rcpp R/C++ interface class library -- access R environments // -// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2014 - 2020 Dirk Eddelbuettel, Romain Francois and Kevin Ushey +// Copyright (C) 2009-2013 Dirk Eddelbuettel and Romain François +// Copyright (C) 2014-2025 Dirk Eddelbuettel, Romain François and Kevin Ushey +// Copyright (C) 2026 Dirk Eddelbuettel, Romain François, Kevin Ushey and Iñaki Ucar // // This file is part of Rcpp. // @@ -84,7 +84,7 @@ namespace Rcpp{ */ SEXP ls(bool all) const { SEXP env = Storage::get__() ; - return R_lsInternal( env, all ? TRUE : FALSE ) ; + return R_lsInternal3(env, all ? TRUE : FALSE, TRUE); return R_NilValue ; } @@ -96,17 +96,8 @@ namespace Rcpp{ * @return a SEXP (possibly R_NilValue) */ SEXP get(const std::string& name) const { - SEXP env = Storage::get__() ; - SEXP nameSym = Rf_install(name.c_str()); - SEXP res = Rf_findVarInFrame( env, nameSym ) ; - - if( res == R_UnboundValue ) return R_NilValue ; - - /* We need to evaluate if it is a promise */ - if( TYPEOF(res) == PROMSXP){ - res = internal::Rcpp_eval_impl( res, env ) ; - } - return res ; + Symbol nameSym = Rf_install(name.c_str()); + return get(nameSym); } /** @@ -118,14 +109,14 @@ namespace Rcpp{ */ SEXP get(Symbol name) const { SEXP env = Storage::get__() ; +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( env, name ) ; - - if( res == R_UnboundValue ) return R_NilValue ; - - /* We need to evaluate if it is a promise */ - if( TYPEOF(res) == PROMSXP){ - res = internal::Rcpp_eval_impl( res, env ) ; - } + if (res == R_UnboundValue) return R_NilValue; + if (TYPEOF(res) == PROMSXP) + res = internal::Rcpp_eval_impl(res, env); +#else + SEXP res = R_getVarEx(name, env, FALSE, R_NilValue); +#endif return res ; } @@ -138,17 +129,8 @@ namespace Rcpp{ * */ SEXP find( const std::string& name) const{ - SEXP env = Storage::get__() ; - SEXP nameSym = Rf_install(name.c_str()); - SEXP res = Rf_findVar( nameSym, env ) ; - - if( res == R_UnboundValue ) throw binding_not_found(name) ; - - /* We need to evaluate if it is a promise */ - if( TYPEOF(res) == PROMSXP){ - res = internal::Rcpp_eval_impl( res, env ) ; - } - return res ; + Symbol nameSym = Rf_install(name.c_str()); + return find(nameSym); } /** @@ -159,18 +141,15 @@ namespace Rcpp{ */ SEXP find(Symbol name) const{ SEXP env = Storage::get__() ; +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVar( name, env ) ; - - if( res == R_UnboundValue ) { - // Pass on the const char* to the RCPP_EXCEPTION_CLASS's - // const std::string& requirement - throw binding_not_found(name.c_str()) ; - } - - /* We need to evaluate if it is a promise */ - if( TYPEOF(res) == PROMSXP){ - res = internal::Rcpp_eval_impl( res, env ) ; - } + if (res == R_UnboundValue) throw binding_not_found(name.c_str()); + if (TYPEOF(res) == PROMSXP) + res = internal::Rcpp_eval_impl(res, env); +#else + SEXP res = R_getVarEx(name, env, TRUE, NULL); + if (res == NULL) throw binding_not_found(name.c_str()); +#endif return res ; } @@ -184,8 +163,13 @@ namespace Rcpp{ */ bool exists( const std::string& name ) const { SEXP nameSym = Rf_install(name.c_str()); +#if R_VERSION < R_Version(4,5,0) SEXP res = Rf_findVarInFrame( Storage::get__() , nameSym ) ; - return res != R_UnboundValue ; + return res != R_UnboundValue; +#else + SEXP res = R_getVarEx(nameSym, Storage::get__(), FALSE, NULL); + return res != NULL; +#endif } /** @@ -372,7 +356,11 @@ namespace Rcpp{ * The parent environment of this environment */ Environment_Impl parent() const { +#if R_VERSION < R_Version(4,5,0) return Environment_Impl( ENCLOS(Storage::get__()) ) ; +#else + return Environment_Impl(R_ParentEnv(Storage::get__())); +#endif } /** diff --git a/inst/include/Rcpp/Function.h b/inst/include/Rcpp/Function.h index f345978b3..c98777bd3 100644 --- a/inst/include/Rcpp/Function.h +++ b/inst/include/Rcpp/Function.h @@ -1,8 +1,8 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Function.h: Rcpp R/C++ interface class library -- functions (also primitives and builtins) // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain François and Iñaki Ucar // // This file is part of Rcpp. // @@ -43,12 +43,12 @@ namespace Rcpp{ case BUILTINSXP: Storage::set__(x); break; - default: + default: // #nocov start const char* fmt = "Cannot convert object to a function: " "[type=%s; target=CLOSXP, SPECIALSXP, or " "BUILTINSXP]."; throw not_compatible(fmt, Rf_type2char(TYPEOF(x))); - } + } // #nocov end } /** @@ -70,10 +70,23 @@ namespace Rcpp{ } Function_Impl(const std::string& name, const std::string& ns) { +#if R_VERSION < R_Version(4,5,0) + // before R 4.5.0 we would use Rf_findVarInFrame Shield env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str()))); - if (env == R_UnboundValue) { + if (env == R_UnboundValue) stop("there is no namespace called \"%s\"", ns); - } +#elif R_VERSION < R_Version(4,6,0) || R_SVN_REVISION < 89746 + // during R 4.5.* and before final R 4.6.0 we could use R_getVarEx + // along with R_NamespaceRegistry but avoid R_UnboundValue + Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue)); + if (env == R_NilValue) + stop("there is no namespace called \"%s\"", ns); +#else + // late R 4.6.0 development got us R_getRegisteredNamespace + Shield env(R_getRegisteredNamespace(ns.c_str())); + if (env == R_NilValue) + stop("there is no namespace called \"%s\"", ns); +#endif get_function(name, env); } @@ -82,14 +95,10 @@ namespace Rcpp{ return Rcpp_fast_eval(call, R_GlobalEnv); } - #if defined(HAS_VARIADIC_TEMPLATES) - template - SEXP operator()(const T&... args) const { + template + SEXP operator()(const T&... args) const { return invoke(pairlist(args...), R_GlobalEnv); - } - #else - #include - #endif + } /** * Returns the environment of this function @@ -99,7 +108,11 @@ namespace Rcpp{ if( TYPEOF(fun) != CLOSXP ) { throw not_a_closure(Rf_type2char(TYPEOF(fun))); } - return CLOENV(fun) ; + #if (defined(R_VERSION) && R_VERSION >= R_Version(4,5,0)) + return R_ClosureEnv(fun); + #else + return CLOENV(fun); + #endif } /** diff --git a/inst/include/Rcpp/InputParameter.h b/inst/include/Rcpp/InputParameter.h index eecaa0802..277ccd1b9 100644 --- a/inst/include/Rcpp/InputParameter.h +++ b/inst/include/Rcpp/InputParameter.h @@ -2,7 +2,8 @@ // // InputParameter.h: Rcpp R/C++ interface class library -- // -// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2013 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -94,6 +95,21 @@ namespace Rcpp { struct input_parameter { typedef typename Rcpp::ConstReferenceInputParameter type ; } ; + + // detects the InputParameter family, which each offer their own + // operator T() converting to whatever type they wrap. Generic + // wrap()-based converting constructors (e.g. DataFrame_Impl) use this + // to exclude these types, so that they don't compete with them + template + struct is_input_parameter : false_type {}; + template + struct is_input_parameter> : true_type {}; + template + struct is_input_parameter> : true_type {}; + template + struct is_input_parameter> : true_type {}; + template + struct is_input_parameter> : true_type {}; } } diff --git a/inst/include/Rcpp/InternalFunction.h b/inst/include/Rcpp/InternalFunction.h index 42f97f90f..43c37e0a3 100644 --- a/inst/include/Rcpp/InternalFunction.h +++ b/inst/include/Rcpp/InternalFunction.h @@ -26,9 +26,7 @@ #include -#ifdef RCPP_USING_CXX11 #include -#endif namespace Rcpp{ @@ -37,23 +35,25 @@ namespace Rcpp{ RCPP_GENERATE_CTOR_ASSIGN(InternalFunction_Impl) -#ifdef RCPP_USING_CXX11 + // the arity goes in the pointer tag, where InternalFunction_invoke + // checks it against the number of supplied arguments + template InternalFunction_Impl(const std::function &fun) { + Shield arity(Rf_ScalarInteger(static_cast(sizeof...(Args)))); set( XPtr >( new Rcpp::InternalFunctionWithStdFunction::CppFunctionBaseFromStdFunction(fun), - false + false, + arity ) ); } template InternalFunction_Impl(RESULT_TYPE (*fun)(T...)) { - set(XPtr >(new CppFunctionN(fun), true)); + Shield arity(Rf_ScalarInteger(static_cast(sizeof...(T)))); + set(XPtr >(new CppFunctionN(fun), true, arity)); } -#else - #include -#endif void update(SEXP){} private: diff --git a/inst/include/Rcpp/InternalFunctionWithStdFunction.h b/inst/include/Rcpp/InternalFunctionWithStdFunction.h index 03f67dfa6..993bf282e 100644 --- a/inst/include/Rcpp/InternalFunctionWithStdFunction.h +++ b/inst/include/Rcpp/InternalFunctionWithStdFunction.h @@ -1,9 +1,8 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- // // InternalFunction_with_std_function.h: Rcpp R/C++ interface class library -- exposing C++ std::function's // -// Copyright (C) 2014 Christian Authmann -// Copyright (C) 2015 Romain Francois and Dirk Eddelbuettel +// Copyright (C) 2014 - 2025 Christian Authmann +// Copyright (C) 2015 - 2025 Romain Francois and Dirk Eddelbuettel // // This file is part of Rcpp. // @@ -23,17 +22,12 @@ #ifndef Rcpp_InternalFunctionWithStdFunction_h #define Rcpp_InternalFunctionWithStdFunction_h -#if defined(HAS_VARIADIC_TEMPLATES) #include -#endif #include namespace Rcpp { namespace InternalFunctionWithStdFunction { - #if !defined(HAS_VARIADIC_TEMPLATES) && !defined(RCPP_USING_CXX11) - #include - #endif template class CppFunctionBaseFromStdFunction : public CppFunctionBase { diff --git a/inst/include/Rcpp/Language.h b/inst/include/Rcpp/Language.h index 75b7b0233..88df9544f 100644 --- a/inst/include/Rcpp/Language.h +++ b/inst/include/Rcpp/Language.h @@ -1,7 +1,8 @@ // Language.h: Rcpp R/C++ interface class library -- language objects (calls) // -// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -102,19 +103,15 @@ namespace Rcpp{ * 0.0 is wrapped as a numeric vector using wrap( const& double ) * ... */ - #if defined(HAS_VARIADIC_TEMPLATES) - template - Language_Impl(const std::string& symbol, const T&... t) { - Storage::set__(pairlist(Rf_install(symbol.c_str()), t...) ); - } + template + Language_Impl(const std::string& symbol, const T&... t) { + Storage::set__(langlist(Rf_install(symbol.c_str()), t...) ); + } - template - Language_Impl(const Function& function, const T&... t) { - Storage::set__(pairlist(function, t...)); - } - #else - #include - #endif + template + Language_Impl(const Function& function, const T&... t) { + Storage::set__(langlist(function, t...)); + } /** * sets the symbol of the call @@ -190,14 +187,10 @@ namespace Rcpp{ }; template -#if __cplusplus < 201103L - class unary_call : public std::unary_function { -#else class unary_call : public std::function { -#endif public: unary_call( Language call_ ) : call(call_), proxy(call_,1) {} - unary_call( Language call_, R_xlen_t index ) : call(call_), proxy(call_,index){} + unary_call( Language call_, int index ) : call(call_), proxy(call_,index){} unary_call( Function fun ) : call( fun, R_NilValue), proxy(call,1) {} RESULT_TYPE operator()( const T& object ){ @@ -211,14 +204,10 @@ namespace Rcpp{ }; template -#if __cplusplus < 201103L - class binary_call : public std::binary_function { -#else class binary_call : public std::function { -#endif public: binary_call( Language call_ ) : call(call_), proxy1(call_,1), proxy2(call_,2) {} - binary_call( Language call_, R_xlen_t index1, R_xlen_t index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){} + binary_call( Language call_, int index1, int index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){} binary_call( Function fun) : call(fun, R_NilValue, R_NilValue), proxy1(call,1), proxy2(call,2){} RESULT_TYPE operator()( const T1& o1, const T2& o2 ){ diff --git a/inst/include/Rcpp/Module.h b/inst/include/Rcpp/Module.h index a41c5a441..3aad2b80c 100644 --- a/inst/include/Rcpp/Module.h +++ b/inst/include/Rcpp/Module.h @@ -1,7 +1,7 @@ // Module.h: Rcpp R/C++ interface class library -- Rcpp modules // -// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -73,10 +73,33 @@ namespace Rcpp{ } ; namespace internal { + + // the class_ this shared library registered in a module, if + // any. Unrelated classes of the same name in other libraries share + // the typeid name, so make_new_object() passes this on for R to pick + // the right module class; hidden visibility keeps one per library, + // where the dynamic linker would otherwise share it between them + template + inline attribute_hidden void*& module_class_pointer(){ + static void* pointer = 0 ; + return pointer ; + } + template SEXP make_new_object( Class* ptr ){ Rcpp::XPtr xp( ptr, true ) ; - Function maker = Environment::Rcpp_namespace()[ "cpp_object_maker"] ; + Environment rcpp = Environment::Rcpp_namespace() ; + + // older versions of Rcpp only have cpp_object_maker() + void* class_pointer = module_class_pointer() ; + SEXP maker_by_class = rcpp.get( "cpp_object_maker_by_class" ) ; + if( class_pointer != 0 && maker_by_class != R_NilValue ){ + Shield class_xp( R_MakeExternalPtr( class_pointer, R_NilValue, R_NilValue ) ) ; + Function maker( maker_by_class ) ; + return maker( typeid(Class).name(), xp, class_xp ) ; + } + + Function maker = rcpp[ "cpp_object_maker" ] ; return maker( typeid(Class).name() , xp ) ; } } @@ -86,7 +109,6 @@ namespace Rcpp{ #include #include -#if defined(HAS_VARIADIC_TEMPLATES) namespace Rcpp { template inline void signature(std::string& s, const char* name) { @@ -114,7 +136,7 @@ namespace Rcpp { inline int nargs() { return sizeof...(T); } inline bool is_void() { return std::is_void::value; } inline void signature(std::string& s, const char* name) { Rcpp::signature(s, name); } - inline DL_FUNC get_function_ptr() { return (DL_FUNC)ptr_fun; } + inline DL_FUNC get_function_ptr() { return (DL_FUNC)(RCPP_FUNC)ptr_fun; } private: RESULT_TYPE (*ptr_fun)(T...); @@ -132,11 +154,7 @@ namespace Rcpp { Rcpp::List formals; }; } -#else - #include - // templates CppFunction0, ..., CppFunction65 - #include -#endif + #include #include @@ -177,7 +195,7 @@ namespace Rcpp{ private: ParentMethod* parent_method_pointer ; } ; -#if defined(HAS_VARIADIC_TEMPLATES) + template inline void ctor_signature(std::string& s, const std::string& classname) { s.assign(classname); @@ -210,7 +228,7 @@ namespace Rcpp{ private: template - Class* get_new_impl(SEXP* args, int nargs, traits::index_sequence) { + Class* get_new_impl(SEXP* args, int /*nargs*/, traits::index_sequence) { return new Class( as(args[Is])... ) ; } }; @@ -227,7 +245,7 @@ namespace Rcpp{ class Factory : public Factory_Base { public: Factory( Class* (*fun)(T...) ) : ptr_fun(fun){} - virtual Class* get_new( SEXP* args, int nargs ){ + virtual Class* get_new( SEXP* args, int /*nargs*/ ){ return get_new( args, traits::make_index_sequence() ) ; } virtual int nargs(){ return sizeof...(T) ; } @@ -251,13 +269,6 @@ namespace Rcpp{ return nargs == n ; } -#else -#include -#include -#include -#include -#endif - typedef bool (*ValidConstructor)(SEXP*,int) ; typedef bool (*ValidMethod)(SEXP*,int) ; @@ -322,20 +333,20 @@ namespace Rcpp{ } ; template - class S4_CppConstructor : public Reference { - typedef Reference Base; + class S4_CppConstructor : public S4 { + typedef S4 Base; public: typedef XPtr XP_Class ; - typedef Reference::Storage Storage ; + typedef S4::Storage Storage ; - S4_CppConstructor( SignedConstructor* m, const XP_Class& class_xp, const std::string& class_name, std::string& buffer ) : Reference( "C++Constructor" ){ + S4_CppConstructor( SignedConstructor* m, const XP_Class& class_xp, const std::string& class_name, std::string& buffer ) : S4( "C++Constructor" ){ RCPP_DEBUG( "S4_CppConstructor( SignedConstructor* m, SEXP class_xp, const std::string& class_name, std::string& buffer" ) ; - field( "pointer" ) = Rcpp::XPtr< SignedConstructor >( m, false ) ; - field( "class_pointer" ) = class_xp ; - field( "nargs" ) = m->nargs() ; + slot( "pointer" ) = Rcpp::XPtr< SignedConstructor >( m, false ) ; + slot( "class_pointer" ) = class_xp ; + slot( "nargs" ) = m->nargs() ; m->signature( buffer, class_name ) ; - field( "signature" ) = buffer ; - field( "docstring" ) = m->docstring ; + slot( "signature" ) = buffer ; + slot( "docstring" ) = m->docstring ; } RCPP_CTOR_ASSIGN_WITH_BASE(S4_CppConstructor) @@ -343,14 +354,14 @@ namespace Rcpp{ } ; template - class S4_CppOverloadedMethods : public Rcpp::Reference { - typedef Rcpp::Reference Base; + class S4_CppOverloadedMethods : public Rcpp::S4 { + typedef Rcpp::S4 Base; public: typedef Rcpp::XPtr XP_Class ; typedef SignedMethod signed_method_class ; typedef std::vector vec_signed_method ; - S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp, const char* name, std::string& buffer ) : Reference( "C++OverloadedMethods" ){ + S4_CppOverloadedMethods( vec_signed_method* m, const XP_Class& class_xp, const char* name, std::string& buffer ) : S4( "C++OverloadedMethods" ){ int n = static_cast(m->size()) ; Rcpp::LogicalVector voidness(n), constness(n) ; Rcpp::CharacterVector docstrings(n), signatures(n) ; @@ -366,14 +377,14 @@ namespace Rcpp{ signatures[i] = buffer ; } - field( "pointer" ) = Rcpp::XPtr< vec_signed_method >( m, false ) ; - field( "class_pointer" ) = class_xp ; - field( "size" ) = n ; - field( "void" ) = voidness ; - field( "const" ) = constness ; - field( "docstrings" ) = docstrings ; - field( "signatures" ) = signatures ; - field( "nargs" ) = nargs ; + slot( "pointer" ) = Rcpp::XPtr< vec_signed_method >( m, false ) ; + slot( "class_pointer" ) = class_xp ; + slot( "size" ) = n ; + slot( "void" ) = voidness ; + slot( "const" ) = constness ; + slot( "docstrings" ) = docstrings ; + slot( "signatures" ) = signatures ; + slot( "nargs" ) = nargs ; } @@ -381,7 +392,7 @@ namespace Rcpp{ } ; -#if defined(HAS_VARIADIC_TEMPLATES) + template class CppMethodImplN : public CppMethod { public: @@ -441,10 +452,8 @@ namespace Rcpp{ template using Const_Pointer_CppMethodN = Pointer_CppMethodImplN; -#else - #include - #include -#endif + + template class CppProperty { @@ -502,17 +511,17 @@ namespace Rcpp{ } ; template - class S4_field : public Rcpp::Reference { - typedef Rcpp::Reference Base; + class S4_field : public Rcpp::S4 { + typedef Rcpp::S4 Base; public: typedef XPtr XP_Class ; - S4_field( CppProperty* p, const XP_Class& class_xp ) : Reference( "C++Field" ){ + S4_field( CppProperty* p, const XP_Class& class_xp ) : S4( "C++Field" ){ RCPP_DEBUG( "S4_field( CppProperty* p, const XP_Class& class_xp )" ) - field( "read_only" ) = p->is_readonly() ; - field( "cpp_class" ) = p->get_class(); - field( "pointer" ) = Rcpp::XPtr< CppProperty >( p, false ) ; - field( "class_pointer" ) = class_xp ; - field( "docstring" ) = p->docstring ; + slot( "read_only" ) = p->is_readonly() ; + slot( "cpp_class" ) = p->get_class(); + slot( "pointer" ) = Rcpp::XPtr< CppProperty >( p, false ) ; + slot( "class_pointer" ) = class_xp ; + slot( "docstring" ) = p->docstring ; } RCPP_CTOR_ASSIGN_WITH_BASE(S4_field) @@ -552,7 +561,7 @@ namespace Rcpp{ } ; } -#if defined(HAS_VARIADIC_TEMPLATES) + namespace Rcpp { template void function(const char* name_, RESULT_TYPE (*fun)(T... t), const char* docstring = 0) { @@ -570,10 +579,7 @@ namespace Rcpp { } } } -#else - // function factories - #include -#endif + namespace Rcpp { @@ -588,7 +594,7 @@ namespace Rcpp { public: typedef XPtr XP_Class ; typedef Rcpp::XPtr XP ; - CppClass( SEXP x) : S4(x){}; + CppClass( SEXP x) : S4(x){}; // #nocov CppClass( Module* p, class_Base* cl, std::string& buffer ) : S4("C++Class") { XP_Class clxp( cl, false, R_NilValue, R_NilValue ) ; @@ -627,18 +633,56 @@ namespace Rcpp { } +namespace Rcpp { + namespace internal { + + // makes module the target of class_<>, function(), etc. while an + // RCPP_MODULE body runs, and restores the previous scope however the + // body exits, so a module loaded from within another module body + // does not clobber the outer scope + class ModuleScope { + public: + explicit ModuleScope( Module* module ) : previous( ::getCurrentScope() ){ + ::setCurrentScope( module ) ; + } + ~ModuleScope(){ ::setCurrentScope( previous ) ; } + + ModuleScope( const ModuleScope& ) = delete ; + ModuleScope& operator=( const ModuleScope& ) = delete ; + + private: + Module* previous ; + } ; + + } +} + #define RCPP_MODULE_BOOT(name) _rcpp_module_boot_##name -#define RCPP_MODULE(name) \ - void _rcpp_module_##name##_init() ; \ - static Rcpp::Module _rcpp_module_##name( # name ) ; \ - extern "C" SEXP _rcpp_module_boot_##name(){ \ - ::setCurrentScope( & _rcpp_module_##name ) ; \ - _rcpp_module_##name##_init( ) ; \ - Rcpp::XPtr mod_xp(& _rcpp_module_##name , false); \ - ::setCurrentScope( 0 ) ; \ - return mod_xp ; \ - } \ +// the boot function is called from R via .Call(), so exceptions thrown by +// the module body must be turned into R errors; it runs every time the +// module is loaded, but the body adds to the static module, so it may only +// run once, and a body that throws part-way leaves nothing behind so that +// the next load does not append to what it registered +#define RCPP_MODULE(name) \ + void _rcpp_module_##name##_init() ; \ + static Rcpp::Module _rcpp_module_##name( # name ) ; \ + static bool _rcpp_module_##name##_initialized = false ; \ + extern "C" SEXP _rcpp_module_boot_##name(){ \ + BEGIN_RCPP \ + if( ! _rcpp_module_##name##_initialized ){ \ + Rcpp::internal::ModuleScope _rcpp_module_scope( & _rcpp_module_##name ) ; \ + try { \ + _rcpp_module_##name##_init( ) ; \ + } catch( ... ) { \ + _rcpp_module_##name.clear() ; \ + throw ; \ + } \ + _rcpp_module_##name##_initialized = true ; \ + } \ + return Rcpp::XPtr( & _rcpp_module_##name , false ) ; \ + END_RCPP \ + } \ void _rcpp_module_##name##_init() // silly little dance to suppress a 'defined but not used variable' warning diff --git a/inst/include/Rcpp/Nullable.h b/inst/include/Rcpp/Nullable.h index 53704ffb8..e810dbb7e 100644 --- a/inst/include/Rcpp/Nullable.h +++ b/inst/include/Rcpp/Nullable.h @@ -1,8 +1,7 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Nullable.h: Rcpp R/C++ interface class library -- SEXP container which can be NULL // -// Copyright (C) 2015 Dirk Eddelbuettel and Daniel C. Dillon +// Copyright (C) 2015-2026 Dirk Eddelbuettel and Daniel C. Dillon // // This file is part of Rcpp. // @@ -81,6 +80,18 @@ namespace Rcpp { return m_sexp; } +#if R_VERSION > R_Version(4,3,0) && !defined(RCPP_DISABLE_NULLABLE_T) + /** + * operator T() to return nullable object + * + * @throw 'not initialized' if object has not been set + */ + inline operator T() const { + checkIfSet(); + return Rcpp::as(m_sexp); + } +#endif + /** * get() accessor for object * @@ -126,7 +137,7 @@ namespace Rcpp { /** * Returns m_sexp as a T */ - inline T as() { return get(); } + inline T as() { return Rcpp::as(get()); } /** * Return a clone of m_sexp as a T diff --git a/inst/include/Rcpp/Pairlist.h b/inst/include/Rcpp/Pairlist.h index facd5ffa1..375d74271 100644 --- a/inst/include/Rcpp/Pairlist.h +++ b/inst/include/Rcpp/Pairlist.h @@ -2,7 +2,7 @@ // // Pairlist.h: Rcpp R/C++ interface class library -- pair lists objects (LISTSXP) // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -42,14 +42,11 @@ namespace Rcpp{ Pairlist_Impl(SEXP x){ Storage::set__(r_cast(x)) ; } - #if defined(HAS_VARIADIC_TEMPLATES) - template - Pairlist_Impl(const T&... args ){ - Storage::set__(pairlist(args... )) ; - } - #else - #include - #endif + template + Pairlist_Impl(const T&... args ){ + Storage::set__(pairlist(args... )) ; + } + void update(SEXP x) { if (TYPEOF(x) != LISTSXP) { Storage::set__(r_cast(x)); diff --git a/inst/include/Rcpp/Promise.h b/inst/include/Rcpp/Promise.h index 8b4096a01..c63593242 100644 --- a/inst/include/Rcpp/Promise.h +++ b/inst/include/Rcpp/Promise.h @@ -2,7 +2,8 @@ // // Promise.h: Rcpp R/C++ interface class library -- promises (PROMSXP) // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain François +// Copyright (C) 2026 Dirk Eddelbuettel, Romain François and Iñaki Ucar // // This file is part of Rcpp. // @@ -48,13 +49,18 @@ namespace Rcpp{ * Return the result of the PRVALUE macro on the promise */ SEXP value() const{ - SEXP val = PRVALUE( Storage::get__() ) ; - if( val == R_UnboundValue ) throw unevaluated_promise() ; - return val ; + if (!was_evaluated()) throw unevaluated_promise(); + return PRVALUE(Storage::get__()); } bool was_evaluated() const { +#if R_VERSION < R_Version(4,6,0) return PRVALUE(Storage::get__()) != R_UnboundValue ; +#else + SEXP env = environment(); + R_BindingType_t bt = R_GetBindingType(Storage::get__(), env); + return bt != R_BindingTypeUnbound; +#endif } /** @@ -71,7 +77,7 @@ namespace Rcpp{ return Environment( PRENV(Storage::get__() ) ) ; } - inline void update(SEXP data){} + inline void update(SEXP /*data*/){} } ; diff --git a/inst/include/Rcpp/Rmath.h b/inst/include/Rcpp/Rmath.h index 757b88582..ad1958e52 100644 --- a/inst/include/Rcpp/Rmath.h +++ b/inst/include/Rcpp/Rmath.h @@ -1,8 +1,7 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // Rmath.h: Rcpp R/C++ interface class library -- Wrappers for R's Rmath API // -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2012-2025 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -131,12 +130,10 @@ namespace R { inline double qnbinom(double p, double sz, double pb, int lt, int lg) { return ::Rf_qnbinom(p, sz, pb, lt, lg); } inline double rnbinom(double sz, double pb) { return ::Rf_rnbinom(sz, pb); } -#if R_VERSION >= R_Version(3, 1, 2) inline double dnbinom_mu(double x, double sz, double mu, int lg) { return ::Rf_dnbinom_mu(x, sz, mu, lg); } inline double pnbinom_mu(double x, double sz, double mu, int lt, int lg) { return ::Rf_pnbinom_mu(x, sz, mu, lt, lg); } inline double qnbinom_mu(double x, double sz, double mu, int lt, int lg) { return ::Rf_qnbinom_mu(x, sz, mu, lt, lg); } //inline double rnbinom_mu(double sz, double mu) { return ::Rf_rnbinom_mu(sz, mu); } -#endif /* Poisson Distribution */ inline double dpois(double x, double lb, int lg) { return ::Rf_dpois(x, lb, lg); } @@ -160,7 +157,7 @@ namespace R { inline double dnbeta(double x, double a, double b, double ncp, int lg) { return ::Rf_dnbeta(x, a, b, ncp, lg); } inline double pnbeta(double x, double a, double b, double ncp, int lt, int lg) { return ::Rf_pnbeta(x, a, b, ncp, lt, lg); } inline double qnbeta(double p, double a, double b, double ncp, int lt, int lg) { return ::Rf_qnbeta(p, a, b, ncp, lt, lg); } - inline double rnbeta(double a, double b, double np) { return ::Rf_rnbeta(a, b, np); } + //inline double rnbeta(double a, double b, double np) { return ::Rf_rnbeta(a, b, np); } /* Non-central F Distribution */ inline double dnf(double x, double df1, double df2, double ncp, int lg) { return ::Rf_dnf(x, df1, df2, ncp, lg); } diff --git a/inst/include/Rcpp/S4.h b/inst/include/Rcpp/S4.h index d5fa8746a..2ec8cdebf 100644 --- a/inst/include/Rcpp/S4.h +++ b/inst/include/Rcpp/S4.h @@ -1,8 +1,7 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- -// + // S4.h: Rcpp R/C++ interface class library -- S4 objects // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -38,10 +37,10 @@ namespace Rcpp{ * * @param x must be an S4 object */ - S4_Impl(SEXP x) { + S4_Impl(SEXP x) { // #nocov start if( ! ::Rf_isS4(x) ) throw not_s4() ; Storage::set__(x) ; - } + } // #nocov end S4_Impl& operator=( SEXP other ){ Storage::set__( other ) ; @@ -57,7 +56,7 @@ namespace Rcpp{ S4_Impl( const std::string& klass ){ Shield x( R_do_new_object(R_do_MAKE_CLASS(klass.c_str())) ); if (!Rf_inherits(x, klass.c_str())) - throw S4_creation_error( klass ) ; + throw S4_creation_error( klass ) ; // #nocov Storage::set__(x) ; } diff --git a/inst/include/Rcpp/StretchyList.h b/inst/include/Rcpp/StretchyList.h index 3a73de118..ad72fc60e 100644 --- a/inst/include/Rcpp/StretchyList.h +++ b/inst/include/Rcpp/StretchyList.h @@ -1,6 +1,7 @@ // StretchyList.h: Rcpp R/C++ interface class library -- stretchy lists // -// Copyright (C) 2013 Romain Francois +// Copyright (C) 2013 - 2025 Romain Francois +// Copyright (C) 2026 Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -48,7 +49,7 @@ namespace Rcpp{ Storage::set__(r_cast(x)) ; } - void update(SEXP x){} + void update(SEXP /*x*/){} inline operator SEXP() const{ return CDR(Storage::get__() ); diff --git a/inst/include/Rcpp/String.h b/inst/include/Rcpp/String.h index 8316acee1..2103e5b28 100644 --- a/inst/include/Rcpp/String.h +++ b/inst/include/Rcpp/String.h @@ -2,7 +2,7 @@ // String.h: Rcpp R/C++ interface class library -- single string // // Copyright (C) 2012 - 2020 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2021 - 2023 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -117,7 +117,7 @@ namespace Rcpp { String(const std::string& s, cetype_t enc = CE_UTF8) : data(R_NilValue), token(R_NilValue), buffer(s), valid(false), buffer_ready(true), enc(enc) { RCPP_STRING_DEBUG("String(const std::string&, cetype_t)"); } -#ifdef RCPP_USING_CXX11 + /** move constructor */ String(String&& s) : data(s.data), token(s.token), buffer(std::move(s.buffer)), valid(s.valid), buffer_ready(s.buffer_ready), enc(s.enc) { // Erase s. @@ -134,7 +134,7 @@ namespace Rcpp { String(std::string&& s, cetype_t enc = CE_UTF8) : data(R_NilValue), token(R_NilValue), buffer(s), valid(false), buffer_ready(true), enc(enc) { RCPP_STRING_DEBUG("String(std::string&&, cetype_t)"); } -#endif + String(const std::wstring& s, cetype_t enc = CE_UTF8) : data(internal::make_charsexp(s)), token(R_NilValue), valid(true), buffer_ready(false), enc(enc) { token = Rcpp_PreciousPreserve(data); RCPP_STRING_DEBUG("String(const std::wstring&, cetype_t)"); @@ -267,7 +267,6 @@ namespace Rcpp { buffer_ready = true; return *this; } -#ifdef RCPP_USING_CXX11 inline String& operator=(String&& other) { data = other.data; token = other.token; @@ -290,7 +289,6 @@ namespace Rcpp { buffer_ready = true; return *this; } -#endif inline String& operator=(const char* s) { buffer = s; valid = false; @@ -734,24 +732,14 @@ namespace Rcpp { } // Rcpp -/** hash can be in std or std::tr1 */ -#if defined(RCPP_USING_CXX11) || defined(HAS_TR1) -namespace std -{ -#ifndef RCPP_USING_CXX11 -namespace tr1 { -#endif +/** hash via std */ +namespace std { template <> - struct hash - { + struct hash { size_t operator()(const Rcpp::String & s) const{ return hash()(s.get_cstring()); } }; -#ifndef RCPP_USING_CXX11 -} -#endif } -#endif #endif diff --git a/inst/include/Rcpp/StringTransformer.h b/inst/include/Rcpp/StringTransformer.h index 0824c031c..8c009ff04 100644 --- a/inst/include/Rcpp/StringTransformer.h +++ b/inst/include/Rcpp/StringTransformer.h @@ -1,7 +1,7 @@ // clone.h: Rcpp R/C++ interface class library -- clone RObject's // -// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -26,11 +26,7 @@ namespace Rcpp{ template -#if __cplusplus < 201103L - class StringTransformer : public std::unary_function { -#else class StringTransformer : public std::function { -#endif public: StringTransformer( const UnaryOperator& op_ ): op(op_), buffer(){} ~StringTransformer(){} diff --git a/inst/include/Rcpp/Symbol.h b/inst/include/Rcpp/Symbol.h index 7a4152c62..beabc546c 100644 --- a/inst/include/Rcpp/Symbol.h +++ b/inst/include/Rcpp/Symbol.h @@ -43,21 +43,13 @@ namespace Rcpp{ Storage::set__( x ) ; break; /* nothing to do */ case CHARSXP: { - #if R_VERSION >= R_Version(3,2,0) SEXP charSym = Rf_installChar(x); // R 3.2.0 or later have Rf_installChar - #else - SEXP charSym = Rf_install(CHAR(x)); // cannot be gc()'ed once in symbol table - #endif Storage::set__( charSym ) ; break ; } case STRSXP: { /* FIXME: check that there is at least one element */ - #if R_VERSION >= R_Version(3,2,0) SEXP charSym = Rf_installChar(STRING_ELT(x, 0 )); // R 3.2.0 or later have Rf_installChar - #else - SEXP charSym = Rf_install( CHAR(STRING_ELT(x, 0 )) ); // cannot be gc()'ed once in symbol table - #endif Storage::set__( charSym ); break ; } diff --git a/inst/include/Rcpp/algo.h b/inst/include/Rcpp/algo.h index c57cbf58d..5a1ed1e02 100644 --- a/inst/include/Rcpp/algo.h +++ b/inst/include/Rcpp/algo.h @@ -2,7 +2,8 @@ // // algo.h: Rcpp R/C++ interface class library -- STL-style algorithms // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -64,14 +65,17 @@ inline bool __any( RandomAccessIterator __first, RandomAccessIterator __last, co if (*__first == __val) return true; ++__first; + // fallthrough case 2: if (*__first == __val) return true; ++__first; + // fallthrough case 1: if (*__first == __val) return true; ++__first; + // fallthrough case 0: default: return false; diff --git a/inst/include/Rcpp/algorithm.h b/inst/include/Rcpp/algorithm.h index 1080dec12..2c84815cd 100644 --- a/inst/include/Rcpp/algorithm.h +++ b/inst/include/Rcpp/algorithm.h @@ -2,7 +2,8 @@ // // algorithm.h: Rcpp R/C++ interface class library -- data frames // -// Copyright (C) 2016 - 2017 Daniel C. Dillon +// Copyright (C) 2016 - 2024 Daniel C. Dillon +// Copyright (C) 2025 Daniel C. Dillon and Iñaki Ucar // // This file is part of Rcpp. // @@ -22,14 +23,6 @@ #ifndef Rcpp__Algorithm_h #define Rcpp__Algorithm_h -#if __cplusplus >= 201103L || __INTEL_CXX11_MODE__ == 1 -# define RCPP_CONSTEXPR_FUNC constexpr -# define RCPP_CONSTEXPR_VAR constexpr -#else -# define RCPP_CONSTEXPR_FUNC -# define RCPP_CONSTEXPR_VAR const -#endif - namespace Rcpp { namespace algorithm { @@ -38,9 +31,7 @@ namespace helpers { typedef struct {char a[2];} CTYPE_SHORT; typedef struct {char a[3];} CTYPE_INT; typedef struct {char a[4];} CTYPE_LONG; -#ifdef RCPP_HAS_LONG_LONG_TYPES typedef struct {char a[5];} CTYPE_LONG_LONG; -#endif typedef struct {char a[6];} CTYPE_FLOAT; typedef struct {char a[7];} CTYPE_DOUBLE; typedef struct {char a[8];} CTYPE_LONG_DOUBLE; @@ -49,9 +40,7 @@ namespace helpers { typedef struct {char a[11];} CTYPE_UNSIGNED_SHORT; typedef struct {char a[12];} CTYPE_UNSIGNED_INT; typedef struct {char a[13];} CTYPE_UNSIGNED_LONG; -#ifdef RCPP_HAS_LONG_LONG_TYPES typedef struct {char a[14];} CTYPE_UNSIGNED_LONG_LONG; -#endif typedef struct {char a[128];} CTYPE_UNKNOWN; template< std::size_t I > @@ -69,10 +58,8 @@ namespace helpers { template<> struct ctype_helper< sizeof(CTYPE_LONG) > { typedef long type; static const bool value = true; }; -#ifdef RCPP_HAS_LONG_LONG_TYPES template<> struct ctype_helper< sizeof(CTYPE_LONG_LONG) > { typedef rcpp_long_long_type type; static const bool value = true; }; -#endif template<> struct ctype_helper< sizeof(CTYPE_FLOAT) > { typedef float type; static const bool value = true; }; @@ -98,11 +85,8 @@ namespace helpers { template<> struct ctype_helper< sizeof(CTYPE_UNSIGNED_LONG) > { typedef unsigned long type; static const bool value = true; }; -#ifdef RCPP_HAS_LONG_LONG_TYPES template<> struct ctype_helper< sizeof(CTYPE_UNSIGNED_LONG_LONG) > { typedef rcpp_ulong_long_type type; static const bool value = true; }; -#endif - template< typename T > struct ctype @@ -111,9 +95,7 @@ namespace helpers { static CTYPE_SHORT test(const short &); static CTYPE_INT test(const int &); static CTYPE_LONG test(const long &); -#ifdef RCPP_HAS_LONG_LONG_TYPES static CTYPE_LONG_LONG test(const rcpp_long_long_type &); -#endif static CTYPE_FLOAT test(const float &); static CTYPE_DOUBLE test(const double &); static CTYPE_LONG_DOUBLE test(const long double &); @@ -122,9 +104,7 @@ namespace helpers { static CTYPE_UNSIGNED_SHORT test(const unsigned short &); static CTYPE_UNSIGNED_INT test(const unsigned int &); static CTYPE_UNSIGNED_LONG test(const unsigned long &); -#ifdef RCPP_HAS_LONG_LONG_TYPES static CTYPE_UNSIGNED_LONG_LONG test(const rcpp_ulong_long_type &); -#endif static CTYPE_UNKNOWN test(...); static T make(); @@ -139,9 +119,7 @@ namespace helpers { static CTYPE_SHORT test(const short &); static CTYPE_INT test(const int &); static CTYPE_LONG test(const long &); -#ifdef RCPP_HAS_LONG_LONG_TYPES static CTYPE_LONG_LONG test(const rcpp_long_long_type &); -#endif static CTYPE_FLOAT test(const float &); static CTYPE_DOUBLE test(const double &); static CTYPE_LONG_DOUBLE test(const long double &); @@ -150,9 +128,7 @@ namespace helpers { static CTYPE_UNSIGNED_SHORT test(const unsigned short &); static CTYPE_UNSIGNED_INT test(const unsigned int &); static CTYPE_UNSIGNED_LONG test(const unsigned long &); -#ifdef RCPP_HAS_LONG_LONG_TYPES static CTYPE_UNSIGNED_LONG_LONG test(const rcpp_ulong_long_type &); -#endif static CTYPE_UNKNOWN test(...); static T make(); @@ -167,29 +143,29 @@ namespace helpers { template<> struct rtype_helper< double > { typedef double type; - static RCPP_CONSTEXPR_VAR int RTYPE = REALSXP; + static constexpr int RTYPE = REALSXP; static inline double NA() { return NA_REAL; } - static inline RCPP_CONSTEXPR_FUNC double ZERO() { return 0.0; } - static inline RCPP_CONSTEXPR_FUNC double ONE() { return 1.0; } + static inline constexpr double ZERO() { return 0.0; } + static inline constexpr double ONE() { return 1.0; } }; template<> struct rtype_helper< int > { typedef int type; - static RCPP_CONSTEXPR_VAR int RTYPE = INTSXP; + static constexpr int RTYPE = INTSXP; static inline int NA() { return NA_INTEGER; } - static inline RCPP_CONSTEXPR_FUNC int ZERO() { return 0; } - static inline RCPP_CONSTEXPR_FUNC int ONE() { return 1; } + static inline constexpr int ZERO() { return 0; } + static inline constexpr int ONE() { return 1; } }; template< typename T > struct rtype { typedef typename rtype_helper< typename ctype< T >::type >::type type; typedef rtype_helper< typename ctype< T >::type > helper_type; - static RCPP_CONSTEXPR_VAR int RTYPE = helper_type::RTYPE; + static constexpr int RTYPE = helper_type::RTYPE; static inline T NA() { return helper_type::NA(); } - static inline RCPP_CONSTEXPR_FUNC T ZERO() { return helper_type::ZERO(); } - static inline RCPP_CONSTEXPR_FUNC T ONE() { return helper_type::ONE(); } + static inline constexpr T ZERO() { return helper_type::ZERO(); } + static inline constexpr T ONE() { return helper_type::ONE(); } }; struct log { @@ -483,7 +459,4 @@ void sqrt(InputIterator begin, InputIterator end, OutputIterator out) { } // namespace algorithm } // namespace Rcpp -#undef RCPP_CONSTEXPR_FUNC -#undef RCPP_CONSTEXPR_VAR - #endif diff --git a/inst/include/Rcpp/api/meat/DataFrame.h b/inst/include/Rcpp/api/meat/DataFrame.h index b679e32ab..67bd81595 100644 --- a/inst/include/Rcpp/api/meat/DataFrame.h +++ b/inst/include/Rcpp/api/meat/DataFrame.h @@ -1,4 +1,5 @@ -// Copyright (C) 2013 Romain Francois +// Copyright (C) 2013 - 2025 Romain Francois +// Copyright (C) 2026 Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -21,7 +22,8 @@ namespace Rcpp{ template