Skip to content

Commit 8ee112a

Browse files
committed
fix clang format
1 parent c016918 commit 8ee112a

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

cpp11test/src/test-integers.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ context("integers-C++") {
148148
expect_true(x.value(0) == 1);
149149
expect_true(x.value(1) == 2);
150150
expect_true(x.value(2) == 3);
151-
152-
// Test that value() works with C-style formatting (this was the original issue in #453)
151+
152+
// Test that value() works with C-style formatting (this was the original issue in
153+
// #453)
153154
expect_true(x.value(0) == x[0]);
154155
expect_true(x.value(1) == x[1]);
155156
expect_true(x.value(2) == x[2]);
@@ -306,20 +307,20 @@ context("integers-C++") {
306307
expect_true(x.value(0) == 0);
307308
expect_true(x.value(1) == 10);
308309
expect_true(x.value(2) == 20);
309-
310+
310311
// Test that explicit cast works
311312
expect_true((int)x[0] == 0);
312313
expect_true((int)x[1] == 10);
313314
expect_true((int)x[2] == 20);
314-
315+
315316
// Test that auto assignment works (triggers implicit conversion)
316317
int val0 = x[0];
317-
int val1 = x[1];
318+
int val1 = x[1];
318319
int val2 = x[2];
319320
expect_true(val0 == 0);
320321
expect_true(val1 == 10);
321322
expect_true(val2 == 20);
322-
323+
323324
// Test that value() and operator[] return equivalent results
324325
expect_true(x.value(0) == (int)x[0]);
325326
expect_true(x.value(1) == (int)x[1]);
@@ -331,17 +332,17 @@ context("integers-C++") {
331332
// Demo function to show the three ways to handle the proxy issue
332333
// To use this function:
333334
// 1. Run cpp11::cpp_register() to regenerate R bindings
334-
// 2. Rebuild and reinstall the package
335+
// 2. Rebuild and reinstall the package
335336
// 3. Call test_proxy_issue_demo() from R
336337
void test_proxy_issue_demo() {
337338
cpp11::writable::integers x;
338339
for (int i = 0; i < 5; i++) {
339340
x.push_back(i);
340-
341+
341342
// These all work correctly:
342343
Rprintf("Method 1 - cast: x[%d] = %d\n", i, (int)x[i]);
343344
Rprintf("Method 2 - value(): x[%d] = %d\n", i, x.value(i));
344-
345+
345346
// This also works (auto triggers implicit conversion):
346347
int val = x[i];
347348
Rprintf("Method 3 - auto: x[%d] = %d\n", i, val);

inst/include/cpp11/integers.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,23 @@ inline integers as_integers(SEXP x) {
105105

106106
// Note: Proxy Behavior in writable::integers
107107
//
108-
// When using writable::integers, operator[] returns a proxy object that allows
109-
// both reading and writing. For cases where you need the actual int value
110-
// (e.g., when using with C-style variadic functions like Rprintf), use one of
108+
// When using writable::integers, operator[] returns a proxy object that allows
109+
// both reading and writing. For cases where you need the actual int value
110+
// (e.g., when using with C-style variadic functions like Rprintf), use one of
111111
// these three approaches:
112112
//
113113
// 1. Direct value access: vec.value(i) [Recommended]
114-
// 2. Explicit cast: (int)vec[i]
114+
// 2. Explicit cast: (int)vec[i]
115115
// 3. Auto with explicit type: int val = vec[i];
116116
//
117117
// Example demonstrating the issue and solutions:
118118
// writable::integers vec;
119119
// vec.push_back(42);
120-
//
120+
//
121121
// // This may print garbage due to proxy object:
122122
// // Rprintf("Value: %d\n", vec[0]); // DON'T DO THIS
123-
//
123+
//
124124
// // These all work correctly:
125125
// Rprintf("Value: %d\n", vec.value(0)); // Recommended
126-
// Rprintf("Value: %d\n", (int)vec[0]); // Also works
126+
// Rprintf("Value: %d\n", (int)vec[0]); // Also works
127127
// int val = vec[0]; Rprintf("Value: %d\n", val); // Also works

inst/include/cpp11/list_of.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ class list_of : public writable::list {
5454

5555
#ifdef LONG_VECTOR_SUPPORT
5656
proxy operator[](int pos) {
57-
return {writable::list::operator[](static_cast<R_xlen_t>(pos))};
57+
return { writable::list::operator[](static_cast<R_xlen_t>(pos)) };
5858
}
5959
#endif
6060

6161
proxy operator[](R_xlen_t pos) { return writable::list::operator[](pos); }
6262

63-
proxy operator[](const char* pos) { return {writable::list::operator[](pos)}; }
63+
proxy operator[](const char* pos) {
64+
return { writable::list::operator[](pos) };
65+
}
6466

6567
proxy operator[](const std::string& pos) {
6668
return writable::list::operator[](pos.c_str());

tests/testthat/single_error.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[[cpp11::register]] int foo() { return 1 }
1+
[[cpp11::register]] int foo(){return 1}

0 commit comments

Comments
 (0)