Skip to content

Commit da0817e

Browse files
committed
tidy documentation
1 parent 92b64bc commit da0817e

File tree

118 files changed

+9741
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+9741
-312
lines changed

.Rbuildignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ script.R
1313
^\.clangd$
1414
^compile_flags\.txt$
1515
^compile_commands\.json$
16-
^cpp4rtest$
1716
^codecov\.yml$
1817
^R/coverage\.R$
1918
^book$
@@ -32,3 +31,8 @@ script.R
3231
^\.cache$
3332
^docs$
3433
^pkgdown$
34+
^cpp4rdummyols$
35+
^cpp4rgaussjordan$
36+
^cpp4romp$
37+
^cpp4rsimplexphase2$
38+
^cpp4rtest$

.github/workflows/R-CMD-check.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
# Use older ubuntu to maximise backward compatibility
3535
- {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
36-
- {os: ubuntu-22.04, r: 'release'}
36+
- {os: ubuntu-22.04, r: 'release', custom: 'clang-format'}
3737
- {os: ubuntu-22.04, r: 'release', custom: 'no-cpp4rtest'}
3838
- {os: ubuntu-22.04, r: 'oldrel-1'}
3939
- {os: ubuntu-22.04, r: 'oldrel-2'}
@@ -47,6 +47,14 @@ jobs:
4747
steps:
4848
- uses: actions/checkout@v4
4949

50+
- uses: pachadotdev/clang-format@v1
51+
if: matrix.config.custom == 'clang-format'
52+
with:
53+
version: '20'
54+
files: 'src/*.cpp src/*.h inst/include/*.h'
55+
auto-commit: true
56+
commit-message: 'style: format C++ code in R package'
57+
5058
- uses: r-lib/actions/setup-pandoc@v2
5159

5260
- uses: r-lib/actions/setup-r@v2

.github/workflows/format.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Description: Provides a header only, C++ interface to R's C
1515
to normal R function semantics and supports interaction with 'ALTREP'
1616
vectors.
1717
License: MIT + file LICENSE
18-
URL: https://cpp4r.r-lib.org, https://github.com/r-lib/cpp4r
19-
BugReports: https://github.com/r-lib/cpp4r/issues
18+
URL: https://cpp4r.org, https://github.com/pachadotdev/cpp4r
19+
BugReports: https://github.com/pachadotdev/cpp4r/issues
2020
Depends:
2121
R (>= 4.0.0)
2222
Suggests:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ site:
2020
install:
2121
@Rscript -e 'devtools::install()'
2222

23-
clang_format=`which clang-format-14`
23+
clang_format=`which clang-format-20`
2424

2525
format: $(shell find . -name '*.h') $(shell find . -name '*.hpp') $(shell find . -name '*.cpp')
26-
@${clang_format} -i $?
26+
@${clang_format} -i $?

README.md

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@
55
[![R-CMD-check](https://github.com/r-lib/cpp4r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/cpp4r/actions/workflows/R-CMD-check.yaml)
66
[![CRAN status](https://www.r-pkg.org/badges/version/cpp4r)](https://CRAN.R-project.org/package=cpp4r)
77
[![Codecov test coverage](https://codecov.io/gh/r-lib/cpp4r/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/cpp4r?branch=main)
8+
[![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg)](https://www.buymeacoffee.com/pacha)
89
<!-- badges: end -->
910

1011
cpp4r helps you to interact with R objects using C++ code.
11-
Its goals and syntax are similar to the excellent [Rcpp](https://cran.r-project.org/package=Rcpp) package.
12+
It is a fork of the [cpp11](https://cran.r-project.org/package=cpp) package with identical syntax and similar goals.
13+
14+
cpp4r can be used as a replacement for cpp11 in existing or new packages. Think of cpp11 and cpp4r as MySQL and MariaDB: they are almost identical, but cpp4r has some extra features.
15+
16+
After discussing some [pull requests](https://github.com/r-lib/cpp11/pulls/pachadotdev) with Hadley Wickham from Posit, it was mentioned that I should create my own fork to add the following features:
17+
18+
- [x] Convert ordered and unordered C++ maps to R lists.
19+
- [x] Roxygen support on C++ side.
20+
- [x] Allow `dimnames` atribute with matrices on C++ side.
21+
- [x] Support nullable `external_ptr<>`.
22+
- [x] Use values added to a vector with `push_back()` immediately.
23+
- [x] Support bidirectional passing of complex numbers/vectors.
24+
- [x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while cpp11's do not).
25+
- [x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and https://github.com/r-lib/cpp11/pull/430).
1226

1327
## Using cpp4r in a package
1428

@@ -19,7 +33,6 @@ LinkingTo: cpp4r
1933
```
2034

2135
Then decorate C++ functions you want to expose to R with `[[cpp4r::register]]`.
22-
*Note that this is a [C++11 attribute](https://en.cppreference.com/w/cpp/language/attributes), not a comment like is used in Rcpp.*
2336

2437
cpp4r is a header only library with no hard dependencies and does not use a shared library, so it is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
2538

@@ -28,63 +41,16 @@ This ensures the headers will remain unchanged until you explicitly update them.
2841

2942
## Getting started
3043

31-
See [vignette("cpp4r")](https://cpp4r.r-lib.org/articles/cpp4r.html) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
44+
See [vignette("cpp4r")](https://cpp4r.org/articles/cpp4r.html) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
3245

3346
## Getting help
3447

35-
[Posit Community](https://forum.posit.co/) is the best place to ask for help using cpp4r or interfacing C++ with R.
36-
37-
## Motivations
38-
39-
[Rcpp](https://cran.r-project.org/package=Rcpp) has been a widely successful project, however over the years a number of issues and additional C++ features have arisen.
40-
Adding these features to Rcpp would require a great deal of work, or in some cases would be impossible without severely breaking backwards compatibility.
41-
42-
**cpp4r** is a ground up rewrite of C++ bindings to R with different design trade-offs and features.
43-
44-
Changes that motivated cpp4r include:
45-
46-
- Enforcing [copy-on-write semantics](https://cpp4r.r-lib.org/articles/motivations.html#copy-on-write-semantics).
47-
- Improving the [safety](https://cpp4r.r-lib.org/articles/motivations.html#improve-safety) of using the R API from C++ code.
48-
- Supporting [ALTREP objects](https://cpp4r.r-lib.org/articles/motivations.html#altrep-support).
49-
- Using [UTF-8 strings](https://cpp4r.r-lib.org/articles/motivations.html#utf-8-everywhere) everywhere.
50-
- Applying newer [C++11 features](https://cpp4r.r-lib.org/articles/motivations.html#c11-features).
51-
- Having a more straightforward, [simpler implementation](https://cpp4r.r-lib.org/articles/motivations.html#simpler-implementation).
52-
- Faster [compilation time](https://cpp4r.r-lib.org/articles/motivations.html#compilation-speed) with lower memory requirements.
53-
- Being *completely* [header only](https://cpp4r.r-lib.org/articles/motivations.html#header-only) to avoid ABI issues.
54-
- Capable of [vendoring](https://cpp4r.r-lib.org/articles/motivations.html#vendoring) if desired.
55-
- More robust [protection](https://cpp4r.r-lib.org/articles/motivations.html#protection) using a much more efficient linked list data structure.
56-
- [Growing vectors](https://cpp4r.r-lib.org/articles/motivations.html#growing-vectors) more efficiently.
57-
58-
See [vignette("motivations")](https://cpp4r.r-lib.org/articles/motivations.html) for full details on the motivations for writing cpp4r.
59-
60-
## Conversion from Rcpp
48+
Please open an issue or email me. I will do my best to respond before 48 hours.
6149

62-
See [vignette("converting")](https://cpp4r.r-lib.org/articles/converting.html) if you are already familiar with Rcpp or have an existing package that uses Rcpp and want to convert it to use cpp4r.
50+
## Contributing
6351

64-
## Learning More
65-
66-
- [Welding R and C++](https://www.youtube.com/watch?v=_kq0N0FNIjA) - Presentation at SatRday Columbus [(slides)](https://speakerdeck.com/jimhester/cpp4r-welding-r-and-c-plus-plus)
67-
68-
69-
## Internals
70-
71-
See [vignette("internals")](https://cpp4r.r-lib.org/articles/internals.html) for details on the cpp4r implementation or if you would like to contribute to cpp4r.
52+
Contributions are welcome! Please see the [internals vignette](https://cpp4r.r-lib.org/articles/internals.html) for details about design choices and coding style.
7253

7354
## Code of Conduct
7455

7556
Please note that the cpp4r project is released with a [Contributor Code of Conduct](https://cpp4r.r-lib.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
76-
77-
## Thanks
78-
79-
cpp4r would not exist without Rcpp.
80-
Thanks to the Rcpp authors, Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou, Nathan Russell, Douglas Bates and John Chambers for their work writing and maintaining Rcpp.
81-
82-
## Clang format
83-
84-
To match GHA, use clang-format-12 to format C++ code. With systems that provide clang-format-14 or newer, you can use Docker:
85-
86-
```bash
87-
docker run --rm -v "$PWD":/work -w /work ubuntu:22.04 bash -lc "\
88-
apt-get update && apt-get install -y clang-format-12 && \
89-
find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' | xargs -r clang-format-12 -i"
90-
```

_pkgdown.yml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,5 @@
1-
url: https://cpp4r.r-lib.org
2-
3-
authors:
4-
"Jim Hester":
5-
href: http://jimhester.com
6-
71
template:
8-
package: tidytemplate
92
bootstrap: 5
103

11-
includes:
12-
in_header: |
13-
<script defer data-domain="cpp4r.r-lib.org,all.tidyverse.org" src="https://plausible.io/js/plausible.js"></script>
14-
15-
development:
16-
mode: auto
17-
18-
reference:
19-
- title: Registering C++ functions
20-
contents:
21-
- cpp_register
22-
- title: Compiling C++ code interactively
23-
contents:
24-
- cpp_source
25-
- title: Vendoring cpp4r
26-
contents:
27-
- cpp_vendor
28-
29-
navbar:
30-
type: default
31-
left:
32-
- text: Home
33-
href: index.html
34-
- text: Get started
35-
href: articles/cpp4r.html
36-
- text: Motivations
37-
href: articles/motivations.html
38-
- text: Converting
39-
href: articles/converting.html
40-
- text: FAQ
41-
href: articles/FAQ.html
42-
- text: Internals
43-
href: articles/internals.html
44-
- text: Reference
45-
href: reference/index.html
46-
- text: News
47-
menu:
48-
- text: "Change log"
49-
href: news/index.html
4+
url: https://cpp4r.org
5+
destination: docs
File renamed without changes.

cpp4rgaussjordan/.Rbuildignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
^cpp4rgaussjordan\.Rproj$
2+
^\.Rproj\.user$
3+
^LICENSE\.md$
4+
^vscode-install\.r$
5+
^\.gitignore$

cpp4rgaussjordan/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.Rproj.user

0 commit comments

Comments
 (0)