Skip to content

Commit 7ba91ea

Browse files
committed
Replace // [[Rcpp::export]] with // [[Rcpp::export]]
* Link to cpp11 * Add C++11 to SystemRequirements * Define `STRICT_R_HEADERS` and `R_NO_REMAP` * Include `cpp11` * Define `as_cpp()` for `DbResult*` and `SqliteResult*`
1 parent 3d26f20 commit 7ba91ea

Some content is hidden

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

47 files changed

+477
-418
lines changed

DESCRIPTION

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,22 @@ Suggests:
5656
xml2
5757
LinkingTo:
5858
plogr (>= 0.2.0),
59-
Rcpp
59+
Rcpp,
60+
cpp11
61+
SystemRequirements: C++11
6062
VignetteBuilder:
6163
knitr
6264
Encoding: UTF-8
6365
Roxygen: list(markdown = TRUE)
64-
RoxygenNote: 7.1.1.9001
66+
RoxygenNote: 7.1.2
6567
Collate:
66-
'RcppExports.R'
6768
'SQLiteConnection.R'
6869
'SQLiteDriver.R'
6970
'SQLiteResult.R'
7071
'coerce.R'
7172
'connect.R'
7273
'copy.R'
74+
'cpp11.R'
7375
'datasetsDb.R'
7476
'deprecated.R'
7577
'export.R'

R/RcppExports.R

-86
This file was deleted.

R/cpp11.R

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Generated by cpp11: do not edit by hand
2+
3+
connection_connect <- function(path, allow_ext, flags, vfs, with_alt_types) {
4+
.Call(`_RSQLite_connection_connect`, path, allow_ext, flags, vfs, with_alt_types)
5+
}
6+
7+
connection_valid <- function(con_) {
8+
.Call(`_RSQLite_connection_valid`, con_)
9+
}
10+
11+
connection_release <- function(con_) {
12+
invisible(.Call(`_RSQLite_connection_release`, con_))
13+
}
14+
15+
connection_copy_database <- function(from, to) {
16+
invisible(.Call(`_RSQLite_connection_copy_database`, from, to))
17+
}
18+
19+
connection_import_file <- function(con, name, value, sep, eol, skip) {
20+
.Call(`_RSQLite_connection_import_file`, con, name, value, sep, eol, skip)
21+
}
22+
23+
set_busy_handler <- function(con, r_callback) {
24+
invisible(.Call(`_RSQLite_set_busy_handler`, con, r_callback))
25+
}
26+
27+
extension_load <- function(con, file, entry_point) {
28+
invisible(.Call(`_RSQLite_extension_load`, con, file, entry_point))
29+
}
30+
31+
result_create <- function(con, sql) {
32+
.Call(`_RSQLite_result_create`, con, sql)
33+
}
34+
35+
result_release <- function(res) {
36+
invisible(.Call(`_RSQLite_result_release`, res))
37+
}
38+
39+
result_valid <- function(res_) {
40+
.Call(`_RSQLite_result_valid`, res_)
41+
}
42+
43+
result_fetch <- function(res, n) {
44+
.Call(`_RSQLite_result_fetch`, res, n)
45+
}
46+
47+
result_bind <- function(res, params) {
48+
invisible(.Call(`_RSQLite_result_bind`, res, params))
49+
}
50+
51+
result_has_completed <- function(res) {
52+
.Call(`_RSQLite_result_has_completed`, res)
53+
}
54+
55+
result_rows_fetched <- function(res) {
56+
.Call(`_RSQLite_result_rows_fetched`, res)
57+
}
58+
59+
result_rows_affected <- function(res) {
60+
.Call(`_RSQLite_result_rows_affected`, res)
61+
}
62+
63+
result_column_info <- function(res) {
64+
.Call(`_RSQLite_result_column_info`, res)
65+
}
66+
67+
result_get_placeholder_names <- function(res) {
68+
.Call(`_RSQLite_result_get_placeholder_names`, res)
69+
}
70+
71+
rsqliteVersion <- function() {
72+
.Call(`_RSQLite_rsqliteVersion`)
73+
}
74+
75+
init_logging <- function(log_level) {
76+
invisible(.Call(`_RSQLite_init_logging`, log_level))
77+
}

src/DbColumn.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbColumn.h"
37
#include "DbColumnDataSource.h"

src/DbColumn.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef DB_COLUMN_H
25
#define DB_COLUMN_H
36

src/DbColumnDataSource.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbColumnDataSource.h"
37

src/DbColumnDataSource.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef DB_COLUMNDATASOURCE_H
25
#define DB_COLUMNDATASOURCE_H
36

src/DbColumnDataSourceFactory.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbColumnDataSourceFactory.h"
37

src/DbColumnDataSourceFactory.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef DB_COLUMNDATASOURCEFACTORY_H
25
#define DB_COLUMNDATASOURCEFACTORY_H
36

src/DbColumnDataType.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef RSQLITE_COLUMNDATATYPE_H
25
#define RSQLITE_COLUMNDATATYPE_H
36

src/DbColumnStorage.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbColumnStorage.h"
37
#include "DbColumnDataSource.h"

src/DbColumnStorage.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef DB_COLUMNSTORAGE_H
25
#define DB_COLUMNSTORAGE_H
36

src/DbConnection.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbConnection.h"
37

src/DbConnection.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef __RSQLITE_SQLITE_CONNECTION__
25
#define __RSQLITE_SQLITE_CONNECTION__
36

src/DbDataFrame.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbDataFrame.h"
37
#include "DbColumn.h"

src/DbDataFrame.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#ifndef DB_DATAFRAME_H
25
#define DB_DATAFRAME_H
36

src/DbResult.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#include "pch.h"
26
#include "DbResult.h"
37
#include "DbConnection.h"

src/DbResult.h

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#ifndef __RDBI_DB_RESULT__
26
#define __RDBI_DB_RESULT__
37

src/DbResultImpl.h

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#include "SqliteResultImpl.h"

src/DbResultImplDecl.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
class SqliteResultImpl;
25
typedef SqliteResultImpl DbResultImpl;

src/Makevars

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ PKG_CPPFLAGS=-I. -Ivendor \
99
-DSQLITE_ENABLE_STAT4 \
1010
-DSQLITE_SOUNDEX \
1111
-DSQLITE_USE_URI=1 \
12-
-DRCPP_DEFAULT_INCLUDE_CALL=false \
13-
-DRCPP_USING_UTF8_ERROR_STRING \
1412
-DBOOST_NO_AUTO_PTR \
1513
-DSQLITE_MAX_LENGTH=2147483647 \
1614
-DHAVE_USLEEP=1

src/RSQLite.h

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
4+
15
#ifndef RSQLite_RSQLite_H
26
#define RSQLite_RSQLite_H
37

src/RSQLite_types.h

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define STRICT_R_HEADERS
2+
#define R_NO_REMAP
3+
14
#include "pch.h"
25

36
#ifndef __RSQLITE_TYPES__
@@ -9,17 +12,33 @@
912
#include "DbResult.h"
1013
#include "SqliteResult.h"
1114

12-
namespace Rcpp {
15+
namespace cpp11 {
1316

14-
template<>
15-
DbConnection* as(SEXP x);
17+
template <typename T>
18+
using enable_if_dbres_ptr = typename std::enable_if<
19+
std::is_same<DbResult*, T>::value, T>::type;
1620

17-
template<>
18-
DbResult* as(SEXP x);
21+
template <typename T>
22+
enable_if_dbres_ptr<T> as_cpp(SEXP x) {
23+
DbResult* result = (DbResult*)(R_ExternalPtrAddr(x));
24+
if (!result)
25+
stop("Invalid result set");
26+
return result;
27+
}
1928

20-
template<>
21-
SqliteResult* as(SEXP x);
29+
template <typename T>
30+
using enable_if_sqliteres_ptr = typename std::enable_if<
31+
std::is_same<SqliteResult*, T>::value, T>::type;
2232

33+
template <typename T>
34+
enable_if_sqliteres_ptr<T> as_cpp(SEXP x) {
35+
SqliteResult* result = (SqliteResult*)(R_ExternalPtrAddr(x));
36+
if (!result)
37+
stop("Invalid result set");
38+
return result;
2339
}
2440

41+
} // namespace cpp11
42+
43+
2544
#endif

0 commit comments

Comments
 (0)