Skip to content

Commit c260499

Browse files
authored
Merge pull request #1132 from RcppCore/feature/dot_in_name
support include files for package names with dot (closes #1129)
2 parents f4342ae + fb91e5a commit c260499

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2021-01-17 Dirk Eddelbuettel <[email protected]>
2+
3+
* DESCRIPTION (Version, Date): Roll minor version
4+
* inst/include/Rcpp/config.h: Idem
5+
16
2021-01-16 Dirk Eddelbuettel <[email protected]>
27

38
* tests/tinytest.R: Test for CODECOV when deciding to run extensive
@@ -12,6 +17,8 @@
1217
* R/RcppClass.R: Idem
1318
* R/RcppLdpath.R: Idem
1419

20+
* src/attributes.cpp: Support include files with dots in package name
21+
1522
2021-01-14 Dirk Eddelbuettel <[email protected]>
1623

1724
* DESCRIPTION (Date, Version): Release 1.0.6

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 1.0.6
4-
Date: 2021-01-14
3+
Version: 1.0.6.1
4+
Date: 2021-01-17
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou,
66
Nathan Russell, Douglas Bates and John Chambers
77
Maintainer: Dirk Eddelbuettel <[email protected]>

inst/include/Rcpp/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define RCPP_VERSION_STRING "1.0.6"
3131

3232
// the current source snapshot
33-
#define RCPP_DEV_VERSION RcppDevVersion(1,0,6,0)
34-
#define RCPP_DEV_VERSION_STRING "1.0.6.0"
33+
#define RCPP_DEV_VERSION RcppDevVersion(1,0,6,1)
34+
#define RCPP_DEV_VERSION_STRING "1.0.6.1"
3535

3636
#endif

src/attributes.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,9 @@ namespace attributes {
633633
// if it wasn't (throws exception on io error)
634634
bool commit(const std::string& preamble = std::string());
635635

636+
// Convert a dot in package name to underscore for use in header file name
637+
std::string dotNameHelper(const std::string & name) const;
638+
636639
private:
637640

638641
// Private virtual for doWriteFunctions so the base class
@@ -717,7 +720,7 @@ namespace attributes {
717720
std::string includeDir_;
718721
};
719722

720-
// Class which manages generating PackageName_RcppExports.h header file
723+
// Class which manages generating PackageName.h header file
721724
class CppPackageIncludeGenerator : public ExportsGenerator {
722725
public:
723726
CppPackageIncludeGenerator(const std::string& packageDir,
@@ -1894,6 +1897,13 @@ namespace attributes {
18941897
return removeFile(targetFile_);
18951898
}
18961899

1900+
// Convert a possible dot in package name to underscore as needed for header file
1901+
std::string ExportsGenerator::dotNameHelper(const std::string & name) const {
1902+
std::string newname(name);
1903+
std::replace(newname.begin(), newname.end(), '.', '_');
1904+
return newname;
1905+
}
1906+
18971907
CppExportsGenerator::CppExportsGenerator(const std::string& packageDir,
18981908
const std::string& package,
18991909
const std::string& fileSep)
@@ -2128,7 +2138,7 @@ namespace attributes {
21282138
const std::string& fileSep)
21292139
: ExportsGenerator(
21302140
packageDir + fileSep + "inst" + fileSep + "include" +
2131-
fileSep + package + kRcppExportsSuffix,
2141+
fileSep + dotNameHelper(package) + kRcppExportsSuffix,
21322142
package,
21332143
"//")
21342144
{
@@ -2346,7 +2356,7 @@ namespace attributes {
23462356
const std::string& fileSep)
23472357
: ExportsGenerator(
23482358
packageDir + fileSep + "inst" + fileSep + "include" +
2349-
fileSep + package + ".h",
2359+
fileSep + dotNameHelper(package) + ".h",
23502360
package,
23512361
"//")
23522362
{
@@ -2359,7 +2369,6 @@ namespace attributes {
23592369
std::string guard = getHeaderGuard(); // #nocov start
23602370
ostr() << "#ifndef " << guard << std::endl;
23612371
ostr() << "#define " << guard << std::endl << std::endl;
2362-
23632372
ostr() << "#include \"" << packageCpp() << kRcppExportsSuffix
23642373
<< "\"" << std::endl;
23652374

0 commit comments

Comments
 (0)