Skip to content

Commit b6fc953

Browse files
committed
Merge pull request #403 from RcppCore/bugfix/generate-valid-cpp-function-name
Avoid invalid function names when generating C++ interfaces
2 parents 2ee93c4 + 06f0d7b commit b6fc953

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-10-01 JJ Allaire <[email protected]>
2+
3+
* src/attributes.cpp: Avoid invalid function names when
4+
generating C++ interfaces.
5+
16
2015-11-14 Dirk Eddelbuettel <[email protected]>
27

38
* DESCRIPTION: Release 0.12.2

inst/NEWS.Rd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
\newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}}
44
\newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}}
55

6+
\section{Changes in Rcpp version 0.12.3 (Unreleased)}{
7+
\itemize{
8+
\item Changes in Rcpp Attributes:
9+
\itemize{
10+
\item Avoid invalid function names when generating C++ interfaces.
11+
}
12+
}
13+
}
14+
615
\section{Changes in Rcpp version 0.12.2 (2015-11-14)}{
716
\itemize{
817
\item Changes in Rcpp API:

src/attributes.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ namespace attributes {
343343
return function().name();
344344
}
345345
}
346+
347+
std::string exportedCppName() const {
348+
std::string name = exportedName();
349+
std::replace(name.begin(), name.end(), '.', '_');
350+
return name;
351+
}
346352

347353
bool rng() const {
348354
Param rngParam = paramNamed(kExportRng);
@@ -1795,7 +1801,7 @@ namespace attributes {
17951801
it = attributes.begin(); it != attributes.end(); ++it) {
17961802
if (it->isExportedFunction()) {
17971803
// add it to the list if it's not hidden
1798-
Function fun = it->function().renamedTo(it->exportedName());
1804+
Function fun = it->function().renamedTo(it->exportedCppName());
17991805
if (!fun.isHidden())
18001806
cppExports_.push_back(*it);
18011807
}
@@ -1978,7 +1984,7 @@ namespace attributes {
19781984
if (it->isExportedFunction()) {
19791985

19801986
Function function =
1981-
it->function().renamedTo(it->exportedName());
1987+
it->function().renamedTo(it->exportedCppName());
19821988

19831989
// if it's hidden then don't generate a C++ interface
19841990
if (function.isHidden())

0 commit comments

Comments
 (0)