@@ -547,6 +547,7 @@ namespace attributes {
547
547
// Name of target file and package
548
548
const std::string& targetFile () const { return targetFile_; }
549
549
const std::string& package () const { return package_; }
550
+ const std::string& packageCpp () const { return packageCpp_; }
550
551
551
552
// Abstract interface for code generation
552
553
virtual void writeBegin () = 0;
@@ -580,10 +581,10 @@ namespace attributes {
580
581
return " RcppExport_validate" ;
581
582
}
582
583
std::string exportValidationFunctionRegisteredName () {
583
- return package () + " _" + exportValidationFunction ();
584
+ return packageCpp () + " _" + exportValidationFunction ();
584
585
}
585
586
std::string registerCCallableExportedName () {
586
- return package () + " _RcppExport_registerCCallable" ;
587
+ return packageCpp () + " _RcppExport_registerCCallable" ;
587
588
}
588
589
589
590
// Commit the stream -- is a no-op if the existing code is identical
@@ -614,6 +615,7 @@ namespace attributes {
614
615
private:
615
616
std::string targetFile_;
616
617
std::string package_;
618
+ std::string packageCpp_;
617
619
std::string commentPrefix_;
618
620
std::string existingCode_;
619
621
std::ostringstream codeStream_;
@@ -1706,6 +1708,7 @@ namespace attributes {
1706
1708
const std::string& commentPrefix)
1707
1709
: targetFile_(targetFile),
1708
1710
package_ (package),
1711
+ packageCpp_(package),
1709
1712
commentPrefix_(commentPrefix),
1710
1713
hasCppInterface_(false ) {
1711
1714
@@ -1719,6 +1722,8 @@ namespace attributes {
1719
1722
existingCode_ = buffer.str ();
1720
1723
}
1721
1724
1725
+ std::replace (packageCpp_.begin (), packageCpp_.end (), ' .' , ' _' );
1726
+
1722
1727
// see if this is safe to overwite and throw if it isn't
1723
1728
if (!isSafeToOverwrite ())
1724
1729
throw Rcpp::file_exists (targetFile_);
@@ -1799,7 +1804,7 @@ namespace attributes {
1799
1804
attributes,
1800
1805
true ,
1801
1806
attributes.hasInterface (kInterfaceCpp ),
1802
- package ());
1807
+ packageCpp ());
1803
1808
1804
1809
// track cppExports and signatures (we use these at the end to
1805
1810
// generate the ValidateSignature and RegisterCCallable functions)
@@ -1866,7 +1871,6 @@ namespace attributes {
1866
1871
<< " () { " << std::endl;
1867
1872
for (std::size_t i=0 ;i<cppExports_.size (); i++) {
1868
1873
const Attribute& attr = cppExports_[i];
1869
- std::string name = package () + " _" + attr.exportedName ();
1870
1874
ostr () << registerCCallable (
1871
1875
4 ,
1872
1876
attr.exportedName (),
@@ -1889,8 +1893,8 @@ namespace attributes {
1889
1893
std::ostringstream ostr;
1890
1894
std::string indentStr (indent, ' ' );
1891
1895
ostr << indentStr << " R_RegisterCCallable(\" " << package () << " \" , "
1892
- << " \" " << package () << " _" << exportedName << " \" , "
1893
- << " (DL_FUNC)" << package () << " _" << name << " );" ;
1896
+ << " \" " << packageCpp () << " _" << exportedName << " \" , "
1897
+ << " (DL_FUNC)" << packageCpp () << " _" << name << " );" ;
1894
1898
return ostr.str ();
1895
1899
}
1896
1900
@@ -1930,7 +1934,7 @@ namespace attributes {
1930
1934
1931
1935
void CppExportsIncludeGenerator::writeBegin () {
1932
1936
1933
- ostr () << " namespace " << package () << " {"
1937
+ ostr () << " namespace " << packageCpp () << " {"
1934
1938
<< std::endl << std::endl;
1935
1939
1936
1940
// Import Rcpp into this namespace. This allows declarations to
@@ -2020,7 +2024,7 @@ namespace attributes {
2020
2024
<< std::endl;
2021
2025
ostr () << " " << ptrName << " = "
2022
2026
<< " (" << fnType << " )"
2023
- << getCCallable (package () + " _" + function.name ()) << " ;"
2027
+ << getCCallable (packageCpp () + " _" + function.name ()) << " ;"
2024
2028
<< std::endl;
2025
2029
ostr () << " }" << std::endl;
2026
2030
ostr () << " RObject __result;" << std::endl;
@@ -2088,12 +2092,12 @@ namespace attributes {
2088
2092
// the package header file (since it includes this file)
2089
2093
// and we transorm _types includes into local includes
2090
2094
std::string preamble = " #include \" ../inst/include/" ;
2091
- std::string pkgInclude = preamble + package () + " .h\" " ;
2095
+ std::string pkgInclude = preamble + packageCpp () + " .h\" " ;
2092
2096
if (includes[i] == pkgInclude)
2093
2097
continue ;
2094
2098
2095
2099
// check for _types
2096
- std::string typesInclude = preamble + package () + " _types.h" ;
2100
+ std::string typesInclude = preamble + packageCpp () + " _types.h" ;
2097
2101
if (includes[i].find (typesInclude) != std::string::npos)
2098
2102
{
2099
2103
std::string include = " #include \" " +
@@ -2126,7 +2130,7 @@ namespace attributes {
2126
2130
}
2127
2131
2128
2132
std::string CppExportsIncludeGenerator::getHeaderGuard () const {
2129
- return " __" + package () + " _RcppExports_h__" ;
2133
+ return " __" + packageCpp () + " _RcppExports_h__" ;
2130
2134
}
2131
2135
2132
2136
CppPackageIncludeGenerator::CppPackageIncludeGenerator (
@@ -2149,7 +2153,7 @@ namespace attributes {
2149
2153
ostr () << " #ifndef " << guard << std::endl;
2150
2154
ostr () << " #define " << guard << std::endl << std::endl;
2151
2155
2152
- ostr () << " #include \" " << package () << kRcppExportsSuffix
2156
+ ostr () << " #include \" " << packageCpp () << kRcppExportsSuffix
2153
2157
<< " \" " << std::endl;
2154
2158
2155
2159
ostr () << std::endl;
@@ -2174,7 +2178,7 @@ namespace attributes {
2174
2178
}
2175
2179
2176
2180
std::string CppPackageIncludeGenerator::getHeaderGuard () const {
2177
- return " __" + package () + " _h__" ;
2181
+ return " __" + packageCpp () + " _h__" ;
2178
2182
}
2179
2183
2180
2184
RExportsGenerator::RExportsGenerator (const std::string& packageDir,
@@ -2230,7 +2234,7 @@ namespace attributes {
2230
2234
if (function.type ().isVoid ())
2231
2235
ostr () << " invisible(" ;
2232
2236
ostr () << " .Call(" ;
2233
- ostr () << " '" << package () << " _" << function.name () << " ', "
2237
+ ostr () << " '" << packageCpp () << " _" << function.name () << " ', "
2234
2238
<< " PACKAGE = '" << package () << " '" ;
2235
2239
2236
2240
// add arguments
0 commit comments