@@ -547,6 +547,7 @@ namespace attributes {
547547 // Name of target file and package
548548 const std::string& targetFile () const { return targetFile_; }
549549 const std::string& package () const { return package_; }
550+ const std::string& packageCpp () const { return packageCpp_; }
550551
551552 // Abstract interface for code generation
552553 virtual void writeBegin () = 0;
@@ -580,10 +581,10 @@ namespace attributes {
580581 return " RcppExport_validate" ;
581582 }
582583 std::string exportValidationFunctionRegisteredName () {
583- return package () + " _" + exportValidationFunction ();
584+ return packageCpp () + " _" + exportValidationFunction ();
584585 }
585586 std::string registerCCallableExportedName () {
586- return package () + " _RcppExport_registerCCallable" ;
587+ return packageCpp () + " _RcppExport_registerCCallable" ;
587588 }
588589
589590 // Commit the stream -- is a no-op if the existing code is identical
@@ -614,6 +615,7 @@ namespace attributes {
614615 private:
615616 std::string targetFile_;
616617 std::string package_;
618+ std::string packageCpp_;
617619 std::string commentPrefix_;
618620 std::string existingCode_;
619621 std::ostringstream codeStream_;
@@ -1706,6 +1708,7 @@ namespace attributes {
17061708 const std::string& commentPrefix)
17071709 : targetFile_(targetFile),
17081710 package_ (package),
1711+ packageCpp_(package),
17091712 commentPrefix_(commentPrefix),
17101713 hasCppInterface_(false ) {
17111714
@@ -1719,6 +1722,8 @@ namespace attributes {
17191722 existingCode_ = buffer.str ();
17201723 }
17211724
1725+ std::replace (packageCpp_.begin (), packageCpp_.end (), ' .' , ' _' );
1726+
17221727 // see if this is safe to overwite and throw if it isn't
17231728 if (!isSafeToOverwrite ())
17241729 throw Rcpp::file_exists (targetFile_);
@@ -1799,7 +1804,7 @@ namespace attributes {
17991804 attributes,
18001805 true ,
18011806 attributes.hasInterface (kInterfaceCpp ),
1802- package ());
1807+ packageCpp ());
18031808
18041809 // track cppExports and signatures (we use these at the end to
18051810 // generate the ValidateSignature and RegisterCCallable functions)
@@ -1866,7 +1871,6 @@ namespace attributes {
18661871 << " () { " << std::endl;
18671872 for (std::size_t i=0 ;i<cppExports_.size (); i++) {
18681873 const Attribute& attr = cppExports_[i];
1869- std::string name = package () + " _" + attr.exportedName ();
18701874 ostr () << registerCCallable (
18711875 4 ,
18721876 attr.exportedName (),
@@ -1889,8 +1893,8 @@ namespace attributes {
18891893 std::ostringstream ostr;
18901894 std::string indentStr (indent, ' ' );
18911895 ostr << indentStr << " R_RegisterCCallable(\" " << package () << " \" , "
1892- << " \" " << package () << " _" << exportedName << " \" , "
1893- << " (DL_FUNC)" << package () << " _" << name << " );" ;
1896+ << " \" " << packageCpp () << " _" << exportedName << " \" , "
1897+ << " (DL_FUNC)" << packageCpp () << " _" << name << " );" ;
18941898 return ostr.str ();
18951899 }
18961900
@@ -1930,7 +1934,7 @@ namespace attributes {
19301934
19311935 void CppExportsIncludeGenerator::writeBegin () {
19321936
1933- ostr () << " namespace " << package () << " {"
1937+ ostr () << " namespace " << packageCpp () << " {"
19341938 << std::endl << std::endl;
19351939
19361940 // Import Rcpp into this namespace. This allows declarations to
@@ -2020,7 +2024,7 @@ namespace attributes {
20202024 << std::endl;
20212025 ostr () << " " << ptrName << " = "
20222026 << " (" << fnType << " )"
2023- << getCCallable (package () + " _" + function.name ()) << " ;"
2027+ << getCCallable (packageCpp () + " _" + function.name ()) << " ;"
20242028 << std::endl;
20252029 ostr () << " }" << std::endl;
20262030 ostr () << " RObject __result;" << std::endl;
@@ -2088,12 +2092,12 @@ namespace attributes {
20882092 // the package header file (since it includes this file)
20892093 // and we transorm _types includes into local includes
20902094 std::string preamble = " #include \" ../inst/include/" ;
2091- std::string pkgInclude = preamble + package () + " .h\" " ;
2095+ std::string pkgInclude = preamble + packageCpp () + " .h\" " ;
20922096 if (includes[i] == pkgInclude)
20932097 continue ;
20942098
20952099 // check for _types
2096- std::string typesInclude = preamble + package () + " _types.h" ;
2100+ std::string typesInclude = preamble + packageCpp () + " _types.h" ;
20972101 if (includes[i].find (typesInclude) != std::string::npos)
20982102 {
20992103 std::string include = " #include \" " +
@@ -2126,7 +2130,7 @@ namespace attributes {
21262130 }
21272131
21282132 std::string CppExportsIncludeGenerator::getHeaderGuard () const {
2129- return " __" + package () + " _RcppExports_h__" ;
2133+ return " __" + packageCpp () + " _RcppExports_h__" ;
21302134 }
21312135
21322136 CppPackageIncludeGenerator::CppPackageIncludeGenerator (
@@ -2149,7 +2153,7 @@ namespace attributes {
21492153 ostr () << " #ifndef " << guard << std::endl;
21502154 ostr () << " #define " << guard << std::endl << std::endl;
21512155
2152- ostr () << " #include \" " << package () << kRcppExportsSuffix
2156+ ostr () << " #include \" " << packageCpp () << kRcppExportsSuffix
21532157 << " \" " << std::endl;
21542158
21552159 ostr () << std::endl;
@@ -2174,7 +2178,7 @@ namespace attributes {
21742178 }
21752179
21762180 std::string CppPackageIncludeGenerator::getHeaderGuard () const {
2177- return " __" + package () + " _h__" ;
2181+ return " __" + packageCpp () + " _h__" ;
21782182 }
21792183
21802184 RExportsGenerator::RExportsGenerator (const std::string& packageDir,
@@ -2230,7 +2234,7 @@ namespace attributes {
22302234 if (function.type ().isVoid ())
22312235 ostr () << " invisible(" ;
22322236 ostr () << " .Call(" ;
2233- ostr () << " '" << package () << " _" << function.name () << " ', "
2237+ ostr () << " '" << packageCpp () << " _" << function.name () << " ', "
22342238 << " PACKAGE = '" << package () << " '" ;
22352239
22362240 // add arguments
0 commit comments